drm/amdgpu:fix waiting on dirty fence
authorMonk Liu <Monk.Liu@amd.com>
Mon, 1 May 2017 08:15:31 +0000 (16:15 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 5 May 2017 22:12:42 +0000 (18:12 -0400)
if bo->shadow is NULL (race issue:BO shadow was just released
and gpu-reset kick in but BO hasn't yet) recover_vram_from_shadow
won't set @next, so the following "fence=next"
will wrongly use a fence pointer which may already dirty.
fixing it by set next to NULL prior to recover_vram_from_shadow

Signed-off-by: Monk Liu <Monk.Liu@amd.com>
Reviewed-by: Chunming Zhou<david1.zhou@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

index 3c1754df4c40a08b223a39c8051411fb9d5ceaa5..367811cd0763113798f30f637e834b07d9012c27 100644 (file)
@@ -2522,6 +2522,7 @@ int amdgpu_sriov_gpu_reset(struct amdgpu_device *adev, bool voluntary)
        ring = adev->mman.buffer_funcs_ring;
        mutex_lock(&adev->shadow_list_lock);
        list_for_each_entry_safe(bo, tmp, &adev->shadow_list, shadow_list) {
+               next = NULL;
                amdgpu_recover_vram_from_shadow(adev, ring, bo, &next);
                if (fence) {
                        r = dma_fence_wait(fence, false);
@@ -2668,6 +2669,7 @@ retry:
                        DRM_INFO("recover vram bo from shadow\n");
                        mutex_lock(&adev->shadow_list_lock);
                        list_for_each_entry_safe(bo, tmp, &adev->shadow_list, shadow_list) {
+                               next = NULL;
                                amdgpu_recover_vram_from_shadow(adev, ring, bo, &next);
                                if (fence) {
                                        r = dma_fence_wait(fence, false);