mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: bod@kernel.org
To: Abel Vesa <abel.vesa@oss.qualcomm.com>
Cc: Vikash Garodia <vikash.garodia@oss.qualcomm.com>,
	 Dikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>,
	 Abhinav Kumar <abhinav.kumar@linux.dev>,
	Bryan O'Donoghue <bod@kernel.org>,
	 Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-media@vger.kernel.org,  linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] media: iris: Unload the firmware before hibernation
Date: Tue, 17 Nov 2026 12:42:14 +0000	[thread overview]
Message-ID: <179491933438.2846709.5025592842946674041.b4-reply@b4> (raw)
In-Reply-To: <20261026-b4-media-iris-unload-firmware-hibernation-v1-1-c1af57ac16b1@oss.qualcomm.com>

On 2026-10-26 15:39 +0200, Abel Vesa wrote:
> A hibernation image is restored after a power cycle, by a kernel that
> may have loaded the firmware itself. Neither the firmware, which lives
> in memory the image does not hold, nor its authentication by the
> TrustZone survive that, so resuming the core from the restored kernel
> fails:
> 
>   qcom-iris aa00000.video-codec: failed to resume
> 
> Make sure the image does not hold an initialized core. Unload the
> firmware before the image is created, and before the kernel that loads
> the image jumps into it, so that the next session loads it again. Keep
> the system error handler disabled meanwhile, so that it cannot load the
> firmware again behind our back.
> 
> Refuse to hibernate while the device is open, as its sessions cannot
> survive this. Failing them the way a system error does would let
> hibernation go on, but would break every open file handle on each
> hibernation, without userspace having a chance to tear the session
> down cleanly.
> 
> Signed-off-by: Abel Vesa <abel.vesa@oss.qualcomm.com>
> ---
> Prepared with help from an LLM-based assistant.
> ---
>  drivers/media/platform/qcom/iris/iris_probe.c | 44 +++++++++++++++++++++++++--
>  1 file changed, 42 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/qcom/iris/iris_probe.c b/drivers/media/platform/qcom/iris/iris_probe.c
> index 41dec90f3e2b..ea77c573b333 100644
> --- a/drivers/media/platform/qcom/iris/iris_probe.c
> +++ b/drivers/media/platform/qcom/iris/iris_probe.c
> @@ -411,9 +411,49 @@ static int __maybe_unused iris_pm_resume(struct device *dev)
>  	return ret;
>  }
>  
> +/*
> + * Neither the firmware nor its TrustZone authentication survive hibernation,
> + * so do not let the image hold an initialized core.
> + */


> +static int iris_pm_freeze(struct device *dev)
> +{
> +	struct iris_core *core = dev_get_drvdata(dev);
> +	int ret;
> +
> +	scoped_guard(mutex, &core->lock) {
> +		if (!list_empty(&core->instances)) {
> +			dev_err(dev, "cannot hibernate while the device is open\n");
> +			return -EBUSY;
> +		}
> +	}
> +
> +	/* Keep a system error from loading the firmware again */
> +	disable_delayed_work_sync(&core->sys_error_handler);
> +	iris_core_deinit(core);

I think the logic here is generally good. One thing though - we appear to
have cancel_delayed_work_sync() + iris_core_deinit() in iris_remove() and
now here disable_delayed_work_sync() + iris_core_deinit().

I think the iris_remove() should be disable_delayed_work_sync() it seems to
be the same error as this:

https://lore.kernel.org/linux-media/20261023223635.3c895c4752c4-3-mhun512@gmail.com

So perhaps a patch before this patch which Fixes: the
cancel_delayed_work_sync() in iris_remove() and then you can use a helper
function 

abels_super_cool_teardown() {

- disable_delayed_work_sync();
- iris_core_deinit();

}

in both iris_remove() and iris_pm_freeze()

> +
> +	ret = pm_runtime_force_suspend(dev);
> +	if (ret)
> +		enable_delayed_work(&core->sys_error_handler);
> +
> +	return ret;
> +}
> +
> +static int iris_pm_thaw(struct device *dev)
> +{
> +	struct iris_core *core = dev_get_drvdata(dev);
> +
> +	enable_delayed_work(&core->sys_error_handler);

I was going to ask about when the firmware gets loaded but its done in
iris_open() so I think this is fine.
---
bod


  reply	other threads:[~2026-11-17 12:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-26 13:39 Abel Vesa
2026-11-17 12:42 ` bod [this message]
2026-12-01 20:37 ` Kaylin Aurora

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=179491933438.2846709.5025592842946674041.b4-reply@b4 \
    --to=bod@kernel.org \
    --cc=abel.vesa@oss.qualcomm.com \
    --cc=abhinav.kumar@linux.dev \
    --cc=dikshita.agarwal@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=vikash.garodia@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

all inboxes | Powered by JetHome®