update(port/ehci): use static iso pool for iso urb to reduce alloc time

This commit is contained in:
sakumisu
2024-06-11 21:59:37 +08:00
parent 77af563898
commit bf54bc2ff1
3 changed files with 16 additions and 7 deletions

View File

@@ -34,6 +34,7 @@ struct usbh_iso_frame_packet {
* Structure containing the USB Urb configuration. * Structure containing the USB Urb configuration.
*/ */
struct usbh_urb { struct usbh_urb {
usb_slist_t list;
void *hcpriv; void *hcpriv;
struct usbh_hubport *hport; struct usbh_hubport *hport;
struct usb_endpoint_descriptor *ep; struct usb_endpoint_descriptor *ep;

View File

@@ -25,7 +25,10 @@
#define CONFIG_USB_EHCI_QTD_NUM 3 #define CONFIG_USB_EHCI_QTD_NUM 3
#endif #endif
#ifndef CONFIG_USB_EHCI_ITD_NUM #ifndef CONFIG_USB_EHCI_ITD_NUM
#define CONFIG_USB_EHCI_ITD_NUM 20 #define CONFIG_USB_EHCI_ITD_NUM 5
#endif
#ifndef CONFIG_USB_EHCI_ISO_NUM
#define CONFIG_USB_EHCI_ISO_NUM 4
#endif #endif
extern uint8_t usbh_get_port_speed(struct usbh_bus *bus, const uint8_t port); extern uint8_t usbh_get_port_speed(struct usbh_bus *bus, const uint8_t port);
@@ -52,12 +55,17 @@ struct ehci_itd_hw {
uint8_t mf_unmask; uint8_t mf_unmask;
uint8_t mf_valid; uint8_t mf_valid;
uint32_t pkt_idx[8]; uint32_t pkt_idx[8];
usb_slist_t list;
} __attribute__((aligned(32))); } __attribute__((aligned(32)));
struct ehci_iso_hw
{
struct ehci_itd_hw itd_pool[CONFIG_USB_EHCI_ITD_NUM];
uint32_t itd_num;
};
struct ehci_hcd { struct ehci_hcd {
bool ehci_qh_used[CONFIG_USB_EHCI_QH_NUM]; bool ehci_qh_used[CONFIG_USB_EHCI_QH_NUM];
bool ehci_itd_used[CONFIG_USB_EHCI_ITD_NUM]; bool ehci_iso_used[CONFIG_USB_EHCI_ISO_NUM];
bool ppc; /* Port Power Control */ bool ppc; /* Port Power Control */
bool has_tt; /* if use tt instead of Companion Controller */ bool has_tt; /* if use tt instead of Companion Controller */
uint8_t n_cc; /* Number of Companion Controller */ uint8_t n_cc; /* Number of Companion Controller */
@@ -70,7 +78,7 @@ extern struct ehci_hcd g_ehci_hcd[CONFIG_USBHOST_MAX_BUS];
extern uint32_t g_framelist[CONFIG_USBHOST_MAX_BUS][USB_ALIGN_UP(CONFIG_USB_EHCI_FRAME_LIST_SIZE, 1024)]; extern uint32_t g_framelist[CONFIG_USBHOST_MAX_BUS][USB_ALIGN_UP(CONFIG_USB_EHCI_FRAME_LIST_SIZE, 1024)];
int ehci_iso_urb_init(struct usbh_bus *bus, struct usbh_urb *urb); int ehci_iso_urb_init(struct usbh_bus *bus, struct usbh_urb *urb);
void ehci_remove_itd_urb(struct usbh_bus *bus, struct usbh_urb *urb); void ehci_kill_iso_urb(struct usbh_bus *bus, struct usbh_urb *urb);
void ehci_scan_isochronous_list(struct usbh_bus *bus); void ehci_scan_isochronous_list(struct usbh_bus *bus);
#endif #endif

View File

@@ -1245,7 +1245,7 @@ int usbh_kill_urb(struct usbh_urb *urb)
} }
} else { } else {
#ifdef CONFIG_USB_EHCI_ISO #ifdef CONFIG_USB_EHCI_ISO
ehci_remove_itd_urb(bus, urb); ehci_kill_iso_urb(bus, urb);
EHCI_HCOR->usbcmd |= (EHCI_USBCMD_PSEN | EHCI_USBCMD_ASEN); EHCI_HCOR->usbcmd |= (EHCI_USBCMD_PSEN | EHCI_USBCMD_ASEN);
usb_osal_leave_critical_section(flags); usb_osal_leave_critical_section(flags);
return 0; return 0;
@@ -1346,8 +1346,8 @@ void USBH_IRQHandler(uint8_t busid)
for (uint8_t index = 0; index < CONFIG_USB_EHCI_QH_NUM; index++) { for (uint8_t index = 0; index < CONFIG_USB_EHCI_QH_NUM; index++) {
g_ehci_hcd[bus->hcd.hcd_id].ehci_qh_used[index] = false; g_ehci_hcd[bus->hcd.hcd_id].ehci_qh_used[index] = false;
} }
for (uint8_t index = 0; index < CONFIG_USB_EHCI_ITD_NUM; index++) { for (uint8_t index = 0; index < CONFIG_USB_EHCI_ISO_NUM; index++) {
g_ehci_hcd[bus->hcd.hcd_id].ehci_itd_used[index] = false; g_ehci_hcd[bus->hcd.hcd_id].ehci_iso_used[index] = false;
} }
} }