mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Darren Salt <linux@youmustbejoking.demon.co.uk>
To: Ben Hutchings <ben@decadent.org.uk>
Cc: Greg Kroah-Hartman <gregkh@suse.de>,
	linux-kernel@vger.kernel.org,
	David Woodhouse <dwmw2@infradead.org>
Subject: [PATCH 4/3] rt2860sta: call release_firmware on module exit, else resume is broken
Date: Sat, 18 Apr 2009 16:15:54 +0100	[thread overview]
Message-ID: <505368DED8%linux@youmustbejoking.demon.co.uk> (raw)
In-Reply-To: <1239590029.18110.122.camel@deadeye.i.decadent.org.uk>

Resume breakage is as follows: it takes somewhat longer (firmware request
timeout), as a result of which the firmware isn't reloaded; and any
subsequent attempt to trying to bring down the interface results in a panic &
lockup (SysRq failure on my 901).

Consequently, it's better to request the firmware once and hang onto it until
the module is unloaded.

Signed-off-by: Darren Salt <linux@youmustbejoking.demon.co.uk>

diff -pur a/drivers/staging/rt2860/2860_main_dev.c b/drivers/staging/rt2860/2860_main_dev.c
--- a/drivers/staging/rt2860/2860_main_dev.c
+++ b/drivers/staging/rt2860/2860_main_dev.c
@@ -289,6 +289,7 @@ static INT __init rt2860_init_module(VOI
 static VOID __exit rt2860_cleanup_module(VOID)
 {
     pci_unregister_driver(&rt2860_driver);
+    NICForgetFirmware();
 }
 
 module_init(rt2860_init_module);
diff -pur a/drivers/staging/rt2860/common/rtmp_init.c b/drivers/staging/rt2860/common/rtmp_init.c
--- a/drivers/staging/rt2860/common/rtmp_init.c
+++ b/drivers/staging/rt2860/common/rtmp_init.c
@@ -144,6 +144,8 @@ RTMP_REG_PAIR	STAMACRegTable[] =	{
 #define FW_FILENAME "rt2860.bin"
 MODULE_FIRMWARE(FW_FILENAME);
 
+const struct firmware *fw = NULL;
+
 #define FIRMWAREIMAGE_MAX_LENGTH	0x2000
 #define FIRMWARE_MAJOR_VERSION	0
 #define FIRMWARE_MINOR_VERSION	2
@@ -2583,6 +2585,12 @@ VOID NICEraseFirmware(
 
 }/* End of NICEraseFirmware */
 
+VOID NICForgetFirmware(void)
+{
+	release_firmware(fw);
+	fw = NULL;
+}
+
 /*
 	========================================================================
 
@@ -2603,11 +2611,11 @@ VOID NICEraseFirmware(
 NDIS_STATUS NICLoadFirmware(
 	IN PRTMP_ADAPTER pAd)
 {
-	const struct firmware *fw;
 	int ret, i;
 	NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
 
-	ret = request_firmware(&fw, FW_FILENAME,
+	ret = fw ? 0 :
+	      request_firmware(&fw, FW_FILENAME,
 			       &((POS_COOKIE)pAd->OS_Cookie)->pci_dev->dev);
 	if (ret) {
 		printk(KERN_ERR "rt2860sta: firmware file %s request failed (%d)\n",
@@ -2659,7 +2667,7 @@ NDIS_STATUS NICLoadFirmware(
 	RTMP_IO_WRITE32(pAd, H2M_BBP_AGENT, 0);
 	RTMP_IO_WRITE32(pAd, H2M_MAILBOX_CSR, 0);
 
-	release_firmware(fw);
+	/*release_firmware(fw);*/
 
 	/* Check if MCU is ready - this may work even if firmware load
 	 * failed: specifically, if firmware was loaded some time ago & the
@@ -2689,7 +2697,7 @@ NDIS_STATUS NICLoadFirmware(
 	return Status;
 
 fail:
-	release_firmware(fw);
+	/*release_firmware(fw);*/
 	return NDIS_STATUS_FAILURE;
 } /* End of NICLoadFirmware */
 
diff -pur a/drivers/staging/rt2860/rtmp.h b/drivers/staging/rt2860/rtmp.h
--- a/drivers/staging/rt2860/rtmp.h
+++ b/drivers/staging/rt2860/rtmp.h
@@ -3571,6 +3571,8 @@ VOID NICEraseFirmware(
 NDIS_STATUS NICLoadFirmware(
 	IN  PRTMP_ADAPTER   pAd);
 
+VOID NICForgetFirmware(void);
+
 NDIS_STATUS NICLoadRateSwitchingParams(
 	IN PRTMP_ADAPTER pAd);
 
-- 
| Darren Salt    | linux or ds at              | nr. Ashington, | Toon
| RISC OS, Linux | youmustbejoking,demon,co,uk | Northumberland | Army
| + Burn less waste. Use less packaging. Waste less.     USE FEWER RESOURCES.

Your society will be sought by people of taste and refinement.

  reply	other threads:[~2009-04-18 15:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-13  2:33 [PATCH 2/3] rt2860sta: use the firmware loader interface and library CRC code Ben Hutchings
2009-04-18 15:15 ` Darren Salt [this message]
2009-04-18 16:54   ` [PATCH 4/3] rt2860sta: call release_firmware on module exit, else resume is broken Ben Hutchings

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=505368DED8%linux@youmustbejoking.demon.co.uk \
    --to=linux@youmustbejoking.demon.co.uk \
    --cc=ben@decadent.org.uk \
    --cc=dwmw2@infradead.org \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®