From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Ming Lei <tom.leiming@gmail.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
"linux-usb" <linux-usb@vger.kernel.org>,
Alan Stern <stern@rowland.harvard.edu>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
Oliver Neukum <oneukum@suse.de>, Dave Jones <davej@redhat.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Matthew Garrett <mjg@redhat.com>,
Jack Stone <jwjstone@fastmail.fm>,
Larry Finger <Larry.Finger@lwfinger.net>,
Alan Cox <alan@lxorguk.ukuu.org.uk>,
Linux PM list <linux-pm@vger.kernel.org>
Subject: Re: [RFC] firmware load: defer request_firmware during early boot and resume
Date: Sat, 21 Jul 2012 19:35:43 +0200 [thread overview]
Message-ID: <201207211935.44157.rjw@sisk.pl> (raw)
In-Reply-To: <CACVXFVM0hZcA8TPpydODpVsQjYP=w5PpvB4-3PZYdDu+r6SchQ@mail.gmail.com>
On Saturday, July 21, 2012, Ming Lei wrote:
> On Sat, Jul 21, 2012 at 5:56 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> > On Saturday, July 21, 2012, Ming Lei wrote:
> >> CC guys who discussed the problem in the below link in Jan. :
> >>
> >> http://marc.info/?t=132528956000002&r=10&w=2
> >>
> >> On Fri, Jul 20, 2012 at 8:33 PM, Ming Lei <tom.leiming@gmail.com> wrote:
> >> > The RFC patch is just for discussing if the idea of deferring
> >> > request_firmware is doable for addressing the issue of
> >> > request_firmware in resume path, which is caused by driver
> >> > unbind/rebind during resume.
> >> >
> >> > At least usb bus is involved in such things, one driver may be
> >> > unbound and rebound in resume path at several situations, and
> >> > request_firmware is often called inside probe().
> >> >
> >> > Also the idea should be helpful for other hotplug buses too,
> >> > at least there was the similar problem report on pcmcia bus.
> >>
> >> Looks it works well in my two test cases: one is to call request_firmware
> >> in early boot(initcall), another one is to call request_firmware in probe()
> >> of resume path(caused by unbind & rebind). And without the patch, both
> >> two request_firmware return failure and can't complete the loading.
> >
> > And that's precisely why you're not supposed to use request_firmware() in
> > those two situations.
>
> So you mean we should do as below?
>
> For the early boot situation, the driver which calls request_firmware in probe()
> can't be built in kernel image.
>
> For the second situation, some drivers can't be allowed to call
> request_firmware()
> in its probe() because these drivers may be unbound and rebound inside resume()
> or complete_resume(), for example, see usb_resume_complete().
>
> IMO, the 1st one is very unfriendly and the 2nd one can't be avoided for some
> hotplug buses.
I'm not sure if it really can't be avoided.
> That is just the motivation of this patch to make request_firmware() workable in
> both the two above situations.
>
> >
> > My opinion is that, at least for the suspend/hibernate case, the firmware
> > data should be loaded into memory before suspend (e.g. using a PM notifier)
> > and released only after the corresponding resume (or suspend failure), so
> > that it's present in memory during the entire suspend-resume cycle.
>
> The patch isn't to replace caching firmware data during suspend-resume cycle,
> and just a supplement for it.
>
> It is not easy to cache firmware data during suspend-resume cycle for
> the above 2nd situation because of the lifetime problem of firmware data:
> the driver may be unbound and rebound inside resume path, even the
> device may vanish and appear again.
>
> Also, Matthew had a below case[1] which can't be solved with caching
> firmware data at all, not to mention consuming much memory by caching
> firmware:
>
> 1) user boots from cold. Device comes up with generic USB ID.
> 2) isight_firmware loads and binds. Firmware is loaded. Device
> disconnects and reconnects with an ID that's bound by the UVC
> driver.
> 3) user reboots. Device comes up with UVC ID. isight_firmware
> doesn't bind.
> 4) user suspends.
> 5) user resumes. isight_firmware binds and attempts to load firmware.
>
> But it can be dealt with easily by the simple patch.
>
> Finally, suppose caching firmware may work well for the 2nd situation, we still
> have to cache all the firmwares of all hotplug devices(in one system) which
> need firmware before suspending, because these devices may be unplugged
> and plugged again during suspend-resume cycle or be powered off by system.
OK, I give up. This may not be too ugly to live, after all.
I'll post some comments in a reply to the message with the patch.
Thanks,
Rafael
next prev parent reply other threads:[~2012-07-21 17:30 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-20 12:33 [RFC] firmware load: defer request_firmware during early boot and resume Ming Lei
2012-07-20 12:52 ` Borislav Petkov
2012-07-20 12:57 ` Ming Lei
2012-07-20 13:03 ` Borislav Petkov
2012-07-20 13:09 ` Ming Lei
2012-07-20 13:13 ` Borislav Petkov
2012-07-20 13:54 ` Oliver Neukum
2012-07-20 15:53 ` Ming Lei
2012-07-21 4:13 ` Ming Lei
2012-07-21 9:56 ` Rafael J. Wysocki
2012-07-21 13:25 ` Ming Lei
2012-07-21 17:35 ` Rafael J. Wysocki [this message]
2012-07-21 17:31 ` Linus Torvalds
2012-07-21 17:53 ` Rafael J. Wysocki
2012-07-21 19:55 ` Ming Lei
2012-07-21 20:38 ` Linus Torvalds
2012-07-21 20:46 ` david
2012-07-21 23:24 ` Ming Lei
2012-07-22 12:58 ` Borislav Petkov
2012-07-22 19:46 ` Linus Torvalds
2012-07-23 8:12 ` Borislav Petkov
2012-07-21 21:01 ` Francois Romieu
2012-07-21 17:49 ` Rafael J. Wysocki
2012-07-21 20:09 ` Ming Lei
2012-07-21 21:33 ` Rafael J. Wysocki
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=201207211935.44157.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=Larry.Finger@lwfinger.net \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=davej@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=jwjstone@fastmail.fm \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mjg@redhat.com \
--cc=oneukum@suse.de \
--cc=stern@rowland.harvard.edu \
--cc=tom.leiming@gmail.com \
--cc=torvalds@linux-foundation.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