mbox series

[0/3] PCI: Introduce new PCI_CONF1_ADDRESS() and PCI_CONF1_EXT_ADDRESS() macros

Message ID 20220924092404.31776-1-pali@kernel.org (mailing list archive)
Headers show
Series PCI: Introduce new PCI_CONF1_ADDRESS() and PCI_CONF1_EXT_ADDRESS() macros | expand

Message

Pali Rohár Sept. 24, 2022, 9:24 a.m. UTC
PCI controllers and lot of non-ECAM compliant PCIe controllers still use
Intel PCI Configuration Mechanism #1 for accessing PCI config space.

Native PCIe controller drivers invents its own macros which implements
config space address calculation and in lof of cases it is just
duplication of the same code.

PCIe ECAM address macro PCIE_ECAM_OFFSET() is already in include header
file linux/pci-ecam.h and ECAM compliant drivers were already converted
to use it.

Do similar thing also for Intel PCI Configuration Mechanism #1.
Introduce into file drivers/pci/pci.h new PCI_CONF1_ADDRESS() and
PCI_CONF1_EXT_ADDRESS() macros and convert two drivers pci-ftpci100.c
and pcie-mt7621.c to use it.

There are many more drivers which could be converted to this common
macros. This can be done later.

Note that similar cleanup was applied for U-Boot PCI controller drivers:
https://lore.kernel.org/u-boot/20211126104252.5443-1-pali@kernel.org/

Changes since RFC:
* Move macros to file drivers/pci/pci.h

Pali Rohár (3):
  PCI: Add standard PCI Config Address macros
  PCI: ftpci100: Use PCI_CONF1_ADDRESS() macro
  PCI: mt7621: Use PCI_CONF1_EXT_ADDRESS() macro

 drivers/pci/controller/pci-ftpci100.c | 21 +++----------
 drivers/pci/controller/pcie-mt7621.c  | 17 ++++------
 drivers/pci/pci.h                     | 45 +++++++++++++++++++++++++++
 3 files changed, 55 insertions(+), 28 deletions(-)

Comments

Lorenzo Pieralisi Sept. 27, 2022, 9:09 a.m. UTC | #1
On Sat, 24 Sep 2022 11:24:01 +0200, Pali Rohár wrote:
> PCI controllers and lot of non-ECAM compliant PCIe controllers still use
> Intel PCI Configuration Mechanism #1 for accessing PCI config space.
> 
> Native PCIe controller drivers invents its own macros which implements
> config space address calculation and in lof of cases it is just
> duplication of the same code.
> 
> [...]

Applied to pci/misc, thanks!

[1/3] PCI: Add standard PCI Config Address macros
      https://git.kernel.org/lpieralisi/pci/c/8a9b7ef74369
[2/3] PCI: ftpci100: Use PCI_CONF1_ADDRESS() macro
      https://git.kernel.org/lpieralisi/pci/c/f75a27dc6c07
[3/3] PCI: mt7621: Use PCI_CONF1_EXT_ADDRESS() macro
      https://git.kernel.org/lpieralisi/pci/c/2301a3e1a566

Thanks,
Lorenzo