aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/host')
-rw-r--r--drivers/usb/host/Kconfig2
-rw-r--r--drivers/usb/host/ehci-omap.c20
-rw-r--r--drivers/usb/host/ehci-q.c27
-rw-r--r--drivers/usb/host/ehci.h2
-rw-r--r--drivers/usb/host/fhci-hcd.c2
-rw-r--r--drivers/usb/host/fhci-tds.c8
-rw-r--r--drivers/usb/host/fhci.h4
-rw-r--r--drivers/usb/host/imx21-hcd.c2
-rw-r--r--drivers/usb/host/isp116x.h2
-rw-r--r--drivers/usb/host/isp1362-hcd.c2
-rw-r--r--drivers/usb/host/isp1760-hcd.c3
-rw-r--r--drivers/usb/host/ohci-au1xxx.c2
-rw-r--r--drivers/usb/host/ohci-hcd.c2
-rw-r--r--drivers/usb/host/ohci-tmio.c8
-rw-r--r--drivers/usb/host/oxu210hp-hcd.c6
-rw-r--r--drivers/usb/host/pci-quirks.c117
-rw-r--r--drivers/usb/host/whci/qset.c2
-rw-r--r--drivers/usb/host/xhci-hub.c19
-rw-r--r--drivers/usb/host/xhci-mem.c106
-rw-r--r--drivers/usb/host/xhci-pci.c4
-rw-r--r--drivers/usb/host/xhci-ring.c219
-rw-r--r--drivers/usb/host/xhci.c27
-rw-r--r--drivers/usb/host/xhci.h13
23 files changed, 381 insertions, 218 deletions
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 9483acdf2e9e..e0e0787b724b 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -402,7 +402,7 @@ config FHCI_DEBUG
402 depends on USB_FHCI_HCD && DEBUG_FS 402 depends on USB_FHCI_HCD && DEBUG_FS
403 help 403 help
404 Say "y" to see some FHCI debug information and statistics 404 Say "y" to see some FHCI debug information and statistics
405 throught debugfs. 405 through debugfs.
406 406
407config USB_U132_HCD 407config USB_U132_HCD
408 tristate "Elan U132 Adapter Host Controller" 408 tristate "Elan U132 Adapter Host Controller"
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 7e41a95c5ceb..627f3a678759 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -40,6 +40,7 @@
40#include <linux/slab.h> 40#include <linux/slab.h>
41#include <linux/usb/ulpi.h> 41#include <linux/usb/ulpi.h>
42#include <plat/usb.h> 42#include <plat/usb.h>
43#include <linux/regulator/consumer.h>
43 44
44/* EHCI Register Set */ 45/* EHCI Register Set */
45#define EHCI_INSNREG04 (0xA0) 46#define EHCI_INSNREG04 (0xA0)
@@ -118,6 +119,8 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
118 struct ehci_hcd *omap_ehci; 119 struct ehci_hcd *omap_ehci;
119 int ret = -ENODEV; 120 int ret = -ENODEV;
120 int irq; 121 int irq;
122 int i;
123 char supply[7];
121 124
122 if (usb_disabled()) 125 if (usb_disabled())
123 return -ENODEV; 126 return -ENODEV;
@@ -158,6 +161,23 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
158 hcd->rsrc_len = resource_size(res); 161 hcd->rsrc_len = resource_size(res);
159 hcd->regs = regs; 162 hcd->regs = regs;
160 163
164 /* get ehci regulator and enable */
165 for (i = 0 ; i < OMAP3_HS_USB_PORTS ; i++) {
166 if (pdata->port_mode[i] != OMAP_EHCI_PORT_MODE_PHY) {
167 pdata->regulator[i] = NULL;
168 continue;
169 }
170 snprintf(supply, sizeof(supply), "hsusb%d", i);
171 pdata->regulator[i] = regulator_get(dev, supply);
172 if (IS_ERR(pdata->regulator[i])) {
173 pdata->regulator[i] = NULL;
174 dev_dbg(dev,
175 "failed to get ehci port%d regulator\n", i);
176 } else {
177 regulator_enable(pdata->regulator[i]);
178 }
179 }
180
161 ret = omap_usbhs_enable(dev); 181 ret = omap_usbhs_enable(dev);
162 if (ret) { 182 if (ret) {
163 dev_err(dev, "failed to start usbhs with err %d\n", ret); 183 dev_err(dev, "failed to start usbhs with err %d\n", ret);
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
index fe99895fb098..42abd0f603bf 100644
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -315,7 +315,6 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh)
315 int stopped; 315 int stopped;
316 unsigned count = 0; 316 unsigned count = 0;
317 u8 state; 317 u8 state;
318 const __le32 halt = HALT_BIT(ehci);
319 struct ehci_qh_hw *hw = qh->hw; 318 struct ehci_qh_hw *hw = qh->hw;
320 319
321 if (unlikely (list_empty (&qh->qtd_list))) 320 if (unlikely (list_empty (&qh->qtd_list)))
@@ -422,7 +421,6 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh)
422 && !(qtd->hw_alt_next 421 && !(qtd->hw_alt_next
423 & EHCI_LIST_END(ehci))) { 422 & EHCI_LIST_END(ehci))) {
424 stopped = 1; 423 stopped = 1;
425 goto halt;
426 } 424 }
427 425
428 /* stop scanning when we reach qtds the hc is using */ 426 /* stop scanning when we reach qtds the hc is using */
@@ -456,16 +454,6 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh)
456 */ 454 */
457 ehci_clear_tt_buffer(ehci, qh, urb, token); 455 ehci_clear_tt_buffer(ehci, qh, urb, token);
458 } 456 }
459
460 /* force halt for unlinked or blocked qh, so we'll
461 * patch the qh later and so that completions can't
462 * activate it while we "know" it's stopped.
463 */
464 if ((halt & hw->hw_token) == 0) {
465halt:
466 hw->hw_token |= halt;
467 wmb ();
468 }
469 } 457 }
470 458
471 /* unless we already know the urb's status, collect qtd status 459 /* unless we already know the urb's status, collect qtd status
@@ -1259,24 +1247,27 @@ static void start_unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
1259 1247
1260static void scan_async (struct ehci_hcd *ehci) 1248static void scan_async (struct ehci_hcd *ehci)
1261{ 1249{
1250 bool stopped;
1262 struct ehci_qh *qh; 1251 struct ehci_qh *qh;
1263 enum ehci_timer_action action = TIMER_IO_WATCHDOG; 1252 enum ehci_timer_action action = TIMER_IO_WATCHDOG;
1264 1253
1265 ehci->stamp = ehci_readl(ehci, &ehci->regs->frame_index); 1254 ehci->stamp = ehci_readl(ehci, &ehci->regs->frame_index);
1266 timer_action_done (ehci, TIMER_ASYNC_SHRINK); 1255 timer_action_done (ehci, TIMER_ASYNC_SHRINK);
1267rescan: 1256rescan:
1257 stopped = !HC_IS_RUNNING(ehci_to_hcd(ehci)->state);
1268 qh = ehci->async->qh_next.qh; 1258 qh = ehci->async->qh_next.qh;
1269 if (likely (qh != NULL)) { 1259 if (likely (qh != NULL)) {
1270 do { 1260 do {
1271 /* clean any finished work for this qh */ 1261 /* clean any finished work for this qh */
1272 if (!list_empty (&qh->qtd_list) 1262 if (!list_empty(&qh->qtd_list) && (stopped ||
1273 && qh->stamp != ehci->stamp) { 1263 qh->stamp != ehci->stamp)) {
1274 int temp; 1264 int temp;
1275 1265
1276 /* unlinks could happen here; completion 1266 /* unlinks could happen here; completion
1277 * reporting drops the lock. rescan using 1267 * reporting drops the lock. rescan using
1278 * the latest schedule, but don't rescan 1268 * the latest schedule, but don't rescan
1279 * qhs we already finished (no looping). 1269 * qhs we already finished (no looping)
1270 * unless the controller is stopped.
1280 */ 1271 */
1281 qh = qh_get (qh); 1272 qh = qh_get (qh);
1282 qh->stamp = ehci->stamp; 1273 qh->stamp = ehci->stamp;
@@ -1297,9 +1288,9 @@ rescan:
1297 */ 1288 */
1298 if (list_empty(&qh->qtd_list) 1289 if (list_empty(&qh->qtd_list)
1299 && qh->qh_state == QH_STATE_LINKED) { 1290 && qh->qh_state == QH_STATE_LINKED) {
1300 if (!ehci->reclaim 1291 if (!ehci->reclaim && (stopped ||
1301 && ((ehci->stamp - qh->stamp) & 0x1fff) 1292 ((ehci->stamp - qh->stamp) & 0x1fff)
1302 >= (EHCI_SHRINK_FRAMES * 8)) 1293 >= EHCI_SHRINK_FRAMES * 8))
1303 start_unlink_async(ehci, qh); 1294 start_unlink_async(ehci, qh);
1304 else 1295 else
1305 action = TIMER_ASYNC_SHRINK; 1296 action = TIMER_ASYNC_SHRINK;
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index f86d3fa20214..333ddc156919 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -644,7 +644,7 @@ static inline void ehci_writel(const struct ehci_hcd *ehci,
644/* 644/*
645 * On certain ppc-44x SoC there is a HW issue, that could only worked around with 645 * On certain ppc-44x SoC there is a HW issue, that could only worked around with
646 * explicit suspend/operate of OHCI. This function hereby makes sense only on that arch. 646 * explicit suspend/operate of OHCI. This function hereby makes sense only on that arch.
647 * Other common bits are dependant on has_amcc_usb23 quirk flag. 647 * Other common bits are dependent on has_amcc_usb23 quirk flag.
648 */ 648 */
649#ifdef CONFIG_44x 649#ifdef CONFIG_44x
650static inline void set_ohci_hcfs(struct ehci_hcd *ehci, int operational) 650static inline void set_ohci_hcfs(struct ehci_hcd *ehci, int operational)
diff --git a/drivers/usb/host/fhci-hcd.c b/drivers/usb/host/fhci-hcd.c
index b84ff7e51896..19223c7449e1 100644
--- a/drivers/usb/host/fhci-hcd.c
+++ b/drivers/usb/host/fhci-hcd.c
@@ -401,7 +401,7 @@ static int fhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
401 /* 1 td fro setup,1 for ack */ 401 /* 1 td fro setup,1 for ack */
402 size = 2; 402 size = 2;
403 case PIPE_BULK: 403 case PIPE_BULK:
404 /* one td for every 4096 bytes(can be upto 8k) */ 404 /* one td for every 4096 bytes(can be up to 8k) */
405 size += urb->transfer_buffer_length / 4096; 405 size += urb->transfer_buffer_length / 4096;
406 /* ...add for any remaining bytes... */ 406 /* ...add for any remaining bytes... */
407 if ((urb->transfer_buffer_length % 4096) != 0) 407 if ((urb->transfer_buffer_length % 4096) != 0)
diff --git a/drivers/usb/host/fhci-tds.c b/drivers/usb/host/fhci-tds.c
index 38fe058fbe61..0ea577bfca2a 100644
--- a/drivers/usb/host/fhci-tds.c
+++ b/drivers/usb/host/fhci-tds.c
@@ -40,7 +40,7 @@
40#define TD_RXER 0x0020 /* Rx error or not */ 40#define TD_RXER 0x0020 /* Rx error or not */
41 41
42#define TD_NAK 0x0010 /* No ack. */ 42#define TD_NAK 0x0010 /* No ack. */
43#define TD_STAL 0x0008 /* Stall recieved */ 43#define TD_STAL 0x0008 /* Stall received */
44#define TD_TO 0x0004 /* time out */ 44#define TD_TO 0x0004 /* time out */
45#define TD_UN 0x0002 /* underrun */ 45#define TD_UN 0x0002 /* underrun */
46#define TD_NO 0x0010 /* Rx Non Octet Aligned Packet */ 46#define TD_NO 0x0010 /* Rx Non Octet Aligned Packet */
@@ -274,7 +274,7 @@ void fhci_init_ep_registers(struct fhci_usb *usb, struct endpoint *ep,
274 * It is also preparing the TDs for new frames. If the Tx interrupts 274 * It is also preparing the TDs for new frames. If the Tx interrupts
275 * are disabled, the application should call that routine to get 275 * are disabled, the application should call that routine to get
276 * confirmation about the submitted frames. Otherwise, the routine is 276 * confirmation about the submitted frames. Otherwise, the routine is
277 * called frome the interrupt service routine during the Tx interrupt. 277 * called from the interrupt service routine during the Tx interrupt.
278 * In that case the application is informed by calling the application 278 * In that case the application is informed by calling the application
279 * specific 'fhci_transaction_confirm' routine 279 * specific 'fhci_transaction_confirm' routine
280 */ 280 */
@@ -337,7 +337,7 @@ static void fhci_td_transaction_confirm(struct fhci_usb *usb)
337 pkt->status = USB_TD_RX_ER_NONOCT; 337 pkt->status = USB_TD_RX_ER_NONOCT;
338 else 338 else
339 fhci_err(usb->fhci, "illegal error " 339 fhci_err(usb->fhci, "illegal error "
340 "occured\n"); 340 "occurred\n");
341 } else if (td_status & TD_NAK) 341 } else if (td_status & TD_NAK)
342 pkt->status = USB_TD_TX_ER_NAK; 342 pkt->status = USB_TD_TX_ER_NAK;
343 else if (td_status & TD_TO) 343 else if (td_status & TD_TO)
@@ -347,7 +347,7 @@ static void fhci_td_transaction_confirm(struct fhci_usb *usb)
347 else if (td_status & TD_STAL) 347 else if (td_status & TD_STAL)
348 pkt->status = USB_TD_TX_ER_STALL; 348 pkt->status = USB_TD_TX_ER_STALL;
349 else 349 else
350 fhci_err(usb->fhci, "illegal error occured\n"); 350 fhci_err(usb->fhci, "illegal error occurred\n");
351 } else if ((extra_data & TD_TOK_IN) && 351 } else if ((extra_data & TD_TOK_IN) &&
352 pkt->len > td_length - CRC_SIZE) { 352 pkt->len > td_length - CRC_SIZE) {
353 pkt->status = USB_TD_RX_DATA_UNDERUN; 353 pkt->status = USB_TD_RX_DATA_UNDERUN;
diff --git a/drivers/usb/host/fhci.h b/drivers/usb/host/fhci.h
index 71c3caaea4c1..dc6939a44a1a 100644
--- a/drivers/usb/host/fhci.h
+++ b/drivers/usb/host/fhci.h
@@ -82,7 +82,7 @@
82#define USB_TD_RX_ER_NONOCT 0x40000000 /* Tx Non Octet Aligned Packet */ 82#define USB_TD_RX_ER_NONOCT 0x40000000 /* Tx Non Octet Aligned Packet */
83#define USB_TD_RX_ER_BITSTUFF 0x20000000 /* Frame Aborted-Received pkt */ 83#define USB_TD_RX_ER_BITSTUFF 0x20000000 /* Frame Aborted-Received pkt */
84#define USB_TD_RX_ER_CRC 0x10000000 /* CRC error */ 84#define USB_TD_RX_ER_CRC 0x10000000 /* CRC error */
85#define USB_TD_RX_ER_OVERUN 0x08000000 /* Over - run occured */ 85#define USB_TD_RX_ER_OVERUN 0x08000000 /* Over - run occurred */
86#define USB_TD_RX_ER_PID 0x04000000 /* wrong PID received */ 86#define USB_TD_RX_ER_PID 0x04000000 /* wrong PID received */
87#define USB_TD_RX_DATA_UNDERUN 0x02000000 /* shorter than expected */ 87#define USB_TD_RX_DATA_UNDERUN 0x02000000 /* shorter than expected */
88#define USB_TD_RX_DATA_OVERUN 0x01000000 /* longer than expected */ 88#define USB_TD_RX_DATA_OVERUN 0x01000000 /* longer than expected */
@@ -363,7 +363,7 @@ struct ed {
363struct td { 363struct td {
364 void *data; /* a pointer to the data buffer */ 364 void *data; /* a pointer to the data buffer */
365 unsigned int len; /* length of the data to be submitted */ 365 unsigned int len; /* length of the data to be submitted */
366 unsigned int actual_len; /* actual bytes transfered on this td */ 366 unsigned int actual_len; /* actual bytes transferred on this td */
367 enum fhci_ta_type type; /* transaction type */ 367 enum fhci_ta_type type; /* transaction type */
368 u8 toggle; /* toggle for next trans. within this TD */ 368 u8 toggle; /* toggle for next trans. within this TD */
369 u16 iso_index; /* ISO transaction index */ 369 u16 iso_index; /* ISO transaction index */
diff --git a/drivers/usb/host/imx21-hcd.c b/drivers/usb/host/imx21-hcd.c
index 2562e92e3178..af05718bdc73 100644
--- a/drivers/usb/host/imx21-hcd.c
+++ b/drivers/usb/host/imx21-hcd.c
@@ -1323,7 +1323,7 @@ static void process_etds(struct usb_hcd *hcd, struct imx21 *imx21, int sof)
1323 * (and hence no interrupt occurs). 1323 * (and hence no interrupt occurs).
1324 * This causes the transfer in question to hang. 1324 * This causes the transfer in question to hang.
1325 * The kludge below checks for this condition at each SOF and processes any 1325 * The kludge below checks for this condition at each SOF and processes any
1326 * blocked ETDs (after an arbitary 10 frame wait) 1326 * blocked ETDs (after an arbitrary 10 frame wait)
1327 * 1327 *
1328 * With a single active transfer the usbtest test suite will run for days 1328 * With a single active transfer the usbtest test suite will run for days
1329 * without the kludge. 1329 * without the kludge.
diff --git a/drivers/usb/host/isp116x.h b/drivers/usb/host/isp116x.h
index 12db961acdfb..9a2c400e6090 100644
--- a/drivers/usb/host/isp116x.h
+++ b/drivers/usb/host/isp116x.h
@@ -13,7 +13,7 @@
13 13
14/* Full speed: max # of bytes to transfer for a single urb 14/* Full speed: max # of bytes to transfer for a single urb
15 at a time must be < 1024 && must be multiple of 64. 15 at a time must be < 1024 && must be multiple of 64.
16 832 allows transfering 4kiB within 5 frames. */ 16 832 allows transferring 4kiB within 5 frames. */
17#define MAX_TRANSFER_SIZE_FULLSPEED 832 17#define MAX_TRANSFER_SIZE_FULLSPEED 832
18 18
19/* Low speed: there is no reason to schedule in very big 19/* Low speed: there is no reason to schedule in very big
diff --git a/drivers/usb/host/isp1362-hcd.c b/drivers/usb/host/isp1362-hcd.c
index 662cd002adfc..f97570a847ca 100644
--- a/drivers/usb/host/isp1362-hcd.c
+++ b/drivers/usb/host/isp1362-hcd.c
@@ -546,7 +546,7 @@ static void postproc_ep(struct isp1362_hcd *isp1362_hcd, struct isp1362_ep *ep)
546 if (usb_pipecontrol(urb->pipe)) { 546 if (usb_pipecontrol(urb->pipe)) {
547 ep->nextpid = USB_PID_ACK; 547 ep->nextpid = USB_PID_ACK;
548 /* save the data underrun error code for later and 548 /* save the data underrun error code for later and
549 * procede with the status stage 549 * proceed with the status stage
550 */ 550 */
551 urb->actual_length += PTD_GET_COUNT(ptd); 551 urb->actual_length += PTD_GET_COUNT(ptd);
552 BUG_ON(urb->actual_length > urb->transfer_buffer_length); 552 BUG_ON(urb->actual_length > urb->transfer_buffer_length);
diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c
index f50e84ac570a..7b2e69aa2e98 100644
--- a/drivers/usb/host/isp1760-hcd.c
+++ b/drivers/usb/host/isp1760-hcd.c
@@ -295,7 +295,7 @@ static void alloc_mem(struct usb_hcd *hcd, struct isp1760_qtd *qtd)
295 } 295 }
296 296
297 dev_err(hcd->self.controller, 297 dev_err(hcd->self.controller,
298 "%s: Can not allocate %lu bytes of memory\n" 298 "%s: Cannot allocate %zu bytes of memory\n"
299 "Current memory map:\n", 299 "Current memory map:\n",
300 __func__, qtd->length); 300 __func__, qtd->length);
301 for (i = 0; i < BLOCKS; i++) { 301 for (i = 0; i < BLOCKS; i++) {
@@ -1633,6 +1633,7 @@ static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
1633 ints[i].qh = NULL; 1633 ints[i].qh = NULL;
1634 ints[i].qtd = NULL; 1634 ints[i].qtd = NULL;
1635 1635
1636 urb->status = status;
1636 isp1760_urb_done(hcd, urb); 1637 isp1760_urb_done(hcd, urb);
1637 if (qtd) 1638 if (qtd)
1638 pe(hcd, qh, qtd); 1639 pe(hcd, qh, qtd);
diff --git a/drivers/usb/host/ohci-au1xxx.c b/drivers/usb/host/ohci-au1xxx.c
index 17a6043c1fa0..958d985f2951 100644
--- a/drivers/usb/host/ohci-au1xxx.c
+++ b/drivers/usb/host/ohci-au1xxx.c
@@ -33,7 +33,7 @@
33 33
34#ifdef __LITTLE_ENDIAN 34#ifdef __LITTLE_ENDIAN
35#define USBH_ENABLE_INIT (USBH_ENABLE_CE | USBH_ENABLE_E | USBH_ENABLE_C) 35#define USBH_ENABLE_INIT (USBH_ENABLE_CE | USBH_ENABLE_E | USBH_ENABLE_C)
36#elif __BIG_ENDIAN 36#elif defined(__BIG_ENDIAN)
37#define USBH_ENABLE_INIT (USBH_ENABLE_CE | USBH_ENABLE_E | USBH_ENABLE_C | \ 37#define USBH_ENABLE_INIT (USBH_ENABLE_CE | USBH_ENABLE_E | USBH_ENABLE_C | \
38 USBH_ENABLE_BE) 38 USBH_ENABLE_BE)
39#else 39#else
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index e7288639edb0..d55723514860 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -162,7 +162,7 @@ static int ohci_urb_enqueue (
162 // case PIPE_INTERRUPT: 162 // case PIPE_INTERRUPT:
163 // case PIPE_BULK: 163 // case PIPE_BULK:
164 default: 164 default:
165 /* one TD for every 4096 Bytes (can be upto 8K) */ 165 /* one TD for every 4096 Bytes (can be up to 8K) */
166 size += urb->transfer_buffer_length / 4096; 166 size += urb->transfer_buffer_length / 4096;
167 /* ... and for any remaining bytes ... */ 167 /* ... and for any remaining bytes ... */
168 if ((urb->transfer_buffer_length % 4096) != 0) 168 if ((urb->transfer_buffer_length % 4096) != 0)
diff --git a/drivers/usb/host/ohci-tmio.c b/drivers/usb/host/ohci-tmio.c
index 8dabe8e31d8c..3558491dd87d 100644
--- a/drivers/usb/host/ohci-tmio.c
+++ b/drivers/usb/host/ohci-tmio.c
@@ -185,7 +185,7 @@ static struct platform_driver ohci_hcd_tmio_driver;
185 185
186static int __devinit ohci_hcd_tmio_drv_probe(struct platform_device *dev) 186static int __devinit ohci_hcd_tmio_drv_probe(struct platform_device *dev)
187{ 187{
188 struct mfd_cell *cell = dev->dev.platform_data; 188 const struct mfd_cell *cell = mfd_get_cell(dev);
189 struct resource *regs = platform_get_resource(dev, IORESOURCE_MEM, 0); 189 struct resource *regs = platform_get_resource(dev, IORESOURCE_MEM, 0);
190 struct resource *config = platform_get_resource(dev, IORESOURCE_MEM, 1); 190 struct resource *config = platform_get_resource(dev, IORESOURCE_MEM, 1);
191 struct resource *sram = platform_get_resource(dev, IORESOURCE_MEM, 2); 191 struct resource *sram = platform_get_resource(dev, IORESOURCE_MEM, 2);
@@ -274,7 +274,7 @@ static int __devexit ohci_hcd_tmio_drv_remove(struct platform_device *dev)
274{ 274{
275 struct usb_hcd *hcd = platform_get_drvdata(dev); 275 struct usb_hcd *hcd = platform_get_drvdata(dev);
276 struct tmio_hcd *tmio = hcd_to_tmio(hcd); 276 struct tmio_hcd *tmio = hcd_to_tmio(hcd);
277 struct mfd_cell *cell = dev->dev.platform_data; 277 const struct mfd_cell *cell = mfd_get_cell(dev);
278 278
279 usb_remove_hcd(hcd); 279 usb_remove_hcd(hcd);
280 tmio_stop_hc(dev); 280 tmio_stop_hc(dev);
@@ -293,7 +293,7 @@ static int __devexit ohci_hcd_tmio_drv_remove(struct platform_device *dev)
293#ifdef CONFIG_PM 293#ifdef CONFIG_PM
294static int ohci_hcd_tmio_drv_suspend(struct platform_device *dev, pm_message_t state) 294static int ohci_hcd_tmio_drv_suspend(struct platform_device *dev, pm_message_t state)
295{ 295{
296 struct mfd_cell *cell = dev->dev.platform_data; 296 const struct mfd_cell *cell = mfd_get_cell(dev);
297 struct usb_hcd *hcd = platform_get_drvdata(dev); 297 struct usb_hcd *hcd = platform_get_drvdata(dev);
298 struct ohci_hcd *ohci = hcd_to_ohci(hcd); 298 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
299 struct tmio_hcd *tmio = hcd_to_tmio(hcd); 299 struct tmio_hcd *tmio = hcd_to_tmio(hcd);
@@ -326,7 +326,7 @@ static int ohci_hcd_tmio_drv_suspend(struct platform_device *dev, pm_message_t s
326 326
327static int ohci_hcd_tmio_drv_resume(struct platform_device *dev) 327static int ohci_hcd_tmio_drv_resume(struct platform_device *dev)
328{ 328{
329 struct mfd_cell *cell = dev->dev.platform_data; 329 const struct mfd_cell *cell = mfd_get_cell(dev);
330 struct usb_hcd *hcd = platform_get_drvdata(dev); 330 struct usb_hcd *hcd = platform_get_drvdata(dev);
331 struct ohci_hcd *ohci = hcd_to_ohci(hcd); 331 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
332 struct tmio_hcd *tmio = hcd_to_tmio(hcd); 332 struct tmio_hcd *tmio = hcd_to_tmio(hcd);
diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hcd.c
index 38193f4e980e..4a771f6cc822 100644
--- a/drivers/usb/host/oxu210hp-hcd.c
+++ b/drivers/usb/host/oxu210hp-hcd.c
@@ -2879,7 +2879,7 @@ static int oxu_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
2879 /* Ok, we have more job to do! :) */ 2879 /* Ok, we have more job to do! :) */
2880 2880
2881 for (i = 0; i < num - 1; i++) { 2881 for (i = 0; i < num - 1; i++) {
2882 /* Get free micro URB poll till a free urb is recieved */ 2882 /* Get free micro URB poll till a free urb is received */
2883 2883
2884 do { 2884 do {
2885 murb = (struct urb *) oxu_murb_alloc(oxu); 2885 murb = (struct urb *) oxu_murb_alloc(oxu);
@@ -2911,7 +2911,7 @@ static int oxu_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
2911 2911
2912 /* Last urb requires special handling */ 2912 /* Last urb requires special handling */
2913 2913
2914 /* Get free micro URB poll till a free urb is recieved */ 2914 /* Get free micro URB poll till a free urb is received */
2915 do { 2915 do {
2916 murb = (struct urb *) oxu_murb_alloc(oxu); 2916 murb = (struct urb *) oxu_murb_alloc(oxu);
2917 if (!murb) 2917 if (!murb)
@@ -3832,7 +3832,7 @@ static int oxu_drv_probe(struct platform_device *pdev)
3832 return -EBUSY; 3832 return -EBUSY;
3833 } 3833 }
3834 3834
3835 ret = set_irq_type(irq, IRQF_TRIGGER_FALLING); 3835 ret = irq_set_irq_type(irq, IRQF_TRIGGER_FALLING);
3836 if (ret) { 3836 if (ret) {
3837 dev_err(&pdev->dev, "error setting irq type\n"); 3837 dev_err(&pdev->dev, "error setting irq type\n");
3838 ret = -EFAULT; 3838 ret = -EFAULT;
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index 1d586d4f7b56..9b166d70ae91 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -84,65 +84,92 @@ int usb_amd_find_chipset_info(void)
84{ 84{
85 u8 rev = 0; 85 u8 rev = 0;
86 unsigned long flags; 86 unsigned long flags;
87 struct amd_chipset_info info;
88 int ret;
87 89
88 spin_lock_irqsave(&amd_lock, flags); 90 spin_lock_irqsave(&amd_lock, flags);
89 91
90 amd_chipset.probe_count++;
91 /* probe only once */ 92 /* probe only once */
92 if (amd_chipset.probe_count > 1) { 93 if (amd_chipset.probe_count > 0) {
94 amd_chipset.probe_count++;
93 spin_unlock_irqrestore(&amd_lock, flags); 95 spin_unlock_irqrestore(&amd_lock, flags);
94 return amd_chipset.probe_result; 96 return amd_chipset.probe_result;
95 } 97 }
98 memset(&info, 0, sizeof(info));
99 spin_unlock_irqrestore(&amd_lock, flags);
96 100
97 amd_chipset.smbus_dev = pci_get_device(PCI_VENDOR_ID_ATI, 0x4385, NULL); 101 info.smbus_dev = pci_get_device(PCI_VENDOR_ID_ATI, 0x4385, NULL);
98 if (amd_chipset.smbus_dev) { 102 if (info.smbus_dev) {
99 rev = amd_chipset.smbus_dev->revision; 103 rev = info.smbus_dev->revision;
100 if (rev >= 0x40) 104 if (rev >= 0x40)
101 amd_chipset.sb_type = 1; 105 info.sb_type = 1;
102 else if (rev >= 0x30 && rev <= 0x3b) 106 else if (rev >= 0x30 && rev <= 0x3b)
103 amd_chipset.sb_type = 3; 107 info.sb_type = 3;
104 } else { 108 } else {
105 amd_chipset.smbus_dev = pci_get_device(PCI_VENDOR_ID_AMD, 109 info.smbus_dev = pci_get_device(PCI_VENDOR_ID_AMD,
106 0x780b, NULL); 110 0x780b, NULL);
107 if (!amd_chipset.smbus_dev) { 111 if (!info.smbus_dev) {
108 spin_unlock_irqrestore(&amd_lock, flags); 112 ret = 0;
109 return 0; 113 goto commit;
110 } 114 }
111 rev = amd_chipset.smbus_dev->revision; 115
116 rev = info.smbus_dev->revision;
112 if (rev >= 0x11 && rev <= 0x18) 117 if (rev >= 0x11 && rev <= 0x18)
113 amd_chipset.sb_type = 2; 118 info.sb_type = 2;
114 } 119 }
115 120
116 if (amd_chipset.sb_type == 0) { 121 if (info.sb_type == 0) {
117 if (amd_chipset.smbus_dev) { 122 if (info.smbus_dev) {
118 pci_dev_put(amd_chipset.smbus_dev); 123 pci_dev_put(info.smbus_dev);
119 amd_chipset.smbus_dev = NULL; 124 info.smbus_dev = NULL;
120 } 125 }
121 spin_unlock_irqrestore(&amd_lock, flags); 126 ret = 0;
122 return 0; 127 goto commit;
123 } 128 }
124 129
125 amd_chipset.nb_dev = pci_get_device(PCI_VENDOR_ID_AMD, 0x9601, NULL); 130 info.nb_dev = pci_get_device(PCI_VENDOR_ID_AMD, 0x9601, NULL);
126 if (amd_chipset.nb_dev) { 131 if (info.nb_dev) {
127 amd_chipset.nb_type = 1; 132 info.nb_type = 1;
128 } else { 133 } else {
129 amd_chipset.nb_dev = pci_get_device(PCI_VENDOR_ID_AMD, 134 info.nb_dev = pci_get_device(PCI_VENDOR_ID_AMD, 0x1510, NULL);
130 0x1510, NULL); 135 if (info.nb_dev) {
131 if (amd_chipset.nb_dev) { 136 info.nb_type = 2;
132 amd_chipset.nb_type = 2; 137 } else {
133 } else { 138 info.nb_dev = pci_get_device(PCI_VENDOR_ID_AMD,
134 amd_chipset.nb_dev = pci_get_device(PCI_VENDOR_ID_AMD, 139 0x9600, NULL);
135 0x9600, NULL); 140 if (info.nb_dev)
136 if (amd_chipset.nb_dev) 141 info.nb_type = 3;
137 amd_chipset.nb_type = 3;
138 } 142 }
139 } 143 }
140 144
141 amd_chipset.probe_result = 1; 145 ret = info.probe_result = 1;
142 printk(KERN_DEBUG "QUIRK: Enable AMD PLL fix\n"); 146 printk(KERN_DEBUG "QUIRK: Enable AMD PLL fix\n");
143 147
144 spin_unlock_irqrestore(&amd_lock, flags); 148commit:
145 return amd_chipset.probe_result; 149
150 spin_lock_irqsave(&amd_lock, flags);
151 if (amd_chipset.probe_count > 0) {
152 /* race - someone else was faster - drop devices */
153
154 /* Mark that we where here */
155 amd_chipset.probe_count++;
156 ret = amd_chipset.probe_result;
157
158 spin_unlock_irqrestore(&amd_lock, flags);
159
160 if (info.nb_dev)
161 pci_dev_put(info.nb_dev);
162 if (info.smbus_dev)
163 pci_dev_put(info.smbus_dev);
164
165 } else {
166 /* no race - commit the result */
167 info.probe_count++;
168 amd_chipset = info;
169 spin_unlock_irqrestore(&amd_lock, flags);
170 }
171
172 return ret;
146} 173}
147EXPORT_SYMBOL_GPL(usb_amd_find_chipset_info); 174EXPORT_SYMBOL_GPL(usb_amd_find_chipset_info);
148 175
@@ -284,6 +311,7 @@ EXPORT_SYMBOL_GPL(usb_amd_quirk_pll_enable);
284 311
285void usb_amd_dev_put(void) 312void usb_amd_dev_put(void)
286{ 313{
314 struct pci_dev *nb, *smbus;
287 unsigned long flags; 315 unsigned long flags;
288 316
289 spin_lock_irqsave(&amd_lock, flags); 317 spin_lock_irqsave(&amd_lock, flags);
@@ -294,20 +322,23 @@ void usb_amd_dev_put(void)
294 return; 322 return;
295 } 323 }
296 324
297 if (amd_chipset.nb_dev) { 325 /* save them to pci_dev_put outside of spinlock */
298 pci_dev_put(amd_chipset.nb_dev); 326 nb = amd_chipset.nb_dev;
299 amd_chipset.nb_dev = NULL; 327 smbus = amd_chipset.smbus_dev;
300 } 328
301 if (amd_chipset.smbus_dev) { 329 amd_chipset.nb_dev = NULL;
302 pci_dev_put(amd_chipset.smbus_dev); 330 amd_chipset.smbus_dev = NULL;
303 amd_chipset.smbus_dev = NULL;
304 }
305 amd_chipset.nb_type = 0; 331 amd_chipset.nb_type = 0;
306 amd_chipset.sb_type = 0; 332 amd_chipset.sb_type = 0;
307 amd_chipset.isoc_reqs = 0; 333 amd_chipset.isoc_reqs = 0;
308 amd_chipset.probe_result = 0; 334 amd_chipset.probe_result = 0;
309 335
310 spin_unlock_irqrestore(&amd_lock, flags); 336 spin_unlock_irqrestore(&amd_lock, flags);
337
338 if (nb)
339 pci_dev_put(nb);
340 if (smbus)
341 pci_dev_put(smbus);
311} 342}
312EXPORT_SYMBOL_GPL(usb_amd_dev_put); 343EXPORT_SYMBOL_GPL(usb_amd_dev_put);
313 344
diff --git a/drivers/usb/host/whci/qset.c b/drivers/usb/host/whci/qset.c
index dc0ab8382f5d..d6e175428618 100644
--- a/drivers/usb/host/whci/qset.c
+++ b/drivers/usb/host/whci/qset.c
@@ -739,7 +739,7 @@ static int get_urb_status_from_qtd(struct urb *urb, u32 status)
739 * process_inactive_qtd - process an inactive (but not halted) qTD. 739 * process_inactive_qtd - process an inactive (but not halted) qTD.
740 * 740 *
741 * Update the urb with the transfer bytes from the qTD, if the urb is 741 * Update the urb with the transfer bytes from the qTD, if the urb is
742 * completely transfered or (in the case of an IN only) the LPF is 742 * completely transferred or (in the case of an IN only) the LPF is
743 * set, then the transfer is complete and the urb should be returned 743 * set, then the transfer is complete and the urb should be returned
744 * to the system. 744 * to the system.
745 */ 745 */
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index a78f2ebd11b7..73f75d26436c 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -777,7 +777,7 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
777 if (t1 != t2) 777 if (t1 != t2)
778 xhci_writel(xhci, t2, port_array[port_index]); 778 xhci_writel(xhci, t2, port_array[port_index]);
779 779
780 if (DEV_HIGHSPEED(t1)) { 780 if (hcd->speed != HCD_USB3) {
781 /* enable remote wake up for USB 2.0 */ 781 /* enable remote wake up for USB 2.0 */
782 u32 __iomem *addr; 782 u32 __iomem *addr;
783 u32 tmp; 783 u32 tmp;
@@ -866,6 +866,21 @@ int xhci_bus_resume(struct usb_hcd *hcd)
866 temp |= PORT_LINK_STROBE | XDEV_U0; 866 temp |= PORT_LINK_STROBE | XDEV_U0;
867 xhci_writel(xhci, temp, port_array[port_index]); 867 xhci_writel(xhci, temp, port_array[port_index]);
868 } 868 }
869 /* wait for the port to enter U0 and report port link
870 * state change.
871 */
872 spin_unlock_irqrestore(&xhci->lock, flags);
873 msleep(20);
874 spin_lock_irqsave(&xhci->lock, flags);
875
876 /* Clear PLC */
877 temp = xhci_readl(xhci, port_array[port_index]);
878 if (temp & PORT_PLC) {
879 temp = xhci_port_state_to_neutral(temp);
880 temp |= PORT_PLC;
881 xhci_writel(xhci, temp, port_array[port_index]);
882 }
883
869 slot_id = xhci_find_slot_id_by_port(hcd, 884 slot_id = xhci_find_slot_id_by_port(hcd,
870 xhci, port_index + 1); 885 xhci, port_index + 1);
871 if (slot_id) 886 if (slot_id)
@@ -873,7 +888,7 @@ int xhci_bus_resume(struct usb_hcd *hcd)
873 } else 888 } else
874 xhci_writel(xhci, temp, port_array[port_index]); 889 xhci_writel(xhci, temp, port_array[port_index]);
875 890
876 if (DEV_HIGHSPEED(temp)) { 891 if (hcd->speed != HCD_USB3) {
877 /* disable remote wake up for USB 2.0 */ 892 /* disable remote wake up for USB 2.0 */
878 u32 __iomem *addr; 893 u32 __iomem *addr;
879 u32 tmp; 894 u32 tmp;
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index a003e79aacdc..627f3438028c 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -846,7 +846,7 @@ static u32 xhci_find_real_port_number(struct xhci_hcd *xhci,
846 * Skip ports that don't have known speeds, or have duplicate 846 * Skip ports that don't have known speeds, or have duplicate
847 * Extended Capabilities port speed entries. 847 * Extended Capabilities port speed entries.
848 */ 848 */
849 if (port_speed == 0 || port_speed == -1) 849 if (port_speed == 0 || port_speed == DUPLICATE_ENTRY)
850 continue; 850 continue;
851 851
852 /* 852 /*
@@ -974,6 +974,47 @@ int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *ud
974 return 0; 974 return 0;
975} 975}
976 976
977/*
978 * Convert interval expressed as 2^(bInterval - 1) == interval into
979 * straight exponent value 2^n == interval.
980 *
981 */
982static unsigned int xhci_parse_exponent_interval(struct usb_device *udev,
983 struct usb_host_endpoint *ep)
984{
985 unsigned int interval;
986
987 interval = clamp_val(ep->desc.bInterval, 1, 16) - 1;
988 if (interval != ep->desc.bInterval - 1)
989 dev_warn(&udev->dev,
990 "ep %#x - rounding interval to %d microframes\n",
991 ep->desc.bEndpointAddress,
992 1 << interval);
993
994 return interval;
995}
996
997/*
998 * Convert bInterval expressed in frames (in 1-255 range) to exponent of
999 * microframes, rounded down to nearest power of 2.
1000 */
1001static unsigned int xhci_parse_frame_interval(struct usb_device *udev,
1002 struct usb_host_endpoint *ep)
1003{
1004 unsigned int interval;
1005
1006 interval = fls(8 * ep->desc.bInterval) - 1;
1007 interval = clamp_val(interval, 3, 10);
1008 if ((1 << interval) != 8 * ep->desc.bInterval)
1009 dev_warn(&udev->dev,
1010 "ep %#x - rounding interval to %d microframes, ep desc says %d microframes\n",
1011 ep->desc.bEndpointAddress,
1012 1 << interval,
1013 8 * ep->desc.bInterval);
1014
1015 return interval;
1016}
1017
977/* Return the polling or NAK interval. 1018/* Return the polling or NAK interval.
978 * 1019 *
979 * The polling interval is expressed in "microframes". If xHCI's Interval field 1020 * The polling interval is expressed in "microframes". If xHCI's Interval field
@@ -982,7 +1023,7 @@ int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *ud
982 * The NAK interval is one NAK per 1 to 255 microframes, or no NAKs if interval 1023 * The NAK interval is one NAK per 1 to 255 microframes, or no NAKs if interval
983 * is set to 0. 1024 * is set to 0.
984 */ 1025 */
985static inline unsigned int xhci_get_endpoint_interval(struct usb_device *udev, 1026static unsigned int xhci_get_endpoint_interval(struct usb_device *udev,
986 struct usb_host_endpoint *ep) 1027 struct usb_host_endpoint *ep)
987{ 1028{
988 unsigned int interval = 0; 1029 unsigned int interval = 0;
@@ -991,45 +1032,38 @@ static inline unsigned int xhci_get_endpoint_interval(struct usb_device *udev,
991 case USB_SPEED_HIGH: 1032 case USB_SPEED_HIGH:
992 /* Max NAK rate */ 1033 /* Max NAK rate */
993 if (usb_endpoint_xfer_control(&ep->desc) || 1034 if (usb_endpoint_xfer_control(&ep->desc) ||
994 usb_endpoint_xfer_bulk(&ep->desc)) 1035 usb_endpoint_xfer_bulk(&ep->desc)) {
995 interval = ep->desc.bInterval; 1036 interval = ep->desc.bInterval;
1037 break;
1038 }
996 /* Fall through - SS and HS isoc/int have same decoding */ 1039 /* Fall through - SS and HS isoc/int have same decoding */
1040
997 case USB_SPEED_SUPER: 1041 case USB_SPEED_SUPER:
998 if (usb_endpoint_xfer_int(&ep->desc) || 1042 if (usb_endpoint_xfer_int(&ep->desc) ||
999 usb_endpoint_xfer_isoc(&ep->desc)) { 1043 usb_endpoint_xfer_isoc(&ep->desc)) {
1000 if (ep->desc.bInterval == 0) 1044 interval = xhci_parse_exponent_interval(udev, ep);
1001 interval = 0;
1002 else
1003 interval = ep->desc.bInterval - 1;
1004 if (interval > 15)
1005 interval = 15;
1006 if (interval != ep->desc.bInterval + 1)
1007 dev_warn(&udev->dev, "ep %#x - rounding interval to %d microframes\n",
1008 ep->desc.bEndpointAddress, 1 << interval);
1009 } 1045 }
1010 break; 1046 break;
1011 /* Convert bInterval (in 1-255 frames) to microframes and round down to 1047
1012 * nearest power of 2.
1013 */
1014 case USB_SPEED_FULL: 1048 case USB_SPEED_FULL:
1049 if (usb_endpoint_xfer_int(&ep->desc)) {
1050 interval = xhci_parse_exponent_interval(udev, ep);
1051 break;
1052 }
1053 /*
1054 * Fall through for isochronous endpoint interval decoding
1055 * since it uses the same rules as low speed interrupt
1056 * endpoints.
1057 */
1058
1015 case USB_SPEED_LOW: 1059 case USB_SPEED_LOW:
1016 if (usb_endpoint_xfer_int(&ep->desc) || 1060 if (usb_endpoint_xfer_int(&ep->desc) ||
1017 usb_endpoint_xfer_isoc(&ep->desc)) { 1061 usb_endpoint_xfer_isoc(&ep->desc)) {
1018 interval = fls(8*ep->desc.bInterval) - 1; 1062
1019 if (interval > 10) 1063 interval = xhci_parse_frame_interval(udev, ep);
1020 interval = 10;
1021 if (interval < 3)
1022 interval = 3;
1023 if ((1 << interval) != 8*ep->desc.bInterval)
1024 dev_warn(&udev->dev,
1025 "ep %#x - rounding interval"
1026 " to %d microframes, "
1027 "ep desc says %d microframes\n",
1028 ep->desc.bEndpointAddress,
1029 1 << interval,
1030 8*ep->desc.bInterval);
1031 } 1064 }
1032 break; 1065 break;
1066
1033 default: 1067 default:
1034 BUG(); 1068 BUG();
1035 } 1069 }
@@ -1041,7 +1075,7 @@ static inline unsigned int xhci_get_endpoint_interval(struct usb_device *udev,
1041 * transaction opportunities per microframe", but that goes in the Max Burst 1075 * transaction opportunities per microframe", but that goes in the Max Burst
1042 * endpoint context field. 1076 * endpoint context field.
1043 */ 1077 */
1044static inline u32 xhci_get_endpoint_mult(struct usb_device *udev, 1078static u32 xhci_get_endpoint_mult(struct usb_device *udev,
1045 struct usb_host_endpoint *ep) 1079 struct usb_host_endpoint *ep)
1046{ 1080{
1047 if (udev->speed != USB_SPEED_SUPER || 1081 if (udev->speed != USB_SPEED_SUPER ||
@@ -1050,7 +1084,7 @@ static inline u32 xhci_get_endpoint_mult(struct usb_device *udev,
1050 return ep->ss_ep_comp.bmAttributes; 1084 return ep->ss_ep_comp.bmAttributes;
1051} 1085}
1052 1086
1053static inline u32 xhci_get_endpoint_type(struct usb_device *udev, 1087static u32 xhci_get_endpoint_type(struct usb_device *udev,
1054 struct usb_host_endpoint *ep) 1088 struct usb_host_endpoint *ep)
1055{ 1089{
1056 int in; 1090 int in;
@@ -1084,7 +1118,7 @@ static inline u32 xhci_get_endpoint_type(struct usb_device *udev,
1084 * Basically, this is the maxpacket size, multiplied by the burst size 1118 * Basically, this is the maxpacket size, multiplied by the burst size
1085 * and mult size. 1119 * and mult size.
1086 */ 1120 */
1087static inline u32 xhci_get_max_esit_payload(struct xhci_hcd *xhci, 1121static u32 xhci_get_max_esit_payload(struct xhci_hcd *xhci,
1088 struct usb_device *udev, 1122 struct usb_device *udev,
1089 struct usb_host_endpoint *ep) 1123 struct usb_host_endpoint *ep)
1090{ 1124{
@@ -1727,12 +1761,12 @@ static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports,
1727 * found a similar duplicate. 1761 * found a similar duplicate.
1728 */ 1762 */
1729 if (xhci->port_array[i] != major_revision && 1763 if (xhci->port_array[i] != major_revision &&
1730 xhci->port_array[i] != (u8) -1) { 1764 xhci->port_array[i] != DUPLICATE_ENTRY) {
1731 if (xhci->port_array[i] == 0x03) 1765 if (xhci->port_array[i] == 0x03)
1732 xhci->num_usb3_ports--; 1766 xhci->num_usb3_ports--;
1733 else 1767 else
1734 xhci->num_usb2_ports--; 1768 xhci->num_usb2_ports--;
1735 xhci->port_array[i] = (u8) -1; 1769 xhci->port_array[i] = DUPLICATE_ENTRY;
1736 } 1770 }
1737 /* FIXME: Should we disable the port? */ 1771 /* FIXME: Should we disable the port? */
1738 continue; 1772 continue;
@@ -1831,7 +1865,7 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags)
1831 for (i = 0; i < num_ports; i++) { 1865 for (i = 0; i < num_ports; i++) {
1832 if (xhci->port_array[i] == 0x03 || 1866 if (xhci->port_array[i] == 0x03 ||
1833 xhci->port_array[i] == 0 || 1867 xhci->port_array[i] == 0 ||
1834 xhci->port_array[i] == -1) 1868 xhci->port_array[i] == DUPLICATE_ENTRY)
1835 continue; 1869 continue;
1836 1870
1837 xhci->usb2_ports[port_index] = 1871 xhci->usb2_ports[port_index] =
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index ceea9f33491c..a10494c2f3c7 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -114,6 +114,10 @@ static int xhci_pci_setup(struct usb_hcd *hcd)
114 if (pdev->vendor == PCI_VENDOR_ID_NEC) 114 if (pdev->vendor == PCI_VENDOR_ID_NEC)
115 xhci->quirks |= XHCI_NEC_HOST; 115 xhci->quirks |= XHCI_NEC_HOST;
116 116
117 /* AMD PLL quirk */
118 if (pdev->vendor == PCI_VENDOR_ID_AMD && usb_amd_find_chipset_info())
119 xhci->quirks |= XHCI_AMD_PLL_FIX;
120
117 /* Make sure the HC is halted. */ 121 /* Make sure the HC is halted. */
118 retval = xhci_halt(xhci); 122 retval = xhci_halt(xhci);
119 if (retval) 123 if (retval)
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index cfc1ad92473f..7437386a9a50 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -93,7 +93,7 @@ dma_addr_t xhci_trb_virt_to_dma(struct xhci_segment *seg,
93/* Does this link TRB point to the first segment in a ring, 93/* Does this link TRB point to the first segment in a ring,
94 * or was the previous TRB the last TRB on the last segment in the ERST? 94 * or was the previous TRB the last TRB on the last segment in the ERST?
95 */ 95 */
96static inline bool last_trb_on_last_seg(struct xhci_hcd *xhci, struct xhci_ring *ring, 96static bool last_trb_on_last_seg(struct xhci_hcd *xhci, struct xhci_ring *ring,
97 struct xhci_segment *seg, union xhci_trb *trb) 97 struct xhci_segment *seg, union xhci_trb *trb)
98{ 98{
99 if (ring == xhci->event_ring) 99 if (ring == xhci->event_ring)
@@ -107,7 +107,7 @@ static inline bool last_trb_on_last_seg(struct xhci_hcd *xhci, struct xhci_ring
107 * segment? I.e. would the updated event TRB pointer step off the end of the 107 * segment? I.e. would the updated event TRB pointer step off the end of the
108 * event seg? 108 * event seg?
109 */ 109 */
110static inline int last_trb(struct xhci_hcd *xhci, struct xhci_ring *ring, 110static int last_trb(struct xhci_hcd *xhci, struct xhci_ring *ring,
111 struct xhci_segment *seg, union xhci_trb *trb) 111 struct xhci_segment *seg, union xhci_trb *trb)
112{ 112{
113 if (ring == xhci->event_ring) 113 if (ring == xhci->event_ring)
@@ -116,7 +116,7 @@ static inline int last_trb(struct xhci_hcd *xhci, struct xhci_ring *ring,
116 return (trb->link.control & TRB_TYPE_BITMASK) == TRB_TYPE(TRB_LINK); 116 return (trb->link.control & TRB_TYPE_BITMASK) == TRB_TYPE(TRB_LINK);
117} 117}
118 118
119static inline int enqueue_is_link_trb(struct xhci_ring *ring) 119static int enqueue_is_link_trb(struct xhci_ring *ring)
120{ 120{
121 struct xhci_link_trb *link = &ring->enqueue->link; 121 struct xhci_link_trb *link = &ring->enqueue->link;
122 return ((link->control & TRB_TYPE_BITMASK) == TRB_TYPE(TRB_LINK)); 122 return ((link->control & TRB_TYPE_BITMASK) == TRB_TYPE(TRB_LINK));
@@ -592,7 +592,7 @@ void xhci_queue_new_dequeue_state(struct xhci_hcd *xhci,
592 ep->ep_state |= SET_DEQ_PENDING; 592 ep->ep_state |= SET_DEQ_PENDING;
593} 593}
594 594
595static inline void xhci_stop_watchdog_timer_in_irq(struct xhci_hcd *xhci, 595static void xhci_stop_watchdog_timer_in_irq(struct xhci_hcd *xhci,
596 struct xhci_virt_ep *ep) 596 struct xhci_virt_ep *ep)
597{ 597{
598 ep->ep_state &= ~EP_HALT_PENDING; 598 ep->ep_state &= ~EP_HALT_PENDING;
@@ -619,6 +619,13 @@ static void xhci_giveback_urb_in_irq(struct xhci_hcd *xhci,
619 619
620 /* Only giveback urb when this is the last td in urb */ 620 /* Only giveback urb when this is the last td in urb */
621 if (urb_priv->td_cnt == urb_priv->length) { 621 if (urb_priv->td_cnt == urb_priv->length) {
622 if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) {
623 xhci_to_hcd(xhci)->self.bandwidth_isoc_reqs--;
624 if (xhci_to_hcd(xhci)->self.bandwidth_isoc_reqs == 0) {
625 if (xhci->quirks & XHCI_AMD_PLL_FIX)
626 usb_amd_quirk_pll_enable();
627 }
628 }
622 usb_hcd_unlink_urb_from_ep(hcd, urb); 629 usb_hcd_unlink_urb_from_ep(hcd, urb);
623 xhci_dbg(xhci, "Giveback %s URB %p\n", adjective, urb); 630 xhci_dbg(xhci, "Giveback %s URB %p\n", adjective, urb);
624 631
@@ -1209,7 +1216,7 @@ static unsigned int find_faked_portnum_from_hw_portnum(struct usb_hcd *hcd,
1209 * Skip ports that don't have known speeds, or have duplicate 1216 * Skip ports that don't have known speeds, or have duplicate
1210 * Extended Capabilities port speed entries. 1217 * Extended Capabilities port speed entries.
1211 */ 1218 */
1212 if (port_speed == 0 || port_speed == -1) 1219 if (port_speed == 0 || port_speed == DUPLICATE_ENTRY)
1213 continue; 1220 continue;
1214 1221
1215 /* 1222 /*
@@ -1235,6 +1242,7 @@ static void handle_port_status(struct xhci_hcd *xhci,
1235 u8 major_revision; 1242 u8 major_revision;
1236 struct xhci_bus_state *bus_state; 1243 struct xhci_bus_state *bus_state;
1237 u32 __iomem **port_array; 1244 u32 __iomem **port_array;
1245 bool bogus_port_status = false;
1238 1246
1239 /* Port status change events always have a successful completion code */ 1247 /* Port status change events always have a successful completion code */
1240 if (GET_COMP_CODE(event->generic.field[2]) != COMP_SUCCESS) { 1248 if (GET_COMP_CODE(event->generic.field[2]) != COMP_SUCCESS) {
@@ -1247,6 +1255,7 @@ static void handle_port_status(struct xhci_hcd *xhci,
1247 max_ports = HCS_MAX_PORTS(xhci->hcs_params1); 1255 max_ports = HCS_MAX_PORTS(xhci->hcs_params1);
1248 if ((port_id <= 0) || (port_id > max_ports)) { 1256 if ((port_id <= 0) || (port_id > max_ports)) {
1249 xhci_warn(xhci, "Invalid port id %d\n", port_id); 1257 xhci_warn(xhci, "Invalid port id %d\n", port_id);
1258 bogus_port_status = true;
1250 goto cleanup; 1259 goto cleanup;
1251 } 1260 }
1252 1261
@@ -1258,12 +1267,14 @@ static void handle_port_status(struct xhci_hcd *xhci,
1258 xhci_warn(xhci, "Event for port %u not in " 1267 xhci_warn(xhci, "Event for port %u not in "
1259 "Extended Capabilities, ignoring.\n", 1268 "Extended Capabilities, ignoring.\n",
1260 port_id); 1269 port_id);
1270 bogus_port_status = true;
1261 goto cleanup; 1271 goto cleanup;
1262 } 1272 }
1263 if (major_revision == (u8) -1) { 1273 if (major_revision == DUPLICATE_ENTRY) {
1264 xhci_warn(xhci, "Event for port %u duplicated in" 1274 xhci_warn(xhci, "Event for port %u duplicated in"
1265 "Extended Capabilities, ignoring.\n", 1275 "Extended Capabilities, ignoring.\n",
1266 port_id); 1276 port_id);
1277 bogus_port_status = true;
1267 goto cleanup; 1278 goto cleanup;
1268 } 1279 }
1269 1280
@@ -1335,6 +1346,13 @@ cleanup:
1335 /* Update event ring dequeue pointer before dropping the lock */ 1346 /* Update event ring dequeue pointer before dropping the lock */
1336 inc_deq(xhci, xhci->event_ring, true); 1347 inc_deq(xhci, xhci->event_ring, true);
1337 1348
1349 /* Don't make the USB core poll the roothub if we got a bad port status
1350 * change event. Besides, at that point we can't tell which roothub
1351 * (USB 2.0 or USB 3.0) to kick.
1352 */
1353 if (bogus_port_status)
1354 return;
1355
1338 spin_unlock(&xhci->lock); 1356 spin_unlock(&xhci->lock);
1339 /* Pass this up to the core */ 1357 /* Pass this up to the core */
1340 usb_hcd_poll_rh_status(hcd); 1358 usb_hcd_poll_rh_status(hcd);
@@ -1554,8 +1572,17 @@ td_cleanup:
1554 1572
1555 urb_priv->td_cnt++; 1573 urb_priv->td_cnt++;
1556 /* Giveback the urb when all the tds are completed */ 1574 /* Giveback the urb when all the tds are completed */
1557 if (urb_priv->td_cnt == urb_priv->length) 1575 if (urb_priv->td_cnt == urb_priv->length) {
1558 ret = 1; 1576 ret = 1;
1577 if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) {
1578 xhci_to_hcd(xhci)->self.bandwidth_isoc_reqs--;
1579 if (xhci_to_hcd(xhci)->self.bandwidth_isoc_reqs
1580 == 0) {
1581 if (xhci->quirks & XHCI_AMD_PLL_FIX)
1582 usb_amd_quirk_pll_enable();
1583 }
1584 }
1585 }
1559 } 1586 }
1560 1587
1561 return ret; 1588 return ret;
@@ -1675,71 +1702,52 @@ static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td,
1675 struct urb_priv *urb_priv; 1702 struct urb_priv *urb_priv;
1676 int idx; 1703 int idx;
1677 int len = 0; 1704 int len = 0;
1678 int skip_td = 0;
1679 union xhci_trb *cur_trb; 1705 union xhci_trb *cur_trb;
1680 struct xhci_segment *cur_seg; 1706 struct xhci_segment *cur_seg;
1707 struct usb_iso_packet_descriptor *frame;
1681 u32 trb_comp_code; 1708 u32 trb_comp_code;
1709 bool skip_td = false;
1682 1710
1683 ep_ring = xhci_dma_to_transfer_ring(ep, event->buffer); 1711 ep_ring = xhci_dma_to_transfer_ring(ep, event->buffer);
1684 trb_comp_code = GET_COMP_CODE(event->transfer_len); 1712 trb_comp_code = GET_COMP_CODE(event->transfer_len);
1685 urb_priv = td->urb->hcpriv; 1713 urb_priv = td->urb->hcpriv;
1686 idx = urb_priv->td_cnt; 1714 idx = urb_priv->td_cnt;
1715 frame = &td->urb->iso_frame_desc[idx];
1687 1716
1688 if (ep->skip) { 1717 /* handle completion code */
1689 /* The transfer is partly done */ 1718 switch (trb_comp_code) {
1690 *status = -EXDEV; 1719 case COMP_SUCCESS:
1691 td->urb->iso_frame_desc[idx].status = -EXDEV; 1720 frame->status = 0;
1692 } else { 1721 xhci_dbg(xhci, "Successful isoc transfer!\n");
1693 /* handle completion code */ 1722 break;
1694 switch (trb_comp_code) { 1723 case COMP_SHORT_TX:
1695 case COMP_SUCCESS: 1724 frame->status = td->urb->transfer_flags & URB_SHORT_NOT_OK ?
1696 td->urb->iso_frame_desc[idx].status = 0; 1725 -EREMOTEIO : 0;
1697 xhci_dbg(xhci, "Successful isoc transfer!\n"); 1726 break;
1698 break; 1727 case COMP_BW_OVER:
1699 case COMP_SHORT_TX: 1728 frame->status = -ECOMM;
1700 if (td->urb->transfer_flags & URB_SHORT_NOT_OK) 1729 skip_td = true;
1701 td->urb->iso_frame_desc[idx].status = 1730 break;
1702 -EREMOTEIO; 1731 case COMP_BUFF_OVER:
1703 else 1732 case COMP_BABBLE:
1704 td->urb->iso_frame_desc[idx].status = 0; 1733 frame->status = -EOVERFLOW;
1705 break; 1734 skip_td = true;
1706 case COMP_BW_OVER: 1735 break;
1707 td->urb->iso_frame_desc[idx].status = -ECOMM; 1736 case COMP_STALL:
1708 skip_td = 1; 1737 frame->status = -EPROTO;
1709 break; 1738 skip_td = true;
1710 case COMP_BUFF_OVER: 1739 break;
1711 case COMP_BABBLE: 1740 case COMP_STOP:
1712 td->urb->iso_frame_desc[idx].status = -EOVERFLOW; 1741 case COMP_STOP_INVAL:
1713 skip_td = 1; 1742 break;
1714 break; 1743 default:
1715 case COMP_STALL: 1744 frame->status = -1;
1716 td->urb->iso_frame_desc[idx].status = -EPROTO; 1745 break;
1717 skip_td = 1;
1718 break;
1719 case COMP_STOP:
1720 case COMP_STOP_INVAL:
1721 break;
1722 default:
1723 td->urb->iso_frame_desc[idx].status = -1;
1724 break;
1725 }
1726 }
1727
1728 /* calc actual length */
1729 if (ep->skip) {
1730 td->urb->iso_frame_desc[idx].actual_length = 0;
1731 /* Update ring dequeue pointer */
1732 while (ep_ring->dequeue != td->last_trb)
1733 inc_deq(xhci, ep_ring, false);
1734 inc_deq(xhci, ep_ring, false);
1735 return finish_td(xhci, td, event_trb, event, ep, status, true);
1736 } 1746 }
1737 1747
1738 if (trb_comp_code == COMP_SUCCESS || skip_td == 1) { 1748 if (trb_comp_code == COMP_SUCCESS || skip_td) {
1739 td->urb->iso_frame_desc[idx].actual_length = 1749 frame->actual_length = frame->length;
1740 td->urb->iso_frame_desc[idx].length; 1750 td->urb->actual_length += frame->length;
1741 td->urb->actual_length +=
1742 td->urb->iso_frame_desc[idx].length;
1743 } else { 1751 } else {
1744 for (cur_trb = ep_ring->dequeue, 1752 for (cur_trb = ep_ring->dequeue,
1745 cur_seg = ep_ring->deq_seg; cur_trb != event_trb; 1753 cur_seg = ep_ring->deq_seg; cur_trb != event_trb;
@@ -1755,7 +1763,7 @@ static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td,
1755 TRB_LEN(event->transfer_len); 1763 TRB_LEN(event->transfer_len);
1756 1764
1757 if (trb_comp_code != COMP_STOP_INVAL) { 1765 if (trb_comp_code != COMP_STOP_INVAL) {
1758 td->urb->iso_frame_desc[idx].actual_length = len; 1766 frame->actual_length = len;
1759 td->urb->actual_length += len; 1767 td->urb->actual_length += len;
1760 } 1768 }
1761 } 1769 }
@@ -1766,6 +1774,35 @@ static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td,
1766 return finish_td(xhci, td, event_trb, event, ep, status, false); 1774 return finish_td(xhci, td, event_trb, event, ep, status, false);
1767} 1775}
1768 1776
1777static int skip_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td,
1778 struct xhci_transfer_event *event,
1779 struct xhci_virt_ep *ep, int *status)
1780{
1781 struct xhci_ring *ep_ring;
1782 struct urb_priv *urb_priv;
1783 struct usb_iso_packet_descriptor *frame;
1784 int idx;
1785
1786 ep_ring = xhci_dma_to_transfer_ring(ep, event->buffer);
1787 urb_priv = td->urb->hcpriv;
1788 idx = urb_priv->td_cnt;
1789 frame = &td->urb->iso_frame_desc[idx];
1790
1791 /* The transfer is partly done */
1792 *status = -EXDEV;
1793 frame->status = -EXDEV;
1794
1795 /* calc actual length */
1796 frame->actual_length = 0;
1797
1798 /* Update ring dequeue pointer */
1799 while (ep_ring->dequeue != td->last_trb)
1800 inc_deq(xhci, ep_ring, false);
1801 inc_deq(xhci, ep_ring, false);
1802
1803 return finish_td(xhci, td, NULL, event, ep, status, true);
1804}
1805
1769/* 1806/*
1770 * Process bulk and interrupt tds, update urb status and actual_length. 1807 * Process bulk and interrupt tds, update urb status and actual_length.
1771 */ 1808 */
@@ -2024,36 +2061,42 @@ static int handle_tx_event(struct xhci_hcd *xhci,
2024 } 2061 }
2025 2062
2026 td = list_entry(ep_ring->td_list.next, struct xhci_td, td_list); 2063 td = list_entry(ep_ring->td_list.next, struct xhci_td, td_list);
2064
2027 /* Is this a TRB in the currently executing TD? */ 2065 /* Is this a TRB in the currently executing TD? */
2028 event_seg = trb_in_td(ep_ring->deq_seg, ep_ring->dequeue, 2066 event_seg = trb_in_td(ep_ring->deq_seg, ep_ring->dequeue,
2029 td->last_trb, event_dma); 2067 td->last_trb, event_dma);
2030 if (event_seg && ep->skip) { 2068 if (!event_seg) {
2069 if (!ep->skip ||
2070 !usb_endpoint_xfer_isoc(&td->urb->ep->desc)) {
2071 /* HC is busted, give up! */
2072 xhci_err(xhci,
2073 "ERROR Transfer event TRB DMA ptr not "
2074 "part of current TD\n");
2075 return -ESHUTDOWN;
2076 }
2077
2078 ret = skip_isoc_td(xhci, td, event, ep, &status);
2079 goto cleanup;
2080 }
2081
2082 if (ep->skip) {
2031 xhci_dbg(xhci, "Found td. Clear skip flag.\n"); 2083 xhci_dbg(xhci, "Found td. Clear skip flag.\n");
2032 ep->skip = false; 2084 ep->skip = false;
2033 } 2085 }
2034 if (!event_seg &&
2035 (!ep->skip || !usb_endpoint_xfer_isoc(&td->urb->ep->desc))) {
2036 /* HC is busted, give up! */
2037 xhci_err(xhci, "ERROR Transfer event TRB DMA ptr not "
2038 "part of current TD\n");
2039 return -ESHUTDOWN;
2040 }
2041 2086
2042 if (event_seg) { 2087 event_trb = &event_seg->trbs[(event_dma - event_seg->dma) /
2043 event_trb = &event_seg->trbs[(event_dma - 2088 sizeof(*event_trb)];
2044 event_seg->dma) / sizeof(*event_trb)]; 2089 /*
2045 /* 2090 * No-op TRB should not trigger interrupts.
2046 * No-op TRB should not trigger interrupts. 2091 * If event_trb is a no-op TRB, it means the
2047 * If event_trb is a no-op TRB, it means the 2092 * corresponding TD has been cancelled. Just ignore
2048 * corresponding TD has been cancelled. Just ignore 2093 * the TD.
2049 * the TD. 2094 */
2050 */ 2095 if ((event_trb->generic.field[3] & TRB_TYPE_BITMASK)
2051 if ((event_trb->generic.field[3] & TRB_TYPE_BITMASK) 2096 == TRB_TYPE(TRB_TR_NOOP)) {
2052 == TRB_TYPE(TRB_TR_NOOP)) { 2097 xhci_dbg(xhci,
2053 xhci_dbg(xhci, "event_trb is a no-op TRB. " 2098 "event_trb is a no-op TRB. Skip it\n");
2054 "Skip it\n"); 2099 goto cleanup;
2055 goto cleanup;
2056 }
2057 } 2100 }
2058 2101
2059 /* Now update the urb's actual_length and give back to 2102 /* Now update the urb's actual_length and give back to
@@ -3126,6 +3169,12 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
3126 } 3169 }
3127 } 3170 }
3128 3171
3172 if (xhci_to_hcd(xhci)->self.bandwidth_isoc_reqs == 0) {
3173 if (xhci->quirks & XHCI_AMD_PLL_FIX)
3174 usb_amd_quirk_pll_disable();
3175 }
3176 xhci_to_hcd(xhci)->self.bandwidth_isoc_reqs++;
3177
3129 giveback_first_trb(xhci, slot_id, ep_index, urb->stream_id, 3178 giveback_first_trb(xhci, slot_id, ep_index, urb->stream_id,
3130 start_cycle, start_trb); 3179 start_cycle, start_trb);
3131 return 0; 3180 return 0;
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 9a3645fd759b..81b976e45880 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -550,6 +550,9 @@ void xhci_stop(struct usb_hcd *hcd)
550 del_timer_sync(&xhci->event_ring_timer); 550 del_timer_sync(&xhci->event_ring_timer);
551#endif 551#endif
552 552
553 if (xhci->quirks & XHCI_AMD_PLL_FIX)
554 usb_amd_dev_put();
555
553 xhci_dbg(xhci, "// Disabling event ring interrupts\n"); 556 xhci_dbg(xhci, "// Disabling event ring interrupts\n");
554 temp = xhci_readl(xhci, &xhci->op_regs->status); 557 temp = xhci_readl(xhci, &xhci->op_regs->status);
555 xhci_writel(xhci, temp & ~STS_EINT, &xhci->op_regs->status); 558 xhci_writel(xhci, temp & ~STS_EINT, &xhci->op_regs->status);
@@ -741,7 +744,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
741 int retval; 744 int retval;
742 745
743 /* Wait a bit if either of the roothubs need to settle from the 746 /* Wait a bit if either of the roothubs need to settle from the
744 * transistion into bus suspend. 747 * transition into bus suspend.
745 */ 748 */
746 if (time_before(jiffies, xhci->bus_state[0].next_statechange) || 749 if (time_before(jiffies, xhci->bus_state[0].next_statechange) ||
747 time_before(jiffies, 750 time_before(jiffies,
@@ -771,7 +774,9 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
771 774
772 /* If restore operation fails, re-initialize the HC during resume */ 775 /* If restore operation fails, re-initialize the HC during resume */
773 if ((temp & STS_SRE) || hibernated) { 776 if ((temp & STS_SRE) || hibernated) {
774 usb_root_hub_lost_power(hcd->self.root_hub); 777 /* Let the USB core know _both_ roothubs lost power. */
778 usb_root_hub_lost_power(xhci->main_hcd->self.root_hub);
779 usb_root_hub_lost_power(xhci->shared_hcd->self.root_hub);
775 780
776 xhci_dbg(xhci, "Stop HCD\n"); 781 xhci_dbg(xhci, "Stop HCD\n");
777 xhci_halt(xhci); 782 xhci_halt(xhci);
@@ -2072,7 +2077,7 @@ int xhci_alloc_streams(struct usb_hcd *hcd, struct usb_device *udev,
2072 return -EINVAL; 2077 return -EINVAL;
2073 } 2078 }
2074 vdev = xhci->devs[udev->slot_id]; 2079 vdev = xhci->devs[udev->slot_id];
2075 /* Mark each endpoint as being in transistion, so 2080 /* Mark each endpoint as being in transition, so
2076 * xhci_urb_enqueue() will reject all URBs. 2081 * xhci_urb_enqueue() will reject all URBs.
2077 */ 2082 */
2078 for (i = 0; i < num_eps; i++) { 2083 for (i = 0; i < num_eps; i++) {
@@ -2386,10 +2391,18 @@ int xhci_discover_or_reset_device(struct usb_hcd *hcd, struct usb_device *udev)
2386 /* Everything but endpoint 0 is disabled, so free or cache the rings. */ 2391 /* Everything but endpoint 0 is disabled, so free or cache the rings. */
2387 last_freed_endpoint = 1; 2392 last_freed_endpoint = 1;
2388 for (i = 1; i < 31; ++i) { 2393 for (i = 1; i < 31; ++i) {
2389 if (!virt_dev->eps[i].ring) 2394 struct xhci_virt_ep *ep = &virt_dev->eps[i];
2390 continue; 2395
2391 xhci_free_or_cache_endpoint_ring(xhci, virt_dev, i); 2396 if (ep->ep_state & EP_HAS_STREAMS) {
2392 last_freed_endpoint = i; 2397 xhci_free_stream_info(xhci, ep->stream_info);
2398 ep->stream_info = NULL;
2399 ep->ep_state &= ~EP_HAS_STREAMS;
2400 }
2401
2402 if (ep->ring) {
2403 xhci_free_or_cache_endpoint_ring(xhci, virt_dev, i);
2404 last_freed_endpoint = i;
2405 }
2393 } 2406 }
2394 xhci_dbg(xhci, "Output context after successful reset device cmd:\n"); 2407 xhci_dbg(xhci, "Output context after successful reset device cmd:\n");
2395 xhci_dbg_ctx(xhci, virt_dev->out_ctx, last_freed_endpoint); 2408 xhci_dbg_ctx(xhci, virt_dev->out_ctx, last_freed_endpoint);
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 711de253bc0f..ba1be6b7cc6d 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -30,6 +30,7 @@
30 30
31/* Code sharing between pci-quirks and xhci hcd */ 31/* Code sharing between pci-quirks and xhci hcd */
32#include "xhci-ext-caps.h" 32#include "xhci-ext-caps.h"
33#include "pci-quirks.h"
33 34
34/* xHCI PCI Configuration Registers */ 35/* xHCI PCI Configuration Registers */
35#define XHCI_SBRN_OFFSET (0x60) 36#define XHCI_SBRN_OFFSET (0x60)
@@ -232,7 +233,7 @@ struct xhci_op_regs {
232 * notification type that matches a bit set in this bit field. 233 * notification type that matches a bit set in this bit field.
233 */ 234 */
234#define DEV_NOTE_MASK (0xffff) 235#define DEV_NOTE_MASK (0xffff)
235#define ENABLE_DEV_NOTE(x) (1 << x) 236#define ENABLE_DEV_NOTE(x) (1 << (x))
236/* Most of the device notification types should only be used for debug. 237/* Most of the device notification types should only be used for debug.
237 * SW does need to pay attention to function wake notifications. 238 * SW does need to pay attention to function wake notifications.
238 */ 239 */
@@ -348,6 +349,9 @@ struct xhci_op_regs {
348/* Initiate a warm port reset - complete when PORT_WRC is '1' */ 349/* Initiate a warm port reset - complete when PORT_WRC is '1' */
349#define PORT_WR (1 << 31) 350#define PORT_WR (1 << 31)
350 351
352/* We mark duplicate entries with -1 */
353#define DUPLICATE_ENTRY ((u8)(-1))
354
351/* Port Power Management Status and Control - port_power_base bitmasks */ 355/* Port Power Management Status and Control - port_power_base bitmasks */
352/* Inactivity timer value for transitions into U1, in microseconds. 356/* Inactivity timer value for transitions into U1, in microseconds.
353 * Timeout can be up to 127us. 0xFF means an infinite timeout. 357 * Timeout can be up to 127us. 0xFF means an infinite timeout.
@@ -601,11 +605,11 @@ struct xhci_ep_ctx {
601#define EP_STATE_STOPPED 3 605#define EP_STATE_STOPPED 3
602#define EP_STATE_ERROR 4 606#define EP_STATE_ERROR 4
603/* Mult - Max number of burtst within an interval, in EP companion desc. */ 607/* Mult - Max number of burtst within an interval, in EP companion desc. */
604#define EP_MULT(p) ((p & 0x3) << 8) 608#define EP_MULT(p) (((p) & 0x3) << 8)
605/* bits 10:14 are Max Primary Streams */ 609/* bits 10:14 are Max Primary Streams */
606/* bit 15 is Linear Stream Array */ 610/* bit 15 is Linear Stream Array */
607/* Interval - period between requests to an endpoint - 125u increments. */ 611/* Interval - period between requests to an endpoint - 125u increments. */
608#define EP_INTERVAL(p) ((p & 0xff) << 16) 612#define EP_INTERVAL(p) (((p) & 0xff) << 16)
609#define EP_INTERVAL_TO_UFRAMES(p) (1 << (((p) >> 16) & 0xff)) 613#define EP_INTERVAL_TO_UFRAMES(p) (1 << (((p) >> 16) & 0xff))
610#define EP_MAXPSTREAMS_MASK (0x1f << 10) 614#define EP_MAXPSTREAMS_MASK (0x1f << 10)
611#define EP_MAXPSTREAMS(p) (((p) << 10) & EP_MAXPSTREAMS_MASK) 615#define EP_MAXPSTREAMS(p) (((p) << 10) & EP_MAXPSTREAMS_MASK)
@@ -873,7 +877,7 @@ struct xhci_transfer_event {
873#define COMP_CMD_ABORT 25 877#define COMP_CMD_ABORT 25
874/* Stopped - transfer was terminated by a stop endpoint command */ 878/* Stopped - transfer was terminated by a stop endpoint command */
875#define COMP_STOP 26 879#define COMP_STOP 26
876/* Same as COMP_EP_STOPPED, but the transfered length in the event is invalid */ 880/* Same as COMP_EP_STOPPED, but the transferred length in the event is invalid */
877#define COMP_STOP_INVAL 27 881#define COMP_STOP_INVAL 27
878/* Control Abort Error - Debug Capability - control pipe aborted */ 882/* Control Abort Error - Debug Capability - control pipe aborted */
879#define COMP_DBG_ABORT 28 883#define COMP_DBG_ABORT 28
@@ -1276,6 +1280,7 @@ struct xhci_hcd {
1276#define XHCI_LINK_TRB_QUIRK (1 << 0) 1280#define XHCI_LINK_TRB_QUIRK (1 << 0)
1277#define XHCI_RESET_EP_QUIRK (1 << 1) 1281#define XHCI_RESET_EP_QUIRK (1 << 1)
1278#define XHCI_NEC_HOST (1 << 2) 1282#define XHCI_NEC_HOST (1 << 2)
1283#define XHCI_AMD_PLL_FIX (1 << 3)
1279 /* There are two roothubs to keep track of bus suspend info for */ 1284 /* There are two roothubs to keep track of bus suspend info for */
1280 struct xhci_bus_state bus_state[2]; 1285 struct xhci_bus_state bus_state[2];
1281 /* Is each xHCI roothub port a USB 3.0, USB 2.0, or USB 1.1 port? */ 1286 /* Is each xHCI roothub port a USB 3.0, USB 2.0, or USB 1.1 port? */