]> git.hungrycats.org Git - linux/commitdiff
USB: work around for EHCI with quirky periodic schedules
authorOliver Neukum <oliver@neukum.org>
Fri, 27 Nov 2009 14:17:59 +0000 (15:17 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 8 Dec 2009 18:22:16 +0000 (10:22 -0800)
commit ee4ecb8ac63a5792bec448037d4b82ec4144f94b upstream.

a quirky chipset needs periodic schedules to run for a minimum
time before they can be disabled again. This enforces the requirement
with a time stamp and a calculated delay

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/host/ehci-hcd.c
drivers/usb/host/ehci-pci.c
drivers/usb/host/ehci-sched.c
drivers/usb/host/ehci.h

index 11c627ce60224754978bf495e40cd94496c3b7c7..7e4b381716a700423f925b8a4a1207b98170bc0f 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/timer.h>
+#include <linux/ktime.h>
 #include <linux/list.h>
 #include <linux/interrupt.h>
 #include <linux/reboot.h>
@@ -655,6 +656,7 @@ static int ehci_run (struct usb_hcd *hcd)
        ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */
        msleep(5);
        up_write(&ehci_cf_port_reset_rwsem);
+       ehci->last_periodic_enable = ktime_get_real();
 
        temp = HC_VERSION(ehci_readl(ehci, &ehci->caps->hc_capbase));
        ehci_info (ehci,
index c2f1b7df918cd52ddd62385e3f02f5696d7f6f06..c757a706843c46e555bc745f82ec68bec63bbee0 100644 (file)
@@ -72,6 +72,12 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
        int                     retval;
 
        switch (pdev->vendor) {
+       case PCI_VENDOR_ID_INTEL:
+               if (pdev->device == 0x27cc) {
+                       ehci->broken_periodic = 1;
+                       ehci_info(ehci, "using broken periodic workaround\n");
+               }
+               break;
        case PCI_VENDOR_ID_TOSHIBA_2:
                /* celleb's companion chip */
                if (pdev->device == 0x01b5) {
index edd61ee90323ce99a5b8fe9eba5fec0c18b2fd23..c340f1f4b8813f89f10edf504e50ac1e94c46ed1 100644 (file)
@@ -456,6 +456,8 @@ static int enable_periodic (struct ehci_hcd *ehci)
        /* make sure ehci_work scans these */
        ehci->next_uframe = ehci_readl(ehci, &ehci->regs->frame_index)
                % (ehci->periodic_size << 3);
+       if (unlikely(ehci->broken_periodic))
+               ehci->last_periodic_enable = ktime_get_real();
        return 0;
 }
 
@@ -467,6 +469,16 @@ static int disable_periodic (struct ehci_hcd *ehci)
        if (--ehci->periodic_sched)
                return 0;
 
+       if (unlikely(ehci->broken_periodic)) {
+               /* delay experimentally determined */
+               ktime_t safe = ktime_add_us(ehci->last_periodic_enable, 1000);
+               ktime_t now = ktime_get_real();
+               s64 delay = ktime_us_delta(safe, now);
+
+               if (unlikely(delay > 0))
+                       udelay(delay);
+       }
+
        /* did setting PSE not take effect yet?
         * takes effect only at frame boundaries...
         */
index 2bfff30f4704f7521678239df30c07323e0d3e59..aab3cbcc9afb8138995ac697f8f02cff3b07e904 100644 (file)
@@ -118,6 +118,7 @@ struct ehci_hcd {                   /* one per controller */
        unsigned                stamp;
        unsigned                random_frame;
        unsigned long           next_statechange;
+       ktime_t                 last_periodic_enable;
        u32                     command;
 
        /* SILICON QUIRKS */
@@ -126,6 +127,7 @@ struct ehci_hcd {                   /* one per controller */
        unsigned                big_endian_mmio:1;
        unsigned                big_endian_desc:1;
        unsigned                has_amcc_usb23:1;
+       unsigned                broken_periodic:1;
 
        /* required for usb32 quirk */
        #define OHCI_CTRL_HCFS          (3 << 6)