diff options
Diffstat (limited to 'drivers/usb/host')
-rw-r--r-- | drivers/usb/host/ehci-sched.c | 2 | ||||
-rw-r--r-- | drivers/usb/host/xhci-mem.c | 36 | ||||
-rw-r--r-- | drivers/usb/host/xhci-pci.c | 1 | ||||
-rw-r--r-- | drivers/usb/host/xhci-ring.c | 61 | ||||
-rw-r--r-- | drivers/usb/host/xhci.c | 22 | ||||
-rw-r--r-- | drivers/usb/host/xhci.h | 5 |
6 files changed, 73 insertions, 54 deletions
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c index b476daf49f6f..010f686d8881 100644 --- a/drivers/usb/host/ehci-sched.c +++ b/drivers/usb/host/ehci-sched.c | |||
@@ -1214,6 +1214,7 @@ itd_urb_transaction ( | |||
1214 | 1214 | ||
1215 | memset (itd, 0, sizeof *itd); | 1215 | memset (itd, 0, sizeof *itd); |
1216 | itd->itd_dma = itd_dma; | 1216 | itd->itd_dma = itd_dma; |
1217 | itd->frame = 9999; /* an invalid value */ | ||
1217 | list_add (&itd->itd_list, &sched->td_list); | 1218 | list_add (&itd->itd_list, &sched->td_list); |
1218 | } | 1219 | } |
1219 | spin_unlock_irqrestore (&ehci->lock, flags); | 1220 | spin_unlock_irqrestore (&ehci->lock, flags); |
@@ -1915,6 +1916,7 @@ sitd_urb_transaction ( | |||
1915 | 1916 | ||
1916 | memset (sitd, 0, sizeof *sitd); | 1917 | memset (sitd, 0, sizeof *sitd); |
1917 | sitd->sitd_dma = sitd_dma; | 1918 | sitd->sitd_dma = sitd_dma; |
1919 | sitd->frame = 9999; /* an invalid value */ | ||
1918 | list_add (&sitd->sitd_list, &iso_sched->td_list); | 1920 | list_add (&sitd->sitd_list, &iso_sched->td_list); |
1919 | } | 1921 | } |
1920 | 1922 | ||
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 35616ffbe3ae..6dc238c592bc 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c | |||
@@ -1022,44 +1022,24 @@ void xhci_copy_ep0_dequeue_into_input_ctx(struct xhci_hcd *xhci, | |||
1022 | * is attached to (or the roothub port its ancestor hub is attached to). All we | 1022 | * is attached to (or the roothub port its ancestor hub is attached to). All we |
1023 | * know is the index of that port under either the USB 2.0 or the USB 3.0 | 1023 | * know is the index of that port under either the USB 2.0 or the USB 3.0 |
1024 | * roothub, but that doesn't give us the real index into the HW port status | 1024 | * roothub, but that doesn't give us the real index into the HW port status |
1025 | * registers. Scan through the xHCI roothub port array, looking for the Nth | 1025 | * registers. Call xhci_find_raw_port_number() to get real index. |
1026 | * entry of the correct port speed. Return the port number of that entry. | ||
1027 | */ | 1026 | */ |
1028 | static u32 xhci_find_real_port_number(struct xhci_hcd *xhci, | 1027 | static u32 xhci_find_real_port_number(struct xhci_hcd *xhci, |
1029 | struct usb_device *udev) | 1028 | struct usb_device *udev) |
1030 | { | 1029 | { |
1031 | struct usb_device *top_dev; | 1030 | struct usb_device *top_dev; |
1032 | unsigned int num_similar_speed_ports; | 1031 | struct usb_hcd *hcd; |
1033 | unsigned int faked_port_num; | 1032 | |
1034 | int i; | 1033 | if (udev->speed == USB_SPEED_SUPER) |
1034 | hcd = xhci->shared_hcd; | ||
1035 | else | ||
1036 | hcd = xhci->main_hcd; | ||
1035 | 1037 | ||
1036 | for (top_dev = udev; top_dev->parent && top_dev->parent->parent; | 1038 | for (top_dev = udev; top_dev->parent && top_dev->parent->parent; |
1037 | top_dev = top_dev->parent) | 1039 | top_dev = top_dev->parent) |
1038 | /* Found device below root hub */; | 1040 | /* Found device below root hub */; |
1039 | faked_port_num = top_dev->portnum; | ||
1040 | for (i = 0, num_similar_speed_ports = 0; | ||
1041 | i < HCS_MAX_PORTS(xhci->hcs_params1); i++) { | ||
1042 | u8 port_speed = xhci->port_array[i]; | ||
1043 | |||
1044 | /* | ||
1045 | * Skip ports that don't have known speeds, or have duplicate | ||
1046 | * Extended Capabilities port speed entries. | ||
1047 | */ | ||
1048 | if (port_speed == 0 || port_speed == DUPLICATE_ENTRY) | ||
1049 | continue; | ||
1050 | 1041 | ||
1051 | /* | 1042 | return xhci_find_raw_port_number(hcd, top_dev->portnum); |
1052 | * USB 3.0 ports are always under a USB 3.0 hub. USB 2.0 and | ||
1053 | * 1.1 ports are under the USB 2.0 hub. If the port speed | ||
1054 | * matches the device speed, it's a similar speed port. | ||
1055 | */ | ||
1056 | if ((port_speed == 0x03) == (udev->speed == USB_SPEED_SUPER)) | ||
1057 | num_similar_speed_ports++; | ||
1058 | if (num_similar_speed_ports == faked_port_num) | ||
1059 | /* Roothub ports are numbered from 1 to N */ | ||
1060 | return i+1; | ||
1061 | } | ||
1062 | return 0; | ||
1063 | } | 1043 | } |
1064 | 1044 | ||
1065 | /* Setup an xHCI virtual device for a Set Address command */ | 1045 | /* Setup an xHCI virtual device for a Set Address command */ |
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index af259e0ec172..1a30c380043c 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c | |||
@@ -313,6 +313,7 @@ static const struct hc_driver xhci_pci_hc_driver = { | |||
313 | .set_usb2_hw_lpm = xhci_set_usb2_hardware_lpm, | 313 | .set_usb2_hw_lpm = xhci_set_usb2_hardware_lpm, |
314 | .enable_usb3_lpm_timeout = xhci_enable_usb3_lpm_timeout, | 314 | .enable_usb3_lpm_timeout = xhci_enable_usb3_lpm_timeout, |
315 | .disable_usb3_lpm_timeout = xhci_disable_usb3_lpm_timeout, | 315 | .disable_usb3_lpm_timeout = xhci_disable_usb3_lpm_timeout, |
316 | .find_raw_port_number = xhci_find_raw_port_number, | ||
316 | }; | 317 | }; |
317 | 318 | ||
318 | /*-------------------------------------------------------------------------*/ | 319 | /*-------------------------------------------------------------------------*/ |
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 882875465301..1969c001b3f9 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c | |||
@@ -1599,14 +1599,20 @@ static void handle_port_status(struct xhci_hcd *xhci, | |||
1599 | max_ports = HCS_MAX_PORTS(xhci->hcs_params1); | 1599 | max_ports = HCS_MAX_PORTS(xhci->hcs_params1); |
1600 | if ((port_id <= 0) || (port_id > max_ports)) { | 1600 | if ((port_id <= 0) || (port_id > max_ports)) { |
1601 | xhci_warn(xhci, "Invalid port id %d\n", port_id); | 1601 | xhci_warn(xhci, "Invalid port id %d\n", port_id); |
1602 | bogus_port_status = true; | 1602 | inc_deq(xhci, xhci->event_ring); |
1603 | goto cleanup; | 1603 | return; |
1604 | } | 1604 | } |
1605 | 1605 | ||
1606 | /* Figure out which usb_hcd this port is attached to: | 1606 | /* Figure out which usb_hcd this port is attached to: |
1607 | * is it a USB 3.0 port or a USB 2.0/1.1 port? | 1607 | * is it a USB 3.0 port or a USB 2.0/1.1 port? |
1608 | */ | 1608 | */ |
1609 | major_revision = xhci->port_array[port_id - 1]; | 1609 | major_revision = xhci->port_array[port_id - 1]; |
1610 | |||
1611 | /* Find the right roothub. */ | ||
1612 | hcd = xhci_to_hcd(xhci); | ||
1613 | if ((major_revision == 0x03) != (hcd->speed == HCD_USB3)) | ||
1614 | hcd = xhci->shared_hcd; | ||
1615 | |||
1610 | if (major_revision == 0) { | 1616 | if (major_revision == 0) { |
1611 | xhci_warn(xhci, "Event for port %u not in " | 1617 | xhci_warn(xhci, "Event for port %u not in " |
1612 | "Extended Capabilities, ignoring.\n", | 1618 | "Extended Capabilities, ignoring.\n", |
@@ -1629,10 +1635,6 @@ static void handle_port_status(struct xhci_hcd *xhci, | |||
1629 | * into the index into the ports on the correct split roothub, and the | 1635 | * into the index into the ports on the correct split roothub, and the |
1630 | * correct bus_state structure. | 1636 | * correct bus_state structure. |
1631 | */ | 1637 | */ |
1632 | /* Find the right roothub. */ | ||
1633 | hcd = xhci_to_hcd(xhci); | ||
1634 | if ((major_revision == 0x03) != (hcd->speed == HCD_USB3)) | ||
1635 | hcd = xhci->shared_hcd; | ||
1636 | bus_state = &xhci->bus_state[hcd_index(hcd)]; | 1638 | bus_state = &xhci->bus_state[hcd_index(hcd)]; |
1637 | if (hcd->speed == HCD_USB3) | 1639 | if (hcd->speed == HCD_USB3) |
1638 | port_array = xhci->usb3_ports; | 1640 | port_array = xhci->usb3_ports; |
@@ -2027,8 +2029,8 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
2027 | if (event_trb != ep_ring->dequeue && | 2029 | if (event_trb != ep_ring->dequeue && |
2028 | event_trb != td->last_trb) | 2030 | event_trb != td->last_trb) |
2029 | td->urb->actual_length = | 2031 | td->urb->actual_length = |
2030 | td->urb->transfer_buffer_length | 2032 | td->urb->transfer_buffer_length - |
2031 | - TRB_LEN(le32_to_cpu(event->transfer_len)); | 2033 | EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)); |
2032 | else | 2034 | else |
2033 | td->urb->actual_length = 0; | 2035 | td->urb->actual_length = 0; |
2034 | 2036 | ||
@@ -2060,7 +2062,7 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
2060 | /* Maybe the event was for the data stage? */ | 2062 | /* Maybe the event was for the data stage? */ |
2061 | td->urb->actual_length = | 2063 | td->urb->actual_length = |
2062 | td->urb->transfer_buffer_length - | 2064 | td->urb->transfer_buffer_length - |
2063 | TRB_LEN(le32_to_cpu(event->transfer_len)); | 2065 | EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)); |
2064 | xhci_dbg(xhci, "Waiting for status " | 2066 | xhci_dbg(xhci, "Waiting for status " |
2065 | "stage event\n"); | 2067 | "stage event\n"); |
2066 | return 0; | 2068 | return 0; |
@@ -2096,7 +2098,7 @@ static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
2096 | /* handle completion code */ | 2098 | /* handle completion code */ |
2097 | switch (trb_comp_code) { | 2099 | switch (trb_comp_code) { |
2098 | case COMP_SUCCESS: | 2100 | case COMP_SUCCESS: |
2099 | if (TRB_LEN(le32_to_cpu(event->transfer_len)) == 0) { | 2101 | if (EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)) == 0) { |
2100 | frame->status = 0; | 2102 | frame->status = 0; |
2101 | break; | 2103 | break; |
2102 | } | 2104 | } |
@@ -2141,7 +2143,7 @@ static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
2141 | len += TRB_LEN(le32_to_cpu(cur_trb->generic.field[2])); | 2143 | len += TRB_LEN(le32_to_cpu(cur_trb->generic.field[2])); |
2142 | } | 2144 | } |
2143 | len += TRB_LEN(le32_to_cpu(cur_trb->generic.field[2])) - | 2145 | len += TRB_LEN(le32_to_cpu(cur_trb->generic.field[2])) - |
2144 | TRB_LEN(le32_to_cpu(event->transfer_len)); | 2146 | EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)); |
2145 | 2147 | ||
2146 | if (trb_comp_code != COMP_STOP_INVAL) { | 2148 | if (trb_comp_code != COMP_STOP_INVAL) { |
2147 | frame->actual_length = len; | 2149 | frame->actual_length = len; |
@@ -2199,7 +2201,7 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
2199 | case COMP_SUCCESS: | 2201 | case COMP_SUCCESS: |
2200 | /* Double check that the HW transferred everything. */ | 2202 | /* Double check that the HW transferred everything. */ |
2201 | if (event_trb != td->last_trb || | 2203 | if (event_trb != td->last_trb || |
2202 | TRB_LEN(le32_to_cpu(event->transfer_len)) != 0) { | 2204 | EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)) != 0) { |
2203 | xhci_warn(xhci, "WARN Successful completion " | 2205 | xhci_warn(xhci, "WARN Successful completion " |
2204 | "on short TX\n"); | 2206 | "on short TX\n"); |
2205 | if (td->urb->transfer_flags & URB_SHORT_NOT_OK) | 2207 | if (td->urb->transfer_flags & URB_SHORT_NOT_OK) |
@@ -2227,18 +2229,18 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
2227 | "%d bytes untransferred\n", | 2229 | "%d bytes untransferred\n", |
2228 | td->urb->ep->desc.bEndpointAddress, | 2230 | td->urb->ep->desc.bEndpointAddress, |
2229 | td->urb->transfer_buffer_length, | 2231 | td->urb->transfer_buffer_length, |
2230 | TRB_LEN(le32_to_cpu(event->transfer_len))); | 2232 | EVENT_TRB_LEN(le32_to_cpu(event->transfer_len))); |
2231 | /* Fast path - was this the last TRB in the TD for this URB? */ | 2233 | /* Fast path - was this the last TRB in the TD for this URB? */ |
2232 | if (event_trb == td->last_trb) { | 2234 | if (event_trb == td->last_trb) { |
2233 | if (TRB_LEN(le32_to_cpu(event->transfer_len)) != 0) { | 2235 | if (EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)) != 0) { |
2234 | td->urb->actual_length = | 2236 | td->urb->actual_length = |
2235 | td->urb->transfer_buffer_length - | 2237 | td->urb->transfer_buffer_length - |
2236 | TRB_LEN(le32_to_cpu(event->transfer_len)); | 2238 | EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)); |
2237 | if (td->urb->transfer_buffer_length < | 2239 | if (td->urb->transfer_buffer_length < |
2238 | td->urb->actual_length) { | 2240 | td->urb->actual_length) { |
2239 | xhci_warn(xhci, "HC gave bad length " | 2241 | xhci_warn(xhci, "HC gave bad length " |
2240 | "of %d bytes left\n", | 2242 | "of %d bytes left\n", |
2241 | TRB_LEN(le32_to_cpu(event->transfer_len))); | 2243 | EVENT_TRB_LEN(le32_to_cpu(event->transfer_len))); |
2242 | td->urb->actual_length = 0; | 2244 | td->urb->actual_length = 0; |
2243 | if (td->urb->transfer_flags & URB_SHORT_NOT_OK) | 2245 | if (td->urb->transfer_flags & URB_SHORT_NOT_OK) |
2244 | *status = -EREMOTEIO; | 2246 | *status = -EREMOTEIO; |
@@ -2280,7 +2282,7 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
2280 | if (trb_comp_code != COMP_STOP_INVAL) | 2282 | if (trb_comp_code != COMP_STOP_INVAL) |
2281 | td->urb->actual_length += | 2283 | td->urb->actual_length += |
2282 | TRB_LEN(le32_to_cpu(cur_trb->generic.field[2])) - | 2284 | TRB_LEN(le32_to_cpu(cur_trb->generic.field[2])) - |
2283 | TRB_LEN(le32_to_cpu(event->transfer_len)); | 2285 | EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)); |
2284 | } | 2286 | } |
2285 | 2287 | ||
2286 | return finish_td(xhci, td, event_trb, event, ep, status, false); | 2288 | return finish_td(xhci, td, event_trb, event, ep, status, false); |
@@ -2368,7 +2370,7 @@ static int handle_tx_event(struct xhci_hcd *xhci, | |||
2368 | * transfer type | 2370 | * transfer type |
2369 | */ | 2371 | */ |
2370 | case COMP_SUCCESS: | 2372 | case COMP_SUCCESS: |
2371 | if (TRB_LEN(le32_to_cpu(event->transfer_len)) == 0) | 2373 | if (EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)) == 0) |
2372 | break; | 2374 | break; |
2373 | if (xhci->quirks & XHCI_TRUST_TX_LENGTH) | 2375 | if (xhci->quirks & XHCI_TRUST_TX_LENGTH) |
2374 | trb_comp_code = COMP_SHORT_TX; | 2376 | trb_comp_code = COMP_SHORT_TX; |
@@ -2461,14 +2463,21 @@ static int handle_tx_event(struct xhci_hcd *xhci, | |||
2461 | * TD list. | 2463 | * TD list. |
2462 | */ | 2464 | */ |
2463 | if (list_empty(&ep_ring->td_list)) { | 2465 | if (list_empty(&ep_ring->td_list)) { |
2464 | xhci_warn(xhci, "WARN Event TRB for slot %d ep %d " | 2466 | /* |
2465 | "with no TDs queued?\n", | 2467 | * A stopped endpoint may generate an extra completion |
2466 | TRB_TO_SLOT_ID(le32_to_cpu(event->flags)), | 2468 | * event if the device was suspended. Don't print |
2467 | ep_index); | 2469 | * warnings. |
2468 | xhci_dbg(xhci, "Event TRB with TRB type ID %u\n", | 2470 | */ |
2469 | (le32_to_cpu(event->flags) & | 2471 | if (!(trb_comp_code == COMP_STOP || |
2470 | TRB_TYPE_BITMASK)>>10); | 2472 | trb_comp_code == COMP_STOP_INVAL)) { |
2471 | xhci_print_trb_offsets(xhci, (union xhci_trb *) event); | 2473 | xhci_warn(xhci, "WARN Event TRB for slot %d ep %d with no TDs queued?\n", |
2474 | TRB_TO_SLOT_ID(le32_to_cpu(event->flags)), | ||
2475 | ep_index); | ||
2476 | xhci_dbg(xhci, "Event TRB with TRB type ID %u\n", | ||
2477 | (le32_to_cpu(event->flags) & | ||
2478 | TRB_TYPE_BITMASK)>>10); | ||
2479 | xhci_print_trb_offsets(xhci, (union xhci_trb *) event); | ||
2480 | } | ||
2472 | if (ep->skip) { | 2481 | if (ep->skip) { |
2473 | ep->skip = false; | 2482 | ep->skip = false; |
2474 | xhci_dbg(xhci, "td_list is empty while skip " | 2483 | xhci_dbg(xhci, "td_list is empty while skip " |
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 849470b18831..53b8f89a0b1c 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c | |||
@@ -3779,6 +3779,28 @@ int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev) | |||
3779 | return 0; | 3779 | return 0; |
3780 | } | 3780 | } |
3781 | 3781 | ||
3782 | /* | ||
3783 | * Transfer the port index into real index in the HW port status | ||
3784 | * registers. Caculate offset between the port's PORTSC register | ||
3785 | * and port status base. Divide the number of per port register | ||
3786 | * to get the real index. The raw port number bases 1. | ||
3787 | */ | ||
3788 | int xhci_find_raw_port_number(struct usb_hcd *hcd, int port1) | ||
3789 | { | ||
3790 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); | ||
3791 | __le32 __iomem *base_addr = &xhci->op_regs->port_status_base; | ||
3792 | __le32 __iomem *addr; | ||
3793 | int raw_port; | ||
3794 | |||
3795 | if (hcd->speed != HCD_USB3) | ||
3796 | addr = xhci->usb2_ports[port1 - 1]; | ||
3797 | else | ||
3798 | addr = xhci->usb3_ports[port1 - 1]; | ||
3799 | |||
3800 | raw_port = (addr - base_addr)/NUM_PORT_REGS + 1; | ||
3801 | return raw_port; | ||
3802 | } | ||
3803 | |||
3782 | #ifdef CONFIG_USB_SUSPEND | 3804 | #ifdef CONFIG_USB_SUSPEND |
3783 | 3805 | ||
3784 | /* BESL to HIRD Encoding array for USB2 LPM */ | 3806 | /* BESL to HIRD Encoding array for USB2 LPM */ |
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 2c510e4a7d4c..63582719e0fb 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h | |||
@@ -972,6 +972,10 @@ struct xhci_transfer_event { | |||
972 | __le32 flags; | 972 | __le32 flags; |
973 | }; | 973 | }; |
974 | 974 | ||
975 | /* Transfer event TRB length bit mask */ | ||
976 | /* bits 0:23 */ | ||
977 | #define EVENT_TRB_LEN(p) ((p) & 0xffffff) | ||
978 | |||
975 | /** Transfer Event bit fields **/ | 979 | /** Transfer Event bit fields **/ |
976 | #define TRB_TO_EP_ID(p) (((p) >> 16) & 0x1f) | 980 | #define TRB_TO_EP_ID(p) (((p) >> 16) & 0x1f) |
977 | 981 | ||
@@ -1829,6 +1833,7 @@ void xhci_test_and_clear_bit(struct xhci_hcd *xhci, __le32 __iomem **port_array, | |||
1829 | int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex, | 1833 | int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex, |
1830 | char *buf, u16 wLength); | 1834 | char *buf, u16 wLength); |
1831 | int xhci_hub_status_data(struct usb_hcd *hcd, char *buf); | 1835 | int xhci_hub_status_data(struct usb_hcd *hcd, char *buf); |
1836 | int xhci_find_raw_port_number(struct usb_hcd *hcd, int port1); | ||
1832 | 1837 | ||
1833 | #ifdef CONFIG_PM | 1838 | #ifdef CONFIG_PM |
1834 | int xhci_bus_suspend(struct usb_hcd *hcd); | 1839 | int xhci_bus_suspend(struct usb_hcd *hcd); |