Dan Streetman | 1 Jun 2009 18:13
Picon

Using udev-extras for hardware-specific quirks?

Hello,

I am creating udev rules for some system units I'm responsible for
enabling Linux on; specifically these systems have multiple serial
ports with labels on the ports like "A", "B", "C", etc.  However on
many of the units the hardware doesn't match the labelling so ports
"C" and above usually do not match the right serial node, i.e. while a
port labeled "C" should be /dev/ttyS2 it isn't.

The initial udev rule I set up for one system is below - just as an
example of what I'm planning on creating.  As you can see this
particular system has a PCI serial card, with the middle 2 ports
actually wired up to the rear panel and labeled "C" and "D".  The
other 4 ports aren't actually wired up, so this rule could be changed
to ignore those instead of creating nodes for them.

Anyway, my question is, is udev-extras the appropriate place for this
to live?  I would like to put the rules into a standard location that
all distros can pull from.  It seems like DeviceKit and udev-extras is
the direction that everything is going in, but I'm not sure if
udev-extras is intended to hold system-specific quirk rules like this.
 If it is, then I would like to get this added once we finish up all
the rules for our system units.  Also, any comments/suggestions on how
I'm writing the rules are welcome.

Thanks!
--

SUBSYSTEM!="tty", GOTO="ibmrss-serial-end"
PROGRAM="/bin/cat $sys/class/dmi/id/board_vendor"
(Continue reading)

Martin Pitt | 3 Jun 2009 12:39
Favicon
Gravatar

hal -> udev migration for libgphoto2

Hello Marcus, hello DeviceKitters,

one part of the "Halsectomy" [1] is the migration of the libgphoto
integration from hal.

Current system
==============

(1) libgphoto2 creates fdi/preprobe/10osvendor/20-libgphoto2.fdi on
    installation (generated with print-camera-list). This FDI has all
    gphoto-supported cameras with access type and name.

(2) gvfs and KDE listen to hal and trigger a camera action for a device
    with the "camera" info.capabilities.

(3) /dev/bus/usb/ access is currently handled in various ways:

  * Ubuntu development release (and I guess the latest Fedora) use
    udev-extras to grant access to the current local foreground
    session user for PtP cameras [2]

  * Ubuntu stable releases and older Fedora/OpenSUSE use the hal
    automatic ACL management which does more or less the same as
    udev-extras' 70-acl.rules.

  * Debian uses print-camera-list to generate an udev .rules file
    which makes all camera USB devices 0770 root:plugdev. This is
    obsolete now, since Debian currently uses hal auto-ACLs.

At some point we need to rip out hal from this chain. Has there been
(Continue reading)

Martin Pitt | 3 Jun 2009 12:47
Favicon
Gravatar

Re: hal -> udev migration for libgphoto2

Martin Pitt [2009-06-03 12:39 +0200]:
>   ENV{ID_CLASS}="camera"

Oops, that won't work well; my mobile phone is a camera, a music
player, and a modem all at the same time. So this should perhaps be

  ENV{ID_CAMERA}="1"

? Kay, is there an established standard practice for tagging the
class/capabilities of a device?

Martin
--

-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
_______________________________________________
devkit-devel mailing list
devkit-devel <at> lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/devkit-devel
Dan Streetman | 3 Jun 2009 15:26
Picon

Re: Using udev-extras for hardware-specific quirks?

Hello...Martin, Kay, and thoughts on my question regarding udev-extras?

On Mon, Jun 1, 2009 at 12:13 PM, Dan Streetman <ddstreet <at> ieee.org> wrote:
> Hello,
>
> I am creating udev rules for some system units I'm responsible for
> enabling Linux on; specifically these systems have multiple serial
> ports with labels on the ports like "A", "B", "C", etc.  However on
> many of the units the hardware doesn't match the labelling so ports
> "C" and above usually do not match the right serial node, i.e. while a
> port labeled "C" should be /dev/ttyS2 it isn't.
>
> The initial udev rule I set up for one system is below - just as an
> example of what I'm planning on creating.  As you can see this
> particular system has a PCI serial card, with the middle 2 ports
> actually wired up to the rear panel and labeled "C" and "D".  The
> other 4 ports aren't actually wired up, so this rule could be changed
> to ignore those instead of creating nodes for them.
>
> Anyway, my question is, is udev-extras the appropriate place for this
> to live?  I would like to put the rules into a standard location that
> all distros can pull from.  It seems like DeviceKit and udev-extras is
> the direction that everything is going in, but I'm not sure if
> udev-extras is intended to hold system-specific quirk rules like this.
>  If it is, then I would like to get this added once we finish up all
> the rules for our system units.  Also, any comments/suggestions on how
> I'm writing the rules are welcome.
>
> Thanks!
> --
(Continue reading)

