Skip to contentSkip to conversation

Order of dvb devices

DISCUSSION Andreas Besse 7 participants 13 messages Jan 14, 2010 – Jan 18, 2010 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

if a system contains multiple DVB cards of the same type, how is the order of devices determined by the driver/kernel?

I use 2 Technotrend S2-3200 cards in a system and observerd that if I load the driver driver budget_ci manually as follows:

modprobe budget_ci adapter_nr=0,1

the device with the lower pci ID 0000:08:00.0 is assigned to adapter0 and the device with the higher pci ID 0000:08:01.0 is assigned to adapter1:

udevinfo -a -p $(udevinfo -q path -n /dev/dvb/adapter0/frontend0) [...]
looking at parent device '/devices/pci0000:00/0000:00:1e.0/0000:08:00.0':

    KERNELS=="0000:08:00.0"
    SUBSYSTEMS=="pci"

udevinfo -a -p $(udevinfo -q path -n /dev/dvb/adapter1/frontend0) [...]
looking at parent device '/devices/pci0000:00/0000:00:1e.0/0000:08:01.0':

    KERNELS=="0000:08:01.0"
    SUBSYSTEMS=="pci"

Is it true for all DVB drives that the device with the lower PCI id gets the lower adapter name?

#1 lore raw
Quoted 19 lines · Andreas Besse

if a system contains multiple DVB cards of the same type, how is the order of devices determined by the driver/kernel?

I use 2 Technotrend S2-3200 cards in a system and observerd that if I load the driver driver budget_ci manually as follows:

modprobe budget_ci adapter_nr=0,1

the device with the lower pci ID 0000:08:00.0 is assigned to adapter0 and the device with the higher pci ID 0000:08:01.0 is assigned to adapter1:

udevinfo -a -p $(udevinfo -q path -n /dev/dvb/adapter0/frontend0) [...]
 looking at parent device '/devices/pci0000:00/0000:00:1e.0/0000:08:00.0':
   KERNELS=="0000:08:00.0"
   SUBSYSTEMS=="pci"

Quoted 8 lines

udevinfo -a -p $(udevinfo -q path -n /dev/dvb/adapter1/frontend0) [...]
 looking at parent device '/devices/pci0000:00/0000:00:1e.0/0000:08:01.0':
   KERNELS=="0000:08:01.0"
   SUBSYSTEMS=="pci"

Is it true for all DVB drives that the device with the lower PCI id gets the lower adapter name?

No, you cannot really make this assumption. In fact, there are users who see behavior where uses have two of the same card and the cards get flipped around randomly just by rebooting. The ordering is based on the timing of the device driver loading, so it is not deterministic.

I believe you can use udev rules though to force a particular driver to get a specific adapter number (although admittedly I do not know the specifics of how it is done, and am not confident it *can* be done if both cards are the same vendor/model).

Devin

Signature · 2 lines
Devin J. Heitmueller - Kernel Labs
http://www.kernellabs.com
#2 lore raw
Quoted 28 lines · Devin Heitmueller
Quoted 26 lines · Andreas Besse

if a system contains multiple DVB cards of the same type, how is the order of devices determined by the driver/kernel?

I use 2 Technotrend S2-3200 cards in a system and observerd that if I load the driver driver budget_ci manually as follows:

modprobe budget_ci adapter_nr=0,1

the device with the lower pci ID 0000:08:00.0 is assigned to adapter0 and the device with the higher pci ID 0000:08:01.0 is assigned to adapter1:

udevinfo -a -p $(udevinfo -q path -n /dev/dvb/adapter0/frontend0) [...]
looking at parent device '/devices/pci0000:00/0000:00:1e.0/0000:08:00.0':

   KERNELS=="0000:08:00.0"
   SUBSYSTEMS=="pci"

udevinfo -a -p $(udevinfo -q path -n /dev/dvb/adapter1/frontend0) [...]
looking at parent device '/devices/pci0000:00/0000:00:1e.0/0000:08:01.0':

   KERNELS=="0000:08:01.0"
   SUBSYSTEMS=="pci"
