BusyBox Bug and Patch Tracking
BusyBox
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0002144 [BusyBox] Standards Compliance minor always 02-14-08 16:14 03-29-08 09:08
Reporter joeyoravec View Status public  
Assigned To BusyBox
Priority normal Resolution fixed  
Status closed   Product Version svn
Summary 0002144: 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.
Additional Information make_device() in mdev.c checks the 5th character of devpath expecting "class" or "block". This works great for an "mdev -s" scan but if mdev is called from a hotplug event, Linux 2.6.23 also gives me get paths under "devices", "bus" and other names. In my case I got a /sys/device/* devpath for a character device, so it failed the check and mdev decided to create an S_IFBLK.

http://kernel.org/doc/pending/hotplug.txt [^] says every hotplug event will provide ACTION, DEVPATH, and SUBSYSTEM. If SUBSYSTEM is not equal to "block" then it's a character device or has no associated device node. It looks like mdev should check the devpath during a scan, or use SUBSYSTEM during a hotplug event. See additional information for the patch that I'm using right now. The caller performs a check and tells make_device() which type to create.

I found another closed issue 0001299 that matches this problem.
Attached Files  busybox-1.7.2-mdevblock.patch [^] (1,957 bytes) 02-14-08 16:14
 mdev.patch [^] (1,858 bytes) 03-29-08 03:30

- Relationships

- Notes
(0004854)
vapier
02-14-08 17:47

please post the hotplug environment and the sysfs path for the device that you are seeing problems with
 
(0004864)
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.
 
(0004874)
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=/
 
(0004944)
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
 
(0005054)
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.
 
(0005064)
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
 
(0006204)
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.
 
(0006214)
vda
03-29-08 09:08

Fixed in rev. 21557. Thanks
 

- 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
03-29-08 09:08 vda Status assigned => closed
03-29-08 09:08 vda Note Added: 0006214
03-29-08 09:08 vda Resolution open => fixed


Copyright © 2000 - 2006 Mantis Group
Powered by Mantis Bugtracker