public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Manuel Estrada Sainz <ranty@debian.org>
To: Oliver Neukum <oliver@neukum.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Simon Kelley <simon@thekelleys.org.uk>,
	Alan Cox <alan@lxorguk.ukuu.org.uk>,
	"Downing, Thomas" <Thomas.Downing@ipc.com>,
	Greg KH <greg@kroah.com>,
	jt@hpl.hp.com, Pavel Roskin <proski@gnu.org>
Subject: Re: request_firmware() hotplug interface, third round.
Date: Fri, 16 May 2003 20:31:52 +0200	[thread overview]
Message-ID: <20030516183152.GB18732@ranty.ddts.net> (raw)
In-Reply-To: <200305161753.17198.oliver@neukum.org>

On Fri, May 16, 2003 at 05:53:17PM +0200, Oliver Neukum wrote:
> Am Freitag, 16. Mai 2003 11:56 schrieb Manuel Estrada Sainz:
> > On Fri, May 16, 2003 at 10:07:31AM +0200, Oliver Neukum wrote:
> > > >  How it works:
> > > > 	- Driver calls request_firmware()
> > > > 	- 'hotplug firmware' gets called with ACCTION=add
> > > > 	- /sysfs/class/firmware/dev_name/{data,loading} show up.
> > > >
> > > > 	- echo 1 > /sysfs/class/firmware/dev_name/loading
> > > > 	- cat whatever_fw > /sysfs/class/firmware/dev_name/data
> > > > 	- echo 0 > /sysfs/class/firmware/dev_name/loading
> > > >
> > > > 	- The call to request_firmware() returns with the firmware in a
> > > > 	  memory buffer and the driver can finish loading.
> > > > 	- Driver loads the firmware.
> > > > 	- Driver calls release_firmware().
> > >
> > > So, if I understand you correctly, RAM is only saved if a device
> > > is hotpluggable and needs firmware only upon intial connection.
> > > Which, if you do suspend to disk correctly, is no device.
> >
> >  Hotpluggability is not required, it is the same for any module, which
> >  gets loaded while the system is running. Drivers don't even need to be
> >  aware of hotplug.
> 
> In that case they can contain the firmware and mark it __init.
> They need no RAM. They can even mark the code needed to put
> firmware into the device as __init.

 There are issues with that approach:

 - Code with firmware will not be accepted in the kernel, there are
   already two drivers that are being hold back for that reason.
   	- Licensing issues.
	- Memory consumption.
	- "new" kernel policy.
 - A device may need to reload firmware upon reset. And if you mark it
   __init, it will not be there.
 - If you include the firmware in the code you have to recompile the
   kernel to update the firmware. Pavel, back me up on this one with the
   ACPI tables issue.
 
> >  And adding some kind of persistence in the mixture so firmware can be
> >  included in the kernel image and later discarded/reconsidered even
> >  in-kernel drivers (meaning non modules) can benefit. Coordinating with
> >  initramfs as Pavel suggested should bring best results in this case.
> >
> >  Also, the hotplug event happens every time you call request_firmware(),
> >  not just on device load or upon initial connection. It is not the
> >  regular "device plug event" it is an special 'firmware' event. For
> >  example, on usb devices you would get two invocations of hotplug, one
> >  'hotplug usb' and one 'hotplug firmware'.
> >
> >  In the case of suspending to disk, you would have to make sure that the
> >  firmware for the device that holds the rest of the firmware is already
> >  in fwfs or whatever persistence method gets finally implemented.
> 
> How and what is the benefit? If you go low on battery you have to suspend,
> there's no choice. This means that you have to have it in RAM always.

 If the device losses the firmware upon suspend, the driver will have to
 reinitialize it as if it just got plugged, which somehow makes all
 devices hotplugable.

 If the driver uses request_firmware(), it doesn't need to handle any
 special case, just initialize as usual and it will get the firmware
 when it needs it.
 
 If the device is needed to access the filesystem, some kind of
 persistence will be needed, so the required firmware is already in
 kernel space. But the driver doesn't need to care, it will just ask for
 the firmware as usual.
 
 Which brings me to another issue, the same device can be required to
 access the filesystem or not:
	- In a diskless client, it is the network card
	- In a live-cd it is the cdrom drive
	- In a multi disk system just one of them will be holding
	  required firmware.
 So you can not decide at coding time, the latest at compile time, and
 ideally at runtime (which is what I am trying to do).
 
> >  At least usb's probe() can sleep, but that is a good point. How about:
> >
> >  int request_firmware_nowait (
> > 		const char *name, const char *device, void *context,
> > 		void (*cont)(const struct firmware *fw, void context)
> >  );
> >
> >  Then you can call request_firmware_nowait providing an appropriate
> >  'cont' callback and 'context' pointer. Then when your callback gets
> >  called with the firmware you finish device setup.
> 
> In this form unworkable. Removing a module could kill the machine.
> That scheme requires that drivers formally register and unregister
> with fwfs and provide module pointers.
> An awful lot of overhead.

 OK, how about:

  int request_firmware_nowait (
  		struct module *module,
 		const char *name, const char *device, void *context,
 		void (*cont)(const struct firmware *fw, void context)
  );

  request_firmware code will try_module_get/module_put as needed.

  Would that fix the issue?
 