Quoted 9 lines
Quoted 2 lines

Is it true for all DVB drives that the device with the lower PCI id gets the lower adapter name?

No, you cannot really make this assumption. In fact, there are users who see behavior where uses have two of the same card and the cards get flipped around randomly just by rebooting. The ordering is based on the timing of the device driver loading, so it is not deterministic.

yes if there are different drivers I already observed the behaviour that the ordering gets flipped after reboot.

But if I assume, that there is only *one* driver that is loaded (e.g. budget_av) for all dvb cards in the system, how is the ordering of these devices determined? How does the driver "search" for available dvb cards?

#3 lore raw
Quoted 6 lines · Andreas Besse

yes if there are different drivers I already observed the behaviour that the ordering gets flipped after reboot.

But if I assume, that there is only *one* driver that is loaded (e.g. budget_av) for all dvb cards in the system, how is the ordering of these devices determined? How does the driver "search" for available dvb cards?

I believe your assumption is incorrect. I believe the enumeration order is not deterministic even for multiple instances of the same driver. It is not uncommon to hear mythtv users complain that "I have two PVR-150 cards installed in my PC and the order sometimes get reversed on reboot".

Devin

Signature · 2 lines
Devin J. Heitmueller - Kernel Labs
http://www.kernellabs.com
#4 lore raw
Quoted 16 lines · Devin Heitmueller
Quoted 6 lines · Andreas Besse

yes if there are different drivers I already observed the behaviour that the ordering gets flipped after reboot.

But if I assume, that there is only *one* driver that is loaded (e.g. budget_av) for all dvb cards in the system, how is the ordering of these devices determined? How does the driver "search" for available dvb cards?

I believe your assumption is incorrect.  I believe the enumeration order is not deterministic even for multiple instances of the same driver.  It is not uncommon to hear mythtv users complain that "I have two PVR-150 cards installed in my PC and the order sometimes get reversed on reboot".

Devin

Quoted 8 lines

--
Devin J. Heitmueller - Kernel Labs
http://www.kernellabs.com
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

If you "modinfo dvb_adapter_driver_foo" you will see an "adapter_nr" module option -- you can use this to force your DVB adapter device minor ordering.

Regards,

Mike

#5 lore raw
In reply to Devin Heitmueller
Quoted 7 lines · Devin Heitmueller
Quoted 6 lines · Andreas Besse

yes if there are different drivers I already observed the behaviour that the ordering gets flipped after reboot.

But if I assume, that there is only *one* driver that is loaded (e.g. budget_av) for all dvb cards in the system, how is the ordering of these devices determined? How does the driver "search" for available dvb cards?

The driver does not 'search' for a card. The driver registers the ids of all supported cards with the pci subsystem of the kernel.

When the pci subsystem detects a new card, it calls the 'probe' routine of the driver (for example saa7146_init_one for saa7146-based cards). So the ordering is determined by the pci subsystem.

Quoted 5 lines

I believe your assumption is incorrect. I believe the enumeration order is not deterministic even for multiple instances of the same driver. It is not uncommon to hear mythtv users complain that "I have two PVR-150 cards installed in my PC and the order sometimes get reversed on reboot".

Afaik the indeterministic behaviour is caused by udev, not by the kernel. We never had these problems before udev was introduced.

CU
Oliver

Signature · 5 lines
----------------------------------------------------------------
VDR Remote Plugin 0.4.0: http://www.escape-edv.de/endriss/vdr/
4 MByte Mod: http://www.escape-edv.de/endriss/dvb-mem-mod/
Full-TS Mod: http://www.escape-edv.de/endriss/dvb-full-ts-mod/
----------------------------------------------------------------
#6 lore raw
Quoted 8 lines · Oliver Endriss
Quoted 5 lines

