linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* WAIT_FOR_SYSFS error, Is my udev rule wrong?
@ 2008-11-20  5:47 Karl O. Pinc
  2008-11-20  6:30 ` Kay Sievers
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Karl O. Pinc @ 2008-11-20  5:47 UTC (permalink / raw)
  To: linux-hotplug

Hello,

I've written a udev rule and am looking
for comment by those with more experience
to see if there are improvements to be made.

I'm running Debian Etch
Linux 2.6.24-etchnhalf.1-486
Udev package version: 0.105-4

I've a USB LCD panel and found that the lcd4linux
daemon that controls it dies when the device is
unplugged.  It seemed smart to write udev rules that
start and stop the daemon whenever the device was plugged or
unplugged.

This is what I came up with:
----------------<snip>-------------------
# /etc/udev/rules.d/z75_lcd4linux.rules
# Copyright (C) 2008, Karl O. Pinc <kop@meme.com>
# Distributed under the GPL V3 or later.
# Adjust file name for your distro.
#
# Rules to start/stop the lcd4linux daemon as USB lcd devices
# are detected.
#
# When using this be sure to remove the link in /etc/rc?.d/S*lcd4linux
# so that the daemon is not started twice at boot.

# Start the daemon whenever ttyUSB0 is plugged in
KERNEL="ttyUSB0", ACTION="add", WAIT_FOR_SYSFS="subsystem/ttyUSB0"  
RUN+="/etc\
/init.d/lcd4linux start"

# Kill the daemon when ttyUSB0 is unplugged.
# (This does not work tremendously well, in that lcd4linux gets
# the chance to generate lots of errors between the time the
# device is unplugged and the daemon stops.)
KERNEL="ttyUSB0", ACTION="remove", RUN+="/etc/init.d/lcd4linux stop"
----------------<snip>-------------------

I added the WAIT_FOR_SYSFS when I found errors like this upon
plugging in the LCD panel.

  Nov 19 16:15:00 mustard LCD4Linux[15799]: Pertelian:  
open(/dev/ttyUSB0) failed: No such file or directory

That made the above error go away, but I still get an error
from wait-for-sysfs as follows:


----------------------<snip>--------------------------
Nov 19 17:47:23 mustard kernel: usb 1-2: new full speed USB device  
using ohci_hcd and address 10
Nov 19 17:47:23 mustard kernel: usb 1-2: configuration #1 chosen from 1  
choice
Nov 19 17:47:23 mustard kernel: ftdi_sio 1-2:1.0: FTDI USB Serial  
Device converter detected
Nov 19 17:47:23 mustard kernel: drivers/usb/serial/ftdi_sio.c: Detected  
FT232RL
Nov 19 17:47:23 mustard kernel: usb 1-2: FTDI USB Serial Device  
converter now attached to ttyUSB0
Nov 19 17:47:27 mustard udevd-event[2205]: wait_for_sysfs: waiting for  
'/sys/devices/pci0000:00/0000:00:15.0/usb1/1-2/1-2:1.0/ttyUSB0/subsystem/ttyUSB0'  
failed
----------------------<snip>--------------------------

Is this expected or have I not setuop udev right?
Everything seems to work just fine.

It would be nice not to depend on the ttyUSB0 device
name, just in case there are other devices, but I
don't see anything I can use to uniquely identify
the LCD panel.  (The panel is a Pertelian X2040.)

If I found a safe way to uniquely identify the
lcd panel there'd probably be a safe way for the
lcd4linux package to automatically install
the udev RUN rules so that everything would
work out of the box.

Here is the udevinfo output:
----------------------<snip>--------------------------

# udevinfo -a -p /sys/class/tty/ttyUSB0

Udevinfo starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

   looking at device '/class/tty/ttyUSB0':
     KERNEL="ttyUSB0"
     SUBSYSTEM="tty"
     DRIVER=""
     ATTR{dev}="188:0"

   looking at parent device  
'/devices/pci0000:00/0000:00:15.0/usb1/1-2/1-2:1.0/ttyUSB0':
     KERNELS="ttyUSB0"
     SUBSYSTEMS="usb-serial"
     DRIVERS="ftdi_sio"
     ATTRS{latency_timer}="16"
     ATTRS{port_number}="0"

   looking at parent device  
'/devices/pci0000:00/0000:00:15.0/usb1/1-2/1-2:1.0':
     KERNELS="1-2:1.0"
     SUBSYSTEMS="usb"
     DRIVERS="ftdi_sio"
     ATTRS{bInterfaceNumber}="00"
     ATTRS{bAlternateSetting}=" 0"
     ATTRS{bNumEndpoints}="02"
     ATTRS{bInterfaceClass}="ff"
     ATTRS{bInterfaceSubClass}="ff"
     ATTRS{bInterfaceProtocol}="ff"
     ATTRS{modalias}="usb:v0403p6001d0600dc00dsc00dp00icFFiscFFipFF"
     ATTRS{interface}="FT245R USB FIFO"

   looking at parent device '/devices/pci0000:00/0000:00:15.0/usb1/1-2':
     KERNELS="1-2"
     SUBSYSTEMS="usb"
     DRIVERS="usb"
     ATTRS{dev}="189:9"
     ATTRS{configuration}=""
     ATTRS{bNumInterfaces}=" 1"
     ATTRS{bConfigurationValue}="1"
     ATTRS{bmAttributes}="a0"
     ATTRS{bMaxPower}=" 90mA"
     ATTRS{urbnum}="1422807"
     ATTRS{idVendor}="0403"
     ATTRS{idProduct}="6001"
     ATTRS{bcdDevice}="0600"
     ATTRS{bDeviceClass}="00"
     ATTRS{bDeviceSubClass}="00"
     ATTRS{bDeviceProtocol}="00"
     ATTRS{bNumConfigurations}="1"
     ATTRS{bMaxPacketSize0}="8"
     ATTRS{speed}="12"
     ATTRS{busnum}="1"
     ATTRS{devnum}="10"
     ATTRS{version}=" 2.00"
     ATTRS{maxchild}="0"
     ATTRS{quirks}="0x0"
     ATTRS{authorized}="1"
     ATTRS{manufacturer}="FTDI"
     ATTRS{product}="FT245R USB FIFO"
     ATTRS{serial}="A2000elL"

   looking at parent device '/devices/pci0000:00/0000:00:15.0/usb1':
     KERNELS="usb1"
     SUBSYSTEMS="usb"
     DRIVERS="usb"
     ATTRS{dev}="189:0"
     ATTRS{configuration}=""
     ATTRS{bNumInterfaces}=" 1"
     ATTRS{bConfigurationValue}="1"
     ATTRS{bmAttributes}="e0"
     ATTRS{bMaxPower}="  0mA"
     ATTRS{urbnum}="247"
     ATTRS{idVendor}="0000"
     ATTRS{idProduct}="0000"
     ATTRS{bcdDevice}="0206"
     ATTRS{bDeviceClass}="09"
     ATTRS{bDeviceSubClass}="00"
     ATTRS{bDeviceProtocol}="00"
     ATTRS{bNumConfigurations}="1"
     ATTRS{bMaxPacketSize0}="64"
     ATTRS{speed}="12"
     ATTRS{busnum}="1"
     ATTRS{devnum}="1"
     ATTRS{version}=" 1.10"
     ATTRS{maxchild}="4"
     ATTRS{quirks}="0x0"
     ATTRS{authorized}="1"
     ATTRS{manufacturer}="Linux 2.6.24-etchnhalf.1-486 ohci_hcd"
     ATTRS{product}="OHCI Host Controller"
     ATTRS{serial}="0000:00:15.0"
     ATTRS{authorized_default}="1"

   looking at parent device '/devices/pci0000:00/0000:00:15.0':
     KERNELS="0000:00:15.0"
     SUBSYSTEMS="pci"
     DRIVERS="ohci_hcd"
     ATTRS{vendor}="0x1022"
     ATTRS{device}="0x2094"
     ATTRS{subsystem_vendor}="0x1022"
     ATTRS{subsystem_device}="0x2094"
     ATTRS{class}="0x0c0310"
     ATTRS{irq}="7"
     ATTRS{local_cpus}="1"
      
ATTRS{modalias}="pci:v00001022d00002094sv00001022sd00002094bc0Csc03i10"
     ATTRS{enable}="1"
     ATTRS{broken_parity_status}="0"
     ATTRS{msi_bus}=""

   looking at parent device '/devices/pci0000:00':
     KERNELS="pci0000:00"
     SUBSYSTEMS=""
     DRIVERS=""
     ATTRS{uevent}=""
----------------------<snip>--------------------------

FYI, the documentation did not make clear to me that
the WAIT_FOR_SYSFS value was a relative path, or
what it is relative to.  Is there somewhere I can
read up on this and on what is what inside /sys/?
I feel like I'm guessing as to what is what every
time I poke around inside /sys/.

Thanks for the help.

Regards,

Karl <kop@meme.com>
Free Software:  "You don't pay back, you pay forward."
                  -- Robert A. Heinlein

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: WAIT_FOR_SYSFS error, Is my udev rule wrong?
  2008-11-20  5:47 WAIT_FOR_SYSFS error, Is my udev rule wrong? Karl O. Pinc
@ 2008-11-20  6:30 ` Kay Sievers
  2008-11-20 14:37 ` Karl O. Pinc
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Kay Sievers @ 2008-11-20  6:30 UTC (permalink / raw)
  To: linux-hotplug

On Thu, Nov 20, 2008 at 06:47, Karl O. Pinc <kop@meme.com> wrote:
> I've written a udev rule and am looking
> for comment by those with more experience
> to see if there are improvements to be made.
> KERNEL="ttyUSB0", ACTION="add", WAIT_FOR_SYSFS="subsystem/ttyUSB0"

You can only wait for attributes ATTR{} of the device you receive the
event for. "subsystem" is a symlink, and it is created long before the
event is sent.

>  looking at device '/class/tty/ttyUSB0':
>    KERNEL="ttyUSB0"
>    SUBSYSTEM="tty"
>    DRIVER=""
>    ATTR{dev}="188:0"

The device you get the event for has only a single attribute, called
"dev" and there is never a need to wait for that. WAIT_FOR* is to work
around (in most cases broken and should be fixed) sysfs timing issues
in the kernel. Seems, there is nothing in your event where that would
be needed.

What are you trying to wait for?

Kay

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: WAIT_FOR_SYSFS error, Is my udev rule wrong?
  2008-11-20  5:47 WAIT_FOR_SYSFS error, Is my udev rule wrong? Karl O. Pinc
  2008-11-20  6:30 ` Kay Sievers
