diff options
author | hselasky <hselasky@FreeBSD.org> | 2013-11-06 15:32:37 +0000 |
---|---|---|
committer | hselasky <hselasky@FreeBSD.org> | 2013-11-06 15:32:37 +0000 |
commit | 32e7b0e2ad4e02afc86137b4c1bbe61562dbdf62 (patch) | |
tree | b6793090b00ff899f4d3b5e60aedf47eb094e510 | |
parent | 29f9888203a389ec7d96382173995c9c7cfeb42c (diff) | |
download | FreeBSD-src-32e7b0e2ad4e02afc86137b4c1bbe61562dbdf62.zip FreeBSD-src-32e7b0e2ad4e02afc86137b4c1bbe61562dbdf62.tar.gz |
Implement a working write region function to speed up loading of the
firmware. You can test this change by switching the "#if 1" statement
right above in the patched code to "#if 0" !
MFC after: 1 week
-rw-r--r-- | sys/dev/usb/wlan/if_run.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/sys/dev/usb/wlan/if_run.c b/sys/dev/usb/wlan/if_run.c index aa0db4c..1118718 100644 --- a/sys/dev/usb/wlan/if_run.c +++ b/sys/dev/usb/wlan/if_run.c @@ -1170,13 +1170,32 @@ run_write_region_1(struct run_softc *sc, uint16_t reg, const uint8_t *buf, return (error); #else usb_device_request_t req; + int error = 0; - req.bmRequestType = UT_WRITE_VENDOR_DEVICE; - req.bRequest = RT2870_WRITE_REGION_1; - USETW(req.wValue, 0); - USETW(req.wIndex, reg); - USETW(req.wLength, len); - return (run_do_request(sc, &req, buf)); + /* + * NOTE: It appears the WRITE_REGION_1 command cannot be + * passed a huge amount of data, which will crash the + * firmware. Limit amount of data passed to 64-bytes at a + * time: + */ + while (len > 0) { + int delta = 64; + if (delta > len) + delta = len; + + req.bmRequestType = UT_WRITE_VENDOR_DEVICE; + req.bRequest = RT2870_WRITE_REGION_1; + USETW(req.wValue, 0); + USETW(req.wIndex, reg); + USETW(req.wLength, delta); + error = run_do_request(sc, &req, __DECONST(uint8_t *, buf)); + if (error != 0) + break; + reg += delta; + buf += delta; + len -= delta; + } + return (error); #endif } |