Merge tag 'usb-for-v4.1-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi...
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Apr 2015 11:45:27 +0000 (13:45 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Apr 2015 11:45:27 +0000 (13:45 +0200)
Felipe writes:

usb: generic resume timeout for v4.1

This part 2 pull request contains only the patches
which make sure everybody on linux uses the same
resume timeout value.

Signed-off-by: Felipe Balbi <balbi@ti.com>
12 files changed:
1  2 
drivers/usb/dwc2/hcd.c
drivers/usb/host/ehci-hub.c
drivers/usb/host/fotg210-hcd.c
drivers/usb/host/fusbh200-hcd.c
drivers/usb/host/isp116x-hcd.c
drivers/usb/host/oxu210hp-hcd.c
drivers/usb/host/r8a66597-hcd.c
drivers/usb/host/sl811-hcd.c
drivers/usb/host/uhci-hub.c
drivers/usb/host/xhci-ring.c
drivers/usb/isp1760/isp1760-hcd.c
drivers/usb/musb/musb_virthub.c

diff --combined drivers/usb/dwc2/hcd.c
@@@ -1529,7 -1529,7 +1529,7 @@@ static int dwc2_hcd_hub_control(struct 
                        dev_dbg(hsotg->dev,
                                "ClearPortFeature USB_PORT_FEAT_SUSPEND\n");
                        writel(0, hsotg->regs + PCGCTL);
-                       usleep_range(20000, 40000);
+                       msleep(USB_RESUME_TIMEOUT);
  
                        hprt0 = dwc2_read_hprt0(hsotg);
                        hprt0 |= HPRT0_RES;
                dev_dbg(hsotg->dev, "GetHubDescriptor\n");
                hub_desc = (struct usb_hub_descriptor *)buf;
                hub_desc->bDescLength = 9;
 -              hub_desc->bDescriptorType = 0x29;
 +              hub_desc->bDescriptorType = USB_DT_HUB;
                hub_desc->bNbrPorts = 1;
                hub_desc->wHubCharacteristics =
                        cpu_to_le16(HUB_CHAR_COMMON_LPSM |
@@@ -471,10 -471,13 +471,13 @@@ static int ehci_bus_resume (struct usb_
                ehci_writel(ehci, temp, &ehci->regs->port_status [i]);
        }
  
-       /* msleep for 20ms only if code is trying to resume port */
+       /*
+        * msleep for USB_RESUME_TIMEOUT ms only if code is trying to resume
+        * port
+        */
        if (resume_needed) {
                spin_unlock_irq(&ehci->lock);
-               msleep(20);
+               msleep(USB_RESUME_TIMEOUT);
                spin_lock_irq(&ehci->lock);
                if (ehci->shutdown)
                        goto shutdown;
@@@ -688,7 -691,7 +691,7 @@@ ehci_hub_descriptor 
        int             ports = HCS_N_PORTS (ehci->hcs_params);
        u16             temp;
  
 -      desc->bDescriptorType = 0x29;
 +      desc->bDescriptorType = USB_DT_HUB;
        desc->bPwrOn2PwrGood = 10;      /* ehci 1.0, 2.3.9 says 20ms max */
        desc->bHubContrCurrent = 0;
  
@@@ -942,7 -945,7 +945,7 @@@ int ehci_hub_control
                        temp &= ~PORT_WAKE_BITS;
                        ehci_writel(ehci, temp | PORT_RESUME, status_reg);
                        ehci->reset_done[wIndex] = jiffies
-                                       + msecs_to_jiffies(20);
+                                       + msecs_to_jiffies(USB_RESUME_TIMEOUT);
                        set_bit(wIndex, &ehci->resuming_ports);
                        usb_hcd_start_port_resume(&hcd->self, wIndex);
                        break;
@@@ -1509,7 -1509,7 +1509,7 @@@ fotg210_hub_descriptor
        int             ports = HCS_N_PORTS(fotg210->hcs_params);
        u16             temp;
  
 -      desc->bDescriptorType = 0x29;
 +      desc->bDescriptorType = USB_DT_HUB;
        desc->bPwrOn2PwrGood = 10;      /* fotg210 1.0, 2.3.9 says 20ms max */
        desc->bHubContrCurrent = 0;
  
@@@ -1595,7 -1595,7 +1595,7 @@@ static int fotg210_hub_control
                        /* resume signaling for 20 msec */
                        fotg210_writel(fotg210, temp | PORT_RESUME, status_reg);
                        fotg210->reset_done[wIndex] = jiffies
-                                       + msecs_to_jiffies(20);
+                                       + msecs_to_jiffies(USB_RESUME_TIMEOUT);
                        break;
                case USB_PORT_FEAT_C_SUSPEND:
                        clear_bit(wIndex, &fotg210->port_c_suspend);
@@@ -1467,7 -1467,7 +1467,7 @@@ fusbh200_hub_descriptor 
        int             ports = HCS_N_PORTS (fusbh200->hcs_params);
        u16             temp;
  
 -      desc->bDescriptorType = 0x29;
 +      desc->bDescriptorType = USB_DT_HUB;
        desc->bPwrOn2PwrGood = 10;      /* fusbh200 1.0, 2.3.9 says 20ms max */
        desc->bHubContrCurrent = 0;
  
@@@ -1550,10 -1550,9 +1550,9 @@@ static int fusbh200_hub_control 
                        if ((temp & PORT_PE) == 0)
                                goto error;
  
-                       /* resume signaling for 20 msec */
                        fusbh200_writel(fusbh200, temp | PORT_RESUME, status_reg);
                        fusbh200->reset_done[wIndex] = jiffies
-                                       + msecs_to_jiffies(20);
+                                       + msecs_to_jiffies(USB_RESUME_TIMEOUT);
                        break;
                case USB_PORT_FEAT_C_SUSPEND:
                        clear_bit(wIndex, &fusbh200->port_c_suspend);
@@@ -943,7 -943,7 +943,7 @@@ static void isp116x_hub_descriptor(stru
  {
        u32 reg = isp116x->rhdesca;
  
 -      desc->bDescriptorType = 0x29;
 +      desc->bDescriptorType = USB_DT_HUB;
        desc->bDescLength = 9;
        desc->bHubContrCurrent = 0;
        desc->bNbrPorts = (u8) (reg & 0x3);
@@@ -1490,7 -1490,7 +1490,7 @@@ static int isp116x_bus_resume(struct us
        spin_unlock_irq(&isp116x->lock);
  
        hcd->state = HC_STATE_RESUMING;
-       msleep(20);
+       msleep(USB_RESUME_TIMEOUT);
  
        /* Go operational */
        spin_lock_irq(&isp116x->lock);
@@@ -445,7 -445,7 +445,7 @@@ static void ehci_hub_descriptor(struct 
        int ports = HCS_N_PORTS(oxu->hcs_params);
        u16 temp;
  
 -      desc->bDescriptorType = 0x29;
 +      desc->bDescriptorType = USB_DT_HUB;
        desc->bPwrOn2PwrGood = 10;      /* oxu 1.0, 2.3.9 says 20ms max */
        desc->bHubContrCurrent = 0;
  
@@@ -2500,11 -2500,12 +2500,12 @@@ static irqreturn_t oxu210_hcd_irq(struc
                                        || oxu->reset_done[i] != 0)
                                continue;
  
-                       /* start 20 msec resume signaling from this port,
-                        * and make hub_wq collect PORT_STAT_C_SUSPEND to
+                       /* start USB_RESUME_TIMEOUT resume signaling from this
+                        * port, and make hub_wq collect PORT_STAT_C_SUSPEND to
                         * stop that signaling.
                         */
-                       oxu->reset_done[i] = jiffies + msecs_to_jiffies(20);
+                       oxu->reset_done[i] = jiffies +
+                               msecs_to_jiffies(USB_RESUME_TIMEOUT);
                        oxu_dbg(oxu, "port %d remote wakeup\n", i + 1);
                        mod_timer(&hcd->rh_timer, oxu->reset_done[i]);
                }
@@@ -2136,7 -2136,7 +2136,7 @@@ static int r8a66597_hub_status_data(str
  static void r8a66597_hub_descriptor(struct r8a66597 *r8a66597,
                                    struct usb_hub_descriptor *desc)
  {
 -      desc->bDescriptorType = 0x29;
 +      desc->bDescriptorType = USB_DT_HUB;
        desc->bHubContrCurrent = 0;
        desc->bNbrPorts = r8a66597->max_root_hub;
        desc->bDescLength = 9;
@@@ -2301,7 -2301,7 +2301,7 @@@ static int r8a66597_bus_resume(struct u
                rh->port &= ~USB_PORT_STAT_SUSPEND;
                rh->port |= USB_PORT_STAT_C_SUSPEND << 16;
                r8a66597_mdfy(r8a66597, RESUME, RESUME | UACT, dvstctr_reg);
-               msleep(50);
+               msleep(USB_RESUME_TIMEOUT);
                r8a66597_mdfy(r8a66597, UACT, RESUME | UACT, dvstctr_reg);
        }
  
@@@ -1091,7 -1091,7 +1091,7 @@@ sl811h_hub_descriptor 
  ) {
        u16             temp = 0;
  
 -      desc->bDescriptorType = 0x29;
 +      desc->bDescriptorType = USB_DT_HUB;
        desc->bHubContrCurrent = 0;
  
        desc->bNbrPorts = 1;
@@@ -1259,7 -1259,7 +1259,7 @@@ sl811h_hub_control
                        sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
  
                        mod_timer(&sl811->timer, jiffies
-                                       + msecs_to_jiffies(20));
+                                       + msecs_to_jiffies(USB_RESUME_TIMEOUT));
                        break;
                case USB_PORT_FEAT_POWER:
                        port_power(sl811, 0);
@@@ -1809,6 -1809,7 +1809,6 @@@ struct platform_driver sl811h_driver = 
        .resume =       sl811h_resume,
        .driver = {
                .name = (char *) hcd_name,
 -              .owner = THIS_MODULE,
        },
  };
  EXPORT_SYMBOL(sl811h_driver);
@@@ -15,7 -15,7 +15,7 @@@
  static const __u8 root_hub_hub_des[] =
  {
        0x09,                   /*  __u8  bLength; */
 -      0x29,                   /*  __u8  bDescriptorType; Hub-descriptor */
 +      USB_DT_HUB,             /*  __u8  bDescriptorType; Hub-descriptor */
        0x02,                   /*  __u8  bNbrPorts; */
        HUB_CHAR_NO_LPSM |      /* __u16  wHubCharacteristics; */
                HUB_CHAR_INDV_PORT_OCPM, /* (per-port OC, no power switching) */
@@@ -166,7 -166,7 +166,7 @@@ static void uhci_check_ports(struct uhc
                                /* Port received a wakeup request */
                                set_bit(port, &uhci->resuming_ports);
                                uhci->ports_timeout = jiffies +
-                                               msecs_to_jiffies(25);
+                                       msecs_to_jiffies(USB_RESUME_TIMEOUT);
                                usb_hcd_start_port_resume(
                                                &uhci_to_hcd(uhci)->self, port);
  
@@@ -338,7 -338,8 +338,8 @@@ static int uhci_hub_control(struct usb_
                        uhci_finish_suspend(uhci, port, port_addr);
  
                        /* USB v2.0 7.1.7.5 */
-                       uhci->ports_timeout = jiffies + msecs_to_jiffies(50);
+                       uhci->ports_timeout = jiffies +
+                               msecs_to_jiffies(USB_RESUME_TIMEOUT);
                        break;
                case USB_PORT_FEAT_POWER:
                        /* UHCI has no power switching */
@@@ -238,7 -238,7 +238,7 @@@ static void inc_enq(struct xhci_hcd *xh
  
                        /* Toggle the cycle bit after the last ring segment. */
                        if (last_trb_on_last_seg(xhci, ring, ring->enq_seg, next)) {
 -                              ring->cycle_state = (ring->cycle_state ? 0 : 1);
 +                              ring->cycle_state ^= 1;
                        }
                }
                ring->enq_seg = ring->enq_seg->next;
@@@ -1574,7 -1574,7 +1574,7 @@@ static void handle_port_status(struct x
                } else {
                        xhci_dbg(xhci, "resume HS port %d\n", port_id);
                        bus_state->resume_done[faked_port_index] = jiffies +
-                               msecs_to_jiffies(20);
+                               msecs_to_jiffies(USB_RESUME_TIMEOUT);
                        set_bit(faked_port_index, &bus_state->resuming_ports);
                        mod_timer(&hcd->rh_timer,
                                  bus_state->resume_done[faked_port_index]);
@@@ -1729,7 -1729,7 +1729,7 @@@ static void xhci_cleanup_halted_endpoin
        if (!command)
                return;
  
 -      ep->ep_state |= EP_HALTED | EP_RECENTLY_HALTED;
 +      ep->ep_state |= EP_HALTED;
        ep->stopped_stream = stream_id;
  
        xhci_queue_reset_ep(xhci, command, slot_id, ep_index);
@@@ -2809,7 -2809,7 +2809,7 @@@ static int prepare_ring(struct xhci_hc
  
                        /* Toggle the cycle bit after the last ring segment. */
                        if (last_trb_on_last_seg(xhci, ring, ring->enq_seg, next)) {
 -                              ring->cycle_state = (ring->cycle_state ? 0 : 1);
 +                              ring->cycle_state ^= 1;
                        }
                        ring->enq_seg = ring->enq_seg->next;
                        ring->enqueue = ring->enq_seg->trbs;
@@@ -1758,7 -1758,7 +1758,7 @@@ static void isp1760_hub_descriptor(stru
        int ports = HCS_N_PORTS(priv->hcs_params);
        u16 temp;
  
 -      desc->bDescriptorType = 0x29;
 +      desc->bDescriptorType = USB_DT_HUB;
        /* priv 1.0, 2.3.9 says 20ms max */
        desc->bPwrOn2PwrGood = 10;
        desc->bHubContrCurrent = 0;
@@@ -1869,7 -1869,7 +1869,7 @@@ static int isp1760_hub_control(struct u
                                reg_write32(hcd->regs, HC_PORTSC1,
                                                        temp | PORT_RESUME);
                                priv->reset_done = jiffies +
-                                       msecs_to_jiffies(20);
+                                       msecs_to_jiffies(USB_RESUME_TIMEOUT);
                        }
                        break;
                case USB_PORT_FEAT_C_SUSPEND:
@@@ -136,7 -136,7 +136,7 @@@ void musb_port_suspend(struct musb *mus
                /* later, GetPortStatus will stop RESUME signaling */
                musb->port1_status |= MUSB_PORT_STAT_RESUME;
                schedule_delayed_work(&musb->finish_resume_work,
-                                     msecs_to_jiffies(20));
+                                     msecs_to_jiffies(USB_RESUME_TIMEOUT));
        }
  }
  
@@@ -345,7 -345,7 +345,7 @@@ int musb_hub_control
                struct usb_hub_descriptor *desc = (void *)buf;
  
                desc->bDescLength = 9;
 -              desc->bDescriptorType = 0x29;
 +              desc->bDescriptorType = USB_DT_HUB;
                desc->bNbrPorts = 1;
                desc->wHubCharacteristics = cpu_to_le16(
                        HUB_CHAR_INDV_PORT_LPSM /* per-port power switching */