summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Nyman <mathias.nyman@linux.intel.com>2019-04-26 09:23:30 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-04-27 08:53:58 -0400
commitd70d5a846671c3acb572425fe429b35cb4ec44a9 (patch)
tree95c8e3dac2127327ef7d8e87c1810f598e230917
parent33e39350ebd20fe6a77a51b8c21c3aa6b4a208cf (diff)
xhci: add port and bus number to port dynamic debugging
Improve port related dynamic debugging by printing out the bus number, port number and port status register content each time there is a port related debug messages. Use the same port numbering method as usbcore to simplify debugging. i.e. starting with port number 1. Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/host/xhci-hub.c44
-rw-r--r--drivers/usb/host/xhci-ring.c12
-rw-r--r--drivers/usb/host/xhci.c17
3 files changed, 48 insertions, 25 deletions
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 96a740543183..3abe70ff1b1e 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -487,8 +487,8 @@ static void xhci_disable_port(struct usb_hcd *hcd, struct xhci_hcd *xhci,
487 /* Write 1 to disable the port */ 487 /* Write 1 to disable the port */
488 writel(port_status | PORT_PE, addr); 488 writel(port_status | PORT_PE, addr);
489 port_status = readl(addr); 489 port_status = readl(addr);
490 xhci_dbg(xhci, "disable port, actual port %d status = 0x%x\n", 490 xhci_dbg(xhci, "disable port %d-%d, portsc: 0x%x\n",
491 wIndex, port_status); 491 hcd->self.busnum, wIndex + 1, port_status);
492} 492}
493 493
494static void xhci_clear_port_change_bit(struct xhci_hcd *xhci, u16 wValue, 494static void xhci_clear_port_change_bit(struct xhci_hcd *xhci, u16 wValue,
@@ -537,8 +537,9 @@ static void xhci_clear_port_change_bit(struct xhci_hcd *xhci, u16 wValue,
537 /* Change bits are all write 1 to clear */ 537 /* Change bits are all write 1 to clear */
538 writel(port_status | status, addr); 538 writel(port_status | status, addr);
539 port_status = readl(addr); 539 port_status = readl(addr);
540 xhci_dbg(xhci, "clear port %s change, actual port %d status = 0x%x\n", 540
541 port_change_bit, wIndex, port_status); 541 xhci_dbg(xhci, "clear port%d %s change, portsc: 0x%x\n",
542 wIndex + 1, port_change_bit, port_status);
542} 543}
543 544
544struct xhci_hub *xhci_get_rhub(struct usb_hcd *hcd) 545struct xhci_hub *xhci_get_rhub(struct usb_hcd *hcd)
@@ -565,13 +566,16 @@ static void xhci_set_port_power(struct xhci_hcd *xhci, struct usb_hcd *hcd,
565 rhub = xhci_get_rhub(hcd); 566 rhub = xhci_get_rhub(hcd);
566 port = rhub->ports[index]; 567 port = rhub->ports[index];
567 temp = readl(port->addr); 568 temp = readl(port->addr);
569
570 xhci_dbg(xhci, "set port power %d-%d %s, portsc: 0x%x\n",
571 hcd->self.busnum, index + 1, on ? "ON" : "OFF", temp);
572
568 temp = xhci_port_state_to_neutral(temp); 573 temp = xhci_port_state_to_neutral(temp);
574
569 if (on) { 575 if (on) {
570 /* Power on */ 576 /* Power on */
571 writel(temp | PORT_POWER, port->addr); 577 writel(temp | PORT_POWER, port->addr);
572 temp = readl(port->addr); 578 readl(port->addr);
573 xhci_dbg(xhci, "set port power, actual port %d status = 0x%x\n",
574 index, temp);
575 } else { 579 } else {
576 /* Power off */ 580 /* Power off */
577 writel(temp & ~PORT_POWER, port->addr); 581 writel(temp & ~PORT_POWER, port->addr);
@@ -666,12 +670,17 @@ void xhci_set_link_state(struct xhci_hcd *xhci, struct xhci_port *port,
666 u32 link_state) 670 u32 link_state)
667{ 671{
668 u32 temp; 672 u32 temp;
673 u32 portsc;
669 674
670 temp = readl(port->addr); 675 portsc = readl(port->addr);
671 temp = xhci_port_state_to_neutral(temp); 676 temp = xhci_port_state_to_neutral(portsc);
672 temp &= ~PORT_PLS_MASK; 677 temp &= ~PORT_PLS_MASK;
673 temp |= PORT_LINK_STROBE | link_state; 678 temp |= PORT_LINK_STROBE | link_state;
674 writel(temp, port->addr); 679 writel(temp, port->addr);
680
681 xhci_dbg(xhci, "Set port %d-%d link state, portsc: 0x%x, write 0x%x",
682 port->rhub->hcd->self.busnum, port->hcd_portnum + 1,
683 portsc, temp);
675} 684}
676 685
677static void xhci_set_remote_wake_mask(struct xhci_hcd *xhci, 686static void xhci_set_remote_wake_mask(struct xhci_hcd *xhci,
@@ -840,7 +849,9 @@ static int xhci_handle_usb2_port_link_resume(struct xhci_port *port,
840 } else if (time_after_eq(jiffies, bus_state->resume_done[wIndex])) { 849 } else if (time_after_eq(jiffies, bus_state->resume_done[wIndex])) {
841 int time_left; 850 int time_left;
842 851
843 xhci_dbg(xhci, "Resume USB2 port %d\n", wIndex + 1); 852 xhci_dbg(xhci, "resume USB2 port %d-%d\n",
853 hcd->self.busnum, wIndex + 1);
854
844 bus_state->resume_done[wIndex] = 0; 855 bus_state->resume_done[wIndex] = 0;
845 clear_bit(wIndex, &bus_state->resuming_ports); 856 clear_bit(wIndex, &bus_state->resuming_ports);
846 857
@@ -867,9 +878,8 @@ static int xhci_handle_usb2_port_link_resume(struct xhci_port *port,
867 } else { 878 } else {
868 int port_status = readl(port->addr); 879 int port_status = readl(port->addr);
869 880
870 xhci_warn(xhci, "Port resume %i msec timed out, portsc = 0x%x\n", 881 xhci_warn(xhci, "Port resume timed out, port %d-%d: 0x%x\n",
871 XHCI_MAX_REXIT_TIMEOUT_MS, 882 hcd->self.busnum, wIndex + 1, port_status);
872 port_status);
873 *status |= USB_PORT_STAT_SUSPEND; 883 *status |= USB_PORT_STAT_SUSPEND;
874 clear_bit(wIndex, &bus_state->rexit_ports); 884 clear_bit(wIndex, &bus_state->rexit_ports);
875 } 885 }
@@ -1124,9 +1134,8 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
1124 if (status == 0xffffffff) 1134 if (status == 0xffffffff)
1125 goto error; 1135 goto error;
1126 1136
1127 xhci_dbg(xhci, "get port status, actual port %d status = 0x%x\n", 1137 xhci_dbg(xhci, "Get port status %d-%d read: 0x%x, return 0x%x",
1128 wIndex, temp); 1138 hcd->self.busnum, wIndex + 1, temp, status);
1129 xhci_dbg(xhci, "Get port status returned 0x%x\n", status);
1130 1139
1131 put_unaligned(cpu_to_le32(status), (__le32 *) buf); 1140 put_unaligned(cpu_to_le32(status), (__le32 *) buf);
1132 /* if USB 3.1 extended port status return additional 4 bytes */ 1141 /* if USB 3.1 extended port status return additional 4 bytes */
@@ -1182,7 +1191,8 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
1182 temp = readl(ports[wIndex]->addr); 1191 temp = readl(ports[wIndex]->addr);
1183 if ((temp & PORT_PE) == 0 || (temp & PORT_RESET) 1192 if ((temp & PORT_PE) == 0 || (temp & PORT_RESET)
1184 || (temp & PORT_PLS_MASK) >= XDEV_U3) { 1193 || (temp & PORT_PLS_MASK) >= XDEV_U3) {
1185 xhci_warn(xhci, "USB core suspending device not in U0/U1/U2.\n"); 1194 xhci_warn(xhci, "USB core suspending port %d-%d not in U0/U1/U2\n",
1195 hcd->self.busnum, wIndex + 1);
1186 goto error; 1196 goto error;
1187 } 1197 }
1188 1198
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 28250319d0b8..fed3385aeac0 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1569,18 +1569,19 @@ static void handle_port_status(struct xhci_hcd *xhci,
1569 "WARN: xHC returned failed port status event\n"); 1569 "WARN: xHC returned failed port status event\n");
1570 1570
1571 port_id = GET_PORT_ID(le32_to_cpu(event->generic.field[0])); 1571 port_id = GET_PORT_ID(le32_to_cpu(event->generic.field[0]));
1572 xhci_dbg(xhci, "Port Status Change Event for port %d\n", port_id);
1573
1574 max_ports = HCS_MAX_PORTS(xhci->hcs_params1); 1572 max_ports = HCS_MAX_PORTS(xhci->hcs_params1);
1573
1575 if ((port_id <= 0) || (port_id > max_ports)) { 1574 if ((port_id <= 0) || (port_id > max_ports)) {
1576 xhci_warn(xhci, "Invalid port id %d\n", port_id); 1575 xhci_warn(xhci, "Port change event with invalid port ID %d\n",
1576 port_id);
1577 inc_deq(xhci, xhci->event_ring); 1577 inc_deq(xhci, xhci->event_ring);
1578 return; 1578 return;
1579 } 1579 }
1580 1580
1581 port = &xhci->hw_ports[port_id - 1]; 1581 port = &xhci->hw_ports[port_id - 1];
1582 if (!port || !port->rhub || port->hcd_portnum == DUPLICATE_ENTRY) { 1582 if (!port || !port->rhub || port->hcd_portnum == DUPLICATE_ENTRY) {
1583 xhci_warn(xhci, "Event for invalid port %u\n", port_id); 1583 xhci_warn(xhci, "Port change event, no port for port ID %u\n",
1584 port_id);
1584 bogus_port_status = true; 1585 bogus_port_status = true;
1585 goto cleanup; 1586 goto cleanup;
1586 } 1587 }
@@ -1597,6 +1598,9 @@ static void handle_port_status(struct xhci_hcd *xhci,
1597 hcd_portnum = port->hcd_portnum; 1598 hcd_portnum = port->hcd_portnum;
1598 portsc = readl(port->addr); 1599 portsc = readl(port->addr);
1599 1600
1601 xhci_dbg(xhci, "Port change event, %d-%d, id %d, portsc: 0x%x\n",
1602 hcd->self.busnum, hcd_portnum + 1, port_id, portsc);
1603
1600 trace_xhci_handle_port_status(hcd_portnum, portsc); 1604 trace_xhci_handle_port_status(hcd_portnum, portsc);
1601 1605
1602 if (hcd->state == HC_STATE_SUSPENDED) { 1606 if (hcd->state == HC_STATE_SUSPENDED) {
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 255f93f741a0..cdccbdfb479e 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -893,7 +893,7 @@ static void xhci_disable_port_wake_on_bits(struct xhci_hcd *xhci)
893 struct xhci_port **ports; 893 struct xhci_port **ports;
894 int port_index; 894 int port_index;
895 unsigned long flags; 895 unsigned long flags;
896 u32 t1, t2; 896 u32 t1, t2, portsc;
897 897
898 spin_lock_irqsave(&xhci->lock, flags); 898 spin_lock_irqsave(&xhci->lock, flags);
899 899
@@ -902,10 +902,15 @@ static void xhci_disable_port_wake_on_bits(struct xhci_hcd *xhci)
902 ports = xhci->usb3_rhub.ports; 902 ports = xhci->usb3_rhub.ports;
903 while (port_index--) { 903 while (port_index--) {
904 t1 = readl(ports[port_index]->addr); 904 t1 = readl(ports[port_index]->addr);
905 portsc = t1;
905 t1 = xhci_port_state_to_neutral(t1); 906 t1 = xhci_port_state_to_neutral(t1);
906 t2 = t1 & ~PORT_WAKE_BITS; 907 t2 = t1 & ~PORT_WAKE_BITS;
907 if (t1 != t2) 908 if (t1 != t2) {
908 writel(t2, ports[port_index]->addr); 909 writel(t2, ports[port_index]->addr);
910 xhci_dbg(xhci, "disable wake bits port %d-%d, portsc: 0x%x, write: 0x%x\n",
911 xhci->usb3_rhub.hcd->self.busnum,
912 port_index + 1, portsc, t2);
913 }
909 } 914 }
910 915
911 /* disable usb2 ports Wake bits */ 916 /* disable usb2 ports Wake bits */
@@ -913,12 +918,16 @@ static void xhci_disable_port_wake_on_bits(struct xhci_hcd *xhci)
913 ports = xhci->usb2_rhub.ports; 918 ports = xhci->usb2_rhub.ports;
914 while (port_index--) { 919 while (port_index--) {
915 t1 = readl(ports[port_index]->addr); 920 t1 = readl(ports[port_index]->addr);
921 portsc = t1;
916 t1 = xhci_port_state_to_neutral(t1); 922 t1 = xhci_port_state_to_neutral(t1);
917 t2 = t1 & ~PORT_WAKE_BITS; 923 t2 = t1 & ~PORT_WAKE_BITS;
918 if (t1 != t2) 924 if (t1 != t2) {
919 writel(t2, ports[port_index]->addr); 925 writel(t2, ports[port_index]->addr);
926 xhci_dbg(xhci, "disable wake bits port %d-%d, portsc: 0x%x, write: 0x%x\n",
927 xhci->usb2_rhub.hcd->self.busnum,
928 port_index + 1, portsc, t2);
929 }
920 } 930 }
921
922 spin_unlock_irqrestore(&xhci->lock, flags); 931 spin_unlock_irqrestore(&xhci->lock, flags);
923} 932}
924 933