I believe your assumption is incorrect.  I believe the enumeration order is not deterministic even for multiple instances of the same driver.  It is not uncommon to hear mythtv users complain that "I have two PVR-150 cards installed in my PC and the order sometimes get reversed on reboot".

Afaik the indeterministic behaviour is caused by udev, not by the kernel. We never had these problems before udev was introduced.

I suppose it's possible that udev does not process the events in the order in which they are received. Admittedly I have not done any real analysis as to how that part of the kernel works.

Devin

Signature · 2 lines
Devin J. Heitmueller - Kernel Labs
http://www.kernellabs.com
#7 lore raw
In reply to Oliver Endriss
Quoted 16 lines · Oliver Endriss
Quoted 7 lines · Devin Heitmueller
Quoted 6 lines · Andreas Besse

yes if there are different drivers I already observed the behaviour that the ordering gets flipped after reboot.

But if I assume, that there is only *one* driver that is loaded (e.g. budget_av) for all dvb cards in the system, how is the ordering of these devices determined? How does the driver "search" for available dvb cards?

The driver does not 'search' for a card. The driver registers the ids of all supported cards with the pci subsystem of the kernel.

When the pci subsystem detects a new card, it calls the 'probe' routine of the driver (for example saa7146_init_one for saa7146-based cards). So the ordering is determined by the pci subsystem.

Quoted 8 lines
Quoted 5 lines

I believe your assumption is incorrect.  I believe the enumeration order is not deterministic even for multiple instances of the same driver.  It is not uncommon to hear mythtv users complain that "I have two PVR-150 cards installed in my PC and the order sometimes get reversed on reboot".

Afaik the indeterministic behaviour is caused by udev, not by the kernel. We never had these problems before udev was introduced.

True, the ordering is not exactly the same everytime. One will need to provide PCI Bus related info also to a practical udev configuration to get things sorted out in a sane way, rather than anything else.

Regards,
Manu

#8 lore raw
Quoted 3 lines

True, the ordering is not exactly the same everytime. One will need to provide PCI Bus related info also to a practical udev configuration to get things sorted out in a sane way, rather than anything else.

At least in Mandriva, the order and naming of network adapters are handled by using a this kind of udev rule which prevents for example eth0 and eth1 to swap between boots:

[lamikr@iiris rules.d]$ cat 70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules # program, run by the persistent-net-generator.rules rules file. #
# You can modify it, as long as you keep each rule on a single # line, and change only the value of the NAME= key.

# Drakx-net rule for eth0 (00:24:e8:9e:66:13)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:11:22:33:44:55", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0

# PCI device 0x8086:0x4232 (iwlagn)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="11:22:33:44:55:66", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan0""

I am not sure whether udev rules itself can originally generate this file or whether it's mandriva's own tools/scripts that will generate this file and add all new adapters it finds that are not yet in the file.

Mika

#9 lore raw
In reply to Manu Abraham
Quoted 27 lines · Manu Abraham
Quoted 25 lines · Oliver Endriss
Quoted 9 lines · Devin Heitmueller
Quoted 7 lines · Andreas Besse

yes if there are different drivers I already observed the behaviour that the ordering gets flipped after reboot.

But if I assume, that there is only *one* driver that is loaded (e.g. budget_av) for all dvb cards in the system, how is the ordering of these devices determined? How does the driver "search" for available dvb cards?

The driver does not 'search' for a card. The driver registers the ids of all supported cards with the pci subsystem of the kernel.

When the pci subsystem detects a new card, it calls the 'probe' routine of the driver (for example saa7146_init_one for saa7146-based cards). So the ordering is determined by the pci subsystem.

Quoted 6 lines

I believe your assumption is incorrect. I believe the enumeration order is not deterministic even for multiple instances of the same driver. It is not uncommon to hear mythtv users complain that "I have two PVR-150 cards installed in my PC and the order sometimes get reversed on reboot".

Quoted 9 lines
Quoted 3 lines

