public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* firmware loading interface
       [not found] <4AFD971C.3090204@csldevices.co.uk>
@ 2009-11-13 17:47 ` Philip Downer
  2009-11-13 19:29   ` Arnd Bergmann
  2009-11-14  0:35   ` Roland Dreier
  0 siblings, 2 replies; 10+ messages in thread
From: Philip Downer @ 2009-11-13 17:47 UTC (permalink / raw)
  To: linux-kernel

Hi,

I'm working for a company which is manufacturing a new pci card. The
details are probably irrelevant at this stage, but for those who might
be concerned the driver will be covered by the GPL and submitted
upstream at or before the launch of the card.

Currently I'm investigating how to provide firmware upgrades for the
card, and I've been looking at the request_firmware api. All of the
documentation (and mails that I've read from lkml archives) suggest that
request_firmware is for use with devices without firmware stored in
flash or eeprom, and to load it in to memory at initialisation of the
device.

However our device will have flash to store the firmware in and, whilst
it looks as though it would be possible for us to use request_firmware
to provide occasional firmware upgrades from userspace, I can't find any
reference as to whether this is an accepted method for doing so. Could
someone please confirm for me whether or not it's a good idea to use
request_firmware for this, or perhaps point me at another standard
method for doing firmware updates from userspace?

Please note that I am not subscribed to this mailing list, so could
anyone responding please CC me in their response.

Philip Downer



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: firmware loading interface
  2009-11-13 17:47 ` firmware loading interface Philip Downer
@ 2009-11-13 19:29   ` Arnd Bergmann
       [not found]     ` <53ea87da0911140951q1050212fwe9f5839b900b3804@mail.gmail.com>
  2009-11-16 10:57     ` Philip Downer
  2009-11-14  0:35   ` Roland Dreier
  1 sibling, 2 replies; 10+ messages in thread
From: Arnd Bergmann @ 2009-11-13 19:29 UTC (permalink / raw)
  To: Philip Downer; +Cc: linux-kernel

On Friday 13 November 2009, Philip Downer wrote:
> However our device will have flash to store the firmware in and, whilst
> it looks as though it would be possible for us to use request_firmware
> to provide occasional firmware upgrades from userspace, I can't find any
> reference as to whether this is an accepted method for doing so. Could
> someone please confirm for me whether or not it's a good idea to use
> request_firmware for this, or perhaps point me at another standard
> method for doing firmware updates from userspace?

The idea of request_firmware is that it helps you load the firmware
into the device at initialization time so you can use it directly,
without making the firmware blob a part of the kernel driver.

If I understand you correctly, you never need a firmware in user space
in order to use the device, but only for flashing a new version into
the nonvolatile memory.

The easiest way to do that would be an ioctl operation, if you are
implementing a character or block device interface anyway. Just load
the firmware into the RAM of a user application and call an ioctl
with the pointer to the firmware as an argument, but don't use
a data structure with a pointer in it, which would mess up 32 bit
compatibility operation.

If you don't implement a character or block device, the chances are
that you need something else besides an ioctl, depending on how
an application would communicate with your hardware.

	Arnd <><

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: firmware loading interface
  2009-11-13 17:47 ` firmware loading interface Philip Downer
  2009-11-13 19:29   ` Arnd Bergmann
@ 2009-11-14  0:35   ` Roland Dreier
  2009-11-14 16:08     ` Robert Hancock
  2009-12-01  9:14     ` Dmitry Torokhov
  1 sibling, 2 replies; 10+ messages in thread
From: Roland Dreier @ 2009-11-14  0:35 UTC (permalink / raw)
  To: Philip Downer; +Cc: linux-kernel


 > However our device will have flash to store the firmware in and, whilst
 > it looks as though it would be possible for us to use request_firmware
 > to provide occasional firmware upgrades from userspace, I can't find any
 > reference as to whether this is an accepted method for doing so. Could
 > someone please confirm for me whether or not it's a good idea to use
 > request_firmware for this, or perhaps point me at another standard
 > method for doing firmware updates from userspace?

I think request_firmware() is fine for this... you could have a look at
drivers/net/cxgb3 to see a device that writes new firmware to flash when
it detects a version mismatch between driver and device.

 - R.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: firmware loading interface
  2009-11-14  0:35   ` Roland Dreier
