[BusyBox 0002144]: mdev hotplug behavior for char/block devices

bugs at busybox.net bugs at busybox.net
Sat Mar 29 10:55:15 UTC 2008


A NOTE has been added to this issue. 
====================================================================== 
http://busybox.net/bugs/view.php?id=2144 
====================================================================== 
Reported By:                joeyoravec
Assigned To:                BusyBox
====================================================================== 
Project:                    BusyBox
Issue ID:                   2144
Category:                   Standards Compliance
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     assigned
====================================================================== 
Date Submitted:             02-14-2008 16:14 PST
Last Modified:              03-29-2008 03:55 PDT
====================================================================== 
Summary:                    mdev hotplug behavior for char/block devices
Description: 
On an embedded system, mdev in busybox 1.7.2 will sometimes create block
instead of character drivers. I experience this problem with two character
devices. Please see additional information for my investigation, and the
attached file for a proposed patch.
====================================================================== 

---------------------------------------------------------------------- 
 vapier - 02-14-08 17:47  
---------------------------------------------------------------------- 
please post the hotplug environment and the sysfs path for the device that
you are seeing problems with 

---------------------------------------------------------------------- 
 espakman - 02-15-08 02:45  
---------------------------------------------------------------------- 
I see the same behaviour with the watchdog device and softdog module

mdev used for hotplugging, echo /sbin/mdev > /proc/sys/kernel/hotplug
/sys/devices/virtual/misc/watchdog


insmod softdog:
/dev/watchdog is added because of hotplugging by mdev, as block device:
brw-rw----  1   root   root  10,130

rm /dev/watchdog, mdev -s:
/dev/watchdog is added as character device:
crw-rw----  1   root   root  10,130

Obviously /usr/sbin/watchdog fails to start in the hotplugging case. 

---------------------------------------------------------------------- 
 joeyoravec - 02-15-08 06:49  
---------------------------------------------------------------------- 
Here's are two of my problem devices, info captured with "env >>
/tmp/mdevlogfile" on a hotplug event. These are devices for an ALSA sound
chip/card over a SPI bitbang bus. There's a dev file under dev path, and
in this situation mdev should create a character device. Without my
proposed patch it would create a block device.

As I said in the original posting "mdev -s" would work fine because it
uses a completely different algorithm (scanning class and bus) and would
correctly create a character device. On hotplug events the situation is
different; the documentation says to use the SUBSYSTEM variable, not to
parse the path.

ACTION=add
HOME=/
SEQNUM=115
MAJOR=116
DEVPATH=/devices/platform/ermine_spi_bb_dac26/spi3.0/sound/card0/pcmC0D0p
SUBSYSTEM=sound
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MINOR=16
PWD=/

ACTION=add
HOME=/
SEQNUM=116
MAJOR=116
DEVPATH=/devices/platform/ermine_spi_bb_dac26/spi3.0/sound/card0/controlC0
SUBSYSTEM=sound
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MINOR=0
PWD=/ 

---------------------------------------------------------------------- 
 vapier - 02-15-08 20:13  
---------------------------------------------------------------------- 
i cannot reproduce this ... if this were actually a problem for me, i would
have fixed it long ago

on my systems, mdev creates all of the alsa devices correctly (which are
loaded as modules, not built into the kernel) and has been since 2.6.19
(i'm currently testing 2.6.24).

for example, with busybox-1.9.1:
root:/> ls -l /dev/watchdog
ls: /dev/watchdog: No such file or directory
root:/> modprobe softdog
Software Watchdog Timer: 0.07 initialized. soft_noboot=0 soft_margin=60
sec (nowayout= 0)
root:/> ls -l /dev/watchdog
crw-rw----    1 root     root      10, 130 Jan  1 18:30 /dev/watchdog

it looks like your DEVPATH is wrong ... it should always start with
/class/... or /block/...  that is why the algorithm works

for example, the environment from first execution with the softdog loading
is:
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
HOME=/
SEQNUM=97
MINOR=130
MAJOR=10
SUBSYSTEM=misc
DEVPATH=/class/misc/watchdog
ACTION=remove 

---------------------------------------------------------------------- 
 joeyoravec - 02-18-08 07:19  
---------------------------------------------------------------------- 
Loading softdog for the first time, but you pasted an environment with
ACTION=remove? That seems fishy.

I haven't seen any document that promises the kernel will only give
devpaths with those two folders. Further, sysfs-rules.txt says that recent
kernels have symlinks under /class/ and /block/ that point to a unified
tree under /devices/. Finally there were a few discussions on lkml
including http://lkml.org/lkml/2007/7/17/527 with info that may not yet
appear in the documentation.

I'm just doing the right thing by filing a bug report to let you know.
Patching mdev to follow my interpretation of the documentation solved my
problem, and I don't plan to argue this any further. I suggest that you
post on LKML if you have any questions. 

---------------------------------------------------------------------- 
 vapier - 02-18-08 07:57  
---------------------------------------------------------------------- 
it's the same, only the action differs

SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
HOME=/
SEQNUM=80
MINOR=130
MAJOR=10
SUBSYSTEM=misc
DEVPATH=/class/misc/watchdog
ACTION=add 

---------------------------------------------------------------------- 
 mmarretta - 03-29-08 03:55  
---------------------------------------------------------------------- 
I have the same problem.

When i plug a usb touchscreen, mdev creates a block device instead of
character device.
This happens because hotplug calls mdev with the following variables:

ACTION: add
DEVPATH: /devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2:1.0/usb/tkpanel0
FIRMAWARE:
SUBSYSTEM: usb

In /sys/class/usb there is tkpanel0 but it's a link to
/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2:1.0/usb/tkpanel0.
So hotplug uses the real path (
/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2:1.0/usb/tkpanel0 ) and
doesn't use the link.
This occures with kernel version 2.6.22.
According to the document http://kernel.org/doc/pending/hotplug.txt I'd
suggest to use the variable SUBSYSTEM.
I have uploaded the patch witch I use. 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
02-14-08 16:14  joeyoravec     New Issue                                    
02-14-08 16:14  joeyoravec     Status                   new => assigned     
02-14-08 16:14  joeyoravec     Assigned To               => BusyBox         
02-14-08 16:14  joeyoravec     File Added: busybox-1.7.2-mdevblock.patch        
           
02-14-08 16:15  joeyoravec     Issue Monitored: joeyoravec                    
02-14-08 17:47  vapier         Note Added: 0004854                          
02-15-08 02:45  espakman       Note Added: 0004864                          
02-15-08 06:49  joeyoravec     Note Added: 0004874                          
02-15-08 20:13  vapier         Note Added: 0004944                          
02-18-08 07:19  joeyoravec     Note Added: 0005054                          
02-18-08 07:57  vapier         Note Added: 0005064                          
03-29-08 03:30  mmarretta      File Added: mdev.patch                       
03-29-08 03:55  mmarretta      Note Added: 0006204                          
======================================================================




More information about the busybox-cvs mailing list