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 --- 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