* [PATCH] drm/mediatek: dsi: Don't let a signal cut the IRQ wait short
@ 2026-11-18 1:25 ` Zi-Hao Huang
0 siblings, 0 replies; 3+ messages in thread
From: Zi-Hao Huang via B4 Relay @ 2026-11-18 1:25 UTC (permalink / raw)
To: Chun-Kuang Hu, Philipp Zabel
Cc: David Airlie, Simona Vetter, Matthias Brugger,
AngeloGioacchino Del Regno, shaoming chen, dri-devel,
linux-mediatek, linux-kernel, linux-arm-kernel, Zi-Hao Huang
From: Zi-Hao Huang <zi-hao.huang@mediatek.com>
mtk_dsi_wait_for_irq_done() waits for the DSI IRQ with
wait_event_interruptible_timeout(). If it returns early, for example
with -ERESTARTSYS when a signal is pending, both callers still treat the
command as done, because they only handle a return value of 0 as a
failure.
On an MT8196 board this led to a hard lockup during shutdown. The wait
returned before the IRQ arrived, the panel disable sequence went on and
restarted video mode, and the late CMD_DONE interrupt was then handled
by mtk_dsi_irq(). The handler writes RACK and loops until DSI_BUSY
clears, but DSI_BUSY stays set while video mode is running, so the CPU
never leaves the handler until the watchdog fires. Forcing the wait to
return early reproduces the lockup every time, and it no longer
happens once the wait cannot return early.
The wait is made from the driver's own context to synchronise with the
hardware, not on behalf of a userspace request, and it is bounded by its
timeout. Use wait_event_timeout() so that it only ends on the IRQ or the
timeout.
wake_up_interruptible() cannot wake a task in uninterruptible sleep, so
switch mtk_dsi_irq() to wake_up(). Without it every wait would last
until its timeout.
Fixes: dd5080a54df8 ("drm/mediatek: add dsi interrupt control")
Signed-off-by: Zi-Hao Huang <zi-hao.huang@mediatek.com>
---
drivers/gpu/drm/mediatek/mtk_dsi.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c
index f82506e10fd5..1315dd31a834 100644
--- a/drivers/gpu/drm/mediatek/mtk_dsi.c
+++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
@@ -627,9 +627,8 @@ static s32 mtk_dsi_wait_for_irq_done(struct mtk_dsi *dsi, u32 irq_flag,
unsigned long jiffies = msecs_to_jiffies(timeout);
struct drm_device *drm = dsi->bridge.dev;
- ret = wait_event_interruptible_timeout(dsi->irq_wait_queue,
- dsi->irq_data & irq_flag,
- jiffies);
+ ret = wait_event_timeout(dsi->irq_wait_queue,
+ dsi->irq_data & irq_flag, jiffies);
if (ret == 0) {
drm_warn(drm, "Wait DSI IRQ(0x%08x) Timeout\n", irq_flag);
@@ -656,7 +655,7 @@ static irqreturn_t mtk_dsi_irq(int irq, void *dev_id)
mtk_dsi_mask(dsi, DSI_INTSTA, status, 0);
mtk_dsi_irq_data_set(dsi, status);
- wake_up_interruptible(&dsi->irq_wait_queue);
+ wake_up(&dsi->irq_wait_queue);
}
return IRQ_HANDLED;
---
base-commit: 067c5c24cef23d913b67eaaf71ae67e7169a6620
change-id: 20261118-mtk-dsi-irq-wait-a24712ada627
Best regards,
--
Zi-Hao Huang <zi-hao.huang@mediatek.com>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] drm/mediatek: dsi: Don't let a signal cut the IRQ wait short
@ 2026-11-18 1:25 ` Zi-Hao Huang
0 siblings, 0 replies; 3+ messages in thread
From: Zi-Hao Huang @ 2026-11-18 1:25 UTC (permalink / raw)
To: Chun-Kuang Hu, Philipp Zabel
Cc: David Airlie, Simona Vetter, Matthias Brugger,
AngeloGioacchino Del Regno, shaoming chen, dri-devel,
linux-mediatek, linux-kernel, linux-arm-kernel, Zi-Hao Huang
mtk_dsi_wait_for_irq_done() waits for the DSI IRQ with
wait_event_interruptible_timeout(). If it returns early, for example
with -ERESTARTSYS when a signal is pending, both callers still treat the
command as done, because they only handle a return value of 0 as a
failure.
On an MT8196 board this led to a hard lockup during shutdown. The wait
returned before the IRQ arrived, the panel disable sequence went on and
restarted video mode, and the late CMD_DONE interrupt was then handled
by mtk_dsi_irq(). The handler writes RACK and loops until DSI_BUSY
clears, but DSI_BUSY stays set while video mode is running, so the CPU
never leaves the handler until the watchdog fires. Forcing the wait to
return early reproduces the lockup every time, and it no longer
happens once the wait cannot return early.
The wait is made from the driver's own context to synchronise with the
hardware, not on behalf of a userspace request, and it is bounded by its
timeout. Use wait_event_timeout() so that it only ends on the IRQ or the
timeout.
wake_up_interruptible() cannot wake a task in uninterruptible sleep, so
switch mtk_dsi_irq() to wake_up(). Without it every wait would last
until its timeout.
Fixes: dd5080a54df8 ("drm/mediatek: add dsi interrupt control")
Signed-off-by: Zi-Hao Huang <zi-hao.huang@mediatek.com>
---
drivers/gpu/drm/mediatek/mtk_dsi.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c
index f82506e10fd5..1315dd31a834 100644
--- a/drivers/gpu/drm/mediatek/mtk_dsi.c
+++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
@@ -627,9 +627,8 @@ static s32 mtk_dsi_wait_for_irq_done(struct mtk_dsi *dsi, u32 irq_flag,
unsigned long jiffies = msecs_to_jiffies(timeout);
struct drm_device *drm = dsi->bridge.dev;
- ret = wait_event_interruptible_timeout(dsi->irq_wait_queue,
- dsi->irq_data & irq_flag,
- jiffies);
+ ret = wait_event_timeout(dsi->irq_wait_queue,
+ dsi->irq_data & irq_flag, jiffies);
if (ret == 0) {
drm_warn(drm, "Wait DSI IRQ(0x%08x) Timeout\n", irq_flag);
@@ -656,7 +655,7 @@ static irqreturn_t mtk_dsi_irq(int irq, void *dev_id)
mtk_dsi_mask(dsi, DSI_INTSTA, status, 0);
mtk_dsi_irq_data_set(dsi, status);
- wake_up_interruptible(&dsi->irq_wait_queue);
+ wake_up(&dsi->irq_wait_queue);
}
return IRQ_HANDLED;
---
base-commit: 067c5c24cef23d913b67eaaf71ae67e7169a6620
change-id: 20261118-mtk-dsi-irq-wait-a24712ada627
Best regards,
--
Zi-Hao Huang <zi-hao.huang@mediatek.com>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/mediatek: dsi: Don't let a signal cut the IRQ wait short
2026-11-18 1:25 ` Zi-Hao Huang
(?)
@ 2026-11-18 1:30 ` sashiko-bot
-1 siblings, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-11-18 1:30 UTC (permalink / raw)
To: Zi-Hao Huang; +Cc: dri-devel
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] drm/mediatek: data race on dsi->irq_data in
mtk_dsi_irq_data_clear() [1]
--
commit 05e9a152e55dc7fe529c1070f18d57f8b05d8243
Author: Zi-Hao Huang <zi-hao.huang@mediatek.com>
drm/mediatek: dsi: Don't let a signal cut the IRQ wait short
This commit switches mtk_dsi_wait_for_irq_done() to wait_event_timeout()
and mtk_dsi_irq() to wake_up() so that pending signals do not abort hardware
IRQ waits prematurely.
> diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c
> index f82506e10fd59..1315dd31a8349 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dsi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
> @@ -627,9 +627,8 @@ static s32 mtk_dsi_wait_for_irq_done(struct mtk_dsi *dsi, u32 irq_flag,
> unsigned long jiffies = msecs_to_jiffies(timeout);
> struct drm_device *drm = dsi->bridge.dev;
>
> - ret = wait_event_interruptible_timeout(dsi->irq_wait_queue,
> - dsi->irq_data & irq_flag,
> - jiffies);
> + ret = wait_event_timeout(dsi->irq_wait_queue,
> + dsi->irq_data & irq_flag, jiffies);
> if (ret == 0) {
> drm_warn(drm, "Wait DSI IRQ(0x%08x) Timeout\n", irq_flag);
>
> @@ -656,7 +655,7 @@ static irqreturn_t mtk_dsi_irq(int irq, void *dev_id)
>
> mtk_dsi_mask(dsi, DSI_INTSTA, status, 0);
> mtk_dsi_irq_data_set(dsi, status);
> - wake_up_interruptible(&dsi->irq_wait_queue);
> + wake_up(&dsi->irq_wait_queue);
[Severity: High]
This problem wasn't introduced by this patch, but can a data race on
dsi->irq_data between mtk_dsi_irq_data_clear() and mtk_dsi_irq_data_set()
[1] lose an interrupt flag?
drivers/gpu/drm/mediatek/mtk_dsi.c:
static void mtk_dsi_irq_data_set(struct mtk_dsi *dsi, u32 irq_bit)
{
dsi->irq_data |= irq_bit;
}
static void mtk_dsi_irq_data_clear(struct mtk_dsi *dsi, u32 irq_bit)
{
dsi->irq_data &= ~irq_bit;
}
Both helpers perform non-atomic read-modify-write operations on
dsi->irq_data without synchronization:
CPU0 <hardirq>
mtk_dsi_irq_data_clear()
read dsi->irq_data
mtk_dsi_irq()
mtk_dsi_irq_data_set()
dsi->irq_data |= status
write stale dsi->irq_data <-- clobbers newly set status bits
When mtk_dsi_irq_data_clear() overwrites the flag set by mtk_dsi_irq(),
mtk_dsi_wait_for_irq_done() misses the completion and times out, causing
DSI command transfers or mode switches to fail.
[1] https://sashiko.dev/#/bug/linux-366e515b-3237-4b5e-90f0-3615e8a40df5
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261118-mtk-dsi-irq-wait-v1-1-205f25fac8b2@mediatek.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-18 1:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 1:25 [PATCH] drm/mediatek: dsi: Don't let a signal cut the IRQ wait short Zi-Hao Huang via B4 Relay
2026-11-18 1:25 ` Zi-Hao Huang
2026-11-18 1:30 ` sashiko-bot
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.