[PATCH v4 3/3] media: qcom: iris: Skip register access in IRQ handler after power-off
From: Vishnu Reddy
Date: Thu Dec 03 2026 - 01:59:50 EST
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@xxxxxxxxxxxxxxx
Reviewed-by: Vikash Garodia <vikash.garodia@xxxxxxxxxxxxxxxx>
Tested-by: Wangao Wang <wangao.wang@xxxxxxxxxxxxxxxx>
Signed-off-by: Vishnu Reddy <busanna.reddy@xxxxxxxxxxxxxxxx>
---
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