mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] media: amlogic: handle C3 MIPI runtime resume failures
@ 2026-10-03  8:11 Jiale Yao
  2026-10-03  8:11 ` [PATCH 1/2] media: c3-mipi-adap: handle runtime resume failure Jiale Yao
  2026-10-03  8:11 ` [PATCH 2/2] media: c3-mipi-csi2: " Jiale Yao
  0 siblings, 2 replies; 7+ messages in thread
From: Jiale Yao @ 2026-10-03  8:11 UTC (permalink / raw)
  To: Keke Li, Mauro Carvalho Chehab, Jacopo Mondi, Hans Verkuil,
	Daniel Scally, linux-media, linux-kernel
  Cc: Jiale Yao

The C3 MIPI adapter and CSI-2 receiver ignore failures from
pm_runtime_resume_and_get() when enabling streams. Both drivers then access
registers while their power domains may be unavailable, report streaming as
enabled, and later drop runtime PM references that were not acquired.

Check and propagate the runtime PM errors before either device is
programmed.

Jiale Yao (2):
  media: c3-mipi-adap: handle runtime resume failure
  media: c3-mipi-csi2: handle runtime resume failure

 drivers/media/platform/amlogic/c3/mipi-adapter/c3-mipi-adap.c | 4 +++-
 drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c    | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] media: c3-mipi-adap: handle runtime resume failure
  2026-10-03  8:11 [PATCH 0/2] media: amlogic: handle C3 MIPI runtime resume failures Jiale Yao
@ 2026-10-03  8:11 ` Jiale Yao
  2026-10-19  6:23   ` Keke Li
  2026-10-03  8:11 ` [PATCH 2/2] media: c3-mipi-csi2: " Jiale Yao
  1 sibling, 1 reply; 7+ messages in thread
From: Jiale Yao @ 2026-10-03  8:11 UTC (permalink / raw)
  To: Keke Li, Mauro Carvalho Chehab, Jacopo Mondi, Hans Verkuil,
	Daniel Scally, linux-media, linux-kernel
  Cc: Jiale Yao

c3_mipi_adap_enable_streams() ignores runtime resume failures and
continues programming adapter registers before reporting that streaming
started. If the power domain could not be resumed, those register
accesses are unsafe and the disable path later drops a reference that
was not acquired.

Return the runtime PM error before accessing the adapter.

Fixes: f0d2d8062cc8 ("media: platform: Add C3 MIPI adapter driver")
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
 drivers/media/platform/amlogic/c3/mipi-adapter/c3-mipi-adap.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/amlogic/c3/mipi-adapter/c3-mipi-adap.c b/drivers/media/platform/amlogic/c3/mipi-adapter/c3-mipi-adap.c
index 4bd98fb9c7e9..750b301f4bbf 100644
--- a/drivers/media/platform/amlogic/c3/mipi-adapter/c3-mipi-adap.c
+++ b/drivers/media/platform/amlogic/c3/mipi-adapter/c3-mipi-adap.c
@@ -455,7 +455,9 @@ static int c3_mipi_adap_enable_streams(struct v4l2_subdev *sd,
 
 	src_sd = media_entity_to_v4l2_subdev(adap->src_pad->entity);
 
-	pm_runtime_resume_and_get(adap->dev);
+	ret = pm_runtime_resume_and_get(adap->dev);
+	if (ret < 0)
+		return ret;
 
 	fmt = v4l2_subdev_state_get_format(state, C3_MIPI_ADAP_PAD_SINK);
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/2] media: c3-mipi-csi2: handle runtime resume failure
  2026-10-03  8:11 [PATCH 0/2] media: amlogic: handle C3 MIPI runtime resume failures Jiale Yao
  2026-10-03  8:11 ` [PATCH 1/2] media: c3-mipi-adap: handle runtime resume failure Jiale Yao
@ 2026-10-03  8:11 ` Jiale Yao
  2026-10-19  6:24   ` Keke Li
  1 sibling, 1 reply; 7+ messages in thread
