Skip to contentSkip to conversation

media: chips-media: wave5: Add system suspend/resume support

PATCH In review Thorsten Lannynd 3 participants 5 messages Jul 7 – Sep 9

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: chips-media: wave5: Add system suspend/resume support

Add SET_SYSTEM_SLEEP_PM_OPS with wave5_system_suspend() and wave5_system_resume() so the driver handles system suspend to RAM. When suspended, Wave5 should gracefully finish the job and shutdown. When resumed, Wave5 should resume the context and finish executing the suspended stream.

---
 .../platform/chips-media/wave5/wave5-vpu.c    | 30 +++++++++++++++++++
 1 file changed, 30 insertions(+)
drivers/media/platform/chips-media/wave5/wave5-vpu.c +30 -0
index 76d57c6b6..a83640751 100644
@@ -254,7 +254,37 @@ static __maybe_unused int wave5_pm_resume(struct device *dev)
 	return ret;
 }
 
+static __maybe_unused int wave5_system_suspend(struct device *dev)
+{
+	struct vpu_device *vpu = dev_get_drvdata(dev);
+
+	if (vpu->v4l2_m2m_dec_dev)
+		v4l2_m2m_suspend(vpu->v4l2_m2m_dec_dev);
+	if (vpu->v4l2_m2m_enc_dev)
+		v4l2_m2m_suspend(vpu->v4l2_m2m_enc_dev);
+
+	return pm_runtime_force_suspend(dev);
+}
+
+static __maybe_unused int wave5_system_resume(struct device *dev)
+{
+	struct vpu_device *vpu = dev_get_drvdata(dev);
+	int ret;
+
+	ret = pm_runtime_force_resume(dev);
+	if (ret < 0)
+		return ret;
+
+	if (vpu->v4l2_m2m_dec_dev)
+		v4l2_m2m_resume(vpu->v4l2_m2m_dec_dev);
+	if (vpu->v4l2_m2m_enc_dev)
+		v4l2_m2m_resume(vpu->v4l2_m2m_enc_dev);
+
+	return 0;
+}
+
 static const struct dev_pm_ops wave5_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(wave5_system_suspend, wave5_system_resume)
 	SET_RUNTIME_PM_OPS(wave5_pm_suspend, wave5_pm_resume, NULL)
 };
 
Signature · 1 line
2.34.1
#1 lore raw

Hi Thorsten,

Quoted 34 lines · Thorsten Lannynd

Add SET_SYSTEM_SLEEP_PM_OPS with wave5_system_suspend() and wave5_system_resume() so the driver handles system suspend to RAM. When suspended, Wave5 should gracefully finish the job and shutdown. When resumed, Wave5 should resume the context and finish executing the suspended stream.

---
 .../platform/chips-media/wave5/wave5-vpu.c    | 30 +++++++++++++++++++
 1 file changed, 30 insertions(+)
drivers/media/platform/chips-media/wave5/wave5-vpu.c +15 -0
index 76d57c6b6..a83640751 100644
@@ -254,7 +254,37 @@ static __maybe_unused int wave5_pm_resume(struct device *dev)
 	return ret;
 }
 
+static __maybe_unused int wave5_system_suspend(struct device *dev)
+{
+	struct vpu_device *vpu = dev_get_drvdata(dev);
+
+	if (vpu->v4l2_m2m_dec_dev)
+		v4l2_m2m_suspend(vpu->v4l2_m2m_dec_dev);
+	if (vpu->v4l2_m2m_enc_dev)
+		v4l2_m2m_suspend(vpu->v4l2_m2m_enc_dev);
+
+	return pm_runtime_force_suspend(dev);
+}
+
+static __maybe_unused int wave5_system_resume(struct device *dev)
+{
+	struct vpu_device *vpu = dev_get_drvdata(dev);

drivers/media/platform/chips-media/wave5/wave5-vpu.c static __maybe_unused int wave5_pm_resume(struct device *dev) · line 281

Quoted 10 lines
drivers/media/platform/chips-media/wave5/wave5-vpu.c +10 -0
+	int ret;
+
+	ret = pm_runtime_force_resume(dev);
+	if (ret < 0)
+		return ret;
+
+	if (vpu->v4l2_m2m_dec_dev)
+		v4l2_m2m_resume(vpu->v4l2_m2m_dec_dev);
+	if (vpu->v4l2_m2m_enc_dev)
+		v4l2_m2m_resume(vpu->v4l2_m2m_enc_dev);

Can you confirm that v4l2_m2m_dec_dev can be resumed before v4l2_m2m_enc_dev? Usually you would suspend devices and resume them in the opposite order so that you can preserve dependencies.

Best,
Kendall

Quoted 12 lines
drivers/media/platform/chips-media/wave5/wave5-vpu.c +5 -0
+
+	return 0;
+}
+
 static const struct dev_pm_ops wave5_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(wave5_system_suspend, wave5_system_resume)
 	SET_RUNTIME_PM_OPS(wave5_pm_suspend, wave5_pm_resume, NULL)
 };
 
