public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@jic23.retrosnub.co.uk>
To: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Cc: Shreeya Patel <shreeya.patel@collabora.com>,
	lars@metafoo.de, robh+dt@kernel.org, Zhigang.Shi@liteon.com,
	krisman@collabora.com, linux-iio@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel@collabora.com, alvaro.soliverez@collabora.com,
	andy.shevchenko@gmail.com
Subject: Re: [PATCH v9 2/2] iio: light: Add support for ltrf216a sensor
Date: Tue, 19 Jul 2022 13:19:28 +0100	[thread overview]
Message-ID: <20220719131808.7899acd4@jic23-huawei> (raw)
In-Reply-To: <1e880d3f-758b-56a8-d468-dcb06f4cbc18@collabora.com>

On Tue, 19 Jul 2022 14:56:51 +0300
Dmitry Osipenko <dmitry.osipenko@collabora.com> wrote:

> On 7/18/22 20:25, Jonathan Cameron wrote:
> > What turns this off again?  I'd expect to see a devm_add_action_or_reset()
> > to do that in the !CONFIG_PM case.
> > 
> > This is also an unusual pattern. As far as I can tell it works.
> > Normal trick for ensuring !CONFIG_PM works is to:
> > 
> > 1) Unconditionally turn device on.
> > 2) Register unconditional device off devm_callback. Very rarely harmful even if device already off
> >    due to runtime pm.  
> 
> If CONFIG_PM is disabled, do we really need to care about the power
> management on removal?
> 

Best effort + in general if we do something probe(), we want to do the
reverse in remove().  Sure it's not super important, but it's a nice
to have.  This tends to get 'fixed' by people revisiting the driver
after it has merged.

> > 3) Then call pm_runtime_set_active() so the state tracking matches.  
> 
> We can add pm_runtime_set_active() before h/w is touched for more
> consistency. On Steam Deck supplies are always enabled, but this may be
> not true for other devices.

Generally set it wherever you 'enable' the device as you are indicating
the state after that has happened. That might be really early though.

> 
> > 4) Call 	
> >   pm_runtime_mark_last_busy(dev);
> >   pm_runtime_put_autosuspend(dev);
> >   (here you have a function to do this anyway)
> >   to let runtime_pm use same path as normal to autosuspend
> > 
> > the upshot of this is that if !CONFIG_PM 3 and 4 do nothing and device
> > is left turned on.  Is there something I'm missing that makes that cycle
> > inappropriate here?  The main reason to do this is it then looks exactly
> > like any other runtime_pm calls elsewhere in the driver, so easier to review.  
> 
> It's appropriate, although caring about PM when it's disabled in kernel
> config could be unnecessary, IMO. It was my suggestion to keep the h/w
> enabled on driver's removal with !CONFIG_PM, minimizing the code.
> 
For the cost of about 4-8 lines of code, I think it's worth having, but can
also see why you decided against.

Jonathan



  reply	other threads:[~2022-07-19 12:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-15 11:16 [PATCH v9 0/2] Add LTRF216A Driver Shreeya Patel
2022-07-15 11:16 ` [PATCH v9 1/2] dt-bindings: Document ltrf216a light sensor bindings Shreeya Patel
2022-07-20 21:40   ` Rob Herring
2022-07-15 11:16 ` [PATCH v9 2/2] iio: light: Add support for ltrf216a sensor Shreeya Patel
2022-07-16 22:29   ` kernel test robot
2022-07-18 17:25   ` Jonathan Cameron
2022-07-19 11:56     ` Dmitry Osipenko
2022-07-19 12:19       ` Jonathan Cameron [this message]
2022-07-19 13:11         ` Dmitry Osipenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220719131808.7899acd4@jic23-huawei \
    --to=jic23@jic23.retrosnub.co.uk \
    --cc=Zhigang.Shi@liteon.com \
    --cc=alvaro.soliverez@collabora.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.osipenko@collabora.com \
    --cc=kernel@collabora.com \
    --cc=krisman@collabora.com \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=shreeya.patel@collabora.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox