]> Git Repo - linux.git/log
linux.git
3 years agoMerge branch 'pci/host/cadence'
Bjorn Helgaas [Fri, 5 Nov 2021 16:28:49 +0000 (11:28 -0500)]
Merge branch 'pci/host/cadence'

- Disable PHY when j721e_pcie_probe() fails after initializing it
  (Christophe JAILLET)

- Return success when cdns-pcie probe succeeds instead of doing error
  cleanup (Li Chen)

* pci/host/cadence:
  PCI: cadence: Add cdns_plat_pcie_probe() missing return
  PCI: j721e: Fix j721e_pcie_probe() error path

3 years agoMerge branch 'pci/host/apple'
Bjorn Helgaas [Fri, 5 Nov 2021 16:28:48 +0000 (11:28 -0500)]
Merge branch 'pci/host/apple'

- Make of_phandle_args_to_fwspec() generally available (Marc Zyngier)

- Allow matching of interrupt-maps local to interrupt controller or PCI
  device (Marc Zyngier)

- Add Apple SoC (e.g., M1) PCIe host controller driver, which enables
  access to USB type-A, Ethernet, Wi-Fi, Bluetooth devices; these require
  additional drivers of their own (Alyssa Rosenzweig)

- Add apple INTx, per-port, and MSI interrupt support (Marc Zyngier)

- Configure apple Requester-ID-to-Stream-ID mapper for IOMMU (DART) support
  (Marc Zyngier)

* pci/host/apple:
  PCI: apple: Configure RID to SID mapper on device addition
  iommu/dart: Exclude MSI doorbell from PCIe device IOVA range
  PCI: apple: Implement MSI support
  PCI: apple: Add INTx and per-port interrupt support
  PCI: apple: Set up reference clocks when probing
  PCI: apple: Add initial hardware bring-up
  PCI: of: Allow matching of an interrupt-map local to a PCI device
  of/irq: Allow matching of an interrupt-map local to an interrupt controller
  irqdomain: Make of_phandle_args_to_fwspec() generally available

3 years agoMerge branch 'remotes/lorenzo/pci/aardvark'
Bjorn Helgaas [Fri, 5 Nov 2021 16:28:48 +0000 (11:28 -0500)]
Merge branch 'remotes/lorenzo/pci/aardvark'

- Define macros for PCI_EXP_DEVCTL_PAYLOAD_* (Pali Rohár)

- Set Max Payload Size to 512 bytes per Marvell spec (Pali Rohár)

- Downgrade PIO Response Status messages to debug level (Marek Behún)

- Preserve CRS SV (Config Request Retry Software Visibility) bit in
  emulated Root Control register (Pali Rohár)

- Fix issue in configuring reference clock (Pali Rohár)

- Don't clear status bits for masked interrupts (Pali Rohár)

- Don't mask unused interrupts (Pali Rohár)

- Avoid code repetition in advk_pcie_rd_conf() (Marek Behún)

- Retry config accesses on CRS response (Pali Rohár)

- Simplify emulated Root Capabilities initialization (Pali Rohár)

- Fix several link training issues (Pali Rohár)

- Fix link-up checking via LTSSM (Pali Rohár)

- Fix reporting of Data Link Layer Link Active (Pali Rohár)

- Fix emulation of W1C bits (Marek Behún)

- Fix MSI domain .alloc() method to return zero on success (Marek Behún)

- Read entire 16-bit MSI vector in MSI handler, not just low 8 bits (Marek
  Behún)

- Clear Root Port I/O Space, Memory Space, and Bus Master Enable bits at
  startup; PCI core will set those as necessary (Pali Rohár)

- When operating as a Root Port, set class code to "PCI Bridge" instead of
  the default "Mass Storage Controller" (Pali Rohár)

- Add emulation for PCI_BRIDGE_CTL_BUS_RESET since aardvark doesn't
  implement this per spec (Pali Rohár)

- Add emulation of option ROM BAR since aardvark doesn't implement this per
  spec (Pali Rohár)

* remotes/lorenzo/pci/aardvark:
  PCI: aardvark: Fix support for PCI_ROM_ADDRESS1 on emulated bridge
  PCI: aardvark: Fix support for PCI_BRIDGE_CTL_BUS_RESET on emulated bridge
  PCI: aardvark: Set PCI Bridge Class Code to PCI Bridge
  PCI: aardvark: Fix support for bus mastering and PCI_COMMAND on emulated bridge
  PCI: aardvark: Read all 16-bits from PCIE_MSI_PAYLOAD_REG
  PCI: aardvark: Fix return value of MSI domain .alloc() method
  PCI: pci-bridge-emul: Fix emulation of W1C bits
  PCI: aardvark: Fix reporting Data Link Layer Link Active
  PCI: aardvark: Fix checking for link up via LTSSM state
  PCI: aardvark: Fix link training
  PCI: aardvark: Simplify initialization of rootcap on virtual bridge
  PCI: aardvark: Implement re-issuing config requests on CRS response
  PCI: aardvark: Deduplicate code in advk_pcie_rd_conf()
  PCI: aardvark: Do not unmask unused interrupts
  PCI: aardvark: Do not clear status bits of masked interrupts
  PCI: aardvark: Fix configuring Reference clock
  PCI: aardvark: Fix preserving PCI_EXP_RTCTL_CRSSVE flag on emulated bridge
  PCI: aardvark: Don't spam about PIO Response Status
  PCI: aardvark: Fix PCIe Max Payload Size setting
  PCI: Add PCI_EXP_DEVCTL_PAYLOAD_* macros

3 years agoMerge branch 'pci/misc'
Bjorn Helgaas [Fri, 5 Nov 2021 16:28:47 +0000 (11:28 -0500)]
Merge branch 'pci/misc'

- Tidy setup-irq.c comments (Pranay Sanghai)

- Fix misspellings (Krzysztof Wilczyński)

- Fix sprintf(), sscanf() format mismatches (Krzysztof Wilczyński)

- Tidy cpqphp code formatting (Krzysztof Wilczyński)

- Remove unused pci_pool wrappers, which have been replaced by dma_pool
  (Cai Huoqing)

- Remove a redundant initialization in __pci_reset_function_locked() (Colin
  Ian King)

- Use 'unsigned int' instead of 'unsigned' (Krzysztof Wilczyński)

- Update PCI subsystem information in MAINTAINERS (Krzysztof Wilczyński)

- Include generic <linux/> headers instead of <asm/> for cpqphp and vmd
  (Krzysztof Wilczyński)

* pci/misc:
  PCI: vmd: Drop redundant includes of <asm/device.h>, <asm/msi.h>
  PCI: cpqphp: Use <linux/io.h> instead of <asm/io.h>
  MAINTAINERS: Update PCI subsystem information
  PCI: Prefer 'unsigned int' over bare 'unsigned'
  PCI: Remove redundant 'rc' initialization
  PCI: Remove unused pci_pool wrappers
  PCI: cpqphp: Format if-statement code block correctly
  PCI: Use unsigned to match sscanf("%x") in pci_dev_str_match_path()
  PCI: hv: Remove unnecessary use of %hx
  PCI: Correct misspelled and remove duplicated words
  PCI: Tidy comments

3 years agoMerge branch 'pci/vpd'
Bjorn Helgaas [Fri, 5 Nov 2021 16:28:47 +0000 (11:28 -0500)]
Merge branch 'pci/vpd'

- Add pci_read_vpd_any(), pci_write_vpd_any() to access VPD at arbitrary
  offsets (Heiner Kallweit)

- Use VPD API to replace custom code in cxgb3 driver (Heiner Kallweit)

* pci/vpd:
  cxgb3: Remove seeprom_write and use VPD API
  cxgb3: Use VPD API in t3_seeprom_wp()
  cxgb3: Remove t3_seeprom_read and use VPD API
  PCI/VPD: Use pci_read_vpd_any() in pci_vpd_size()
  PCI/VPD: Add pci_read/write_vpd_any()

3 years agoMerge branch 'pci/virtualization'
Bjorn Helgaas [Fri, 5 Nov 2021 16:28:46 +0000 (11:28 -0500)]
Merge branch 'pci/virtualization'

- Avoid bus resets on Atheros QCA6174, since they hang (Ingmar Klein)

- Use store and forward mode on Pericom PI7C9X2G switches to avoid ACS
  erratum with ACS P2P Request Redirect (Nathan Rossi)

* pci/virtualization:
  PCI: Add ACS quirk for Pericom PI7C9X2G switches
  PCI: Mark Atheros QCA6174 to avoid bus reset

3 years agoMerge branch 'pci/sysfs'
Bjorn Helgaas [Fri, 5 Nov 2021 16:28:46 +0000 (11:28 -0500)]
Merge branch 'pci/sysfs'

- Check for CAP_SYS_ADMIN before validating sysfs user input, not after
  (Krzysztof Wilczyński)

- Always return -EINVAL from sysfs "store" functions for invalid user input
  instead of -EINVAL sometimes and -ERANGE others (Krzysztof Wilczyński)

- Use kstrtobool() directly instead of the strtobool() wrapper (Krzysztof
  Wilczyński)

* pci/sysfs:
  PCI: Use kstrtobool() directly, sans strtobool() wrapper
  PCI/sysfs: Return -EINVAL consistently from "store" functions
  PCI/sysfs: Check CAP_SYS_ADMIN before parsing user input

# Conflicts:
# drivers/pci/iov.c

3 years agoMerge branch 'pci/switchtec'
Bjorn Helgaas [Fri, 5 Nov 2021 16:28:45 +0000 (11:28 -0500)]
Merge branch 'pci/switchtec'

- Return error to application when command execution fails because an
  out-of-band reset has cleared the device BARs, Memory Space Enable, etc
  (Kelvin Cao)

- Fix MRPC error status handling issue (Kelvin Cao)

- Mask out other bits when reading of management VEP instance ID (Kelvin
  Cao)

- Return EOPNOTSUPP instead of ENOTSUPP from sysfs show functions (Kelvin
  Cao)

- Add check of event support (Logan Gunthorpe)

* pci/switchtec:
  PCI/switchtec: Add check of event support
  PCI/switchtec: Replace ENOTSUPP with EOPNOTSUPP
  PCI/switchtec: Update the way of getting management VEP instance ID
  PCI/switchtec: Fix a MRPC error status handling issue
  PCI/switchtec: Error out MRPC execution when MMIO reads fail

3 years agoMerge branch 'pci/resource'
Bjorn Helgaas [Fri, 5 Nov 2021 16:28:45 +0000 (11:28 -0500)]
Merge branch 'pci/resource'

- Coalesce host bridge contiguous apertures to allow P2P bridge windows
  that span several contiguous host bridge apertures (Kai-Heng Feng)

* pci/resource:
  PCI: Coalesce host bridge contiguous apertures

3 years agoMerge branch 'pci/portdrv'
Bjorn Helgaas [Fri, 5 Nov 2021 16:28:45 +0000 (11:28 -0500)]
Merge branch 'pci/portdrv'

- Don't setup portdrv IRQs if there are no port drivers that use them, to
  conserve vectors and avoid spurious events (Jan Kiszka)

* pci/portdrv:
  PCI/portdrv: Do not setup up IRQs if there are no users

3 years agoMerge branch 'pci/p2pdma'
Bjorn Helgaas [Fri, 5 Nov 2021 16:28:44 +0000 (11:28 -0500)]
Merge branch 'pci/p2pdma'

- Apply bus offset correctly in DMA address calculation, which used the
  wrong sign before (Wang Lu)

* pci/p2pdma:
  PCI/P2PDMA: Apply bus offset correctly in DMA address calculation

3 years agoMerge branch 'pci/msi'
Bjorn Helgaas [Fri, 5 Nov 2021 16:28:44 +0000 (11:28 -0500)]
Merge branch 'pci/msi'

- Document sysfs "irq" attribute, which contains either the INTx IRQ (the
  intended behavior) or the first MSI IRQ (historical mistake retained for
  backwards compatibility) (Barry Song)

- Rework "irq" sysfs show function to explicitly fetch first MSI IRQ
  instead of depending on core to put it in dev->irq, to enable future core
  cleanup (Barry Song)

* pci/msi:
  PCI/sysfs: Explicitly show first MSI IRQ for 'irq'
  PCI: Document /sys/bus/pci/devices/.../irq

3 years agoMerge branch 'pci/hotplug'
Bjorn Helgaas [Fri, 5 Nov 2021 16:28:43 +0000 (11:28 -0500)]
Merge branch 'pci/hotplug'

- Ignore Link Down/Up caused by error-induced Hot Reset so endpoint driver
  can remain bound to device during error recovery (Lukas Wunner)

- Remove unused resume err_handler (Lukas Wunner)

- Remove unused pcie_port_bus_{,un}register() declarations (Lukas Wunner)

- Skip compiling err.c when CONFIG_PCIEAER not set (Lukas Wunner)

* pci/hotplug:
  PCI/ERR: Reduce compile time for CONFIG_PCIEAER=n
  PCI/portdrv: Remove unused pcie_port_bus_{,un}register() declarations
  PCI/portdrv: Remove unused resume err_handler
  PCI: pciehp: Ignore Link Down/Up caused by error-induced Hot Reset
  PCI/portdrv: Rename pm_iter() to pcie_port_device_iter()

3 years agoMerge branch 'pci/driver'
Bjorn Helgaas [Fri, 5 Nov 2021 16:28:43 +0000 (11:28 -0500)]
Merge branch 'pci/driver'

- Drop the struct pci_dev.driver pointer, which is redundant with the
  struct device.driver pointer (Uwe Kleine-König)

* pci/driver:
  PCI: Remove struct pci_dev->driver
  PCI: Use to_pci_driver() instead of pci_dev->driver
  x86/pci/probe_roms: Use to_pci_driver() instead of pci_dev->driver
  perf/x86/intel/uncore: Use to_pci_driver() instead of pci_dev->driver
  powerpc/eeh: Use to_pci_driver() instead of pci_dev->driver
  usb: xhci: Use to_pci_driver() instead of pci_dev->driver
  cxl: Use to_pci_driver() instead of pci_dev->driver
  cxl: Factor out common dev->driver expressions
  xen/pcifront: Use to_pci_driver() instead of pci_dev->driver
  xen/pcifront: Drop pcifront_common_process() tests of pcidev, pdrv
  nfp: use dev_driver_string() instead of pci_dev->driver->name
  mlxsw: pci: Use dev_driver_string() instead of pci_dev->driver->name
  net: marvell: prestera: use dev_driver_string() instead of pci_dev->driver->name
  net: hns3: use dev_driver_string() instead of pci_dev->driver->name
  crypto: hisilicon - use dev_driver_string() instead of pci_dev->driver->name
  powerpc/eeh: Use dev_driver_string() instead of struct pci_dev->driver->name
  ssb: Use dev_driver_string() instead of pci_dev->driver->name
  bcma: simplify reference to driver name
  crypto: qat - simplify adf_enable_aer()
  scsi: message: fusion: Remove unused mpt_pci driver .probe() 'id' parameter
  PCI/ERR: Factor out common dev->driver expressions
  PCI: Drop pci_device_probe() test of !pci_dev->driver
  PCI: Drop pci_device_remove() test of pci_dev->driver
  PCI: Return NULL for to_pci_driver(NULL)

3 years agoMerge branch 'pci/enumeration'
Bjorn Helgaas [Fri, 5 Nov 2021 16:28:42 +0000 (11:28 -0500)]
Merge branch 'pci/enumeration'

- Rename pcibios_add_device() to pcibios_device_add() since it's called
  from pci_device_add() (Oliver O'Halloran)

- Don't try to enable AtomicOps on VFs, since they can only be enabled on
  the PF (Selvin Xavier)

* pci/enumeration:
  PCI: Do not enable AtomicOps on VFs
  PCI: Rename pcibios_add_device() to pcibios_device_add()

3 years agoMerge branch 'pci/aspm'
Bjorn Helgaas [Fri, 5 Nov 2021 16:28:42 +0000 (11:28 -0500)]
Merge branch 'pci/aspm'

- Re-enable LTR in Downstream Ports after it has been disabled by reset or
  hotplug to allow use of ASPM L1.2 again and prevent Unsupported Request
  errors when Endpoint sends LTR messages (Mingchuang Qiao)

* pci/aspm:
  PCI: Re-enable Downstream Port LTR after reset or hotplug

3 years agoMerge branch 'pci/acpi'
Bjorn Helgaas [Fri, 5 Nov 2021 16:28:42 +0000 (11:28 -0500)]
Merge branch 'pci/acpi'

- Simplify _OSC negotiation with platform for control of PCIe features
  (Joerg Roedel)

* pci/acpi:
  PCI/ACPI: Check for _OSC support in acpi_pci_osc_control_set()
  PCI/ACPI: Move _OSC query checks to separate function
  PCI/ACPI: Move supported and control calculations to separate functions
  PCI/ACPI: Remove OSC_PCI_SUPPORT_MASKS and OSC_PCI_CONTROL_MASKS

3 years agoPCI: Add ACS quirk for Pericom PI7C9X2G switches
Nathan Rossi [Fri, 10 Sep 2021 02:58:23 +0000 (02:58 +0000)]
PCI: Add ACS quirk for Pericom PI7C9X2G switches

The Pericom PI7C9X2G404/PI7C9X2G304/PI7C9X2G303 PCIe switches have an
erratum for ACS P2P Request Redirect behaviour when used in the cut-through
forwarding mode. The recommended work around for this issue is to use the
switch in store and forward mode. The erratum results in packets being
queued and not being delivered upstream, which can be observed as very poor
downstream device performance and/or dropped device-generated
data/interrupts.

Add a fixup so that when enabling or resuming the downstream port we check
if it has enabled ACS P2P Request Redirect, and if so, change the device
(via the upstream port) to use the store and forward operating mode.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=177471
Link: https://lore.kernel.org/r/[email protected]
Tested-by: Alex Williamson <[email protected]>
Signed-off-by: Nathan Rossi <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agoPCI: apple: Configure RID to SID mapper on device addition
Marc Zyngier [Wed, 29 Sep 2021 16:38:42 +0000 (17:38 +0100)]
PCI: apple: Configure RID to SID mapper on device addition

The Apple PCIe controller doesn't directly feed the endpoint's Requester ID
to the IOMMU (DART), but instead maps RIDs onto Stream IDs (SIDs). The DART
and the PCIe controller must thus agree on the SIDs that are used for
translation (by using the 'iommu-map' property).

For this purpose, parse the 'iommu-map' property each time a device gets
added, and use the resulting translation to configure the PCIe RID-to-SID
mapper. Similarly, remove the translation if/when the device gets removed.

This is all driven from a bus notifier which gets registered at probe time.
Hopefully this is the only PCI controller driver in the whole system.

[bhelgaas: squash indentation from Zhaoyu Liu <[email protected]>:
https://lore.kernel.org/r/20211031135544.GA1616@pc]
Link: https://lore.kernel.org/r/[email protected]
Tested-by: Alyssa Rosenzweig <[email protected]>
Signed-off-by: Marc Zyngier <[email protected]>
Signed-off-by: Lorenzo Pieralisi <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Reviewed-by: Sven Peter <[email protected]>
3 years agoiommu/dart: Exclude MSI doorbell from PCIe device IOVA range
Marc Zyngier [Wed, 29 Sep 2021 16:38:41 +0000 (17:38 +0100)]
iommu/dart: Exclude MSI doorbell from PCIe device IOVA range

The MSI doorbell on Apple HW can be any address in the low 4GB range.
However, the MSI write is matched by the PCIe block before hitting the
iommu. It must thus be excluded from the IOVA range that is assigned to any
PCIe device.

Link: https://lore.kernel.org/r/[email protected]
Tested-by: Alyssa Rosenzweig <[email protected]>
Signed-off-by: Marc Zyngier <[email protected]>
Signed-off-by: Lorenzo Pieralisi <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Reviewed-by: Sven Peter <[email protected]>
3 years agoPCI: apple: Implement MSI support
Marc Zyngier [Wed, 29 Sep 2021 16:38:40 +0000 (17:38 +0100)]
PCI: apple: Implement MSI support

Probe for the 'msi-ranges' property, and implement the MSI support in the
form of the usual two-level hierarchy.

Note that contrary to the wired interrupts, MSIs are shared among all the
ports.

Link: https://lore.kernel.org/r/[email protected]
Tested-by: Alyssa Rosenzweig <[email protected]>
Signed-off-by: Marc Zyngier <[email protected]>
Signed-off-by: Lorenzo Pieralisi <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agoPCI: apple: Add INTx and per-port interrupt support
Marc Zyngier [Wed, 29 Sep 2021 16:38:39 +0000 (17:38 +0100)]
PCI: apple: Add INTx and per-port interrupt support

Add support for the per-port interrupt controller that deals with both INTx
signalling and management interrupts.

This allows the Link-up/Link-down interrupts to be wired, allowing the
bring-up to be synchronised (and provide debug information).  The framework
can further be used to handle the rest of the per port events if and when
necessary.

Likewise, INTx signalling is implemented so that end-points can actually be
used.

Link: https://lore.kernel.org/r/[email protected]
Link: https://lore.kernel.org/r/[email protected]
Tested-by: Alyssa Rosenzweig <[email protected]>
Signed-off-by: Marc Zyngier <[email protected]>
Signed-off-by: Lorenzo Pieralisi <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agoPCI: apple: Set up reference clocks when probing
Alyssa Rosenzweig [Wed, 29 Sep 2021 16:38:38 +0000 (17:38 +0100)]
PCI: apple: Set up reference clocks when probing

Apple's PCIe controller requires clocks to be configured in order to
bring up the hardware. Add the register pokes required to do so.

Adapted from Corellium's driver via Mark Kettenis's U-Boot patches.

Co-developed-by: Stan Skowronek <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Stan Skowronek <[email protected]>
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Signed-off-by: Marc Zyngier <[email protected]>
Signed-off-by: Lorenzo Pieralisi <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agoPCI: apple: Add initial hardware bring-up
Alyssa Rosenzweig [Wed, 29 Sep 2021 16:38:37 +0000 (17:38 +0100)]
PCI: apple: Add initial hardware bring-up

Add a minimal driver to bring up the PCIe bus on Apple system-on-chips,
particularly the Apple M1. This driver exposes the internal bus used for
the USB type-A ports, Ethernet, Wi-Fi, and Bluetooth. Bringing up the
radios requires additional drivers beyond what's necessary for PCIe itself.

Co-developed-by: Stan Skowronek <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Stan Skowronek <[email protected]>
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Signed-off-by: Marc Zyngier <[email protected]>
Signed-off-by: Lorenzo Pieralisi <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Reviewed-by: Rob Herring <[email protected]>
Reviewed-by: Sven Peter <[email protected]>
3 years agoPCI: of: Allow matching of an interrupt-map local to a PCI device
Marc Zyngier [Wed, 29 Sep 2021 16:38:36 +0000 (17:38 +0100)]
PCI: of: Allow matching of an interrupt-map local to a PCI device

Just as we now allow an interrupt map to be parsed when part of an
interrupt controller, there is no reason to ignore an interrupt map that
would be part of a pci device node such as a root port since we already
allow interrupt specifiers.

Allow the matching of such property when local to the node of a PCI
device, which allows the device itself to use the interrupt map for for
its own purpose.

Link: https://lore.kernel.org/r/[email protected]
Tested-by: Alyssa Rosenzweig <[email protected]>
Signed-off-by: Marc Zyngier <[email protected]>
Signed-off-by: Lorenzo Pieralisi <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Reviewed-by: Rob Herring <[email protected]>
3 years agoof/irq: Allow matching of an interrupt-map local to an interrupt controller
Marc Zyngier [Wed, 29 Sep 2021 16:38:35 +0000 (17:38 +0100)]
of/irq: Allow matching of an interrupt-map local to an interrupt controller

of_irq_parse_raw() has a baked assumption that if a node has an
interrupt-controller property, it cannot possibly also have an
interrupt-map property (the latter being ignored).

This seems to be an odd behaviour, and there is no reason why we should
avoid supporting this use case. This is specially useful when a PCI root
port acts as an interrupt controller for PCI endpoints, such as this:

  pcie0: pcie@690000000 {
      [...]
      port00: pci@0,0 {
  device_type = "pci";
  [...]
  #address-cells = <3>;

  interrupt-controller;
  #interrupt-cells = <1>;

  interrupt-map-mask = <0 0 0 7>;
  interrupt-map = <0 0 0 1 &port00 0 0 0 0>,
  <0 0 0 2 &port00 0 0 0 1>,
  <0 0 0 3 &port00 0 0 0 2>,
  <0 0 0 4 &port00 0 0 0 3>;
      };
  };

Handle it by detecting that we have an interrupt-map early in the parsing,
and special case the situation where the phandle in the interrupt map
refers to the current node (which is the interesting case here).

Link: https://lore.kernel.org/r/[email protected]
Tested-by: Alyssa Rosenzweig <[email protected]>
Signed-off-by: Marc Zyngier <[email protected]>
Signed-off-by: Lorenzo Pieralisi <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Reviewed-by: Rob Herring <[email protected]>
3 years agoirqdomain: Make of_phandle_args_to_fwspec() generally available
Marc Zyngier [Wed, 29 Sep 2021 16:38:34 +0000 (17:38 +0100)]
irqdomain: Make of_phandle_args_to_fwspec() generally available

of_phandle_args_to_fwspec() can be generally useful to code extracting a DT
of_phandle and using an irq_fwspec to use the hierarchical irqdomain API.

Make it visible to the rest of the kernel, including modules.

Link: https://lore.kernel.org/r/[email protected]
Tested-by: Alyssa Rosenzweig <[email protected]>
Signed-off-by: Marc Zyngier <[email protected]>
Signed-off-by: Lorenzo Pieralisi <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agoPCI: Do not enable AtomicOps on VFs
Selvin Xavier [Sat, 11 Sep 2021 10:03:05 +0000 (03:03 -0700)]
PCI: Do not enable AtomicOps on VFs

Host crashes when pci_enable_atomic_ops_to_root() is called for VFs with
virtual buses. The virtual buses added to SR-IOV have bus->self set to NULL
and host crashes due to this.

  PID: 4481   TASK: ffff89c6941b0000  CPU: 53  COMMAND: "bash"
  ...
   #3 [ffff9a9481713808] oops_end at ffffffffb9025cd6
   #4 [ffff9a9481713828] page_fault_oops at ffffffffb906e417
   #5 [ffff9a9481713888] exc_page_fault at ffffffffb9a0ad14
   #6 [ffff9a94817138b0] asm_exc_page_fault at ffffffffb9c00ace
      [exception RIP: pcie_capability_read_dword+28]
      RIP: ffffffffb952fd5c  RSP: ffff9a9481713960  RFLAGS: 00010246
      RAX: 0000000000000001  RBX: ffff89c6b1096000  RCX: 0000000000000000
      RDX: ffff9a9481713990  RSI: 0000000000000024  RDI: 0000000000000000
      RBP: 0000000000000080   R8: 0000000000000008   R9: ffff89c64341a2f8
      R10: 0000000000000002  R11: 0000000000000000  R12: ffff89c648bab000
      R13: 0000000000000000  R14: 0000000000000000  R15: ffff89c648bab0c8
      ORIG_RAX: ffffffffffffffff  CS: 0010  SS: 0018
   #7 [ffff9a9481713988] pci_enable_atomic_ops_to_root at ffffffffb95359a6
   #8 [ffff9a94817139c0] bnxt_qplib_determine_atomics at ffffffffc08c1a33 [bnxt_re]
   #9 [ffff9a94817139d0] bnxt_re_dev_init at ffffffffc08ba2d1 [bnxt_re]

Per PCIe r5.0, sec 9.3.5.10, the AtomicOp Requester Enable bit in Device
Control 2 is reserved for VFs.  The PF value applies to all associated VFs.

Return -EINVAL if pci_enable_atomic_ops_to_root() is called for a VF.

Link: https://lore.kernel.org/r/[email protected]
Fixes: 35f5ace5dea4 ("RDMA/bnxt_re: Enable global atomic ops if platform supports")
Fixes: 430a23689dea ("PCI: Add pci_enable_atomic_ops_to_root()")
Signed-off-by: Selvin Xavier <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Reviewed-by: Andy Gospodarek <[email protected]>
3 years agoPCI: vmd: Drop redundant includes of <asm/device.h>, <asm/msi.h>
Krzysztof Wilczyński [Wed, 13 Oct 2021 00:31:44 +0000 (00:31 +0000)]
PCI: vmd: Drop redundant includes of <asm/device.h>, <asm/msi.h>

We already include <linux/device.h> and <linux/msi.h>, which
include <asm/device.h> and <asm/msi.h>.

Drop the redundant includes of <asm/device.h> and <asm/msi.h>.

[bhelgaas: squash in fix from Wan Jiabing <[email protected]>:
https://lore.kernel.org/r/20211104063720[email protected]]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Krzysztof Wilczyński <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Reviewed-by: Jonathan Derrick <[email protected]>
3 years agoPCI: cadence: Add cdns_plat_pcie_probe() missing return
Li Chen [Thu, 21 Oct 2021 02:50:19 +0000 (02:50 +0000)]
PCI: cadence: Add cdns_plat_pcie_probe() missing return

When cdns_plat_pcie_probe() succeeds, return success instead of falling
into the error handling code.

Fixes: bd22885aa188 ("PCI: cadence: Refactor driver to use as a core library")
Link: https://lore.kernel.org/r/DM6PR19MB40271B93057D949310F0B0EDA0BF9@DM6PR19MB4027.namprd19.prod.outlook.com
Signed-off-by: Xuliang Zhang <[email protected]>
Signed-off-by: Li Chen <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Reviewed-by: Bjorn Helgaas <[email protected]>
Cc: [email protected]
3 years agoPCI: j721e: Fix j721e_pcie_probe() error path
Christophe JAILLET [Sun, 27 Jun 2021 11:46:24 +0000 (13:46 +0200)]
PCI: j721e: Fix j721e_pcie_probe() error path

If an error occurs after a successful cdns_pcie_init_phy() call, it must be
undone by a cdns_pcie_disable_phy() call, as already done above and below.

Update the goto to branch at the correct place of the error handling path.

Link: https://lore.kernel.org/r/db477b0cb444891a17c4bb424467667dc30d0bab.1624794264.git.christophe.jaillet@wanadoo.fr
Fixes: 49e0efdce791 ("PCI: j721e: Add support to provide refclk to PCIe connector")
Signed-off-by: Christophe JAILLET <[email protected]>
Signed-off-by: Lorenzo Pieralisi <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Reviewed-by: Krzysztof Wilczyński <[email protected]>
3 years agoPCI: cpqphp: Use <linux/io.h> instead of <asm/io.h>
Krzysztof Wilczyński [Wed, 13 Oct 2021 00:31:45 +0000 (00:31 +0000)]
PCI: cpqphp: Use <linux/io.h> instead of <asm/io.h>

Use the preferred generic header file linux/io.h that already includes the
corresponding asm/io.h file.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Krzysztof Wilczyński <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Reviewed-by: Jonathan Derrick <[email protected]>
3 years agoPCI: aardvark: Fix support for PCI_ROM_ADDRESS1 on emulated bridge
Pali Rohár [Thu, 28 Oct 2021 18:56:59 +0000 (20:56 +0200)]
PCI: aardvark: Fix support for PCI_ROM_ADDRESS1 on emulated bridge

This register is exported at address offset 0x30.

Link: https://lore.kernel.org/r/[email protected]
Fixes: 8a3ebd8de328 ("PCI: aardvark: Implement emulated root PCI bridge config space")
Signed-off-by: Pali Rohár <[email protected]>
Signed-off-by: Marek Behún <[email protected]>
Signed-off-by: Lorenzo Pieralisi <[email protected]>
Cc: [email protected]
3 years agoPCI: aardvark: Fix support for PCI_BRIDGE_CTL_BUS_RESET on emulated bridge
Pali Rohár [Thu, 28 Oct 2021 18:56:58 +0000 (20:56 +0200)]
PCI: aardvark: Fix support for PCI_BRIDGE_CTL_BUS_RESET on emulated bridge

Aardvark supports PCIe Hot Reset via PCIE_CORE_CTRL1_REG.

Use it for implementing PCI_BRIDGE_CTL_BUS_RESET bit of PCI_BRIDGE_CONTROL
register on emulated bridge.

With this, the function pci_reset_secondary_bus() starts working and can
reset connected PCIe card. Custom userspace script [1] which uses setpci
can trigger PCIe Hot Reset and reset the card manually.

[1] https://alexforencich.com/wiki/en/pcie/hot-reset-linux

Link: https://lore.kernel.org/r/[email protected]
Fixes: 8a3ebd8de328 ("PCI: aardvark: Implement emulated root PCI bridge config space")
Signed-off-by: Pali Rohár <[email protected]>
Signed-off-by: Marek Behún <[email protected]>
Signed-off-by: Lorenzo Pieralisi <[email protected]>
Cc: [email protected]
3 years agoPCI: aardvark: Set PCI Bridge Class Code to PCI Bridge
Pali Rohár [Thu, 28 Oct 2021 18:56:57 +0000 (20:56 +0200)]
PCI: aardvark: Set PCI Bridge Class Code to PCI Bridge

Aardvark controller has something like config space of a Root Port
available at offset 0x0 of internal registers - these registers are used
for implementation of the emulated bridge.

The default value of Class Code of this bridge corresponds to a RAID Mass
storage controller, though. (This is probably intended for when the
controller is used as Endpoint.)

Change the Class Code to correspond to a PCI Bridge.

Add comment explaining this change.

Link: https://lore.kernel.org/r/[email protected]
Fixes: 8a3ebd8de328 ("PCI: aardvark: Implement emulated root PCI bridge config space")
Signed-off-by: Pali Rohár <[email protected]>
Signed-off-by: Marek Behún <[email protected]>
Signed-off-by: Lorenzo Pieralisi <[email protected]>
Cc: [email protected]
3 years agoPCI: aardvark: Fix support for bus mastering and PCI_COMMAND on emulated bridge
Pali Rohár [Thu, 28 Oct 2021 18:56:56 +0000 (20:56 +0200)]
PCI: aardvark: Fix support for bus mastering and PCI_COMMAND on emulated bridge

From very vague, ambiguous and incomplete information from Marvell we
deduced that the 32-bit Aardvark register at address 0x4
(PCIE_CORE_CMD_STATUS_REG), which is not documented for Root Complex mode
in the Functional Specification (only for Endpoint mode), controls two
16-bit PCIe registers: Command Register and Status Registers of PCIe Root
Port.

This means that bit 2 controls bus mastering and forwarding of memory and
I/O requests in the upstream direction. 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 setup of the Aardvark
driver.

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

Link: https://lore.kernel.org/r/[email protected]
Fixes: 8a3ebd8de328 ("PCI: aardvark: Implement emulated root PCI bridge config space")
Signed-off-by: Pali Rohár <[email protected]>
Signed-off-by: Marek Behún <[email protected]>
Signed-off-by: Lorenzo Pieralisi <[email protected]>
Cc: [email protected] # b2a56469d550 ("PCI: aardvark: Add FIXME comment for PCIE_CORE_CMD_STATUS_REG access")
3 years agoPCI: aardvark: Read all 16-bits from PCIE_MSI_PAYLOAD_REG
Marek Behún [Thu, 28 Oct 2021 18:56:55 +0000 (20:56 +0200)]
PCI: aardvark: Read all 16-bits from PCIE_MSI_PAYLOAD_REG

The PCIE_MSI_PAYLOAD_REG contains 16-bit MSI number, not only lower
8 bits. Fix reading content of this register and add a comment
describing the access to this register.

Link: https://lore.kernel.org/r/[email protected]
Fixes: 8c39d710363c ("PCI: aardvark: Add Aardvark PCI host controller driver")
Signed-off-by: Pali Rohár <[email protected]>
Signed-off-by: Marek Behún <[email protected]>
Signed-off-by: Lorenzo Pieralisi <[email protected]>
Cc: [email protected]
3 years agoPCI: aardvark: Fix return value of MSI domain .alloc() method
Marek Behún [Thu, 28 Oct 2021 18:56:54 +0000 (20:56 +0200)]
PCI: aardvark: Fix return value of MSI domain .alloc() method

MSI domain callback .alloc() (implemented by advk_msi_irq_domain_alloc()
function) should return zero on success, since non-zero value indicates
failure.

When the driver was converted to generic MSI API in commit f21a8b1b6837
("PCI: aardvark: Move to MSI handling using generic MSI support"), it
was converted so that it returns hwirq number.

Fix this.

Link: https://lore.kernel.org/r/[email protected]
Fixes: f21a8b1b6837 ("PCI: aardvark: Move to MSI handling using generic MSI support")
Signed-off-by: Pali Rohár <[email protected]>
Signed-off-by: Marek Behún <[email protected]>
Signed-off-by: Lorenzo Pieralisi <[email protected]>
Cc: [email protected]
3 years agoPCI: pci-bridge-emul: Fix emulation of W1C bits
Marek Behún [Thu, 28 Oct 2021 18:56:53 +0000 (20:56 +0200)]
PCI: pci-bridge-emul: Fix emulation of W1C bits

The pci_bridge_emul_conf_write() function correctly clears W1C bits in
cfgspace cache, but it does not inform the underlying implementation
about the clear request: the .write_op() method is given the value with
these bits cleared.

This is wrong if the .write_op() needs to know which bits were requested
to be cleared.

Fix the value to be passed into the .write_op() method to have requested
W1C bits set, so that it can clear them.

Both pci-bridge-emul users (mvebu and aardvark) are compatible with this
change.

Link: https://lore.kernel.org/r/[email protected]
Fixes: 23a5fba4d941 ("PCI: Introduce PCI bridge emulated config space common logic")
Signed-off-by: Pali Rohár <[email protected]>
Signed-off-by: Marek Behún <[email protected]>
Signed-off-by: Lorenzo Pieralisi <[email protected]>
Cc: [email protected]
Cc: Russell King <[email protected]>
3 years agoMAINTAINERS: Update PCI subsystem information
Krzysztof Wilczyński [Wed, 27 Oct 2021 10:50:41 +0000 (10:50 +0000)]
MAINTAINERS: Update PCI subsystem information

Update the following information related to the PCI subsystem which
includes the PCI drivers, PCI native host bridge and endpoint drivers,
and the PCI endpoint sub-system:

 - Sort fields as per preferred order
 - Sort files in the alphabetical order
 - Update old Patchwork URLs
 - Update Git repository for the PCI endpoint subsystem
 - Add Bugzilla link
 - Add link to the official IRC channel
 - Add files "drivers/pci/pci-bridge-emul.{c,h}" to the right
   section so that proper ownership is returned for both files
   from the get_maintainer.pl script

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Krzysztof Wilczyński <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agoPCI: Prefer 'unsigned int' over bare 'unsigned'
Krzysztof Wilczyński [Wed, 13 Oct 2021 01:41:36 +0000 (01:41 +0000)]
PCI: Prefer 'unsigned int' over bare 'unsigned'

The bare "unsigned" type implicitly means "unsigned int", but the preferred
coding style is to use the complete type name.

Update the bare use of "unsigned" to the preferred "unsigned int".

No change to functionality intended.

See a1ce18e4f941 ("checkpatch: warn on bare unsigned or signed declarations
without int").

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Krzysztof Wilczyński <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agoPCI: Remove redundant 'rc' initialization
Colin Ian King [Fri, 10 Sep 2021 16:14:17 +0000 (17:14 +0100)]
PCI: Remove redundant 'rc' initialization

The variable 'rc' is being initialized with a value that is never read.
Remove the redundant assignment.

Addresses-Coverity: ("Unused value")
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Colin Ian King <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Reviewed-by: Krzysztof Wilczyński <[email protected]>
3 years agocxgb3: Remove seeprom_write and use VPD API
Heiner Kallweit [Fri, 10 Sep 2021 06:27:08 +0000 (08:27 +0200)]
cxgb3: Remove seeprom_write and use VPD API

Using the VPD API allows to simplify the code and completely get
rid of t3_seeprom_write().

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Heiner Kallweit <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Acked-by: Jakub Kicinski <[email protected]>
3 years agocxgb3: Use VPD API in t3_seeprom_wp()
Heiner Kallweit [Fri, 10 Sep 2021 06:25:49 +0000 (08:25 +0200)]
cxgb3: Use VPD API in t3_seeprom_wp()

Use standard VPD API to replace t3_seeprom_write(), this prepares for
removing this function. Chelsio T3 maps the EEPROM write protect flag
to an arbitrary place in VPD address space, therefore we have to use
pci_write_vpd_any().

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Heiner Kallweit <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Acked-by: Jakub Kicinski <[email protected]>
3 years agocxgb3: Remove t3_seeprom_read and use VPD API
Heiner Kallweit [Fri, 10 Sep 2021 06:24:07 +0000 (08:24 +0200)]
cxgb3: Remove t3_seeprom_read and use VPD API

Using the VPD API allows to simplify the code and completely get rid
of t3_seeprom_read(). Note that we don't have to use pci_read_vpd_any()
here because a VPD quirk sets dev->vpd.len to the full EEPROM size.

Tested with a T320 card.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Heiner Kallweit <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Acked-by: Jakub Kicinski <[email protected]>
3 years agoPCI/VPD: Use pci_read_vpd_any() in pci_vpd_size()
Heiner Kallweit [Fri, 10 Sep 2021 06:22:49 +0000 (08:22 +0200)]
PCI/VPD: Use pci_read_vpd_any() in pci_vpd_size()

Use new function pci_read_vpd_any() to simplify the code.

[bhelgaas: squash in fix for stack overflow reported & tested by
Qian [1] and Kunihiko [2]:
[1] https://lore.kernel.org/netdev/e89087c5-c495-c5ca-feb1-54cf3a8775c5@quicinc.com/
[2] https://lore.kernel.org/r/2f7e3770-ab47-42b5-719c-f7c661c07d28@socionext.com
Link: https://lore.kernel.org/r/[email protected]
Reported-by: Qian Cai <[email protected]>
Tested-by: Qian Cai <[email protected]>
Reported-by: Kunihiko Hayashi <[email protected]>
Tested-by: Kunihiko Hayashi <[email protected]>
]

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Heiner Kallweit <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Acked-by: Jakub Kicinski <[email protected]>
3 years agoPCI: Re-enable Downstream Port LTR after reset or hotplug
Mingchuang Qiao [Tue, 12 Oct 2021 07:56:14 +0000 (15:56 +0800)]
PCI: Re-enable Downstream Port LTR after reset or hotplug

Per PCIe r5.0, sec 7.5.3.16, Downstream Ports must disable LTR if the link
goes down (the Port goes DL_Down status).  This is a problem because the
Downstream Port's dev->ltr_path is still set, so we think LTR is still
enabled, and we enable LTR in the Endpoint.  When it sends LTR messages,
they cause Unsupported Request errors at the Downstream Port.

This happens in the reset path, where we may enable LTR in
pci_restore_pcie_state() even though the Downstream Port disabled LTR
because the reset caused a link down event.

It also happens in the hot-remove and hot-add path, where we may enable LTR
in pci_configure_ltr() even though the Downstream Port disabled LTR when
the hot-remove took the link down.

In these two scenarios, check the upstream bridge and restore its LTR
enable if appropriate.

The Unsupported Request may be logged by AER as follows:

  pcieport 0000:00:1d.0: AER: Uncorrected (Non-Fatal) error received: id=00e8
  pcieport 0000:00:1d.0: PCIe Bus Error: severity=Uncorrected (Non-Fatal), type=Transaction Layer, id=00e8(Requester ID)
  pcieport 0000:00:1d.0:   device [8086:9d18] error status/mask=00100000/00010000
  pcieport 0000:00:1d.0:    [20] Unsupported Request    (First)

In addition, if LTR is not configured correctly, the link cannot enter the
L1.2 state, which prevents some machines from entering the S0ix low power
state.

[bhelgaas: commit log]
Link: https://lore.kernel.org/r/[email protected]
Reported-by: Utkarsh H Patel <[email protected]>
Signed-off-by: Mingchuang Qiao <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Reviewed-by: Mika Westerberg <[email protected]>
3 years agoPCI/sysfs: Explicitly show first MSI IRQ for 'irq'
Barry Song [Wed, 25 Aug 2021 10:26:35 +0000 (18:26 +0800)]
PCI/sysfs: Explicitly show first MSI IRQ for 'irq'

The sysfs "irq" file contains the legacy INTx IRQ.  Or, if the device has
MSI enabled, it contains the first MSI IRQ instead.

Previously this file showed the pci_dev.irq value directly.  But we'd
prefer to use pci_dev.irq only for the INTx IRQ and decouple that from any
MSI or MSI-X IRQs.

If the device has MSI enabled, explicitly look up and show the first MSI
IRQ in the sysfs "irq" file.  Otherwise, show the INTx IRQ.

This removes the requirement that msi_capability_init() set pci_dev.irq to
the first MSI IRQ when enabling MSI and pci_msi_shutdown() restore the INTx
IRQ when disabling MSI.

[bhelgaas: commit log]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Barry Song <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agoPCI: Document /sys/bus/pci/devices/.../irq
Barry Song [Wed, 25 Aug 2021 10:26:34 +0000 (18:26 +0800)]
PCI: Document /sys/bus/pci/devices/.../irq

Document /sys/bus/pci/devices/.../irq.

This file contains the IRQ of the INTx interrupt (or zero if the device
doesn't support INTx interrupts).

If the device has enabled MSI (not MSI-X), it contains the first MSI IRQ
instead.  This is a historical mistake because devices may support several
MSI or MSI-X vectors, and this file can't contain them all.  But we
preserve this behavior to avoid breaking userspace.

[bhelgaas: commit log]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Barry Song <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Acked-by: Greg Kroah-Hartman <[email protected]>
3 years agoPCI: Remove unused pci_pool wrappers
Cai Huoqing [Mon, 18 Oct 2021 12:41:09 +0000 (20:41 +0800)]
PCI: Remove unused pci_pool wrappers

The pci_pool users have been converted to dma_pool.  Remove the unused
pci_pool wrappers.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Cai Huoqing <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agoPCI: Remove struct pci_dev->driver
Uwe Kleine-König [Mon, 4 Oct 2021 12:59:35 +0000 (14:59 +0200)]
PCI: Remove struct pci_dev->driver

There are no remaining uses of the struct pci_dev->driver pointer, so
remove it.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Uwe Kleine-König <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agoPCI: Use to_pci_driver() instead of pci_dev->driver
Uwe Kleine-König [Tue, 12 Oct 2021 21:11:24 +0000 (16:11 -0500)]
PCI: Use to_pci_driver() instead of pci_dev->driver

Struct pci_driver contains a struct device_driver, so for PCI devices, it's
easy to convert a device_driver * to a pci_driver * with to_pci_driver().
The device_driver * is in struct device, so we don't need to also keep
track of the pci_driver * in struct pci_dev.

Replace pci_dev->driver with to_pci_driver().  This is a step toward
removing pci_dev->driver.

[bhelgaas: split to separate patch]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Uwe Kleine-König <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agox86/pci/probe_roms: Use to_pci_driver() instead of pci_dev->driver
Uwe Kleine-König [Tue, 12 Oct 2021 21:05:47 +0000 (16:05 -0500)]
x86/pci/probe_roms: Use to_pci_driver() instead of pci_dev->driver

Struct pci_driver contains a struct device_driver, so for PCI devices, it's
easy to convert a device_driver * to a pci_driver * with to_pci_driver().
The device_driver * is in struct device, so we don't need to also keep
track of the pci_driver * in struct pci_dev.

Replace pdev->driver with to_pci_driver().  This is a step toward removing
pci_dev->driver.

[bhelgaas: split to separate patch]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Uwe Kleine-König <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agoperf/x86/intel/uncore: Use to_pci_driver() instead of pci_dev->driver
Uwe Kleine-König [Tue, 12 Oct 2021 21:38:32 +0000 (16:38 -0500)]
perf/x86/intel/uncore: Use to_pci_driver() instead of pci_dev->driver

Struct pci_driver contains a struct device_driver, so for PCI devices, it's
easy to convert a device_driver * to a pci_driver * with to_pci_driver().
The device_driver * is in struct device, so we don't need to also keep
track of the pci_driver * in struct pci_dev.

Replace pdev->driver with to_pci_driver().  This is a step toward removing
pci_dev->driver.

[bhelgaas: split to separate patch]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Uwe Kleine-König <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agopowerpc/eeh: Use to_pci_driver() instead of pci_dev->driver
Uwe Kleine-König [Tue, 12 Oct 2021 21:37:55 +0000 (16:37 -0500)]
powerpc/eeh: Use to_pci_driver() instead of pci_dev->driver

Struct pci_driver contains a struct device_driver, so for PCI devices, it's
easy to convert a device_driver * to a pci_driver * with to_pci_driver().
The device_driver * is in struct device, so we don't need to also keep
track of the pci_driver * in struct pci_dev.

Replace pdev->driver with to_pci_driver().  This is a step toward removing
pci_dev->driver.

[bhelgaas: split to separate patch]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Uwe Kleine-König <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agousb: xhci: Use to_pci_driver() instead of pci_dev->driver
Uwe Kleine-König [Tue, 12 Oct 2021 21:36:05 +0000 (16:36 -0500)]
usb: xhci: Use to_pci_driver() instead of pci_dev->driver

Struct pci_driver contains a struct device_driver, so for PCI devices, it's
easy to convert a device_driver * to a pci_driver * with to_pci_driver().
The device_driver * is in struct device, so we don't need to also keep
track of the pci_driver * in struct pci_dev.

Replace pdev->driver with to_pci_driver().  This is a step toward removing
pci_dev->driver.

[bhelgaas: split to separate patch]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Uwe Kleine-König <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agocxl: Use to_pci_driver() instead of pci_dev->driver
Uwe Kleine-König [Tue, 12 Oct 2021 21:03:39 +0000 (16:03 -0500)]
cxl: Use to_pci_driver() instead of pci_dev->driver

Struct pci_driver contains a struct device_driver, so for PCI devices, it's
easy to convert a device_driver * to a pci_driver * with to_pci_driver().
The device_driver * is in struct device, so we don't need to also keep
track of the pci_driver * in struct pci_dev.

Replace pdev->driver with to_pci_driver().  This is a step toward removing
pci_dev->driver.

[bhelgaas: split to separate patch]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Uwe Kleine-König <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agocxl: Factor out common dev->driver expressions
Bjorn Helgaas [Tue, 12 Oct 2021 20:51:32 +0000 (15:51 -0500)]
cxl: Factor out common dev->driver expressions

Save the struct pci_driver and struct pci_error_handlers pointers from
pdev->driver instead of chasing the pointers several times.  No functional
change intended.

Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agoPCI/ERR: Reduce compile time for CONFIG_PCIEAER=n
Lukas Wunner [Sat, 31 Jul 2021 12:39:04 +0000 (14:39 +0200)]
PCI/ERR: Reduce compile time for CONFIG_PCIEAER=n

The sole non-static function in err.c, pcie_do_recovery(), is only
called from:

* aer.c (if CONFIG_PCIEAER=y)
* dpc.c (if CONFIG_PCIE_DPC=y, which depends on CONFIG_PCIEAER)
* edr.c (if CONFIG_PCIE_EDR=y, which depends on CONFIG_PCIE_DPC)

Thus, err.c need not be compiled if CONFIG_PCIEAER=n.

Also, pci_uevent_ers() and pcie_clear_device_status(), which are called
from err.c, can be #ifdef'ed away unless CONFIG_PCIEAER=y.

Since x86_64_defconfig doesn't enable CONFIG_PCIEAER, this change may
slightly reduce compile time for anyone doing a test build with that
config.

Link: https://lore.kernel.org/r/98f9041151268c1c035ab64cca320ad86803f64a.1627638184.git.lukas@wunner.de
Signed-off-by: Lukas Wunner <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agoPCI/portdrv: Remove unused pcie_port_bus_{,un}register() declarations
Lukas Wunner [Sat, 31 Jul 2021 12:39:03 +0000 (14:39 +0200)]
PCI/portdrv: Remove unused pcie_port_bus_{,un}register() declarations

Commit c6c889d932bb ("PCI/portdrv: Remove pcie_port_bus_type link order
dependency") removed pcie_port_bus_{,un}register() but erroneously
retained their declarations in portdrv.h.  Remove them as well.

Link: https://lore.kernel.org/r/7fd76b0591c37287ab94d911d8fd9ab9a2afcd16.1627638184.git.lukas@wunner.de
Signed-off-by: Lukas Wunner <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agoPCI/portdrv: Remove unused resume err_handler
Lukas Wunner [Sat, 31 Jul 2021 12:39:02 +0000 (14:39 +0200)]
PCI/portdrv: Remove unused resume err_handler

Commit 3e41a317ae45 ("PCI/AER: Remove unused aer_error_resume()")
removed the resume err_handler from AER.  Since no other port service
implements the callback, support for it can be removed from portdrv.
It can be revived later if need be, preferably by re-using the
pcie_port_device_iter() iterator.

Link: https://lore.kernel.org/r/25334149b604e005058aeb0fdf51e01f991d5d74.1627638184.git.lukas@wunner.de
Signed-off-by: Lukas Wunner <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Cc: Keith Busch <[email protected]>
3 years agoPCI: pciehp: Ignore Link Down/Up caused by error-induced Hot Reset
Lukas Wunner [Sat, 31 Jul 2021 12:39:01 +0000 (14:39 +0200)]
PCI: pciehp: Ignore Link Down/Up caused by error-induced Hot Reset

Stuart Hayes reports that an error handled by DPC at a Root Port results
in pciehp gratuitously bringing down a subordinate hotplug port:

  RP -- UP -- DP -- UP -- DP (hotplug) -- EP

pciehp brings the slot down because the Link to the Endpoint goes down.
That is caused by a Hot Reset being propagated as a result of DPC.
Per PCIe Base Spec 5.0, section 6.6.1 "Conventional Reset":

  For a Switch, the following must cause a hot reset to be sent on all
  Downstream Ports: [...]

  * The Data Link Layer of the Upstream Port reporting DL_Down status.
    In Switches that support Link speeds greater than 5.0 GT/s, the
    Upstream Port must direct the LTSSM of each Downstream Port to the
    Hot Reset state, but not hold the LTSSMs in that state. This permits
    each Downstream Port to begin Link training immediately after its
    hot reset completes. This behavior is recommended for all Switches.

  * Receiving a hot reset on the Upstream Port.

Once DPC recovers, pcie_do_recovery() walks down the hierarchy and
invokes pcie_portdrv_slot_reset() to restore each port's config space.
At that point, a hotplug interrupt is signaled per PCIe Base Spec r5.0,
section 6.7.3.4 "Software Notification of Hot-Plug Events":

  If the Port is enabled for edge-triggered interrupt signaling using
  MSI or MSI-X, an interrupt message must be sent every time the logical
  AND of the following conditions transitions from FALSE to TRUE: [...]

  * The Hot-Plug Interrupt Enable bit in the Slot Control register is
    set to 1b.

  * At least one hot-plug event status bit in the Slot Status register
    and its associated enable bit in the Slot Control register are both
    set to 1b.

Prevent pciehp from gratuitously bringing down the slot by clearing the
error-induced Data Link Layer State Changed event before restoring
config space.  Afterwards, check whether the link has unexpectedly
failed to retrain and synthesize a DLLSC event if so.

Allow each pcie_port_service_driver (one of them being pciehp) to define
a slot_reset callback and re-use the existing pm_iter() function to
iterate over the callbacks.

Thereby, the Endpoint driver remains bound throughout error recovery and
may restore the device to working state.

Surprise removal during error recovery is detected through a Presence
Detect Changed event.  The hotplug port is expected to not signal that
event as a result of a Hot Reset.

The issue isn't DPC-specific, it also occurs when an error is handled by
AER through aer_root_reset().  So while the issue was noticed only now,
it's been around since 2006 when AER support was first introduced.

[bhelgaas: drop PCI_ERROR_RECOVERY Kconfig, split pm_iter() rename to
preparatory patch]
Link: https://lore.kernel.org/linux-pci/[email protected]/
Fixes: 6c2b374d7485 ("PCI-Express AER implemetation: AER core and aerdriver")
Link: https://lore.kernel.org/r/251f4edcc04c14f873ff1c967bc686169cd07d2d.1627638184.git.lukas@wunner.de
Reported-by: Stuart Hayes <[email protected]>
Tested-by: Stuart Hayes <[email protected]>
Signed-off-by: Lukas Wunner <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Cc: [email protected] # v2.6.19+: ba952824e6c1: PCI/portdrv: Report reset for frozen channel
Cc: Keith Busch <[email protected]>
3 years agoPCI/portdrv: Rename pm_iter() to pcie_port_device_iter()
Lukas Wunner [Fri, 15 Oct 2021 18:58:40 +0000 (13:58 -0500)]
PCI/portdrv: Rename pm_iter() to pcie_port_device_iter()

Rename pm_iter() to pcie_port_device_iter() and make it visible outside
CONFIG_PM and portdrv_core.c so it can be used for pciehp slot reset
recovery.

[bhelgaas: split into its own patch]
Link: https://lore.kernel.org/linux-pci/[email protected]/
Link: https://lore.kernel.org/r/251f4edcc04c14f873ff1c967bc686169cd07d2d.1627638184.git.lukas@wunner.de
Signed-off-by: Lukas Wunner <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agoxen/pcifront: Use to_pci_driver() instead of pci_dev->driver
Uwe Kleine-König [Tue, 12 Oct 2021 21:35:34 +0000 (16:35 -0500)]
xen/pcifront: Use to_pci_driver() instead of pci_dev->driver

Struct pci_driver contains a struct device_driver, so for PCI devices, it's
easy to convert a device_driver * to a pci_driver * with to_pci_driver().
The device_driver * is in struct device, so we don't need to also keep
track of the pci_driver * in struct pci_dev.

Replace pdev->driver with to_pci_driver().  This is a step toward removing
pci_dev->driver.

[bhelgaas: split to separate patch]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Uwe Kleine-König <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Reviewed-by: Boris Ostrovsky <[email protected]>
3 years agoxen/pcifront: Drop pcifront_common_process() tests of pcidev, pdrv
Uwe Kleine-König [Fri, 8 Oct 2021 23:22:08 +0000 (18:22 -0500)]
xen/pcifront: Drop pcifront_common_process() tests of pcidev, pdrv

pcifront_common_process() exits early if pcidev or pcidev->driver are NULL,
so simplify it by not checking them again.

[bhelgaas: split flag change to separate patch]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Uwe Kleine-König <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Reviewed-by: Boris Ostrovsky <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
3 years agoPCI/switchtec: Add check of event support
Logan Gunthorpe [Thu, 14 Oct 2021 14:18:59 +0000 (14:18 +0000)]
PCI/switchtec: Add check of event support

Not all events are supported by every gen/variant of the Switchtec
firmware. To solve this, since Gen4, a new bit in each event header
is introduced to indicate if an event is supported by the firmware.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Logan Gunthorpe <[email protected]>
Signed-off-by: Kelvin Cao <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agoPCI/switchtec: Replace ENOTSUPP with EOPNOTSUPP
Kelvin Cao [Thu, 14 Oct 2021 14:18:58 +0000 (14:18 +0000)]
PCI/switchtec: Replace ENOTSUPP with EOPNOTSUPP

ENOTSUPP is not a SUSV4 error code, and the following checkpatch.pl
warning will be given for new patches which still use ENOTSUPP.

    WARNING: ENOTSUPP is not a SUSV4 error code, prefer EOPNOTSUPP

See the link below for the discussion.

  https://lore.kernel.org/netdev/20200511165319.2251678[email protected]/

Replace ENOTSUPP with EOPNOTSUPP to align with future patches which will
be using EOPNOTSUPP.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Kelvin Cao <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agoPCI/switchtec: Update the way of getting management VEP instance ID
Kelvin Cao [Thu, 14 Oct 2021 14:18:57 +0000 (14:18 +0000)]
PCI/switchtec: Update the way of getting management VEP instance ID

Gen4 firmware adds DMA VEP and NVMe VEP support in VEP (virtual EP)
instance ID register in addtion to management EP, update the way of
getting management VEP instance ID.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Kelvin Cao <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agoPCI/switchtec: Fix a MRPC error status handling issue
Kelvin Cao [Thu, 14 Oct 2021 14:18:56 +0000 (14:18 +0000)]
PCI/switchtec: Fix a MRPC error status handling issue

If an error is encountered when executing a MRPC command, the firmware
will set the status register to SWITCHTEC_MRPC_STATUS_ERROR and return
the error code in the return value register.

Add handling of SWITCHTEC_MRPC_STATUS_ERROR on status register when
completing a MRPC command.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Kelvin Cao <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agoPCI/switchtec: Error out MRPC execution when MMIO reads fail
Kelvin Cao [Thu, 14 Oct 2021 14:18:55 +0000 (14:18 +0000)]
PCI/switchtec: Error out MRPC execution when MMIO reads fail

A firmware hard reset may be initiated by various mechanisms including a
UART interface, TWI sideband interface from BMC, MRPC command from
userspace, etc. The switchtec management driver is unaware of these
resets.

The reset clears PCI state including the BARs and Memory Space Enable
bits, so the device no longer responds to the MMIO accesses the driver
uses to operate it.

MMIO reads to the device will fail with a PCIe error. When the root
complex handles that error, it typically fabricates ~0 data to complete
the CPU read.

Check for this sort of error by reading the device ID from MMIO space.
This ID can never be ~0, so if we see that value, it probably means the
PCIe Memory Read failed and we should return an error indication to the
application using the switchtec driver.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Kelvin Cao <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agoPCI: cpqphp: Format if-statement code block correctly
Krzysztof Wilczyński [Wed, 13 Oct 2021 01:14:12 +0000 (01:14 +0000)]
PCI: cpqphp: Format if-statement code block correctly

The code block related to the if-statement in cpqhp_set_irq() is
somewhat awkwardly formatted making the code hard to read.

Make it readable.  No change to functionality intended.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Krzysztof Wilczyński <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agonfp: use dev_driver_string() instead of pci_dev->driver->name
Uwe Kleine-König [Tue, 12 Oct 2021 22:55:03 +0000 (17:55 -0500)]
nfp: use dev_driver_string() instead of pci_dev->driver->name

Replace dev->driver_name() by dev_driver_string() for the corresponding
struct device.  This is a step toward removing pci_dev->driver.

[bhelgaas: split to separate patch]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Uwe Kleine-König <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Acked-by: Simon Horman <[email protected]>
3 years agomlxsw: pci: Use dev_driver_string() instead of pci_dev->driver->name
Uwe Kleine-König [Tue, 12 Oct 2021 22:54:37 +0000 (17:54 -0500)]
mlxsw: pci: Use dev_driver_string() instead of pci_dev->driver->name

Replace dev->driver_name() by dev_driver_string() for the corresponding
struct device.  This is a step toward removing pci_dev->driver.

[bhelgaas: split to separate patch]
Link: https://lore.kernel.org/r/[email protected]
Tested-by: Ido Schimmel <[email protected]>
Signed-off-by: Uwe Kleine-König <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Reviewed-by: Ido Schimmel <[email protected]>
3 years agonet: marvell: prestera: use dev_driver_string() instead of pci_dev->driver->name
Uwe Kleine-König [Tue, 12 Oct 2021 22:53:45 +0000 (17:53 -0500)]
net: marvell: prestera: use dev_driver_string() instead of pci_dev->driver->name

Replace dev->driver_name() by dev_driver_string() for the corresponding
struct device.  This is a step toward removing pci_dev->driver.

[bhelgaas: split to separate patch]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Uwe Kleine-König <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agonet: hns3: use dev_driver_string() instead of pci_dev->driver->name
Uwe Kleine-König [Tue, 12 Oct 2021 22:52:59 +0000 (17:52 -0500)]
net: hns3: use dev_driver_string() instead of pci_dev->driver->name

Replace dev->driver_name() by dev_driver_string() for the corresponding
struct device.  This is a step toward removing pci_dev->driver.

[bhelgaas: split to separate patch]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Uwe Kleine-König <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agocrypto: hisilicon - use dev_driver_string() instead of pci_dev->driver->name
Uwe Kleine-König [Tue, 12 Oct 2021 22:51:53 +0000 (17:51 -0500)]
crypto: hisilicon - use dev_driver_string() instead of pci_dev->driver->name

Replace dev->driver_name() by dev_driver_string() for the corresponding
struct device.  This is a step toward removing pci_dev->driver.

[bhelgaas: split to separate patch]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Uwe Kleine-König <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agopowerpc/eeh: Use dev_driver_string() instead of struct pci_dev->driver->name
Uwe Kleine-König [Mon, 4 Oct 2021 12:59:29 +0000 (14:59 +0200)]
powerpc/eeh: Use dev_driver_string() instead of struct pci_dev->driver->name

Replace pdev->driver->name by dev_driver_string() for the corresponding
struct device.  This is a step toward removing pci_dev->driver.

Move the function nearer its only user and instead of the ?: operator use a
normal "if" which is more readable.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Uwe Kleine-König <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agossb: Use dev_driver_string() instead of pci_dev->driver->name
Uwe Kleine-König [Mon, 4 Oct 2021 12:59:30 +0000 (14:59 +0200)]
ssb: Use dev_driver_string() instead of pci_dev->driver->name

All drivers that use ssb_pcihost_probe(), i.e., b43_pci_bridge_driver and
b44_pci_driver, set the pci_driver.name, and __pci_register_driver() sets
the struct driver.name member to the same value.

Replace dev->driver_name() by dev_driver_string() for the corresponding
struct device.  This is a step toward removing pci_dev->driver.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Uwe Kleine-König <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Acked-by: Michael Büsch <[email protected]>
3 years agobcma: simplify reference to driver name
Uwe Kleine-König [Mon, 4 Oct 2021 12:59:28 +0000 (14:59 +0200)]
bcma: simplify reference to driver name

When bcma_host_pci_probe() is called, the PCI driver core has already
assigned the device's driver in local_pci_probe(). So dev->driver is always
true, and here it points to bcma_pci_bridge_driver, which has .name set to
"bcma-pci-bridge". Simplify accordingly.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Uwe Kleine-König <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agocrypto: qat - simplify adf_enable_aer()
Uwe Kleine-König [Mon, 4 Oct 2021 12:59:33 +0000 (14:59 +0200)]
crypto: qat - simplify adf_enable_aer()

A struct pci_driver is shared across all device instances, so assigning
pci_driver.err_handler once per device isn't really sensible.

Set adf_driver.err_handler statically instead of in adf_enable_aer().
This removes a use of pci_dev->driver, which is a step toward removing
pci_dev->driver altogether.

Since adf_enable_aer() returns zero unconditionally, make it a void
function.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Uwe Kleine-König <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agoscsi: message: fusion: Remove unused mpt_pci driver .probe() 'id' parameter
Uwe Kleine-König [Mon, 4 Oct 2021 12:59:32 +0000 (14:59 +0200)]
scsi: message: fusion: Remove unused mpt_pci driver .probe() 'id' parameter

The only two drivers don't make use of the id parameter, so drop it.  This
is a step toward removing pci_dev->driver.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Uwe Kleine-König <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Acked-by: Martin K. Petersen <[email protected]>
3 years agoPCI/ERR: Factor out common dev->driver expressions
Bjorn Helgaas [Tue, 12 Oct 2021 22:20:06 +0000 (17:20 -0500)]
PCI/ERR: Factor out common dev->driver expressions

Save the struct pci_driver pointer from pdev->driver instead of repeating
it several times.  No functional change.

Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agoPCI: Drop pci_device_probe() test of !pci_dev->driver
Uwe Kleine-König [Mon, 4 Oct 2021 12:59:26 +0000 (14:59 +0200)]
PCI: Drop pci_device_probe() test of !pci_dev->driver

When the device core calls the .probe() callback for a device, the device
is never bound, so pci_dev->driver is always NULL.

Remove the unnecessary test of !pci_dev->driver.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Uwe Kleine-König <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
3 years agoPCI: Drop pci_device_remove() test of pci_dev->driver
Uwe Kleine-König [Mon, 4 Oct 2021 12:59:25 +0000 (14:59 +0200)]
PCI: Drop pci_device_remove() test of pci_dev->driver

When the driver core calls pci_device_remove(), there is a driver bound
to the device, so pci_dev->driver is never NULL.

Remove the unnecessary test of pci_dev->driver.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Uwe Kleine-König <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
3 years agoPCI: Return NULL for to_pci_driver(NULL)
Bjorn Helgaas [Tue, 12 Oct 2021 20:42:59 +0000 (15:42 -0500)]
PCI: Return NULL for to_pci_driver(NULL)

to_pci_driver() takes a pointer to a struct device_driver and uses
container_of() to find the struct pci_driver that contains it.

If given a NULL pointer to a struct device_driver, return a NULL pci_driver
pointer instead of applying container_of() to NULL.

This simplifies callers that would otherwise have to check for a NULL
pointer first.

Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agoPCI: Use unsigned to match sscanf("%x") in pci_dev_str_match_path()
Krzysztof Wilczyński [Fri, 8 Oct 2021 22:27:32 +0000 (22:27 +0000)]
PCI: Use unsigned to match sscanf("%x") in pci_dev_str_match_path()

Cppcheck warns that pci_dev_str_match_path() passes pointers to signed ints
to sscanf("%x"), which expects pointers to *unsigned* ints:

  invalidScanfArgType_int drivers/pci/pci.c:312 %x in format string (no. 2) requires 'unsigned int *' but the argument type is 'signed int *'.

Declare the variables as unsigned to avoid this issue.

[bhelgaas: commit log]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Krzysztof Wilczyński <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agoPCI: hv: Remove unnecessary use of %hx
Krzysztof Wilczyński [Fri, 8 Oct 2021 22:27:30 +0000 (22:27 +0000)]
PCI: hv: Remove unnecessary use of %hx

"dom_req" is a u16 but varargs automatically promotes it to int, so there's
no point in using the %h modifier.  Drop it.

See cbacb5ab0aa0 ("docs: printk-formats: Stop encouraging use of
unnecessary %h[xudi] and %hh[xudi]") and 70eb2275ff8e ("checkpatch: add
warning for unnecessary use of %h[xudi] and %hh[xudi]").

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Krzysztof Wilczyński <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agoPCI/VPD: Add pci_read/write_vpd_any()
Heiner Kallweit [Fri, 10 Sep 2021 06:22:06 +0000 (08:22 +0200)]
PCI/VPD: Add pci_read/write_vpd_any()

In certain cases we need a variant of pci_read_vpd()/pci_write_vpd() that
does not check against dev->vpd.len. Such cases are:

  - Reading VPD if dev->vpd.len isn't set yet (in pci_vpd_size())

  - Devices that map non-VPD information to arbitrary places in VPD address
    space (example: Chelsio T3 EEPROM write-protect flag)

Therefore add pci_read_vpd_any() and pci_write_vpd_any() that check against
PCI_VPD_MAX_SIZE only.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Heiner Kallweit <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Acked-by: Jakub Kicinski <[email protected]>
3 years agoPCI: Correct misspelled and remove duplicated words
Krzysztof Wilczyński [Wed, 6 Oct 2021 23:38:27 +0000 (23:38 +0000)]
PCI: Correct misspelled and remove duplicated words

Correct a number of misspelled words and remove any words that were
duplicated in the PCI tree.  No change to functionality intended.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Krzysztof Wilczyński <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
3 years agoPCI: aardvark: Fix reporting Data Link Layer Link Active
Pali Rohár [Tue, 5 Oct 2021 18:09:52 +0000 (20:09 +0200)]
PCI: aardvark: Fix reporting Data Link Layer Link Active

Add support for reporting PCI_EXP_LNKSTA_DLLLA bit in Link Control register
on emulated bridge via current LTSSM state. Also correctly indicate DLLLA
capability via PCI_EXP_LNKCAP_DLLLARC bit in Link Control Capability
register.

Link: https://lore.kernel.org/r/[email protected]
Fixes: 8a3ebd8de328 ("PCI: aardvark: Implement emulated root PCI bridge config space")
Signed-off-by: Pali Rohár <[email protected]>
Signed-off-by: Marek Behún <[email protected]>
Signed-off-by: Lorenzo Pieralisi <[email protected]>
Reviewed-by: Marek Behún <[email protected]>
Cc: [email protected]
3 years agoPCI: aardvark: Fix checking for link up via LTSSM state
Pali Rohár [Tue, 5 Oct 2021 18:09:51 +0000 (20:09 +0200)]
PCI: aardvark: Fix checking for link up via LTSSM state

Current implementation of advk_pcie_link_up() is wrong as it marks also
link disabled or hot reset states as link up.

Fix it by marking link up only to those states which are defined in PCIe
Base specification 3.0, Table 4-14: Link Status Mapped to the LTSSM.

To simplify implementation, Define macros for every LTSSM state which
aardvark hardware can return in CFG_REG register.

Fix also checking for link training according to the same Table 4-14.
Define a new function advk_pcie_link_training() for this purpose.

Link: https://lore.kernel.org/r/[email protected]
Fixes: 8c39d710363c ("PCI: aardvark: Add Aardvark PCI host controller driver")
Signed-off-by: Pali Rohár <[email protected]>
Signed-off-by: Marek Behún <[email protected]>
Signed-off-by: Lorenzo Pieralisi <[email protected]>
Reviewed-by: Marek Behún <[email protected]>
Cc: [email protected]
Cc: Remi Pommarel <[email protected]>
3 years agoPCI: aardvark: Fix link training
Pali Rohár [Tue, 5 Oct 2021 18:09:50 +0000 (20:09 +0200)]
PCI: aardvark: Fix link training

Fix multiple link training issues in aardvark driver. The main reason of
these issues was misunderstanding of what certain registers do, since their
names and comments were misleading: before commit 96be36dbffac ("PCI:
aardvark: Replace custom macros by standard linux/pci_regs.h macros"), the
pci-aardvark.c driver used custom macros for accessing standard PCIe Root
Bridge registers, and misleading comments did not help to understand what
the code was really doing.

After doing more tests and experiments I've come to the conclusion that the
SPEED_GEN register in aardvark sets the PCIe revision / generation
compliance and forces maximal link speed. Both GEN3 and GEN2 values set the
read-only PCI_EXP_FLAGS_VERS bits (PCIe capabilities version of Root
Bridge) to value 2, while GEN1 value sets PCI_EXP_FLAGS_VERS to 1, which
matches with PCI Express specifications revisions 3, 2 and 1 respectively.
Changing SPEED_GEN also sets the read-only bits PCI_EXP_LNKCAP_SLS and
PCI_EXP_LNKCAP2_SLS to corresponding speed.

(Note that PCI Express rev 1 specification does not define PCI_EXP_LNKCAP2
 and PCI_EXP_LNKCTL2 registers and when SPEED_GEN is set to GEN1 (which
 also sets PCI_EXP_FLAGS_VERS set to 1), lspci cannot access
 PCI_EXP_LNKCAP2 and PCI_EXP_LNKCTL2 registers.)

Changing PCIe link speed can be done via PCI_EXP_LNKCTL2_TLS bits of
PCI_EXP_LNKCTL2 register. Armada 3700 Functional Specifications says that
the default value of PCI_EXP_LNKCTL2_TLS is based on SPEED_GEN value, but
tests showed that the default value is always 8.0 GT/s, independently of
speed set by SPEED_GEN. So after setting SPEED_GEN, we must also set value
in PCI_EXP_LNKCTL2 register via PCI_EXP_LNKCTL2_TLS bits.

Triggering PCI_EXP_LNKCTL_RL bit immediately after setting LINK_TRAINING_EN
bit actually doesn't do anything. Tests have shown that a delay is needed
after enabling LINK_TRAINING_EN bit. As triggering PCI_EXP_LNKCTL_RL
currently does nothing, remove it.

Commit 43fc679ced18 ("PCI: aardvark: Improve link training") introduced
code which sets SPEED_GEN register based on negotiated link speed from
PCI_EXP_LNKSTA_CLS bits of PCI_EXP_LNKSTA register. This code was added to
fix detection of Compex WLE900VX (Atheros QCA9880) WiFi GEN1 PCIe cards, as
otherwise these cards were "invisible" on PCIe bus (probably because they
crashed). But apparently more people reported the same issues with these
cards also with other PCIe controllers [1] and I was able to reproduce this
issue also with other "noname" WiFi cards based on Atheros QCA9890 chip
(with the same PCI vendor/device ids as Atheros QCA9880). So this is not an
issue in aardvark but rather an issue in Atheros QCA98xx chips. Also, this
issue only exists if the kernel is compiled with PCIe ASPM support, and a
generic workaround for this is to change PCIe Bridge to 2.5 GT/s link speed
via PCI_EXP_LNKCTL2_TLS_2_5GT bits in PCI_EXP_LNKCTL2 register [2], before
triggering PCI_EXP_LNKCTL_RL bit. This workaround also works when SPEED_GEN
is set to value GEN2 (5 GT/s). So remove this hack completely in the
aardvark driver and always set SPEED_GEN to value from 'max-link-speed' DT
property. Fix for Atheros QCA98xx chips is handled separately by patch [2].

These two things (code for triggering PCI_EXP_LNKCTL_RL bit and changing
SPEED_GEN value) also explain why commit 6964494582f5 ("PCI: aardvark:
Train link immediately after enabling training") somehow fixed detection of
those problematic Compex cards with Atheros chips: if triggering link
retraining (via PCI_EXP_LNKCTL_RL bit) was done immediately after enabling
link training (via LINK_TRAINING_EN), it did nothing. If there was a
specific delay, aardvark HW already initialized PCIe link and therefore
triggering link retraining caused the above issue. Compex cards triggered
link down event and disappeared from the PCIe bus.

Commit f4c7d053d7f7 ("PCI: aardvark: Wait for endpoint to be ready before
training link") added 100ms sleep before calling 'Start link training'
command and explained that it is a requirement of PCI Express
specification. But the code after this 100ms sleep was not doing 'Start
link training', rather it triggered PCI_EXP_LNKCTL_RL bit via PCIe Root
Bridge to put link into Recovery state.

The required delay after fundamental reset is already done in function
advk_pcie_wait_for_link() which also checks whether PCIe link is up.
So after removing the code which triggers PCI_EXP_LNKCTL_RL bit on PCIe
Root Bridge, there is no need to wait 100ms again. Remove the extra
msleep() call and update comment about the delay required by the PCI
Express specification.

According to Marvell Armada 3700 Functional Specifications, Link training
should be enabled via aardvark register LINK_TRAINING_EN after selecting
PCIe generation and x1 lane. There is no need to disable it prior resetting
card via PERST# signal. This disabling code was introduced in commit
5169a9851daa ("PCI: aardvark: Issue PERST via GPIO") as a workaround for
some Atheros cards. It turns out that this also is Atheros specific issue
and affects any PCIe controller, not only aardvark. Moreover this Atheros
issue was triggered by juggling with PCI_EXP_LNKCTL_RL, LINK_TRAINING_EN
and SPEED_GEN bits interleaved with sleeps. Now, after removing triggering
PCI_EXP_LNKCTL_RL, there is no need to explicitly disable LINK_TRAINING_EN
bit. So remove this code too. The problematic Compex cards described in
previous git commits are correctly detected in advk_pcie_train_link()
function even after applying all these changes.

Note that with this patch, and also prior this patch, some NVMe disks which
support PCIe GEN3 with 8 GT/s speed are negotiated only at the lowest link
speed 2.5 GT/s, independently of SPEED_GEN value. After manually triggering
PCI_EXP_LNKCTL_RL bit (e.g. from userspace via setpci), these NVMe disks
change link speed to 5 GT/s when SPEED_GEN was configured to GEN2. This
issue first needs to be properly investigated. I will send a fix in the
future.

On the other hand, some other GEN2 PCIe cards with 5 GT/s speed are
autonomously by HW autonegotiated at full 5 GT/s speed without need of any
software interaction.

Armada 3700 Functional Specifications describes the following steps for
link training: set SPEED_GEN to GEN2, enable LINK_TRAINING_EN, poll until
link training is complete, trigger PCI_EXP_LNKCTL_RL, poll until signal
rate is 5 GT/s, poll until link training is complete, enable ASPM L0s.

The requirement for triggering PCI_EXP_LNKCTL_RL can be explained by the
need to achieve 5 GT/s speed (as changing link speed is done by throw to
recovery state entered by PCI_EXP_LNKCTL_RL) or maybe as a part of enabling
ASPM L0s (but in this case ASPM L0s should have been enabled prior
PCI_EXP_LNKCTL_RL).

It is unknown why the original pci-aardvark.c driver was triggering
PCI_EXP_LNKCTL_RL bit before waiting for the link to be up. This does not
align with neither PCIe base specifications nor with Armada 3700 Functional
Specification. (Note that in older versions of aardvark, this bit was
called incorrectly PCIE_CORE_LINK_TRAINING, so this may be the reason.)

It is also unknown why Armada 3700 Functional Specification says that it is
needed to trigger PCI_EXP_LNKCTL_RL for GEN2 mode, as according to PCIe
base specification 5 GT/s speed negotiation is supposed to be entirely
autonomous, even if initial speed is 2.5 GT/s.

[1] - https://lore.kernel.org/linux-pci/[email protected]/
[2] - https://lore.kernel.org/linux-pci/20210326124326[email protected]/

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Pali Rohár <[email protected]>
Signed-off-by: Marek Behún <[email protected]>
Signed-off-by: Lorenzo Pieralisi <[email protected]>
Reviewed-by: Marek Behún <[email protected]>
3 years agoPCI: aardvark: Simplify initialization of rootcap on virtual bridge
Pali Rohár [Tue, 5 Oct 2021 18:09:49 +0000 (20:09 +0200)]
PCI: aardvark: Simplify initialization of rootcap on virtual bridge

PCIe config space can be initialized also before pci_bridge_emul_init()
call, so move rootcap initialization after PCI config space initialization.

This simplifies the function a little since it removes one if (ret < 0)
check.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Pali Rohár <[email protected]>
Signed-off-by: Marek Behún <[email protected]>
Signed-off-by: Lorenzo Pieralisi <[email protected]>
Reviewed-by: Marek Behún <[email protected]>
3 years agoPCI: aardvark: Implement re-issuing config requests on CRS response
Pali Rohár [Tue, 5 Oct 2021 18:09:48 +0000 (20:09 +0200)]
PCI: aardvark: Implement re-issuing config requests on CRS response

Commit 43f5c77bcbd2 ("PCI: aardvark: Fix reporting CRS value") fixed
handling of CRS response and when CRSSVE flag was not enabled it marked CRS
response as failed transaction (due to simplicity).

But pci-aardvark.c driver is already waiting up to the PIO_RETRY_CNT count
for PIO config response and so we can with a small change implement
re-issuing of config requests as described in PCIe base specification.

This change implements re-issuing of config requests when response is CRS.
Set upper bound of wait cycles to around PIO_RETRY_CNT, afterwards the
transaction is marked as failed and an all-ones value is returned as
before.

We do this by returning appropriate error codes from function
advk_pcie_check_pio_status(). On CRS we return -EAGAIN and caller then
reissues transaction.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Pali Rohár <[email protected]>
Signed-off-by: Marek Behún <[email protected]>
Signed-off-by: Lorenzo Pieralisi <[email protected]>
Reviewed-by: Marek Behún <[email protected]>
3 years agoPCI: aardvark: Deduplicate code in advk_pcie_rd_conf()
Marek Behún [Tue, 5 Oct 2021 18:09:47 +0000 (20:09 +0200)]
PCI: aardvark: Deduplicate code in advk_pcie_rd_conf()

Avoid code repetition in advk_pcie_rd_conf() by handling errors with
goto jump, as is customary in kernel.

Link: https://lore.kernel.org/r/[email protected]
Fixes: 43f5c77bcbd2 ("PCI: aardvark: Fix reporting CRS value")
Signed-off-by: Marek Behún <[email protected]>
Signed-off-by: Lorenzo Pieralisi <[email protected]>
3 years agoPCI: aardvark: Do not unmask unused interrupts
Pali Rohár [Tue, 5 Oct 2021 18:09:46 +0000 (20:09 +0200)]
PCI: aardvark: Do not unmask unused interrupts

There are lot of undocumented interrupt bits. To prevent unwanted
spurious interrupts, fix all *_ALL_MASK macros to define all interrupt
bits, so that driver can properly mask all interrupts, including those
which are undocumented.

Link: https://lore.kernel.org/r/[email protected]
Fixes: 8c39d710363c ("PCI: aardvark: Add Aardvark PCI host controller driver")
Signed-off-by: Pali Rohár <[email protected]>
Signed-off-by: Marek Behún <[email protected]>
Signed-off-by: Lorenzo Pieralisi <[email protected]>
Reviewed-by: Marek Behún <[email protected]>
Cc: [email protected]
3 years agoPCI: aardvark: Do not clear status bits of masked interrupts
Pali Rohár [Tue, 5 Oct 2021 18:09:45 +0000 (20:09 +0200)]
PCI: aardvark: Do not clear status bits of masked interrupts

The PCIE_ISR1_REG says which interrupts are currently set / active,
including those which are masked.

The driver currently reads this register and looks if some unmasked
interrupts are active, and if not, it clears status bits of _all_
interrupts, including the masked ones.

This is incorrect, since, for example, some drivers may poll these bits.

Remove this clearing, and also remove this early return statement
completely, since it does not change functionality in any way.

Link: https://lore.kernel.org/r/[email protected]
Fixes: 8c39d710363c ("PCI: aardvark: Add Aardvark PCI host controller driver")
Signed-off-by: Pali Rohár <[email protected]>
Signed-off-by: Marek Behún <[email protected]>
Signed-off-by: Lorenzo Pieralisi <[email protected]>
Reviewed-by: Marek Behún <[email protected]>
Cc: [email protected]
3 years agoPCI: aardvark: Fix configuring Reference clock
Pali Rohár [Tue, 5 Oct 2021 18:09:44 +0000 (20:09 +0200)]
PCI: aardvark: Fix configuring Reference clock

Commit 366697018c9a ("PCI: aardvark: Add PHY support") introduced
configuration of PCIe Reference clock via PCIE_CORE_REF_CLK_REG register,
but did it incorrectly.

PCIe Reference clock differential pair is routed from system board to
endpoint card, so on CPU side it has output direction. Therefore it is
required to enable transmitting and disable receiving.

Default configuration according to Armada 3700 Functional Specifications is
enabled receiver part and disabled transmitter.

We need this change because otherwise PCIe Reference clock is configured to
some undefined state when differential pair is used for both transmitting
and receiving.

Fix this by disabling receiver part.

Link: https://lore.kernel.org/r/[email protected]
Fixes: 366697018c9a ("PCI: aardvark: Add PHY support")
Signed-off-by: Pali Rohár <[email protected]>
Signed-off-by: Marek Behún <[email protected]>
Signed-off-by: Lorenzo Pieralisi <[email protected]>
Reviewed-by: Marek Behún <[email protected]>
Cc: [email protected]
3 years agoPCI: aardvark: Fix preserving PCI_EXP_RTCTL_CRSSVE flag on emulated bridge
Pali Rohár [Tue, 5 Oct 2021 18:09:43 +0000 (20:09 +0200)]
PCI: aardvark: Fix preserving PCI_EXP_RTCTL_CRSSVE flag on emulated bridge

Commit 43f5c77bcbd2 ("PCI: aardvark: Fix reporting CRS value") started
using CRSSVE flag for handling CRS responses.

PCI_EXP_RTCTL_CRSSVE flag is stored only in emulated config space buffer
and there is handler for PCI_EXP_RTCTL register. So every read operation
from config space automatically clears CRSSVE flag as it is not defined in
PCI_EXP_RTCTL read handler.

Fix this by reading current CRSSVE bit flag from emulated space buffer and
appending it to PCI_EXP_RTCTL read response.

Link: https://lore.kernel.org/r/[email protected]
Fixes: 43f5c77bcbd2 ("PCI: aardvark: Fix reporting CRS value")
Signed-off-by: Pali Rohár <[email protected]>
Signed-off-by: Marek Behún <[email protected]>
Signed-off-by: Lorenzo Pieralisi <[email protected]>
Reviewed-by: Marek Behún <[email protected]>
3 years agoPCI: aardvark: Don't spam about PIO Response Status
Marek Behún [Tue, 5 Oct 2021 18:09:42 +0000 (20:09 +0200)]
PCI: aardvark: Don't spam about PIO Response Status

Use dev_dbg() instead of dev_err() in advk_pcie_check_pio_status().

For example CRS is not an error status, it just says that the request
should be retried.

Link: https://lore.kernel.org/r/[email protected]
Fixes: 8c39d710363c1 ("PCI: aardvark: Add Aardvark PCI host controller driver")
Signed-off-by: Marek Behún <[email protected]>
Signed-off-by: Lorenzo Pieralisi <[email protected]>
This page took 0.130321 seconds and 4 git commands to generate.