Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to ask the Linux Kernel to re-run its PCI initialization code?

I'm looking for either a kernel mode call that I can make from a driver, a userland utility, or a system call that will ask the Kernel to look at the PCI bus and either completely re-run its initialization, or initialize a specific device. Specifically, I need the Kernel to recognize a device that was added to the bus after boot and then configure its address space, interrupt, and other configuration parameters, and finally enable the device so that I can load the driver for it (unless this all happens as part of the driver load).

I'm stuck on the 2.4.x series Kernel for this, and am currently working with 2.4.20, but will be moving to 2.4.37 if it matters. The distro is a stripped down Red Hat 7.3 running in a ram disk, but I can add in whatever tools are needed to get this working (as long as they play nice with 2.4 series).

If some background would help clarify what I'm trying to do: From a cold boot, once in Linux I use GPIO to program an FPGA. Part of the FPGA, once programmed, implements a simple PCI device. Currently, after programming the FPGA, I reboot the system and Linux recognizes the device after coming up and loads the driver for it.

Instead of needing that reboot, I'd like to simply ask the Kernel to do whatever it does during boot up to find PCI devices (I have the Kernel configured to find PCI devices on its own, instead of asking the BIOS for that information, so the BIOS won't need to know about this device (I hope)).

I believe that Linux is capable of seeing the device after it is programmed but before a reboot, because scanpci will show the device after I program it, as will lspci -H 1. I just need a way to get it into /proc/pci, configured and enabled.

like image 391
mlustig Avatar asked Dec 01 '09 17:12

mlustig


People also ask

How do I rescan PCI on Linux?

The steps: echo 1 >/sys/bus/pci/<pci-id-of-device>/remove . We can find its PCI ID with an lspci command. echo 1 >/sys/bus/pci/rescan.

What is PCI in kernel?

Peripheral Component Interconnect (PCI), as its name implies is a standard that describes how to connect the peripheral components of a system together in a structured and controlled way. The standard describes the way that the system components are electrically connected and the way that they should behave.

What is Pci_dev?

Every PCI device in a system, including PCI-PCI and PCI-ISA bridge devices, is represented by a pci_dev structure. The struct device dev member of pci_dev represents the generic interface for a device. A PCI bus layer can access the members of this structure.

What is PCI buses in Linux?

Peripheral Component Interconnect (PCI) is a local computer bus for attaching hardware devices in a computer and is part of the PCI Local Bus standard. The PCI bus supports the functions found on a processor bus but in a standardized format that is independent of any given processor's native bus.


2 Answers

This below command will help the user to rescan it complete root hub.

echo "1" > /sys/class/pci_bus/0000\:00/rescan
like image 140
Arulpandiyan Vadivel Avatar answered Oct 25 '22 03:10

Arulpandiyan Vadivel


You could speed up the reboot with kexec, if you don't figure out how to get the PCI scan redone. You could ask this on the LKML, if you haven't already.

unloading/reloading the module doesn't help, does it?

like image 27
Peter Cordes Avatar answered Oct 25 '22 01:10

Peter Cordes