Martin Pitt | 3 Jun 2009 15:39
Favicon
Gravatar

Re: Using udev-extras for hardware-specific quirks?

Hello Dan,

Dan Streetman [2009-06-01 12:13 -0400]:
> I am creating udev rules for some system units I'm responsible for
> enabling Linux on; specifically these systems have multiple serial
> ports with labels on the ports like "A", "B", "C", etc.  However on
> many of the units the hardware doesn't match the labelling so ports
> "C" and above usually do not match the right serial node, i.e. while a
> port labeled "C" should be /dev/ttyS2 it isn't.

This is just a general property of current Linux, which is pretty much
fully "hotplug" based. You cant't rely at all on any particular device
ordering in general. Distributions special-case some device classes
such as network devices where (for historical reasons) eth0 must
always be the same device. E. g. Ubuntu's installer creates a file
/etc/udev/rules.d/70-persistent-net.rules  which looks like

# PCI device 0x14e4:0x1600 (tg3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1c:23:14:1c:2a",
ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

You can apply a similar "persistent naming" rule on your system.

> Anyway, my question is, is udev-extras the appropriate place for this
> to live?

I'm afraid not. Programs need to be fixed to not rely on a particular
device name instead.

> DEVPATH=="/devices/pci0000:00/0000:00:13.1/0000:04:0b.1/tty/ttyS2", NAME="ttyS6"
(Continue reading)

Daniel D Streetman | 3 Jun 2009 16:48
Picon
Favicon

Re: Using udev-extras for hardware-specific quirks?

devkit-devel-bounces <at> lists.freedesktop.org wrote on 06/03/2009 09:39:22 AM:

> Hello Dan,
>
> Dan Streetman [2009-06-01 12:13 -0400]:
> > I am creating udev rules for some system units I'm responsible for
> > enabling Linux on; specifically these systems have multiple serial
> > ports with labels on the ports like "A", "B", "C", etc.  However on
> > many of the units the hardware doesn't match the labelling so ports
> > "C" and above usually do not match the right serial node, i.e. while a
> > port labeled "C" should be /dev/ttyS2 it isn't.
>
> This is just a general property of current Linux, which is pretty much
> fully "hotplug" based. You cant't rely at all on any particular device
> ordering in general.

Well that is the problem, isn't it?  With serial ports there is absolutely nothing to go on to tell what physical port it is except for numbering.  The application cannot probe a serial port to tell what's connected.

> Distributions special-case some device classes
> such as network devices where (for historical reasons) eth0 must
> always be the same device. E. g. Ubuntu's installer creates a file
> /etc/udev/rules.d/70-persistent-net.rules  which looks like
>
> # PCI device 0x14e4:0x1600 (tg3)
> SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:
> 1c:23:14:1c:2a", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
>
> You can apply a similar "persistent naming" rule on your system.

Well, I don't think this will work as the problem isn't consistent naming - serial ports are not added/removed and so there is no danger of inconsistent numbering, the ports are always numbered exactly the same - the problem is they are numbered wrong, i.e. not matching the labeling on the physical system.

I could create permanent "persistent naming" rules such as the above one to correctly number the ports, but I don't think that is what you mean - you mean I should create a dynamic rule to create those persistent naming rules on-the-fly as serial ports are (first) detected.  That is what you mean right?

Also to clarify, I'm not looking to create a rule for just my system - I am trying to create a permanent rule that I can upstream into a common repository that all distributions can draw from so the various quirks on these systems can be correctly handled by all distributions.