Signature · 1 line
2.34.1
#2 lore raw

Hi Kendall,

Quoted 41 lines · Kendall Willis

Hi Thorsten,

drivers/media/platform/chips-media/wave5/wave5-vpu.c static __maybe_unused int

Quoted 17 lines · Thorsten Lannynd

Add SET_SYSTEM_SLEEP_PM_OPS with wave5_system_suspend() and wave5_system_resume() so the driver handles system suspend to RAM. When suspended, Wave5 should gracefully finish the job and shutdown. When resumed, Wave5 should resume the context and finish executing the suspended stream.

---
 .../platform/chips-media/wave5/wave5-vpu.c    | 30 +++++++++++++++++++
 1 file changed, 30 insertions(+)
drivers/media/platform/chips-media/wave5/wave5-vpu.c +0 -0
index 76d57c6b6..a83640751 100644
@@ -254,7 +254,37 @@ static __maybe_unused int

wave5_pm_resume(struct device *dev)

Quoted 21 lines
drivers/media/platform/chips-media/wave5/wave5-vpu.c +18 -0
 	return ret;
 }
 
+static __maybe_unused int wave5_system_suspend(struct device *dev) {
+	struct vpu_device *vpu = dev_get_drvdata(dev);
+
+	if (vpu->v4l2_m2m_dec_dev)
+		v4l2_m2m_suspend(vpu->v4l2_m2m_dec_dev);
+	if (vpu->v4l2_m2m_enc_dev)
+		v4l2_m2m_suspend(vpu->v4l2_m2m_enc_dev);
+
+	return pm_runtime_force_suspend(dev); }
+
+static __maybe_unused int wave5_system_resume(struct device *dev) {
+	struct vpu_device *vpu = dev_get_drvdata(dev);
+	int ret;
+
+	ret = pm_runtime_force_resume(dev);
+	if (ret < 0)
+		return ret;
+
Quoted 8 lines

drivers/media/platform/chips-media/wave5/wave5-vpu.c static __maybe_unused int wave5_pm_resume(struct device *dev) · line 281

Quoted 4 lines
drivers/media/platform/chips-media/wave5/wave5-vpu.c +4 -0
+	if (vpu->v4l2_m2m_dec_dev)
+		v4l2_m2m_resume(vpu->v4l2_m2m_dec_dev);
+	if (vpu->v4l2_m2m_enc_dev)
+		v4l2_m2m_resume(vpu->v4l2_m2m_enc_dev);

Can you confirm that v4l2_m2m_dec_dev can be resumed before v4l2_m2m_enc_dev? Usually you would suspend devices and resume them in the opposite order so that you can preserve dependencies.

Yes, both devices share the same IP and suspend/resume hooks, so the ordering should not matter.

Thanks,
Thorsten

Quoted 16 lines

Best,
Kendall

drivers/media/platform/chips-media/wave5/wave5-vpu.c static __maybe_unused int wave5_pm_resume(struct device *dev)

Quoted 6 lines
drivers/media/platform/chips-media/wave5/wave5-vpu.c +5 -0
+
+	return 0;
+}
+
 static const struct dev_pm_ops wave5_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(wave5_system_suspend,

wave5_system_resume)

drivers/media/platform/chips-media/wave5/wave5-vpu.c static __maybe_unused int · line 285

Quoted 1 line
drivers/media/platform/chips-media/wave5/wave5-vpu.c +0 -0
 	SET_RUNTIME_PM_OPS(wave5_pm_suspend, wave5_pm_resume,

NULL) };

Quoted 4 lines
drivers/media/platform/chips-media/wave5/wave5-vpu.c +0 -1
--

2.34.1

Reviewed-by
#3 lore raw
Quoted 51 lines · Thorsten

Hi Kendall,

Quoted 41 lines · Kendall Willis

Hi Thorsten,

drivers/media/platform/chips-media/wave5/wave5-vpu.c static __maybe_unused int

Quoted 17 lines · Thorsten Lannynd

Add SET_SYSTEM_SLEEP_PM_OPS with wave5_system_suspend() and wave5_system_resume() so the driver handles system suspend to RAM. When suspended, Wave5 should gracefully finish the job and shutdown. When resumed, Wave5 should resume the context and finish executing the suspended stream.

---
 .../platform/chips-media/wave5/wave5-vpu.c    | 30 +++++++++++++++++++
 1 file changed, 30 insertions(+)
drivers/media/platform/chips-media/wave5/wave5-vpu.c +0 -0
index 76d57c6b6..a83640751 100644
@@ -254,7 +254,37 @@ static __maybe_unused int

wave5_pm_resume(struct device *dev)

Quoted 21 lines
drivers/media/platform/chips-media/wave5/wave5-vpu.c +18 -0
 	return ret;
 }
 
