Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 61965
b: refs/heads/master
c: 809a58b
h: refs/heads/master
i:
  61963: feecc14
v: v3
  • Loading branch information
Alan Stern authored and Greg Kroah-Hartman committed Jul 20, 2007
1 parent 6c593f8 commit 52c8859
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 24 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: 32aca5600526189dd876e6c92b64fd88cf052c8d
refs/heads/master: 809a58b896ba07e771adc76a47c83e4ca1969da8
49 changes: 26 additions & 23 deletions trunk/drivers/usb/core/hcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,17 @@ EXPORT_SYMBOL_GPL (usb_bus_list_lock);
/* used for controlling access to virtual root hubs */
static DEFINE_SPINLOCK(hcd_root_hub_lock);

/* used when updating hcd data */
static DEFINE_SPINLOCK(hcd_data_lock);
/* used when updating an endpoint's URB list */
static DEFINE_SPINLOCK(hcd_urb_list_lock);

/* wait queue for synchronous unlinks */
DECLARE_WAIT_QUEUE_HEAD(usb_kill_urb_queue);

static inline int is_root_hub(struct usb_device *udev)
{
return (udev->parent == NULL);
}

/*-------------------------------------------------------------------------*/

/*
Expand Down Expand Up @@ -906,14 +911,13 @@ EXPORT_SYMBOL (usb_calc_bus_time);
static void urb_unlink(struct usb_hcd *hcd, struct urb *urb)
{
unsigned long flags;
int at_root_hub = (urb->dev == hcd->self.root_hub);

/* clear all state linking urb to this dev (and hcd) */
spin_lock_irqsave (&hcd_data_lock, flags);
spin_lock_irqsave(&hcd_urb_list_lock, flags);
list_del_init (&urb->urb_list);
spin_unlock_irqrestore (&hcd_data_lock, flags);
spin_unlock_irqrestore(&hcd_urb_list_lock, flags);

if (hcd->self.uses_dma && !at_root_hub) {
if (hcd->self.uses_dma && !is_root_hub(urb->dev)) {
if (usb_pipecontrol (urb->pipe)
&& !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP))
dma_unmap_single (hcd->self.controller, urb->setup_dma,
Expand Down Expand Up @@ -955,7 +959,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)

// FIXME: verify that quiescing hc works right (RH cleans up)

spin_lock_irqsave (&hcd_data_lock, flags);
spin_lock_irqsave(&hcd_urb_list_lock, flags);
ep = (usb_pipein(urb->pipe) ? urb->dev->ep_in : urb->dev->ep_out)
[usb_pipeendpoint(urb->pipe)];
if (unlikely (!ep))
Expand All @@ -972,7 +976,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
status = -ESHUTDOWN;
break;
}
spin_unlock_irqrestore (&hcd_data_lock, flags);
spin_unlock_irqrestore(&hcd_urb_list_lock, flags);
if (status) {
INIT_LIST_HEAD (&urb->urb_list);
usbmon_urb_submit_error(&hcd->self, urb, status);
Expand All @@ -986,7 +990,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
urb = usb_get_urb (urb);
atomic_inc (&urb->use_count);

if (urb->dev == hcd->self.root_hub) {
if (is_root_hub(urb->dev)) {
/* NOTE: requirement on hub callers (usbfs and the hub
* driver, for now) that URBs' urb->transfer_buffer be
* valid and usb_buffer_{sync,unmap}() not be needed, since
Expand Down Expand Up @@ -1043,7 +1047,7 @@ unlink1 (struct usb_hcd *hcd, struct urb *urb)
{
int value;

if (urb->dev == hcd->self.root_hub)
if (is_root_hub(urb->dev))
value = usb_rh_urb_dequeue (hcd, urb);
else {

Expand Down Expand Up @@ -1091,11 +1095,11 @@ int usb_hcd_unlink_urb (struct urb *urb, int status)
* that it was submitted. But as a rule it can't know whether or
* not it's already been unlinked ... so we respect the reversed
* lock sequence needed for the usb_hcd_giveback_urb() code paths
* (urb lock, then hcd_data_lock) in case some other CPU is now
* (urb lock, then hcd_urb_list_lock) in case some other CPU is now
* unlinking it.
*/
spin_lock_irqsave (&urb->lock, flags);
spin_lock (&hcd_data_lock);
spin_lock(&hcd_urb_list_lock);

sys = &urb->dev->dev;
hcd = bus_to_hcd(urb->dev->bus);
Expand Down Expand Up @@ -1127,17 +1131,16 @@ int usb_hcd_unlink_urb (struct urb *urb, int status)
* finish unlinking the initial failed usb_set_address()
* or device descriptor fetch.
*/
if (!test_bit(HCD_FLAG_SAW_IRQ, &hcd->flags)
&& hcd->self.root_hub != urb->dev) {
if (!test_bit(HCD_FLAG_SAW_IRQ, &hcd->flags) &&
!is_root_hub(urb->dev)) {
dev_warn (hcd->self.controller, "Unlink after no-IRQ? "
"Controller is probably using the wrong IRQ."
"\n");
"Controller is probably using the wrong IRQ.\n");
set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags);
}

urb->status = status;

spin_unlock (&hcd_data_lock);
spin_unlock(&hcd_urb_list_lock);
spin_unlock_irqrestore (&urb->lock, flags);

retval = unlink1 (hcd, urb);
Expand All @@ -1146,7 +1149,7 @@ int usb_hcd_unlink_urb (struct urb *urb, int status)
return retval;

done:
spin_unlock (&hcd_data_lock);
spin_unlock(&hcd_urb_list_lock);
spin_unlock_irqrestore (&urb->lock, flags);
if (retval != -EIDRM && sys && sys->driver)
dev_dbg (sys, "hcd_unlink_urb %p fail %d\n", urb, retval);
Expand Down Expand Up @@ -1203,15 +1206,15 @@ void usb_hcd_endpoint_disable (struct usb_device *udev,

/* ep is already gone from udev->ep_{in,out}[]; no more submits */
rescan:
spin_lock (&hcd_data_lock);
spin_lock(&hcd_urb_list_lock);
list_for_each_entry (urb, &ep->urb_list, urb_list) {
int tmp;

/* the urb may already have been unlinked */
if (urb->status != -EINPROGRESS)
continue;
usb_get_urb (urb);
spin_unlock (&hcd_data_lock);
spin_unlock(&hcd_urb_list_lock);

spin_lock (&urb->lock);
tmp = urb->status;
Expand Down Expand Up @@ -1240,7 +1243,7 @@ void usb_hcd_endpoint_disable (struct usb_device *udev,
/* list contents may have changed */
goto rescan;
}
spin_unlock (&hcd_data_lock);
spin_unlock(&hcd_urb_list_lock);
local_irq_enable ();

/* synchronize with the hardware, so old configuration state
Expand All @@ -1257,7 +1260,7 @@ void usb_hcd_endpoint_disable (struct usb_device *udev,
* endpoint_disable methods.
*/
while (!list_empty (&ep->urb_list)) {
spin_lock_irq (&hcd_data_lock);
spin_lock_irq(&hcd_urb_list_lock);

/* The list may have changed while we acquired the spinlock */
urb = NULL;
Expand All @@ -1266,7 +1269,7 @@ void usb_hcd_endpoint_disable (struct usb_device *udev,
urb_list);
usb_get_urb (urb);
}
spin_unlock_irq (&hcd_data_lock);
spin_unlock_irq(&hcd_urb_list_lock);

if (urb) {
usb_kill_urb (urb);
Expand Down

0 comments on commit 52c8859

Please sign in to comment.