Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a machine with multiple capture cards in PCI express slots. For ease of trouble shooting stuff, I would like for the devices to appear on the OS in order of their physical position when I'm plugging them in or unplugging them from the machine. Here is a list of the devices I get from the command lspci | grep lackmagic

0a:00.0 Multimedia video controller: Blackmagic Design Device a117
0d:00.0 Multimedia video controller: Blackmagic Design Device a117
10:00.0 Multimedia video controller: Blackmagic Design Device a117
18:00.0 Multimedia video controller: Blackmagic Design Device a117
1b:00.0 Multimedia video controller: Blackmagic Design Device a117
1e:00.0 Multimedia video controller: Blackmagic Design Device a117
21:00.0 Multimedia video controller: Blackmagic Design Device a117
24:00.0 Multimedia video controller: Blackmagic Design Device a117

and here is the relevant stuff from my dmesg | grep lackmagic.

[   16.105068] blackmagic: module license 'Proprietary' taints kernel.
[   16.110742] blackmagic: Loading driver (version: 8.0.1rc4)
[   16.111152] blackmagic_driver 0000:0a:00.0: PCI INT A -> GSI 28 (level, low) -> IRQ 28
[   16.111163] blackmagic_driver 0000:0a:00.0: setting latency timer to 64
[   16.111215] blackmagic_driver 0000:0a:00.0: setting latency timer to 64
[   18.248018] blackmagic: Successfully loaded device "blackmagic0" [pci@0000:0a:00.0]
[   18.248136] blackmagic_driver 0000:10:00.0: PCI INT A -> GSI 26 (level, low) -> IRQ 26
[   18.248142] blackmagic_driver 0000:10:00.0: setting latency timer to 64
[   18.248175] blackmagic_driver 0000:10:00.0: setting latency timer to 64
[   20.372321] blackmagic: Successfully loaded device "blackmagic1" [pci@0000:10:00.0]
[   20.372483] blackmagic_driver 0000:0d:00.0: PCI INT A -> GSI 30 (level, low) -> IRQ 30
[   20.372489] blackmagic_driver 0000:0d:00.0: setting latency timer to 64
[   20.372520] blackmagic_driver 0000:0d:00.0: setting latency timer to 64
[   22.497786] blackmagic: Successfully loaded device "blackmagic2" [pci@0000:0d:00.0]
[   22.497929] blackmagic_driver 0000:18:00.0: PCI INT A -> GSI 52 (level, low) -> IRQ 52
[   22.497937] blackmagic_driver 0000:18:00.0: setting latency timer to 64
[   22.497976] blackmagic_driver 0000:18:00.0: setting latency timer to 64
[   24.621774] blackmagic: Successfully loaded device "blackmagic3" [pci@0000:18:00.0]
[   24.621906] blackmagic_driver 0000:21:00.0: PCI INT A -> GSI 48 (level, low) -> IRQ 48
[   24.621912] blackmagic_driver 0000:21:00.0: setting latency timer to 64
[   24.621946] blackmagic_driver 0000:21:00.0: setting latency timer to 64
[   26.745616] blackmagic: Successfully loaded device "blackmagic4" [pci@0000:21:00.0]
[   26.745737] blackmagic_driver 0000:24:00.0: PCI INT A -> GSI 54 (level, low) -> IRQ 54
[   26.745742] blackmagic_driver 0000:24:00.0: setting latency timer to 64
[   26.745775] blackmagic_driver 0000:24:00.0: setting latency timer to 64
[   28.870874] blackmagic: Successfully loaded device "blackmagic5" [pci@0000:24:00.0]
[   28.870994] blackmagic_driver 0000:1e:00.0: PCI INT A -> GSI 55 (level, low) -> IRQ 55
[   28.871001] blackmagic_driver 0000:1e:00.0: setting latency timer to 64
[   28.871036] blackmagic_driver 0000:1e:00.0: setting latency timer to 64
[   30.995130] blackmagic: Successfully loaded device "blackmagic6" [pci@0000:1e:00.0]
[   30.995277] blackmagic_driver 0000:1b:00.0: PCI INT A -> GSI 56 (level, low) -> IRQ 56
[   30.995284] blackmagic_driver 0000:1b:00.0: setting latency timer to 64
[   30.995326] blackmagic_driver 0000:1b:00.0: setting latency timer to 64
[   33.118817] blackmagic: Successfully loaded device "blackmagic7" [pci@0000:1b:00.0]

currently if i take out, say, card 3, then i will not have blackmagic0 blackmagic1 blackmagic2 blackmagic4 blackmagic5 blackmagic6 blackmagic7, but rather they be remapped so that i have the 7 remaining devices on blackmagic0-6.

  1. what are these numbers like 0a:00.0 ? Are they related to physical addresses of the PCI slots, i.e. can I reasonably expect those numbers not to change when I muck around with other PCI devices or changing things in the boot process of the OS?

  2. can i control where the cards are mounted, so that /dev/blackmagic3 would correspond to the device located fourth from the back when i'm looking at the machine? and preferably so that when i remove a card the addresses of the other ones will not be remapped to lower numbers? i have heard this might be possible with udev rules.

  3. failing 2, is it possible to reliably and repeatably determine the mapping of the device names to their physical locations, so that i can use symbolic links to reorder them?

i'm using Ubuntu 11.04.

edit: some further information, here are the current contents of the file /etc/udev/rules.d/20-blackmagic.rules

KERNEL=="blackmagic[0-9]*", NAME="blackmagic/card%n", MODE="0666", GROUP="video", RUN+="/usr/lib64/blackmagic/BlackmagicPreferencesStartup %n", OPTIONS="last_rule"
KERNEL=="blackmagic_serial[0-9]*", NAME="blackmagic/serial%n", MODE="0666", GROUP="video", OPTIONS="last_rule"
share|improve this question
    
i was able to create persistent mapping for the devices by matching DEVPATH in the rules file. the correct information to use in DEVPATH i found with e.g. udevadm info -q all -n /dev/blackmagic0 –  wim Jul 28 '11 at 8:25
add comment

1 Answer

up vote 1 down vote accepted

The numbers like "0a:00.0" are the PCI bus addresses associated with the PCI slots. These are a consistent mapping - a card in a given slot will always have the same PCI bus address.

The devices will be enumerated in order they are seen, so if you remove a device it will reshuffle the list as you suggest. You may be able to change this behaviour with udev, but it's probably easier to create symlinks instead.

You can either empirically determine which PCI address maps to which slot (eg, put a card in slot 1, record the bus address, repeat), or if you are very lucky, then the bus address to slot mapping contained in the output of "biosdecode" will actually be useful. It's not useful in most of the motherboards I've seen, in that it has duplicate slot names, or they don't actually correspond to any logical ordering on the back. However, once you have worked out the mapping yourself, it won't change.

At any rate, have a look through the output of biosdecode and perhaps dmidecode -t slot, you may find something there that is useful. Otherwise, make your mapping manually.

(Also, the PCI mapping can change - if you change your BIOS or BIOS options, it may cause devices to be enumerated differently. EG, if an onboard USB controller shows up at 0b:00.00, and you have PCI devices showing up at 0a:00.0 and 0c:00.0, and you disable the USB controller, it may result in the 0c:00.0 device being shifted down to 0b:00.0. Or it may not. Your mileage may vary)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.