Re: [PATCH 38/78] media: i2c: mt9m001: use pm_runtime_resume_and_get()

From: Johan Hovold
Date: Wed Apr 28 2021 - 07:56:16 EST


On Wed, Apr 28, 2021 at 01:28:53PM +0200, Mauro Carvalho Chehab wrote:
> Em Wed, 28 Apr 2021 12:05:26 +0200
> Johan Hovold <johan@xxxxxxxxxx> escreveu:

> > Right, a resume failure is a pretty big issue and it's not really clear
> > how to to even handle that generally. But at remove() time you don't
> > have much choice but to go on and release resource anyway.
> >
> > So unless actually implementing some error handling too, using
> > pm_runtime_sync_get() without checking for errors is still preferred
> > over pm_runtime_resume_and_get(). That is
> >
> > pm_runtime_get_sync();
> > /* cleanup */
> > pm_runtime_disable()
> > pm_runtime_put_noidle();
> >
> > is better than:
> >
> > ret = pm_runtime_resume_and_get();
> > /* cleanup */
> > pm_runtime_disable();
> > if (ret == 0)
> > pm_runtime_put_noidle();
> >
> > unless you also start doing something ret.
>
> Perhaps the best would be to use, instead:
>
> pm_runtime_get_noresume();
> /* cleanup */
> pm_runtime_disable()
> pm_runtime_put_noidle();
> pm_runtime_set_suspended();
>
> I mean, at least for my eyes, it doesn't make sense to do a PM
> resume during driver's removal/unbind time.

The cleanup bit above would depend on the device being resumed so using
pm_runtime_get_noresume() makes little sense.

Some drivers disable clocks etc explicitly at remove instead of relying
on pm runtime for that and then they'd use the above scheme (plus
explicit pm_runtime_set_suspended()).

Johan