[PATCH v9 3/4] media: imagination: e5010: Update e5010_init_device Call Sites to Ensure Proper Device State
From: Brandon Brnich
Date: Wed Nov 11 2026 - 12:15:37 EST
The PM framework skips the runtime resume hook if the device was never on
in the first place. This results in a crash in the system resume hook when
a call to e5010_init_device() attempts a write to a powered down device.
Move e5010_init_device() to the resume hook to ensure register write only
occurs when device is properly powered on.
e5010_reset() resets the whole IP, which reverts all registers,
including the interrupt enables, input source and quantization
tables, back to their reset defaults. Call e5010_init_device() after the
reset so the next device_run() starts from a properly programmed
device. e5010->last_context_run in e5010_init_device() should be set to
NULL as well to guarantee the next device_run() reloads the user-configured
QP tables instead of encoding with the default ones.
Fixes: a1e294045885 ("media: imagination: Add E5010 JPEG Encoder driver")
Cc: stable@xxxxxxxxxxxxxxx
Reviewed-by: Devarsh Thakkar <devarsht@xxxxxx>
Signed-off-by: Brandon Brnich <b-brnich@xxxxxx>
---
.../platform/imagination/e5010-jpeg-enc.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/drivers/media/platform/imagination/e5010-jpeg-enc.c b/drivers/media/platform/imagination/e5010-jpeg-enc.c
index c9dc12126cf9c..2da43c14a25c8 100644
--- a/drivers/media/platform/imagination/e5010-jpeg-enc.c
+++ b/drivers/media/platform/imagination/e5010-jpeg-enc.c
@@ -986,6 +986,8 @@ static int e5010_init_device(struct e5010_dev *e5010)
{
int ret = 0;
+ e5010->last_context_run = NULL;
+
/*TODO: Set MMU in bypass mode until support for the same is added in driver*/
e5010_hw_bypass_mmu(e5010->mmu_base, 1);
@@ -1487,7 +1489,9 @@ static void e5010_device_run(void *priv)
device_busy_err:
e5010_reset(e5010->dev, e5010->core_base, e5010->mmu_base);
-
+ ret = e5010_init_device(e5010);
+ if (ret)
+ v4l2_err(&e5010->v4l2_dev, "failed to initialize device after reset\n");
no_ready_buf_err:
if (s_vb) {
v4l2_m2m_src_buf_remove_by_buf(ctx->fh.m2m_ctx, s_vb);
@@ -1516,6 +1520,13 @@ static int e5010_runtime_resume(struct device *dev)
return ret;
}
+ ret = e5010_init_device(e5010);
+ if (ret) {
+ dev_err(dev, "Failed to re-enable e5010 device\n");
+ clk_disable_unprepare(e5010->clk);
+ return ret;
+ }
+
return 0;
}
@@ -1548,12 +1559,6 @@ static int e5010_resume(struct device *dev)
if (ret < 0)
return ret;
- ret = e5010_init_device(e5010);
- if (ret) {
- dev_err(dev, "Failed to re-enable e5010 device\n");
- return ret;
- }
-
v4l2_m2m_resume(e5010->m2m_dev);
return ret;
--
2.43.0