<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Acked-by: Alex Deucher <alexander.deucher@amd.com><br>
</p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Christian König <ckoenig.leichtzumerken@gmail.com><br>
<b>Sent:</b> Friday, November 2, 2018 9:48:07 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org<br>
<b>Subject:</b> [PATCH] drm/amdkfd: fix interrupt spin lock</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Vega10 has multiple interrupt rings, so this can be called from multiple<br>
calles at the same time resulting in:<br>
<br>
[   71.779334] ================================<br>
[   71.779406] WARNING: inconsistent lock state<br>
[   71.779478] 4.19.0-rc1+ #44 Tainted: G        W<br>
[   71.779565] --------------------------------<br>
[   71.779637] inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage.<br>
[   71.779740] kworker/6:1/120 [HC0[0]:SC0[0]:HE1:SE1] takes:<br>
[   71.779832] 00000000ad761971 (&(&kfd->interrupt_lock)->rlock){?...},<br>
at: kgd2kfd_interrupt+0x75/0x100 [amdgpu]<br>
[   71.780058] {IN-HARDIRQ-W} state was registered at:<br>
[   71.780115]   _raw_spin_lock+0x2c/0x40<br>
[   71.780180]   kgd2kfd_interrupt+0x75/0x100 [amdgpu]<br>
[   71.780248]   amdgpu_irq_callback+0x6c/0x150 [amdgpu]<br>
[   71.780315]   amdgpu_ih_process+0x88/0x100 [amdgpu]<br>
[   71.780380]   amdgpu_irq_handler+0x20/0x40 [amdgpu]<br>
[   71.780409]   __handle_irq_event_percpu+0x49/0x2a0<br>
[   71.780436]   handle_irq_event_percpu+0x30/0x70<br>
[   71.780461]   handle_irq_event+0x37/0x60<br>
[   71.780484]   handle_edge_irq+0x83/0x1b0<br>
[   71.780506]   handle_irq+0x1f/0x30<br>
[   71.780526]   do_IRQ+0x53/0x110<br>
[   71.780544]   ret_from_intr+0x0/0x22<br>
[   71.780566]   cpuidle_enter_state+0xaa/0x330<br>
[   71.780591]   do_idle+0x203/0x280<br>
[   71.780610]   cpu_startup_entry+0x6f/0x80<br>
[   71.780634]   start_secondary+0x1b0/0x200<br>
[   71.780657]   secondary_startup_64+0xa4/0xb0<br>
<br>
Fix this by always using irq save spin locks.<br>
<br>
Signed-off-by: Christian König <christian.koenig@amd.com><br>
---<br>
 drivers/gpu/drm/amd/amdkfd/kfd_device.c | 5 +++--<br>
 1 file changed, 3 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device.c b/drivers/gpu/drm/amd/amdkfd/kfd_device.c<br>
index d7e0f41f8edc..c004647c8cb4 100644<br>
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device.c<br>
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device.c<br>
@@ -682,6 +682,7 @@ void kgd2kfd_interrupt(struct kfd_dev *kfd, const void *ih_ring_entry)<br>
 {<br>
         uint32_t patched_ihre[KFD_MAX_RING_ENTRY_SIZE];<br>
         bool is_patched = false;<br>
+       unsigned long flags;<br>
 <br>
         if (!kfd->init_complete)<br>
                 return;<br>
@@ -691,7 +692,7 @@ void kgd2kfd_interrupt(struct kfd_dev *kfd, const void *ih_ring_entry)<br>
                 return;<br>
         }<br>
 <br>
-       spin_lock(&kfd->interrupt_lock);<br>
+       spin_lock_irqsave(&kfd->interrupt_lock, flags);<br>
 <br>
         if (kfd->interrupts_active<br>
             && interrupt_is_wanted(kfd, ih_ring_entry,<br>
@@ -700,7 +701,7 @@ void kgd2kfd_interrupt(struct kfd_dev *kfd, const void *ih_ring_entry)<br>
                                      is_patched ? patched_ihre : ih_ring_entry))<br>
                 queue_work(kfd->ih_wq, &kfd->interrupt_work);<br>
 <br>
-       spin_unlock(&kfd->interrupt_lock);<br>
+       spin_unlock_irqrestore(&kfd->interrupt_lock, flags);<br>
 }<br>
 <br>
 int kgd2kfd_quiesce_mm(struct mm_struct *mm)<br>
-- <br>
2.14.1<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br>
</div>
</span></font></div>
</body>
</html>