yangsong8-a1 opened a new pull request, #21995:
URL: https://github.com/apache/nuttx/pull/21995
## Summary
Four changes to the USB mass storage class driver:
- Fix a WRITE deadlock: the bulk-OUT request length was set to
CONFIG_USBMSC_BULKOUTREQLEN instead of one maxpacket, but the
controller requires req->len <= maxpacket for bulk-OUT completion
signaling. Also use sq_remfirst under the spinlock instead of
sq_peek, return requests to the free list on EP_SUBMIT failure, and
widen nsectbytes/nreqbytes/iosize to uint32_t for >64 KiB I/O
buffers.
- Fill each bulk-IN request up to its full allocated buffer
(bulkinreqlen, recorded at bind time from the same expression used
to allocate it) instead of one maxpacket, so the controller DMA
splits one transfer into many packets. Floored at one maxpacket so
no sub-maxpacket packet is emitted mid-transfer.
- Re-queue each bulk-OUT request at up to its full allocated buffer
during the CMDWRITE data phase. The first NRDREQS requests are
already queued at one maxpacket when the command is accepted;
priv->residue carries the count of bytes still to request, so the
total requested never exceeds the host's data-out length and an
enlarged request can never stall waiting for bytes the host will
not send. The CSW residue is rebuilt from xfrlen*sectorsize when
the data phase ends.
- Fix the pre-existing nxstyle errors (switch/case indentation, brace
and comment alignment, long lines) in usbmsc.c and usbmsc_scsi.c.
## Impact
drivers/usbdev/usbmsc.c, usbmsc.h, usbmsc_scsi.c and drivers/usbdev/Kconfig.
USBMSC_BULKINREQLEN and USBMSC_BULKOUTREQLEN gain range limits (512..65536
with USBDEV_DUALSPEED, 64..65536 without). The 12 in-tree defconfigs that
set them all use 256 without USBDEV_DUALSPEED, so they stay valid. No API
change.
## Testing
Ubuntu 22.04, arm-none-eabi-gcc 10.3. Builds with no new warnings:
- pimoroni-pico-2-plus:usbmsc (with and without
CONFIG_USBMSC_BULKOUTREQLEN=2048)
sim:usbdev with SIM_USB_RAW_GADGET, a composite gadget with one 8 MiB
ramdisk LUN and dummy_hcd on the host: the device enumerates, binds to
usb-storage, and INQUIRY and READ CAPACITY(10) return the expected
16384 x 512 B geometry.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]