From: Jiale Yao @ 2026-10-03  8:11 UTC (permalink / raw)
  To: Keke Li, Mauro Carvalho Chehab, Jacopo Mondi, Hans Verkuil,
	Daniel Scally, linux-media, linux-kernel
  Cc: Jiale Yao

c3_mipi_csi_enable_streams() ignores runtime resume failures and starts
the receiver before reporting that streaming is enabled. If the power
domain could not be resumed, this accesses unavailable registers and
the disable path later drops a reference that was not acquired.

Return the runtime PM error before starting the receiver.

Fixes: b63ef604a28d ("media: platform: Add C3 MIPI CSI-2 driver")
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
 drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c b/drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c
index b9e4ef3fc308..4731d58bf2dd 100644
--- a/drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c
+++ b/drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c
@@ -431,7 +431,9 @@ static int c3_mipi_csi_enable_streams(struct v4l2_subdev *sd,
 
 	src_sd = media_entity_to_v4l2_subdev(csi->src_pad->entity);
 
-	pm_runtime_resume_and_get(csi->dev);
+	ret = pm_runtime_resume_and_get(csi->dev);
+	if (ret < 0)
+		return ret;
 
 	c3_mipi_csi_start_stream(csi);
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] media: c3-mipi-adap: handle runtime resume failure
  2026-10-03  8:11 ` [PATCH 1/2] media: c3-mipi-adap: handle runtime resume failure Jiale Yao
@ 2026-10-19  6:23   ` Keke Li
  0 siblings, 0 replies; 7+ messages in thread
From: Keke Li @ 2026-10-19  6:23 UTC (permalink / raw)
  To: Jiale Yao, Mauro Carvalho Chehab, Jacopo Mondi, Hans Verkuil,
	Daniel Scally, linux-media, linux-kernel

Hi Jiale,

Thanks for your patch.

