* [PATCH v3 1/3] Revert "media: qcom: iris: use disable_irq() during power-off"
2026-11-20 7:42 [PATCH v3 0/3] media: qcom: iris: Fix IRQ synchronization during power-off Vishnu Reddy
@ 2026-11-20 7:42 ` Vishnu Reddy
2026-11-20 7:42 ` [PATCH v3 2/3] media: qcom: iris: Fix IRQ disable depth imbalance on watchdog interrupt Vishnu Reddy
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Vishnu Reddy @ 2026-11-20 7:42 UTC (permalink / raw)
To: Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
Bryan O'Donoghue, Mauro Carvalho Chehab, Konrad Dybcio,
Dmitry Baryshkov, Hungyu Lin, Stefan Schmidt, Hans Verkuil
Cc: Bryan O'Donoghue, linux-media, linux-arm-msm, linux-kernel,
Vishnu Reddy, stable
iris_vpu_power_off() is always called with core->lock held. Its callers
are core init, core deinit and the runtime PM suspend and resume
callbacks, and each of them takes core->lock before calling it.
The threaded IRQ handler also requires core->lock to proceed. If the
handler is woken and queued around the same time power-off is entered,
it cannot acquire core->lock because it is held by the power-off caller.
disable_irq() waits for the handler to complete, resulting in a
deadlock.
Fixes: b9c2215bdedc9c ("media: qcom: iris: use disable_irq() during power-off")
Cc: stable@vger.kernel.org
Signed-off-by: Vishnu Reddy <busanna.reddy@oss.qualcomm.com>
---
drivers/media/platform/qcom/iris/iris_vpu_common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/platform/qcom/iris/iris_vpu_common.c b/drivers/media/platform/qcom/iris/iris_vpu_common.c
index 243bd845349f..1e183fc4e58c 100644
--- a/drivers/media/platform/qcom/iris/iris_vpu_common.c
+++ b/drivers/media/platform/qcom/iris/iris_vpu_common.c
@@ -240,7 +240,7 @@ void iris_vpu_power_off(struct iris_core *core)
iris_unset_icc_bw(core);
if (!iris_vpu_watchdog(core, core->intr_status))
- disable_irq(core->irq);
+ disable_irq_nosync(core->irq);
}
int iris_vpu_power_on_controller(struct iris_core *core)
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v3 2/3] media: qcom: iris: Fix IRQ disable depth imbalance on watchdog interrupt
2026-11-20 7:42 [PATCH v3 0/3] media: qcom: iris: Fix IRQ synchronization during power-off Vishnu Reddy
2026-11-20 7:42 ` [PATCH v3 1/3] Revert "media: qcom: iris: use disable_irq() during power-off" Vishnu Reddy
@ 2026-11-20 7:42 ` Vishnu Reddy
2026-11-20 7:42 ` [PATCH v3 3/3] media: qcom: iris: Skip register access in IRQ handler after power-off Vishnu Reddy
2026-11-25 6:06 ` [PATCH v3 0/3] media: qcom: iris: Fix IRQ synchronization during power-off Wangao Wang
3 siblings, 0 replies; 5+ messages in thread
From: Vishnu Reddy @ 2026-11-20 7:42 UTC (permalink / raw)
To: Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
Bryan O'Donoghue, Mauro Carvalho Chehab, Konrad Dybcio,
Dmitry Baryshkov, Hungyu Lin, Stefan Schmidt, Hans Verkuil
Cc: Bryan O'Donoghue, linux-media, linux-arm-msm, linux-kernel,
Vishnu Reddy, stable
The hard IRQ handler disables the IRQ for every interrupt, and the
threaded handler re-enables it for non-watchdog interrupts. This
duplicates the masking and unmasking provided by IRQF_ONESHOT.
If power-off runs after the hard handler disables the IRQ but before
the threaded handler updates core->intr_status, and the stale status
indicates a non-watchdog interrupt, power-off disables the IRQ again.
The watchdog handler does not re-enable the IRQ, so the two disables
are not balanced by the single enable in power-on.
Request the IRQ with IRQF_ONESHOT and remove the hard IRQ handler.
Explicitly disable the IRQ in the threaded handler for watchdog
interrupts to prevent repeated triggering. Power-off always disables
the IRQ once, and power-on balances that disable and any additional
watchdog disable.
Fixes: bb8a95aa038e ("media: iris: implement power management")
Cc: stable@vger.kernel.org
Signed-off-by: Vishnu Reddy <busanna.reddy@oss.qualcomm.com>
---
drivers/media/platform/qcom/iris/iris_core.h | 2 ++
drivers/media/platform/qcom/iris/iris_hfi_common.c | 14 ++++----------
drivers/media/platform/qcom/iris/iris_hfi_common.h | 1 -
drivers/media/platform/qcom/iris/iris_probe.c | 5 +++--
drivers/media/platform/qcom/iris/iris_vpu_common.c | 7 +++++--
5 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/drivers/media/platform/qcom/iris/iris_core.h b/drivers/media/platform/qcom/iris/iris_core.h
index 3e4cf652bf39..468ccb551ec3 100644
--- a/drivers/media/platform/qcom/iris/iris_core.h
+++ b/drivers/media/platform/qcom/iris/iris_core.h
@@ -70,6 +70,7 @@ struct qcom_ubwc_cfg_data;
* @message_queue: shared interface queue to receive responses from firmware
* @debug_queue: shared interface queue to receive debug info from firmware
* @lock: a lock for this strucure
+ * @wdt_irq_disabled: IRQ was disabled by the handler on a watchdog interrupt
* @response_packet: a pointer to response packet from fw to driver
* @header_id: id of packet header
* @packet_id: id of packet
@@ -116,6 +117,7 @@ struct iris_core {
struct iris_iface_q_info message_queue;
struct iris_iface_q_info debug_queue;
struct mutex lock; /* lock for core related operations */
+ bool wdt_irq_disabled;
u8 *response_packet;
u32 header_id;
u32 packet_id;
diff --git a/drivers/media/platform/qcom/iris/iris_hfi_common.c b/drivers/media/platform/qcom/iris/iris_hfi_common.c
index dad906d03fdc..a27c543e75bc 100644
--- a/drivers/media/platform/qcom/iris/iris_hfi_common.c
+++ b/drivers/media/platform/qcom/iris/iris_hfi_common.c
@@ -90,13 +90,6 @@ int iris_hfi_core_init(struct iris_core *core)
return hfi_ops->sys_interframe_powercollapse(core);
}
-irqreturn_t iris_hfi_isr(int irq, void *data)
-{
- disable_irq_nosync(irq);
-
- return IRQ_WAKE_THREAD;
-}
-
irqreturn_t iris_hfi_isr_handler(int irq, void *data)
{
struct iris_core *core = data;
@@ -107,14 +100,15 @@ irqreturn_t iris_hfi_isr_handler(int irq, void *data)
mutex_lock(&core->lock);
pm_runtime_mark_last_busy(core->dev);
iris_vpu_clear_interrupt(core);
+ if (iris_vpu_watchdog(core, core->intr_status)) {
+ disable_irq_nosync(irq);
+ core->wdt_irq_disabled = true;
+ }
mutex_unlock(&core->lock);
if (core->hfi_sys_ops)
core->hfi_sys_ops->sys_hfi_response_handler(core);
- if (!iris_vpu_watchdog(core, core->intr_status))
- enable_irq(irq);
-
return IRQ_HANDLED;
}
diff --git a/drivers/media/platform/qcom/iris/iris_hfi_common.h b/drivers/media/platform/qcom/iris/iris_hfi_common.h
index 16099f9a25b6..366c9b81675c 100644
--- a/drivers/media/platform/qcom/iris/iris_hfi_common.h
+++ b/drivers/media/platform/qcom/iris/iris_hfi_common.h
@@ -157,7 +157,6 @@ int iris_hfi_core_init(struct iris_core *core);
int iris_hfi_pm_suspend(struct iris_core *core);
int iris_hfi_pm_resume(struct iris_core *core);
-irqreturn_t iris_hfi_isr(int irq, void *data);
irqreturn_t iris_hfi_isr_handler(int irq, void *data);
#endif
diff --git a/drivers/media/platform/qcom/iris/iris_probe.c b/drivers/media/platform/qcom/iris/iris_probe.c
index 343e44c6b9c4..cecd2282e29c 100644
--- a/drivers/media/platform/qcom/iris/iris_probe.c
+++ b/drivers/media/platform/qcom/iris/iris_probe.c
@@ -311,9 +311,10 @@ static int iris_probe(struct platform_device *pdev)
if (IS_ERR(core->ubwc_cfg))
return PTR_ERR(core->ubwc_cfg);
- ret = devm_request_threaded_irq(core->dev, core->irq, iris_hfi_isr,
+ ret = devm_request_threaded_irq(core->dev, core->irq, NULL,
iris_hfi_isr_handler,
- IRQF_TRIGGER_HIGH | IRQF_NO_AUTOEN,
+ IRQF_TRIGGER_HIGH | IRQF_NO_AUTOEN |
+ IRQF_ONESHOT,
"iris", core);
if (ret)
return ret;
diff --git a/drivers/media/platform/qcom/iris/iris_vpu_common.c b/drivers/media/platform/qcom/iris/iris_vpu_common.c
index 1e183fc4e58c..54ee7a671ef8 100644
--- a/drivers/media/platform/qcom/iris/iris_vpu_common.c
+++ b/drivers/media/platform/qcom/iris/iris_vpu_common.c
@@ -239,8 +239,7 @@ void iris_vpu_power_off(struct iris_core *core)
core->iris_platform_data->vpu_ops->power_off_controller(core);
iris_unset_icc_bw(core);
- if (!iris_vpu_watchdog(core, core->intr_status))
- disable_irq_nosync(core->irq);
+ disable_irq_nosync(core->irq);
}
int iris_vpu_power_on_controller(struct iris_core *core)
@@ -521,6 +520,10 @@ int iris_vpu_power_on(struct iris_core *core)
core->iris_platform_data->vpu_ops->interrupt_init(core);
core->intr_status = 0;
+ if (core->wdt_irq_disabled) {
+ core->wdt_irq_disabled = false;
+ enable_irq(core->irq);
+ }
enable_irq(core->irq);
return 0;
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v3 3/3] media: qcom: iris: Skip register access in IRQ handler after power-off
2026-11-20 7:42 [PATCH v3 0/3] media: qcom: iris: Fix IRQ synchronization during power-off Vishnu Reddy
2026-11-20 7:42 ` [PATCH v3 1/3] Revert "media: qcom: iris: use disable_irq() during power-off" Vishnu Reddy
2026-11-20 7:42 ` [PATCH v3 2/3] media: qcom: iris: Fix IRQ disable depth imbalance on watchdog interrupt Vishnu Reddy
@ 2026-11-20 7:42 ` Vishnu Reddy
2026-11-25 6:06 ` [PATCH v3 0/3] media: qcom: iris: Fix IRQ synchronization during power-off Wangao Wang
3 siblings, 0 replies; 5+ messages in thread
From: Vishnu Reddy @ 2026-11-20 7:42 UTC (permalink / raw)
To: Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
Bryan O'Donoghue, Mauro Carvalho Chehab, Konrad Dybcio,
Dmitry Baryshkov, Hungyu Lin, Stefan Schmidt, Hans Verkuil
Cc: Bryan O'Donoghue, linux-media, linux-arm-msm, linux-kernel,
Vishnu Reddy, stable
The threaded IRQ handler reads and clears the interrupt registers
under core->lock. Power-off disables the IRQ without waiting for a
queued handler. If the handler is woken and queued around the same
time power-off is entered, it runs after the VPU is powered down and
accesses the registers of powered-off hardware.
disable_irq() cannot be used to wait for the handler. The caller of
power-off holds core->lock and blocks in disable_irq() waiting for the
handler, while the handler blocks waiting for core->lock.
Track the power state in core->powered, which power-on and power-off
change under core->lock. The handler checks it after taking the lock
and returns without touching the hardware when the VPU is off.
Fixes: bb8a95aa038e ("media: iris: implement power management")
Cc: stable@vger.kernel.org
Signed-off-by: Vishnu Reddy <busanna.reddy@oss.qualcomm.com>
---
drivers/media/platform/qcom/iris/iris_core.h | 2 ++
drivers/media/platform/qcom/iris/iris_hfi_common.c | 6 ++++++
drivers/media/platform/qcom/iris/iris_vpu_common.c | 2 ++
3 files changed, 10 insertions(+)
diff --git a/drivers/media/platform/qcom/iris/iris_core.h b/drivers/media/platform/qcom/iris/iris_core.h
index 468ccb551ec3..ca1a55bec334 100644
--- a/drivers/media/platform/qcom/iris/iris_core.h
+++ b/drivers/media/platform/qcom/iris/iris_core.h
@@ -70,6 +70,7 @@ struct qcom_ubwc_cfg_data;
* @message_queue: shared interface queue to receive responses from firmware
* @debug_queue: shared interface queue to receive debug info from firmware
* @lock: a lock for this strucure
+ * @powered: VPU is powered on, protected by @lock
* @wdt_irq_disabled: IRQ was disabled by the handler on a watchdog interrupt
* @response_packet: a pointer to response packet from fw to driver
* @header_id: id of packet header
@@ -117,6 +118,7 @@ struct iris_core {
struct iris_iface_q_info message_queue;
struct iris_iface_q_info debug_queue;
struct mutex lock; /* lock for core related operations */
+ bool powered;
bool wdt_irq_disabled;
u8 *response_packet;
u32 header_id;
diff --git a/drivers/media/platform/qcom/iris/iris_hfi_common.c b/drivers/media/platform/qcom/iris/iris_hfi_common.c
index a27c543e75bc..b7be3ccf499a 100644
--- a/drivers/media/platform/qcom/iris/iris_hfi_common.c
+++ b/drivers/media/platform/qcom/iris/iris_hfi_common.c
@@ -98,6 +98,11 @@ irqreturn_t iris_hfi_isr_handler(int irq, void *data)
return IRQ_NONE;
mutex_lock(&core->lock);
+ if (!core->powered) {
+ mutex_unlock(&core->lock);
+ goto exit;
+ }
+
pm_runtime_mark_last_busy(core->dev);
iris_vpu_clear_interrupt(core);
if (iris_vpu_watchdog(core, core->intr_status)) {
@@ -109,6 +114,7 @@ irqreturn_t iris_hfi_isr_handler(int irq, void *data)
if (core->hfi_sys_ops)
core->hfi_sys_ops->sys_hfi_response_handler(core);
+exit:
return IRQ_HANDLED;
}
diff --git a/drivers/media/platform/qcom/iris/iris_vpu_common.c b/drivers/media/platform/qcom/iris/iris_vpu_common.c
index 54ee7a671ef8..73ac63376b91 100644
--- a/drivers/media/platform/qcom/iris/iris_vpu_common.c
+++ b/drivers/media/platform/qcom/iris/iris_vpu_common.c
@@ -234,6 +234,7 @@ void iris_vpu_power_off_hw(struct iris_core *core)
void iris_vpu_power_off(struct iris_core *core)
{
+ core->powered = false;
iris_opp_set_rate(core->dev, 0);
core->iris_platform_data->vpu_ops->power_off_hw(core);
core->iris_platform_data->vpu_ops->power_off_controller(core);
@@ -520,6 +521,7 @@ int iris_vpu_power_on(struct iris_core *core)
core->iris_platform_data->vpu_ops->interrupt_init(core);
core->intr_status = 0;
+ core->powered = true;
if (core->wdt_irq_disabled) {
core->wdt_irq_disabled = false;
enable_irq(core->irq);
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v3 0/3] media: qcom: iris: Fix IRQ synchronization during power-off
2026-11-20 7:42 [PATCH v3 0/3] media: qcom: iris: Fix IRQ synchronization during power-off Vishnu Reddy
` (2 preceding siblings ...)
2026-11-20 7:42 ` [PATCH v3 3/3] media: qcom: iris: Skip register access in IRQ handler after power-off Vishnu Reddy
@ 2026-11-25 6:06 ` Wangao Wang
3 siblings, 0 replies; 5+ messages in thread
From: Wangao Wang @ 2026-11-25 6:06 UTC (permalink / raw)
To: Vishnu Reddy, Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
Bryan O'Donoghue, Mauro Carvalho Chehab, Konrad Dybcio,
Dmitry Baryshkov, Hungyu Lin, Stefan Schmidt, Hans Verkuil
Cc: wangao.wang, Bryan O'Donoghue, linux-media, linux-arm-msm,
linux-kernel, stable
On 2026/11/20 15:42, Vishnu Reddy wrote:
> Commit b9c2215bdedc9c ("media: qcom: iris: use disable_irq() during
> power-off") changed the VPU power-off sequence to use disable_irq()
> instead of disable_irq_nosync(). This was intended to stop a queued
> threaded IRQ handler from accessing the hardware after power-off.
>
> However, iris_vpu_power_off() is called with core->lock held, and the
> threaded IRQ handler (iris_hfi_isr_handler()) takes this same lock. If
> the handler is queued when power-off begins, disable_irq() blocks
> waiting for the handler, while the handler blocks waiting for
> core->lock. This results in a deadlock.
>
> This series reverts the commit that introduced the deadlock and fixes
> the IRQ handling around power-off. It keeps the IRQ disable depth
> balanced across power-off and power-on, and makes sure a handler queued
> around power-off does not access the registers of powered-off hardware.
>
> Signed-off-by: Vishnu Reddy <busanna.reddy@oss.qualcomm.com>
> ---
> Changes in v3:
> - Used IRQF_ONESHOT and dropped the manual IRQ disable/enable (Bryan)
> - Avoided the irq_disabling flag, waitqueue and unlock of core->lock during power-off
> - Skipped the register access once the hardware is powered off
> - Link to v2: https://patch.msgid.link/20261111-fix-disable-irq-safely-v2-0-8e13f68c2ef9@oss.qualcomm.com
>
> Changes in v2:
> - Added new patch to handle the irq depth
> - Link to v1: https://patch.msgid.link/20261007-fix-disable-irq-safely-v1-0-45746f9a92de@oss.qualcomm.com
>
> ---
> Vishnu Reddy (3):
> Revert "media: qcom: iris: use disable_irq() during power-off"
> media: qcom: iris: Fix IRQ disable depth imbalance on watchdog interrupt
> media: qcom: iris: Skip register access in IRQ handler after power-off
>
> drivers/media/platform/qcom/iris/iris_core.h | 4 ++++
> drivers/media/platform/qcom/iris/iris_hfi_common.c | 20 ++++++++++----------
> drivers/media/platform/qcom/iris/iris_hfi_common.h | 1 -
> drivers/media/platform/qcom/iris/iris_probe.c | 5 +++--
> drivers/media/platform/qcom/iris/iris_vpu_common.c | 9 +++++++--
> 5 files changed, 24 insertions(+), 15 deletions(-)
> ---
> base-commit: adcad7f4e6332cff3d6d7165f41584899f598534
> change-id: 20261004-fix-disable-irq-safely-15b2f712800b
>
> Best regards,
> --
> Vishnu Reddy <busanna.reddy@oss.qualcomm.com>
Tested-by: Wangao Wang <wangao.wang@oss.qualcomm.com>
--
Best Regards,
Wangao
^ permalink raw reply [flat|nested] 5+ messages in thread