> > Anyway, my question is, is udev-extras the appropriate place for this
> > to live?
>
> I'm afraid not. Programs need to be fixed to not rely on a particular
> device name instead.

With serial ports?  How can an application not rely on the serial port number?  For other types of interfaces, USB devices, ethernet interfaces, displays, whatever - I can understand that.  But ever since serial ports were invented, the port number is the one and only thing the application can use.  Right?

>
> > DEVPATH=="/devices/pci0000:00/0000:00:13.1/0000:04:0b.1/tty/
> ttyS2", NAME="ttyS6"
>
> This really looks wrong. Since the initial naming isn't stable, the
> mapping isn't either. You need to identify a particular device on
> stable properties such as device names, serial numbers, or other
> constant properties.

For PCI-card based serial ports, there are no other device properties besides the PCI address and kernel-assigned name.  Or do you know of any other properties I can key off of?  I checked with "udevadm info -q all -n /dev/ttyS2" for example and only DEVPATH and the simple name were defined.

I'm more than willing to key off a hardware-specific constant key, but I don't think a PCI serial port has any, besides the specific PCI connectivity.  And even then, the entire PCI add-in card has a common PCI address/path, so I don't see any way to distinguish each individual port on the PCI serial card besides the port name...?

>
> Martin
>
> --
> Martin Pitt                        | http://www.piware.de
> Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
> _______________________________________________
> devkit-devel mailing list
> devkit-devel <at> lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/devkit-devel

_______________________________________________
devkit-devel mailing list
devkit-devel <at> lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/devkit-devel
David Zeuthen | 3 Jun 2009 18:03
Picon
Gravatar

Re: hal -> udev migration for libgphoto2

Hi,

On Wed, 2009-06-03 at 12:47 +0200, Martin Pitt wrote:
> Martin Pitt [2009-06-03 12:39 +0200]:
> >   ENV{ID_CLASS}="camera"
> 
> Oops, that won't work well; my mobile phone is a camera, a music
> player, and a modem all at the same time. So this should perhaps be
> 
>   ENV{ID_CAMERA}="1"

I would suggest to use

 ENV{ID_GPHOTO2}="1"

and also use GPHOTO2 as a namespace, e.g.

 ENV{GPHOTO2_DRIVER}="PTP"

or something. Just makes it easier and more future-proof if there will
be a libgphoto3 or other usermode libraries providing access to cameras.

     David
Martin Pitt | 3 Jun 2009 18:56
Favicon
Gravatar

Re: Using udev-extras for hardware-specific quirks?

Hello Daniel,

Daniel D Streetman [2009-06-03 10:48 -0400]:
> Well that is the problem, isn't it?  With serial ports there is absolutely
> nothing to go on to tell what physical port it is except for numbering.

Right, that might be more tricky. I actually can't test it here, it's
been a long time since I had a machine with a real serial port.

> Well, I don't think this will work as the problem isn't consistent naming -
> serial ports are not added/removed and so there is no danger of
> inconsistent numbering

I wouldn't rely too much on it. Ethernet cards aren't added/removed
either, and yet without the persistency rules they get a pretty much
random order on boot. I guess the ordering is more reliable for serial
ports since they are all covered by the same driver (unlike the two
ethernet cards I used to have).

> I could create permanent "persistent naming" rules such as the above one to
> correctly number the ports, but I don't think that is what you mean - you
> mean I should create a dynamic rule to create those persistent naming rules
> on-the-fly as serial ports are (first) detected.  That is what you mean
> right?

Not really on the fly, just attaching the name to a physical attribute
which stays constant across reboots. If there is none, then I guess
you can keep your current rules which just rename the interfaces.

> Also to clarify, I'm not looking to create a rule for just my system - I am
> trying to create a permanent rule that I can upstream into a common
> repository that all distributions can draw from so the various quirks on
> these systems can be correctly handled by all distributions.

Right, I understood your intention, but I don't think we want
arbitrary renaming like that, since they are going to have a different
effect on every machine anyway, and one order is as good as the other
usually.