On 10/3/26 16:11, Jiale Yao wrote:
> [You don't often get email from yaojiale02@163.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> [ EXTERNAL EMAIL ]
>
> c3_mipi_adap_enable_streams() ignores runtime resume failures and
> continues programming adapter registers before reporting that streaming
> started. If the power domain could not be resumed, those register
> accesses are unsafe and the disable path later drops a reference that
> was not acquired.
>
> Return the runtime PM error before accessing the adapter.
>
> Fixes: f0d2d8062cc8 ("media: platform: Add C3 MIPI adapter driver")
> Signed-off-by: Jiale Yao <yaojiale02@163.com>
> ---
>   drivers/media/platform/amlogic/c3/mipi-adapter/c3-mipi-adap.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/amlogic/c3/mipi-adapter/c3-mipi-adap.c b/drivers/media/platform/amlogic/c3/mipi-adapter/c3-mipi-adap.c
> index 4bd98fb9c7e9..750b301f4bbf 100644
> --- a/drivers/media/platform/amlogic/c3/mipi-adapter/c3-mipi-adap.c
> +++ b/drivers/media/platform/amlogic/c3/mipi-adapter/c3-mipi-adap.c
> @@ -455,7 +455,9 @@ static int c3_mipi_adap_enable_streams(struct v4l2_subdev *sd,
>
>          src_sd = media_entity_to_v4l2_subdev(adap->src_pad->entity);
>
> -       pm_runtime_resume_and_get(adap->dev);
> +       ret = pm_runtime_resume_and_get(adap->dev);
> +       if (ret < 0)

                     Is   ' if (ret)'  better?

       Thanks!

> +               return ret;
>
>          fmt = v4l2_subdev_state_get_format(state, C3_MIPI_ADAP_PAD_SINK);
>
> --
> 2.34.1
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] media: c3-mipi-csi2: handle runtime resume failure
  2026-10-03  8:11 ` [PATCH 2/2] media: c3-mipi-csi2: " Jiale Yao
@ 2026-10-19  6:24   ` Keke Li
  2026-10-19  7:31     ` Jacopo Mondi
  0 siblings, 1 reply; 7+ messages in thread
From: Keke Li @ 2026-10-19  6:24 UTC (permalink / raw)
  To: Jiale Yao, Mauro Carvalho Chehab, Jacopo Mondi, Hans Verkuil,
	Daniel Scally, linux-media, linux-kernel

Hi Jiale,

On 10/3/26 16:11, Jiale Yao wrote:
> [You don't often get email from yaojiale02@163.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> [ EXTERNAL EMAIL ]
>
> c3_mipi_csi_enable_streams() ignores runtime resume failures and starts
> the receiver before reporting that streaming is enabled. If the power
> domain could not be resumed, this accesses unavailable registers and
> the disable path later drops a reference that was not acquired.
>
> Return the runtime PM error before starting the receiver.
>
> Fixes: b63ef604a28d ("media: platform: Add C3 MIPI CSI-2 driver")
> Signed-off-by: Jiale Yao <yaojiale02@163.com>
> ---
>   drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c b/drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c
> index b9e4ef3fc308..4731d58bf2dd 100644
> --- a/drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c
> +++ b/drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c
> @@ -431,7 +431,9 @@ static int c3_mipi_csi_enable_streams(struct v4l2_subdev *sd,
>
>          src_sd = media_entity_to_v4l2_subdev(csi->src_pad->entity);
>
> -       pm_runtime_resume_and_get(csi->dev);
> +       ret = pm_runtime_resume_and_get(csi->dev);
> +       if (ret < 0)
Is   ' if (ret)'  better?
> +               return ret;
>
>          c3_mipi_csi_start_stream(csi);
>
> --
> 2.34.1
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] media: c3-mipi-csi2: handle runtime resume failure
  2026-10-19  6:24   ` Keke Li
@ 2026-10-19  7:31     ` Jacopo Mondi
  2026-10-19  8:48       ` Keke Li
  0 siblings, 1 reply; 7+ messages in thread
From: Jacopo Mondi @ 2026-10-19  7:31 UTC (permalink / raw)
  To: Keke Li
  Cc: Jiale Yao, Mauro Carvalho Chehab, Jacopo Mondi, Hans Verkuil,
	Daniel Scally, linux-media, linux-kernel

Hi Keke

On Mon, Oct 19, 2026 at 02:24:34PM +0800, Keke Li wrote:
> Hi Jiale,
>
> On 10/3/26 16:11, Jiale Yao wrote:
> > [You don't often get email from yaojiale02@163.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
> >
> > [ EXTERNAL EMAIL ]
> >
> > c3_mipi_csi_enable_streams() ignores runtime resume failures and starts
> > the receiver before reporting that streaming is enabled. If the power
> > domain could not be resumed, this accesses unavailable registers and
> > the disable path later drops a reference that was not acquired.
> >
> > Return the runtime PM error before starting the receiver.
> >
> > Fixes: b63ef604a28d ("media: platform: Add C3 MIPI CSI-2 driver")
> > Signed-off-by: Jiale Yao <yaojiale02@163.com>
> > ---
> >   drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c | 4 +++-
> >   1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c b/drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c
> > index b9e4ef3fc308..4731d58bf2dd 100644
> > --- a/drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c
> > +++ b/drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c
> > @@ -431,7 +431,9 @@ static int c3_mipi_csi_enable_streams(struct v4l2_subdev *sd,
> >
> >          src_sd = media_entity_to_v4l2_subdev(csi->src_pad->entity);
> >
> > -       pm_runtime_resume_and_get(csi->dev);
> > +       ret = pm_runtime_resume_and_get(csi->dev);
> > +       if (ret < 0)
> Is   ' if (ret)'  better?

Does your driver depend on select PM ? It doesn't seem the case to me.

If PM is disabled pm_runtime_resume_and_get() returns 1
if my reading of

        static inline int __pm_runtime_resume(struct device *dev, int rpmflags)
        {
                return 1;
        }

is correct.

If you
        if (ret)

also this case will be caught as an error, while we instead want to
continue as the peripheral is meant to stay powered on from probe() if
CONFIG_PM is not selected.

(I quickly had a look at the csi2 driver probe() routine
c3_mipi_csi_probe() and it doesn't seem to power up the interface in
probe() to support !CONFIG_PM. Personally, I would just select PM
unconditionally almost everywhere these days and be done with it).

> > +               return ret;
> >
> >          c3_mipi_csi_start_stream(csi);
> >
> > --
> > 2.34.1
> >

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] media: c3-mipi-csi2: handle runtime resume failure
  2026-10-19  7:31     ` Jacopo Mondi
@ 2026-10-19  8:48       ` Keke Li
  0 siblings, 0 replies; 7+ messages in thread
From: Keke Li @ 2026-10-19  8:48 UTC (permalink / raw)
  To: Jacopo Mondi
  Cc: Jiale Yao, Mauro Carvalho Chehab, Hans Verkuil, Daniel Scally,
	linux-media, linux-kernel

Hi Jacopo,

Thanks for your reply.

On 10/19/26 15:31, Jacopo Mondi wrote:
> [ EXTERNAL EMAIL ]
>
> Hi Keke
>
> On Mon, Oct 19, 2026 at 02:24:34PM +0800, Keke Li wrote:
>> Hi Jiale,
>>
>> On 10/3/26 16:11, Jiale Yao wrote:
>>> [You don't often get email from yaojiale02@163.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>>>
>>> [ EXTERNAL EMAIL ]
>>>
>>> c3_mipi_csi_enable_streams() ignores runtime resume failures and starts
>>> the receiver before reporting that streaming is enabled. If the power
>>> domain could not be resumed, this accesses unavailable registers and
>>> the disable path later drops a reference that was not acquired.
>>>
>>> Return the runtime PM error before starting the receiver.
>>>
>>> Fixes: b63ef604a28d ("media: platform: Add C3 MIPI CSI-2 driver")
>>> Signed-off-by: Jiale Yao <yaojiale02@163.com>
>>> ---
>>>    drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c | 4 +++-
>>>    1 file changed, 3 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c b/drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c
>>> index b9e4ef3fc308..4731d58bf2dd 100644
>>> --- a/drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c
>>> +++ b/drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c
>>> @@ -431,7 +431,9 @@ static int c3_mipi_csi_enable_streams(struct v4l2_subdev *sd,
>>>
>>>           src_sd = media_entity_to_v4l2_subdev(csi->src_pad->entity);
>>>
>>> -       pm_runtime_resume_and_get(csi->dev);
>>> +       ret = pm_runtime_resume_and_get(csi->dev);
>>> +       if (ret < 0)
>> Is   ' if (ret)'  better?
>> Does your driver depend on select PM ? It doesn't seem the case to me.
>>
>> If PM is disabled pm_runtime_resume_and_get() returns 1
>> if my reading of
>>
>>          static inline int __pm_runtime_resume(struct device *dev, int rpmflags)
>>          {
>>                  return 1;
>>          }
>>
>> is correct.
>>
>> If you
>>          if (ret)
>>
>> also this case will be caught as an error, while we instead want to
>> continue as the peripheral is meant to stay powered on from probe() if
>> CONFIG_PM is not selected.
>>
>> (I quickly had a look at the csi2 driver probe() routine
>> c3_mipi_csi_probe() and it doesn't seem to power up the interface in
>> probe() to support !CONFIG_PM. Personally, I would just select PM
>> unconditionally almost everywhere these days and be done with it).

Yes, you are correct.🙂

a. Here should keep 'if (ret < 0)'.

b. Add 'select PM' in each Kconfig file.

Thanks very much!

>>> +               return ret;
>>>
>>>           c3_mipi_csi_start_stream(csi);
>>>
>>> --
>>> 2.34.1
>>>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-10-19  8:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-03  8:11 [PATCH 0/2] media: amlogic: handle C3 MIPI runtime resume failures Jiale Yao
2026-10-03  8:11 ` [PATCH 1/2] media: c3-mipi-adap: handle runtime resume failure Jiale Yao
2026-10-19  6:23   ` Keke Li
2026-10-03  8:11 ` [PATCH 2/2] media: c3-mipi-csi2: " Jiale Yao
2026-10-19  6:24   ` Keke Li
2026-10-19  7:31     ` Jacopo Mondi
2026-10-19  8:48       ` Keke Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®