Re: [PATCH] media: iris: Unload the firmware before hibernation
From: bod
Date: Tue Nov 17 2026 - 07:43:57 EST
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@xxxxxxxxxxxxxxxx>
> ---
> 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@xxxxxxxxx
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