Skip to contentSkip to conversation

libertas: prioritize usb8388_v5.bin firmware on OLPC machines

PATCH Superseded Andres Salomon 3 participants 7 messages Jul 31, 2011 – Aug 3, 2011 Networking drivers (wireless)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libertas: prioritize usb8388_v5.bin firmware on OLPC machines

Normally, the v9 firmware will be loaded if it's available. However, on OLPC XO-1 machines, the v5 firmware supports extra functionality. This makes the libertas driver attempt to load the v5 firmware first if the machine is an OLPC machine; if that fails (or it's not an OLPC machine), fall back to attempting to load the other firmwares.

---
 drivers/net/wireless/libertas/if_usb.c |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
drivers/net/wireless/libertas/if_usb.c +24 -0
index b5acc39..6a2e70e 100644
@@ -973,6 +973,26 @@ static const struct {
 	{ MODEL_8682, "libertas/usb8682.bin" }
 };
 
+#ifdef CONFIG_OLPC
+
+/* default OLPC firmware to try; index into fw_table above */
+#define OLPC_FW 1
+
+static int try_olpc_fw(struct if_usb_card *cardp)
+{
+	int retval = -ENOENT;
+
+	/* try the OLPC firmware first; fall back to any others */
+	if (machine_is_olpc())
+		retval = request_firmware(&cardp->fw,
+				fw_table[OLPC_FW].fwname, &cardp->udev->dev);
+	return retval;
+}
+
+#else
+static int try_olpc_fw(struct if_usb_card *cardp) { return -ENOENT; }
+#endif /* !CONFIG_OLPC */
+
 static int get_fw(struct if_usb_card *cardp, const char *fwname)
 {
 	int i;
@@ -981,6 +1001,10 @@ static int get_fw(struct if_usb_card *cardp, const char *fwname)
 	if (fwname)
 		return request_firmware(&cardp->fw, fwname, &cardp->udev->dev);
 
+	/* Handle OLPC firmware */
+	if (try_olpc_fw(cardp) == 0)
+		return 0;
+
 	/* Otherwise search for firmware to use */
 	for (i = 0; i < ARRAY_SIZE(fw_table); i++) {
 		if (fw_table[i].model != cardp->model)
Signature · 1 line
1.7.2.5
#1 lore raw

Note: I've not tested this out yet on an XO-1. I'll do that after some feedback regarding the matching linux-firmware pull request. This should address dsd's concern about changing the loading order of the firmware.

Quoted 55 lines · On Sun, 31 Jul 2011 00:03:00 -0700 Andres Salomon <[email protected]> wrote:

Normally, the v9 firmware will be loaded if it's available. However, on OLPC XO-1 machines, the v5 firmware supports extra functionality. This makes the libertas driver attempt to load the v5 firmware first if the machine is an OLPC machine; if that fails (or it's not an OLPC machine), fall back to attempting to load the other firmwares.

---
 drivers/net/wireless/libertas/if_usb.c |   24

++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-)

(quoted diff) +0 -0

b/drivers/net/wireless/libertas/if_usb.c index b5acc39..6a2e70e 100644

drivers/net/wireless/libertas/if_usb.c +20 -0
@@ -973,6 +973,26 @@ static const struct {
 	{ MODEL_8682, "libertas/usb8682.bin" }
 };
 
