PCI: add kernel parameter to override devid<->driver mapping.
Subsystems (2)
PATCH v2 1/1 PCI: add kernel parameter to override devid<->driver mapping.
Scanning a lot of devices during boot requires a lot of time. On other scenarios there is a need to bind a driver to a specific slot.
Binding devices to pci-stub driver does not work, as it will not differentiate between devices of the same type. Using some start scripts is error prone.
The solution leverages driver_override functionality introduced by
commit: 782a985d7af26db39e86070d28f987cad21313c0 Author: Alex Williamson <[email protected]> Date: Tue May 20 08:53:21 2014 -0600 PCI: Introduce new device binding path using pci_dev.driver_override
In order to bind PCI slots to specific drivers use:
pci=driver[xxxx:xx:xx.x]=foo,driver[xxxx:xx:xx.x]=bar,...
---
v1 -> v2:
- Addressed Michael S. Tsirkin comments
- Removed 32 slots limitation
- Better handling of memory allocation failures (preferred BUG_ON over error messages)
- Addressed Alex Williamson's comments:
- Modified commit message to show parameter usage more clear.
- I preferred to re-use parse_args instead of manually using strstr in order to better comply with command line parsing rules.
- I didn't use any locking when parsing the command line args (see parse_done usage) assuming that first call will be early in system boot and no race can occur. Please correct me if I am wrong.
Notes:
- I have further ideas on top of this patch based on your reviews. I thought of:
- Use wildcards to specify entire buses/devices, something like:
driver[0001:02:*.*]=pci-stub
- Use comma to separate several devices:
driver[0001:02:03.4,0001:02:04.0,...]=pci-stub - Make domain optional:
driver[00:03.0]=pci-stub
Comments will be appreciated,
Thanks,
Marcel
Documentation/kernel-parameters.txt | 4 ++ drivers/pci/bus.c | 86 +++++++++++++++++++++++++++++++++++++ drivers/pci/pci.c | 2 + 3 files changed, 92 insertions(+)
Documentation/kernel-parameters.txt +4 -0
@@ -2631,6 +2631,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted. pcie_scan_all Scan all possible PCIe devices. Otherwise we only look for one device below a PCIe downstream port. + driver Provide an override to the devid<->driver mapping + for a specific slot. + Bind PCI slot 0001:02:03.4 to pci-stub by: + driver[0001:02:03.4]=pci-stub pcie_aspm= [PCIE] Forcibly enable or disable PCIe Active State Power Management.
drivers/pci/bus.c +86 -0
98 lines not on this page · raw message
drivers/pci/pci.c +2 -0
@@ -4468,6 +4468,8 @@ static int __init pci_setup(char *str) pcie_bus_config =PCIE_BUS_PEER2PEER ; }else if (!strncmp (str,"pcie_scan_all" ,13 )) {pci_add_flags (PCI_SCAN_ALL_PCIE_DEVS ); + }else if (!strncmp (str,"driver" ,6 )) { +/* lazy evaluation by the pci subsystem */ }else {printk (KERN_ERR "PCI: Unknown option `%s'\n" , str);
Signature · 1 line
1.8.3.1