media: amphion: fix a bug that vpu core may not resume after suspend
authorMing Qian <ming.qian@nxp.com>
Thu, 18 Aug 2022 03:18:21 +0000 (05:18 +0200)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Tue, 30 Aug 2022 13:27:51 +0000 (15:27 +0200)
commit0202a665bf17fbe98fed954944aabbcb4f14a4cc
tree166d233a00e7c4692d18595c12c886fd3bc4cdd0
parentc65c3f3a2cbf21ed429d9b9c725bdb5dc6abf4cf
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.

Fixes: 9f599f351e86 ("media: amphion: add vpu core driver")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/platform/amphion/vpu.h
drivers/media/platform/amphion/vpu_core.c
drivers/media/platform/amphion/vpu_core.h
drivers/media/platform/amphion/vpu_dbg.c