+static __maybe_unused int wave5_system_suspend(struct device *dev) {
+	struct vpu_device *vpu = dev_get_drvdata(dev);
+
+	if (vpu->v4l2_m2m_dec_dev)
+		v4l2_m2m_suspend(vpu->v4l2_m2m_dec_dev);
+	if (vpu->v4l2_m2m_enc_dev)
+		v4l2_m2m_suspend(vpu->v4l2_m2m_enc_dev);
+
+	return pm_runtime_force_suspend(dev); }
+
+static __maybe_unused int wave5_system_resume(struct device *dev) {
+	struct vpu_device *vpu = dev_get_drvdata(dev);
+	int ret;
+
+	ret = pm_runtime_force_resume(dev);
+	if (ret < 0)
+		return ret;
+
Quoted 8 lines

drivers/media/platform/chips-media/wave5/wave5-vpu.c static __maybe_unused int wave5_pm_resume(struct device *dev) · line 281

Quoted 4 lines
drivers/media/platform/chips-media/wave5/wave5-vpu.c +4 -0
+	if (vpu->v4l2_m2m_dec_dev)
+		v4l2_m2m_resume(vpu->v4l2_m2m_dec_dev);
+	if (vpu->v4l2_m2m_enc_dev)
+		v4l2_m2m_resume(vpu->v4l2_m2m_enc_dev);

Can you confirm that v4l2_m2m_dec_dev can be resumed before v4l2_m2m_enc_dev? Usually you would suspend devices and resume them in the opposite order so that you can preserve dependencies.

Quoted 2 lines

Yes, both devices share the same IP and suspend/resume hooks, so the ordering should not matter.

Thanks for checking on this.

Quoted 19 lines

Thanks,
Thorsten

Quoted 16 lines

Best,
Kendall

drivers/media/platform/chips-media/wave5/wave5-vpu.c static __maybe_unused int wave5_pm_resume(struct device *dev)

Quoted 6 lines
drivers/media/platform/chips-media/wave5/wave5-vpu.c +5 -0
+
+	return 0;
+}
+
 static const struct dev_pm_ops wave5_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(wave5_system_suspend,

wave5_system_resume)

drivers/media/platform/chips-media/wave5/wave5-vpu.c static __maybe_unused int · line 285

Quoted 1 line
drivers/media/platform/chips-media/wave5/wave5-vpu.c +0 -0
 	SET_RUNTIME_PM_OPS(wave5_pm_suspend, wave5_pm_resume,

NULL) };

Quoted 4 lines
drivers/media/platform/chips-media/wave5/wave5-vpu.c +0 -1
--

2.34.1

maintainer Reviewed-by on v1 1/1
#4 lore raw
In reply to Thorsten Lannynd
Quoted 12 lines

-----Original Message-----
From: Thorsten Lannynd <[email protected]>
Sent: Wednesday, July 8, 2026 5:17 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Nas Chung <[email protected]>; jackson.lee <[email protected]>; Mauro Carvalho Chehab <[email protected]>; [email protected]
Subject: [PATCH] media: chips-media: wave5: Add system suspend/resume support

Quoted 7 lines

Add SET_SYSTEM_SLEEP_PM_OPS with wave5_system_suspend() and wave5_system_resume() so the driver handles system suspend to RAM. When suspended, Wave5 should gracefully finish the job and shutdown. When resumed, Wave5 should resume the context and finish executing the suspended stream.

thanks

Quoted 47 lines
---
 .../platform/chips-media/wave5/wave5-vpu.c    | 30 +++++++++++++++++++
 1 file changed, 30 insertions(+)
drivers/media/platform/chips-media/wave5/wave5-vpu.c +28 -1
index 76d57c6b6..a83640751 100644
@@ -254,7 +254,37 @@ static __maybe_unused int wave5_pm_resume(struct
 device *dev)
 	return ret;
 }
 
+static __maybe_unused int wave5_system_suspend(struct device *dev) {
+	struct vpu_device *vpu = dev_get_drvdata(dev);
+
+	if (vpu->v4l2_m2m_dec_dev)
+		v4l2_m2m_suspend(vpu->v4l2_m2m_dec_dev);
+	if (vpu->v4l2_m2m_enc_dev)
+		v4l2_m2m_suspend(vpu->v4l2_m2m_enc_dev);
+
+	return pm_runtime_force_suspend(dev);
+}
+
+static __maybe_unused int wave5_system_resume(struct device *dev) {
+	struct vpu_device *vpu = dev_get_drvdata(dev);
+	int ret;
+
+	ret = pm_runtime_force_resume(dev);
+	if (ret < 0)
+		return ret;
+
+	if (vpu->v4l2_m2m_dec_dev)
+		v4l2_m2m_resume(vpu->v4l2_m2m_dec_dev);
+	if (vpu->v4l2_m2m_enc_dev)
+		v4l2_m2m_resume(vpu->v4l2_m2m_enc_dev);
+
+	return 0;
+}
+
 static const struct dev_pm_ops wave5_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(wave5_system_suspend, wave5_system_resume)
 	SET_RUNTIME_PM_OPS(wave5_pm_suspend, wave5_pm_resume, NULL)  };
 
--

2.34.1