@ 2008-11-20 14:37 ` Karl O. Pinc
  2008-11-20 14:49 ` Kay Sievers
  2008-11-20 15:41 ` Karl O. Pinc
  3 siblings, 0 replies; 5+ messages in thread
From: Karl O. Pinc @ 2008-11-20 14:37 UTC (permalink / raw)
  To: linux-hotplug


On 11/20/2008 12:30:19 AM, Kay Sievers wrote:
> On Thu, Nov 20, 2008 at 06:47, Karl O. Pinc <kop@meme.com> wrote:
> > I've written a udev rule and am looking
> > for comment by those with more experience
> > to see if there are improvements to be made.
> > KERNEL="ttyUSB0", ACTION="add", WAIT_FOR_SYSFS="subsystem/ttyUSB0"
> 

> The device you get the event for has only a single attribute, called
> "dev" and there is never a need to wait for that. WAIT_FOR* is to work
> around (in most cases broken and should be fixed) sysfs timing issues
> in the kernel. Seems, there is nothing in your event where that would
> be needed.
> 
> What are you trying to wait for?

I am trying to wait long enough that at startup the ldc4linux
daemon does not log the error:

Nov 19 16:15:00 mustard LCD4Linux[15799]: Pertelian: open(/dev/ttyUSB0)
failed: No such file or directory

It seems to work anyway, but I interpret the error to mean that
something in udev has not finished by the time the daemon
starts.  I don't get the error if I start lcd4linux
manually after plugging in the lcd panel.

Thanks for the help.

Karl <kop@meme.com>
Free Software:  "You don't pay back, you pay forward."
                  -- Robert A. Heinlein

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: WAIT_FOR_SYSFS error, Is my udev rule wrong?
  2008-11-20  5:47 WAIT_FOR_SYSFS error, Is my udev rule wrong? Karl O. Pinc
  2008-11-20  6:30 ` Kay Sievers
  2008-11-20 14:37 ` Karl O. Pinc
@ 2008-11-20 14:49 ` Kay Sievers
  2008-11-20 15:41 ` Karl O. Pinc
  3 siblings, 0 replies; 5+ messages in thread
From: Kay Sievers @ 2008-11-20 14:49 UTC (permalink / raw)
  To: linux-hotplug

On Thu, Nov 20, 2008 at 15:37, Karl O. Pinc <kop@meme.com> wrote:
> On 11/20/2008 12:30:19 AM, Kay Sievers wrote:
>>
>> On Thu, Nov 20, 2008 at 06:47, Karl O. Pinc <kop@meme.com> wrote:
>> > I've written a udev rule and am looking
>> > for comment by those with more experience
>> > to see if there are improvements to be made.
>> > KERNEL="ttyUSB0", ACTION="add", WAIT_FOR_SYSFS="subsystem/ttyUSB0"
>>
>
>> The device you get the event for has only a single attribute, called
>> "dev" and there is never a need to wait for that. WAIT_FOR* is to work
>> around (in most cases broken and should be fixed) sysfs timing issues
>> in the kernel. Seems, there is nothing in your event where that would
>> be needed.
>>
>> What are you trying to wait for?
>
> I am trying to wait long enough that at startup the ldc4linux
> daemon does not log the error:

We can be sure, the device file is there before any RUN+= instructions
are executed. You can not wait for anything here.

> Nov 19 16:15:00 mustard LCD4Linux[15799]: Pertelian: open(/dev/ttyUSB0)
> failed: No such file or directory
>
> It seems to work anyway, but I interpret the error to mean that
> something in udev has not finished by the time the daemon
> starts.  I don't get the error if I start lcd4linux
> manually after plugging in the lcd panel.

I guess the event for the serial device, not the only the tty, matches
your rule too, and you try to start the daemon twice. Try adding
SUBSYSTEM="tty". And remove the WAIT_FOR* rule, it will not do
anything, but print an error after 10 seconds.

Kay

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: WAIT_FOR_SYSFS error, Is my udev rule wrong?
  2008-11-20  5:47 WAIT_FOR_SYSFS error, Is my udev rule wrong? Karl O. Pinc
                   ` (2 preceding siblings ...)
  2008-11-20 14:49 ` Kay Sievers
@ 2008-11-20 15:41 ` Karl O. Pinc
  3 siblings, 0 replies; 5+ messages in thread
From: Karl O. Pinc @ 2008-11-20 15:41 UTC (permalink / raw)
  To: linux-hotplug


On 11/20/2008 08:49:28 AM, Kay Sievers wrote:

> I guess the event for the serial device, not the only the tty, matches
> your rule too, and you try to start the daemon twice. Try adding
> SUBSYSTEM="tty". And remove the WAIT_FOR* rule,

Works perfectly.  Thanks!

Karl <kop@meme.com>
Free Software:  "You don't pay back, you pay forward."
                  -- Robert A. Heinlein

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-11-20 15:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-20  5:47 WAIT_FOR_SYSFS error, Is my udev rule wrong? Karl O. Pinc
2008-11-20  6:30 ` Kay Sievers
2008-11-20 14:37 ` Karl O. Pinc
2008-11-20 14:49 ` Kay Sievers
2008-11-20 15:41 ` Karl O. Pinc

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).