Skip to content

Commit cce16fc

Browse files
author
Thomas Zimmermann
committed
drm/gem-framebuffer: Use dma_buf from GEM object instance
Avoid dereferencing struct drm_gem_object.import_attach for the imported dma-buf. The dma_buf field in the GEM object instance refers to the same buffer. Prepares to make import_attach optional. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Anusha Srivatsa <asrivats@redhat.com> Reviewed-by: Christian König <christian.koenig@amd.com> Link: https://patchwork.freedesktop.org/patch/msgid/20250226172457.217725-8-tzimmermann@suse.de
1 parent 3d672f4 commit cce16fc

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

drivers/gpu/drm/drm_gem_framebuffer_helper.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,6 @@ EXPORT_SYMBOL(drm_gem_fb_vunmap);
419419
static void __drm_gem_fb_end_cpu_access(struct drm_framebuffer *fb, enum dma_data_direction dir,
420420
unsigned int num_planes)
421421
{
422-
struct dma_buf_attachment *import_attach;
423422
struct drm_gem_object *obj;
424423
int ret;
425424

@@ -428,10 +427,9 @@ static void __drm_gem_fb_end_cpu_access(struct drm_framebuffer *fb, enum dma_dat
428427
obj = drm_gem_fb_get_obj(fb, num_planes);
429428
if (!obj)
430429
continue;
431-
import_attach = obj->import_attach;
432430
if (!drm_gem_is_imported(obj))
433431
continue;
434-
ret = dma_buf_end_cpu_access(import_attach->dmabuf, dir);
432+
ret = dma_buf_end_cpu_access(obj->dma_buf, dir);
435433
if (ret)
436434
drm_err(fb->dev, "dma_buf_end_cpu_access(%u, %d) failed: %d\n",
437435
ret, num_planes, dir);
@@ -454,7 +452,6 @@ static void __drm_gem_fb_end_cpu_access(struct drm_framebuffer *fb, enum dma_dat
454452
*/
455453
int drm_gem_fb_begin_cpu_access(struct drm_framebuffer *fb, enum dma_data_direction dir)
456454
{
457-
struct dma_buf_attachment *import_attach;
458455
struct drm_gem_object *obj;
459456
unsigned int i;
460457
int ret;
@@ -465,10 +462,9 @@ int drm_gem_fb_begin_cpu_access(struct drm_framebuffer *fb, enum dma_data_direct
465462
ret = -EINVAL;
466463
goto err___drm_gem_fb_end_cpu_access;
467464
}
468-
import_attach = obj->import_attach;
469465
if (!drm_gem_is_imported(obj))
470466
continue;
471-
ret = dma_buf_begin_cpu_access(import_attach->dmabuf, dir);
467+
ret = dma_buf_begin_cpu_access(obj->dma_buf, dir);
472468
if (ret)
473469
goto err___drm_gem_fb_end_cpu_access;
474470
}

0 commit comments

Comments
 (0)