Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 28338
b: refs/heads/master
c: c433472
h: refs/heads/master
v: v3
  • Loading branch information
Alan Stern authored and Greg Kroah-Hartman committed Jun 21, 2006
1 parent b9b6926 commit d8aedf2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 20 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: 3612242e527eb47ee4756b5350f8bdf791aa5ede
refs/heads/master: c433472658b4df11bd3590a59be79194a1ff43ae
4 changes: 3 additions & 1 deletion trunk/drivers/usb/host/uhci-debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ static int uhci_show_status(struct uhci_hcd *uhci, char *buf, int len)
unsigned short portsc1, portsc2;

/* Try to make sure there's enough memory */
if (len < 80 * 6)
if (len < 80 * 9)
return 0;

usbcmd = inw(io_addr + 0);
Expand Down Expand Up @@ -328,6 +328,8 @@ static int uhci_show_status(struct uhci_hcd *uhci, char *buf, int len)
out += sprintf(out, " sof = %02x\n", sof);
out += uhci_show_sc(1, portsc1, out, len - (out - buf));
out += uhci_show_sc(2, portsc2, out, len - (out - buf));
out += sprintf(out, "Most recent frame: %x\n",
uhci->frame_number);

return out - buf;
}
Expand Down
40 changes: 22 additions & 18 deletions trunk/drivers/usb/host/uhci-hcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* (C) Copyright 2000 Yggdrasil Computing, Inc. (port of new PCI interface
* support from usb-ohci.c by Adam Richter, adam@yggdrasil.com).
* (C) Copyright 1999 Gregory P. Smith (from usb-ohci.c)
* (C) Copyright 2004-2005 Alan Stern, stern@rowland.harvard.edu
* (C) Copyright 2004-2006 Alan Stern, stern@rowland.harvard.edu
*
* Intel documents this fairly well, and as far as I know there
* are no royalties or anything like that, but even so there are
Expand All @@ -31,7 +31,6 @@
#include <linux/ioport.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/smp_lock.h>
#include <linux/errno.h>
#include <linux/unistd.h>
#include <linux/interrupt.h>
Expand Down Expand Up @@ -146,7 +145,8 @@ static void configure_hc(struct uhci_hcd *uhci)
outl(uhci->frame_dma_handle, uhci->io_addr + USBFLBASEADD);

/* Set the current frame number */
outw(uhci->frame_number, uhci->io_addr + USBFRNUM);
outw(uhci->frame_number & UHCI_MAX_SOF_NUMBER,
uhci->io_addr + USBFRNUM);

/* Mark controller as not halted before we enable interrupts */
uhci_to_hcd(uhci)->state = HC_STATE_SUSPENDED;
Expand Down Expand Up @@ -239,7 +239,6 @@ __acquires(uhci->lock)
dev_warn(uhci_dev(uhci), "Controller not stopped yet!\n");

uhci_get_current_frame_number(uhci);
smp_wmb();

uhci->rh_state = new_state;
uhci->is_stopped = UHCI_IS_STOPPED;
Expand All @@ -253,7 +252,6 @@ static void start_rh(struct uhci_hcd *uhci)
{
uhci_to_hcd(uhci)->state = HC_STATE_RUNNING;
uhci->is_stopped = 0;
smp_wmb();

/* Mark it configured and running with a 64-byte max packet.
* All interrupts are enabled, even though RESUME won't do anything.
Expand Down Expand Up @@ -360,12 +358,21 @@ static irqreturn_t uhci_irq(struct usb_hcd *hcd, struct pt_regs *regs)

/*
* Store the current frame number in uhci->frame_number if the controller
* is runnning
* is runnning. Expand from 11 bits (of which we use only 10) to a
* full-sized integer.
*
* Like many other parts of the driver, this code relies on being polled
* more than once per second as long as the controller is running.
*/
static void uhci_get_current_frame_number(struct uhci_hcd *uhci)
{
if (!uhci->is_stopped)
uhci->frame_number = inw(uhci->io_addr + USBFRNUM);
if (!uhci->is_stopped) {
unsigned delta;

delta = (inw(uhci->io_addr + USBFRNUM) - uhci->frame_number) &
(UHCI_NUMFRAMES - 1);
uhci->frame_number += delta;
}
}

/*
Expand Down Expand Up @@ -798,18 +805,15 @@ static void uhci_hcd_endpoint_disable(struct usb_hcd *hcd,
static int uhci_hcd_get_frame_number(struct usb_hcd *hcd)
{
struct uhci_hcd *uhci = hcd_to_uhci(hcd);
unsigned long flags;
int is_stopped;
int frame_number;
unsigned frame_number;
unsigned delta;

/* Minimize latency by avoiding the spinlock */
local_irq_save(flags);
is_stopped = uhci->is_stopped;
smp_rmb();
frame_number = (is_stopped ? uhci->frame_number :
inw(uhci->io_addr + USBFRNUM));
local_irq_restore(flags);
return frame_number;
frame_number = uhci->frame_number;
barrier();
delta = (inw(uhci->io_addr + USBFRNUM) - frame_number) &
(UHCI_NUMFRAMES - 1);
return frame_number + delta;
}

static const char hcd_name[] = "uhci_hcd";
Expand Down
3 changes: 3 additions & 0 deletions trunk/drivers/usb/host/uhci-hcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,9 @@ static inline struct usb_hcd *uhci_to_hcd(struct uhci_hcd *uhci)

#define uhci_dev(u) (uhci_to_hcd(u)->self.controller)

/* Utility macro for comparing frame numbers */
#define uhci_frame_before_eq(f1, f2) (0 <= (int) ((f2) - (f1)))


/*
* Private per-URB data
Expand Down

0 comments on commit d8aedf2

Please sign in to comment.