How does the "/sys/bus/pci/drivers/*/*" interface work?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,
I hope this is the correct mailing list to ask my question.

Looking at "/sys/bus/pci/drivers/xxxxx/" I see a bunch of files, which (for a lack of better term) I will call "interfaces" and they can be used to associate a device with a driver. E.g.:

```
$ ls /sys/bus/pci/drivers/vfio-pci/
bind  module  new_id  remove_id  uevent  unbind
```

For example I can use `bind` or `new_id` to bind a driver to a device:

```
sudo bash -c "echo '0000:${PCI_ADDRESS}' > '/sys/bus/pci/drivers/vfio-pci/bind'"

sudo bash -c "echo '${VENDOR_ID} ${DEVICE_ID}' > '/sys/bus/pci/drivers/vfio-pci/new_id'"
```

and I can use `unbind` to unbind the currently used driver from a device:

```
sudo bash -c "echo '0000:${PCI_ADDRESS}' > '/sys/bus/pci/drivers/${DRIVER}/unbind'"
```

My problem is that I can find no official documentation on these "interfaces" (`bind`, `unbind`, `new_id`, `remove_id`,`uevent`).


It seems to me that I have to use `new_id` to bind the driver for the first time after a reboot and if I then unbind it again, I have to use `bind` instead of `new_id` until I reboot again.

If I use `remove_id` after using `new_id`, I have to use `new_id` again the next time.
But if I use `remove_id` before using `new_id`, I get an error (`echo: write error: No such device`). Same for using `bind` before using `new_id` first.

I have 3 questions now:
1. Are my assumptions correct?
2. If so, how can I check which of these "interfaces" I need (`new_id` vs `bind`) without blindly executing them an then checking if it failed?
3. What are each of these "interfaces" actually doing and how do you use them correctly?

Thanks in advance. I hope I'm doing this correctly, this is my first time on a mailing list.

Best regards
linux.enthusiast





[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux