Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 28379
b: refs/heads/master
c: e323de4
h: refs/heads/master
i:
  28377: f199d98
  28375: 9de6c9a
v: v3
  • Loading branch information
Alan Stern authored and Greg Kroah-Hartman committed Jun 21, 2006
1 parent 887d74f commit 300dca6
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 27 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: be3cbc5f87d4b1fbd714644b6824ce4eb229f372
refs/heads/master: e323de46e83b6df2f330651907ac823f8d53308a
49 changes: 26 additions & 23 deletions trunk/drivers/usb/host/uhci-hcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,23 @@ static void finish_reset(struct uhci_hcd *uhci)
uhci->is_stopped = UHCI_IS_STOPPED;
uhci_to_hcd(uhci)->state = HC_STATE_HALT;
uhci_to_hcd(uhci)->poll_rh = 0;

uhci->dead = 0; /* Full reset resurrects the controller */
}

/*
* Last rites for a defunct/nonfunctional controller
* or one we don't want to use any more.
*/
static void hc_died(struct uhci_hcd *uhci)
static void uhci_hc_died(struct uhci_hcd *uhci)
{
uhci_get_current_frame_number(uhci);
uhci_reset_hc(to_pci_dev(uhci_dev(uhci)), uhci->io_addr);
finish_reset(uhci);
uhci->hc_inaccessible = 1;
uhci->dead = 1;

/* The current frame may already be partway finished */
++uhci->frame_number;
}

/*
Expand Down Expand Up @@ -234,7 +240,7 @@ __acquires(uhci->lock)
spin_unlock_irq(&uhci->lock);
msleep(1);
spin_lock_irq(&uhci->lock);
if (uhci->hc_inaccessible) /* Died */
if (uhci->dead)
return;
}
if (!(inw(uhci->io_addr + USBSTS) & USBSTS_HCH))
Expand Down Expand Up @@ -287,7 +293,7 @@ __acquires(uhci->lock)
spin_unlock_irq(&uhci->lock);
msleep(20);
spin_lock_irq(&uhci->lock);
if (uhci->hc_inaccessible) /* Died */
if (uhci->dead)
return;

/* End Global Resume and wait for EOP to be sent */
Expand Down Expand Up @@ -339,7 +345,7 @@ static irqreturn_t uhci_irq(struct usb_hcd *hcd, struct pt_regs *regs)
errbuf, ERRBUF_LEN);
lprintk(errbuf);
}
hc_died(uhci);
uhci_hc_died(uhci);

/* Force a callback in case there are
* pending unlinks */
Expand Down Expand Up @@ -462,7 +468,7 @@ static void uhci_shutdown(struct pci_dev *pdev)
{
struct usb_hcd *hcd = (struct usb_hcd *) pci_get_drvdata(pdev);

hc_died(hcd_to_uhci(hcd));
uhci_hc_died(hcd_to_uhci(hcd));
}

/*
Expand Down Expand Up @@ -664,8 +670,8 @@ static void uhci_stop(struct usb_hcd *hcd)
struct uhci_hcd *uhci = hcd_to_uhci(hcd);

spin_lock_irq(&uhci->lock);
if (!uhci->hc_inaccessible)
hc_died(uhci);
if (test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) && !uhci->dead)
uhci_hc_died(uhci);
uhci_scan_schedule(uhci, NULL);
spin_unlock_irq(&uhci->lock);

Expand All @@ -681,7 +687,7 @@ static int uhci_rh_suspend(struct usb_hcd *hcd)
spin_lock_irq(&uhci->lock);
if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))
rc = -ESHUTDOWN;
else if (!uhci->hc_inaccessible)
else if (!uhci->dead)
suspend_rh(uhci, UHCI_RH_SUSPENDED);
spin_unlock_irq(&uhci->lock);
return rc;
Expand All @@ -696,7 +702,7 @@ static int uhci_rh_resume(struct usb_hcd *hcd)
if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) {
dev_warn(&hcd->self.root_hub->dev, "HC isn't running!\n");
rc = -ESHUTDOWN;
} else if (!uhci->hc_inaccessible)
} else if (!uhci->dead)
wakeup_rh(uhci);
spin_unlock_irq(&uhci->lock);
return rc;
Expand All @@ -710,8 +716,8 @@ static int uhci_suspend(struct usb_hcd *hcd, pm_message_t message)
dev_dbg(uhci_dev(uhci), "%s\n", __FUNCTION__);

spin_lock_irq(&uhci->lock);
if (uhci->hc_inaccessible) /* Dead or already suspended */
goto done;
if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) || uhci->dead)
goto done_okay; /* Already suspended or dead */

if (uhci->rh_state > UHCI_RH_SUSPENDED) {
dev_warn(uhci_dev(uhci), "Root hub isn't suspended!\n");
Expand All @@ -724,12 +730,12 @@ static int uhci_suspend(struct usb_hcd *hcd, pm_message_t message)
*/
pci_write_config_word(to_pci_dev(uhci_dev(uhci)), USBLEGSUP, 0);
mb();
clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
uhci->hc_inaccessible = 1;
hcd->poll_rh = 0;

/* FIXME: Enable non-PME# remote wakeup? */

done_okay:
clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
done:
spin_unlock_irq(&uhci->lock);
return rc;
Expand All @@ -742,25 +748,22 @@ static int uhci_resume(struct usb_hcd *hcd)
dev_dbg(uhci_dev(uhci), "%s\n", __FUNCTION__);

/* Since we aren't in D3 any more, it's safe to set this flag
* even if the controller was dead. It might not even be dead
* any more, if the firmware or quirks code has reset it.
* even if the controller was dead.
*/
set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
mb();

if (uhci->rh_state == UHCI_RH_RESET) /* Dead */
return 0;

spin_lock_irq(&uhci->lock);

/* FIXME: Disable non-PME# remote wakeup? */

uhci->hc_inaccessible = 0;

/* The BIOS may have changed the controller settings during a
* system wakeup. Check it and reconfigure to avoid problems.
/* The firmware or a boot kernel may have changed the controller
* settings during a system wakeup. Check it and reconfigure
* to avoid problems.
*/
check_and_reset_hc(uhci);

/* If the controller was dead before, it's back alive now */
configure_hc(uhci);

if (uhci->rh_state == UHCI_RH_RESET) {
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/usb/host/uhci-hcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ struct uhci_hcd {

unsigned int scan_in_progress:1; /* Schedule scan is running */
unsigned int need_rescan:1; /* Redo the schedule scan */
unsigned int hc_inaccessible:1; /* HC is suspended or dead */
unsigned int dead:1; /* Controller has died */
unsigned int working_RD:1; /* Suspended root hub doesn't
need to be polled */
unsigned int is_initialized:1; /* Data structure is usable */
Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/usb/host/uhci-hub.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ static int uhci_hub_status_data(struct usb_hcd *hcd, char *buf)
spin_lock_irqsave(&uhci->lock, flags);

uhci_scan_schedule(uhci, NULL);
if (uhci->hc_inaccessible)
if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) || uhci->dead)
goto done;
uhci_check_ports(uhci);

Expand Down Expand Up @@ -227,7 +227,7 @@ static int uhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
u16 wPortChange, wPortStatus;
unsigned long flags;

if (uhci->hc_inaccessible)
if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) || uhci->dead)
return -ETIMEDOUT;

spin_lock_irqsave(&uhci->lock, flags);
Expand Down

0 comments on commit 300dca6

Please sign in to comment.