@ 2009-11-14 16:08     ` Robert Hancock
       [not found]       ` <53ea87da0911140855u7993989aod746bcaf18ee4c31@mail.gmail.com>
  2009-12-01  9:14     ` Dmitry Torokhov
  1 sibling, 1 reply; 10+ messages in thread
From: Robert Hancock @ 2009-11-14 16:08 UTC (permalink / raw)
  To: Roland Dreier; +Cc: Philip Downer, linux-kernel

On 11/13/2009 06:35 PM, Roland Dreier wrote:
>
>   >  However our device will have flash to store the firmware in and, whilst
>   >  it looks as though it would be possible for us to use request_firmware
>   >  to provide occasional firmware upgrades from userspace, I can't find any
>   >  reference as to whether this is an accepted method for doing so. Could
>   >  someone please confirm for me whether or not it's a good idea to use
>   >  request_firmware for this, or perhaps point me at another standard
>   >  method for doing firmware updates from userspace?
>
> I think request_firmware() is fine for this... you could have a look at
> drivers/net/cxgb3 to see a device that writes new firmware to flash when
> it detects a version mismatch between driver and device.

It depends on the consequences of a failed flash due to losing power, 
crash, etc - if it has the potential to brick the device then I don't 
think that should happen without the user triggering it explicitly..

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: firmware loading interface
       [not found]     ` <53ea87da0911140951q1050212fwe9f5839b900b3804@mail.gmail.com>
@ 2009-11-14 17:54       ` Arnd Bergmann
  0 siblings, 0 replies; 10+ messages in thread
From: Arnd Bergmann @ 2009-11-14 17:54 UTC (permalink / raw)
  To: venu; +Cc: Philip Downer, linux-kernel

On Saturday 14 November 2009, venu wrote:
> Hi Arnd,
> 
> When the driver calls the request_firmware during initialization where is
> the firmware stored. What mean to ask is where the path it picks th firmware
> from ?

See Documentation/firmware_class/README. The file name is hardcoded
in the device driver. The path is part of the hotplug implementation,
typicaly /lib/firmware.

	Arnd <><

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: firmware loading interface
       [not found]       ` <53ea87da0911140855u7993989aod746bcaf18ee4c31@mail.gmail.com>
@ 2009-11-14 18:19         ` Robert Hancock
  2009-11-14 18:29           ` Arjan van de Ven
  0 siblings, 1 reply; 10+ messages in thread
From: Robert Hancock @ 2009-11-14 18:19 UTC (permalink / raw)
  To: venu; +Cc: Roland Dreier, Philip Downer, linux-kernel

On Sat, Nov 14, 2009 at 10:55 AM, venu <vjosyula@gmail.com> wrote:
>  who triggers this upgrade from userspace ? I understand it is a naivee /
> beginers questions but i hope somebody explains me how ?

The request_firmware interface probably isn't suitable for that..
using an ioctl or read/write-based interface, possibly on a separate
device node, would likely be the way to go..

>
> On Sat, Nov 14, 2009 at 9:38 PM, Robert Hancoctk <hancockrwd@gmail.cr tom>
> wrote:
>>
>> On 11/13/2009 06:35 PM, Roland Dreier wrote:
>>>
>>>  >  However our device will have flash to store the firmware in and,
>>> whilst
>>>  >  it looks as though it would be possible for us to use
>>> request_firmware
>>>  >  to provide occasional firmware upgrades from userspace, I can't find
>>> any
>>>  >  reference as to whether this is an accepted method for doing so.
>>> Could
>>>  >  someone please confirm for me whether or not it's a good idea to use
>>>  >  request_firmware for this, or perhaps point me at another standard
>>>  >  method for doing firmware updates from userspace?
>>>
>>> I think request_firmware() is fine for this... you could have a look at
>>> drivers/net/cxgb3 to see a device that writes new firmware to flash when
>>> it detects a version mismatch between driver and device.
>>
>> It depends on the consequences of a failed flash due to losing power,
>> crash, etc - if it has the potential to brick the device then I don't think
>> that should happen without the user triggering it explicitly..

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: firmware loading interface
  2009-11-14 18:19         ` Robert Hancock
@ 2009-11-14 18:29           ` Arjan van de Ven
  2009-11-16 11:16             ` Philip Downer
  0 siblings, 1 reply; 10+ messages in thread
From: Arjan van de Ven @ 2009-11-14 18:29 UTC (permalink / raw)
  To: Robert Hancock; +Cc: venu, Roland Dreier, Philip Downer, linux-kernel

On Sat, 14 Nov 2009 12:19:13 -0600
Robert Hancock <hancockrwd@gmail.com> wrote:

> On Sat, Nov 14, 2009 at 10:55 AM, venu <vjosyula@gmail.com> wrote:
> >  who triggers this upgrade from userspace ? I understand it is a
> > naivee / beginers questions but i hope somebody explains me how ?
> 
> The request_firmware interface probably isn't suitable for that..
> using an ioctl or read/write-based interface, possibly on a separate
> device node, would likely be the way to go..
> 

it's not unusual to have a sysfs attribute that, when written to, will
just do a request_firmware().
It's not pretty, but it's cleaner than the alternatives....


-- 
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: firmware loading interface
  2009-11-13 19:29   ` Arnd Bergmann
       [not found]     ` <53ea87da0911140951q1050212fwe9f5839b900b3804@mail.gmail.com>
@ 2009-11-16 10:57     ` Philip Downer
  1 sibling, 0 replies; 10+ messages in thread
