Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
From: Bryan O'Donoghue <bod@kernel.org>
To: Vishnu Reddy <busanna.reddy@oss.qualcomm.com>,
	Vikash Garodia <vikash.garodia@oss.qualcomm.com>,
	Dikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>,
	Abhinav Kumar <abhinav.kumar@linux.dev>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>,
	Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,
	Hungyu Lin <dennylin0707@gmail.com>,
	Stefan Schmidt <stefan.schmidt@linaro.org>,
	Hans Verkuil <hverkuil@kernel.org>
Cc: Bryan O'Donoghue <bryan.odonoghue@linaro.org>,
	linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	Wangao Wang <wangao.wang@oss.qualcomm.com>
Subject: Re: [PATCH v4 3/3] media: qcom: iris: Skip register access in IRQ handler after power-off
Date: Thu, 3 Dec 2026 09:37:17 +0000	[thread overview]
Message-ID: <1c36bdee-a3ca-4830-a652-ba669e5eb7f9@kernel.org> (raw)
In-Reply-To: <20261203-fix-disable-irq-safely-v4-3-2774a9e036b2@oss.qualcomm.com>

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

  reply	other threads:[~2026-12-03  9:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2026-12-03  9:44   ` Bryan O'Donoghue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1c36bdee-a3ca-4830-a652-ba669e5eb7f9@kernel.org \
    --to=bod@kernel.org \
    --cc=abhinav.kumar@linux.dev \
    --cc=bryan.odonoghue@linaro.org \
    --cc=busanna.reddy@oss.qualcomm.com \
    --cc=dennylin0707@gmail.com \
    --cc=dikshita.agarwal@oss.qualcomm.com \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=hverkuil@kernel.org \
    --cc=konrad.dybcio@oss.qualcomm.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=stefan.schmidt@linaro.org \
    --cc=vikash.garodia@oss.qualcomm.com \
    --cc=wangao.wang@oss.qualcomm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox