linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ulf Hansson <ulf.hansson@linaro.org>
To: Peter Chen <hzpeterchen@gmail.com>
Cc: Peter Chen <peter.chen@nxp.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Heiko Stuebner <heiko@sntech.de>,
	Stephen Boyd <stephen.boyd@linaro.org>,
	frank.li@nxp.com,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Gary Bisson <gary.bisson@boundarydevices.com>,
	Fabio Estevam <festevam@gmail.com>,
	Joshua Clayton <stillcompiling@gmail.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>,
	Vaibhav Hiremath <vaibhav.hiremath@linaro.org>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	mka@chromium.org, Alan Stern <stern@rowland.harvard.edu>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"Maciej S. Szmigiero" <mail@maciej.szmigiero.name>,
	Pawel Moll <pawel.moll@arm.com>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	troy.kisky@boundarydevices.com, Rob Herring <robh+dt@kernel.org>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	hverkuil@xs4all.nl, oscar@naiandei.net,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Linux USB List <linux-usb@vger.kernel.org>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Sebastian Reichel <sre@kernel.org>,
	Mark Brown <broonie@kernel.org>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Shawn Guo <shawnguo@kernel.org>,
	jun.li@nxp.com
Subject: Re: [PATCH v15 2/7] power: add power sequence library
Date: Thu, 15 Jun 2017 11:35:20 +0200	[thread overview]
Message-ID: <CAPDyKFrZoyoYCQA1rnRbz9tmT9vJigzSb+xyTZpJjhd=5eFA5A@mail.gmail.com> (raw)
In-Reply-To: <20170615091131.GB24157@b29397-desktop>

On 15 June 2017 at 11:11, Peter Chen <hzpeterchen@gmail.com> wrote:
> On Thu, Jun 15, 2017 at 10:11:45AM +0200, Ulf Hansson wrote:
>> > Yes, you are right. This is the limitation for this power sequence
>> > library, the registration for the 1st power sequence instance must
>> > be finished before device driver uses it. I am appreciated that
>> > you can supply some suggestions for it.
>>
>> In general this kind of problems is solved by first parsing the DTB,
>> which means you will find out whether there is a resource (a pwrseq)
>> required for the device. Then you try to fetch that resource, and if
>> that fails, it means the resource is not yet available, and hence you
>> want to retry later and should return -EPROBE_DEFER.
>>
>> In this case, of_pwrseq_on() needs to be converted to start looking
>> for a pwrseq compatible in it's child node - I guess. Then if that is
>> found, you try to fetch the instance of the corresponding library.
>> Failing to fetch the library instance should then cause a return
>> -EPROBE_DEFER.
>
> The most difficulty for this is we can't know whether the requested
> pwrseq instance will be registered or not, the kernel configuration
> for this pwrseq library may not be chosen at all.

In such case it is still correct to return -EPROBE_DEFER, because the
driver that tries to probe its device will fail unless it can run the
needed pwrseq. Right?

>
>>
>> >
>> >> Moreover, I have found yet another severe problem but reviewing the code:
>> >> In the struct pwrseq, you have a "bool used", which you are setting to
>> >> "true" once the pwrseq has been hooked up with the device, when a
>> >> driver calls of_pwrseq_on(). Setting that variable to true, will also
>> >> prevent another driver from using the same instance of the pwrseq for
>> >> its device. So, to cope with multiple users, you register a new
>> >> instance of the same pwrseq library that got hooked up, once the
>> >> ->get() callback is about to complete.
>> >>
>> >> The problem the occurs, when there is another driver calling
>> >> of_pwrseq_on() in between, meaning that the new instance has not yet
>> >> been registered. This will simply fail, won't it?
>> >
>> > Yes, you are right, thanks for pointing that, I will add mutex_lock for
>> > of_pwrseq_on.
>>
>> Another option is to entirely skip to two step approach.
>>
>> In other words, make the library to cope with multiple users via the
>> same registered library instance.
>>
>
> No, the pwrseq instance stores dtb information (clock, gpio, etc), it
> needs to be per device.

I think you misunderstood my suggestion here. Of course you need to
allocate one pwrseq data per device.

However, my point is that you shouldn't need more than one instance of
the library functions to be registered in the list of available pwrseq
libraries.

Kind regards
Uffe

  reply	other threads:[~2017-06-15  9:35 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-13  1:59 [PATCH v15 0/7] power: add power sequence library Peter Chen
2017-06-13  1:59 ` [PATCH v15 1/7] binding-doc: power: pwrseq-generic: add binding doc for generic " Peter Chen
2017-06-13  1:59 ` [PATCH v15 2/7] power: add " Peter Chen
2017-06-13 10:24   ` Ulf Hansson
2017-06-14  1:53     ` Peter Chen
2017-06-14  8:53       ` Ulf Hansson
2017-06-15  6:58         ` Peter Chen
2017-06-15  8:11           ` Ulf Hansson
2017-06-15  9:11             ` Peter Chen
2017-06-15  9:35               ` Ulf Hansson [this message]
2017-06-15 10:06                 ` Peter Chen
2017-06-19  0:59                   ` Peter Chen
2017-06-19  8:09                   ` Ulf Hansson
2017-06-19  9:02                     ` Peter Chen
2017-06-19  9:48                       ` Ulf Hansson
2017-06-20  2:37                         ` Peter Chen
2017-06-13  1:59 ` [PATCH v15 3/7] binding-doc: usb: usb-device: add optional properties for power sequence Peter Chen
2017-06-13  1:59 ` [PATCH v15 4/7] usb: core: add power sequence handling for USB devices Peter Chen
2017-06-13  1:59 ` [PATCH v15 5/7] ARM: dts: imx6qdl: Enable usb node children with <reg> Peter Chen
2017-06-13  1:59 ` [PATCH v15 6/7] ARM: dts: imx6qdl-udoo.dtsi: fix onboard USB HUB property Peter Chen
2017-06-13  1:59 ` [PATCH v15 7/7] ARM: dts: imx6q-evi: Fix onboard hub reset line Peter Chen

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='CAPDyKFrZoyoYCQA1rnRbz9tmT9vJigzSb+xyTZpJjhd=5eFA5A@mail.gmail.com' \
    --to=ulf.hansson@linaro.org \
    --cc=arnd@arndb.de \
    --cc=broonie@kernel.org \
    --cc=dbaryshkov@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=frank.li@nxp.com \
    --cc=gary.bisson@boundarydevices.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heiko@sntech.de \
    --cc=hverkuil@xs4all.nl \
    --cc=hzpeterchen@gmail.com \
    --cc=jun.li@nxp.com \
    --cc=krzk@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mail@maciej.szmigiero.name \
    --cc=mark.rutland@arm.com \
    --cc=mka@chromium.org \
    --cc=oscar@naiandei.net \
    --cc=p.zabel@pengutronix.de \
    --cc=pawel.moll@arm.com \
    --cc=peter.chen@nxp.com \
    --cc=rjw@rjwysocki.net \
    --cc=robh+dt@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    --cc=sre@kernel.org \
    --cc=stephen.boyd@linaro.org \
    --cc=stern@rowland.harvard.edu \
    --cc=stillcompiling@gmail.com \
    --cc=troy.kisky@boundarydevices.com \
    --cc=vaibhav.hiremath@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).