Skip to content

Commit 3eb61d7

Browse files
committed
Revert "drm/amdgpu: Use dma_buf from GEM object instance"
This reverts commit 5159861. The dma_buf field in struct drm_gem_object is not stable over the object instance's lifetime. The field becomes NULL when user space releases the final GEM handle on the buffer object. This resulted in a NULL-pointer deref. Workarounds in commit 5307dce ("drm/gem: Acquire references on GEM handles for framebuffers") and commit f6bfc9a ("drm/framebuffer: Acquire internal references on GEM handles") only solved the problem partially. They especially don't work for buffer objects without a DRM framebuffer associated. Hence, this revert to going back to using .import_attach->dmabuf. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Simona Vetter <simona.vetter@ffwll.ch> Acked-by: Alex Deucher <alexander.deucher@amd.com> Link: https://lore.kernel.org/r/20250715082635.34974-1-tzimmermann@suse.de
1 parent 9af8f2b commit 3eb61d7

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ bool amdgpu_dmabuf_is_xgmi_accessible(struct amdgpu_device *adev,
514514
return false;
515515

516516
if (drm_gem_is_imported(obj)) {
517-
struct dma_buf *dma_buf = obj->dma_buf;
517+
struct dma_buf *dma_buf = obj->import_attach->dmabuf;
518518

519519
if (dma_buf->ops != &amdgpu_dmabuf_ops)
520520
/* No XGMI with non AMD GPUs */

drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,8 @@ static int amdgpu_gem_object_open(struct drm_gem_object *obj,
317317
*/
318318
if (!vm->is_compute_context || !vm->process_info)
319319
return 0;
320-
if (!drm_gem_is_imported(obj) || !dma_buf_is_dynamic(obj->dma_buf))
320+
if (!drm_gem_is_imported(obj) ||
321+
!dma_buf_is_dynamic(obj->import_attach->dmabuf))
321322
return 0;
322323
mutex_lock_nested(&vm->process_info->lock, 1);
323324
if (!WARN_ON(!vm->process_info->eviction_fence)) {

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,7 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, struct amdgpu_bo_va *bo_va,
12761276
struct drm_gem_object *obj = &bo->tbo.base;
12771277

12781278
if (drm_gem_is_imported(obj) && bo_va->is_xgmi) {
1279-
struct dma_buf *dma_buf = obj->dma_buf;
1279+
struct dma_buf *dma_buf = obj->import_attach->dmabuf;
12801280
struct drm_gem_object *gobj = dma_buf->priv;
12811281
struct amdgpu_bo *abo = gem_to_amdgpu_bo(gobj);
12821282

0 commit comments

Comments
 (0)