+#ifdef CONFIG_OLPC
+
+/* default OLPC firmware to try; index into fw_table above */
+#define OLPC_FW 1
+
+static int try_olpc_fw(struct if_usb_card *cardp)
+{
+	int retval = -ENOENT;
+
+	/* try the OLPC firmware first; fall back to any others */
+	if (machine_is_olpc())
+		retval = request_firmware(&cardp->fw,
+				fw_table[OLPC_FW].fwname,
 &cardp->udev->dev);
+	return retval;
+}
+
+#else
+static int try_olpc_fw(struct if_usb_card *cardp) { return -ENOENT; }
+#endif /* !CONFIG_OLPC */
+
 static int get_fw(struct if_usb_card *cardp, const char *fwname)
 {
drivers/net/wireless/libertas/if_usb.c +4 -0
 	int i;
@@ -981,6 +1001,10 @@ static int get_fw(struct if_usb_card *cardp,
 const char *fwname) if (fwname)
 		return request_firmware(&cardp->fw, fwname,
 &cardp->udev->dev); 
+	/* Handle OLPC firmware */
+	if (try_olpc_fw(cardp) == 0)
+		return 0;
+
 	/* Otherwise search for firmware to use */
 	for (i = 0; i < ARRAY_SIZE(fw_table); i++) {
 		if (fw_table[i].model != cardp->model)
#2 lore raw
Quoted 4 lines · Andres Salomon

Note: I've not tested this out yet on an XO-1.  I'll do that after some feedback regarding the matching linux-firmware pull request.  This should address dsd's concern about changing the loading order of the firmware.

That indeed was a concern, but only until Dan Williams and Chris pointed out that OLPC is the only usb8388 user. With that in mind, I am in agreement with them that simply putting usb8388_olpc_v5.bin (or whatever name is chosen) at the top of the firmware loading list is the best option.

Daniel

#3 lore raw
Quoted 11 lines · Daniel Drake
Quoted 4 lines · Andres Salomon

Note: I've not tested this out yet on an XO-1. I'll do that after some feedback regarding the matching linux-firmware pull request. This should address dsd's concern about changing the loading order of the firmware.

That indeed was a concern, but only until Dan Williams and Chris pointed out that OLPC is the only usb8388 user. With that in mind, I am in agreement with them that simply putting usb8388_olpc_v5.bin (or whatever name is chosen) at the top of the firmware loading list is the best option.

Yeah, patches for that would be immediately acked.

Dan

#4 lore raw
Quoted 7 lines · On Mon, 01 Aug 2011 12:17:23 -0500 Dan Williams <[email protected]> wrote:
Quoted 6 lines · Daniel Drake
Quoted 4 lines · Andres Salomon

Note: I've not tested this out yet on an XO-1. I'll do that after some feedback regarding the matching linux-firmware pull request. This should address dsd's concern about changing the loading order of the firmware.

Quoted 8 lines
Quoted 5 lines

That indeed was a concern, but only until Dan Williams and Chris pointed out that OLPC is the only usb8388 user. With that in mind, I am in agreement with them that simply putting usb8388_olpc_v5.bin (or whatever name is chosen) at the top of the firmware loading list is the best option.

Yeah, patches for that would be immediately acked.

What's your opinion on overwriting usb8388_v5.bin with OLPC's version, versus having both a usb8388_v5.bin and a usb8388_olpc_v5.bin?

#5 lore raw
Quoted 16 lines · Andres Salomon
Quoted 13 lines · On Mon, 01 Aug 2011 12:17:23 -0500 Dan Williams <[email protected]> wrote:
Quoted 11 lines · Daniel Drake
Quoted 4 lines · Andres Salomon

Note: I've not tested this out yet on an XO-1. I'll do that after some feedback regarding the matching linux-firmware pull request. This should address dsd's concern about changing the loading order of the firmware.

That indeed was a concern, but only until Dan Williams and Chris pointed out that OLPC is the only usb8388 user. With that in mind, I am in agreement with them that simply putting usb8388_olpc_v5.bin (or whatever name is chosen) at the top of the firmware loading list is the best option.

Quoted 5 lines
Quoted 2 lines

Yeah, patches for that would be immediately acked.

What's your opinion on overwriting usb8388_v5.bin with OLPC's version, versus having both a usb8388_v5.bin and a usb8388_olpc_v5.bin?

I'd slightly prefer to keep them separate, but I don't really care that much. Whatever you'd like to do here is fine.

Dan

#6 lore raw
Quoted 21 lines · On Mon, 01 Aug 2011 16:20:07 -0500 Dan Williams <[email protected]> wrote:
Quoted 20 lines · Andres Salomon
Quoted 16 lines · On Mon, 01 Aug 2011 12:17:23 -0500 Dan Williams <[email protected]> wrote:
Quoted 7 lines · Daniel Drake
Quoted 4 lines · Andres Salomon

Note: I've not tested this out yet on an XO-1. I'll do that after some feedback regarding the matching linux-firmware pull request. This should address dsd's concern about changing the loading order of the firmware.

Quoted 5 lines

That indeed was a concern, but only until Dan Williams and Chris pointed out that OLPC is the only usb8388 user. With that in mind, I am in agreement with them that simply putting usb8388_olpc_v5.bin (or whatever name is chosen) at the top of the firmware loading list is the best option.

Yeah, patches for that would be immediately acked.

Quoted 7 lines
Quoted 3 lines

What's your opinion on overwriting usb8388_v5.bin with OLPC's version, versus having both a usb8388_v5.bin and a usb8388_olpc_v5.bin?

I'd slightly prefer to keep them separate, but I don't really care that much. Whatever you'd like to do here is fine.

Alright, since people seem to prefer keeping it around, I'll redo the pull request (and libertas patch) to do that.