Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 235418
b: refs/heads/master
c: 518e848
h: refs/heads/master
v: v3
  • Loading branch information
Sarah Sharp committed Mar 14, 2011
1 parent a278f05 commit 0291523
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 23 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1d5810b6923c76fc95e52d9d3491c91824c2f075
refs/heads/master: 518e848ea8e2932ce18ce2daef8ad5f55a145f27
41 changes: 22 additions & 19 deletions trunk/drivers/usb/host/xhci-hub.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,50 +568,52 @@ int xhci_hub_status_data(struct usb_hcd *hcd, char *buf)
int xhci_bus_suspend(struct usb_hcd *hcd)
{
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
int port;
int max_ports, port_index;
unsigned long flags;

xhci_dbg(xhci, "suspend root hub\n");
max_ports = HCS_MAX_PORTS(xhci->hcs_params1);

spin_lock_irqsave(&xhci->lock, flags);

if (hcd->self.root_hub->do_remote_wakeup) {
port = HCS_MAX_PORTS(xhci->hcs_params1);
while (port--) {
if (xhci->resume_done[port] != 0) {
port_index = max_ports;
while (port_index--) {
if (xhci->resume_done[port_index] != 0) {
spin_unlock_irqrestore(&xhci->lock, flags);
xhci_dbg(xhci, "suspend failed because "
"port %d is resuming\n",
port + 1);
port_index + 1);
return -EBUSY;
}
}
}

port = HCS_MAX_PORTS(xhci->hcs_params1);
port_index = max_ports;
xhci->bus_suspended = 0;
while (port--) {
while (port_index--) {
/* suspend the port if the port is not suspended */
u32 __iomem *addr;
u32 t1, t2;
int slot_id;

addr = &xhci->op_regs->port_status_base +
NUM_PORT_REGS * (port & 0xff);
NUM_PORT_REGS * (port_index & 0xff);
t1 = xhci_readl(xhci, addr);
t2 = xhci_port_state_to_neutral(t1);

if ((t1 & PORT_PE) && !(t1 & PORT_PLS_MASK)) {
xhci_dbg(xhci, "port %d not suspended\n", port);
slot_id = xhci_find_slot_id_by_port(xhci, port + 1);
xhci_dbg(xhci, "port %d not suspended\n", port_index);
slot_id = xhci_find_slot_id_by_port(xhci,
port_index + 1);
if (slot_id) {
spin_unlock_irqrestore(&xhci->lock, flags);
xhci_stop_device(xhci, slot_id, 1);
spin_lock_irqsave(&xhci->lock, flags);
}
t2 &= ~PORT_PLS_MASK;
t2 |= PORT_LINK_STROBE | XDEV_U3;
set_bit(port, &xhci->bus_suspended);
set_bit(port_index, &xhci->bus_suspended);
}
if (hcd->self.root_hub->do_remote_wakeup) {
if (t1 & PORT_CONNECT) {
Expand All @@ -634,7 +636,7 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
u32 tmp;

addr = &xhci->op_regs->port_power_base +
NUM_PORT_REGS * (port & 0xff);
NUM_PORT_REGS * (port_index & 0xff);
tmp = xhci_readl(xhci, addr);
tmp |= PORT_RWE;
xhci_writel(xhci, tmp, addr);
Expand All @@ -649,11 +651,12 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
int xhci_bus_resume(struct usb_hcd *hcd)
{
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
int port;
int max_ports, port_index;
u32 temp;
unsigned long flags;

xhci_dbg(xhci, "resume root hub\n");
max_ports = HCS_MAX_PORTS(xhci->hcs_params1);

if (time_before(jiffies, xhci->next_statechange))
msleep(5);
Expand All @@ -669,22 +672,22 @@ int xhci_bus_resume(struct usb_hcd *hcd)
temp &= ~CMD_EIE;
xhci_writel(xhci, temp, &xhci->op_regs->command);

port = HCS_MAX_PORTS(xhci->hcs_params1);
while (port--) {
port_index = max_ports;
while (port_index--) {
/* Check whether need resume ports. If needed
resume port and disable remote wakeup */
u32 __iomem *addr;
u32 temp;
int slot_id;

addr = &xhci->op_regs->port_status_base +
NUM_PORT_REGS * (port & 0xff);
NUM_PORT_REGS * (port_index & 0xff);
temp = xhci_readl(xhci, addr);
if (DEV_SUPERSPEED(temp))
temp &= ~(PORT_RWC_BITS | PORT_CEC | PORT_WAKE_BITS);
else
temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS);
if (test_bit(port, &xhci->bus_suspended) &&
if (test_bit(port_index, &xhci->bus_suspended) &&
(temp & PORT_PLS_MASK)) {
if (DEV_SUPERSPEED(temp)) {
temp = xhci_port_state_to_neutral(temp);
Expand All @@ -707,7 +710,7 @@ int xhci_bus_resume(struct usb_hcd *hcd)
temp |= PORT_LINK_STROBE | XDEV_U0;
xhci_writel(xhci, temp, addr);
}
slot_id = xhci_find_slot_id_by_port(xhci, port + 1);
slot_id = xhci_find_slot_id_by_port(xhci, port_index + 1);
if (slot_id)
xhci_ring_device(xhci, slot_id);
} else
Expand All @@ -719,7 +722,7 @@ int xhci_bus_resume(struct usb_hcd *hcd)
u32 tmp;

addr = &xhci->op_regs->port_power_base +
NUM_PORT_REGS * (port & 0xff);
NUM_PORT_REGS * (port_index & 0xff);
tmp = xhci_readl(xhci, addr);
tmp &= ~PORT_RWE;
xhci_writel(xhci, tmp, addr);
Expand Down
6 changes: 3 additions & 3 deletions trunk/drivers/usb/host/xhci-ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,7 @@ static void handle_port_status(struct xhci_hcd *xhci,
u32 port_id;
u32 temp, temp1;
u32 __iomem *addr;
int ports;
int max_ports;
int slot_id;

/* Port status change events always have a successful completion code */
Expand All @@ -1174,8 +1174,8 @@ static void handle_port_status(struct xhci_hcd *xhci,
port_id = GET_PORT_ID(event->generic.field[0]);
xhci_dbg(xhci, "Port Status Change Event for port %d\n", port_id);

ports = HCS_MAX_PORTS(xhci->hcs_params1);
if ((port_id <= 0) || (port_id > ports)) {
max_ports = HCS_MAX_PORTS(xhci->hcs_params1);
if ((port_id <= 0) || (port_id > max_ports)) {
xhci_warn(xhci, "Invalid port id %d\n", port_id);
goto cleanup;
}
Expand Down

0 comments on commit 0291523

Please sign in to comment.