> With serial ports?  How can an application not rely on the serial port
> number?  For other types of interfaces, USB devices, ethernet interfaces,
> displays, whatever - I can understand that.  But ever since serial ports
> were invented, the port number is the one and only thing the application
> can use.  Right?

Right, that's true. Probably one of the reasons why they are
considered "legacy".

Usually, when there is a device on a port, there is often a way to
probe that device instead of the port it is attached to (which is what
you actually want in most cases). That needs an external probe program
with RUN/IMPORT, and is very specific to the type of hardware you
attach.

> For PCI-card based serial ports, there are no other device properties
> besides the PCI address and kernel-assigned name.

The PCI device should have an unique physical slot name
(PCI_SLOT_NAME), but that won't help you, since I guess one PCI device
drives all of your serial ports?

So I think you should either locally keep your current renaming, or
perhaps just swap the stickers to have the correct number :)

Martin
--

-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
Martin Pitt | 3 Jun 2009 18:57
Favicon
Gravatar

Re: hal -> udev migration for libgphoto2

Hello all,

David Zeuthen [2009-06-03 12:03 -0400]:
> I would suggest to use
> 
>  ENV{ID_GPHOTO2}="1"
> 
> and also use GPHOTO2 as a namespace, e.g.
> 
>  ENV{GPHOTO2_DRIVER}="PTP"

Works for me. If Marcus is fine with that, I'll work on some patches
and send them bugzilla-wards.

Thanks,

Martin
--

-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
Dan Streetman | 3 Jun 2009 22:44
Picon
Favicon

Re: Using udev-extras for hardware-specific quirks?

On Wed, Jun 3, 2009 at 12:56 PM, Martin Pitt <martin.pitt <at> ubuntu.com> wrote:
> Hello Daniel,
>
> Daniel D Streetman [2009-06-03 10:48 -0400]:
>> Well that is the problem, isn't it?  With serial ports there is absolutely
>> nothing to go on to tell what physical port it is except for numbering.
>
> Right, that might be more tricky. I actually can't test it here, it's
> been a long time since I had a machine with a real serial port.
>
>> Well, I don't think this will work as the problem isn't consistent naming -
>> serial ports are not added/removed and so there is no danger of
>> inconsistent numbering
>
> I wouldn't rely too much on it. Ethernet cards aren't added/removed
> either, and yet without the persistency rules they get a pretty much
> random order on boot. I guess the ordering is more reliable for serial
> ports since they are all covered by the same driver (unlike the two
> ethernet cards I used to have).
>
>> I could create permanent "persistent naming" rules such as the above one to
>> correctly number the ports, but I don't think that is what you mean - you
>> mean I should create a dynamic rule to create those persistent naming rules
>> on-the-fly as serial ports are (first) detected.  That is what you mean
>> right?
>
> Not really on the fly, just attaching the name to a physical attribute
> which stays constant across reboots. If there is none, then I guess
> you can keep your current rules which just rename the interfaces.
>
>> Also to clarify, I'm not looking to create a rule for just my system - I am
>> trying to create a permanent rule that I can upstream into a common
>> repository that all distributions can draw from so the various quirks on
>> these systems can be correctly handled by all distributions.
>
> Right, I understood your intention, but I don't think we want
> arbitrary renaming like that, since they are going to have a different
> effect on every machine anyway,

Well I am using the system vendor/product IDs from dmi so the rules
would only apply for the specific systems I'm working on - on any
other systems they would be skipped entirely.  I was hoping that
udev-extras would be the right place to put system-specific quirks
like this.

> and one order is as good as the other
> usually.

Well, not in my case.  Customers expect the numbering to match the labeling.

>
>> With serial ports?  How can an application not rely on the serial port
>> number?  For other types of interfaces, USB devices, ethernet interfaces,
>> displays, whatever - I can understand that.  But ever since serial ports
>> were invented, the port number is the one and only thing the application
>> can use.  Right?
>
> Right, that's true. Probably one of the reasons why they are
> considered "legacy".
>
> Usually, when there is a device on a port, there is often a way to
> probe that device instead of the port it is attached to (which is what
> you actually want in most cases). That needs an external probe program
> with RUN/IMPORT, and is very specific to the type of hardware you
> attach.
>
>> For PCI-card based serial ports, there are no other device properties
>> besides the PCI address and kernel-assigned name.
>
> The PCI device should have an unique physical slot name
> (PCI_SLOT_NAME), but that won't help you, since I guess one PCI device
> drives all of your serial ports?

