mirror of
https://github.com/hardkernel/linux.git
synced 2026-03-25 03:50:24 +09:00
Revert "xhci: cleanup xhci_hub_control port references"
This reverts commitea6c19c736which is commitfaaae0190dupstream. It breaks the Android kernel abi and can be brought back in the future in an abi-safe way if it is really needed. Bug: 161946584 Change-Id: Id29f82e491e7bf665c17098a55fcaafd73ac82ba Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
@@ -1194,14 +1194,11 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
|
||||
u16 test_mode = 0;
|
||||
struct xhci_hub *rhub;
|
||||
struct xhci_port **ports;
|
||||
struct xhci_port *port;
|
||||
int portnum1;
|
||||
|
||||
rhub = xhci_get_rhub(hcd);
|
||||
ports = rhub->ports;
|
||||
max_ports = rhub->num_ports;
|
||||
bus_state = &rhub->bus_state;
|
||||
portnum1 = wIndex & 0xff;
|
||||
|
||||
spin_lock_irqsave(&xhci->lock, flags);
|
||||
switch (typeReq) {
|
||||
@@ -1235,12 +1232,10 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
|
||||
spin_unlock_irqrestore(&xhci->lock, flags);
|
||||
return retval;
|
||||
case GetPortStatus:
|
||||
if (!portnum1 || portnum1 > max_ports)
|
||||
if (!wIndex || wIndex > max_ports)
|
||||
goto error;
|
||||
|
||||
wIndex--;
|
||||
port = ports[portnum1 - 1];
|
||||
temp = readl(port->addr);
|
||||
temp = readl(ports[wIndex]->addr);
|
||||
if (temp == ~(u32)0) {
|
||||
xhci_hc_died(xhci);
|
||||
retval = -ENODEV;
|
||||
@@ -1253,7 +1248,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
|
||||
goto error;
|
||||
|
||||
xhci_dbg(xhci, "Get port status %d-%d read: 0x%x, return 0x%x",
|
||||
hcd->self.busnum, portnum1, temp, status);
|
||||
hcd->self.busnum, wIndex + 1, temp, status);
|
||||
|
||||
put_unaligned(cpu_to_le32(status), (__le32 *) buf);
|
||||
/* if USB 3.1 extended port status return additional 4 bytes */
|
||||
@@ -1265,7 +1260,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
|
||||
retval = -EINVAL;
|
||||
break;
|
||||
}
|
||||
port_li = readl(port->addr + PORTLI);
|
||||
port_li = readl(ports[wIndex]->addr + PORTLI);
|
||||
status = xhci_get_ext_port_status(temp, port_li);
|
||||
put_unaligned_le32(status, &buf[4]);
|
||||
}
|
||||
@@ -1279,14 +1274,11 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
|
||||
test_mode = (wIndex & 0xff00) >> 8;
|
||||
/* The MSB of wIndex is the U1/U2 timeout */
|
||||
timeout = (wIndex & 0xff00) >> 8;
|
||||
|
||||
wIndex &= 0xff;
|
||||
if (!portnum1 || portnum1 > max_ports)
|
||||
if (!wIndex || wIndex > max_ports)
|
||||
goto error;
|
||||
|
||||
port = ports[portnum1 - 1];
|
||||
wIndex--;
|
||||
temp = readl(port->addr);
|
||||
temp = readl(ports[wIndex]->addr);
|
||||
if (temp == ~(u32)0) {
|
||||
xhci_hc_died(xhci);
|
||||
retval = -ENODEV;
|
||||
@@ -1296,10 +1288,11 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
|
||||
/* FIXME: What new port features do we need to support? */
|
||||
switch (wValue) {
|
||||
case USB_PORT_FEAT_SUSPEND:
|
||||
temp = readl(port->addr);
|
||||
temp = readl(ports[wIndex]->addr);
|
||||
if ((temp & PORT_PLS_MASK) != XDEV_U0) {
|
||||
/* Resume the port to U0 first */
|
||||
xhci_set_link_state(xhci, port, XDEV_U0);
|
||||
xhci_set_link_state(xhci, ports[wIndex],
|
||||
XDEV_U0);
|
||||
spin_unlock_irqrestore(&xhci->lock, flags);
|
||||
msleep(10);
|
||||
spin_lock_irqsave(&xhci->lock, flags);
|
||||
@@ -1308,16 +1301,16 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
|
||||
* a port unless the port reports that it is in the
|
||||
* enabled (PED = ‘1’,PLS < ‘3’) state.
|
||||
*/
|
||||
temp = readl(port->addr);
|
||||
temp = readl(ports[wIndex]->addr);
|
||||
if ((temp & PORT_PE) == 0 || (temp & PORT_RESET)
|
||||
|| (temp & PORT_PLS_MASK) >= XDEV_U3) {
|
||||
xhci_warn(xhci, "USB core suspending port %d-%d not in U0/U1/U2\n",
|
||||
hcd->self.busnum, portnum1);
|
||||
hcd->self.busnum, wIndex + 1);
|
||||
goto error;
|
||||
}
|
||||
|
||||
slot_id = xhci_find_slot_id_by_port(hcd, xhci,
|
||||
portnum1);
|
||||
wIndex + 1);
|
||||
if (!slot_id) {
|
||||
xhci_warn(xhci, "slot_id is zero\n");
|
||||
goto error;
|
||||
@@ -1327,21 +1320,21 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
|
||||
xhci_stop_device(xhci, slot_id, 1);
|
||||
spin_lock_irqsave(&xhci->lock, flags);
|
||||
|
||||
xhci_set_link_state(xhci, port, XDEV_U3);
|
||||
xhci_set_link_state(xhci, ports[wIndex], XDEV_U3);
|
||||
|
||||
spin_unlock_irqrestore(&xhci->lock, flags);
|
||||
msleep(10); /* wait device to enter */
|
||||
spin_lock_irqsave(&xhci->lock, flags);
|
||||
|
||||
temp = readl(port->addr);
|
||||
temp = readl(ports[wIndex]->addr);
|
||||
bus_state->suspended_ports |= 1 << wIndex;
|
||||
break;
|
||||
case USB_PORT_FEAT_LINK_STATE:
|
||||
temp = readl(port->addr);
|
||||
temp = readl(ports[wIndex]->addr);
|
||||
/* Disable port */
|
||||
if (link_state == USB_SS_PORT_LS_SS_DISABLED) {
|
||||
xhci_dbg(xhci, "Disable port %d-%d\n",
|
||||
hcd->self.busnum, portnum1);
|
||||
hcd->self.busnum, wIndex + 1);
|
||||
temp = xhci_port_state_to_neutral(temp);
|
||||
/*
|
||||
* Clear all change bits, so that we get a new
|
||||
@@ -1350,17 +1343,18 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
|
||||
temp |= PORT_CSC | PORT_PEC | PORT_WRC |
|
||||
PORT_OCC | PORT_RC | PORT_PLC |
|
||||
PORT_CEC;
|
||||
writel(temp | PORT_PE, port->addr);
|
||||
temp = readl(port->addr);
|
||||
writel(temp | PORT_PE, ports[wIndex]->addr);
|
||||
temp = readl(ports[wIndex]->addr);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Put link in RxDetect (enable port) */
|
||||
if (link_state == USB_SS_PORT_LS_RX_DETECT) {
|
||||
xhci_dbg(xhci, "Enable port %d-%d\n",
|
||||
hcd->self.busnum, portnum1);
|
||||
xhci_set_link_state(xhci, port, link_state);
|
||||
temp = readl(port->addr);
|
||||
hcd->self.busnum, wIndex + 1);
|
||||
xhci_set_link_state(xhci, ports[wIndex],
|
||||
link_state);
|
||||
temp = readl(ports[wIndex]->addr);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1390,10 +1384,11 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
|
||||
}
|
||||
|
||||
xhci_dbg(xhci, "Enable compliance mode transition for port %d-%d\n",
|
||||
hcd->self.busnum, portnum1);
|
||||
xhci_set_link_state(xhci, port, link_state);
|
||||
hcd->self.busnum, wIndex + 1);
|
||||
xhci_set_link_state(xhci, ports[wIndex],
|
||||
link_state);
|
||||
|
||||
temp = readl(port->addr);
|
||||
temp = readl(ports[wIndex]->addr);
|
||||
break;
|
||||
}
|
||||
/* Port must be enabled */
|
||||
@@ -1404,7 +1399,8 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
|
||||
/* Can't set port link state above '3' (U3) */
|
||||
if (link_state > USB_SS_PORT_LS_U3) {
|
||||
xhci_warn(xhci, "Cannot set port %d-%d link state %d\n",
|
||||
hcd->self.busnum, portnum1, link_state);
|
||||
hcd->self.busnum, wIndex + 1,
|
||||
link_state);
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -1429,7 +1425,8 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
|
||||
reinit_completion(&bus_state->u3exit_done[wIndex]);
|
||||
}
|
||||
if (pls <= XDEV_U3) /* U1, U2, U3 */
|
||||
xhci_set_link_state(xhci, port, USB_SS_PORT_LS_U0);
|
||||
xhci_set_link_state(xhci, ports[wIndex],
|
||||
USB_SS_PORT_LS_U0);
|
||||
if (!wait_u0) {
|
||||
if (pls > XDEV_U3)
|
||||
goto error;
|
||||
@@ -1439,16 +1436,16 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
|
||||
if (!wait_for_completion_timeout(&bus_state->u3exit_done[wIndex],
|
||||
msecs_to_jiffies(500)))
|
||||
xhci_dbg(xhci, "missing U0 port change event for port %d-%d\n",
|
||||
hcd->self.busnum, portnum1);
|
||||
hcd->self.busnum, wIndex + 1);
|
||||
spin_lock_irqsave(&xhci->lock, flags);
|
||||
temp = readl(port->addr);
|
||||
temp = readl(ports[wIndex]->addr);
|
||||
break;
|
||||
}
|
||||
|
||||
if (link_state == USB_SS_PORT_LS_U3) {
|
||||
int retries = 16;
|
||||
slot_id = xhci_find_slot_id_by_port(hcd, xhci,
|
||||
portnum1);
|
||||
wIndex + 1);
|
||||
if (slot_id) {
|
||||
/* unlock to execute stop endpoint
|
||||
* commands */
|
||||
@@ -1457,16 +1454,16 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
|
||||
xhci_stop_device(xhci, slot_id, 1);
|
||||
spin_lock_irqsave(&xhci->lock, flags);
|
||||
}
|
||||
xhci_set_link_state(xhci, port, USB_SS_PORT_LS_U3);
|
||||
xhci_set_link_state(xhci, ports[wIndex], USB_SS_PORT_LS_U3);
|
||||
spin_unlock_irqrestore(&xhci->lock, flags);
|
||||
while (retries--) {
|
||||
usleep_range(4000, 8000);
|
||||
temp = readl(port->addr);
|
||||
temp = readl(ports[wIndex]->addr);
|
||||
if ((temp & PORT_PLS_MASK) == XDEV_U3)
|
||||
break;
|
||||
}
|
||||
spin_lock_irqsave(&xhci->lock, flags);
|
||||
temp = readl(port->addr);
|
||||
temp = readl(ports[wIndex]->addr);
|
||||
bus_state->suspended_ports |= 1 << wIndex;
|
||||
}
|
||||
break;
|
||||
@@ -1481,38 +1478,39 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
|
||||
break;
|
||||
case USB_PORT_FEAT_RESET:
|
||||
temp = (temp | PORT_RESET);
|
||||
writel(temp, port->addr);
|
||||
writel(temp, ports[wIndex]->addr);
|
||||
|
||||
temp = readl(port->addr);
|
||||
temp = readl(ports[wIndex]->addr);
|
||||
xhci_dbg(xhci, "set port reset, actual port %d-%d status = 0x%x\n",
|
||||
hcd->self.busnum, portnum1, temp);
|
||||
hcd->self.busnum, wIndex + 1, temp);
|
||||
break;
|
||||
case USB_PORT_FEAT_REMOTE_WAKE_MASK:
|
||||
xhci_set_remote_wake_mask(xhci, port, wake_mask);
|
||||
temp = readl(port->addr);
|
||||
xhci_set_remote_wake_mask(xhci, ports[wIndex],
|
||||
wake_mask);
|
||||
temp = readl(ports[wIndex]->addr);
|
||||
xhci_dbg(xhci, "set port remote wake mask, actual port %d-%d status = 0x%x\n",
|
||||
hcd->self.busnum, portnum1, temp);
|
||||
hcd->self.busnum, wIndex + 1, temp);
|
||||
break;
|
||||
case USB_PORT_FEAT_BH_PORT_RESET:
|
||||
temp |= PORT_WR;
|
||||
writel(temp, port->addr);
|
||||
temp = readl(port->addr);
|
||||
writel(temp, ports[wIndex]->addr);
|
||||
temp = readl(ports[wIndex]->addr);
|
||||
break;
|
||||
case USB_PORT_FEAT_U1_TIMEOUT:
|
||||
if (hcd->speed < HCD_USB3)
|
||||
goto error;
|
||||
temp = readl(port->addr + PORTPMSC);
|
||||
temp = readl(ports[wIndex]->addr + PORTPMSC);
|
||||
temp &= ~PORT_U1_TIMEOUT_MASK;
|
||||
temp |= PORT_U1_TIMEOUT(timeout);
|
||||
writel(temp, port->addr + PORTPMSC);
|
||||
writel(temp, ports[wIndex]->addr + PORTPMSC);
|
||||
break;
|
||||
case USB_PORT_FEAT_U2_TIMEOUT:
|
||||
if (hcd->speed < HCD_USB3)
|
||||
goto error;
|
||||
temp = readl(port->addr + PORTPMSC);
|
||||
temp = readl(ports[wIndex]->addr + PORTPMSC);
|
||||
temp &= ~PORT_U2_TIMEOUT_MASK;
|
||||
temp |= PORT_U2_TIMEOUT(timeout);
|
||||
writel(temp, port->addr + PORTPMSC);
|
||||
writel(temp, ports[wIndex]->addr + PORTPMSC);
|
||||
break;
|
||||
case USB_PORT_FEAT_TEST:
|
||||
/* 4.19.6 Port Test Modes (USB2 Test Mode) */
|
||||
@@ -1528,16 +1526,13 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
|
||||
goto error;
|
||||
}
|
||||
/* unblock any posted writes */
|
||||
temp = readl(port->addr);
|
||||
temp = readl(ports[wIndex]->addr);
|
||||
break;
|
||||
case ClearPortFeature:
|
||||
if (!portnum1 || portnum1 > max_ports)
|
||||
if (!wIndex || wIndex > max_ports)
|
||||
goto error;
|
||||
|
||||
port = ports[portnum1 - 1];
|
||||
|
||||
wIndex--;
|
||||
temp = readl(port->addr);
|
||||
temp = readl(ports[wIndex]->addr);
|
||||
if (temp == ~(u32)0) {
|
||||
xhci_hc_died(xhci);
|
||||
retval = -ENODEV;
|
||||
@@ -1547,7 +1542,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
|
||||
temp = xhci_port_state_to_neutral(temp);
|
||||
switch (wValue) {
|
||||
case USB_PORT_FEAT_SUSPEND:
|
||||
temp = readl(port->addr);
|
||||
temp = readl(ports[wIndex]->addr);
|
||||
xhci_dbg(xhci, "clear USB_PORT_FEAT_SUSPEND\n");
|
||||
xhci_dbg(xhci, "PORTSC %04x\n", temp);
|
||||
if (temp & PORT_RESET)
|
||||
@@ -1558,18 +1553,20 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
|
||||
|
||||
set_bit(wIndex, &bus_state->resuming_ports);
|
||||
usb_hcd_start_port_resume(&hcd->self, wIndex);
|
||||
xhci_set_link_state(xhci, port, XDEV_RESUME);
|
||||
xhci_set_link_state(xhci, ports[wIndex],
|
||||
XDEV_RESUME);
|
||||
spin_unlock_irqrestore(&xhci->lock, flags);
|
||||
msleep(USB_RESUME_TIMEOUT);
|
||||
spin_lock_irqsave(&xhci->lock, flags);
|
||||
xhci_set_link_state(xhci, port, XDEV_U0);
|
||||
xhci_set_link_state(xhci, ports[wIndex],
|
||||
XDEV_U0);
|
||||
clear_bit(wIndex, &bus_state->resuming_ports);
|
||||
usb_hcd_end_port_resume(&hcd->self, wIndex);
|
||||
}
|
||||
bus_state->port_c_suspend |= 1 << wIndex;
|
||||
|
||||
slot_id = xhci_find_slot_id_by_port(hcd, xhci,
|
||||
portnum1);
|
||||
wIndex + 1);
|
||||
if (!slot_id) {
|
||||
xhci_dbg(xhci, "slot_id is zero\n");
|
||||
goto error;
|
||||
@@ -1587,11 +1584,11 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
|
||||
case USB_PORT_FEAT_C_PORT_LINK_STATE:
|
||||
case USB_PORT_FEAT_C_PORT_CONFIG_ERROR:
|
||||
xhci_clear_port_change_bit(xhci, wValue, wIndex,
|
||||
port->addr, temp);
|
||||
ports[wIndex]->addr, temp);
|
||||
break;
|
||||
case USB_PORT_FEAT_ENABLE:
|
||||
xhci_disable_port(hcd, xhci, wIndex,
|
||||
port->addr, temp);
|
||||
ports[wIndex]->addr, temp);
|
||||
break;
|
||||
case USB_PORT_FEAT_POWER:
|
||||
xhci_set_port_power(xhci, hcd, wIndex, false, &flags);
|
||||
|
||||
Reference in New Issue
Block a user