> > > You cannot kill a part of the kernel if a script fails to perform
> > > correctly for some reason.
> >
> >  Good point. Since it is easily solvable by hand:
> >
> >  echo 1 > /sysfs/class/firmware/dev_name/loading
> >  echo 0 > /sysfs/class/firmware/dev_name/loading
> >
> >  I thought that it was OK. (I'll do the timeout)
> 
> No, it isn't. These writes must require CAP_HARDWARE, thus
> is no good.

 I'll do the timeout anyway, and make it configurable just in case.

> > > Even worse, you cannot detect the script terminating abnormally in
> > > that design.
> >
> >  Well, the device model doesn't provide that information :(
> >
> >  It would be great if it did.
> >
> >  Would a patch to wait for hotplug termination and provide termination
> >  status be accepted?
> 
> No, you must not wait for user space.

 And to get notified when userspace is done?

> >  Adding an 'struct completion' and 'int status' to the right place
> >  should be just about it.
> >
> > > You'd have to introduce some arbitrary timeout.
> >
> >  OK, I'll do that for now.
> >
> > > It seems to me that you introduce three new problems to get rid of
> > > one old problem.
> >
> >  This is the kind of feedback I wanted, thanks a lot.
> 
> Sorry.

 Don't be, this is still the kind of feedback I want. Weather I manage
 or not, I get the chance to fix the issues.

 Thanks

 	Manuel

-- 
--- Manuel Estrada Sainz <ranty@debian.org>
                         <ranty@bigfoot.com>
			 <ranty@users.sourceforge.net>
------------------------ <manuel.estrada@hispalinux.es> -------------------
Let us have the serenity to accept the things we cannot change, courage to
change the things we can, and wisdom to know the difference.

  reply	other threads:[~2003-05-16 18:19 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-15 20:03 request_firmware() hotplug interface, third round Manuel Estrada Sainz
2003-05-16  8:07 ` Oliver Neukum
2003-05-16  9:56   ` Manuel Estrada Sainz
2003-05-16 15:53     ` Oliver Neukum
2003-05-16 18:31       ` Manuel Estrada Sainz [this message]
2003-05-16 22:22         ` Oliver Neukum
2003-05-17  0:59           ` Manuel Estrada Sainz
2003-05-17  4:00             ` Robert White
2003-05-17 13:23           ` Alan Cox
2003-05-17 14:57             ` Manuel Estrada Sainz
2003-05-16 18:49       ` Jean Tourrilhes
2003-05-16 22:24         ` Oliver Neukum
2003-05-16 23:21         ` Greg KH
2003-05-16 16:09   ` Alan Cox
2003-05-16 22:13     ` Oliver Neukum
2003-05-17  4:50       ` David Gibson
2003-05-17  7:02         ` Oliver Neukum
2003-05-17  8:21           ` David Gibson
2003-05-16 13:13 ` Ingo Oeser
2003-05-16 17:07   ` Manuel Estrada Sainz
2003-05-16 22:36 ` Greg KH
2003-05-16 23:37   ` Manuel Estrada Sainz
2003-05-16 23:59     ` Greg KH
2003-05-17  4:47       ` David Gibson
2003-05-17  8:54         ` Manuel Estrada Sainz
2003-05-16 23:55   ` Oliver Neukum
2003-05-17  0:03     ` Greg KH
2003-05-17  2:42       ` Robert White
2003-05-17  4:44       ` David Gibson
2003-05-17  8:46         ` Manuel Estrada Sainz
2003-05-17  9:07           ` David Gibson
2003-05-17  9:50             ` Manuel Estrada Sainz
2003-05-17 10:30             ` Manuel Estrada Sainz
2003-05-20  5:21               ` David Gibson
2003-05-20  8:07                 ` Manuel Estrada Sainz
2003-05-21  4:21                   ` Greg KH
2003-05-21  7:06                     ` Manuel Estrada Sainz
2003-05-17 10:51   ` Manuel Estrada Sainz
2003-05-17 13:21   ` Ingo Oeser
2003-05-17 15:15     ` Manuel Estrada Sainz
     [not found] ` <Pine.LNX.4.55.0305151623520.2885@marabou.research.att.com>
2003-05-16  9:27   ` Manuel Estrada Sainz
2003-05-16 22:39   ` Greg KH

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=20030516183152.GB18732@ranty.ddts.net \
    --to=ranty@debian.org \
    --cc=Thomas.Downing@ipc.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=greg@kroah.com \
    --cc=jt@hpl.hp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oliver@neukum.org \
    --cc=proski@gnu.org \
    --cc=simon@thekelleys.org.uk \
    /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