* [PATCH v4 0/3] media: qcom: iris: Fix IRQ synchronization during power-off
@ 2026-12-03 6:59 Vishnu Reddy
2026-12-03 6:59 ` [PATCH v4 1/3] Revert "media: qcom: iris: use disable_irq() during power-off" Vishnu Reddy
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Vishnu Reddy @ 2026-12-03 6:59 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, Wangao Wang
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 v4:
- Masked the watchdog interrupt instead of disabling the IRQ (Bryan)
- Dropped the wdt_irq_disabled and powered flags (Bryan)
- Updated the commit descriptions
- Link to v3: https://patch.msgid.link/20261120-fix-disable-irq-safely-v3-0-82f9561394cb@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_hfi_common.c | 25 +++++++++++++---------
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 | 13 +++++++++--
drivers/media/platform/qcom/iris/iris_vpu_common.h | 1 +
5 files changed, 30 insertions(+), 15 deletions(-)
---
base-commit: 799dd936553182df5770dde7f38d94c8337df75a
change-id: 20261004-fix-disable-irq-safely-15b2f712800b
Best regards,
--
Vishnu Reddy <busanna.reddy@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v4 1/3] Revert "media: qcom: iris: use disable_irq() during power-off" 2026-12-03 6:59 [PATCH v4 0/3] media: qcom: iris: Fix IRQ synchronization during power-off Vishnu Reddy @ 2026-12-03 6:59 ` Vishnu Reddy 2026-12-03 6:59 ` [PATCH v4 2/3] media: qcom: iris: Fix IRQ disable depth imbalance on watchdog interrupt Vishnu Reddy 2026-12-03 6:59 ` [PATCH v4 3/3] media: qcom: iris: Skip register access in IRQ handler after power-off Vishnu Reddy 2 siblings, 0 replies; 7+ messages in thread From: Vishnu Reddy @ 2026-12-03 6:59 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, Wangao Wang 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 Reviewed-by: Vikash Garodia <vikash.garodia@oss.qualcomm.com> Tested-by: Wangao Wang <wangao.wang@oss.qualcomm.com> 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 related [flat|nested] 7+ messages in thread
* [PATCH v4 2/3] media: qcom: iris: Fix IRQ disable depth imbalance on watchdog interrupt 2026-12-03 6:59 [PATCH v4 0/3] media: qcom: iris: Fix IRQ synchronization during power-off Vishnu Reddy 2026-12-03 6:59 ` [PATCH v4 1/3] Revert "media: qcom: iris: use disable_irq() during power-off" Vishnu Reddy @ 2026-12-03 6:59 ` Vishnu Reddy 2026-12-03 9:18 ` Bryan O'Donoghue 2026-12-03 6:59 ` [PATCH v4 3/3] media: qcom: iris: Skip register access in IRQ handler after power-off Vishnu Reddy 2 siblings, 1 reply; 7+ messages in thread From: Vishnu Reddy @ 2026-12-03 6:59 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, Wangao Wang Currently, the hard IRQ handler disables the IRQ for every interrupt to keep the level triggered IRQ from firing again until the threaded handler clears its source. The threaded handler then re-enables it for non-watchdog interrupts. Instead of doing this manually, IRQF_ONESHOT can be used, which keeps the IRQ masked until the threaded handler completes. 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. The watchdog interrupt stays asserted until the VPU is reset, so mask it in the wrapper interrupt mask register when it fires to prevent repeated triggering. The next power-on unmasks it again when it initializes the interrupts. Power-off disables the IRQ once and power-on enables it once. Fixes: bb8a95aa038e ("media: iris: implement power management") Cc: stable@vger.kernel.org Reviewed-by: Vikash Garodia <vikash.garodia@oss.qualcomm.com> Tested-by: Wangao Wang <wangao.wang@oss.qualcomm.com> Signed-off-by: Vishnu Reddy <busanna.reddy@oss.qualcomm.com> --- drivers/media/platform/qcom/iris/iris_hfi_common.c | 12 ++---------- 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 | 13 +++++++++++-- drivers/media/platform/qcom/iris/iris_vpu_common.h | 1 + 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/media/platform/qcom/iris/iris_hfi_common.c b/drivers/media/platform/qcom/iris/iris_hfi_common.c index dad906d03fdc..ed8d6e0368b4 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,13 @@ 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)) + iris_vpu_mask_watchdog_interrupt(core); 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..a1bab1fb236a 100644 --- a/drivers/media/platform/qcom/iris/iris_vpu_common.c +++ b/drivers/media/platform/qcom/iris/iris_vpu_common.c @@ -135,6 +135,16 @@ int iris_vpu_watchdog(struct iris_core *core, u32 intr_status) return 0; } +void iris_vpu_mask_watchdog_interrupt(struct iris_core *core) +{ + u32 wd_intr_mask = core->iris_platform_data->wd_intr_mask; + u32 mask_val; + + mask_val = readl(core->reg_base + WRAPPER_INTR_MASK); + mask_val |= wd_intr_mask; + writel(mask_val, core->reg_base + WRAPPER_INTR_MASK); +} + int iris_vpu_prepare_pc(struct iris_core *core) { u32 wfi_status, idle_status, pc_ready; @@ -239,8 +249,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) diff --git a/drivers/media/platform/qcom/iris/iris_vpu_common.h b/drivers/media/platform/qcom/iris/iris_vpu_common.h index a62b6184bde7..7ab77c786e35 100644 --- a/drivers/media/platform/qcom/iris/iris_vpu_common.h +++ b/drivers/media/platform/qcom/iris/iris_vpu_common.h @@ -32,6 +32,7 @@ int iris_vpu_boot_firmware(struct iris_core *core); void iris_vpu_raise_interrupt(struct iris_core *core); void iris_vpu_clear_interrupt(struct iris_core *core); int iris_vpu_watchdog(struct iris_core *core, u32 intr_status); +void iris_vpu_mask_watchdog_interrupt(struct iris_core *core); int iris_vpu_prepare_pc(struct iris_core *core); int iris_vpu_power_on_controller(struct iris_core *core); int iris_vpu_power_on_hw(struct iris_core *core); -- 2.34.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v4 2/3] media: qcom: iris: Fix IRQ disable depth imbalance on watchdog interrupt 2026-12-03 6:59 ` [PATCH v4 2/3] media: qcom: iris: Fix IRQ disable depth imbalance on watchdog interrupt Vishnu Reddy @ 2026-12-03 9:18 ` Bryan O'Donoghue 0 siblings, 0 replies; 7+ messages in thread From: Bryan O'Donoghue @ 2026-12-03 9:18 UTC (permalink / raw) To: Vishnu Reddy, Vikash Garodia, Dikshita Agarwal, Abhinav Kumar, Mauro Carvalho Chehab, Konrad Dybcio, Dmitry Baryshkov, Hungyu Lin, Stefan Schmidt, Hans Verkuil Cc: Bryan O'Donoghue, linux-media, linux-arm-msm, linux-kernel, stable, Wangao Wang On 03/12/2026 06:59, Vishnu Reddy wrote: > Currently, the hard IRQ handler disables the IRQ for every interrupt > to keep the level triggered IRQ from firing again until the threaded > handler clears its source. The threaded handler then re-enables it for > non-watchdog interrupts. Instead of doing this manually, IRQF_ONESHOT > can be used, which keeps the IRQ masked until the threaded handler > completes. > > 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. > The watchdog interrupt stays asserted until the VPU is reset, so mask > it in the wrapper interrupt mask register when it fires to prevent > repeated triggering. The next power-on unmasks it again when it > initializes the interrupts. Power-off disables the IRQ once and > power-on enables it once. Great. > Fixes: bb8a95aa038e ("media: iris: implement power management") > Cc: stable@vger.kernel.org > Reviewed-by: Vikash Garodia <vikash.garodia@oss.qualcomm.com> With the amount of change since the RB was given, I don't think this patch can continue to carry it. A significant change to code should also come with an honest appraisal of whether RB should be carried and "doing the right thing" if not. I think this patch now requires a re-up for RB and TB since it has experienced non-trivial churn. > Tested-by: Wangao Wang <wangao.wang@oss.qualcomm.com> > Signed-off-by: Vishnu Reddy <busanna.reddy@oss.qualcomm.com> That said, I think this patch is correct now. Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> > drivers/media/platform/qcom/iris/iris_hfi_common.c | 12 ++---------- > 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 | 13 +++++++++++-- > drivers/media/platform/qcom/iris/iris_vpu_common.h | 1 + > 5 files changed, 17 insertions(+), 15 deletions(-) > > diff --git a/drivers/media/platform/qcom/iris/iris_hfi_common.c b/drivers/media/platform/qcom/iris/iris_hfi_common.c > index dad906d03fdc..ed8d6e0368b4 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,13 @@ 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)) > + iris_vpu_mask_watchdog_interrupt(core); > 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..a1bab1fb236a 100644 > --- a/drivers/media/platform/qcom/iris/iris_vpu_common.c > +++ b/drivers/media/platform/qcom/iris/iris_vpu_common.c > @@ -135,6 +135,16 @@ int iris_vpu_watchdog(struct iris_core *core, u32 intr_status) > return 0; > } > > +void iris_vpu_mask_watchdog_interrupt(struct iris_core *core) > +{ > + u32 wd_intr_mask = core->iris_platform_data->wd_intr_mask; > + u32 mask_val; > + > + mask_val = readl(core->reg_base + WRAPPER_INTR_MASK); > + mask_val |= wd_intr_mask; > + writel(mask_val, core->reg_base + WRAPPER_INTR_MASK); > +} > + > int iris_vpu_prepare_pc(struct iris_core *core) > { > u32 wfi_status, idle_status, pc_ready; > @@ -239,8 +249,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) > diff --git a/drivers/media/platform/qcom/iris/iris_vpu_common.h b/drivers/media/platform/qcom/iris/iris_vpu_common.h > index a62b6184bde7..7ab77c786e35 100644 > --- a/drivers/media/platform/qcom/iris/iris_vpu_common.h > +++ b/drivers/media/platform/qcom/iris/iris_vpu_common.h > @@ -32,6 +32,7 @@ int iris_vpu_boot_firmware(struct iris_core *core); > void iris_vpu_raise_interrupt(struct iris_core *core); > void iris_vpu_clear_interrupt(struct iris_core *core); > int iris_vpu_watchdog(struct iris_core *core, u32 intr_status); > +void iris_vpu_mask_watchdog_interrupt(struct iris_core *core); > int iris_vpu_prepare_pc(struct iris_core *core); > int iris_vpu_power_on_controller(struct iris_core *core); > int iris_vpu_power_on_hw(struct iris_core *core); > > -- > 2.34.1 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v4 3/3] media: qcom: iris: Skip register access in IRQ handler after power-off 2026-12-03 6:59 [PATCH v4 0/3] media: qcom: iris: Fix IRQ synchronization during power-off Vishnu Reddy 2026-12-03 6:59 ` [PATCH v4 1/3] Revert "media: qcom: iris: use disable_irq() during power-off" Vishnu Reddy 2026-12-03 6:59 ` [PATCH v4 2/3] media: qcom: iris: Fix IRQ disable depth imbalance on watchdog interrupt Vishnu Reddy @ 2026-12-03 6:59 ` Vishnu Reddy 2026-12-03 9:37 ` Bryan O'Donoghue 2026-12-03 9:44 ` Bryan O'Donoghue 2 siblings, 2 replies; 7+ messages in thread From: Vishnu Reddy @ 2026-12-03 6:59 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, Wangao Wang 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. The IRQ is enabled only in power-on and disabled only in power-off, both under core->lock, and it starts disabled due to IRQF_NO_AUTOEN. So the IRQ disabled state tells whether the VPU is powered on. In the threaded handler, check it after taking core->lock. If the IRQ is already disabled, the handler was queued before power-off and the VPU is already powered off, so return without accessing the hardware. Fixes: bb8a95aa038e ("media: iris: implement power management") Cc: stable@vger.kernel.org Reviewed-by: Vikash Garodia <vikash.garodia@oss.qualcomm.com> Tested-by: Wangao Wang <wangao.wang@oss.qualcomm.com> Signed-off-by: Vishnu Reddy <busanna.reddy@oss.qualcomm.com> --- drivers/media/platform/qcom/iris/iris_hfi_common.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/media/platform/qcom/iris/iris_hfi_common.c b/drivers/media/platform/qcom/iris/iris_hfi_common.c index ed8d6e0368b4..bbc5d632473d 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_common.c +++ b/drivers/media/platform/qcom/iris/iris_hfi_common.c @@ -3,6 +3,7 @@ * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved. */ +#include <linux/irq.h> #include <linux/pm_runtime.h> #include "iris_firmware.h" @@ -98,6 +99,18 @@ irqreturn_t iris_hfi_isr_handler(int irq, void *data) return IRQ_NONE; mutex_lock(&core->lock); + /* + * Power-on enables the IRQ and power-off disables it, both under + * core->lock, so with core->lock held the IRQ is disabled only when + * the VPU is powered off. This happens when the threaded handler was + * queued and then blocked on core->lock while power-off was running. + * Bail out without touching the registers of the powered-off VPU. + */ + if (irqd_irq_disabled(irq_get_irq_data(irq))) { + mutex_unlock(&core->lock); + return IRQ_HANDLED; + } + pm_runtime_mark_last_busy(core->dev); iris_vpu_clear_interrupt(core); if (iris_vpu_watchdog(core, core->intr_status)) -- 2.34.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v4 3/3] media: qcom: iris: Skip register access in IRQ handler after power-off 2026-12-03 6:59 ` [PATCH v4 3/3] media: qcom: iris: Skip register access in IRQ handler after power-off Vishnu Reddy @ 2026-12-03 9:37 ` Bryan O'Donoghue 2026-12-03 9:44 ` Bryan O'Donoghue 1 sibling, 0 replies; 7+ messages in thread From: Bryan O'Donoghue @ 2026-12-03 9:37 UTC (permalink / raw) To: Vishnu Reddy, Vikash Garodia, Dikshita Agarwal, Abhinav Kumar, Mauro Carvalho Chehab, Konrad Dybcio, Dmitry Baryshkov, Hungyu Lin, Stefan Schmidt, Hans Verkuil Cc: Bryan O'Donoghue, linux-media, linux-arm-msm, linux-kernel, stable, Wangao Wang On 03/12/2026 06:59, Vishnu Reddy wrote: > 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. > > The IRQ is enabled only in power-on and disabled only in power-off, > both under core->lock, and it starts disabled due to IRQF_NO_AUTOEN. > So the IRQ disabled state tells whether the VPU is powered on. In the > threaded handler, check it after taking core->lock. If the IRQ is > already disabled, the handler was queued before power-off and the VPU > is already powered off, so return without accessing the hardware. > > Fixes: bb8a95aa038e ("media: iris: implement power management") > Cc: stable@vger.kernel.org > Reviewed-by: Vikash Garodia <vikash.garodia@oss.qualcomm.com> > Tested-by: Wangao Wang <wangao.wang@oss.qualcomm.com> > Signed-off-by: Vishnu Reddy <busanna.reddy@oss.qualcomm.com> > --- > drivers/media/platform/qcom/iris/iris_hfi_common.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/drivers/media/platform/qcom/iris/iris_hfi_common.c b/drivers/media/platform/qcom/iris/iris_hfi_common.c > index ed8d6e0368b4..bbc5d632473d 100644 > --- a/drivers/media/platform/qcom/iris/iris_hfi_common.c > +++ b/drivers/media/platform/qcom/iris/iris_hfi_common.c > @@ -3,6 +3,7 @@ > * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved. > */ > > +#include <linux/irq.h> > #include <linux/pm_runtime.h> > > #include "iris_firmware.h" > @@ -98,6 +99,18 @@ irqreturn_t iris_hfi_isr_handler(int irq, void *data) > return IRQ_NONE; > > mutex_lock(&core->lock); > + /* > + * Power-on enables the IRQ and power-off disables it, both under > + * core->lock, so with core->lock held the IRQ is disabled only when > + * the VPU is powered off. This happens when the threaded handler was > + * queued and then blocked on core->lock while power-off was running. > + * Bail out without touching the registers of the powered-off VPU. > + */ > + if (irqd_irq_disabled(irq_get_irq_data(irq))) { > + mutex_unlock(&core->lock); > + return IRQ_HANDLED; > + } > + This is a horrible hack. Just do disable_irq_sync() in your power-off routine before taking a critical section ... ? diff --git a/drivers/media/platform/qcom/iris/iris_core.c b/drivers/media/platform/qcom/iris/iris_core.c index d558475986ff0..7ebe513658c64 100644 --- a/drivers/media/platform/qcom/iris/iris_core.c +++ b/drivers/media/platform/qcom/iris/iris_core.c @@ -17,6 +17,8 @@ void iris_core_deinit(struct iris_core *core) ret = pm_runtime_resume_and_get(core->dev); + disable_irq_sync(core->irq); + mutex_lock(&core->lock); if (core->state != IRIS_CORE_DEINIT) { iris_fw_unload(core); diff --git a/drivers/media/platform/qcom/iris/iris_vpu_common.c b/drivers/media/platform/qcom/iris/iris_vpu_common.c index 243bd845349fe..dfe2a737b7576 100644 --- a/drivers/media/platform/qcom/iris/iris_vpu_common.c +++ b/drivers/media/platform/qcom/iris/iris_vpu_common.c @@ -238,9 +238,6 @@ void iris_vpu_power_off(struct iris_core *core) core->iris_platform_data->vpu_ops->power_off_hw(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(core->irq); } int iris_vpu_power_on_controller(struct iris_core *core) --- bod ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v4 3/3] media: qcom: iris: Skip register access in IRQ handler after power-off 2026-12-03 6:59 ` [PATCH v4 3/3] media: qcom: iris: Skip register access in IRQ handler after power-off Vishnu Reddy 2026-12-03 9:37 ` Bryan O'Donoghue @ 2026-12-03 9:44 ` Bryan O'Donoghue 1 sibling, 0 replies; 7+ messages in thread From: Bryan O'Donoghue @ 2026-12-03 9:44 UTC (permalink / raw) To: Bryan O'Donoghue, Vishnu Reddy, Vikash Garodia, Dikshita Agarwal, Abhinav Kumar, Mauro Carvalho Chehab, Konrad Dybcio, Dmitry Baryshkov, Hungyu Lin, Stefan Schmidt, Hans Verkuil Cc: Bryan O'Donoghue, linux-media, linux-arm-msm, linux-kernel, stable, Wangao Wang On 03/12/2026 09:37, Bryan O'Donoghue wrote: > Just do disable_irq_sync() in your power-off routine before taking a > critical section ... ? *disable_irq(); --- bod ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-12-03 9:44 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-12-03 6:59 [PATCH v4 0/3] media: qcom: iris: Fix IRQ synchronization during power-off Vishnu Reddy 2026-12-03 6:59 ` [PATCH v4 1/3] Revert "media: qcom: iris: use disable_irq() during power-off" Vishnu Reddy 2026-12-03 6:59 ` [PATCH v4 2/3] media: qcom: iris: Fix IRQ disable depth imbalance on watchdog interrupt Vishnu Reddy 2026-12-03 9:18 ` Bryan O'Donoghue 2026-12-03 6:59 ` [PATCH v4 3/3] media: qcom: iris: Skip register access in IRQ handler after power-off Vishnu Reddy 2026-12-03 9:37 ` Bryan O'Donoghue 2026-12-03 9:44 ` Bryan O'Donoghue
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox