Skip to content

Commit e7a1cbc

Browse files
committed
drm/gem-shmem: Do not map s/g table by default
The vast majority of drivers that use GEM-SHMEM helpers do not use an s/g table for imported buffers; specifically all drivers that use DRM_GEM_SHMEM_DRIVER_OPS. Therefore convert the initializer macro to DRM_GEM_SHMEM_DRIVER_OPS_NO_MAP_SGT and remove the latter. This helps to avoid swiotbl errors, such as seen with some Aspeed systems ast 0000:07:00.0: swiotlb buffer is full (sz: 3145728 bytes), total 32768 (slots), used 0 (slots) The error is caused by the system's limited DMA capabilities and can happen with any GEM-SHMEM-based driver. It results in a performance penalty. In the case of vgem and vkms, the devices do not support DMA at all, which can result in failure to map the buffer object into the kernel's address space. [1][2] Avoiding the s/g table fixes this problem. The other drivers based on GEM-SHMEM, imagination, lima, panfrost, panthor, v3d and virtio, use the s/g table of imported buffers. Neither driver uses the default initializer, so they won't be affected by this change. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reported-by: Zenghui Yu <zenghui.yu@linux.dev> Closes: https://lore.kernel.org/dri-devel/6d22bce3-4533-4cfa-96ba-64352b715741@linux.dev/ # [1] Reported-by: José Expósito <jose.exposito89@gmail.com> Closes: https://lore.kernel.org/dri-devel/20250311172054.2903-1-jose.exposito89@gmail.com/ # [2] Tested-by: Zenghui Yu <zenghui.yu@linux.dev> Reviewed-by: Christian König <christian.koenig@amd.com> Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com> Link: https://lore.kernel.org/r/20250630143537.309052-1-tzimmermann@suse.de
1 parent cb86354 commit e7a1cbc

3 files changed

Lines changed: 5 additions & 17 deletions

File tree

drivers/gpu/drm/ast/ast_drv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static const struct drm_driver ast_driver = {
6464
.minor = DRIVER_MINOR,
6565
.patchlevel = DRIVER_PATCHLEVEL,
6666

67-
DRM_GEM_SHMEM_DRIVER_OPS_NO_MAP_SGT,
67+
DRM_GEM_SHMEM_DRIVER_OPS,
6868
DRM_FBDEV_SHMEM_DRIVER_OPS,
6969
};
7070

drivers/gpu/drm/udl/udl_drv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static const struct drm_driver driver = {
5757

5858
/* GEM hooks */
5959
.fops = &udl_driver_fops,
60-
DRM_GEM_SHMEM_DRIVER_OPS_NO_MAP_SGT,
60+
DRM_GEM_SHMEM_DRIVER_OPS,
6161
DRM_FBDEV_SHMEM_DRIVER_OPS,
6262

6363
.name = DRIVER_NAME,

include/drm/drm_gem_shmem_helper.h

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -293,23 +293,11 @@ struct drm_gem_object *drm_gem_shmem_prime_import_no_map(struct drm_device *dev,
293293
/**
294294
* DRM_GEM_SHMEM_DRIVER_OPS - Default shmem GEM operations
295295
*
296-
* This macro provides a shortcut for setting the shmem GEM operations in
297-
* the &drm_driver structure.
296+
* This macro provides a shortcut for setting the shmem GEM operations
297+
* in the &drm_driver structure. Drivers that do not require an s/g table
298+
* for imported buffers should use this.
298299
*/
299300
#define DRM_GEM_SHMEM_DRIVER_OPS \
300-
.gem_prime_import_sg_table = drm_gem_shmem_prime_import_sg_table, \
301-
.dumb_create = drm_gem_shmem_dumb_create
302-
303-
/**
304-
* DRM_GEM_SHMEM_DRIVER_OPS_NO_MAP_SGT - shmem GEM operations
305-
* without mapping sg_table on
306-
* imported buffer.
307-
*
308-
* This macro provides a shortcut for setting the shmem GEM operations in
309-
* the &drm_driver structure for drivers that do not require a sg_table on
310-
* imported buffers.
311-
*/
312-
#define DRM_GEM_SHMEM_DRIVER_OPS_NO_MAP_SGT \
313301
.gem_prime_import = drm_gem_shmem_prime_import_no_map, \
314302
.dumb_create = drm_gem_shmem_dumb_create
315303

0 commit comments

Comments
 (0)