Skip to content

Commit 4948e6c

Browse files
tdzalexdeucher
authored andcommitted
drm/amdgpu: Test for imported buffers with drm_gem_is_imported()
Instead of testing import_attach for imported GEM buffers, invoke drm_gem_is_imported() to do the test. v2: - keep amdgpu_bo_print_info() as-is (Christian) 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 a3e510f commit 4948e6c

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,7 @@ amdgpu_display_user_framebuffer_create(struct drm_device *dev,
13171317
/* Handle is imported dma-buf, so cannot be migrated to VRAM for scanout */
13181318
bo = gem_to_amdgpu_bo(obj);
13191319
domains = amdgpu_display_supported_domains(drm_to_adev(dev), bo->flags);
1320-
if (obj->import_attach && !(domains & AMDGPU_GEM_DOMAIN_GTT)) {
1320+
if (drm_gem_is_imported(obj) && !(domains & AMDGPU_GEM_DOMAIN_GTT)) {
13211321
drm_dbg_kms(dev, "Cannot create framebuffer from imported dma_buf\n");
13221322
drm_gem_object_put(obj);
13231323
return ERR_PTR(-EINVAL);

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

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

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

519519
if (dma_buf->ops != &amdgpu_dmabuf_ops)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +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 (!obj->import_attach ||
320+
if (!drm_gem_is_imported(obj) ||
321321
!dma_buf_is_dynamic(obj->import_attach->dmabuf))
322322
return 0;
323323
mutex_lock_nested(&vm->process_info->lock, 1);
@@ -1024,7 +1024,7 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data,
10241024
break;
10251025
}
10261026
case AMDGPU_GEM_OP_SET_PLACEMENT:
1027-
if (robj->tbo.base.import_attach &&
1027+
if (drm_gem_is_imported(&robj->tbo.base) &&
10281028
args->value & AMDGPU_GEM_DOMAIN_VRAM) {
10291029
r = -EINVAL;
10301030
amdgpu_bo_unreserve(robj);

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static void amdgpu_bo_destroy(struct ttm_buffer_object *tbo)
6363

6464
amdgpu_bo_kunmap(bo);
6565

66-
if (bo->tbo.base.import_attach)
66+
if (drm_gem_is_imported(&bo->tbo.base))
6767
drm_prime_gem_destroy(&bo->tbo.base, bo->tbo.sg);
6868
drm_gem_object_release(&bo->tbo.base);
6969
amdgpu_bo_unref(&bo->parent);
@@ -940,7 +940,7 @@ int amdgpu_bo_pin(struct amdgpu_bo *bo, u32 domain)
940940
domain = bo->preferred_domains & domain;
941941

942942
/* A shared bo cannot be migrated to VRAM */
943-
if (bo->tbo.base.import_attach) {
943+
if (drm_gem_is_imported(&bo->tbo.base)) {
944944
if (domain & AMDGPU_GEM_DOMAIN_GTT)
945945
domain = AMDGPU_GEM_DOMAIN_GTT;
946946
else
@@ -968,7 +968,7 @@ int amdgpu_bo_pin(struct amdgpu_bo *bo, u32 domain)
968968
*/
969969
domain = amdgpu_bo_get_preferred_domain(adev, domain);
970970

971-
if (bo->tbo.base.import_attach)
971+
if (drm_gem_is_imported(&bo->tbo.base))
972972
dma_buf_pin(bo->tbo.base.import_attach);
973973

974974
/* force to pin into visible video ram */
@@ -1019,7 +1019,7 @@ void amdgpu_bo_unpin(struct amdgpu_bo *bo)
10191019
if (bo->tbo.pin_count)
10201020
return;
10211021

1022-
if (bo->tbo.base.import_attach)
1022+
if (drm_gem_is_imported(&bo->tbo.base))
10231023
dma_buf_unpin(bo->tbo.base.import_attach);
10241024

10251025
if (bo->tbo.resource->mem_type == TTM_PL_VRAM) {
@@ -1264,7 +1264,7 @@ void amdgpu_bo_move_notify(struct ttm_buffer_object *bo,
12641264

12651265
amdgpu_bo_kunmap(abo);
12661266

1267-
if (abo->tbo.base.dma_buf && !abo->tbo.base.import_attach &&
1267+
if (abo->tbo.base.dma_buf && !drm_gem_is_imported(&abo->tbo.base) &&
12681268
old_mem && old_mem->mem_type != TTM_PL_SYSTEM)
12691269
dma_buf_move_notify(abo->tbo.base.dma_buf);
12701270

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ static void amdgpu_ttm_backend_unbind(struct ttm_device *bdev,
10611061
/* if the pages have userptr pinning then clear that first */
10621062
if (gtt->userptr) {
10631063
amdgpu_ttm_tt_unpin_userptr(bdev, ttm);
1064-
} else if (ttm->sg && gtt->gobj->import_attach) {
1064+
} else if (ttm->sg && drm_gem_is_imported(gtt->gobj)) {
10651065
struct dma_buf_attachment *attach;
10661066

10671067
attach = gtt->gobj->import_attach;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,7 +1271,7 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, struct amdgpu_bo_va *bo_va,
12711271
} else {
12721272
struct drm_gem_object *obj = &bo->tbo.base;
12731273

1274-
if (obj->import_attach && bo_va->is_xgmi) {
1274+
if (drm_gem_is_imported(obj) && bo_va->is_xgmi) {
12751275
struct dma_buf *dma_buf = obj->import_attach->dmabuf;
12761276
struct drm_gem_object *gobj = dma_buf->priv;
12771277
struct amdgpu_bo *abo = gem_to_amdgpu_bo(gobj);
@@ -1631,7 +1631,7 @@ int amdgpu_vm_handle_moved(struct amdgpu_device *adev,
16311631
* validation
16321632
*/
16331633
if (vm->is_compute_context &&
1634-
bo_va->base.bo->tbo.base.import_attach &&
1634+
drm_gem_is_imported(&bo_va->base.bo->tbo.base) &&
16351635
(!bo_va->base.bo->tbo.resource ||
16361636
bo_va->base.bo->tbo.resource->mem_type == TTM_PL_SYSTEM))
16371637
amdgpu_vm_bo_evicted_user(&bo_va->base);

0 commit comments

Comments
 (0)