All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] drm/amdgpu: Use spinlock_irqsave for pasid_lock
@ 2021-06-14 22:07 Felix Kuehling
  2021-06-15  6:48 ` Christian König
  2021-06-15 14:40 ` Zeng, Oak
  0 siblings, 2 replies; 3+ messages in thread
From: Felix Kuehling @ 2021-06-14 22:07 UTC (permalink / raw)
  To: amd-gfx

This should fix a kernel LOCKDEP warning on Vega10:
[  149.416604] ================================
[  149.420877] WARNING: inconsistent lock state
[  149.425152] 5.11.0-kfd-fkuehlin #517 Not tainted
[  149.429770] --------------------------------
[  149.434053] inconsistent {HARDIRQ-ON-W} -> {IN-HARDIRQ-W} usage.
[  149.440059] swapper/3/0 [HC1[1]:SC0[0]:HE0:SE1] takes:
[  149.445198] ffff9ac80e005d68 (&adev->vm_manager.pasid_lock){?.+.}-{2:2}, at: amdgpu_vm_get_task_info+0x25/0x90 [amdgpu]
[  149.456252] {HARDIRQ-ON-W} state was registered at:
[  149.461136]   lock_acquire+0x242/0x390
[  149.464895]   _raw_spin_lock+0x2c/0x40
[  149.468647]   amdgpu_vm_handle_fault+0x44/0x380 [amdgpu]
[  149.474187]   gmc_v9_0_process_interrupt+0xa8/0x410 [amdgpu]
...

Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 3b6c0b48d0b1..0b63686fc31a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -3394,11 +3394,12 @@ bool amdgpu_vm_handle_fault(struct amdgpu_device *adev, u32 pasid,
 {
 	bool is_compute_context = false;
 	struct amdgpu_bo *root;
+	unsigned long irqflags;
 	uint64_t value, flags;
 	struct amdgpu_vm *vm;
 	int r;
 
-	spin_lock(&adev->vm_manager.pasid_lock);
+	spin_lock_irqsave(&adev->vm_manager.pasid_lock, irqflags);
 	vm = idr_find(&adev->vm_manager.pasid_idr, pasid);
 	if (vm) {
 		root = amdgpu_bo_ref(vm->root.base.bo);
@@ -3406,7 +3407,7 @@ bool amdgpu_vm_handle_fault(struct amdgpu_device *adev, u32 pasid,
 	} else {
 		root = NULL;
 	}
-	spin_unlock(&adev->vm_manager.pasid_lock);
+	spin_unlock_irqrestore(&adev->vm_manager.pasid_lock, irqflags);
 
 	if (!root)
 		return false;
@@ -3424,11 +3425,11 @@ bool amdgpu_vm_handle_fault(struct amdgpu_device *adev, u32 pasid,
 		goto error_unref;
 
 	/* Double check that the VM still exists */
-	spin_lock(&adev->vm_manager.pasid_lock);
+	spin_lock_irqsave(&adev->vm_manager.pasid_lock, irqflags);
 	vm = idr_find(&adev->vm_manager.pasid_idr, pasid);
 	if (vm && vm->root.base.bo != root)
 		vm = NULL;
-	spin_unlock(&adev->vm_manager.pasid_lock);
+	spin_unlock_irqrestore(&adev->vm_manager.pasid_lock, irqflags);
 	if (!vm)
 		goto error_unlock;
 
-- 
2.32.0

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] drm/amdgpu: Use spinlock_irqsave for pasid_lock
  2021-06-14 22:07 [PATCH 1/1] drm/amdgpu: Use spinlock_irqsave for pasid_lock Felix Kuehling
@ 2021-06-15  6:48 ` Christian König
  2021-06-15 14:40 ` Zeng, Oak
  1 sibling, 0 replies; 3+ messages in thread
From: Christian König @ 2021-06-15  6:48 UTC (permalink / raw)
  To: Felix Kuehling, amd-gfx

Am 15.06.21 um 00:07 schrieb Felix Kuehling:
> This should fix a kernel LOCKDEP warning on Vega10:
> [  149.416604] ================================
> [  149.420877] WARNING: inconsistent lock state
> [  149.425152] 5.11.0-kfd-fkuehlin #517 Not tainted
> [  149.429770] --------------------------------
> [  149.434053] inconsistent {HARDIRQ-ON-W} -> {IN-HARDIRQ-W} usage.
> [  149.440059] swapper/3/0 [HC1[1]:SC0[0]:HE0:SE1] takes:
> [  149.445198] ffff9ac80e005d68 (&adev->vm_manager.pasid_lock){?.+.}-{2:2}, at: amdgpu_vm_get_task_info+0x25/0x90 [amdgpu]
> [  149.456252] {HARDIRQ-ON-W} state was registered at:
> [  149.461136]   lock_acquire+0x242/0x390
> [  149.464895]   _raw_spin_lock+0x2c/0x40
> [  149.468647]   amdgpu_vm_handle_fault+0x44/0x380 [amdgpu]
> [  149.474187]   gmc_v9_0_process_interrupt+0xa8/0x410 [amdgpu]

This is actually a false postive, but the patch is ok since it's the 
easiest way to fix this :)

> ...
>
> Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 9 +++++----
>   1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index 3b6c0b48d0b1..0b63686fc31a 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -3394,11 +3394,12 @@ bool amdgpu_vm_handle_fault(struct amdgpu_device *adev, u32 pasid,
>   {
>   	bool is_compute_context = false;
>   	struct amdgpu_bo *root;
> +	unsigned long irqflags;
>   	uint64_t value, flags;
>   	struct amdgpu_vm *vm;
>   	int r;
>   
> -	spin_lock(&adev->vm_manager.pasid_lock);
> +	spin_lock_irqsave(&adev->vm_manager.pasid_lock, irqflags);
>   	vm = idr_find(&adev->vm_manager.pasid_idr, pasid);
>   	if (vm) {
>   		root = amdgpu_bo_ref(vm->root.base.bo);
> @@ -3406,7 +3407,7 @@ bool amdgpu_vm_handle_fault(struct amdgpu_device *adev, u32 pasid,
>   	} else {
>   		root = NULL;
>   	}
> -	spin_unlock(&adev->vm_manager.pasid_lock);
> +	spin_unlock_irqrestore(&adev->vm_manager.pasid_lock, irqflags);
>   
>   	if (!root)
>   		return false;
> @@ -3424,11 +3425,11 @@ bool amdgpu_vm_handle_fault(struct amdgpu_device *adev, u32 pasid,
>   		goto error_unref;
>   
>   	/* Double check that the VM still exists */
> -	spin_lock(&adev->vm_manager.pasid_lock);
> +	spin_lock_irqsave(&adev->vm_manager.pasid_lock, irqflags);
>   	vm = idr_find(&adev->vm_manager.pasid_idr, pasid);
>   	if (vm && vm->root.base.bo != root)
>   		vm = NULL;
> -	spin_unlock(&adev->vm_manager.pasid_lock);
> +	spin_unlock_irqrestore(&adev->vm_manager.pasid_lock, irqflags);
>   	if (!vm)
>   		goto error_unlock;
>   

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] drm/amdgpu: Use spinlock_irqsave for pasid_lock
  2021-06-14 22:07 [PATCH 1/1] drm/amdgpu: Use spinlock_irqsave for pasid_lock Felix Kuehling
  2021-06-15  6:48 ` Christian König
@ 2021-06-15 14:40 ` Zeng, Oak
  1 sibling, 0 replies; 3+ messages in thread
From: Zeng, Oak @ 2021-06-15 14:40 UTC (permalink / raw)
  To: Kuehling, Felix, amd-gfx

Reviewed-by: Oak Zeng <Oak.Zeng@amd.com>

Regards,
Oak 

 

On 2021-06-14, 6:07 PM, "amd-gfx on behalf of Felix Kuehling" <amd-gfx-bounces@lists.freedesktop.org on behalf of Felix.Kuehling@amd.com> wrote:

    This should fix a kernel LOCKDEP warning on Vega10:
    [  149.416604] ================================
    [  149.420877] WARNING: inconsistent lock state
    [  149.425152] 5.11.0-kfd-fkuehlin #517 Not tainted
    [  149.429770] --------------------------------
    [  149.434053] inconsistent {HARDIRQ-ON-W} -> {IN-HARDIRQ-W} usage.
    [  149.440059] swapper/3/0 [HC1[1]:SC0[0]:HE0:SE1] takes:
    [  149.445198] ffff9ac80e005d68 (&adev->vm_manager.pasid_lock){?.+.}-{2:2}, at: amdgpu_vm_get_task_info+0x25/0x90 [amdgpu]
    [  149.456252] {HARDIRQ-ON-W} state was registered at:
    [  149.461136]   lock_acquire+0x242/0x390
    [  149.464895]   _raw_spin_lock+0x2c/0x40
    [  149.468647]   amdgpu_vm_handle_fault+0x44/0x380 [amdgpu]
    [  149.474187]   gmc_v9_0_process_interrupt+0xa8/0x410 [amdgpu]
    ...

    Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
    ---
     drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 9 +++++----
     1 file changed, 5 insertions(+), 4 deletions(-)

    diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
    index 3b6c0b48d0b1..0b63686fc31a 100644
    --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
    +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
    @@ -3394,11 +3394,12 @@ bool amdgpu_vm_handle_fault(struct amdgpu_device *adev, u32 pasid,
     {
     	bool is_compute_context = false;
     	struct amdgpu_bo *root;
    +	unsigned long irqflags;
     	uint64_t value, flags;
     	struct amdgpu_vm *vm;
     	int r;

    -	spin_lock(&adev->vm_manager.pasid_lock);
    +	spin_lock_irqsave(&adev->vm_manager.pasid_lock, irqflags);
     	vm = idr_find(&adev->vm_manager.pasid_idr, pasid);
     	if (vm) {
     		root = amdgpu_bo_ref(vm->root.base.bo);
    @@ -3406,7 +3407,7 @@ bool amdgpu_vm_handle_fault(struct amdgpu_device *adev, u32 pasid,
     	} else {
     		root = NULL;
     	}
    -	spin_unlock(&adev->vm_manager.pasid_lock);
    +	spin_unlock_irqrestore(&adev->vm_manager.pasid_lock, irqflags);

     	if (!root)
     		return false;
    @@ -3424,11 +3425,11 @@ bool amdgpu_vm_handle_fault(struct amdgpu_device *adev, u32 pasid,
     		goto error_unref;

     	/* Double check that the VM still exists */
    -	spin_lock(&adev->vm_manager.pasid_lock);
    +	spin_lock_irqsave(&adev->vm_manager.pasid_lock, irqflags);
     	vm = idr_find(&adev->vm_manager.pasid_idr, pasid);
     	if (vm && vm->root.base.bo != root)
     		vm = NULL;
    -	spin_unlock(&adev->vm_manager.pasid_lock);
    +	spin_unlock_irqrestore(&adev->vm_manager.pasid_lock, irqflags);
     	if (!vm)
     		goto error_unlock;

    -- 
    2.32.0

    _______________________________________________
    amd-gfx mailing list
    amd-gfx@lists.freedesktop.org
    https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=04%7C01%7Coak.zeng%40amd.com%7Ccbbdf385c6a2403bddc408d92f80c6da%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637593052418313221%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=MdlZzRjnc9sg9ikXsu8dNnih%2FlOKRh7a4X9pNEWPSIo%3D&amp;reserved=0

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-06-15 14:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-14 22:07 [PATCH 1/1] drm/amdgpu: Use spinlock_irqsave for pasid_lock Felix Kuehling
2021-06-15  6:48 ` Christian König
2021-06-15 14:40 ` Zeng, Oak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.