linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Greg KH <gregkh@linuxfoundation.org>,
	linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org, pi-cheng.chen@linaro.org
Subject: Re: [PATCH] bus: subsys: propagate errors from subsys interface's ->add_dev()
Date: Thu, 30 Jul 2015 20:53:04 +0200	[thread overview]
Message-ID: <8139001.Q4eV8YG1Il@vostro.rjw.lan> (raw)
In-Reply-To: <20150730034431.GH5100@linux>

On Thursday, July 30, 2015 09:14:31 AM Viresh Kumar wrote:
> On 30-07-15, 01:29, Rafael J. Wysocki wrote:
> > > > There is a small problem with it that I've already pointed out to Viresh.
> > > > 
> > > > Namely, while changing subsys_interface_(un)register() to handle return
> > > > values from ->add_dev(), it doesn't do the same thing in bus_probe_device()
> > > > which I believe it should for consistency at least.
> > > 
> > > Oops, sorry, missed that response.  I'll go drop this patch then, thanks
> > > for letting me know.
> 
> It was discussed in last 2-3 days over a cpufreq related thread, no way you
> could have caught that :)
> 
> But, I think we should keep this patch until the time we find a better solution
> to our problem.
> 
> You are the driver core maintainer and probably no one can give a better
> suggestion to fix our problem, so lemme explain that again here :)
> 
> A platform specific cpufreq driver may depend on a external driver (say i2c
> which may control access to regulators) for its working, and until the time
> regulator is up along with i2c we need to defer cpufreq driver from being
> registered. We already have an EPROBE_DEFER mechanism to handle such situations
> nicely.
> 
> cpufreq core calling sequence at a glance:
> cpufreq_register_driver()
>  -> subsys_interface_register()
>    -> subsys->add_dev() for all present CPUs one by one
>      -> cpufreq_add_dev()
>        -> cpufreq_driver->init()
> 
> 	  Now init() is the only location where the drivers initialize per
> 	  policy (group of CPUs that share clock/voltage rails) stuff and can
> 	  check if all the resources like clk/regulator are available or not.
> 	  And so -EPROBE_DEFER will be returned from here.

No, this is not the only place (see below).


> The only broken part here is the return value of subsys->add_dev() and that I
> tried to fix.
> 
> Another important part here is that the cpufreq driver isn't probed against a
> cpu device, but a dummy platform device to get the EPROBE_DEFER story right,

So the big question here is: why?  Why is that done the way it is done?


> plus there are few other issues that it solves, like probing the right cpufreq
> driver.
> 
> Now, please explain a sane way to get things working for such platforms.

Well, on ACPI systems we actually do probe CPU devices.  We have a processor
driver there that binds to CPU devices and the cpufreq driver is just a
frontend to that.

So question is what prevents DT-based systems from doing it analogously.


Now, even if you use a fake platform device for that (I'm sure there are
reasons for doing that, but I'd very much like them to be explained), then
all of the information on dependencies should already be available to the
->probe callback of that device's driver, so it can check them before
registering the cpufreq interface, can't it?


Essentially, what you're suggesting to do is something like: Make the ->probe
of one device's driver register a subsys interface for a specific bus type
and check what ->add_dev of that interface returns for each device on that
bus and if that is -EPROBE_DEFER, return it as its own return value.  Do you
honestly think this is a good design?


> > > > But then, the question is whether or not the probing should fail and
> > > > what if device_attach() returns 0 and one of the ->add_dev() callbacks
> > > > returns an error.
> > > 
> > > That's a total mess...
> 
> Right and so modifying that to propagate return value wouldn't be that straight
> forward.

That's the point.  Doing it in one place only just because that covers your
particular use case (which is questionable at best) is not exactly correct in
my view.


> > > Given that there are almost no uses of this api, I think people should
> > > work it out before any more start to pop up :)
> > 
> > cpufreq is one of the users and that's where the problem is, but in my opinion
> > it should be addressed in a different way.
> > 
> > But while we are at it, should the ->add_dev and ->remove_dev callbacks in
> > struct subsys_interface return an int if their return values are always
> > ignored?  Maybe it would be better to redefine them to be void to make it clear
> > that they can't fail?
> 
> For remove_dev(), surely a void return type will make sense. I can put some
> effort to get that done. But not sure about add_dev() yet.

The way ->add_dev is used by the core today, it should be void as well.

Changing the way the core uses it would require figuring out how it should
interact with device_attach().

Thanks,
Rafael


  reply	other threads:[~2015-07-30 18:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-26  9:02 [PATCH] bus: subsys: propagate errors from subsys interface's ->add_dev() Viresh Kumar
2015-07-29 21:19 ` Greg KH
2015-07-29 23:01   ` Rafael J. Wysocki
2015-07-29 22:37     ` Greg KH
2015-07-29 23:29       ` Rafael J. Wysocki
2015-07-29 23:34         ` Greg KH
2015-07-30  3:44         ` Viresh Kumar
2015-07-30 18:53           ` Rafael J. Wysocki [this message]
2015-07-31  6:09             ` Viresh Kumar
2015-07-31 13:41               ` Rafael J. Wysocki
2015-07-30  3:25   ` Viresh Kumar

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=8139001.Q4eV8YG1Il@vostro.rjw.lan \
    --to=rjw@rjwysocki.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pi-cheng.chen@linaro.org \
    --cc=viresh.kumar@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).