<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Arial;font-size:10pt;color:#0000FF;margin:5pt;" align="Left">
[AMD Official Use Only]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Acked-by: Alex Deucher <alexander.deucher@amd.com><br>
</div>
<div id="appendonsend"></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> Chen, Guchun <Guchun.Chen@amd.com><br>
<b>Sent:</b> Monday, January 10, 2022 12:13 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Deucher, Alexander <Alexander.Deucher@amd.com>; Koenig, Christian <Christian.Koenig@amd.com>; Pan, Xinhui <Xinhui.Pan@amd.com>; Zytaruk, Kelly <Kelly.Zytaruk@amd.com>; Huang, Qiliang
(Warden) <Qiliang.Huang@amd.com>; Zhang, Bokun <Bokun.Zhang@amd.com><br>
<b>Cc:</b> Chen, Guchun <Guchun.Chen@amd.com><br>
<b>Subject:</b> [PATCH] drm/amdgpu: use spin_lock_irqsave to avoid deadlock by local interrupt</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">This is observed in SRIOV case with virtual KMS as display.<br>
<br>
_raw_spin_lock_irqsave+0x37/0x40<br>
drm_handle_vblank+0x69/0x350 [drm]<br>
? try_to_wake_up+0x432/0x5c0<br>
? amdgpu_vkms_prepare_fb+0x1c0/0x1c0 [amdgpu]<br>
drm_crtc_handle_vblank+0x17/0x20 [drm]<br>
amdgpu_vkms_vblank_simulate+0x4d/0x80 [amdgpu]<br>
__hrtimer_run_queues+0xfb/0x230<br>
hrtimer_interrupt+0x109/0x220<br>
__sysvec_apic_timer_interrupt+0x64/0xe0<br>
asm_call_irq_on_stack+0x12/0x20<br>
<br>
Fixes: ba5317109d0c("drm/amdgpu: create amdgpu_vkms (v4)")<br>
Signed-off-by: Guchun Chen <guchun.chen@amd.com><br>
---<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c | 5 +++--<br>
1 file changed, 3 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c<br>
index 2dcc68e04e84..d99c8779b51e 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c<br>
@@ -144,15 +144,16 @@ static void amdgpu_vkms_crtc_atomic_disable(struct drm_crtc *crtc,<br>
static void amdgpu_vkms_crtc_atomic_flush(struct drm_crtc *crtc,<br>
struct drm_atomic_state *state)<br>
{<br>
+ unsigned long flags;<br>
if (crtc->state->event) {<br>
- spin_lock(&crtc->dev->event_lock);<br>
+ spin_lock_irqsave(&crtc->dev->event_lock, flags);<br>
<br>
if (drm_crtc_vblank_get(crtc) != 0)<br>
drm_crtc_send_vblank_event(crtc, crtc->state->event);<br>
else<br>
drm_crtc_arm_vblank_event(crtc, crtc->state->event);<br>
<br>
- spin_unlock(&crtc->dev->event_lock);<br>
+ spin_unlock_irqrestore(&crtc->dev->event_lock, flags);<br>
<br>
crtc->state->event = NULL;<br>
}<br>
-- <br>
2.17.1<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>