aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-04-10 07:45:27 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-04-10 07:45:27 -0400
commitc8d1bc12c7986c166bd3504213d9df2bc11ad7d6 (patch)
tree9882ae7d9eb103c73029050d62232cd83328be52
parentb7a4abb67416aa07cd65446dd39e64525ccfe8e5 (diff)
parentbbc78c07a51f6fd29c227b1220a9016e585358ba (diff)
Merge tag 'usb-for-v4.1-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-testing
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>
-rw-r--r--drivers/usb/core/hub.c4
-rw-r--r--drivers/usb/dwc2/hcd.c2
-rw-r--r--drivers/usb/host/ehci-hcd.c10
-rw-r--r--drivers/usb/host/ehci-hub.c9
-rw-r--r--drivers/usb/host/fotg210-hcd.c2
-rw-r--r--drivers/usb/host/fusbh200-hcd.c3
-rw-r--r--drivers/usb/host/isp116x-hcd.c2
-rw-r--r--drivers/usb/host/oxu210hp-hcd.c7
-rw-r--r--drivers/usb/host/r8a66597-hcd.c2
-rw-r--r--drivers/usb/host/sl811-hcd.c2
-rw-r--r--drivers/usb/host/uhci-hub.c5
-rw-r--r--drivers/usb/host/xhci-ring.c2
-rw-r--r--drivers/usb/isp1760/isp1760-hcd.c2
-rw-r--r--drivers/usb/musb/musb_core.c7
-rw-r--r--drivers/usb/musb/musb_virthub.c2
-rw-r--r--include/linux/usb.h26
16 files changed, 59 insertions, 28 deletions
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index d7c3d5a35946..3b7151687776 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -3406,10 +3406,10 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg)
3406 if (status) { 3406 if (status) {
3407 dev_dbg(&port_dev->dev, "can't resume, status %d\n", status); 3407 dev_dbg(&port_dev->dev, "can't resume, status %d\n", status);
3408 } else { 3408 } else {
3409 /* drive resume for at least 20 msec */ 3409 /* drive resume for USB_RESUME_TIMEOUT msec */
3410 dev_dbg(&udev->dev, "usb %sresume\n", 3410 dev_dbg(&udev->dev, "usb %sresume\n",
3411 (PMSG_IS_AUTO(msg) ? "auto-" : "")); 3411 (PMSG_IS_AUTO(msg) ? "auto-" : ""));
3412 msleep(25); 3412 msleep(USB_RESUME_TIMEOUT);
3413 3413
3414 /* Virtual root hubs can trigger on GET_PORT_STATUS to 3414 /* Virtual root hubs can trigger on GET_PORT_STATUS to
3415 * stop resume signaling. Then finish the resume 3415 * stop resume signaling. Then finish the resume
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 6f4acfa9252e..93bd4a10ab52 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -1529,7 +1529,7 @@ static int dwc2_hcd_hub_control(struct dwc2_hsotg *hsotg, u16 typereq,
1529 dev_dbg(hsotg->dev, 1529 dev_dbg(hsotg->dev,
1530 "ClearPortFeature USB_PORT_FEAT_SUSPEND\n"); 1530 "ClearPortFeature USB_PORT_FEAT_SUSPEND\n");
1531 writel(0, hsotg->regs + PCGCTL); 1531 writel(0, hsotg->regs + PCGCTL);
1532 usleep_range(20000, 40000); 1532 msleep(USB_RESUME_TIMEOUT);
1533 1533
1534 hprt0 = dwc2_read_hprt0(hsotg); 1534 hprt0 = dwc2_read_hprt0(hsotg);
1535 hprt0 |= HPRT0_RES; 1535 hprt0 |= HPRT0_RES;
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 85e56d1abd23..f4d88dfb26a7 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -792,12 +792,12 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
792 ehci->reset_done[i] == 0)) 792 ehci->reset_done[i] == 0))
793 continue; 793 continue;
794 794
795 /* start 20 msec resume signaling from this port, 795 /* start USB_RESUME_TIMEOUT msec resume signaling from
796 * and make hub_wq collect PORT_STAT_C_SUSPEND to 796 * this port, and make hub_wq collect
797 * stop that signaling. Use 5 ms extra for safety, 797 * PORT_STAT_C_SUSPEND to stop that signaling.
798 * like usb_port_resume() does.
799 */ 798 */
800 ehci->reset_done[i] = jiffies + msecs_to_jiffies(25); 799 ehci->reset_done[i] = jiffies +
800 msecs_to_jiffies(USB_RESUME_TIMEOUT);
801 set_bit(i, &ehci->resuming_ports); 801 set_bit(i, &ehci->resuming_ports);
802 ehci_dbg (ehci, "port %d remote wakeup\n", i + 1); 802 ehci_dbg (ehci, "port %d remote wakeup\n", i + 1);
803 usb_hcd_start_port_resume(&hcd->self, i); 803 usb_hcd_start_port_resume(&hcd->self, i);
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index d7b4b511b5c6..69208447d213 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -471,10 +471,13 @@ static int ehci_bus_resume (struct usb_hcd *hcd)
471 ehci_writel(ehci, temp, &ehci->regs->port_status [i]); 471 ehci_writel(ehci, temp, &ehci->regs->port_status [i]);
472 } 472 }
473 473
474 /* msleep for 20ms only if code is trying to resume port */ 474 /*
475 * msleep for USB_RESUME_TIMEOUT ms only if code is trying to resume
476 * port
477 */
475 if (resume_needed) { 478 if (resume_needed) {
476 spin_unlock_irq(&ehci->lock); 479 spin_unlock_irq(&ehci->lock);
477 msleep(20); 480 msleep(USB_RESUME_TIMEOUT);
478 spin_lock_irq(&ehci->lock); 481 spin_lock_irq(&ehci->lock);
479 if (ehci->shutdown) 482 if (ehci->shutdown)
480 goto shutdown; 483 goto shutdown;
@@ -942,7 +945,7 @@ int ehci_hub_control(
942 temp &= ~PORT_WAKE_BITS; 945 temp &= ~PORT_WAKE_BITS;
943 ehci_writel(ehci, temp | PORT_RESUME, status_reg); 946 ehci_writel(ehci, temp | PORT_RESUME, status_reg);
944 ehci->reset_done[wIndex] = jiffies 947 ehci->reset_done[wIndex] = jiffies
945 + msecs_to_jiffies(20); 948 + msecs_to_jiffies(USB_RESUME_TIMEOUT);
946 set_bit(wIndex, &ehci->resuming_ports); 949 set_bit(wIndex, &ehci->resuming_ports);
947 usb_hcd_start_port_resume(&hcd->self, wIndex); 950 usb_hcd_start_port_resume(&hcd->self, wIndex);
948 break; 951 break;
diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c
index af08ff12954d..000ed80ab592 100644
--- a/drivers/usb/host/fotg210-hcd.c
+++ b/drivers/usb/host/fotg210-hcd.c
@@ -1595,7 +1595,7 @@ static int fotg210_hub_control(
1595 /* resume signaling for 20 msec */ 1595 /* resume signaling for 20 msec */
1596 fotg210_writel(fotg210, temp | PORT_RESUME, status_reg); 1596 fotg210_writel(fotg210, temp | PORT_RESUME, status_reg);
1597 fotg210->reset_done[wIndex] = jiffies 1597 fotg210->reset_done[wIndex] = jiffies
1598 + msecs_to_jiffies(20); 1598 + msecs_to_jiffies(USB_RESUME_TIMEOUT);
1599 break; 1599 break;
1600 case USB_PORT_FEAT_C_SUSPEND: 1600 case USB_PORT_FEAT_C_SUSPEND:
1601 clear_bit(wIndex, &fotg210->port_c_suspend); 1601 clear_bit(wIndex, &fotg210->port_c_suspend);
diff --git a/drivers/usb/host/fusbh200-hcd.c b/drivers/usb/host/fusbh200-hcd.c
index eb39a451ef06..00e492eaba6a 100644
--- a/drivers/usb/host/fusbh200-hcd.c
+++ b/drivers/usb/host/fusbh200-hcd.c
@@ -1550,10 +1550,9 @@ static int fusbh200_hub_control (
1550 if ((temp & PORT_PE) == 0) 1550 if ((temp & PORT_PE) == 0)
1551 goto error; 1551 goto error;
1552 1552
1553 /* resume signaling for 20 msec */
1554 fusbh200_writel(fusbh200, temp | PORT_RESUME, status_reg); 1553 fusbh200_writel(fusbh200, temp | PORT_RESUME, status_reg);
1555 fusbh200->reset_done[wIndex] = jiffies 1554 fusbh200->reset_done[wIndex] = jiffies
1556 + msecs_to_jiffies(20); 1555 + msecs_to_jiffies(USB_RESUME_TIMEOUT);
1557 break; 1556 break;
1558 case USB_PORT_FEAT_C_SUSPEND: 1557 case USB_PORT_FEAT_C_SUSPEND:
1559 clear_bit(wIndex, &fusbh200->port_c_suspend); 1558 clear_bit(wIndex, &fusbh200->port_c_suspend);
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c
index aa335fa716d1..13181dcd9820 100644
--- a/drivers/usb/host/isp116x-hcd.c
+++ b/drivers/usb/host/isp116x-hcd.c
@@ -1490,7 +1490,7 @@ static int isp116x_bus_resume(struct usb_hcd *hcd)
1490 spin_unlock_irq(&isp116x->lock); 1490 spin_unlock_irq(&isp116x->lock);
1491 1491
1492 hcd->state = HC_STATE_RESUMING; 1492 hcd->state = HC_STATE_RESUMING;
1493 msleep(20); 1493 msleep(USB_RESUME_TIMEOUT);
1494 1494
1495 /* Go operational */ 1495 /* Go operational */
1496 spin_lock_irq(&isp116x->lock); 1496 spin_lock_irq(&isp116x->lock);
diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hcd.c
index 681ce57bf7b9..6352f54e65a1 100644
--- a/drivers/usb/host/oxu210hp-hcd.c
+++ b/drivers/usb/host/oxu210hp-hcd.c
@@ -2500,11 +2500,12 @@ static irqreturn_t oxu210_hcd_irq(struct usb_hcd *hcd)
2500 || oxu->reset_done[i] != 0) 2500 || oxu->reset_done[i] != 0)
2501 continue; 2501 continue;
2502 2502
2503 /* start 20 msec resume signaling from this port, 2503 /* start USB_RESUME_TIMEOUT resume signaling from this
2504 * and make hub_wq collect PORT_STAT_C_SUSPEND to 2504 * port, and make hub_wq collect PORT_STAT_C_SUSPEND to
2505 * stop that signaling. 2505 * stop that signaling.
2506 */ 2506 */
2507 oxu->reset_done[i] = jiffies + msecs_to_jiffies(20); 2507 oxu->reset_done[i] = jiffies +
2508 msecs_to_jiffies(USB_RESUME_TIMEOUT);
2508 oxu_dbg(oxu, "port %d remote wakeup\n", i + 1); 2509 oxu_dbg(oxu, "port %d remote wakeup\n", i + 1);
2509 mod_timer(&hcd->rh_timer, oxu->reset_done[i]); 2510 mod_timer(&hcd->rh_timer, oxu->reset_done[i]);
2510 } 2511 }
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index 5cbaa9846ab9..4cbd0633c5c2 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -2301,7 +2301,7 @@ static int r8a66597_bus_resume(struct usb_hcd *hcd)
2301 rh->port &= ~USB_PORT_STAT_SUSPEND; 2301 rh->port &= ~USB_PORT_STAT_SUSPEND;
2302 rh->port |= USB_PORT_STAT_C_SUSPEND << 16; 2302 rh->port |= USB_PORT_STAT_C_SUSPEND << 16;
2303 r8a66597_mdfy(r8a66597, RESUME, RESUME | UACT, dvstctr_reg); 2303 r8a66597_mdfy(r8a66597, RESUME, RESUME | UACT, dvstctr_reg);
2304 msleep(50); 2304 msleep(USB_RESUME_TIMEOUT);
2305 r8a66597_mdfy(r8a66597, UACT, RESUME | UACT, dvstctr_reg); 2305 r8a66597_mdfy(r8a66597, UACT, RESUME | UACT, dvstctr_reg);
2306 } 2306 }
2307 2307
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index 53e4fb75b04c..fd2a11473be7 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -1259,7 +1259,7 @@ sl811h_hub_control(
1259 sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1); 1259 sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
1260 1260
1261 mod_timer(&sl811->timer, jiffies 1261 mod_timer(&sl811->timer, jiffies
1262 + msecs_to_jiffies(20)); 1262 + msecs_to_jiffies(USB_RESUME_TIMEOUT));
1263 break; 1263 break;
1264 case USB_PORT_FEAT_POWER: 1264 case USB_PORT_FEAT_POWER:
1265 port_power(sl811, 0); 1265 port_power(sl811, 0);
diff --git a/drivers/usb/host/uhci-hub.c b/drivers/usb/host/uhci-hub.c
index a7cc0221e003..ece9e37e89fe 100644
--- a/drivers/usb/host/uhci-hub.c
+++ b/drivers/usb/host/uhci-hub.c
@@ -166,7 +166,7 @@ static void uhci_check_ports(struct uhci_hcd *uhci)
166 /* Port received a wakeup request */ 166 /* Port received a wakeup request */
167 set_bit(port, &uhci->resuming_ports); 167 set_bit(port, &uhci->resuming_ports);
168 uhci->ports_timeout = jiffies + 168 uhci->ports_timeout = jiffies +
169 msecs_to_jiffies(25); 169 msecs_to_jiffies(USB_RESUME_TIMEOUT);
170 usb_hcd_start_port_resume( 170 usb_hcd_start_port_resume(
171 &uhci_to_hcd(uhci)->self, port); 171 &uhci_to_hcd(uhci)->self, port);
172 172
@@ -338,7 +338,8 @@ static int uhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
338 uhci_finish_suspend(uhci, port, port_addr); 338 uhci_finish_suspend(uhci, port, port_addr);
339 339
340 /* USB v2.0 7.1.7.5 */ 340 /* USB v2.0 7.1.7.5 */
341 uhci->ports_timeout = jiffies + msecs_to_jiffies(50); 341 uhci->ports_timeout = jiffies +
342 msecs_to_jiffies(USB_RESUME_TIMEOUT);
342 break; 343 break;
343 case USB_PORT_FEAT_POWER: 344 case USB_PORT_FEAT_POWER:
344 /* UHCI has no power switching */ 345 /* UHCI has no power switching */
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index d8fb2cdaf8d8..f5397a517c54 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1574,7 +1574,7 @@ static void handle_port_status(struct xhci_hcd *xhci,
1574 } else { 1574 } else {
1575 xhci_dbg(xhci, "resume HS port %d\n", port_id); 1575 xhci_dbg(xhci, "resume HS port %d\n", port_id);
1576 bus_state->resume_done[faked_port_index] = jiffies + 1576 bus_state->resume_done[faked_port_index] = jiffies +
1577 msecs_to_jiffies(20); 1577 msecs_to_jiffies(USB_RESUME_TIMEOUT);
1578 set_bit(faked_port_index, &bus_state->resuming_ports); 1578 set_bit(faked_port_index, &bus_state->resuming_ports);
1579 mod_timer(&hcd->rh_timer, 1579 mod_timer(&hcd->rh_timer,
1580 bus_state->resume_done[faked_port_index]); 1580 bus_state->resume_done[faked_port_index]);
diff --git a/drivers/usb/isp1760/isp1760-hcd.c b/drivers/usb/isp1760/isp1760-hcd.c
index 9e23153c3c2e..ac31d19cc54b 100644
--- a/drivers/usb/isp1760/isp1760-hcd.c
+++ b/drivers/usb/isp1760/isp1760-hcd.c
@@ -1869,7 +1869,7 @@ static int isp1760_hub_control(struct usb_hcd *hcd, u16 typeReq,
1869 reg_write32(hcd->regs, HC_PORTSC1, 1869 reg_write32(hcd->regs, HC_PORTSC1,
1870 temp | PORT_RESUME); 1870 temp | PORT_RESUME);
1871 priv->reset_done = jiffies + 1871 priv->reset_done = jiffies +
1872 msecs_to_jiffies(20); 1872 msecs_to_jiffies(USB_RESUME_TIMEOUT);
1873 } 1873 }
1874 break; 1874 break;
1875 case USB_PORT_FEAT_C_SUSPEND: 1875 case USB_PORT_FEAT_C_SUSPEND:
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index a48b5a9c6c47..3789b08ef67b 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -99,6 +99,7 @@
99#include <linux/platform_device.h> 99#include <linux/platform_device.h>
100#include <linux/io.h> 100#include <linux/io.h>
101#include <linux/dma-mapping.h> 101#include <linux/dma-mapping.h>
102#include <linux/usb.h>
102 103
103#include "musb_core.h" 104#include "musb_core.h"
104 105
@@ -549,7 +550,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
549 (USB_PORT_STAT_C_SUSPEND << 16) 550 (USB_PORT_STAT_C_SUSPEND << 16)
550 | MUSB_PORT_STAT_RESUME; 551 | MUSB_PORT_STAT_RESUME;
551 musb->rh_timer = jiffies 552 musb->rh_timer = jiffies
552 + msecs_to_jiffies(20); 553 + msecs_to_jiffies(USB_RESUME_TIMEOUT);
553 musb->need_finish_resume = 1; 554 musb->need_finish_resume = 1;
554 555
555 musb->xceiv->otg->state = OTG_STATE_A_HOST; 556 musb->xceiv->otg->state = OTG_STATE_A_HOST;
@@ -2463,7 +2464,7 @@ static int musb_resume(struct device *dev)
2463 if (musb->need_finish_resume) { 2464 if (musb->need_finish_resume) {
2464 musb->need_finish_resume = 0; 2465 musb->need_finish_resume = 0;
2465 schedule_delayed_work(&musb->finish_resume_work, 2466 schedule_delayed_work(&musb->finish_resume_work,
2466 msecs_to_jiffies(20)); 2467 msecs_to_jiffies(USB_RESUME_TIMEOUT));
2467 } 2468 }
2468 2469
2469 /* 2470 /*
@@ -2506,7 +2507,7 @@ static int musb_runtime_resume(struct device *dev)
2506 if (musb->need_finish_resume) { 2507 if (musb->need_finish_resume) {
2507 musb->need_finish_resume = 0; 2508 musb->need_finish_resume = 0;
2508 schedule_delayed_work(&musb->finish_resume_work, 2509 schedule_delayed_work(&musb->finish_resume_work,
2509 msecs_to_jiffies(20)); 2510 msecs_to_jiffies(USB_RESUME_TIMEOUT));
2510 } 2511 }
2511 2512
2512 return 0; 2513 return 0;
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
index 52ee9a74f6ee..86c4b533e90b 100644
--- a/drivers/usb/musb/musb_virthub.c
+++ b/drivers/usb/musb/musb_virthub.c
@@ -136,7 +136,7 @@ void musb_port_suspend(struct musb *musb, bool do_suspend)
136 /* later, GetPortStatus will stop RESUME signaling */ 136 /* later, GetPortStatus will stop RESUME signaling */
137 musb->port1_status |= MUSB_PORT_STAT_RESUME; 137 musb->port1_status |= MUSB_PORT_STAT_RESUME;
138 schedule_delayed_work(&musb->finish_resume_work, 138 schedule_delayed_work(&musb->finish_resume_work,
139 msecs_to_jiffies(20)); 139 msecs_to_jiffies(USB_RESUME_TIMEOUT));
140 } 140 }
141} 141}
142 142
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 7ee1b5c3b4cb..447fe29b55b4 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -205,6 +205,32 @@ void usb_put_intf(struct usb_interface *intf);
205#define USB_MAXINTERFACES 32 205#define USB_MAXINTERFACES 32
206#define USB_MAXIADS (USB_MAXINTERFACES/2) 206#define USB_MAXIADS (USB_MAXINTERFACES/2)
207 207
208/*
209 * USB Resume Timer: Every Host controller driver should drive the resume
210 * signalling on the bus for the amount of time defined by this macro.
211 *
212 * That way we will have a 'stable' behavior among all HCDs supported by Linux.
213 *
214 * Note that the USB Specification states we should drive resume for *at least*
215 * 20 ms, but it doesn't give an upper bound. This creates two possible
216 * situations which we want to avoid:
217 *
218 * (a) sometimes an msleep(20) might expire slightly before 20 ms, which causes
219 * us to fail USB Electrical Tests, thus failing Certification
220 *
221 * (b) Some (many) devices actually need more than 20 ms of resume signalling,
222 * and while we can argue that's against the USB Specification, we don't have
223 * control over which devices a certification laboratory will be using for
224 * certification. If CertLab uses a device which was tested against Windows and
225 * that happens to have relaxed resume signalling rules, we might fall into
226 * situations where we fail interoperability and electrical tests.
227 *
228 * In order to avoid both conditions, we're using a 40 ms resume timeout, which
229 * should cope with both LPJ calibration errors and devices not following every
230 * detail of the USB Specification.
231 */
232#define USB_RESUME_TIMEOUT 40 /* ms */
233
208/** 234/**
209 * struct usb_interface_cache - long-term representation of a device interface 235 * struct usb_interface_cache - long-term representation of a device interface
210 * @num_altsetting: number of altsettings defined. 236 * @num_altsetting: number of altsettings defined.