PCI: Separate reset and link code to separate files
v2 cover PCI: Separate reset and link code to separate files
pci.c has been catch-all for lots of code which didn't fit elsewhere, making its footprint large.
Move reset and link related code into own files as they seem independent enough from the other code and result in reasonably sized .c files. While some of the code in link.c could have gone into reset.c, reset.c would have become clearly larger and pcie_retrain_link() wouldn't really have fit under reset.c so I thought independent link.c would make sense and keep .c files in more manageable sizes.
The series is based on top of the pci/reset branch. Expected conflicts:
- reset.c patch with:
- PCI: Print the actual delay time in pci_bridge_wait_for_secondary_bus() (in pci/enumeration)
- link.c patch with:
- LBMS reset & update speed changes in the pci/bwctrl branch
There are some conflicts with some pending changes, the most imporant being Mani's slot reset series:
https://lore.kernel.org/r/[email protected]/
After these moves, the .c file sizes are:
5295 pci.c
3332 probe.c
578 link.c
1253 reset.c
I've been sit on top of the reset.c patch since the last Fall as there have been just way too many complex conflicts to handle but currently the conflict level would be relatively low.
In addition to these moves, I'm considering moving D0/D3 related logic that is plenty in pci.c into own .c file (probably power.c but suggestions welcome).
Ilpo Järvinen (2):
PCI: Move reset and restore related code to reset-restore.c
PCI: Move link related code into link.c
drivers/pci/Makefile | 6 +- drivers/pci/link.c | 578 +++++++++++++ drivers/pci/pci.c | 1890 ++++-------------------------------------- drivers/pci/pci.h | 5 +- drivers/pci/probe.c | 194 ----- drivers/pci/reset.c | 1253 ++++++++++++++++++++++++++++ 6 files changed, 1977 insertions(+), 1949 deletions(-) create mode 100644 drivers/pci/link.c create mode 100644 drivers/pci/reset.c
base-commit: f3efb9569b4a21354ef2caf7ab0608a3e14cc6e4
Signature · 1 line
2.39.5
PATCH v2 1/2 PCI: Move reset and restore related code to reset.c
There are quite many reset and restore related functions in pci.c that barely depend on the other functions in pci.c. Create reset.c for reset and restore related logic to keep those 1k lines in one place.
--- drivers/pci/Makefile | 4 +- drivers/pci/pci.c | 1277 +----------------------------------------- drivers/pci/pci.h | 2 + drivers/pci/reset.c | 1253 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 1275 insertions(+), 1261 deletions(-) create mode 100644 drivers/pci/reset.c
drivers/pci/Makefile +2 -2
@@ -3,8 +3,8 @@ # Makefile for the PCI bus specific drivers. obj-$(CONFIG_PCI) += access.o bus.o probe.o host-bridge.o \ - remove.o pci.o pci-driver.o search.o \ - rom.o setup-res.o irq.o vpd.o \ + remove.o reset.o pci.o pci-driver.o \ + search.o rom.o setup-res.o irq.o vpd.o \ setup-bus.o vc.o mmap.o devres.o obj-$(CONFIG_PCI) += msi/
drivers/pci/pci.c +18 -1259
1,331 lines not on this page · raw message
drivers/pci/pci.h +2 -0
@@ -154,6 +154,7 @@ void pci_msi_init(struct pci_dev *dev);void pci_msix_init (struct pci_dev *dev);bool pci_bridge_d3_possible (struct pci_dev *dev);void pci_bridge_d3_update (struct pci_dev *dev); +void pci_dev_d3_sleep (struct pci_dev *dev);int pci_bridge_wait_for_secondary_bus (struct pci_dev *dev,char *reset_type);static inline bool pci_bus_rrs_vendor_id (u32 l)
@@ -789,6 +790,7 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,pci_channel_state_t state, pci_ers_result_t (*reset_subordinates)(struct pci_dev *pdev)); +bool pcie_wait_for_link_delay (struct pci_dev *pdev,bool active,int delay);bool pcie_wait_for_link (struct pci_dev *pdev,bool active);int pcie_retrain_link (struct pci_dev *pdev,bool use_lt);
drivers/pci/reset.c new file +1253 -0
1,253 lines not on this page · raw message
Signature · 1 line
2.39.5
PATCH v2 2/2 PCI: Move link related code into link.c
In reply to Ilpo JärvinenMove PCIe Link (and legacy bus speed) related code into link.c to reduce the number of lines in pci.c and probe.c that are the two largest C files under drivers/pci/.
The moved functions relate to:
- Link Speed and Width (including arrays)
- Link status
- Link Training
- Waiting for the Link to come up
- Legacy AGP & PCI-X Bus speed (including arrays)
--- drivers/pci/Makefile | 2 +- drivers/pci/link.c | 578 +++++++++++++++++++++++++++++++++++++++++++ drivers/pci/pci.c | 369 --------------------------- drivers/pci/pci.h | 3 +- drivers/pci/probe.c | 194 --------------- 5 files changed, 580 insertions(+), 566 deletions(-) create mode 100644 drivers/pci/link.c
drivers/pci/Makefile +1 -1
@@ -2,7 +2,7 @@ # # Makefile for the PCI bus specific drivers. -obj-$(CONFIG_PCI) += access.o bus.o probe.o host-bridge.o \ +obj-$(CONFIG_PCI) += access.o bus.o probe.o host-bridge.o link.o \ remove.o reset.o pci.o pci-driver.o \ search.o rom.o setup-res.o irq.o vpd.o \ setup-bus.o vc.o mmap.o devres.o
drivers/pci/link.c new file +578 -0
578 lines not on this page · raw message
drivers/pci/pci.c +0 -369
381 lines not on this page · raw message
drivers/pci/pci.h +1 -2
@@ -13,7 +13,6 @@ struct pcie_tlp_log;#define PCI_VSEC_ID_INTEL_TBT 0x1234/* Thunderbolt */ -#define PCIE_LINK_RETRAIN_TIMEOUT_MS 1000/* * Power stable to PERST# inactive.
@@ -450,7 +449,6 @@ static inline int pcie_dev_speed_mbps(enum pci_bus_speed speed)u8 pcie_get_supported_speeds (struct pci_dev *dev);const char *pci_speed_string (enum pci_bus_speed speed); -void __pcie_print_link_status (struct pci_dev *dev,bool verbose);void pcie_report_downtraining (struct pci_dev *dev);static inline void __pcie_update_link_speed (struct pci_bus *bus,u16 linksta,u16 linksta2)
@@ -459,6 +457,7 @@ static inline void __pcie_update_link_speed(struct pci_bus *bus, u16 linksta, u1 bus->flit_mode = (linksta2 &PCI_EXP_LNKSTA2_FLIT ) ?1 :0 ; }void pcie_update_link_speed (struct pci_bus *bus); +void pci_set_bus_speed (struct pci_bus *bus);/* Single Root I/O Virtualization */ struct pci_sriov {
drivers/pci/probe.c +0 -194
206 lines not on this page · raw message
Signature · 1 line
2.39.5