From: Philip Downer @ 2009-11-16 10:57 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linux-kernel

Arnd Bergmann wrote:
> On Friday 13 November 2009, Philip Downer wrote:
>   
>> However our device will have flash to store the firmware in and, whilst
>> it looks as though it would be possible for us to use request_firmware
>> to provide occasional firmware upgrades from userspace, I can't find any
>> reference as to whether this is an accepted method for doing so. Could
>> someone please confirm for me whether or not it's a good idea to use
>> request_firmware for this, or perhaps point me at another standard
>> method for doing firmware updates from userspace?
>>     
>
> The idea of request_firmware is that it helps you load the firmware
> into the device at initialization time so you can use it directly,
> without making the firmware blob a part of the kernel driver.
>
> If I understand you correctly, you never need a firmware in user space
> in order to use the device, but only for flashing a new version into
> the nonvolatile memory.
>   

Thats correct.

> The easiest way to do that would be an ioctl operation, if you are
> implementing a character or block device interface anyway. Just load
> the firmware into the RAM of a user application and call an ioctl
> with the pointer to the firmware as an argument, but don't use
> a data structure with a pointer in it, which would mess up 32 bit
> compatibility operation.

Thank you for this suggestion and for the warning about 32bit, we are in 
fact implementing a character device and could use this method.

Thanks,

Philip Downer

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: firmware loading interface
  2009-11-14 18:29           ` Arjan van de Ven
@ 2009-11-16 11:16             ` Philip Downer
  0 siblings, 0 replies; 10+ messages in thread
From: Philip Downer @ 2009-11-16 11:16 UTC (permalink / raw)
  To: Arjan van de Ven; +Cc: Robert Hancock, venu, Roland Dreier, linux-kernel

Arjan van de Ven wrote:
> it's not unusual to have a sysfs attribute that, when written to, will
> just do a request_firmware().
> It's not pretty, but it's cleaner than the alternatives....
>   

This was in fact what I was considering when making my initial post, but 
couldn't find any examples or drivers which do use sysfs and request 
firmware in this way and as you say, it's not pretty. However if it's 
considered to be cleaner by others (I certainly think it to be so) then 
I am inclined to use this method as opposed to the ioctl method 
suggested by Arnd earlier in the thread.

Arjan, could you possibly point me at any drivers which already work in 
this way?

Thanks,

Philip Downer


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: firmware loading interface
  2009-11-14  0:35   ` Roland Dreier
  2009-11-14 16:08     ` Robert Hancock
@ 2009-12-01  9:14     ` Dmitry Torokhov
  1 sibling, 0 replies; 10+ messages in thread
From: Dmitry Torokhov @ 2009-12-01  9:14 UTC (permalink / raw)
  To: Roland Dreier; +Cc: Philip Downer, linux-kernel

On Fri, Nov 13, 2009 at 04:35:01PM -0800, Roland Dreier wrote:
> 
>  > However our device will have flash to store the firmware in and, whilst
>  > it looks as though it would be possible for us to use request_firmware
>  > to provide occasional firmware upgrades from userspace, I can't find any
>  > reference as to whether this is an accepted method for doing so. Could
>  > someone please confirm for me whether or not it's a good idea to use
>  > request_firmware for this, or perhaps point me at another standard
>  > method for doing firmware updates from userspace?
> 
> I think request_firmware() is fine for this... you could have a look at
> drivers/net/cxgb3 to see a device that writes new firmware to flash when
> it detects a version mismatch between driver and device.
> 

Doesn't dell_rbu also uses request-firmware for flashing BIOS?

-- 
Dmitry

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-12-01  9:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <4AFD971C.3090204@csldevices.co.uk>
2009-11-13 17:47 ` firmware loading interface Philip Downer
2009-11-13 19:29   ` Arnd Bergmann
     [not found]     ` <53ea87da0911140951q1050212fwe9f5839b900b3804@mail.gmail.com>
2009-11-14 17:54       ` Arnd Bergmann
2009-11-16 10:57     ` Philip Downer
2009-11-14  0:35   ` Roland Dreier
2009-11-14 16:08     ` Robert Hancock
     [not found]       ` <53ea87da0911140855u7993989aod746bcaf18ee4c31@mail.gmail.com>
2009-11-14 18:19         ` Robert Hancock
2009-11-14 18:29           ` Arjan van de Ven
2009-11-16 11:16             ` Philip Downer
2009-12-01  9:14     ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox