On Mon, 9 Jul 2007 10:52:05 -0400 (EDT), Alan Stern <[EMAIL PROTECTED]> wrote:
> > Then i plug in SD card, nothing could happen, it fail to find scsi > > device. I know there would be three kernel threads to polling current > > usb status. One is "hub_thread" to polling port status; one is > > "usb_stor_control_thread" to dealing with scsi cmd; another is > > "usb_stor_scan_thread" to scan scsi devie. > > > > Question1: > > when i plug SD card in USB2227 card reader, which thread would > > responsible such event? i guess it must be the "usb_stor_scan_thread". > > No. None of the threads you listed is responsible. In practice the > detection is done by HAL, a userspace daemon. Actually, HAL is entirely optional. It provides the interfaces needed for the GUI. So, the events follow thus: - khubd polls hub status and knows the state change - khubd isses hotplug request (used to be an exec, netlink now) - udev listens and gets the "add" event with arguments including the alias string - udev runs modprobe with alias string - modprobe loads the driver; its context runs module init, which usually registers something and this walks pre-scanned buses and registers things (if ub); forks threads for usb-storage. - SCSI scans add SCSI buses then - There's one more round of "add" events, which add sd/sg/st in the same fashion Now you can run mount or dd. This is the point where HAL gets involved. It polls for new leaf devices (e.g. storage volumes, webcams, etc.), builds the tree with properties, and posts updates to D-bus where Nautilus/Tomboy/etc. can fetch them. > Are you asking why the SD card wasn't detected when you put in in the > reader? Probably because you weren't running HAL. That's right. Partitions are scanned when the whole device is open. HAL substitutes for that on a typical desktop. This is actually something that udev sort of broke. The kernel code would scan partitions for you even if you tried to open a slice. However, you cannot do it on dynamic /dev because udev hasn't created the slice nodes, and it won't do it until partitions are scanned. Embedded devices usually just run static /dev for that purpose. Heck, some even use ub with static /dev. The fewer threads, the better. -- Pete ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel