platform/kernel/linux-starfive.git
2 years agoMerge branch 'remotes/lorenzo/pci/rcar'
Bjorn Helgaas [Thu, 13 Jan 2022 15:57:50 +0000 (09:57 -0600)]
Merge branch 'remotes/lorenzo/pci/rcar'

- Fix aarch32 abort handler so it doesn't check the wrong bus clock before
  accessing the host controller (Marek Vasut)

* remotes/lorenzo/pci/rcar:
  PCI: rcar: Check if device is runtime suspended instead of __clk_is_enabled()

2 years agoMerge branch 'remotes/lorenzo/pci/qcom'
Bjorn Helgaas [Thu, 13 Jan 2022 15:57:50 +0000 (09:57 -0600)]
Merge branch 'remotes/lorenzo/pci/qcom'

- Undo PM setup in qcom_pcie_probe() error handling path (Christophe
  JAILLET)

- Use __be16 type to store return value from cpu_to_be16() (Manivannan
  Sadhasivam)

- Constify static dw_pcie_ep_ops (Rikard Falkeborn)

* remotes/lorenzo/pci/qcom:
  PCI: qcom-ep: Constify static dw_pcie_ep_ops
  PCI: qcom: Use __be16 type to store return value from cpu_to_be16()
  PCI: qcom: Fix an error handling path in 'qcom_pcie_probe()'

2 years agoMerge branch 'remotes/lorenzo/pci/mvebu'
Bjorn Helgaas [Thu, 13 Jan 2022 15:57:49 +0000 (09:57 -0600)]
Merge branch 'remotes/lorenzo/pci/mvebu'

- Implement pci_remap_iospace() for ARM so mvebu can use
  devm_pci_remap_iospace() instead of the previous ARM-specific
  pci_ioremap_io() interface (Pali Rohár)

- Use the standard pci_host_probe() instead of the device-specific
  mvebu_pci_host_probe() (Pali Rohár)

- Replace all uses of ARM-specific pci_ioremap_io() with the
  ARM implementation of the standard pci_remap_iospace() interface and
  remove pci_ioremap_io() (Pali Rohár)

- Skip initializing invalid Root Ports (Pali Rohár)

- Check for errors from pci_bridge_emul_init() (Pali Rohár)

- Ignore any bridges at non-zero function numbers (Pali Rohár)

- Return ~0 data for invalid config read size (Pali Rohár)

- Disallow mapping interrupts on emulated bridges (Pali Rohár)

- Clear Root Port Memory & I/O Space Enable and Bus Master Enable at
  initialization (Pali Rohár)

- Make type bits in Root Port I/O Base register read-only (Pali Rohár)

- Disable Root Port windows when base/limit set to invalid values (Pali
  Rohár)

- Set controller to Root Complex mode (Pali Rohár)

- Set Root Port Class Code to PCI Bridge (Pali Rohár)

- Update emulated Root Port secondary bus numbers to better reflect the
  actual topology (Pali Rohár)

- Add PCI_BRIDGE_CTL_BUS_RESET support to emulated Root Ports so
  pci_reset_secondary_bus() can reset connected devices (Pali Rohár)

- Add PCI_EXP_DEVCTL Error Reporting Enable support to emulated Root Ports
  (Pali Rohár)

- Add PCI_EXP_RTSTA PME Status bit support to emulated Root Ports (Pali
  Rohár)

- Add DEVCAP2, DEVCTL2 and LNKCTL2 support to emulated Root Ports on Armada
  XP and newer devices (Pali Rohár)

- Export mvebu-mbus.c symbols to allow pci-mvebu.c to be a module (Pali
  Rohár)

- Add support for compiling as a module (Pali Rohár)

* remotes/lorenzo/pci/mvebu:
  PCI: mvebu: Add support for compiling driver as module
  bus: mvebu-mbus: Export symbols for public API window functions
  PCI: mvebu: Fix support for DEVCAP2, DEVCTL2 and LNKCTL2 registers on emulated bridge
  PCI: mvebu: Fix support for PCI_EXP_RTSTA on emulated bridge
  PCI: mvebu: Fix support for PCI_EXP_DEVCTL on emulated bridge
  PCI: mvebu: Fix support for PCI_BRIDGE_CTL_BUS_RESET on emulated bridge
  PCI: mvebu: Fix configuring secondary bus of PCIe Root Port via emulated bridge
  PCI: mvebu: Set PCI Bridge Class Code to PCI Bridge
  PCI: mvebu: Setup PCIe controller to Root Complex mode
  PCI: mvebu: Propagate errors when updating PCI_IO_BASE and PCI_MEM_BASE registers
  PCI: mvebu: Do not modify PCI IO type bits in conf_write
  PCI: mvebu: Fix support for bus mastering and PCI_COMMAND on emulated bridge
  PCI: mvebu: Disallow mapping interrupts on emulated bridges
  PCI: mvebu: Handle invalid size of read config request
  PCI: mvebu: Check that PCI bridge specified in DT has function number zero
  PCI: mvebu: Check for errors from pci_bridge_emul_init() call
  PCI: mvebu: Check for valid ports
  arm: ioremap: Remove unused ARM-specific function pci_ioremap_io()
  arm: ioremap: Replace pci_ioremap_io() usage by pci_remap_iospace()
  PCI: mvebu: Remove custom mvebu_pci_host_probe() function
  PCI: mvebu: Replace pci_ioremap_io() usage by devm_pci_remap_iospace()
  arm: ioremap: Implement standard PCI function pci_remap_iospace()

2 years agoMerge branch 'pci/host/mt7621'
Bjorn Helgaas [Thu, 13 Jan 2022 15:57:49 +0000 (09:57 -0600)]
Merge branch 'pci/host/mt7621'

- Declare mt7621_pci_ops static (Sergio Paracuellos)

- Give pcibios_root_bridge_prepare() access to host bridge windows (Sergio
  Paracuellos)

- Move MIPS I/O coherency unit setup from driver to
  pcibios_root_bridge_prepare() (Sergio Paracuellos)

- Add missing MODULE_LICENSE() (Sergio Paracuellos)

- Allow COMPILE_TEST for all arches (Sergio Paracuellos)

* pci/host/mt7621:
  PCI: mt7621: Allow COMPILE_TEST for all arches
  PCI: mt7621: Add missing MODULE_LICENSE()
  PCI: mt7621: Move MIPS setup to pcibios_root_bridge_prepare()
  PCI: Let pcibios_root_bridge_prepare() access bridge->windows
  PCI: mt7621: Declare mt7621_pci_ops static

2 years agoMerge branch 'remotes/lorenzo/pci/mediatek-gen3'
Bjorn Helgaas [Thu, 13 Jan 2022 15:57:48 +0000 (09:57 -0600)]
Merge branch 'remotes/lorenzo/pci/mediatek-gen3'

- Disable Mediatek DVFSRC voltage request since lack of DVFSRC to respond
  to the request causes failure to exit L1 PM Substate (Jianjun Wang)

* remotes/lorenzo/pci/mediatek-gen3:
  PCI: mediatek-gen3: Disable DVFSRC voltage request

2 years agoMerge branch 'remotes/lorenzo/pci/mediatek'
Bjorn Helgaas [Thu, 13 Jan 2022 15:57:48 +0000 (09:57 -0600)]
Merge branch 'remotes/lorenzo/pci/mediatek'

- Assert PERST# for 100ms to allow power and clock to stabilize (qizhong
  cheng)

* remotes/lorenzo/pci/mediatek:
  PCI: mediatek: Assert PERST# for 100ms for power and clock to stabilize

2 years agoMerge branch 'remotes/lorenzo/pci/keystone'
Bjorn Helgaas [Thu, 13 Jan 2022 15:57:48 +0000 (09:57 -0600)]
Merge branch 'remotes/lorenzo/pci/keystone'

- Add register offset for ti,syscon-pcie-id and ti,syscon-pcie-mode DT
  properties (Kishon Vijay Abraham I)

* remotes/lorenzo/pci/keystone:
  PCI: keystone: Use phandle argument from "ti,syscon-pcie-id"/"ti,syscon-pcie-mode"
  dt-bindings: PCI: ti,am65: Fix "ti,syscon-pcie-id"/"ti,syscon-pcie-mode" to take argument

2 years agoMerge branch 'pci/host/hv'
Bjorn Helgaas [Thu, 13 Jan 2022 15:57:47 +0000 (09:57 -0600)]
Merge branch 'pci/host/hv'

- Add hv-internal interfaces to encapsulate arch IRQ dependencies (Sunil
  Muthuswamy)

- Add arm64 Hyper-V vPCI support (Sunil Muthuswamy)

* pci/host/hv:
  PCI: hv: Add arm64 Hyper-V vPCI support
  PCI: hv: Make the code arch neutral by adding arch specific interfaces

2 years agoMerge branch 'remotes/lorenzo/pci/endpoint'
Bjorn Helgaas [Thu, 13 Jan 2022 15:57:47 +0000 (09:57 -0600)]
Merge branch 'remotes/lorenzo/pci/endpoint'

- Return failure from pci_epc_set_msi() if no interrupts are available (Li
  Chen)

* remotes/lorenzo/pci/endpoint:
  PCI: endpoint: Return -EINVAL when interrupts num is smaller than 1

2 years agoMerge branch 'remotes/lorenzo/pci/dwc'
Bjorn Helgaas [Thu, 13 Jan 2022 15:57:47 +0000 (09:57 -0600)]
Merge branch 'remotes/lorenzo/pci/dwc'

- Don't ioremap NULL when DT lacks ATU resource (Tim Harvey)

- Drop redundant qcom-ep error message for platform_get_irq_byname()
  failure (Krzysztof Wilczyński)

- Add i.MX8MM support (Richard Zhu)

- Use DWC common ops instead of layerscape-specific link-up functions (Hou
  Zhiqiang)

* remotes/lorenzo/pci/dwc:
  PCI: layerscape: Change to use the DWC common link-up check function
  PCI: imx: Add the imx8mm pcie support
  dt-bindings: imx6q-pcie: Add PHY phandles and name properties
  PCI: qcom-ep: Remove surplus dev_err() when using platform_get_irq_byname()
  PCI: dwc: Do not remap invalid res

2 years agoMerge branch 'pci/host/brcmstb'
Bjorn Helgaas [Thu, 13 Jan 2022 15:57:46 +0000 (09:57 -0600)]
Merge branch 'pci/host/brcmstb'

- Declare bitmap correctly for use by bitmap interfaces (Christophe
  JAILLET)

- Clean up computation of legacy and non-legacy MSI bitmasks (Florian
  Fainelli)

- Update suspend/resume/remove error handling to warn about errors and not
  fail the operation (Jim Quinlan)

- Correct the "pcie" and "msi" interrupt descriptions in DT binding (Jim
  Quinlan)

- Add DT bindings for endpoint voltage regulators (Jim Quinlan)

- Split brcm_pcie_setup() into two functions (Jim Quinlan)

- Add mechanism for turning on voltage regulators for connected devices
  (Jim Quinlan)

- Turn voltage regulators for connected devices on/off when bus is added or
  removed (Jim Quinlan)

- When suspending, don't turn off voltage regulators for wakeup devices
  (Jim Quinlan)

* pci/host/brcmstb:
  PCI: brcmstb: Do not turn off WOL regulators on suspend
  PCI: brcmstb: Add control of subdevice voltage regulators
  PCI: brcmstb: Add mechanism to turn on subdev regulators
  PCI: brcmstb: Split brcm_pcie_setup() into two funcs
  dt-bindings: PCI: Add bindings for Brcmstb EP voltage regulators
  dt-bindings: PCI: Correct brcmstb interrupts, interrupt-map.
  PCI: brcmstb: Fix function return value handling
  PCI: brcmstb: Do not use __GENMASK
  PCI: brcmstb: Declare 'used' as bitmap, not unsigned long

2 years agoMerge branch 'remotes/lorenzo/pci/apple'
Bjorn Helgaas [Thu, 13 Jan 2022 15:57:46 +0000 (09:57 -0600)]
Merge branch 'remotes/lorenzo/pci/apple'

- Enable clock gating to save power (Hector Martin)

- Fix REFCLK1 enable/poll logic (Hector Martin)

* remotes/lorenzo/pci/apple:
  PCI: apple: Fix REFCLK1 enable/poll logic
  PCI: apple: Enable clock gating

2 years agoMerge branch 'remotes/lorenzo/pci/aardvark'
Bjorn Helgaas [Thu, 13 Jan 2022 15:57:46 +0000 (09:57 -0600)]
Merge branch 'remotes/lorenzo/pci/aardvark'

- Add bridge emulation definitions for PCIe DEVCAP2, DEVCTL2, DEVSTA2,
  LNKCAP2, LNKCTL2, LNKSTA2, SLTCAP2, SLTCTL2, SLTSTA2 (Pali Rohár)

- Add aardvark support for DEVCAP2, DEVCTL2, LNKCAP2 and LNKCTL2 registers
  (Pali Rohár)

- Clear all MSIs at setup to avoid spurious interrupts (Pali Rohár)

- Disable bus mastering when unbinding host controller driver (Pali Rohár)

- Mask all interrupts when unbinding host controller driver (Pali Rohár)

- Fix memory leak in host controller unbind (Pali Rohár)

- Assert PERST# when unbinding host controller driver (Pali Rohár)

- Disable link training when unbinding host controller driver (Pali Rohár)

- Disable common PHY when unbinding host controller driver (Pali Rohár)

- Fix resource type checking to check only IORESOURCE_MEM, not
  IORESOURCE_MEM_64, which is a flavor of IORESOURCE_MEM (Pali Rohár)

* remotes/lorenzo/pci/aardvark:
  PCI: aardvark: Fix checking for MEM resource type
  PCI: aardvark: Disable common PHY when unbinding driver
  PCI: aardvark: Disable link training when unbinding driver
  PCI: aardvark: Assert PERST# when unbinding driver
  PCI: aardvark: Fix memory leak in driver unbind
  PCI: aardvark: Mask all interrupts when unbinding driver
  PCI: aardvark: Disable bus mastering when unbinding driver
  PCI: aardvark: Comment actions in driver remove method
  PCI: aardvark: Clear all MSIs at setup
  PCI: aardvark: Add support for DEVCAP2, DEVCTL2, LNKCAP2 and LNKCTL2 registers on emulated bridge
  PCI: pci-bridge-emul: Add definitions for missing capabilities registers
  PCI: pci-bridge-emul: Add description for class_revision field

2 years agoMerge branch 'pci/virtualization'
Bjorn Helgaas [Thu, 13 Jan 2022 15:57:45 +0000 (09:57 -0600)]
Merge branch 'pci/virtualization'

- Add function 1 DMA alias quirk for Marvell 88SE9125 SATA controller so it
  can work with an IOMMU (Yifeng Li)

* pci/virtualization:
  PCI: Add function 1 DMA alias quirk for Marvell 88SE9125 SATA controller

2 years agoMerge branch 'pci/switchtec'
Bjorn Helgaas [Thu, 13 Jan 2022 15:57:45 +0000 (09:57 -0600)]
Merge branch 'pci/switchtec'

- Add Gen4 automotive device IDs (Kelvin Cao)

- Declare state_names[] as static so it's not allocated and initialized for
  every call (Kelvin Cao)

* pci/switchtec:
  PCI/switchtec: Declare local state_names[] as static
  PCI/switchtec: Add Gen4 automotive device IDs

2 years agoMerge branch 'pci/resource'
Bjorn Helgaas [Thu, 13 Jan 2022 15:57:45 +0000 (09:57 -0600)]
Merge branch 'pci/resource'

- Always write Intel I210 ROM BAR on update to work around device defect
  (Bjorn Helgaas)

* pci/resource:
  PCI: Work around Intel I210 ROM BAR overlap defect

2 years agoMerge branch 'pci/p2pdma'
Bjorn Helgaas [Thu, 13 Jan 2022 15:57:44 +0000 (09:57 -0600)]
Merge branch 'pci/p2pdma'

- Add Logan Gunthorpe as P2PDMA maintainer (Bjorn Helgaas)

- Optimize by using percpu_ref_tryget_live_rcu() inside RCU critical
  section (Christophe JAILLET)

* pci/p2pdma:
  PCI/P2PDMA: Use percpu_ref_tryget_live_rcu() inside RCU critical section
  MAINTAINERS: Add Logan Gunthorpe as P2PDMA maintainer

2 years agoMerge branch 'pci/legacy-pm-removal'
Bjorn Helgaas [Thu, 13 Jan 2022 15:57:44 +0000 (09:57 -0600)]
Merge branch 'pci/legacy-pm-removal'

- Convert amd64-agp, sis-agp, via-agp from legacy PCI power management to
  generic power management (Vaibhav Gupta)

* pci/legacy-pm-removal:
  via-agp: convert to generic power management
  sis-agp: convert to generic power management
  amd64-agp: convert to generic power management

2 years agoMerge branch 'pci/hotplug'
Bjorn Helgaas [Thu, 13 Jan 2022 15:57:43 +0000 (09:57 -0600)]
Merge branch 'pci/hotplug'

- Fix infinite loop in pciehp IRQ handler on power fault (Lukas Wunner)

- Removed commented-out ibmphp functions (Vihas Mak)

- Fix pciehp lockdep errors on Thunderbolt undock (Hans de Goede)

* pci/hotplug:
  PCI: pciehp: Use down_read/write_nested(reset_lock) to fix lockdep errors
  PCI: ibmphp: Remove commented-out functions
  PCI: pciehp: Fix infinite loop in IRQ handler upon power fault

2 years agoMerge branch 'pci/enumeration'
Bjorn Helgaas [Thu, 13 Jan 2022 15:57:43 +0000 (09:57 -0600)]
Merge branch 'pci/enumeration'

- Use pci_find_vsec_capability() instead of open-coding it (Andy
  Shevchenko)

- Convert pci_dev_present() stub from macro to static inline to avoid
  'unused variable' errors (Hans de Goede)

- Convert sysfs slot attributes from default_attrs to default_groups (Greg
  Kroah-Hartman)

- Use DWORD accesses for LTR, L1 SS to avoid BayHub OZ711LV2 erratum (Rajat
  Jain)

- Remove unnecessary initialization of static variables (Longji Guo)

* pci/enumeration:
  x86/PCI: Remove initialization of static variables to false
  PCI: Use DWORD accesses for LTR, L1 SS to avoid erratum
  PCI/sysfs: Use default_groups in kobj_type for slot attrs
  PCI: Convert pci_dev_present() stub to static inline
  PCI: Use pci_find_vsec_capability() when looking for TBT devices

2 years agoMerge branch 'pci/aspm'
Bjorn Helgaas [Thu, 13 Jan 2022 15:57:43 +0000 (09:57 -0600)]
Merge branch 'pci/aspm'

- Calculate link L0s and L1 exit latencies when needed instead of caching
  them (Saheed O. Bolarinwa)

- Calculate device L0s and L1 acceptable exit latencies when needed instead
  of caching them (Saheed O. Bolarinwa)

- Remove struct aspm_latency since it's no longer needed (Saheed O.
  Bolarinwa)

* pci/aspm:
  PCI/ASPM: Remove struct aspm_latency
  PCI/ASPM: Stop caching device L0s, L1 acceptable exit latencies
  PCI/ASPM: Stop caching link L0s, L1 exit latencies
  PCI/ASPM: Move pci_function_0() upward

2 years agoPCI: mt7621: Allow COMPILE_TEST for all arches
Sergio Paracuellos [Wed, 12 Jan 2022 21:28:10 +0000 (15:28 -0600)]
PCI: mt7621: Allow COMPILE_TEST for all arches

Since all MIPS-specific code has been removed from driver, allow it to be
enabled for COMPILE_TEST on all architectures.

Mark it as tristate and remove MIPS the MIPS dependency.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
2 years agoPCI: mt7621: Add missing MODULE_LICENSE()
Sergio Paracuellos [Tue, 7 Dec 2021 10:49:23 +0000 (11:49 +0100)]
PCI: mt7621: Add missing MODULE_LICENSE()

The MT7621 PCIe host controller driver can be built as a module, but it
lacks a MODULE_LICENSE(), which causes a build error:

  ERROR: modpost: missing MODULE_LICENSE() in drivers/pci/controller/pcie-mt7621.o

Add MODULE_LICENSE() to the driver.

Fixes: 2bdd5238e756 ("PCI: mt7621: Add MediaTek MT7621 PCIe host controller driver")
Link: https://lore.kernel.org/r/20211207104924.21327-5-sergio.paracuellos@gmail.com
Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Krzysztof Wilczyński <kw@linux.com>
2 years agoPCI: mt7621: Move MIPS setup to pcibios_root_bridge_prepare()
Sergio Paracuellos [Tue, 7 Dec 2021 10:49:21 +0000 (11:49 +0100)]
PCI: mt7621: Move MIPS setup to pcibios_root_bridge_prepare()

On the MIPS ralink mt7621 platform, we need to set up I/O coherency units
based on the host bridge apertures.

To remove this arch dependency from the driver itself, move the coherency
setup from the driver to pcibios_root_bridge_prepare().

[bhelgaas: squash add/remove into one patch, commit log]
Link: https://lore.kernel.org/r/20211207104924.21327-3-sergio.paracuellos@gmail.com
Link: https://lore.kernel.org/r/20211207104924.21327-4-sergio.paracuellos@gmail.com
Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net> # arch/mips
Acked-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de> # arch/mips
2 years agoPCI: Let pcibios_root_bridge_prepare() access bridge->windows
Sergio Paracuellos [Tue, 7 Dec 2021 10:49:20 +0000 (11:49 +0100)]
PCI: Let pcibios_root_bridge_prepare() access bridge->windows

When pci_register_host_bridge() is called, bridge->windows are already
available. However these windows are being moved temporarily from there.

To let pcibios_root_bridge_prepare() have access to these windows, move the
windows movement after calling this function. This is useful for the MIPS
ralink mt7621 platform so it can set up I/O coherence units and avoid
custom MIPS code in the mt7621 PCIe controller driver.

Link: https://lore.kernel.org/r/20211207104924.21327-2-sergio.paracuellos@gmail.com
Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
2 years agoPCI: mt7621: Declare mt7621_pci_ops static
Sergio Paracuellos [Wed, 17 Nov 2021 15:29:52 +0000 (16:29 +0100)]
PCI: mt7621: Declare mt7621_pci_ops static

Sparse complains about mt7621_pci_ops symbol is not declared and asks if
it should be declared as static instead. Sparse is right. Hence declare
symbol as static.

Link: https://lore.kernel.org/r/20211117152952.12271-1-sergio.paracuellos@gmail.com
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Krzysztof Wilczyński <kw@linux.com>
2 years agoPCI: brcmstb: Do not turn off WOL regulators on suspend
Jim Quinlan [Thu, 6 Jan 2022 16:03:30 +0000 (11:03 -0500)]
PCI: brcmstb: Do not turn off WOL regulators on suspend

If any downstream device can be a wakeup device, do not turn off the
regulators as the device will need them on.

Link: https://lore.kernel.org/r/20220106160332.2143-8-jim2101024@gmail.com
Signed-off-by: Jim Quinlan <jim2101024@gmail.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
2 years agoPCI: brcmstb: Add control of subdevice voltage regulators
Jim Quinlan [Thu, 6 Jan 2022 16:03:29 +0000 (11:03 -0500)]
PCI: brcmstb: Add control of subdevice voltage regulators

This Broadcom STB PCIe RC driver has one port and connects directly to one
device, be it a switch or an endpoint.  We want to be able to leverage the
recently added mechanism that allocates and turns on/off subdevice
regulators.

All that needs to be done is to put the regulator DT nodes in the bridge
below host and to set the pci_ops methods add_bus and remove_bus.

Note that the pci_subdev_regulators_add_bus() method is wrapped for two
reasons:

   1. To achieve link up after the voltage regulators are turned on.

   2. If, in the case of an unsuccessful link up, to redirect any PCIe
      accesses to subdevices, e.g. the scan for DEV/ID.  This redirection
      is needed because the Broadcom PCIe HW will issue a CPU abort if such
      an access is made when the link is down.

