linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Abel Vesa <abel.vesa@linaro.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J . Wysocki" <rafael@kernel.org>,
	Kevin Hilman <khilman@kernel.org>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>,
	Saravana Kannan <saravanak@google.com>,
	Bjorn Andersson <andersson@kernel.org>,
	linux-pm@vger.kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-arm-msm@vger.kernel.org,
	Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Subject: Re: [RFC PATCH v5 2/4] driver core: Add dev_is_drv_state_synced()
Date: Wed, 28 Jun 2023 14:50:31 +0300	[thread overview]
Message-ID: <ZJweh0MTuSY9jtW9@linaro.org> (raw)
In-Reply-To: <2023062103-chevron-sabotage-bf26@gregkh>

On 23-06-21 17:22:54, Greg Kroah-Hartman wrote:
> On Wed, Jun 21, 2023 at 05:40:17PM +0300, Abel Vesa wrote:
> > This can be used by drivers to figure out if a different device
> > driver has state synced or not for a specific device.
> > 
> > Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
> > ---
> >  include/linux/device.h | 14 ++++++++++++++
> >  1 file changed, 14 insertions(+)
> > 
> > diff --git a/include/linux/device.h b/include/linux/device.h
> > index bae11928ef7e..8f042f04b5d9 100644
> > --- a/include/linux/device.h
> > +++ b/include/linux/device.h
> > @@ -1007,6 +1007,20 @@ static inline int dev_set_drv_sync_state(struct device *dev,
> >  	return 0;
> >  }
> >  
> > +static inline bool dev_is_drv_state_synced(struct device *dev)
> > +{
> > +	bool ret = false;
> > +
> > +	if (!dev)
> > +		return ret;
> > +
> > +	device_lock(dev);
> > +	ret = dev->state_synced;
> > +	device_unlock(dev);
> 
> This lock is "protecting" nothing, given that the value can instantly
> change after it is read.

Hmm, for some reason I thought it needs to be synchronized with the
sync state callback being called already. But I just noticed that call
to the sync state callback is independently locked after state_synced is
set. So I guess the lock can go away here.

> 
> Because it can change, how will this function actually show anything
> relevant?

The only usecase I can think of for this new API is for some driver
to delay an action until ultimately the driver for a specific device
gets state synced. So even if the value can change after it has
been checked, such consumer driver will most likely retry later on.

Hope that makes sense.

> 
> thanks,
> 
> greg k-h

  reply	other threads:[~2023-06-28 11:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-21 14:40 [RFC PATCH v5 0/4] PM: domain: Support skiping disabling unused domains until sync state Abel Vesa
2023-06-21 14:40 ` [RFC PATCH v5 1/4] driver core: Add dev_set_drv_sync_state() Abel Vesa
2023-06-21 14:40 ` [RFC PATCH v5 2/4] driver core: Add dev_is_drv_state_synced() Abel Vesa
2023-06-21 15:22   ` Greg Kroah-Hartman
2023-06-28 11:50     ` Abel Vesa [this message]
2023-06-21 14:40 ` [RFC PATCH v5 3/4] PM: domains: Ignore power off request for enabled unused domains Abel Vesa
2023-07-04 13:24   ` Ulf Hansson
2023-06-21 14:40 ` [RFC PATCH v5 4/4] PM: domains: Add and set generic sync state callback Abel Vesa
2023-07-04 13:54   ` Ulf Hansson
     [not found] ` <2786d9ff-0579-429b-b431-a8547cbf6fb6@ti>
2025-04-07 16:13   ` [RFC PATCH v5 0/4] PM: domain: Support skiping disabling unused domains until sync state 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=ZJweh0MTuSY9jtW9@linaro.org \
    --to=abel.vesa@linaro.org \
    --cc=andersson@kernel.org \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=khilman@kernel.org \
    --cc=len.brown@intel.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rafael@kernel.org \
    --cc=saravanak@google.com \
    --cc=ulf.hansson@linaro.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;
as well as URLs for NNTP newsgroup(s).