summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2024-06-06 21:48:56 +0800
committersakumisu <[email protected]>2024-06-06 21:48:56 +0800
commitf197716f52c7688f31d3b6a7eddc64dc268e0c9a (patch)
tree5643eed025adaee7077328afcab5244d9fb8f362
parent62ed025ddc579f967e012054aa8b59776edc10b4 (diff)
update(port/dwc2/usb_hc_dwc2): add check for fifo with ep mps
-rw-r--r--port/dwc2/usb_hc_dwc2.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/port/dwc2/usb_hc_dwc2.c b/port/dwc2/usb_hc_dwc2.c
index 3dcf5fcc..907ae8b1 100644
--- a/port/dwc2/usb_hc_dwc2.c
+++ b/port/dwc2/usb_hc_dwc2.c
@@ -21,9 +21,9 @@
#define CONFIG_USB_DWC2_PTX_FIFO_SIZE (1024 / 4)
#endif
-/*
- * (largest USB packet used / 4) + 1 for status information + 1 transfer complete +
- * 1 location each for Bulk/Control endpoint for handling NAK/NYET scenario
+/*
+ * (largest USB packet used / 4) + 1 for status information + 1 transfer complete +
+ * 1 location each for Bulk/Control endpoint for handling NAK/NYET scenario
*/
#ifndef CONFIG_USB_DWC2_RX_FIFO_SIZE
#define CONFIG_USB_DWC2_RX_FIFO_SIZE ((1012 - CONFIG_USB_DWC2_NPTX_FIFO_SIZE - CONFIG_USB_DWC2_PTX_FIFO_SIZE) / 4)
@@ -744,6 +744,25 @@ int usbh_submit_urb(struct usbh_urb *urb)
return -USB_ERR_NOMEM;
}
+ if (urb->ep->bEndpointAddress & 0x80) {
+ /* Check if pipe rx fifo is overflow */
+ if (USB_GET_MAXPACKETSIZE(urb->ep->wMaxPacketSize) > (CONFIG_USB_DWC2_RX_FIFO_SIZE * 4)) {
+ return -USB_ERR_RANGE;
+ }
+ } else {
+ /* Check if intr and iso pipe tx fifo is overflow */
+ if (((USB_GET_MAXPACKETSIZE(urb->ep->wMaxPacketSize) == USB_ENDPOINT_TYPE_ISOCHRONOUS) ||
+ (USB_GET_MAXPACKETSIZE(urb->ep->wMaxPacketSize) == USB_ENDPOINT_TYPE_INTERRUPT)) &&
+ USB_GET_MAXPACKETSIZE(urb->ep->wMaxPacketSize) > (CONFIG_USB_DWC2_PTX_FIFO_SIZE * 4)) {
+ return -USB_ERR_RANGE;
+ } else {
+ /* Check if control and bulk pipe tx fifo is overflow */
+ if (USB_GET_MAXPACKETSIZE(urb->ep->wMaxPacketSize) > (CONFIG_USB_DWC2_NPTX_FIFO_SIZE * 4)) {
+ return -USB_ERR_RANGE;
+ }
+ }
+ }
+
chan = &g_dwc2_hcd[bus->hcd.hcd_id].chan_pool[chidx];
chan->chidx = chidx;
chan->urb = urb;