orinoco: clean up firmware download
cover orinoco: clean up firmware download
This series is a refactorring of the RFC previously posted as
orinoco: Don't keep cached firmware around permanently
The recent patch to load orinoco firmware correctly on resume simply kept the firmware in RAM for the entire time the module was loaded, and only applied to Agere firmware.
The first two patches extend this to Symbol firmware.
The third makes the spectrum_cs driver use this functionality directly during resume instead of resetting the card.
The final patch provides an option to use the new power management notifiers to load the firmware prior to suspend and release it after resume.
David Kilroy (4):
orinoco: Separate fw caching from download
orinoco: Cache Symbol firmware
orinoco: Resume spectrum_cs in the same way as orinoco_cs
orinoco: Provide option to avoid unnecessary fw caching
drivers/net/wireless/Kconfig | 15 +++ drivers/net/wireless/orinoco/orinoco.c | 156 ++++++++++++++++++++++----- drivers/net/wireless/orinoco/orinoco.h | 6 +- drivers/net/wireless/orinoco/spectrum_cs.c | 21 ++++- 4 files changed, 167 insertions(+), 31 deletions(-)
PATCH 1/4 orinoco: Separate fw caching from download
This refactorring will make it easier to share logic with Symbol firmware.
Signed-off by: David Kilroy <[email protected]>
--- drivers/net/wireless/orinoco/orinoco.c | 53 +++++++++++++++++++++++--------- 1 files changed, 38 insertions(+), 15 deletions(-)
drivers/net/wireless/orinoco/orinoco.c +38 -15
@@ -431,9 +431,9 @@ struct fw_info { };const static struct fw_info orinoco_fw[] = { - {"" ,"agere_sta_fw.bin" ,"agere_ap_fw.bin" ,0x00390000 ,1000 }, - {"" ,"prism_sta_fw.bin" ,"prism_ap_fw.bin" ,0 ,1024 }, - {"symbol_sp24t_prim_fw" ,"symbol_sp24t_sec_fw" ,"" ,0x00003100 ,512 } + {NULL ,"agere_sta_fw.bin" ,"agere_ap_fw.bin" ,0x00390000 ,1000 }, + {NULL ,"prism_sta_fw.bin" ,"prism_ap_fw.bin" ,0 ,1024 }, + {"symbol_sp24t_prim_fw" ,"symbol_sp24t_sec_fw" ,NULL ,0x00003100 ,512 } };/* Structure used to access fields in FW
@@ -487,18 +487,17 @@ orinoco_dl_firmware(struct orinoco_private *priv,if (err) goto free; -if (priv->cached_fw) - fw_entry = priv->cached_fw; -else { +if (!priv->cached_fw) { err =request_firmware (&fw_entry, firmware, priv->dev); +if (err) {printk (KERN_ERR "%s: Cannot find firmware %s\n" , dev->name, firmware); err = -ENOENT ; goto free; } - priv->cached_fw = fw_entry; - } + }else + fw_entry = priv->cached_fw; hdr = (const struct orinoco_fw_header *) fw_entry->data;
@@ -540,11 +539,9 @@ orinoco_dl_firmware(struct orinoco_private *priv, dev->name, hermes_present(hw)); abort: -/* In case of error, assume firmware was bogus and release it */ -if (err) { - priv->cached_fw =NULL ; +/* If we requested the firmware, release it. */ +if (!priv->cached_fw)release_firmware (fw_entry); - } free:kfree (pda);
@@ -708,6 +705,30 @@ static int orinoco_download(struct orinoco_private *priv)return err; } +static void orinoco_cache_fw (struct orinoco_private *priv,int ap) +{ +const struct firmware *fw_entry =NULL ; +const char *fw; + +if (ap) + fw = orinoco_fw[priv->firmware_type].ap_fw; +else + fw = orinoco_fw[priv->firmware_type].sta_fw; + +if (fw) { +if (request_firmware (&fw_entry, fw, priv->dev) ==0 ) + priv->cached_fw = fw_entry; + } +} + +static void orinoco_uncache_fw (struct orinoco_private *priv) +{ +if (priv->cached_fw) +release_firmware (priv->cached_fw); + + priv->cached_fw =NULL ; +} +/********************************************************************/ /* Device methods */ /********************************************************************/
@@ -3308,6 +3329,8 @@ static int orinoco_init(struct net_device *dev) }if (priv->do_fw_download) { +orinoco_cache_fw (priv,0 ); + err =orinoco_download (priv);if (err) priv->do_fw_download =0 ;
@@ -3557,9 +3580,9 @@ void free_orinocodev(struct net_device *dev)* when we call tasklet_kill it will run one final time, * emptying the list */ tasklet_kill (&priv->rx_tasklet); -if (priv->cached_fw) -release_firmware (priv->cached_fw); - priv->cached_fw =NULL ; + +orinoco_uncache_fw (priv); + priv->wpa_ie_len =0 ;kfree (priv->wpa_ie);orinoco_mic_free (priv);
Signature · 1 line
1.5.6.4
PATCH 2/4 orinoco: Cache Symbol firmware
Signed-off by: David Kilroy <[email protected]>
--- drivers/net/wireless/orinoco/orinoco.c | 46 ++++++++++++++++++++++--------- drivers/net/wireless/orinoco/orinoco.h | 3 +- 2 files changed, 34 insertions(+), 15 deletions(-)
drivers/net/wireless/orinoco/orinoco.c +32 -14
@@ -645,34 +645,41 @@ symbol_dl_firmware(struct orinoco_private *priv,int ret;const struct firmware *fw_entry; -if (request_firmware (&fw_entry, fw->pri_fw, - priv->dev) !=0 ) { -printk (KERN_ERR "%s: Cannot find firmware: %s\n" , - dev->name, fw->pri_fw); -return -ENOENT ; - } +if (!priv->cached_pri_fw) { +if (request_firmware (&fw_entry, fw->pri_fw, priv->dev) !=0 ) { +printk (KERN_ERR "%s: Cannot find firmware: %s\n" , + dev->name, fw->pri_fw); +return -ENOENT ; + } + }else + fw_entry = priv->cached_pri_fw;/* Load primary firmware */ ret =symbol_dl_image (priv, fw, fw_entry->data, fw_entry->data + fw_entry->size,0 ); -release_firmware (fw_entry); + +if (!priv->cached_pri_fw) +release_firmware (fw_entry);if (ret) {printk (KERN_ERR "%s: Primary firmware download failed\n" , dev->name);return ret; } -if (request_firmware (&fw_entry, fw->sta_fw, - priv->dev) !=0 ) { -printk (KERN_ERR "%s: Cannot find firmware: %s\n" , - dev->name, fw->sta_fw); -return -ENOENT ; - } +if (!priv->cached_fw) { +if (request_firmware (&fw_entry, fw->sta_fw, priv->dev) !=0 ) { +printk (KERN_ERR "%s: Cannot find firmware: %s\n" , + dev->name, fw->sta_fw); +return -ENOENT ; + } + }else + fw_entry = priv->cached_fw;/* Load secondary firmware */ ret =symbol_dl_image (priv, fw, fw_entry->data, fw_entry->data + fw_entry->size,1 ); -release_firmware (fw_entry); +if (!priv->cached_fw) +release_firmware (fw_entry);if (ret) {printk (KERN_ERR "%s: Secondary firmware download failed\n" , dev->name);
@@ -708,13 +715,20 @@ static int orinoco_download(struct orinoco_private *priv)static void orinoco_cache_fw (struct orinoco_private *priv,int ap) {const struct firmware *fw_entry =NULL ; +const char *pri_fw;const char *fw; + pri_fw = orinoco_fw[priv->firmware_type].pri_fw;if (ap) fw = orinoco_fw[priv->firmware_type].ap_fw;else fw = orinoco_fw[priv->firmware_type].sta_fw; +if (pri_fw) { +if (request_firmware (&fw_entry, pri_fw, priv->dev) ==0 ) + priv->cached_pri_fw = fw_entry; + } +if (fw) {if (request_firmware (&fw_entry, fw, priv->dev) ==0 ) priv->cached_fw = fw_entry;
@@ -723,9 +737,12 @@ static void orinoco_cache_fw(struct orinoco_private *priv, int ap)static void orinoco_uncache_fw (struct orinoco_private *priv) { +if (priv->cached_pri_fw) +release_firmware (priv->cached_pri_fw);if (priv->cached_fw)release_firmware (priv->cached_fw); + priv->cached_pri_fw =NULL ; priv->cached_fw =NULL ; }
@@ -3567,6 +3584,7 @@ struct net_devicenetif_carrier_off (dev); priv->last_linkstatus =0xffff ; + priv->cached_pri_fw =NULL ; priv->cached_fw =NULL ;return dev;
drivers/net/wireless/orinoco/orinoco.h +2 -1
@@ -167,7 +167,8 @@ struct orinoco_private { unsigned int tkip_cm_active:1; unsigned int key_mgmt:3; -/* Cached in memory firmware to use in ->resume */ +/* Cached in memory firmware to use during ->resume. */ +const struct firmware *cached_pri_fw;const struct firmware *cached_fw; };
Signature · 1 line
1.5.6.4
PATCH 3/4 orinoco: Resume spectrum_cs in the same way as orinoco_cs
Retrieval of external firmware has been resolved, and should work with the standard orinoco resume algorithm.
This fixes an issue where priv->hw_unavailable indicates the card is ready when firmware has not been loaded.
Signed-off by: David Kilroy <[email protected]>
--- drivers/net/wireless/orinoco/spectrum_cs.c | 21 ++++++++++++++++++++- 1 files changed, 20 insertions(+), 1 deletions(-)
drivers/net/wireless/orinoco/spectrum_cs.c +20 -1
@@ -450,10 +450,29 @@ spectrum_cs_resume(struct pcmcia_device *link) {struct net_device *dev = link->priv;struct orinoco_private *priv =netdev_priv (dev); +unsigned long flags; +int err; + + err =orinoco_reinit_firmware (dev); +if (err) { +printk (KERN_ERR "%s: Error %d re-initializing firmware\n" , + dev->name, err); +return -EIO ; + } + +spin_lock_irqsave (&priv->lock, flags);netif_device_attach (dev); priv->hw_unavailable--; -schedule_work (&priv->reset_work); + +if (priv->open && !priv->hw_unavailable) { + err =__orinoco_up (dev); +if (err) +printk (KERN_ERR "%s: Error %d restarting card\n" , + dev->name, err); + } + +spin_unlock_irqrestore (&priv->lock, flags);return 0 ; }
Signature · 1 line
1.5.6.4
PATCH 4/4 orinoco: Provide option to avoid unnecessary fw caching
Make firmware caching on startup optional, and make it default.
When the option is not selected and PM_SLEEP is configured, then cache firmware in the suspend pm_notifier. This configuration saves about 64k RAM in normal use, but can lead to a situation where the driver is configured to use a different firmware.
Signed-off by: David Kilroy <[email protected]>
--- drivers/net/wireless/Kconfig | 15 ++++++++ drivers/net/wireless/orinoco/orinoco.c | 57 ++++++++++++++++++++++++++++++++ drivers/net/wireless/orinoco/orinoco.h | 3 ++ 3 files changed, 75 insertions(+), 0 deletions(-)
drivers/net/wireless/Kconfig +15 -0
@@ -214,6 +214,21 @@ config HERMES configure your card and that /etc/pcmcia/wireless.opts works : <http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html> +config HERMES_CACHE_FW_ON_INIT + bool "Cache Hermes firmware on driver initialisation" + depends on HERMES + default y + ---help--- + Say Y to cache any firmware required by the Hermes drivers + on startup. The firmware will remain cached until the + driver is unloaded. The cache uses 64K of RAM. + + Otherwise load the firmware from userspace as required. In + this case the driver should be unloaded and restarted + whenever the firmware is changed. + + If you are not sure, say Y. + config APPLE_AIRPORT tristate "Apple Airport support (built-in)" depends on PPC_PMAC && HERMES
drivers/net/wireless/orinoco/orinoco.c +57 -0
100 lines not on this page · raw message
drivers/net/wireless/orinoco/orinoco.h +3 -0
@@ -10,6 +10,7 @@#define DRIVER_VERSION "0.15"#include <linux/interrupt.h> +#include <linux/suspend.h> #include <linux/netdevice.h> #include <linux/wireless.h> #include <net/iw_handler.h>
@@ -170,6 +171,8 @@ struct orinoco_private {/* Cached in memory firmware to use during ->resume. */ const struct firmware *cached_pri_fw;const struct firmware *cached_fw; + +struct notifier_block pm_notifier; };#ifdef ORINOCO_DEBUG
Signature · 1 line
1.5.6.4