Ver Fonte

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

sakumisu há 1 ano atrás
pai
commit
bf54bc2ff1
3 ficheiros alterados com 16 adições e 7 exclusões
  1. 1 0
      common/usb_hc.h
  2. 12 4
      port/ehci/usb_ehci_priv.h
  3. 3 3
      port/ehci/usb_hc_ehci.c

+ 1 - 0
common/usb_hc.h

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

+ 12 - 4
port/ehci/usb_ehci_priv.h

@@ -25,7 +25,10 @@
 #define CONFIG_USB_EHCI_QTD_NUM  3
 #endif
 #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
 
 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_valid;
     uint32_t pkt_idx[8];
-    usb_slist_t list;
 } __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 {
     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 has_tt;   /* if use tt instead 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)];
 
 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);
 
 #endif

+ 3 - 3
port/ehci/usb_hc_ehci.c

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