[lkml]   [2012]   [Mar]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] firmware loader: don't cancel _nowait requests when helper is not yet available
On Saturday 10 March 2012 00:36:59 Greg KH wrote:
> On Fri, Mar 09, 2012 at 11:30:24PM +0100, Christian Lamparter wrote:
> > This patch fixes a regression which was introduced by:
> > "PM: Print a warning if firmware is requested when tasks are frozen"
> >
> > request_firmware_nowait does not stall in any system resume paths.
> > Therefore, I think it is perfectly save to use request_firmware_nowait
> > from at least the ->complete() callback.
> Is there code somewhere in the kernel that wants to do this?
uum, yes: The USB subsystem [Good thing, I'm already talking to you! :-D]

Take a look at drivers/usb/core/usb.c:

the ->complete callback is registered to usb_dev_complete(dev*), which
is just a lengthy wrapper for usb_resume(dev, PMSG_ON).

Now, let's switch to drivers/usb/core/driver.c:

usb_resume calls do_unbind_rebind(udev, DO_REBIND) and there we go...
So any usb driver which uses request_firmware_nowait in .probe is
a possible target for the warning.

The one I stumbled across is the pcmcia subsystem. Currently it
tries to rebind the devices during ->resume but I have already
sent a patch to postpone that till the ->complete callback comes in.

> Has commit a144c6a broken it somehow that this fix would resolve it?
When I read the commit, it only talked only about broken drivers doing
"request_firmware" during .probe. But it does not mention what should
be done with "request_firmware_nowait" in such a case at all. I think
it was just an oversight from all involved parties that just got
noticed now.

> > Signed-off-by: Christian Lamparter <>
> > ---
> > drivers/base/firmware_class.c | 2 +-
> > 1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
> > index 6c9387d..017e020 100644
> > --- a/drivers/base/firmware_class.c
> > +++ b/drivers/base/firmware_class.c
> > @@ -535,7 +535,7 @@ static int _request_firmware(const struct firmware **firmware_p,
> >
> > read_lock_usermodehelper();
> >
> > - if (WARN_ON(usermodehelper_is_disabled())) {
> > + if (WARN_ON(usermodehelper_is_disabled() && !(nowait && uevent))) {
> What does uevent have to do with things here?
I found this "useful" comment about uevent in request_firmware_nowait's kdocs:
* @uevent: sends uevent to copy the firmware image if this flag
* is non-zero else the firmware copy must be done manually.
I think this flag controls whenever we want to sent a firmware request event
to the usermodehelper...
[No idea why this should ever be 'false', maybe there is a good use-case for
it when the firmware is built-in... But anyway let's just say I'm as ignorant
as everybody else and I haven't got a single clue about it.]


 \ /
  Last update: 2012-03-10 01:55    [W:0.134 / U:2.496 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site