1

I've got a PCIe board with a FPGA and my own kernel device driver.

After the FPGA has been loaded, I need to rescan the PCIe tree. I used the regular /sys/bus/pci/devices/xxx/remove + /sys/bus/pci/rescan to do that.

The access to these files must be done with root privileges and it could be a pain.

Is it possible to do the rescan from my kernel device driver ?

I tried to call pci_remove_bus () + pci_rescan_bus () in the open call but I've got a kernel panic.

Where can I find an example of pci_remove_bus () + pci_rescan_bus () use ?

Thanks,

Fred

Fred
  • 39
  • 4
  • You have to hold a bus lock. Otherwise it works like you described. – 0andriy Aug 04 '17 at 17:41
  • Check `bus_rescan_store()` implementation. – 0andriy Aug 04 '17 at 17:56
  • Thanks a lot, it works fine. I just added `pci_stop_and_remove_bus_device()` before this sequence. – Fred Aug 07 '17 at 11:34
  • Btw, consider to use / implement PCI switch from FPGA side so you can leverage PCI hotplug mechanism and you don't need to take care of this manually. – 0andriy Aug 07 '17 at 13:36
  • I don't know this mechanism, how can it be done ? – Fred Aug 10 '17 at 07:22
  • @Fred - I have a similar requirement but having an issue with `pci_rescan_bus()` https://stackoverflow.com/questions/64549023/pci-rescan-bus-doesnt-rescan-pci-bus-in-linux – Raxesh Oriya Oct 27 '20 at 08:47

0 Answers0