All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Boyd <sboyd@codeaurora.org>
To: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Rob Herring <robh@kernel.org>,
	linux-clk <linux-clk@vger.kernel.org>,
	Michael Turquette <mturquette@baylibre.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: of_clk_add_(hw_)providers multipule times for one node?
Date: Wed, 10 Aug 2016 16:08:45 -0700	[thread overview]
Message-ID: <20160810230845.GH2996@codeaurora.org> (raw)
In-Reply-To: <CAK7LNAScz7bJABbOgUuvg9J-ORaiLEfpwA3yMP+bZbLgB+S3uQ@mail.gmail.com>

On 08/10, Masahiro Yamada wrote:
> Hi Stephen,
> 
> 
> 
> 2016-08-09 8:37 GMT+09:00 Stephen Boyd <sboyd@codeaurora.org>:
> > On 08/08, Masahiro Yamada wrote:
> >> Hi Stephen,
> >>
> >>
> >> 2016-08-05 6:25 GMT+09:00 Stephen Boyd <sboyd@codeaurora.org>:
> >
> >>
> >> of_clk_add_provider() calls of_clk_del_provider()
> >> in its failure path.
> >>
> >> Notice of_clk_del_provider() unregister
> >> all the providers associated with the device node.
> >
> > Where is that? I see a break statement in the while loop after
> > the first matching np is found.
> 
> Ah, I missed the "break".
> 
> So, this works *almost* well.
> 
> I mean *almost* because the of_clk_mutex is released
> between of_clk_add_hw_provider() and of_clk_del_provider().
> 
> What if two providers are added concurrently.
> I know it never happens in use-cases we assume, though.

Agreed, that would be bad. We can definitely do better in that
case and properly delete the provider that we have already
registered without calling of_clk_del_provider() though. We have
everything in the local scope at the time.

> 
> 
> >>
> >> Some platform drivers call of_clk_del_provider() in a .remove callback,
> >> so the same problem could happen.
> >>
> >> Why does of_clk_del_provider() take (struct device_node *np) ?
> >> Shouldn't it take (struct of_clk_provider *cp)?
> >>
> >
> > Not sure. Probably someone thought they could hide the structure
> > from consumers and just return success or failure.
> 
> consumers?   or did you mean providers?
> I think consumers have no chance to call of_clk_del_provider().

Sorry, bad choice of words. I meant users of this
of_clk_add*_provider() API.

> 
> 
> > The best we can do is have the framework only return probe defer
> > if there isn't a provider registered. Once a provider is
> > registered, it needs to do the right thing and return the
> > appropriate error (invalid or probe defer for example) at the
> > right time.
> 
> Agreed.

Ok. I think I will merge my patch then to restore previous
behavior.

> 
> Lastly, we have two solutions so far.  Which do you think is better?
> 
> One solution is, as others suggested,
> CLK_OF_DECLARE() can allocate a bigger array than it needs,
> so that blank entries can be filled by a platfrom_driver later.
> 
> 
> The other way is,
> CLK_OF_DECLARE() and a platfrom_driver
> allocate separate of_clk_provider for each of them.
> 

I believe we have precedence for the former case, so there's some
momentum around that approach. It doesn't make me feel great
though because we have published the provider before all clks are
registered, and then we go back and modify the array in place
while consumers could potentially be using it. I suppose we're
saved because cpus access the pointer in the array and only see
the whole pointer and not half of the old one and half of the new
one?

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

  reply	other threads:[~2016-08-10 23:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-08 17:23 of_clk_add_(hw_)providers multipule times for one node? Masahiro Yamada
2016-08-04 21:25 ` Stephen Boyd
2016-08-04 22:02   ` Rob Herring
2016-08-07 16:54   ` Masahiro Yamada
2016-08-08  9:00     ` Geert Uytterhoeven
2016-08-08 23:37     ` Stephen Boyd
2016-08-10  7:59       ` Masahiro Yamada
2016-08-10 23:08         ` Stephen Boyd [this message]
2016-08-12  7:04           ` Masahiro Yamada
2016-08-24  7:11             ` Masahiro Yamada
2016-08-24 18:08               ` Stephen Boyd
2016-08-25  2:36                 ` Masahiro Yamada
2016-08-25 20:30                   ` Stephen Boyd

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=20160810230845.GH2996@codeaurora.org \
    --to=sboyd@codeaurora.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=robh@kernel.org \
    --cc=yamada.masahiro@socionext.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.