For this particular system, yep.  There are 2 standard ports on the
mainboard, ttyS0 and ttyS1, and a single (integrated) PCI chip that
provides the rest.  So none of the PCI hardware's information helps to
distinguish between any of the individual ports it provides.  I could
check each port's irq and ioport information, but I suspect that is
even more dynamic, as I assume the PCI serial driver probably can
assign whatever IRQ and ioport addresses it wants to its ports.  Maybe
I should get into the PCI serial driver and see how static or dynamic
it really is with numbering/naming and with IRQ/ioport assignment...

>
> So I think you should either locally keep your current renaming,

Well my choices are either maintain these udev rules and ship them to
customers as an add-on, or get the udev rules upstream somewhere so I
don't have to ship it specifically to customers.  As maintaining the
udev rules myself is not really the Open Source way of doing things
(plus it's more work for me and all customers), I would of course
prefer to upstream the udev rules.  I do have a SysV init (bash)
script (that I inherited) that was previously sent to any Linux
customers that remaps the serial ports to match the labeling.  I would
prefer to do it the right way (or at least "better" way) instead of
continuing to maintain and ship that to customers.

So if udev-extras isn't the right place for this, any suggestions on
where might be the right place?  Or do you think I should try a
completely different approach instead of udev rules?

I will mention again that the rules I am proposing are system
vendor/product-specific, i.e. they will be skipped entirely on systems
whose DMI info does not match.  In the example I included I did leave
out one line (the lone GOTO) so it should have read:

SUBSYSTEM!="tty", GOTO="ibmrss-serial-end"
PROGRAM="/bin/cat $sys/class/dmi/id/board_vendor"
RESULT!="IBM*", GOTO="ibmrss-serial-end"

PROGRAM="/bin/cat $sys/class/dmi/id/board_version"
RESULT=="4800783", GOTO="ibmrss-serial-4800783"
GOTO="ibmrss-serial-end"

LABEL="ibmrss-serial-4800783"
DEVPATH=="/devices/pci0000:00/0000:00:13.1/0000:04:0b.1/tty/ttyS2", NAME="ttyS6"
DEVPATH=="/devices/pci0000:00/0000:00:13.1/0000:04:0b.1/tty/ttyS3", NAME="ttyS7"
DEVPATH=="/devices/pci0000:00/0000:00:13.1/0000:04:0b.1/tty/ttyS4", NAME="ttyS2"
DEVPATH=="/devices/pci0000:00/0000:00:13.1/0000:04:0b.1/tty/ttyS5", NAME="ttyS3"
DEVPATH=="/devices/pci0000:00/0000:00:13.1/0000:04:0b.1/tty/ttyS6", NAME="ttyS4"
DEVPATH=="/devices/pci0000:00/0000:00:13.1/0000:04:0b.1/tty/ttyS7", NAME="ttyS5"
GOTO="ibmrss-serial-end"

LABEL="ibmrss-serial-end"

So for this case unless the DMI vendor string matches "IBM*" and the
version string matches "4800783" then the rule is not applied.  I
would add more rules for each of the system units with this serial
port remapping quirk (which is several).  The GOTO logic could be
changed of course if it should be different.  I also think the DMI
product_vendor and product_version is better to use instead of
board_vendor and board_version, but that's just details.

> or perhaps just swap the stickers to have the correct number :)

Well it's screen printed onto tens of thousands of units, many of
which are already shipped to customers so that probably would be
tough. ;-)

>
> Martin
> --
> Martin Pitt                        | http://www.piware.de
> Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
> _______________________________________________
> devkit-devel mailing list
> devkit-devel <at> lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/devkit-devel
>
_______________________________________________
devkit-devel mailing list
devkit-devel <at> lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/devkit-devel

Gmane