]> git.karo-electronics.de Git - linux-beck.git/commitdiff
drm/amdgpu: link all shadow bo V2
authorChunming Zhou <David1.Zhou@amd.com>
Wed, 17 Aug 2016 03:41:30 +0000 (11:41 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 22 Aug 2016 17:47:20 +0000 (13:47 -0400)
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>
drivers/gpu/drm/amd/amdgpu/amdgpu.h
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c

index 60030f951152cfcbbdd138fba82ee78f4aae325e..e30a0d6353cd6fb96377be50301da30ca57819cc 100644 (file)
@@ -468,6 +468,7 @@ struct amdgpu_bo {
        struct ttm_bo_kmap_obj          dma_buf_vmap;
        struct amdgpu_mn                *mn;
        struct list_head                mn_list;
+       struct list_head                shadow_list;
 };
 #define gem_to_amdgpu_bo(gobj) container_of((gobj), struct amdgpu_bo, gem_base)
 
@@ -2096,6 +2097,10 @@ struct amdgpu_device {
        struct kfd_dev          *kfd;
 
        struct amdgpu_virtualization virtualization;
+
+       /* link all shadow bo */
+       struct list_head                shadow_list;
+       struct mutex                    shadow_list_lock;
 };
 
 bool amdgpu_device_is_px(struct drm_device *dev);
index 21f4b748aff0fdb7a330a9ee6a41eccaf75612a3..76fd2dec7b42033196d2a787c6d2b1723a9f18c5 100644 (file)
@@ -1550,6 +1550,9 @@ int amdgpu_device_init(struct amdgpu_device *adev,
        spin_lock_init(&adev->gc_cac_idx_lock);
        spin_lock_init(&adev->audio_endpt_idx_lock);
 
+       INIT_LIST_HEAD(&adev->shadow_list);
+       mutex_init(&adev->shadow_list_lock);
+
        adev->rmmio_base = pci_resource_start(adev->pdev, 5);
        adev->rmmio_size = pci_resource_len(adev->pdev, 5);
        adev->rmmio = ioremap(adev->rmmio_base, adev->rmmio_size);
index 84990415a3dcd59b02c7550df31053761e37231b..9113fffbb8b94797de4086bf45c32c2a3cf6b52b 100644 (file)
@@ -98,6 +98,11 @@ static void amdgpu_ttm_bo_destroy(struct ttm_buffer_object *tbo)
 
        drm_gem_object_release(&bo->gem_base);
        amdgpu_bo_unref(&bo->parent);
+       if (!list_empty(&bo->shadow_list)) {
+               mutex_lock(&bo->adev->shadow_list_lock);
+               list_del_init(&bo->shadow_list);
+               mutex_unlock(&bo->adev->shadow_list_lock);
+       }
        kfree(bo->metadata);
        kfree(bo);
 }
@@ -315,6 +320,7 @@ int amdgpu_bo_create_restricted(struct amdgpu_device *adev,
        }
        bo->adev = adev;
        INIT_LIST_HEAD(&bo->list);
+       INIT_LIST_HEAD(&bo->shadow_list);
        INIT_LIST_HEAD(&bo->va);
        bo->prefered_domains = domain & (AMDGPU_GEM_DOMAIN_VRAM |
                                         AMDGPU_GEM_DOMAIN_GTT |
@@ -407,8 +413,12 @@ static int amdgpu_bo_create_shadow(struct amdgpu_device *adev,
                                        NULL, &placement,
                                        bo->tbo.resv,
                                        &bo->shadow);
-       if (!r)
+       if (!r) {
                bo->shadow->parent = amdgpu_bo_ref(bo);
+               mutex_lock(&adev->shadow_list_lock);
+               list_add_tail(&bo->shadow_list, &adev->shadow_list);
+               mutex_unlock(&adev->shadow_list_lock);
+       }
 
        return r;
 }