mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Linux PM <linux-pm@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Alan Stern <stern@rowland.harvard.edu>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	Wolfram Sang <wsa@kernel.org>
Subject: Re: [PATCH] PM: runtime: Add kerneldoc comments to multiple helpers
Date: Wed, 5 Aug 2020 11:49:28 +0300	[thread overview]
Message-ID: <20200805084928.GK13316@paasikivi.fi.intel.com> (raw)
In-Reply-To: <CAJZ5v0jDpuKYJED90CveWgfYcoA60X5qYY6U6CJmEFd7KDiY-A@mail.gmail.com>

Hi Rafael,

On Tue, Aug 04, 2020 at 12:15:03PM +0200, Rafael J. Wysocki wrote:
> Hi Sakari,
> 
> On Tue, Aug 4, 2020 at 1:05 AM Sakari Ailus
> <sakari.ailus@linux.intel.com> wrote:
> >
> > Hi Rafael,
> >
> > On Mon, Aug 03, 2020 at 01:36:52PM +0200, Rafael J. Wysocki wrote:
> > > Hi Sakari,
> > >
> > > On Mon, Aug 3, 2020 at 10:53 AM Sakari Ailus
> > > <sakari.ailus@linux.intel.com> wrote:
> > > >
> > > > Hi Rafael,
> > > >
> > > > Thanks for the patch.
> > > >
> > > > On Fri, Jul 31, 2020 at 07:03:26PM +0200, Rafael J. Wysocki wrote:
> > > > > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > > > >
> > > > > Add kerneldoc comments to multiple PM-runtime helper functions
> > > > > defined as static inline wrappers around lower-level routines to
> > > > > provide quick reference decumentation of their behavior.
> > > >
> > > > > Some of them are similar to each other with subtle differences only
> > > > > and the behavior of some of them may appear as counter-intuitive, so
> > > > > clarify all that to avoid confusion.
> > > > >
> > > > > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > > > > ---
> > > > >  include/linux/pm_runtime.h |  246 +++++++++++++++++++++++++++++++++++++++++++++
> > > > >  1 file changed, 246 insertions(+)
> > > > >
> > > > > Index: linux-pm/include/linux/pm_runtime.h
> > > > > ===================================================================
> > > > > --- linux-pm.orig/include/linux/pm_runtime.h
> > > > > +++ linux-pm/include/linux/pm_runtime.h
> > > > > @@ -60,58 +60,151 @@ extern void pm_runtime_put_suppliers(str
> > > > >  extern void pm_runtime_new_link(struct device *dev);
> > > > >  extern void pm_runtime_drop_link(struct device *dev);
> > > > >
> > > > > +/**
> > > > > + * pm_runtime_get_if_in_use - Conditionally bump up runtime PM usage counter.
> > > > > + * @dev: Target device.
> > > > > + *
> > > > > + * Increment the runtime PM usage counter of @dev if its runtime PM status is
> > > > > + * %RPM_ACTIVE and its runtime PM usage counter is greater than 0.
> > > >
> > > > The implementation of the non-runtime PM variants (used when CONFIG_PM is
> > > > disabled) isn't here but I think it'd be nice if their behaviour was also
> > > > documented here. pm_runtime_get_if_in_use() returns -EINVAL if CONFIG_PM is
> > > > disabled, for instance.
> > >
> > > These kerneldoc comments cover the CONFIG_PM case only.  The behavior
> > > for !CONFIG_PM needs to be figured out from the code, if it matters.
> > >
> > > I'm not sure why it would matter for pm_runtime_get_if_in_use(), in particular?
> >
> > Just as an example. It depends on the use case, but there have been bugs
> > related to these (e.g. commit 4d471563d87b2b83e73b8abffb9273950e6d2e36),
> > likely at least partly because it's extra manual work to figure out what a
> > given API function could return when it's not documented.
> 
> If it is a static inline wrapper around another exported function,
> whoever uses it should look at the documentation of the function being
> wrapped anyway, so IMO it is sufficient to document the return values
> in there and also (as stated in another message) this avoids the need
> to manually synchronize the kerneldoc comments every time a new return
> value is added or removed.
> 
> In the particular case above it might be useful to change
> pm_runtime_get_if_active() to return bool, make it return "false" if
> PM-runtime is disabled for the device and update the callers
> accordingly (some of them still appear to be doing the wrong thing).
> 
> IOW, it would return "true" only if the usage counter has been
> incremented and so it needs to be decremented.

In the case of above commit, the driver is interested in knowing whether
the device is powered on, and so accessible. That's the case if PM is
disabled, so it should return true. Then we do lose the information whether
the counter was touched. I guess we should keep it as-is.

-- 
Sakari Ailus

  reply	other threads:[~2020-08-05  8:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-31 17:03 Rafael J. Wysocki
2020-07-31 19:03 ` Alan Stern
2020-08-03  8:53 ` Sakari Ailus
2020-08-03 11:36   ` Rafael J. Wysocki
2020-08-03 23:05     ` Sakari Ailus
2020-08-04 10:15       ` Rafael J. Wysocki
2020-08-05  8:49         ` Sakari Ailus [this message]
2020-08-05 16:49           ` Rafael J. Wysocki
2020-08-03 23:03 ` Sakari Ailus
2020-08-04 10:03   ` Rafael J. Wysocki
2020-08-12  9:25 ` Ulf Hansson

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=20200805084928.GK13316@paasikivi.fi.intel.com \
    --to=sakari.ailus@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=stern@rowland.harvard.edu \
    --cc=ulf.hansson@linaro.org \
    --cc=wsa@kernel.org \
    /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

all inboxes | Powered by JetHome®