Re: [PATCH v4 3/3] media: qcom: iris: Skip register access in IRQ handler after power-off
From: Bryan O'Donoghue
Date: Thu Dec 03 2026 - 04:37:26 EST
On 03/12/2026 06:59, Vishnu Reddy wrote:
The threaded IRQ handler reads and clears the interrupt registersThis is a horrible hack.
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;
+ }
+
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