mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-16 17:57:38 -04:00
drm/shmem-helper: Import dmabuf without mapping its sg_table
[WHY] 1. Drivers using DRM_GEM_SHADOW_PLANE_HELPER_FUNCS and DRM_GEM_SHMEM_DRIVER_OPS (e.g., udl, ast) do not require sg_table import. They only need dma_buf_vmap() to access the shared buffer's kernel virtual address. 2. On certain Aspeed-based boards, a dma_mask of 0xffff_ffff may trigger SWIOTLB during dmabuf import. However, IO_TLB_SEGSIZE restricts the maximum DMA streaming mapping memory, resulting in errors like: ast 0000:07:00.0: swiotlb buffer is full (sz: 3145728 bytes), total 32768 (slots), used 0 (slots) [HOW] Provide a gem_prime_import implementation without sg_table mapping to avoid issues (e.g., "swiotlb buffer is full"). Drivers that do not require sg_table can adopt this. Signed-off-by: Shixiong Ou <oushixiong@kylinos.cn> Acked-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Link: https://lore.kernel.org/r/20250522070714.439824-1-oushixiong1025@163.com
This commit is contained in:
committed by
Thomas Zimmermann
parent
6048f55876
commit
660cd44659
@@ -287,6 +287,8 @@ drm_gem_shmem_prime_import_sg_table(struct drm_device *dev,
|
||||
struct sg_table *sgt);
|
||||
int drm_gem_shmem_dumb_create(struct drm_file *file, struct drm_device *dev,
|
||||
struct drm_mode_create_dumb *args);
|
||||
struct drm_gem_object *drm_gem_shmem_prime_import_no_map(struct drm_device *dev,
|
||||
struct dma_buf *buf);
|
||||
|
||||
/**
|
||||
* DRM_GEM_SHMEM_DRIVER_OPS - Default shmem GEM operations
|
||||
@@ -298,4 +300,17 @@ int drm_gem_shmem_dumb_create(struct drm_file *file, struct drm_device *dev,
|
||||
.gem_prime_import_sg_table = drm_gem_shmem_prime_import_sg_table, \
|
||||
.dumb_create = drm_gem_shmem_dumb_create
|
||||
|
||||
/**
|
||||
* DRM_GEM_SHMEM_DRIVER_OPS_NO_MAP_SGT - shmem GEM operations
|
||||
* without mapping sg_table on
|
||||
* imported buffer.
|
||||
*
|
||||
* This macro provides a shortcut for setting the shmem GEM operations in
|
||||
* the &drm_driver structure for drivers that do not require a sg_table on
|
||||
* imported buffers.
|
||||
*/
|
||||
#define DRM_GEM_SHMEM_DRIVER_OPS_NO_MAP_SGT \
|
||||
.gem_prime_import = drm_gem_shmem_prime_import_no_map, \
|
||||
.dumb_create = drm_gem_shmem_dumb_create
|
||||
|
||||
#endif /* __DRM_GEM_SHMEM_HELPER_H__ */
|
||||
|
||||
@@ -100,6 +100,9 @@ struct dma_buf *drm_gem_prime_export(struct drm_gem_object *obj,
|
||||
unsigned long drm_prime_get_contiguous_size(struct sg_table *sgt);
|
||||
|
||||
/* helper functions for importing */
|
||||
bool drm_gem_is_prime_exported_dma_buf(struct drm_device *dev,
|
||||
struct dma_buf *dma_buf);
|
||||
|
||||
struct drm_gem_object *drm_gem_prime_import_dev(struct drm_device *dev,
|
||||
struct dma_buf *dma_buf,
|
||||
struct device *attach_dev);
|
||||
|
||||
Reference in New Issue
Block a user