[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cdi-devel] [PATCH] usb: A bit faster



From: Max Reitz <max@xxxxxxxxxx>

* Made faster (OHCI is now limited to 48 packets at a time,
  so the MSC driver may send or receive more than 4 sectors
  consecutively)

Signed-off-by: Max Reitz <max@xxxxxxxxxx>
---
 usb/msd.c  |    2 +-
 usb/ohci.c |   22 +++++++++++++++++++---
 usb/uhci.c |    4 ++--
 3 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/usb/msd.c b/usb/msd.c
index 34e6e04..b3f303c 100644
--- a/usb/msd.c
+++ b/usb/msd.c
@@ -376,7 +376,7 @@ static inline int tsl(volatile int* variable)
     return rval;
 }
 
-#define MAX_ACCESS_BLOCKS 4
+#define MAX_ACCESS_BLOCKS 32
 
 static uint32_t msd_read(struct usb_device* usbdev, uint32_t lba,
     uint16_t sectors, void* buffer,
diff --git a/usb/ohci.c b/usb/ohci.c
index d95f330..cc88169 100644
--- a/usb/ohci.c
+++ b/usb/ohci.c
@@ -53,7 +53,8 @@ static void ohci_kill(struct cdi_driver* cdi_hcd);
 static void ohci_deinit(struct cdi_device* cdi_hci);
 void ohci_init(struct cdi_device* cdi_hci);
 static void ohci_handler(struct cdi_device* dev);
-static int ohci_do_packets(struct usb_packet* packet, int num_packets);
+static int ohci_do_all_packets(struct usb_packet* packet, int num_packets);
+static int ohci_do_some_packets(struct usb_packet* packets, int num_packets);
 static cdi_list_t get_devices(struct hci* gen_hci);
 static void activate_device(struct usb_device* device);
 static void ohci_reset_device(struct usb_device* device);
@@ -229,7 +230,7 @@ void ohci_init(struct cdi_device* cdi_hci)
 
     gen_hci->find_devices = &get_devices;
     gen_hci->activate_device = &activate_device;
-    gen_hci->do_packets = &ohci_do_packets;
+    gen_hci->do_packets = &ohci_do_all_packets;
     gen_hci->add_pipe = &ohci_establish_pipe;
 
     enumerate_hci(gen_hci);
@@ -243,7 +244,22 @@ static inline int tsl(volatile int* variable)
     return rval;
 }
 
-static int ohci_do_packets(struct usb_packet* packets, int num_packets)
+static int ohci_do_all_packets(struct usb_packet* packets, int num_packets)
+{
+    int error = USB_NO_ERROR;
+
+    //Mehr als 48 sind wohl nicht ratsam (vor allem wegen des Mempools)
+    while ((num_packets > 0) && (error == USB_NO_ERROR)) {
+        error = ohci_do_some_packets(packets,
+            (num_packets > 48) ? 48 : num_packets);
+        packets = &packets[48];
+        num_packets -= (num_packets > 48) ? 48 : num_packets;
+    }
+
+    return error;
+}
+
+static int ohci_do_some_packets(struct usb_packet* packets, int num_packets)
 {
     struct ohci_ed_desc* edsc;
     struct ohci_td_desc* tdsc, * otdsc;
diff --git a/usb/uhci.c b/usb/uhci.c
index bad63bb..bd9169f 100644
--- a/usb/uhci.c
+++ b/usb/uhci.c
@@ -341,9 +341,9 @@ static int uhci_do_packets(struct usb_packet* packet, int num_packets)
     int i, cond = 0;
 
     //TODO
-    for (i = 0; i < num_packets; i++) {
+    for (i = 0; (i < num_packets) && !cond; i++) {
         packet[i].condition = uhci_do_packet(&packet[i]);
-        cond |= packet[i].condition;
+        cond = packet[i].condition;
     }
 
     return cond;
-- 
1.6.3.3