Skip to contentSkip to conversation

libertas: fix CF firmware loading for some cards

PATCH In review Dan Williams 4 participants 6 messages Jan 23, 2009 – Jan 26, 2009 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libertas: fix CF firmware loading for some cards

if_cs_poll_while_fw_download() returned the number of iterations remaining on success, which in turn got returned as the value from if_cs_prog_real() and if_cs_prog_helper(). But since if_cs_probe() interprets non-zero return values from firmware load functions as an error, this sometimes caused spurious firmware load failures.

---

drivers/net/wireless/libertas/if_cs.c +1 -1
index 842a08d..8f8934a 100644
@@ -151,7 +151,7 @@ static int if_cs_poll_while_fw_download(struct if_cs_card *card, uint addr, u8 r
 	for (i = 0; i < 100000; i++) {
 		u8 val = if_cs_read8(card, addr);
 		if (val == reg)
-			return i;
+			return 0;
 		udelay(5);
 	}
 	return -ETIME;
#1 lore raw
Quoted 14 lines · On Friday 23 January 2009 17:55:33 Dan Williams wrote:

if_cs_poll_while_fw_download() returned the number of iterations remaining on success, which in turn got returned as the value from if_cs_prog_real() and if_cs_prog_helper(). But since if_cs_probe() interprets non-zero return values from firmware load functions as an error, this sometimes caused spurious firmware load failures.

---

drivers/net/wireless/libertas/if_cs.c +0 -0
index 842a08d..8f8934a 100644

drivers/net/wireless/libertas/if_cs.c static int if_cs_poll_while_fw_download(struct if_cs_card *card, uint addr, u8 r · line 157

Quoted 8 lines
drivers/net/wireless/libertas/if_cs.c +1 -1
@@ -151,7 +151,7 @@ static int if_cs_poll_while_fw_download(struct if_cs_card *card, uint addr, u8 r
 	for (i = 0; i < 100000; i++) {
 		u8 val = if_cs_read8(card, addr);
 		if (val == reg)
-			return i;
+			return 0;
 		udelay(5);
 	}
 	return -ETIME;

This is an incredibly expensive loop, btw. Even for init it's really painful to hog the CPU for more than half a second. Especially on UP.
Any chance for msleep()?

Signature · 1 line
Greetings, Michael.
#2 lore raw
Quoted 19 lines · Michael Buesch
Quoted 18 lines · On Friday 23 January 2009 17:55:33 Dan Williams wrote:

if_cs_poll_while_fw_download() returned the number of iterations remaining on success, which in turn got returned as the value from if_cs_prog_real() and if_cs_prog_helper(). But since if_cs_probe() interprets non-zero return values from firmware load functions as an error, this sometimes caused spurious firmware load failures.

---

drivers/net/wireless/libertas/if_cs.c +0 -1
index 842a08d..8f8934a 100644
@@ -151,7 +151,7 @@ static int if_cs_poll_while_fw_download(struct if_cs_card *card, uint addr, u8 r
 	for (i = 0; i < 100000; i++) {
 		u8 val = if_cs_read8(card, addr);
 		if (val == reg)
-			return i;
Quoted 8 lines

drivers/net/wireless/libertas/if_cs.c static int if_cs_poll_while_fw_download(struct if_cs_card *card, uint addr, u8 r · line 157

Quoted 4 lines
drivers/net/wireless/libertas/if_cs.c +1 -0
+			return 0;
 		udelay(5);
 	}
 	return -ETIME;

This is an incredibly expensive loop, btw. Even for init it's really painful to hog the CPU for more than half a second. Especially on UP.
Any chance for msleep()?

Could be, Holger did the initial patch and I'm not sure if the udelay was intentional. Note that this happens at PCMCIA/CF hardware probe time (if that has any constraints that might apply here).

dan

#3 lore raw
Quoted 4 lines

Could be, Holger did the initial patch and I'm not sure if the udelay was intentional. Note that this happens at PCMCIA/CF hardware probe time (if that has any constraints that might apply here).

I'm used the card on an ARM architecture, and there long mdelay won't work as on i386, so I used udelay.

In practice, the "expensive loop" isn't that expensive, because the real number of iterations is quite low (contrary to what the manual states).

Tested-by Acked-by on v1 1/1
#4 lore raw
In reply to Dan Williams
Quoted 16 lines · Dan Williams

if_cs_poll_while_fw_download() returned the number of iterations remaining on success, which in turn got returned as the value from if_cs_prog_real() and if_cs_prog_helper(). But since if_cs_probe() interprets non-zero return values from firmware load functions as an error, this sometimes caused spurious firmware load failures.

---

drivers/net/wireless/libertas/if_cs.c +0 -0
index 842a08d..8f8934a 100644

drivers/net/wireless/libertas/if_cs.c static int if_cs_poll_while_fw_download(struct if_cs_card *card, uint addr, u8 r · line 157

Quoted 8 lines
drivers/net/wireless/libertas/if_cs.c +1 -1
@@ -151,7 +151,7 @@ static int if_cs_poll_while_fw_download(struct if_cs_card *card, uint addr, u8 r
 	for (i = 0; i < 100000; i++) {
 		u8 val = if_cs_read8(card, addr);
 		if (val == reg)
-			return i;
+			return 0;
 		udelay(5);
 	}
 	return -ETIME;

Hmmm, I posted this same patch here a couple of months ago
(http://lists.infradead.org/pipermail/libertas-dev/2008-October/002019.html),
did I get something wrong in the submission process, or did it just get lost in the woodwork? Anyway:

~Ryan

#5 lore raw
Quoted 22 lines · Ryan Mallon
Quoted 21 lines · Dan Williams

if_cs_poll_while_fw_download() returned the number of iterations remaining on success, which in turn got returned as the value from if_cs_prog_real() and if_cs_prog_helper(). But since if_cs_probe() interprets non-zero return values from firmware load functions as an error, this sometimes caused spurious firmware load failures.

---

drivers/net/wireless/libertas/if_cs.c +1 -1
index 842a08d..8f8934a 100644
@@ -151,7 +151,7 @@ static int if_cs_poll_while_fw_download(struct if_cs_card *card, uint addr, u8 r
 	for (i = 0; i < 100000; i++) {
 		u8 val = if_cs_read8(card, addr);
 		if (val == reg)
-			return i;
+			return 0;
 		udelay(5);
 	}
Quoted 8 lines

drivers/net/wireless/libertas/if_cs.c static int if_cs_poll_while_fw_download(struct if_cs_card *card, uint addr, u8 r · line 157

Quoted 3 lines
drivers/net/wireless/libertas/if_cs.c +0 -0
 	return -ETIME;

Hmmm, I posted this same patch here a couple of months ago
(http://lists.infradead.org/pipermail/libertas-dev/2008-October/002019.html),
did I get something wrong in the submission process, or did it just get lost in the woodwork? Anyway:

Apparently I didn't read enough down that thread to find the second patch; I only found the one that changed if_cs_prog_helper() and if_cs_prog_real(). My mistake, this patch is yours.

John; when you apply, please credit Ryan.

Dan