linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Petr Baudis <pasky@ucw.cz>
To: linux-hotplug@vger.kernel.org
Subject: [PATCH] USB hotplug race
Date: Wed, 17 Mar 2004 14:27:17 +0000	[thread overview]
Message-ID: <20040317142717.GA14149@pasky.ji.cz> (raw)

  Hello,

  so I finally upgraded from 2.4 to 2.6 (2.6.4), and one of the few
problems I've hit is hotplug. Basically, when I start up hotplug while
my Zaurus is plugged, everything works fine and usbnet gets loaded,
however when I plug Zaurus after hotplug was loaded, it trashes the
event.

  After populating the hotplug scripts with plethora of debug prints,
I've tracked it down to usb_convert_vars() - basically, immediatelly
after the USB device is plugged and the signal is already delivered to
hotplug, the sysfs tree isn't yet populated by all the relevant data
and only detach_state is present there - no bDeviceClass or so.

  Looking at drivers/usb/core/message.c:usb_set_configuration(),
device_add() is called first (which I suppose calls /sbin/hotplug
through platform_notify ?), and _then_ this set of files is created. It
doesn't look like there would be a lot of time to trigger the race, but
I personally get a _very_ high reproducibility rate (actually I'm not
sure if I ever managed not to trigger it).

  I don't know how to fix it in the kernel since we would probably need to
first add kobject, then pop out and create the sysfs nodes, and _then_ call the
userspace helper. So I just created a trivial bandaid for
/etc/hotplug/usb.agent, which fixes this for me:

--- hotplug-2004_03_11/etc/hotplug/usb.agent	Fri Mar 12 00:18:23 2004
+++ hotplug-2004_03_11+pasky/etc/hotplug/usb.agent	Wed Mar 17 00:17:47 2004
@@ -354,9 +354,14 @@
     # they happen to issue requests at the same time ... it happens easily
     # with slow HID devices and "usbmodules".
     # starting with 2.5 (DEVPATH set), all hcds must queue control traffic.
+
+    # However by the time of 2.6.4, the kernel has an easy-to-trigger (at
+    # least for me) race condition when /sbin/hotplug already got called but
+    # the sysfs device directory is not yet populated with all the neccessary
+    # files. --pasky
-    if [ "$DEVPATH" = "" ]; then
+    # if [ "$DEVPATH" = "" ]; then
 	sleep 3
-    fi
+    # fi
 
     usb_convert_vars
 

  Please consider applying.

  PS: By the way, usb.agent.(orig|rej) slipped into the 2004_03_11
distribution.

  Kind regards,

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man. -- George Bernard Shaw


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id\x1470&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

             reply	other threads:[~2004-03-17 14:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-17 14:27 Petr Baudis [this message]
2004-03-26 23:05 ` [PATCH] USB hotplug race Greg KH
2004-03-27  0:05 ` Oliver Neukum
2004-03-27  0:12 ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040317142717.GA14149@pasky.ji.cz \
    --to=pasky@ucw.cz \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).