Skip to content

Commit 5159861

Browse files
tdzalexdeucher
authored andcommitted
drm/amdgpu: 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 an implementation detail of PRIME. Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 4948e6c commit 5159861

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

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->import_attach->dmabuf;
517+
struct dma_buf *dma_buf = obj->dma_buf;
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: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,7 @@ 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) ||
321-
!dma_buf_is_dynamic(obj->import_attach->dmabuf))
320+
if (!drm_gem_is_imported(obj) || !dma_buf_is_dynamic(obj->dma_buf))
322321
return 0;
323322
mutex_lock_nested(&vm->process_info->lock, 1);
324323
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
@@ -1272,7 +1272,7 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, struct amdgpu_bo_va *bo_va,
12721272
struct drm_gem_object *obj = &bo->tbo.base;
12731273

12741274
if (drm_gem_is_imported(obj) && bo_va->is_xgmi) {
1275-
struct dma_buf *dma_buf = obj->import_attach->dmabuf;
1275+
struct dma_buf *dma_buf = obj->dma_buf;
12761276
struct drm_gem_object *gobj = dma_buf->priv;
12771277
struct amdgpu_bo *abo = gem_to_amdgpu_bo(gobj);
12781278

0 commit comments

Comments
 (0)