drm/amdgpu: Fix the dead lock issue.
Subsystems (2)
PATCH 1/1 drm/amdgpu: Fix the dead lock issue.
It will ramdomly have the dead lock issue when test TDR:
1. amdgpu_device_handle_vram_lost gets the lock shadow_list_lock
2. amdgpu_bo_create locked the bo's resv lock
3. amdgpu_bo_create_shadow is waiting for the shadow_list_lock
4. amdgpu_device_recover_vram_from_shadow is waiting for the bo's resv lock.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +7 -5
@@ -557,12 +557,8 @@ static int amdgpu_bo_create_shadow(struct amdgpu_device *adev, bp.resv = bo->tbo.resv; r =amdgpu_bo_do_create (adev, &bp, &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; }
@@ -603,6 +599,12 @@ int amdgpu_bo_create(struct amdgpu_device *adev,if (!bp->resv)reservation_object_unlock ((*bo_ptr)->tbo.resv); +if (!r) { +mutex_lock (&adev->shadow_list_lock); +list_add_tail (&(*bo_ptr)->shadow_list, &adev->shadow_list); +mutex_unlock (&adev->shadow_list_lock); + } +if (r)amdgpu_bo_unref (bo_ptr); }
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1536552453-18595-1-git-send-email-Emily.Deng-5C7GfCeVMHo@public.gmane.org
Am 10.09.2018 um 06:07 schrieb Emily Deng:
Quoted 8 lines
It will ramdomly have the dead lock issue when test TDR:
1.amdgpu_device_handle_vram_lostgets the lockshadow_list_lock
2.amdgpu_bo_createlocked the bo's resv lock
3.amdgpu_bo_create_shadowis waiting for theshadow_list_lock
4.amdgpu_device_recover_vram_from_shadowis waiting for the bo's resv lock.Signed-off-by Emily Deng <[email protected]>
Good catch, problem is the fix doesn't work like this because the lock won't be dropped at this point in most cases.
Instead you need to fix amdgpu_device_recover_vram_from_shadow to make a local copy of the list.
You can do this by grabbing a reference to each BO and moving it to a local list.
Regards,
Christian.
Quoted 25 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1
-5@@ -557,12 +557,8 @@ static int amdgpu_bo_create_shadow(struct amdgpu_device *adev, bp.resv = bo->tbo.resv; r =amdgpu_bo_do_create (adev, &bp, &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; }@@ -603,6 +599,12 @@ int amdgpu_bo_create(struct amdgpu_device *adev,if (!bp->resv)reservation_object_unlock ((*bo_ptr)->tbo.resv);
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_create(struct amdgpu_device *adev, · line 610
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +6
-0+if (!r) { +mutex_lock (&adev->shadow_list_lock); +list_add_tail (&(*bo_ptr)->shadow_list, &adev->shadow_list); +mutex_unlock (&adev->shadow_list_lock); + } +if (r)amdgpu_bo_unref (bo_ptr); }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): fe055a6c-0859-7404-6236-2c22eb8e3df5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Quoted 14 lines
-----Original Message-----
From: Christian König <[email protected]>
Sent: Monday, September 10, 2018 3:06 PM
To: Deng, Emily <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Fix the dead lock issue.Am 10.09.2018 um 06:07 schrieb Emily Deng:
Quoted 7 lines
It will ramdomly have the dead lock issue when test TDR:
1.amdgpu_device_handle_vram_lostgets the lockshadow_list_lock2.amdgpu_bo_createlocked the bo's resv lock 3.amdgpu_bo_create_shadowis waiting for theshadow_list_lock4.amdgpu_device_recover_vram_from_shadowis waiting for the bo's resv lock.
Quoted 4 lines
Quoted 1 line
Signed-off-by Emily Deng <[email protected]>Good catch, problem is the fix doesn't work like this because the lock won't be dropped at this point in most cases.
Sorry, could you explain more, why the lock won't be dropped after calling reservation_object_unlock?
Quoted 39 lines
Instead you need to fix
amdgpu_device_recover_vram_from_shadowto make a local copy of the list.You can do this by grabbing a reference to each BO and moving it to a local list.
Regards,
Christian.drivers/gpu/drm/amd/amdgpu/amdgpu_object.c static int amdgpu_bo_create_shadow(struct
Quoted 10 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0
-0@@ -557,12 +557,8 @@ static int amdgpu_bo_create_shadow(struct
amdgpu_device*adev,drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_create(struct amdgpu_device
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1
-5bp.resv = bo->tbo.resv; r =amdgpu_bo_do_create (adev, &bp, &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; }@@ -603,6 +599,12 @@ int amdgpu_bo_create(struct amdgpu_device*adev,
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0
-0if (!bp->resv)reservation_object_unlock ((*bo_ptr)->tbo.resv);
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +6
-0+if (!r) { +mutex_lock (&adev->shadow_list_lock); +list_add_tail (&(*bo_ptr)->shadow_list, &adev- shadow_list); +mutex_unlock (&adev->shadow_list_lock); + } +if (r)amdgpu_bo_unref (bo_ptr);}
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): BN7PR12MB2644EBCEAD5A7EAD4700FDD28F050-Zx/IyJUqfGKoYeSiBV3SvgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Am 10.09.2018 um 09:19 schrieb Deng, Emily:
Quoted 14 lines
Quoted 14 lines
-----Original Message-----
From: Christian König <[email protected]>
Sent: Monday, September 10, 2018 3:06 PM
To: Deng, Emily <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Fix the dead lock issue.Am 10.09.2018 um 06:07 schrieb Emily Deng:
Quoted 7 lines
It will ramdomly have the dead lock issue when test TDR:
1.amdgpu_device_handle_vram_lostgets the lockshadow_list_lock2.amdgpu_bo_createlocked the bo's resv lock 3.amdgpu_bo_create_shadowis waiting for theshadow_list_lock4.amdgpu_device_recover_vram_from_shadowis waiting for the bo's resv lock.
Quoted 4 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Emily Deng <[email protected]>Good catch, problem is the fix doesn't work like this because the lock won't be dropped at this point in most cases.
Sorry, could you explain more, why the lock won't be dropped after calling
reservation_object_unlock?
reservation_object_unlock won't be called for most BOs.
E.g. the shadow is used for page directories and all page directories use the root reservation object and so have bp->resv set here.
Christian.
Quoted 38 lines
Quoted 38 lines
Instead you need to fix
amdgpu_device_recover_vram_from_shadowto make a local copy of the list.You can do this by grabbing a reference to each BO and moving it to a local list.
Regards,
Christian.drivers/gpu/drm/amd/amdgpu/amdgpu_object.c static int amdgpu_bo_create_shadow(struct
Quoted 10 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0
-0@@ -557,12 +557,8 @@ static int amdgpu_bo_create_shadow(struct
amdgpu_device*adev,drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_create(struct amdgpu_device
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1
-5bp.resv = bo->tbo.resv; r =amdgpu_bo_do_create (adev, &bp, &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; }@@ -603,6 +599,12 @@ int amdgpu_bo_create(struct amdgpu_device*adev,
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0
-0if (!bp->resv)reservation_object_unlock ((*bo_ptr)->tbo.resv);
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +6
-0+if (!r) { +mutex_lock (&adev->shadow_list_lock); +list_add_tail (&(*bo_ptr)->shadow_list, &adev- shadow_list); +mutex_unlock (&adev->shadow_list_lock); + } +if (r)amdgpu_bo_unref (bo_ptr);}
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 6798b857-49ec-06b3-f25f-f9df91a1ae20-5C7GfCeVMHo@public.gmane.org
Quoted 24 lines
-----Original Message-----
From: Koenig, Christian
Sent: Monday, September 10, 2018 3:23 PM
To: Deng, Emily <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Fix the dead lock issue.Am 10.09.2018 um 09:19 schrieb Deng, Emily:
Quoted 17 lines
Quoted 17 lines
-----Original Message-----
From: Christian König <[email protected]>
Sent: Monday, September 10, 2018 3:06 PM
To: Deng, Emily <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Fix the dead lock issue.Am 10.09.2018 um 06:07 schrieb Emily Deng:
Quoted 8 lines
It will ramdomly have the dead lock issue when test TDR:
1.amdgpu_device_handle_vram_lostgets the lockshadow_list_lock2.amdgpu_bo_createlocked the bo's resv lock 3.amdgpu_bo_create_shadowis waiting for theshadow_list_lock4.amdgpu_device_recover_vram_from_shadowis waiting for the bo's resv lock.Signed-off-by Emily Deng <[email protected]>Good catch, problem is the fix doesn't work like this because the lock won't be dropped at this point in most cases.
Quoted 7 lines
Quoted 1 line
Sorry, could you explain more, why the lock won't be dropped after calling
reservation_object_unlock?
reservation_object_unlockwon't be called for most BOs.E.g. the shadow is used for page directories and all page directories use the root reservation object and so have
bp->resvset here.
Thanks, will modify as your suggestion.
Best wishes
Emily Deng
Quoted 40 lines
Christian.
Quoted 38 lines
Quoted 38 lines
Instead you need to fix
amdgpu_device_recover_vram_from_shadowto make a local copy of the list.You can do this by grabbing a reference to each BO and moving it to a local list.
Regards,
Christian.drivers/gpu/drm/amd/amdgpu/amdgpu_object.c static int amdgpu_bo_create_shadow(struct
Quoted 10 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0
-0@@ -557,12 +557,8 @@ static int amdgpu_bo_create_shadow(struct
amdgpu_device*adev,drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_create(struct amdgpu_device
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1
-5bp.resv = bo->tbo.resv; r =amdgpu_bo_do_create (adev, &bp, &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; }@@ -603,6 +599,12 @@ int amdgpu_bo_create(struct amdgpu_device*adev,
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0
-0if (!bp->resv)reservation_object_unlock ((*bo_ptr)->tbo.resv);
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +6
-0+if (!r) { +mutex_lock (&adev->shadow_list_lock); +list_add_tail (&(*bo_ptr)->shadow_list, &adev- shadow_list); +mutex_unlock (&adev->shadow_list_lock); + } +if (r)amdgpu_bo_unref (bo_ptr);}
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx