PCI: limit pci bridge and subsystem speed to 2.5GT/s
Subsystems (2)
PATCH 1/1 PCI: limit pci bridge and subsystem speed to 2.5GT/s
From: weiyufeng <[email protected]>
Add a kernel command-line option 'speed2_5g' to limit pci bridge and subsystem devices speed to 2.5GT/s. As a debug method, this provide for developer to temporarily slow down PCIe devices for verification.
Signed-off-by weiyufeng <[email protected]>
--- .../admin-guide/kernel-parameters.txt | 8 ++++ drivers/pci/pci.c | 6 ++- drivers/pci/pci.h | 1 + drivers/pci/probe.c | 41 +++++++++++++++++++ include/linux/pci.h | 3 ++ 5 files changed, 58 insertions(+), 1 deletion(-)
Documentation/admin-guide/kernel-parameters.txt +8 -0
@@ -4632,6 +4632,14 @@ nomio [S390] Do not use MIO instructions. norid [S390] ignore the RID field and force use of one PCI domain per PCI function + speed2_5g= + Format: + [<domain>:]<bus>:<dev>.<func>[/<dev>.<func>]* + pci:<vendor>:<device>[:<subvendor>:<subdevice>] + Specify one or more PCI bridge devices (in the + format specified above) separated by semicolons. + Each bridge device specified will limit the bridge + and subsystem devices speed to 2.5GT/s. pcie_aspm= [PCIE] Forcibly enable or ignore PCIe Active State Power Management.
drivers/pci/pci.c +5 -1
@@ -159,6 +159,7 @@ static bool pcie_ats_disabled;/* If set, the PCI config space of each device is printed during boot. */ bool pci_early_dump; +const char *pci_speed_2_5g;bool pci_ats_disabled (void ) {
@@ -374,7 +375,7 @@ static int pci_dev_str_match_path(struct pci_dev *dev, const char *path,* Returns 1 if the string matches the device, 0 if it does not and * a negative error code if the string cannot be parsed. */ -static int pci_dev_str_match (struct pci_dev *dev,const char *p, +int pci_dev_str_match (struct pci_dev *dev,const char *p,const char **endptr) {int ret;
@@ -423,6 +424,7 @@ static int pci_dev_str_match(struct pci_dev *dev, const char *p, *endptr = p;return 1 ; } +EXPORT_SYMBOL_GPL (pci_dev_str_match);static u8 __pci_find_next_cap_ttl (struct pci_bus *bus,unsigned int devfn,u8 pos,int cap,int *ttl)
@@ -6905,6 +6907,8 @@ static int __init pci_setup(char *str) disable_acs_redir_param = str +18 ; }else if (!strncmp (str,"config_acs=" ,11 )) { config_acs_param = str +11 ; + }else if (!strncmp (str,"speed2_5g=" ,10 )) { + pci_speed_2_5g = str +10 ; }else {pr_err ("PCI: Unknown option `%s'\n" , str); }
drivers/pci/pci.h +1 -0
@@ -67,6 +67,7 @@extern const unsigned char pcie_link_speed[];extern bool pci_early_dump; +extern const char *pci_speed_2_5g;bool pcie_cap_has_lnkctl (const struct pci_dev *dev);bool pcie_cap_has_lnkctl2 (const struct pci_dev *dev);
drivers/pci/probe.c +41 -0
53 lines not on this page · raw message
include/linux/pci.h +3 -0
@@ -1184,6 +1184,7 @@ void pci_sort_breadthfirst(void);u8 pci_bus_find_capability (struct pci_bus *bus,unsigned int devfn,int cap);u8 pci_find_capability (struct pci_dev *dev,int cap); +int pci_dev_str_match (struct pci_dev *dev,const char *p,const char **endptr);u8 pci_find_next_capability (struct pci_dev *dev,u8 pos,int cap);u8 pci_find_ht_capability (struct pci_dev *dev,int ht_cap);u8 pci_find_next_ht_capability (struct pci_dev *dev,u8 pos,int ht_cap);
@@ -1984,6 +1985,8 @@ static inline int pci_register_driver(struct pci_driver *drv)static inline void pci_unregister_driver (struct pci_driver *drv) { }static inline u8 pci_find_capability (struct pci_dev *dev,int cap) {return 0 ; } +static inline int pci_dev_str_match (struct pci_dev *dev,const char *p,const char **endptr) +{return 0 ; }static inline u8 pci_find_next_capability (struct pci_dev *dev,u8 post,int cap) {return 0 ; }static inline u16 pci_find_ext_capability (struct pci_dev *dev,int cap)
Signature · 1 line
2.25.1
Quoted 6 lines · On Mon, Aug 05, 2024 at 05:20:10PM +0800, [email protected] wrote:
From: weiyufeng <[email protected]>
Add a kernel command-line option '
speed2_5g' to limit pci bridge and subsystem devices speed to 2.5GT/s. As a debug method, this provide for developer to temporarily slow down PCIe devices for verification.
I am opposed to this patch benig merged. There's no harm to keep it for your own testing.