Re: 2.6.7-mm7

From: Jesse Stockall
Date: Fri Jul 09 2004 - 06:49:55 EST


On Fri, 2004-07-09 at 06:27, Stefano Rivoir wrote:
>
> It seems that hotplug "subsystem" is having problems (I use debian/sid),
> because it stucks during
>
> /sbin/modprobe -s -q ehci_hcd
>
> Note that I'm seeing this after a /etc/init.d/hotplug start (after a
> successfull boot), but just before I had a kernel oops (see attached
> file) when issuing a /etc/init.d/hotplug stop.

Hi

This is a known issue that appeared in 2.6.7-mm6. See below for a
temporary fix. Check the [2.6.7-mm6 - USB problems] thread on
linux-usb-devel@xxxxxxxxxxxxxxxxxxxxx for more info.

Jesse

<-- msg from Alan Stern -->

This patch fixes a problem with my recent set of locking changes for
USB.
The problem is that rw-semaphores don't have the semantics I need. I
need
something where, if the semaphore is locked for reading and a writer is
waiting for the lock, another reader will be granted a readlock
immediately. That's because there are several places where a thread
holding the readlock will acquire the readlock again, in a nested or
recursive fashion. If a writer is waiting for the first readlock to be
released, the standard semantics will yield deadlock.

This patch implements those alternate semantics by putting writers on a
separate wait queue. It's a little bit awkward and has a definite
roll-you-own flavor, but it works. Please apply.

Alan Stern



Signed-off-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>

===== drivers/usb/core/usb.c 1.281 vs edited =====
--- 1.281/drivers/usb/core/usb.c Wed Jun 30 09:44:26 2004
+++ edited/drivers/usb/core/usb.c Wed Jul 7 15:47:23 2004
@@ -64,6 +64,7 @@
/* Not honored on modular build */

static DECLARE_RWSEM(usb_all_devices_rwsem);
+static DECLARE_WAIT_QUEUE_HEAD(usb_all_devices_wqh);


static int generic_probe (struct device *dev)
@@ -933,6 +934,7 @@
{
up(&udev->serialize);
up_read(&usb_all_devices_rwsem);
+ wake_up(&usb_all_devices_wqh);
}

/**
@@ -940,10 +942,15 @@
*
* This is necessary when registering a new driver or probing a bus,
* since the driver-model core may try to use any usb_device.
+ *
+ * Unfortunately we have to use a separate wait queue, because we need
+ * to make sure that a thread waiting for a writelock won't block other
+ * threads from acquiring a readlock.
*/
void usb_lock_all_devices(void)
{
- down_write(&usb_all_devices_rwsem);
+ wait_event(usb_all_devices_wqh,
+ down_write_trylock(&usb_all_devices_rwsem));
}

/**
@@ -952,6 +959,7 @@
void usb_unlock_all_devices(void)
{
up_write(&usb_all_devices_rwsem);
+ wake_up(&usb_all_devices_wqh);
}

--
Jesse Stockall <stockall@xxxxxxxx>

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/