Afaik the indeterministic behaviour is caused by udev, not by the kernel. We never had these problems before udev was introduced.

True, the ordering is not exactly the same everytime. One will need to provide PCI Bus related info also to a practical udev configuration to get things sorted out in a sane way, rather than anything else.

with "PCI Bus related info" you mean the KERNELS parameter which is reported by udevinfo?

udevinfo -a -p $(udevinfo -q path -n /dev/dvb/adapter0/frontend0) [...]
looking at parent device '/devices/pci0000:00/0000:00:1e.0/0000:08:00.0':

    KERNELS=="0000:08:00.0"
    SUBSYSTEMS=="pci"

does this KERNELS parameter always match the Slot-Id of "lspci -vmm" ?

Slot:   08:00.0
Class:  Multimedia controller
Vendor: Philips Semiconductors
Device: SAA7146
SVendor:        Technotrend Systemtechnik GmbH
SDevice:        S2-3200
Rev:    01

is it right that the Slot-Id is deterministic for PCI/PCIe based systems?

#10 lore raw
Quoted 55 lines · Andreas Besse
Quoted 27 lines · Manu Abraham
Quoted 25 lines · Oliver Endriss
Quoted 9 lines · Devin Heitmueller
Quoted 7 lines · Andreas Besse

yes if there are different drivers I already observed the behaviour that the ordering gets flipped after reboot.

But if I assume, that there is only *one* driver that is loaded (e.g. budget_av) for all dvb cards in the system, how is the ordering of these devices determined? How does the driver "search" for available dvb cards?

The driver does not 'search' for a card. The driver registers the ids of all supported cards with the pci subsystem of the kernel.

When the pci subsystem detects a new card, it calls the 'probe' routine of the driver (for example saa7146_init_one for saa7146-based cards). So the ordering is determined by the pci subsystem.

Quoted 6 lines

I believe your assumption is incorrect.  I believe the enumeration order is not deterministic even for multiple instances of the same driver.  It is not uncommon to hear mythtv users complain that "I have two PVR-150 cards installed in my PC and the order sometimes get reversed on reboot".

Quoted 9 lines
Quoted 3 lines

Afaik the indeterministic behaviour is caused by udev, not by the kernel. We never had these problems before udev was introduced.

True, the ordering is not exactly the same everytime. One will need to provide PCI Bus related info also to a practical udev configuration to get things sorted out in a sane way, rather than anything else.

with "PCI Bus related info" you mean the KERNELS parameter which is reported by udevinfo?

udevinfo -a -p $(udevinfo -q path -n /dev/dvb/adapter0/frontend0) [...]
 looking at parent device '/devices/pci0000:00/0000:00:1e.0/0000:08:00.0':
   KERNELS=="0000:08:00.0"
   SUBSYSTEMS=="pci"

does this KERNELS parameter always match the Slot-Id of "lspci -vmm" ?
Slot:   08:00.0
Class:  Multimedia controller
Vendor: Philips Semiconductors
Device: SAA7146
SVendor:        Technotrend Systemtechnik GmbH
SDevice:        S2-3200
Rev:    01

Quoted 1 line

is it right that the Slot-Id is deterministic for PCI/PCIe based systems?

Slot can also change, since slots are behind a specific bridge which could be susceptible to events such as hotplug. Also things such as PCI reordering and things like that tend to muck up things even more.Things such as DVB_ADAPTER number are also pointless and useless.

You can see an example how to handle it in a bit practical manner:
http://www.wlug.org.nz/UDev

Regards,
Manu

#11 lore raw
Quoted 68 lines · Manu Abraham
Quoted 62 lines · Andreas Besse
Quoted 33 lines · Manu Abraham
Quoted 30 lines · Oliver Endriss
Quoted 11 lines · Devin Heitmueller
Quoted 8 lines · Andreas Besse

yes if there are different drivers I already observed the behaviour that the ordering gets flipped after reboot.

