According to this answer, PCI/PCIe devices (such as GPUs) in the system need to go through an initialization process before being used:
- The OS kernel obtains the values in PCI configuration registers.
- The OS passes the obtained value to the corresponding device driver through
struct pci_dev. - The device driver registers PCI/PCIe devices according to its own logic.
Which piece of kernel code performs the second step?
Is there any software method to modify the PCI/PCIe device information field passed to device driver by the OS in the first or second step?
Assuming you're on Linux, You can change some registers read values with the setpci command, but the absolute recommendation is to use it only for debug, learning needs etc.
The initialization process (a.k.a Enumeration) is pretty complex and has lots of internal dependencies.