[bhelgaas: fold in
https://lore.kernel.org/r/20220112013100.48029-1-jim2101024@gmail.com]
Link: https://lore.kernel.org/r/20220106160332.2143-7-jim2101024@gmail.com
Signed-off-by: Jim Quinlan <jim2101024@gmail.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
2 years agoPCI: brcmstb: Add mechanism to turn on subdev regulators
Jim Quinlan [Thu, 6 Jan 2022 16:03:28 +0000 (11:03 -0500)]
PCI: brcmstb: Add mechanism to turn on subdev regulators

Add a mechanism to identify standard PCIe regulators in the DT, allocate
them, and turn them on before the rest of the bus is scanned during
pci_host_probe().

The allocated structure that contains the regulators is stored in the port
driver dev.driver_data field.  Here is a point-by-point of how and when
this mechanism is activated:

If:
    -- PCIe RC driver sets pci_ops {add,remove)_bus to
       pci_subdev_regulators_{add,remove}_bus during its probe.
    -- There is a DT node "RB" under the host bridge DT node.
    -- During the RC driver's pci_host_probe() the add_bus callback
       is invoked where (bus->parent && pci_is_root_bus(bus->parent)
       is true

Then:
    -- A struct subdev_regulators structure will be allocated and
       assigned to bus->dev.driver_data.
    -- regulator_bulk_{get,enable} will be invoked on &bus->dev
       and the former will search for and process any
       vpcie{12v,3v3,3v3aux}-supply properties that reside in node "RB".
    -- The regulators will be turned off/on for any unbind/bind operations.
    -- The regulators will be turned off/on for any suspend/resumes, but
       only if the RC driver handles this on its own.  This will appear
       in a later commit for the pcie-brcmstb.c driver.

The unabridged reason for doing this is as follows.  We would like the
Broadcom STB PCIe root complex driver (and others) to be able to turn
off/on regulators[1] that provide power to endpoint[2] devices.  Typically,
the drivers of these endpoint devices are stock Linux drivers that are not
aware that these regulator(s) exist and must be turned on for the driver to
be probed.  The simple solution of course is to turn these regulators on at
boot and keep them on.  However, this solution does not satisfy at least
three of our usage modes:

  1. For example, one customer uses multiple PCIe controllers, but wants
     the ability to, by script invoking and unbind, turn any or all of them
     and their subdevices off to save power, e.g. when in battery mode.

  2. Another example is when a watchdog script discovers that an endpoint
     device is in an unresponsive state and would like to unbind, power
     toggle, and re-bind just the PCIe endpoint and controller.

  3. Of course we also want power turned off during suspend mode.  However,
     some endpoint devices may be able to "wake" during suspend and we need
     to recognise this case and veto the nominal act of turning off its
     regulator.  Such is the case with Wake-on-LAN and Wake-on-WLAN support
     where the PCIe endpoint device needs to be kept powered on in order to
     receive network packets and wake the system.

In all of these cases it is advantageous for the PCIe controller to govern
the turning off/on the regulators needed by the endpoint device.  The first
two cases can be done by simply unbinding and binding the PCIe controller,
if the controller has control of these regulators.

[1] These regulators typically govern the actual power supply to the
    endpoint chip.  Sometimes they may be the official PCIe socket
    power -- such as 3.3v or aux-3.3v.  Sometimes they are truly
    the regulator(s) that supply power to the EP chip.

[2] The 99% configuration of our boards is a single endpoint device
    attached to the PCIe controller.  I use the term endpoint but it could
    possibly mean a switch as well.

Link: https://lore.kernel.org/r/20220106160332.2143-6-jim2101024@gmail.com
Signed-off-by: Jim Quinlan <jim2101024@gmail.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
2 years agoPCI: brcmstb: Split brcm_pcie_setup() into two funcs
Jim Quinlan [Thu, 6 Jan 2022 16:03:27 +0000 (11:03 -0500)]
PCI: brcmstb: Split brcm_pcie_setup() into two funcs

We need to take some code in brcm_pcie_setup() and put it in a new function
brcm_pcie_linkup().  In future commits the brcm_pcie_linkup() function will
be called indirectly by pci_host_probe() as opposed to the host driver
invoking it directly.

Some code that was executed after the PCIe linkup is now placed so that it
executes prior to linkup, since this code has to run prior to the
invocation of pci_host_probe().

Link: https://lore.kernel.org/r/20220106160332.2143-5-jim2101024@gmail.com
Signed-off-by: Jim Quinlan <jim2101024@gmail.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
2 years agodt-bindings: PCI: Add bindings for Brcmstb EP voltage regulators
Jim Quinlan [Thu, 6 Jan 2022 16:03:26 +0000 (11:03 -0500)]
dt-bindings: PCI: Add bindings for Brcmstb EP voltage regulators

Add bindings for Brcmstb EP voltage regulators.  A new mechanism is to be
added to the Linux PCI subsystem that will allocate and turn on/off
regulators.  These are standard regulators -- vpcie12v, vpcie3v3, and
vpcie3v3aux -- placed in the DT in the bridge node under the host bridge
device.

The use of a regulator property in the PCIe EP subnode such as
"vpcie12v-supply" depends on a pending pullreq to the pci-bus.yaml
file at

  https://github.com/devicetree-org/dt-schema/pull/63

Link: https://lore.kernel.org/r/20220106160332.2143-4-jim2101024@gmail.com
Signed-off-by: Jim Quinlan <jim2101024@gmail.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
2 years agodt-bindings: PCI: Correct brcmstb interrupts, interrupt-map.
Jim Quinlan [Thu, 6 Jan 2022 16:03:25 +0000 (11:03 -0500)]
dt-bindings: PCI: Correct brcmstb interrupts, interrupt-map.

The "pcie" and "msi" interrupts were given the same interrupt when they are
actually different.  Interrupt-map only had the INTA entry; add the INTB,
INTC, and INTD entries.

Link: https://lore.kernel.org/r/20220106160332.2143-3-jim2101024@gmail.com
Signed-off-by: Jim Quinlan <jim2101024@gmail.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Acked-by: Rob Herring <robh@kernel.org>
2 years agoPCI: brcmstb: Fix function return value handling
Jim Quinlan [Thu, 6 Jan 2022 16:03:24 +0000 (11:03 -0500)]
PCI: brcmstb: Fix function return value handling

Do at least a dev_err() on some calls to reset_control_rearm() and
brcm_phy_stop().  In some cases it may not make sense to return this error
value "above" as doing so will cause more trouble than is warranted.

Link: https://lore.kernel.org/r/20220106160332.2143-2-jim2101024@gmail.com
Signed-off-by: Jim Quinlan <jim2101024@gmail.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
2 years agoPCI: brcmstb: Do not use __GENMASK
Florian Fainelli [Mon, 22 Nov 2021 19:04:58 +0000 (11:04 -0800)]
PCI: brcmstb: Do not use __GENMASK

Define the legacy MSI interrupt bitmask as well as the non-legacy interrupt
bitmask using GENMASK and then use them in brcm_msi_set_regs() in place of
__GENMASK().

Link: https://lore.kernel.org/r/20211122190459.3189616-1-f.fainelli@gmail.com
Reported-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
2 years agoPCI: brcmstb: Declare 'used' as bitmap, not unsigned long
Christophe JAILLET [Sun, 7 Nov 2021 08:32:58 +0000 (09:32 +0100)]
PCI: brcmstb: Declare 'used' as bitmap, not unsigned long

The 'used' field of 'struct brcm_msi' is used as a bitmap.  Declare it with
DECLARE_BITMAP() and adjust users accordingly.

This fixes a harmless Coverity warning about array vs singleton usage.

This bitmap can be used for either legacy or MSI interrupts, which require
a size of BRCM_INT_PCI_MSI_LEGACY_NR or BRCM_INT_PCI_MSI_NR respectively.
Add a BUILD_BUG_ON() to ensure it is large enough.

Suggested-by: Krzysztof Wilczynski <kw@linux.com>
Addresses-Coverity: "Out-of-bounds access (ARRAY_VS_SINGLETON)"
Link: https://lore.kernel.org/r/e6d9da2112aab2939d1507b90962d07bfd735b4c.1636273671.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
2 years agoPCI: hv: Add arm64 Hyper-V vPCI support
Sunil Muthuswamy [Wed, 5 Jan 2022 19:32:36 +0000 (11:32 -0800)]
PCI: hv: Add arm64 Hyper-V vPCI support

Add arm64 Hyper-V vPCI support by implementing the arch specific
interfaces. Introduce an IRQ domain and chip specific to Hyper-v vPCI that
is based on SPIs. The IRQ domain parents itself to the arch GIC IRQ domain
for basic vector management.

[bhelgaas: squash in fix from Yang Li <yang.lee@linux.alibaba.com>:
https://lore.kernel.org/r/20220112003324.62755-1-yang.lee@linux.alibaba.com]
Link: https://lore.kernel.org/r/1641411156-31705-3-git-send-email-sunilmut@linux.microsoft.com
Signed-off-by: Sunil Muthuswamy <sunilmut@microsoft.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
2 years agoPCI: hv: Make the code arch neutral by adding arch specific interfaces
Sunil Muthuswamy [Wed, 5 Jan 2022 19:32:35 +0000 (11:32 -0800)]
PCI: hv: Make the code arch neutral by adding arch specific interfaces

Encapsulate arch dependencies in Hyper-V vPCI through a set of
arch-dependent interfaces. Adding these arch specific interfaces will
allow for an implementation for other architectures, such as arm64.

There are no functional changes expected from this patch.

Link: https://lore.kernel.org/r/1641411156-31705-2-git-send-email-sunilmut@linux.microsoft.com
Signed-off-by: Sunil Muthuswamy <sunilmut@microsoft.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Boqun Feng <boqun.feng@gmail.com>
Reviewed-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
2 years agoPCI: pciehp: Use down_read/write_nested(reset_lock) to fix lockdep errors
Hans de Goede [Fri, 17 Dec 2021 14:17:09 +0000 (15:17 +0100)]
PCI: pciehp: Use down_read/write_nested(reset_lock) to fix lockdep errors

Use down_read_nested() and down_write_nested() when taking the
ctrl->reset_lock rw-sem, passing the number of PCIe hotplug controllers in
the path to the PCI root bus as lock subclass parameter.

This fixes the following false-positive lockdep report when unplugging a
Lenovo X1C8 from a Lenovo 2nd gen TB3 dock:

  pcieport 0000:06:01.0: pciehp: Slot(1): Link Down
  pcieport 0000:06:01.0: pciehp: Slot(1): Card not present
  ============================================
  WARNING: possible recursive locking detected
  5.16.0-rc2+ #621 Not tainted
  --------------------------------------------
  irq/124-pciehp/86 is trying to acquire lock:
  ffff8e5ac4299ef8 (&ctrl->reset_lock){.+.+}-{3:3}, at: pciehp_check_presence+0x23/0x80

  but task is already holding lock:
  ffff8e5ac4298af8 (&ctrl->reset_lock){.+.+}-{3:3}, at: pciehp_ist+0xf3/0x180

   other info that might help us debug this:
   Possible unsafe locking scenario:

 CPU0
 ----
    lock(&ctrl->reset_lock);
    lock(&ctrl->reset_lock);

   *** DEADLOCK ***

   May be due to missing lock nesting notation

  3 locks held by irq/124-pciehp/86:
   #0: ffff8e5ac4298af8 (&ctrl->reset_lock){.+.+}-{3:3}, at: pciehp_ist+0xf3/0x180
   #1: ffffffffa3b024e8 (pci_rescan_remove_lock){+.+.}-{3:3}, at: pciehp_unconfigure_device+0x31/0x110
   #2: ffff8e5ac1ee2248 (&dev->mutex){....}-{3:3}, at: device_release_driver+0x1c/0x40

  stack backtrace:
  CPU: 4 PID: 86 Comm: irq/124-pciehp Not tainted 5.16.0-rc2+ #621
  Hardware name: LENOVO 20U90SIT19/20U90SIT19, BIOS N2WET30W (1.20 ) 08/26/2021
  Call Trace:
   <TASK>
   dump_stack_lvl+0x59/0x73
   __lock_acquire.cold+0xc5/0x2c6
   lock_acquire+0xb5/0x2b0
   down_read+0x3e/0x50
   pciehp_check_presence+0x23/0x80
   pciehp_runtime_resume+0x5c/0xa0
   device_for_each_child+0x45/0x70
   pcie_port_device_runtime_resume+0x20/0x30
   pci_pm_runtime_resume+0xa7/0xc0
   __rpm_callback+0x41/0x110
   rpm_callback+0x59/0x70
   rpm_resume+0x512/0x7b0
   __pm_runtime_resume+0x4a/0x90
   __device_release_driver+0x28/0x240
   device_release_driver+0x26/0x40
   pci_stop_bus_device+0x68/0x90
   pci_stop_bus_device+0x2c/0x90
   pci_stop_and_remove_bus_device+0xe/0x20
   pciehp_unconfigure_device+0x6c/0x110
   pciehp_disable_slot+0x5b/0xe0
   pciehp_handle_presence_or_link_change+0xc3/0x2f0
   pciehp_ist+0x179/0x180

This lockdep warning is triggered because with Thunderbolt, hotplug ports
are nested. When removing multiple devices in a daisy-chain, each hotplug
port's reset_lock may be acquired recursively. It's never the same lock, so
the lockdep splat is a false positive.

Because locks at the same hierarchy level are never acquired recursively, a
per-level lockdep class is sufficient to fix the lockdep warning.

The choice to use one lockdep subclass per pcie-hotplug controller in the
path to the root-bus was made to conserve class keys because their number
is limited and the complexity grows quadratically with number of keys
according to Documentation/locking/lockdep-design.rst.

Link: https://lore.kernel.org/linux-pci/20190402021933.GA2966@mit.edu/
Link: https://lore.kernel.org/linux-pci/de684a28-9038-8fc6-27ca-3f6f2f6400d7@redhat.com/
Link: https://lore.kernel.org/r/20211217141709.379663-1-hdegoede@redhat.com
Link: https://bugzilla.kernel.org/show_bug.cgi?id=208855
Reported-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Lukas Wunner <lukas@wunner.de>
Cc: stable@vger.kernel.org
2 years agox86/PCI: Remove initialization of static variables to false
Longji Guo [Fri, 3 Dec 2021 08:07:58 +0000 (16:07 +0800)]
x86/PCI: Remove initialization of static variables to false

Remove the initialization of pci_ignore_seg to false which is pointless.

Link: https://lore.kernel.org/r/20211203080758.962-1-guolongji@uniontech.com
Signed-off-by: Longji Guo <guolongji@uniontech.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
2 years agoPCI: Use DWORD accesses for LTR, L1 SS to avoid erratum
Rajat Jain [Wed, 22 Dec 2021 01:21:05 +0000 (17:21 -0800)]
PCI: Use DWORD accesses for LTR, L1 SS to avoid erratum

Some devices have an erratum such that they only support DWORD accesses to
some registers.  E.g., this Bayhub O2 device ([VID:DID] = [0x1217:0x8621])
only supports DWORD accesses to LTR latency registers and L1 PM substates
control registers:

  https://github.com/rajatxjain/public_shared/blob/main/OZ711LV2_appnote.pdf

The L1 PM substate control registers are DWORD sized, and hence their
access in the kernel is already DWORD sized, so we don't need to do
anything for them.

However, the LTR registers being WORD sized, are in need of a solution.
Convert the WORD sized accesses to these registers into DWORD sized
accesses while saving and restoring them.

Link: https://lore.kernel.org/r/20211222012105.3438916-1-rajatja@google.com
Signed-off-by: Rajat Jain <rajatja@google.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
2 years agoPCI: Work around Intel I210 ROM BAR overlap defect
Bjorn Helgaas [Tue, 21 Dec 2021 16:45:07 +0000 (10:45 -0600)]
PCI: Work around Intel I210 ROM BAR overlap defect

Per PCIe r5, sec 7.5.1.2.4, a device must not claim accesses to its
Expansion ROM unless both the Memory Space Enable and the Expansion ROM
Enable bit are set.  But apparently some Intel I210 NICs don't work
correctly if the ROM BAR overlaps another BAR, even if the Expansion ROM is
disabled.

Michael reported that on a Kontron SMARC-sAL28 ARM64 system with U-Boot
v2021.01-rc3, the ROM BAR overlaps BAR 3, and networking doesn't work at
all:

  BAR 0: 0x40000000 (32-bit, non-prefetchable) [size=1M]
  BAR 3: 0x40200000 (32-bit, non-prefetchable) [size=16K]
  ROM:   0x40200000 (disabled) [size=1M]

  NETDEV WATCHDOG: enP2p1s0 (igb): transmit queue 0 timed out
  Hardware name: Kontron SMARC-sAL28 (Single PHY) on SMARC Eval 2.0 carrier (DT)
  igb 0002:01:00.0 enP2p1s0: Reset adapter

Previously, pci_std_update_resource() wrote the assigned ROM address to the
BAR only when the ROM was enabled.  This meant that the I210 ROM BAR could
be left with an address assigned by firmware, which might overlap with
other BARs.

Quirk these I210 devices so pci_std_update_resource() always writes the
assigned address to the ROM BAR, whether or not the ROM is enabled.

Link: https://lore.kernel.org/r/20211223163754.GA1267351@bhelgaas
Link: https://lore.kernel.org/r/20201230185317.30915-1-michael@walle.cc
Link: https://bugzilla.kernel.org/show_bug.cgi?id=211105
Reported-by: Michael Walle <michael@walle.cc>
Tested-by: Michael Walle <michael@walle.cc>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
2 years agoPCI: keystone: Use phandle argument from "ti,syscon-pcie-id"/"ti,syscon-pcie-mode"
Kishon Vijay Abraham I [Fri, 26 Nov 2021 08:31:16 +0000 (14:01 +0530)]
PCI: keystone: Use phandle argument from "ti,syscon-pcie-id"/"ti,syscon-pcie-mode"

Get "syscon" pcie_mode and pcie_id offset from the argument of
"ti,syscon-pcie-id" and "ti,syscon-pcie-mode" phandle respectively.
Previously a subnode to "syscon" node was added which has the
exact memory mapped address of pcie_mode and pcie_id but now the
offset of pcie_mode and pcie_id within "syscon" is now being passed
as argument to "ti,syscon-pcie-id" and "ti,syscon-pcie-mode" phandle.

If the offset is not provided in "ti,syscon-pcie-id"/"ti,syscon-pcie-mode",
the full memory mapped address of pcie_ctrl is used in order to maintain
old DT compatibility.

Similar change for J721E is as discussed in [1]

[1] -> http://lore.kernel.org/r/CAL_JsqKiUcO76bo1GoepWM1TusJWoty_BRy2hFSgtEVMqtrvvQ@mail.gmail.com

Link: https://lore.kernel.org/r/20211126083119.16570-3-kishon@ti.com
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agodt-bindings: PCI: ti,am65: Fix "ti,syscon-pcie-id"/"ti,syscon-pcie-mode" to take...
Kishon Vijay Abraham I [Fri, 26 Nov 2021 08:31:15 +0000 (14:01 +0530)]
dt-bindings: PCI: ti,am65: Fix "ti,syscon-pcie-id"/"ti,syscon-pcie-mode" to take argument

Fix binding documentation of "ti,syscon-pcie-id" and "ti,syscon-pcie-mode"
to take phandle with argument. The argument is the register offset within
"syscon" used to configure PCIe controller. Similar change for j721e is
discussed in [1]

[1] -> http://lore.kernel.org/r/CAL_JsqKiUcO76bo1GoepWM1TusJWoty_BRy2hFSgtEVMqtrvvQ@mail.gmail.com

Link: https://lore.kernel.org/r/20211126083119.16570-2-kishon@ti.com
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Rob Herring <robh@kernel.org>
2 years agoPCI: endpoint: Return -EINVAL when interrupts num is smaller than 1
Li Chen [Tue, 21 Dec 2021 02:59:56 +0000 (02:59 +0000)]
PCI: endpoint: Return -EINVAL when interrupts num is smaller than 1

In pci_epc_set_msi() we should return immediately if there are no
interrupts to configure; update the code to return early.

Link: https://lore.kernel.org/r/CH2PR19MB402491B9E503694DBCAC6005A07C9@CH2PR19MB4024.namprd19.prod.outlook.com
Signed-off-by: Li Chen <lchen@ambarella.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Kishon Vijay Abraham I <kishon@ti.com>
2 years agoPCI: mediatek: Assert PERST# for 100ms for power and clock to stabilize
qizhong cheng [Mon, 27 Dec 2021 13:31:10 +0000 (21:31 +0800)]
PCI: mediatek: Assert PERST# for 100ms for power and clock to stabilize

Described in PCIe CEM specification sections 2.2 (PERST# Signal) and
2.2.1 (Initial Power-Up (G3 to S0)). The deassertion of PERST# should
be delayed 100ms (TPVPERL) for the power and clock to become stable.

Link: https://lore.kernel.org/r/20211227133110.14500-1-qizhong.cheng@mediatek.com
Signed-off-by: qizhong cheng <qizhong.cheng@mediatek.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Pali Rohár <pali@kernel.org>
2 years agoPCI: mvebu: Add support for compiling driver as module
Pali Rohár [Fri, 26 Nov 2021 14:43:07 +0000 (15:43 +0100)]
PCI: mvebu: Add support for compiling driver as module

Now when driver uses devm_pci_remap_iospace() function, it is possible
implement ->remove() callback for unbinding device from driver.

Implement mvebu_pcie_remove() callback with proper cleanup phase, drop
driver's suppress_bind_attrs flag and switch type of CONFIG_PCI_MVEBU
option from bool to tristate.

This allows to compile pci-mvebu.c driver as loadable module pci-mvebu.ko
with ability to unload it.

Link: https://lore.kernel.org/r/20211126144307.7568-3-pali@kernel.org
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agobus: mvebu-mbus: Export symbols for public API window functions
Pali Rohár [Fri, 26 Nov 2021 14:43:06 +0000 (15:43 +0100)]
bus: mvebu-mbus: Export symbols for public API window functions

This would allow to compile pci-mvebu.c driver as module.

Link: https://lore.kernel.org/r/20211126144307.7568-2-pali@kernel.org
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoPCI: layerscape: Change to use the DWC common link-up check function
Hou Zhiqiang [Fri, 24 Dec 2021 09:40:00 +0000 (17:40 +0800)]
PCI: layerscape: Change to use the DWC common link-up check function

The current Layerscape PCIe driver directly uses the physical layer
LTSSM code to check the link-up state, which treats the > L0 states
as link-up. This is not correct, since there is not explicit map
between link-up state and LTSSM. So this patch changes to use the
DWC common link-up check function.

Link: https://lore.kernel.org/r/20211224094000.8513-1-Zhiqiang.Hou@nxp.com
Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Rob Herring <robh@kernel.org>
2 years agoPCI: qcom-ep: Constify static dw_pcie_ep_ops
Rikard Falkeborn [Sat, 4 Dec 2021 22:03:16 +0000 (23:03 +0100)]
PCI: qcom-ep: Constify static dw_pcie_ep_ops

The only usage of pci_ep_ops is to assign its address to the ops field
in the dw_pcie_ep struct which is a pointer to const struct dw_pcie_ep_ops.
Make it const to allow the compiler to put it in read-only memory.

Link: https://lore.kernel.org/r/20211204220316.88655-1-rikard.falkeborn@gmail.com
Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Krzysztof Wilczyński <kw@linux.com>
2 years agoPCI: mvebu: Fix support for DEVCAP2, DEVCTL2 and LNKCTL2 registers on emulated bridge
Pali Rohár [Thu, 25 Nov 2021 12:46:05 +0000 (13:46 +0100)]
PCI: mvebu: Fix support for DEVCAP2, DEVCTL2 and LNKCTL2 registers on emulated bridge

Armada XP and new hardware supports access to DEVCAP2, DEVCTL2 and LNKCTL2
configuration registers of PCIe core via PCIE_CAP_PCIEXP. So export them
via emulated software root bridge.

Pre-XP hardware does not support these registers and returns zeros.

Link: https://lore.kernel.org/r/20211125124605.25915-16-pali@kernel.org
Fixes: 1f08673eef12 ("PCI: mvebu: Convert to PCI emulated bridge config space")
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoPCI: mvebu: Fix support for PCI_EXP_RTSTA on emulated bridge
Pali Rohár [Thu, 25 Nov 2021 12:46:04 +0000 (13:46 +0100)]
PCI: mvebu: Fix support for PCI_EXP_RTSTA on emulated bridge

PME Status bit in Root Status Register (PCIE_RC_RTSTA_OFF) is read-only and
can be cleared only by writing 0b to the Interrupt Cause RW0C register
(PCIE_INT_CAUSE_OFF).

Link: https://lore.kernel.org/r/20211125124605.25915-15-pali@kernel.org
Fixes: 1f08673eef12 ("PCI: mvebu: Convert to PCI emulated bridge config space")
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoPCI: mvebu: Fix support for PCI_EXP_DEVCTL on emulated bridge
Pali Rohár [Thu, 25 Nov 2021 12:46:03 +0000 (13:46 +0100)]
PCI: mvebu: Fix support for PCI_EXP_DEVCTL on emulated bridge

Comment in Armada 370 functional specification is misleading.
PCI_EXP_DEVCTL_*RE bits are supported and configures receiving of error
interrupts.

Link: https://lore.kernel.org/r/20211125124605.25915-14-pali@kernel.org
Fixes: 1f08673eef12 ("PCI: mvebu: Convert to PCI emulated bridge config space")
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoPCI: mvebu: Fix support for PCI_BRIDGE_CTL_BUS_RESET on emulated bridge
Pali Rohár [Thu, 25 Nov 2021 12:46:02 +0000 (13:46 +0100)]
PCI: mvebu: Fix support for PCI_BRIDGE_CTL_BUS_RESET on emulated bridge

Hardware supports PCIe Hot Reset via PCIE_CTRL_OFF register. Use it for
implementing PCI_BRIDGE_CTL_BUS_RESET bit of PCI_BRIDGE_CONTROL register on
emulated bridge.

With this change the function pci_reset_secondary_bus() starts working and
can reset connected PCIe card.

Link: https://lore.kernel.org/r/20211125124605.25915-13-pali@kernel.org
Fixes: 1f08673eef12 ("PCI: mvebu: Convert to PCI emulated bridge config space")
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoPCI: mvebu: Fix configuring secondary bus of PCIe Root Port via emulated bridge
Pali Rohár [Thu, 25 Nov 2021 12:46:01 +0000 (13:46 +0100)]
PCI: mvebu: Fix configuring secondary bus of PCIe Root Port via emulated bridge

It looks like that mvebu PCIe controller has for each PCIe link fully
independent PCIe host bridge and so every PCIe Root Port is isolated not
only on its own bus but also isolated from each others. But in past device
tree structure was defined to put all PCIe Root Ports (as PCI Bridge
devices) into one root bus 0 and this bus is emulated by pci-mvebu.c
driver.

Probably reason for this decision was incorrect understanding of PCIe
topology of these Armada SoCs and also reason of misunderstanding how is
PCIe controller generating Type 0 and Type 1 config requests (it is fully
different compared to other drivers). Probably incorrect setup leaded to
very surprised things like having PCIe Root Port (PCI Bridge device, with
even incorrect Device Class set to Memory Controller) and the PCIe device
behind the Root Port on the same PCI bus, which obviously was needed to
somehow hack (as these two devices cannot be in reality on the same bus).

Properly set mvebu local bus number and mvebu local device number based on
PCI Bridge secondary bus number configuration. Also correctly report
configured secondary bus number in config space. And explain in driver
comment why this setup is correct.

Link: https://lore.kernel.org/r/20211125124605.25915-12-pali@kernel.org
Fixes: 1f08673eef12 ("PCI: mvebu: Convert to PCI emulated bridge config space")
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoPCI: mvebu: Set PCI Bridge Class Code to PCI Bridge
Pali Rohár [Thu, 25 Nov 2021 12:46:00 +0000 (13:46 +0100)]
PCI: mvebu: Set PCI Bridge Class Code to PCI Bridge

The default value of Class Code of this bridge corresponds to a Memory
controller, though. This is probably relict from the past when old
Marvell/Galileo PCI-based controllers were used as standalone PCI device
for connecting SDRAM or workaround for PCs with broken BIOS. Details are
in commit 36de23a4c5f0 ("MIPS: Cobalt: Explain GT64111 early PCI fixup").

Change the Class Code to correspond to a PCI Bridge.

Add comment explaining this change.

Link: https://lore.kernel.org/r/20211125124605.25915-11-pali@kernel.org
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoPCI: mvebu: Setup PCIe controller to Root Complex mode
Pali Rohár [Thu, 25 Nov 2021 12:45:59 +0000 (13:45 +0100)]
PCI: mvebu: Setup PCIe controller to Root Complex mode

This driver operates only in Root Complex mode, so ensure that hardware is
properly configured in Root Complex mode.

Link: https://lore.kernel.org/r/20211125124605.25915-10-pali@kernel.org
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoPCI: mvebu: Propagate errors when updating PCI_IO_BASE and PCI_MEM_BASE registers
Pali Rohár [Thu, 25 Nov 2021 12:45:58 +0000 (13:45 +0100)]
PCI: mvebu: Propagate errors when updating PCI_IO_BASE and PCI_MEM_BASE registers

Properly propagate failure from mvebu_pcie_add_windows() function back to
the caller mvebu_pci_bridge_emul_base_conf_write() and correctly updates
PCI_IO_BASE, PCI_MEM_BASE and PCI_IO_BASE_UPPER16 registers on error.
On error set base value higher than limit value which indicates that
address range is disabled. When IO is unsupported then let IO registers
zeroed as required by PCIe base specification.

Link: https://lore.kernel.org/r/20211125124605.25915-9-pali@kernel.org
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoPCI: mvebu: Do not modify PCI IO type bits in conf_write
Pali Rohár [Thu, 25 Nov 2021 12:45:57 +0000 (13:45 +0100)]
PCI: mvebu: Do not modify PCI IO type bits in conf_write

PCI IO type bits are already initialized in mvebu_pci_bridge_emul_init()
function and only when IO support is enabled. These type bits are read-only
and pci-bridge-emul.c code already does not allow to modify them from upper
layers.

When IO support is disabled then all IO registers should be read-only and
return zeros. Therefore do not modify PCI IO type bits in
mvebu_pci_bridge_emul_base_conf_write() callback.

Link: https://lore.kernel.org/r/20211125124605.25915-8-pali@kernel.org
Fixes: 1f08673eef12 ("PCI: mvebu: Convert to PCI emulated bridge config space")
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoPCI: mvebu: Fix support for bus mastering and PCI_COMMAND on emulated bridge
Pali Rohár [Thu, 25 Nov 2021 12:45:56 +0000 (13:45 +0100)]
PCI: mvebu: Fix support for bus mastering and PCI_COMMAND on emulated bridge

According to PCI specifications bits [0:2] of Command Register, this should
be by default disabled on reset. So explicitly disable these bits at early
beginning of driver initialization.

Also remove code which unconditionally enables all 3 bits and let kernel
code (via pci_set_master() function) to handle bus mastering of PCI Bridge
via emulated PCI_COMMAND on emulated bridge.

Adjust existing functions mvebu_pcie_handle_iobase_change() and
mvebu_pcie_handle_membase_change() to handle PCI_IO_BASE and PCI_MEM_BASE
registers correctly even when bus mastering on emulated bridge is disabled.

Link: https://lore.kernel.org/r/20211125124605.25915-7-pali@kernel.org
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoPCI: mvebu: Disallow mapping interrupts on emulated bridges
Pali Rohár [Thu, 25 Nov 2021 12:45:55 +0000 (13:45 +0100)]
PCI: mvebu: Disallow mapping interrupts on emulated bridges

Interrupt support on mvebu emulated bridges is not implemented yet.

So properly indicate return value to callers that they cannot request
interrupts from emulated bridge.

Link: https://lore.kernel.org/r/20211125124605.25915-6-pali@kernel.org
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoPCI: mvebu: Handle invalid size of read config request
Pali Rohár [Thu, 25 Nov 2021 12:45:54 +0000 (13:45 +0100)]
PCI: mvebu: Handle invalid size of read config request

Function mvebu_pcie_hw_rd_conf() does not handle invalid size. So correctly
set read value to all-ones and return appropriate error return value
PCIBIOS_BAD_REGISTER_NUMBER like in mvebu_pcie_hw_wr_conf() function.

Link: https://lore.kernel.org/r/20211125124605.25915-5-pali@kernel.org
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoPCI: mvebu: Check that PCI bridge specified in DT has function number zero
Pali Rohár [Thu, 25 Nov 2021 12:45:53 +0000 (13:45 +0100)]
PCI: mvebu: Check that PCI bridge specified in DT has function number zero

Driver cannot handle PCI bridges at non-zero function address. So add
appropriate check. Currently all in-tree kernel DTS files set PCI bridge
function to zero.

Link: https://lore.kernel.org/r/20211125124605.25915-4-pali@kernel.org
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoPCI: mvebu: Check for errors from pci_bridge_emul_init() call
Pali Rohár [Thu, 25 Nov 2021 12:45:52 +0000 (13:45 +0100)]
PCI: mvebu: Check for errors from pci_bridge_emul_init() call

Function pci_bridge_emul_init() may fail so correctly check for errors.

Link: https://lore.kernel.org/r/20211125124605.25915-3-pali@kernel.org
Fixes: 1f08673eef12 ("PCI: mvebu: Convert to PCI emulated bridge config space")
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoPCI: mvebu: Check for valid ports
Pali Rohár [Thu, 25 Nov 2021 12:45:51 +0000 (13:45 +0100)]
PCI: mvebu: Check for valid ports

Some mvebu ports do not have to be initialized. So skip these uninitialized
mvebu ports in every port iteration function to prevent access to unmapped
memory or dereferencing NULL pointers. Uninitialized mvebu port has base
address set to NULL.

Link: https://lore.kernel.org/r/20211125124605.25915-2-pali@kernel.org
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoPCI/sysfs: Use default_groups in kobj_type for slot attrs
Greg Kroah-Hartman [Tue, 28 Dec 2021 13:57:22 +0000 (14:57 +0100)]
PCI/sysfs: Use default_groups in kobj_type for slot attrs

There are currently two ways to create a set of sysfs files for a
kobj_type: through the default_attrs field, and the default_groups field.
Move the PCI slot code to use the default_groups field which has been the
preferred way since aa30f47cf666 ("kobject: Add support for default
attribute groups to kobj_type") so that we can soon get rid of the obsolete
default_attrs field.

Link: https://lore.kernel.org/r/20211228135722.381023-1-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
2 years agoPCI: imx: Add the imx8mm pcie support
Richard Zhu [Fri, 24 Dec 2021 02:28:05 +0000 (10:28 +0800)]
PCI: imx: Add the imx8mm pcie support

i.MX8MM PCIe works mostly like the i.MX8MQ one, but has a different PHY
and allows to output the internal PHY reference clock via the refclk pad.
Add the i.MX8MM PCIe support based on the standalone PHY driver.

Link: https://lore.kernel.org/r/1640312885-31142-2-git-send-email-hongxing.zhu@nxp.com
Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Tested-by: Tim Harvey <tharvey@gateworks.com>
Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Tim Harvey <tharvey@gateworks.com>
2 years agoPCI: Convert pci_dev_present() stub to static inline
Hans de Goede [Fri, 17 Dec 2021 14:15:15 +0000 (15:15 +0100)]
PCI: Convert pci_dev_present() stub to static inline

Change the pci_dev_present() stub which is used when CONFIG_PCI is not set
from a #define to a static inline stub.

Thix should fix clang -Werror builds failing due to errors like this:

  drivers/platform/x86/thinkpad_acpi.c:4475:35:
   error: unused variable 'fwbug_cards_ids' [-Werror,-Wunused-const-variable]

Where fwbug_cards_ids is an array of pci_device_id passed to
pci_dev_present() during a quirk check.

Link: https://lore.kernel.org/r/20211217141515.379586-1-hdegoede@redhat.com
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: platform-driver-x86@vger.kernel.org
2 years agodt-bindings: imx6q-pcie: Add PHY phandles and name properties
Richard Zhu [Thu, 2 Dec 2021 08:02:33 +0000 (16:02 +0800)]
dt-bindings: imx6q-pcie: Add PHY phandles and name properties

i.MX8MM PCIe has the PHY. Add a PHY phandle and name properties
in the binding document.

Link: https://lore.kernel.org/r/1638432158-4119-4-git-send-email-hongxing.zhu@nxp.com
Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Tested-by: Tim Harvey <tharvey@gateworks.com>
Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Tim Harvey <tharvey@gateworks.com>
Reviewed-by: Rob Herring <robh@kernel.org>
2 years agoPCI/P2PDMA: Use percpu_ref_tryget_live_rcu() inside RCU critical section
Christophe JAILLET [Wed, 3 Nov 2021 21:16:53 +0000 (22:16 +0100)]
PCI/P2PDMA: Use percpu_ref_tryget_live_rcu() inside RCU critical section

Since pci_alloc_p2pmem() has already called rcu_read_lock(), we're in an
RCU read-side critical section and don't need to take the lock again.  Use
percpu_ref_tryget_live_rcu() instead of percpu_ref_tryget_live() to save a
few cycles.

[bhelgaas: commit log]
Link: https://lore.kernel.org/r/ab80164f4d5b32f9e6240aa4863c3a147ff9c89f.1635974126.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Krzysztof Wilczyński <kw@linux.com>
Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
2 years agoMAINTAINERS: Add Logan Gunthorpe as P2PDMA maintainer
Bjorn Helgaas [Wed, 15 Dec 2021 21:43:04 +0000 (15:43 -0600)]
MAINTAINERS: Add Logan Gunthorpe as P2PDMA maintainer

Add a P2PDMA entry to make sure Logan is aware of changes to that area.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Logan Gunthorpe <logang@deltatee.com>
2 years agoPCI: Add function 1 DMA alias quirk for Marvell 88SE9125 SATA controller
Yifeng Li [Thu, 2 Dec 2021 06:35:21 +0000 (06:35 +0000)]
PCI: Add function 1 DMA alias quirk for Marvell 88SE9125 SATA controller

Like other SATA controller chips in the Marvell 88SE91xx series, the
Marvell 88SE9125 has the same DMA requester ID hardware bug that prevents
it from working under IOMMU.  Add it to the list of devices that need the
quirk.

Without this patch, device initialization fails with DMA errors:

  ata8: softreset failed (1st FIS failed)
  DMAR: DRHD: handling fault status reg 2
  DMAR: [DMA Write NO_PASID] Request device [03:00.1] fault addr 0xfffc0000 [fault reason 0x02] Present bit in context entry is clear
  DMAR: DRHD: handling fault status reg 2
  DMAR: [DMA Read NO_PASID] Request device [03:00.1] fault addr 0xfffc0000 [fault reason 0x02] Present bit in context entry is clear

After applying the patch, the controller can be successfully initialized:

  ata8: SATA link up 1.5 Gbps (SStatus 113 SControl 330)
  ata8.00: ATAPI: PIONEER BD-RW   BDR-207M, 1.21, max UDMA/100
  ata8.00: configured for UDMA/100
  scsi 7:0:0:0: CD-ROM            PIONEER  BD-RW   BDR-207M 1.21 PQ: 0 ANSI: 5

Link: https://lore.kernel.org/r/YahpKVR+McJVDdkD@work
Reported-by: Sam Bingner <sam@bingner.com>
Tested-by: Sam Bingner <sam@bingner.com>
Tested-by: Yifeng Li <tomli@tomli.me>
Signed-off-by: Yifeng Li <tomli@tomli.me>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Krzysztof Wilczyński <kw@linux.com>
Cc: stable@vger.kernel.org
2 years agovia-agp: convert to generic power management
Vaibhav Gupta [Tue, 12 Jan 2021 08:09:24 +0000 (13:39 +0530)]
via-agp: convert to generic power management

Convert via-agp from legacy PCI power management to the generic power
management framework.

Previously, via-agp used legacy PCI power management, and agp_via_suspend()
and agp_via_resume() were responsible for both device-specific things and
generic PCI things:

  agp_via_suspend
    pci_save_state(pdev)                <-- generic PCI
    pci_set_power_state(pdev, pci_choose_state(pdev, state)) <-- generic PCI

  agp_via_resume
    pci_set_power_state(pdev, PCI_D0)   <-- generic PCI
    pci_restore_state(pdev)             <-- generic PCI
    via_configure_agp3()                <-- device-specific
    via_configure()                     <-- device-specific

With generic power management, the PCI bus PM methods do the generic PCI
things, and the driver needs only the device-specific part, i.e.,

  suspend_devices_and_enter
    dpm_suspend_start(PMSG_SUSPEND)
      pci_pm_suspend                    # PCI bus .suspend() method
        agp_via_suspend                 <-- not needed at all; removed
    suspend_enter
      dpm_suspend_noirq(PMSG_SUSPEND)
        pci_pm_suspend_noirq            # PCI bus .suspend_noirq() method
          pci_save_state                <-- generic PCI
          pci_prepare_to_sleep          <-- generic PCI
            pci_set_power_state
    ...
    dpm_resume_end(PMSG_RESUME)
      pci_pm_resume                     # PCI bus .resume() method
        pci_restore_standard_config
          pci_set_power_state(PCI_D0)   <-- generic PCI
          pci_restore_state             <-- generic PCI
        agp_via_resume                  # dev->driver->pm->resume
          via_configure_agp3()          <-- device-specific
          via_configure()               <-- device-specific

[bhelgaas: commit log]
Link: https://lore.kernel.org/r/20211208193305.147072-4-helgaas@kernel.org
Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Dave Airlie <airlied@redhat.com>
2 years agosis-agp: convert to generic power management
Vaibhav Gupta [Tue, 12 Jan 2021 08:09:23 +0000 (13:39 +0530)]
sis-agp: convert to generic power management

Convert sis-agp from legacy PCI power management to the generic power
management framework.

Previously, sis-agp used legacy PCI power management, and agp_sis_suspend()
and agp_sis_resume() were responsible for both device-specific things and
generic PCI things:

  agp_sis_suspend
    pci_save_state(pdev)                <-- generic PCI
    pci_set_power_state(pdev, pci_choose_state(pdev, state)) <-- generic PCI

  agp_sis_resume
    pci_set_power_state(pdev, PCI_D0)   <-- generic PCI
    pci_restore_state(pdev)             <-- generic PCI
    sis_driver.configure()              <-- device-specific

With generic power management, the PCI bus PM methods do the generic PCI
things, and the driver needs only the device-specific part, i.e.,

  suspend_devices_and_enter
    dpm_suspend_start(PMSG_SUSPEND)
      pci_pm_suspend                    # PCI bus .suspend() method
        agp_sis_suspend                 <-- not needed at all; removed
    suspend_enter
      dpm_suspend_noirq(PMSG_SUSPEND)
        pci_pm_suspend_noirq            # PCI bus .suspend_noirq() method
          pci_save_state                <-- generic PCI
          pci_prepare_to_sleep          <-- generic PCI
            pci_set_power_state
    ...
    dpm_resume_end(PMSG_RESUME)
      pci_pm_resume                     # PCI bus .resume() method
        pci_restore_standard_config
          pci_set_power_state(PCI_D0)   <-- generic PCI
          pci_restore_state             <-- generic PCI
        agp_sis_resume                  # dev->driver->pm->resume
          sis_driver.configure()        <-- device-specific

[bhelgaas: commit log]
Link: https://lore.kernel.org/r/20211208193305.147072-3-helgaas@kernel.org
Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Dave Airlie <airlied@redhat.com>
2 years agoamd64-agp: convert to generic power management
Vaibhav Gupta [Tue, 12 Jan 2021 08:09:22 +0000 (13:39 +0530)]
amd64-agp: convert to generic power management

Convert amd64-agp from legacy PCI power management to the generic power
management framework.

Previously, amd64-agp used legacy PCI power management, and
agp_amd64_suspend() and agp_amd64_resume() were responsible for both
device-specific things and generic PCI things:

  agp_amd64_suspend
    pci_save_state(pdev)                <-- generic PCI
    pci_set_power_state(pdev, pci_choose_state(pdev, state)) <-- generic PCI

  agp_amd64_resume
    pci_set_power_state(pdev, PCI_D0)   <-- generic PCI
    pci_restore_state(pdev)             <-- generic PCI
    nforce3_agp_init()                  <-- device-specific
    amd_8151_configure()                <-- device-specific

With generic power management, the PCI bus PM methods do the generic PCI
things, and the driver needs only the device-specific part, i.e.,

  suspend_devices_and_enter
    dpm_suspend_start(PMSG_SUSPEND)
      pci_pm_suspend                    # PCI bus .suspend() method
        agp_amd64_suspend               <-- not needed at all; removed
    suspend_enter
      dpm_suspend_noirq(PMSG_SUSPEND)
        pci_pm_suspend_noirq            # PCI bus .suspend_noirq() method
          pci_save_state                <-- generic PCI
          pci_prepare_to_sleep          <-- generic PCI
            pci_set_power_state
    ...
    dpm_resume_end(PMSG_RESUME)
      pci_pm_resume                     # PCI bus .resume() method
        pci_restore_standard_config
          pci_set_power_state(PCI_D0)   <-- generic PCI
          pci_restore_state             <-- generic PCI
        agp_amd64_resume                # dev->driver->pm->resume
          nforce3_agp_init()            <-- device-specific
          amd_8151_configure()          <-- device-specific

[bhelgaas: commit log]
Link: https://lore.kernel.org/r/20211208193305.147072-2-helgaas@kernel.org
Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Dave Airlie <airlied@redhat.com>
2 years agoPCI: ibmphp: Remove commented-out functions
Vihas Mak [Thu, 9 Dec 2021 21:36:18 +0000 (03:06 +0530)]
PCI: ibmphp: Remove commented-out functions

The functions get_max_adapter_speed() and get_bus_name() in ibmphp_core.c
are commented-out and the fields .get_max_adapter_speed and
.get_bus_name_status are removed from struct hotplug_slot_ops in
pci_hotplug.h. Remove the commented-out functions.

Link: https://lore.kernel.org/r/20211209213618.20522-1-makvihas@gmail.com
Signed-off-by: Vihas Mak <makvihas@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
2 years agoarm: ioremap: Remove unused ARM-specific function pci_ioremap_io()
Pali Rohár [Wed, 24 Nov 2021 15:41:16 +0000 (16:41 +0100)]
arm: ioremap: Remove unused ARM-specific function pci_ioremap_io()

This function is not used by any driver anymore. So completely remove it.

Link: https://lore.kernel.org/r/20211124154116.916-6-pali@kernel.org
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2 years agoarm: ioremap: Replace pci_ioremap_io() usage by pci_remap_iospace()
Pali Rohár [Wed, 24 Nov 2021 15:41:15 +0000 (16:41 +0100)]
arm: ioremap: Replace pci_ioremap_io() usage by pci_remap_iospace()

Replace all usage of ARM specific pci_ioremap_io() function by standard
PCI core API function pci_remap_iospace() in all drivers and ARM mach
code.

Link: https://lore.kernel.org/r/20211124154116.916-5-pali@kernel.org
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2 years agoPCI: qcom-ep: Remove surplus dev_err() when using platform_get_irq_byname()
Krzysztof Wilczyński [Wed, 27 Oct 2021 11:29:31 +0000 (11:29 +0000)]
PCI: qcom-ep: Remove surplus dev_err() when using platform_get_irq_byname()

There is no need to call the dev_err() function directly to print a
custom message when handling an error from either the platform_get_irq()
or platform_get_irq_byname() functions as both are going to display an
appropriate error message in case of a failure.

This change is as per suggestions from Coccinelle, e.g.,
  drivers/pci/controller/dwc/pcie-qcom-ep.c:556:2-9: line 556 is redundant because platform_get_irq() already prints an error

Related:
  https://lore.kernel.org/all/20210310131913.2802385-1-kw@linux.com/
  https://lore.kernel.org/all/20200802142601.1635926-1-kw@linux.com/

Link: https://lore.kernel.org/r/20211027112931.37182-1-kw@linux.com
Signed-off-by: Krzysztof Wilczyński <kw@linux.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoPCI: apple: Fix REFCLK1 enable/poll logic
Hector Martin [Wed, 17 Nov 2021 14:00:44 +0000 (23:00 +0900)]
PCI: apple: Fix REFCLK1 enable/poll logic

REFCLK1 has req/ack bits that need to be programmed, just like REFCLK0.

Link: https://lore.kernel.org/r/20211117140044.193865-1-marcan@marcan.st
Fixes: 1e33888fbe44 ("PCI: apple: Add initial hardware bring-up")
Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Marc Zyngier <maz@kernel.org>
2 years agoPCI: qcom: Use __be16 type to store return value from cpu_to_be16()
Manivannan Sadhasivam [Tue, 30 Nov 2021 08:09:24 +0000 (13:39 +0530)]
PCI: qcom: Use __be16 type to store return value from cpu_to_be16()

cpu_to_be16() returns __be16 value but the driver uses u16 and that's
incorrect. Fix it by using __be16 as the data type of bdf_be variable.

The issue was spotted by the below sparse warning:

sparse warnings: (new ones prefixed by >>)
>> drivers/pci/controller/dwc/pcie-qcom.c:1305:30: sparse: sparse: incorrect type in initializer (different base types) @@     expected unsigned short [usertype] bdf_be @@     got restricted __be16 [usertype] @@
   drivers/pci/controller/dwc/pcie-qcom.c:1305:30: sparse:     expected unsigned short [usertype] bdf_be
   drivers/pci/controller/dwc/pcie-qcom.c:1305:30: sparse:     got restricted __be16 [usertype]

Link: https://lore.kernel.org/r/20211130080924.266116-1-manivannan.sadhasivam@linaro.org
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Krzysztof Wilczyński <kw@linux.com>
2 years agoPCI: aardvark: Fix checking for MEM resource type
Pali Rohár [Thu, 25 Nov 2021 16:01:47 +0000 (17:01 +0100)]
PCI: aardvark: Fix checking for MEM resource type

IORESOURCE_MEM_64 is not a resource type but a type flag.

Remove incorrect check for type IORESOURCE_MEM_64.

Link: https://lore.kernel.org/r/20211125160148.26029-2-kabel@kernel.org
Fixes: 64f160e19e92 ("PCI: aardvark: Configure PCIe resources from 'ranges' DT property")
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Marek Behún <kabel@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoPCI: aardvark: Disable common PHY when unbinding driver
Pali Rohár [Tue, 30 Nov 2021 17:29:13 +0000 (18:29 +0100)]
PCI: aardvark: Disable common PHY when unbinding driver

Disable the PCIe PHY when unbinding driver. This should save some power.

Link: https://lore.kernel.org/r/20211130172913.9727-12-kabel@kernel.org
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Marek Behún <kabel@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoPCI: aardvark: Disable link training when unbinding driver
Pali Rohár [Tue, 30 Nov 2021 17:29:12 +0000 (18:29 +0100)]
PCI: aardvark: Disable link training when unbinding driver

Disable link training circuit in driver unbind sequence. We want to
leave link training in the same state as it was before the driver was
probed.

Link: https://lore.kernel.org/r/20211130172913.9727-11-kabel@kernel.org
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Marek Behún <kabel@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoPCI: aardvark: Assert PERST# when unbinding driver
Pali Rohár [Tue, 30 Nov 2021 17:29:11 +0000 (18:29 +0100)]
PCI: aardvark: Assert PERST# when unbinding driver

Put the PCIe card into reset by asserting PERST# signal when unbinding
driver. It doesn't make sense to leave the card working if it can't
communicate with the host. This should also save some power.

Link: https://lore.kernel.org/r/20211130172913.9727-10-kabel@kernel.org
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Marek Behún <kabel@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoPCI: aardvark: Fix memory leak in driver unbind
Pali Rohár [Tue, 30 Nov 2021 17:29:10 +0000 (18:29 +0100)]
PCI: aardvark: Fix memory leak in driver unbind

Free config space for emulated root bridge when unbinding driver to fix
memory leak. Do it after disabling and masking all interrupts, since
aardvark interrupt handler accesses config space of emulated root
bridge.

Link: https://lore.kernel.org/r/20211130172913.9727-9-kabel@kernel.org
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Marek Behún <kabel@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoPCI: aardvark: Mask all interrupts when unbinding driver
Pali Rohár [Tue, 30 Nov 2021 17:29:09 +0000 (18:29 +0100)]
PCI: aardvark: Mask all interrupts when unbinding driver

Ensure that no interrupt can be triggered after driver unbind.

Link: https://lore.kernel.org/r/20211130172913.9727-8-kabel@kernel.org
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Marek Behún <kabel@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoPCI: aardvark: Disable bus mastering when unbinding driver
Pali Rohár [Tue, 30 Nov 2021 17:29:08 +0000 (18:29 +0100)]
PCI: aardvark: Disable bus mastering when unbinding driver

Ensure that after driver unbind PCIe cards are not able to forward
memory and I/O requests in the upstream direction.

Link: https://lore.kernel.org/r/20211130172913.9727-7-kabel@kernel.org
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Marek Behún <kabel@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoPCI: aardvark: Comment actions in driver remove method
Pali Rohár [Tue, 30 Nov 2021 17:29:07 +0000 (18:29 +0100)]
PCI: aardvark: Comment actions in driver remove method

Add two more comments into the advk_pcie_remove() method.

Link: https://lore.kernel.org/r/20211130172913.9727-6-kabel@kernel.org
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Marek Behún <kabel@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoPCI: aardvark: Clear all MSIs at setup
Pali Rohár [Tue, 30 Nov 2021 17:29:06 +0000 (18:29 +0100)]
PCI: aardvark: Clear all MSIs at setup

We already clear all the other interrupts (ISR0, ISR1, HOST_CTRL_INT).

Define a new macro PCIE_MSI_ALL_MASK and do the same clearing for MSIs,
to ensure that we don't start receiving spurious interrupts.

Use this new mask in advk_pcie_handle_msi();

Link: https://lore.kernel.org/r/20211130172913.9727-5-kabel@kernel.org
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Marek Behún <kabel@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoPCI: aardvark: Add support for DEVCAP2, DEVCTL2, LNKCAP2 and LNKCTL2 registers on...
Pali Rohár [Tue, 30 Nov 2021 17:29:05 +0000 (18:29 +0100)]
PCI: aardvark: Add support for DEVCAP2, DEVCTL2, LNKCAP2 and LNKCTL2 registers on emulated bridge

PCI aardvark hardware supports access to DEVCAP2, DEVCTL2, LNKCAP2 and
LNKCTL2 configuration registers of PCIe core via PCIE_CORE_PCIEXP_CAP.
Export them via emulated software root bridge.

Link: https://lore.kernel.org/r/20211130172913.9727-4-kabel@kernel.org
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Marek Behún <kabel@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoPCI: pci-bridge-emul: Add definitions for missing capabilities registers
Pali Rohár [Tue, 30 Nov 2021 17:29:04 +0000 (18:29 +0100)]
PCI: pci-bridge-emul: Add definitions for missing capabilities registers

pci-bridge-emul driver already allocates buffer for capabilities up to the
PCI_EXP_SLTSTA2 register, but does not define bit access behavior for these
registers. Add these missing definitions.

Link: https://lore.kernel.org/r/20211130172913.9727-3-kabel@kernel.org
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Marek Behún <kabel@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoPCI: pci-bridge-emul: Add description for class_revision field
Pali Rohár [Tue, 30 Nov 2021 17:29:03 +0000 (18:29 +0100)]
PCI: pci-bridge-emul: Add description for class_revision field

The current assignment to the class_revision member

  class_revision |= cpu_to_le32(PCI_CLASS_BRIDGE_PCI << 16);

can make the reader think that class is at high 16 bits of the member and
revision at low 16 bits.

In reality, class is at high 24 bits, but the class for PCI Bridge Normal
Decode is PCI_CLASS_BRIDGE_PCI << 8.

Change the assignment and add a comment to make this clearer.

Link: https://lore.kernel.org/r/20211130172913.9727-2-kabel@kernel.org
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Marek Behún <kabel@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoPCI: dwc: Do not remap invalid res
Tim Harvey [Mon, 1 Nov 2021 18:02:43 +0000 (11:02 -0700)]
PCI: dwc: Do not remap invalid res

On imx6 and perhaps others when pcie probes you get a:
imx6q-pcie 33800000.pcie: invalid resource

This occurs because the atu is not specified in the DT and as such it
should not be remapped.

Link: https://lore.kernel.org/r/20211101180243.23761-1-tharvey@gateworks.com
Fixes: 281f1f99cf3a ("PCI: dwc: Detect number of iATU windows")
Signed-off-by: Tim Harvey <tharvey@gateworks.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Acked-by: Richard Zhu <hongxing.zhu@nxp.com>
Cc: Richard Zhu <hongxing.zhu@nxp.com>
2 years agoPCI: mvebu: Remove custom mvebu_pci_host_probe() function
Pali Rohár [Wed, 24 Nov 2021 15:41:14 +0000 (16:41 +0100)]
PCI: mvebu: Remove custom mvebu_pci_host_probe() function

Now after pci_ioremap_io() usage was replaced by devm_pci_remap_iospace()
function, there is no need to use custom mvebu_pci_host_probe() function.
Current implementation of mvebu_pci_host_probe() is same as standard PCI
core function pci_host_probe(). So replace mvebu_pci_host_probe() call by
pci_host_probe() and remove custom mvebu_pci_host_probe() function.

Link: https://lore.kernel.org/r/20211124154116.916-4-pali@kernel.org
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoPCI: rcar: Check if device is runtime suspended instead of __clk_is_enabled()
Marek Vasut [Mon, 15 Nov 2021 20:46:41 +0000 (21:46 +0100)]
PCI: rcar: Check if device is runtime suspended instead of __clk_is_enabled()

Replace __clk_is_enabled() with pm_runtime_suspended(),
as __clk_is_enabled() was checking the wrong bus clock
and caused the following build error too:
  arm-linux-gnueabi-ld: drivers/pci/controller/pcie-rcar-host.o: in function `rcar_pcie_aarch32_abort_handler':
  pcie-rcar-host.c:(.text+0xdd0): undefined reference to `__clk_is_enabled'

Link: https://lore.kernel.org/r/20211115204641.12941-1-marek.vasut@gmail.com
Fixes: a115b1bd3af0 ("PCI: rcar: Add L1 link state fix into data abort hook")
Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: linux-renesas-soc@vger.kernel.org
2 years agoPCI: apple: Enable clock gating
Hector Martin [Wed, 17 Nov 2021 14:19:16 +0000 (23:19 +0900)]
PCI: apple: Enable clock gating

These pokes are not required to make the PCIe port work, but it sounds
like this should save some power at least.

Link: https://lore.kernel.org/r/20211117141916.197192-1-marcan@marcan.st
Tested-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Marc Zyngier <maz@kernel.org>
2 years agoPCI: mvebu: Replace pci_ioremap_io() usage by devm_pci_remap_iospace()
Pali Rohár [Wed, 24 Nov 2021 15:41:13 +0000 (16:41 +0100)]
PCI: mvebu: Replace pci_ioremap_io() usage by devm_pci_remap_iospace()

Now when ARM architecture code also provides standard PCI core function
pci_remap_iospace(), use its devm_pci_remap_iospace() variant in
pci-mvebu.c driver instead of old ARM-specific pci_ioremap_io() function.

Call devm_pci_remap_iospace() before adding IO resource to host bridge
structure, at the place where it should be.

Link: https://lore.kernel.org/r/20211124154116.916-3-pali@kernel.org
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2 years agoarm: ioremap: Implement standard PCI function pci_remap_iospace()
Pali Rohár [Wed, 24 Nov 2021 15:41:12 +0000 (16:41 +0100)]
arm: ioremap: Implement standard PCI function pci_remap_iospace()

pci_remap_iospace() is standard PCI core function. Architecture code can
reimplement default core implementation if needs custom arch specific
functionality.

ARM needs custom implementation due to pci_ioremap_set_mem_type() hook
which allows ARM platforms to change mem type for iospace.

Implement this pci_remap_iospace() function for ARM architecture to
correctly handle pci_ioremap_set_mem_type() hook, which allows usage of
this standard PCI core function also for platforms which needs different
mem type (e.g. Marvell Armada 375, 38x and 39x).

Link: https://lore.kernel.org/r/20211124154116.916-2-pali@kernel.org
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2 years agoPCI: qcom: Fix an error handling path in 'qcom_pcie_probe()'
Christophe JAILLET [Sat, 6 Nov 2021 17:44:52 +0000 (18:44 +0100)]
PCI: qcom: Fix an error handling path in 'qcom_pcie_probe()'

If 'of_device_get_match_data()' fails, previous 'pm_runtime_get_sync()/
pm_runtime_enable()' should be undone.

To fix it, the easiest is to move this block of code before the memory
allocations and the pm_runtime_xxx calls.

Link: https://lore.kernel.org/r/4d03c636193f64907c8dacb17fa71ed05fd5f60c.1636220582.git.christophe.jaillet@wanadoo.fr
Fixes: b89ff410253d ("PCI: qcom: Replace ops with struct pcie_cfg in pcie match data")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
2 years agoPCI: mediatek-gen3: Disable DVFSRC voltage request
Jianjun Wang [Fri, 15 Oct 2021 06:36:02 +0000 (14:36 +0800)]
PCI: mediatek-gen3: Disable DVFSRC voltage request

When the DVFSRC (dynamic voltage and frequency scaling resource collector)
feature is not implemented, the PCIe hardware will assert a voltage request
signal when exit from the L1 PM Substates to request a specific Vcore
voltage, but cannot receive the voltage ready signal, which will cause
the link to fail to exit the L1 PM Substates.

Disable DVFSRC voltage request by default, we need to find a common way to
enable it in the future.

Link: https://lore.kernel.org/r/20211015063602.29058-1-jianjun.wang@mediatek.com
Fixes: d3bf75b579b9 ("PCI: mediatek-gen3: Add MediaTek Gen3 driver for MT8192")
Tested-by: Qizhong Cheng <qizhong.cheng@mediatek.com>
Signed-off-by: Jianjun Wang <jianjun.wang@mediatek.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Tzung-Bi Shih <tzungbi@google.com>
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>