fix(port): enter section before alloc pipe
This commit is contained in:
@@ -322,15 +322,15 @@ static int dwc2_chan_alloc(struct usbh_bus *bus)
|
|||||||
size_t flags;
|
size_t flags;
|
||||||
int chidx;
|
int chidx;
|
||||||
|
|
||||||
|
flags = usb_osal_enter_critical_section();
|
||||||
for (chidx = 0; chidx < CONFIG_USBHOST_PIPE_NUM; chidx++) {
|
for (chidx = 0; chidx < CONFIG_USBHOST_PIPE_NUM; chidx++) {
|
||||||
if (!g_dwc2_hcd[bus->hcd.hcd_id].chan_pool[chidx].inuse) {
|
if (!g_dwc2_hcd[bus->hcd.hcd_id].chan_pool[chidx].inuse) {
|
||||||
flags = usb_osal_enter_critical_section();
|
|
||||||
g_dwc2_hcd[bus->hcd.hcd_id].chan_pool[chidx].inuse = true;
|
g_dwc2_hcd[bus->hcd.hcd_id].chan_pool[chidx].inuse = true;
|
||||||
usb_osal_leave_critical_section(flags);
|
usb_osal_leave_critical_section(flags);
|
||||||
return chidx;
|
return chidx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
usb_osal_leave_critical_section(flags);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -736,11 +736,8 @@ int usbh_submit_urb(struct usbh_urb *urb)
|
|||||||
return -USB_ERR_BUSY;
|
return -USB_ERR_BUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
flags = usb_osal_enter_critical_section();
|
|
||||||
|
|
||||||
chidx = dwc2_chan_alloc(bus);
|
chidx = dwc2_chan_alloc(bus);
|
||||||
if (chidx == -1) {
|
if (chidx == -1) {
|
||||||
usb_osal_leave_critical_section(flags);
|
|
||||||
return -USB_ERR_NOMEM;
|
return -USB_ERR_NOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -763,6 +760,8 @@ int usbh_submit_urb(struct usbh_urb *urb)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flags = usb_osal_enter_critical_section();
|
||||||
|
|
||||||
chan = &g_dwc2_hcd[bus->hcd.hcd_id].chan_pool[chidx];
|
chan = &g_dwc2_hcd[bus->hcd.hcd_id].chan_pool[chidx];
|
||||||
chan->chidx = chidx;
|
chan->chidx = chidx;
|
||||||
chan->urb = urb;
|
chan->urb = urb;
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ static struct ehci_qh_hw *ehci_qh_alloc(struct usbh_bus *bus)
|
|||||||
struct ehci_qtd_hw *qtd;
|
struct ehci_qtd_hw *qtd;
|
||||||
size_t flags;
|
size_t flags;
|
||||||
|
|
||||||
|
flags = usb_osal_enter_critical_section();
|
||||||
for (uint32_t i = 0; i < CONFIG_USB_EHCI_QH_NUM; i++) {
|
for (uint32_t i = 0; i < CONFIG_USB_EHCI_QH_NUM; i++) {
|
||||||
if (!g_ehci_hcd[bus->hcd.hcd_id].ehci_qh_used[i]) {
|
if (!g_ehci_hcd[bus->hcd.hcd_id].ehci_qh_used[i]) {
|
||||||
flags = usb_osal_enter_critical_section();
|
|
||||||
g_ehci_hcd[bus->hcd.hcd_id].ehci_qh_used[i] = true;
|
g_ehci_hcd[bus->hcd.hcd_id].ehci_qh_used[i] = true;
|
||||||
usb_osal_leave_critical_section(flags);
|
usb_osal_leave_critical_section(flags);
|
||||||
|
|
||||||
@@ -56,6 +56,7 @@ static struct ehci_qh_hw *ehci_qh_alloc(struct usbh_bus *bus)
|
|||||||
return qh;
|
return qh;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
usb_osal_leave_critical_section(flags);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -684,19 +684,18 @@ int usbh_submit_urb(struct usbh_urb *urb)
|
|||||||
|
|
||||||
bus = urb->hport->bus;
|
bus = urb->hport->bus;
|
||||||
|
|
||||||
flags = usb_osal_enter_critical_section();
|
|
||||||
|
|
||||||
if (USB_GET_ENDPOINT_TYPE(urb->ep->bmAttributes) == USB_ENDPOINT_TYPE_CONTROL) {
|
if (USB_GET_ENDPOINT_TYPE(urb->ep->bmAttributes) == USB_ENDPOINT_TYPE_CONTROL) {
|
||||||
chidx = 0;
|
chidx = 0;
|
||||||
} else {
|
} else {
|
||||||
chidx = (urb->ep->bEndpointAddress & 0x0f);
|
chidx = (urb->ep->bEndpointAddress & 0x0f);
|
||||||
|
|
||||||
if (chidx > (CONFIG_USBHOST_PIPE_NUM - 1)) {
|
if (chidx > (CONFIG_USBHOST_PIPE_NUM - 1)) {
|
||||||
usb_osal_leave_critical_section(flags);
|
|
||||||
return -USB_ERR_RANGE;
|
return -USB_ERR_RANGE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flags = usb_osal_enter_critical_section();
|
||||||
|
|
||||||
pipe = &g_musb_hcd[bus->hcd.hcd_id].pipe_pool[chidx];
|
pipe = &g_musb_hcd[bus->hcd.hcd_id].pipe_pool[chidx];
|
||||||
pipe->chidx = chidx;
|
pipe->chidx = chidx;
|
||||||
pipe->urb = urb;
|
pipe->urb = urb;
|
||||||
@@ -705,8 +704,6 @@ int usbh_submit_urb(struct usbh_urb *urb)
|
|||||||
urb->errorcode = -USB_ERR_BUSY;
|
urb->errorcode = -USB_ERR_BUSY;
|
||||||
urb->actual_length = 0;
|
urb->actual_length = 0;
|
||||||
|
|
||||||
usb_osal_sem_reset(pipe->waitsem);
|
|
||||||
|
|
||||||
switch (USB_GET_ENDPOINT_TYPE(urb->ep->bmAttributes)) {
|
switch (USB_GET_ENDPOINT_TYPE(urb->ep->bmAttributes)) {
|
||||||
case USB_ENDPOINT_TYPE_CONTROL:
|
case USB_ENDPOINT_TYPE_CONTROL:
|
||||||
pipe->ep0_state = USB_EP0_STATE_SETUP;
|
pipe->ep0_state = USB_EP0_STATE_SETUP;
|
||||||
|
|||||||
Reference in New Issue
Block a user