diff options
author | Chunming Zhou <David1.Zhou@amd.com> | 2016-08-16 23:41:30 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2016-08-22 13:47:20 -0400 |
commit | 0c4e7fa56112b0eaef0bf88b569608620e0465b8 (patch) | |
tree | 279d4fee9378ef0f3d560170548aa66c1feb59f9 | |
parent | 4c7e885506eaefc55c2b45293b52cae9ef797d67 (diff) |
drm/amdgpu: link all shadow bo V2
V2:
1. use mutex instead of spinlock for shadow list, since its process could
sleep.
2. move list_del to bo destroy phase.
Signed-off-by: Chunming Zhou <David1.Zhou@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu.h | 5 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 12 |
3 files changed, 19 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 60030f951152..e30a0d6353cd 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h | |||
@@ -468,6 +468,7 @@ struct amdgpu_bo { | |||
468 | struct ttm_bo_kmap_obj dma_buf_vmap; | 468 | struct ttm_bo_kmap_obj dma_buf_vmap; |
469 | struct amdgpu_mn *mn; | 469 | struct amdgpu_mn *mn; |
470 | struct list_head mn_list; | 470 | struct list_head mn_list; |
471 | struct list_head shadow_list; | ||
471 | }; | 472 | }; |
472 | #define gem_to_amdgpu_bo(gobj) container_of((gobj), struct amdgpu_bo, gem_base) | 473 | #define gem_to_amdgpu_bo(gobj) container_of((gobj), struct amdgpu_bo, gem_base) |
473 | 474 | ||
@@ -2096,6 +2097,10 @@ struct amdgpu_device { | |||
2096 | struct kfd_dev *kfd; | 2097 | struct kfd_dev *kfd; |
2097 | 2098 | ||
2098 | struct amdgpu_virtualization virtualization; | 2099 | struct amdgpu_virtualization virtualization; |
2100 | |||
2101 | /* link all shadow bo */ | ||
2102 | struct list_head shadow_list; | ||
2103 | struct mutex shadow_list_lock; | ||
2099 | }; | 2104 | }; |
2100 | 2105 | ||
2101 | bool amdgpu_device_is_px(struct drm_device *dev); | 2106 | bool amdgpu_device_is_px(struct drm_device *dev); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 21f4b748aff0..76fd2dec7b42 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | |||
@@ -1550,6 +1550,9 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
1550 | spin_lock_init(&adev->gc_cac_idx_lock); | 1550 | spin_lock_init(&adev->gc_cac_idx_lock); |
1551 | spin_lock_init(&adev->audio_endpt_idx_lock); | 1551 | spin_lock_init(&adev->audio_endpt_idx_lock); |
1552 | 1552 | ||
1553 | INIT_LIST_HEAD(&adev->shadow_list); | ||
1554 | mutex_init(&adev->shadow_list_lock); | ||
1555 | |||
1553 | adev->rmmio_base = pci_resource_start(adev->pdev, 5); | 1556 | adev->rmmio_base = pci_resource_start(adev->pdev, 5); |
1554 | adev->rmmio_size = pci_resource_len(adev->pdev, 5); | 1557 | adev->rmmio_size = pci_resource_len(adev->pdev, 5); |
1555 | adev->rmmio = ioremap(adev->rmmio_base, adev->rmmio_size); | 1558 | adev->rmmio = ioremap(adev->rmmio_base, adev->rmmio_size); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 84990415a3dc..9113fffbb8b9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | |||
@@ -98,6 +98,11 @@ static void amdgpu_ttm_bo_destroy(struct ttm_buffer_object *tbo) | |||
98 | 98 | ||
99 | drm_gem_object_release(&bo->gem_base); | 99 | drm_gem_object_release(&bo->gem_base); |
100 | amdgpu_bo_unref(&bo->parent); | 100 | amdgpu_bo_unref(&bo->parent); |
101 | if (!list_empty(&bo->shadow_list)) { | ||
102 | mutex_lock(&bo->adev->shadow_list_lock); | ||
103 | list_del_init(&bo->shadow_list); | ||
104 | mutex_unlock(&bo->adev->shadow_list_lock); | ||
105 | } | ||
101 | kfree(bo->metadata); | 106 | kfree(bo->metadata); |
102 | kfree(bo); | 107 | kfree(bo); |
103 | } | 108 | } |
@@ -315,6 +320,7 @@ int amdgpu_bo_create_restricted(struct amdgpu_device *adev, | |||
315 | } | 320 | } |
316 | bo->adev = adev; | 321 | bo->adev = adev; |
317 | INIT_LIST_HEAD(&bo->list); | 322 | INIT_LIST_HEAD(&bo->list); |
323 | INIT_LIST_HEAD(&bo->shadow_list); | ||
318 | INIT_LIST_HEAD(&bo->va); | 324 | INIT_LIST_HEAD(&bo->va); |
319 | bo->prefered_domains = domain & (AMDGPU_GEM_DOMAIN_VRAM | | 325 | bo->prefered_domains = domain & (AMDGPU_GEM_DOMAIN_VRAM | |
320 | AMDGPU_GEM_DOMAIN_GTT | | 326 | AMDGPU_GEM_DOMAIN_GTT | |
@@ -407,8 +413,12 @@ static int amdgpu_bo_create_shadow(struct amdgpu_device *adev, | |||
407 | NULL, &placement, | 413 | NULL, &placement, |
408 | bo->tbo.resv, | 414 | bo->tbo.resv, |
409 | &bo->shadow); | 415 | &bo->shadow); |
410 | if (!r) | 416 | if (!r) { |
411 | bo->shadow->parent = amdgpu_bo_ref(bo); | 417 | bo->shadow->parent = amdgpu_bo_ref(bo); |
418 | mutex_lock(&adev->shadow_list_lock); | ||
419 | list_add_tail(&bo->shadow_list, &adev->shadow_list); | ||
420 | mutex_unlock(&adev->shadow_list_lock); | ||
421 | } | ||
412 | 422 | ||
413 | return r; | 423 | return r; |
414 | } | 424 | } |