media: amphion: fix a bug that vpu core may not resume after suspend
Subsystems (2)
Ming Qian
maintainerPATCH 1/1 media: amphion: fix a bug that vpu core may not resume after suspend
driver will enable the vpu core when request the first instance on the core.
one vpu core can only support 8 streaming instances in the same time, the instance won't be added to core's list before streamon.
so the actual instance count may be greater then the number in the core's list.
in pm resume callback, driver will resume the core immediately if core's list is not empty.
but this check is not accurate,
if suspend during one instance is requested, but not streamon, then after suspend, the core won't be resume, and led to instance failure.
use the request_count instead of the core's list to check whether is the core needed to resume immediately after suspend.
And it can make the pm suspend and resume callback more clear.
--- drivers/media/platform/amphion/vpu.h | 1 - drivers/media/platform/amphion/vpu_core.c | 84 ++++++++++++----------- drivers/media/platform/amphion/vpu_core.h | 1 + drivers/media/platform/amphion/vpu_dbg.c | 9 ++- 4 files changed, 51 insertions(+), 44 deletions(-)
drivers/media/platform/amphion/vpu.h +0 -1
@@ -121,7 +121,6 @@ struct vpu_mbox {enum vpu_core_state {VPU_CORE_DEINIT =0 ,VPU_CORE_ACTIVE , -VPU_CORE_SNAPSHOT ,VPU_CORE_HANG };
drivers/media/platform/amphion/vpu_core.c +43 -41
149 lines not on this page · raw message
drivers/media/platform/amphion/vpu_core.h +1 -0
@@ -11,5 +11,6 @@ u32 csr_readl(struct vpu_core *core, u32 reg);int vpu_alloc_dma (struct vpu_core *core,struct vpu_buffer *buf);void vpu_free_dma (struct vpu_buffer *buf);struct vpu_inst *vpu_core_find_instance (struct vpu_core *core,u32 index); +void vpu_core_set_state (struct vpu_core *core,enum vpu_core_state state);#endif
drivers/media/platform/amphion/vpu_dbg.c +7 -2
@@ -15,6 +15,7 @@#include <linux/debugfs.h> #include "vpu.h" #include "vpu_defs.h" +#include "vpu_core.h" #include "vpu_helpers.h" #include "vpu_cmds.h" #include "vpu_rpc.h"
@@ -233,6 +234,10 @@ static int vpu_dbg_core(struct seq_file *s, void *data)if (seq_write (s, str, num))return 0 ; + num =scnprintf (str,sizeof (str),"power %s\n" , +vpu_iface_get_power_state (core) ?"on" :"off" ); +if (seq_write (s, str, num)) +return 0 ; num =scnprintf (str,sizeof (str),"state = %d\n" , core->state);if (seq_write (s, str, num))return 0 ;
@@ -346,10 +351,10 @@ static ssize_t vpu_dbg_core_write(struct file *file,pm_runtime_resume_and_get (core->dev);mutex_lock (&core->lock); -if (core->state !=VPU_CORE_DEINIT && !core->instance_mask) { +if (vpu_iface_get_power_state (core) && !core->request_count) {dev_info (core->dev,"reset\n" );if (!vpu_core_sw_reset (core)) { - core->state =VPU_CORE_ACTIVE ; +vpu_core_set_state (core,VPU_CORE_ACTIVE ); core->hang_mask =0 ; } }
Signature · 1 line
2.37.1