linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: hzpeterchen@gmail.com (Peter Chen)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v15 2/7] power: add power sequence library
Date: Thu, 15 Jun 2017 14:58:54 +0800	[thread overview]
Message-ID: <20170615065854.GA24157@b29397-desktop> (raw)
In-Reply-To: <CAPDyKFrLL10TY1JZAhF44_0+qGETLNtFc6ujKVUu7Ay=O8+M5A@mail.gmail.com>

On Wed, Jun 14, 2017 at 10:53:29AM +0200, Ulf Hansson wrote:
> On 14 June 2017 at 03:53, Peter Chen <hzpeterchen@gmail.com> wrote:
> > On Tue, Jun 13, 2017 at 12:24:42PM +0200, Ulf Hansson wrote:
> >> [...]
> >>
> >> > +
> >> > +/**
> >> > + * of_pwrseq_on - Carry out power sequence on for device node
> >> > + *
> >> > + * @np: the device node would like to power on
> >> > + *
> >> > + * Carry out a single device power on.  If multiple devices
> >> > + * need to be handled, use of_pwrseq_on_list() instead.
> >> > + *
> >> > + * Return a pointer to the power sequence instance on success,
> >> > + * or an error code otherwise.
> >> > + */
> >> > +struct pwrseq *of_pwrseq_on(struct device_node *np)
> >> > +{
> >> > +       struct pwrseq *pwrseq;
> >> > +       int ret;
> >> > +
> >> > +       pwrseq = pwrseq_find_available_instance(np);
> >> > +       if (!pwrseq)
> >> > +               return ERR_PTR(-ENOENT);
> >>
> >> In case the pwrseq instance hasn't been registered yet, then there is
> >> no way to deal with -EPROBE_DEFER properly here.
> >>
> >> I haven't been following the discussions in-depth during all
> >> iterations, so perhaps you have already discussed why doing it like
> >> this.
> >
> > Yes, it has been discussed. In order to compare with compatible string
> > at dts, we need to have one registered pwrseq instance for each
> > pwrseq library, this pre-registered one is allocated using
> > postcore_initcall, and the new (eg, second) instance is registered
> > after pwrseq_get has succeeded.
> 
> I understand you need one compatible per pwrseq library, but how does
> that have anything to do with -EPROBE_DEFER?
> 
> My point is that, if a driver calls of_pwrseq_on() (which calls
> pwrseq_find_available_instance()), but the corresponding pwrseq
> library and instance has not yet been registered for that device. Then
> how will you handle -EPROBE_DEFER? I guess you simply can't, which is
> why *all* pwrseq libraries needs to be registered in early boot phase,
> like at postcore_initcall(). Right?
> 
> If that is the case, I really don't like it.
> 

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.

> 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.

> 
> Sorry for jumping in late, however to me it seems like there is still
> some pieces missing to make this work.
> 
> [...]
> 
> Kind regards
> Uffe

-- 

Best Regards,
Peter Chen

  reply	other threads:[~2017-06-15  6:58 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 [this message]
2017-06-15  8:11           ` Ulf Hansson
2017-06-15  9:11             ` Peter Chen
2017-06-15  9:35               ` Ulf Hansson
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=20170615065854.GA24157@b29397-desktop \
    --to=hzpeterchen@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.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).