But if I assume, that there is only *one* driver that is loaded (e.g. budget_av) for all dvb cards in the system, how is the ordering of these devices determined? How does the driver "search" for available dvb cards?

The driver does not 'search' for a card. The driver registers the ids of all supported cards with the pci subsystem of the kernel.

When the pci subsystem detects a new card, it calls the 'probe' routine of the driver (for example saa7146_init_one for saa7146-based cards). So the ordering is determined by the pci subsystem.

Quoted 7 lines

I believe your assumption is incorrect. I believe the enumeration order is not deterministic even for multiple instances of the same driver. It is not uncommon to hear mythtv users complain that "I have two PVR-150 cards installed in my PC and the order sometimes get reversed on reboot".

Quoted 9 lines
Quoted 4 lines

Afaik the indeterministic behaviour is caused by udev, not by the kernel. We never had these problems before udev was introduced.

True, the ordering is not exactly the same everytime. One will need to provide PCI Bus related info also to a practical udev configuration to get things sorted out in a sane way, rather than anything else.

with "PCI Bus related info" you mean the KERNELS parameter which is reported by udevinfo?

udevinfo -a -p $(udevinfo -q path -n /dev/dvb/adapter0/frontend0) [...]
looking at parent device '/devices/pci0000:00/0000:00:1e.0/0000:08:00.0':

   KERNELS=="0000:08:00.0"
   SUBSYSTEMS=="pci"

does this KERNELS parameter always match the Slot-Id of "lspci -vmm" ?

Slot:   08:00.0
Class:  Multimedia controller
Vendor: Philips Semiconductors
Device: SAA7146
SVendor:        Technotrend Systemtechnik GmbH
SDevice:        S2-3200
Rev:    01
Quoted 2 lines

is it right that the Slot-Id is deterministic for PCI/PCIe based systems?

Quoted 10 lines

Slot can also change, since slots are behind a specific bridge which could be susceptible to events such as hotplug. Also things such as PCI reordering and things like that tend to muck up things even more.Things such as DVB_ADAPTER number are also pointless and useless.

You can see an example how to handle it in a bit practical manner:
http://www.wlug.org.nz/UDev
thanks for your explanation.

thank for your answer.

if no hotplug (removing or adding PCI/PCie cards) is involved, is the PCI Slot-ID then fixed?

does the KERNELS parameter of the following udev rule not change after boot if no hotplug is involved?

SUBSYSTEM=="dvb", ATTRS{vendor}=="0x18c3", ATTRS{device}=="0x0720", KERNELS=="0000:01:00.0",
PROGRAM="/bin/sh -c 'K=%k; K=$${K#dvb}; printf dvb/adapter0/%%s $${K#*.}'", SYMLINK+="%c"

#12 lore raw
In reply to Oliver Endriss

Am Samstag, den 16.01.2010, 00:00 +0100 schrieb Oliver Endriss:

Quoted 22 lines
Quoted 7 lines · Devin Heitmueller
Quoted 6 lines · Andreas Besse

yes if there are different drivers I already observed the behaviour that the ordering gets flipped after reboot.

But if I assume, that there is only *one* driver that is loaded (e.g. budget_av) for all dvb cards in the system, how is the ordering of these devices determined? How does the driver "search" for available dvb cards?

The driver does not 'search' for a card. The driver registers the ids of all supported cards with the pci subsystem of the kernel.

When the pci subsystem detects a new card, it calls the 'probe' routine of the driver (for example saa7146_init_one for saa7146-based cards). So the ordering is determined by the pci subsystem.

Quoted 5 lines

I believe your assumption is incorrect. I believe the enumeration order is not deterministic even for multiple instances of the same driver. It is not uncommon to hear mythtv users complain that "I have two PVR-150 cards installed in my PC and the order sometimes get reversed on reboot".

Quoted 6 lines

Afaik the indeterministic behaviour is caused by udev, not by the kernel. We never had these problems before udev was introduced.

CU
Oliver

Agreed.

Hermann