Re: [PATCH v8 17/18] media: ti: j721e-csi2rx: Support runtime suspend
From: Sakari Ailus
Date: Mon Dec 08 2025 - 05:14:23 EST
Hi Jai,
On Mon, Dec 08, 2025 at 01:17:21PM +0530, Jai Luthra wrote:
> > > @@ -1579,6 +1622,10 @@ static int ti_csi2rx_probe(struct platform_device *pdev)
> > > goto err_notifier;
> > > }
> > >
> > > + pm_runtime_set_active(csi->dev);
> > > + pm_runtime_enable(csi->dev);
> >
> > Note that the sub-device driver's UAPI may be already available to users
> > when the async sub-device is registered. Therefore you'll need enable
> > runtime PM before that.
> >
>
> The only place where the driver actually writes registers to the hardware
> is in .start_streaming(), which I presume can only be called after the
> whole media pipeline is probed?
Correct, but without enabling runtime PM before registering the async
sub-device there's no guarantee of that order.
>
> > > + pm_request_idle(csi->dev);
> > > +
> > > return 0;
> > >
> > > err_notifier:
> > > @@ -1609,6 +1656,9 @@ static void ti_csi2rx_remove(struct platform_device *pdev)
> > > mutex_destroy(&csi->mutex);
> > > dma_free_coherent(csi->dev, csi->drain.len, csi->drain.vaddr,
> > > csi->drain.paddr);
> >
> > Is there a guarantee the device is in a particular runtime PM state here,
> > e.g. suspended?
> >
>
> I don't think so, userspace could attempt to remove the device while
> streaming. Good point, I haven't checked what all goes wrong in that case.
We don't really support that yet. :-)
I'd still check the runtime Pm state and if it's active, I'd power the
device off.
>
> > > + pm_runtime_disable(&pdev->dev);
> > > + pm_runtime_set_suspended(&pdev->dev);
> > > +
> > > }
> > >
> > > static const struct of_device_id ti_csi2rx_of_match[] = {
> > > @@ -1623,6 +1673,7 @@ static struct platform_driver ti_csi2rx_pdrv = {
> > > .driver = {
> > > .name = TI_CSI2RX_MODULE_NAME,
> > > .of_match_table = ti_csi2rx_of_match,
> > > + .pm = &ti_csi2rx_pm_ops,
> > > },
> > > };
> > >
> >
--
Kind regards,
Sakari Ailus