]> www.infradead.org Git - users/jedix/linux-maple.git/log
users/jedix/linux-maple.git
5 weeks agoMerge branch 'pci/controller/xgene'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:24 +0000 (12:13 -0500)]
Merge branch 'pci/controller/xgene'

* pci/controller/xgene:
  PCI: xgene-msi: Return negative -EINVAL in xgene_msi_handler_setup()

5 weeks agoMerge branch 'pci/controller/tegra'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:23 +0000 (12:13 -0500)]
Merge branch 'pci/controller/tegra'

- Correct the devm_kcalloc() argument order (Alok Tiwari)

- When asserting PERST#, disable the controller instead of mistakenly
  disabling the PLL twice (Nagarjuna Kristam)

- Convert struct tegra_msi mask_lock to raw spinlock to avoid a lock
  nesting error (Marek Vasut)

- Rename 'root_bus' to 'root_port_bus' for clarity (Manivannan Sadhasivam)

* pci/controller/tegra:
  PCI: tegra194: Rename 'root_bus' to 'root_port_bus' in tegra_pcie_downstream_dev_to_D0()
  PCI: tegra: Convert struct tegra_msi mask_lock into raw spinlock
  PCI: tegra194: Fix duplicate PLL disable in pex_ep_event_pex_rst_assert()
  PCI: tegra: Fix devm_kcalloc() argument order for port->phys allocation

5 weeks agoMerge branch 'pci/controller/stm32'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:23 +0000 (12:13 -0500)]
Merge branch 'pci/controller/stm32'

- Update pinctrl documentation of initial states and use in runtime
  suspend/resume (Christian Bruel)

- Add pinctrl_pm_select_init_state() for use by stm32 driver, which needs
  it during resume (Christian Bruel)

- Add devicetree bindings and drivers for the STMicroelectronics STM32MP25
  in host and endpoint modes (Christian Bruel)

* pci/controller/stm32:
  MAINTAINERS: Add entry for ST STM32MP25 PCIe drivers
  PCI: stm32-ep: Add PCIe Endpoint support for STM32MP25
  dt-bindings: PCI: Add STM32MP25 PCIe Endpoint bindings
  PCI: stm32: Add PCIe host support for STM32MP25
  dt-bindings: PCI: Add STM32MP25 PCIe Root Complex bindings
  pinctrl: Add pinctrl_pm_select_init_state helper function
  Documentation: pinctrl: Describe PM helper functions for standard states.

5 weeks agoMerge branch 'pci/controller/sophgo'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:22 +0000 (12:13 -0500)]
Merge branch 'pci/controller/sophgo'

- Check for existence of struct cdns_pcie.ops before using it to allow
  Cadence drivers that don't need to supply ops (Chen Wang)

- Add DT binding and driver for the Sophgo SG2042 PCIe controller (Chen
  Wang)

* pci/controller/sophgo:
  PCI: sg2042: Add Sophgo SG2042 PCIe driver
  PCI: cadence: Check for the existence of cdns_pcie::ops before using it
  dt-bindings: pci: Add Sophgo SG2042 PCIe host

5 weeks agoMerge branch 'pci/controller/rcar-host'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:22 +0000 (12:13 -0500)]
Merge branch 'pci/controller/rcar-host'

- Pass the correct IRQ domain to generic_handle_domain_irq() to fix a
  regression when converting to msi_create_parent_irq_domain() (Claudiu
  Beznea)

- Drop the spinlock protecting the PMSR register; it's no longer required
  since pci_lock already serializes accesses (Marek Vasut)

- Convert struct rcar_msi mask_lock to raw spinlock to avoid a lock nesting
  error (Marek Vasut)

* pci/controller/rcar-host:
  PCI: rcar-host: Convert struct rcar_msi mask_lock into raw spinlock
  PCI: rcar-host: Drop PMSR spinlock
  PCI: rcar-host: Pass proper IRQ domain to generic_handle_domain_irq()

5 weeks agoMerge branch 'pci/controller/rcar-gen4'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:21 +0000 (12:13 -0500)]
Merge branch 'pci/controller/rcar-gen4'

- Fix a typo that prevented correct PHY initialization (Marek Vasut)

- Add a missing 1ms delay after PWR reset assertion as required by the V4H
  manual (Marek Vasut)

- Assure reset has completed before DBI access to avoid SError (Marek
  Vasut)

- Fix inverted PHY initialization check, which sometimes led to timeouts
  and failure to start the controller (Marek Vasut)

* pci/controller/rcar-gen4:
  PCI: rcar-gen4: Fix inverted break condition in PHY initialization
  PCI: rcar-gen4: Assure reset occurs before DBI access
  PCI: rcar-gen4: Add missing 1ms delay after PWR reset assertion
  PCI: rcar-gen4: Fix PHY initialization

5 weeks agoMerge branch 'pci/controller/qcom'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:20 +0000 (12:13 -0500)]
Merge branch 'pci/controller/qcom'

- Select PCI Power Control Slot driver so slot voltage rails can be turned
  on/off if described in Root Port device tree node (Qiang Yu)

- Parse only PCI bridge child nodes in device tree, skipping unrelated
  nodes such as OPP (Operating Performance Points), which caused probe
  failures (Krishna Chaitanya Chundru)

- Add 8.0 GT/s and 32.0 GT/s equalization settings (Ziyue Zhang)

- Fix typo in CURSOR macro names (Ziyue Zhang)

- Consolidate Root Port 'phy' and 'reset' properties in struct
  qcom_pcie_port, regardless of whether we got them from the Root Port node
  or the host bridge node (Manivannan Sadhasivam)

- Fetch and map the ELBI register space in the DWC core rather than in each
  driver individually (Krishna Chaitanya Chundru)

- Enable ECAM mechanism in DWC core by setting up iATU with 'CFG Shift
  Feature' and use this in the qcom driver (Krishna Chaitanya Chundru)

* pci/controller/qcom:
  PCI: dwc: Support ECAM mechanism by enabling iATU 'CFG Shift Feature'
  PCI: qcom: Prepare for the DWC ECAM enablement
  PCI: dwc: Prepare the driver for enabling ECAM mechanism using iATU 'CFG Shift Feature'
  PCI: dwc: Add support for ELBI resource mapping
  PCI: qcom: Move host bridge 'phy' and 'reset' pointers to struct qcom_pcie_port
  PCI: qcom: Fix macro typo for CURSOR
  PCI: qcom: Add equalization settings for 8.0 GT/s and 32.0 GT/s
  PCI: qcom: Restrict port parsing only to PCIe bridge child nodes
  PCI: qcom: Select PCI Power Control Slot driver

5 weeks agoMerge branch 'pci/controller/plda'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:20 +0000 (12:13 -0500)]
Merge branch 'pci/controller/plda'

- Return -ENOMEM directly instead of using dev_err_probe() (Xichao Zhao)

* pci/controller/plda:
  PCI: plda: Remove dev_err_probe() when the errno is -ENOMEM

5 weeks agoMerge branch 'pci/controller/mediatek-gen3'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:19 +0000 (12:13 -0500)]
Merge branch 'pci/controller/mediatek-gen3'

- Add optional sys clock ready time setting to avoid sys_clk_rdy signal
  glitching in MT6991 and MT8196 (AngeloGioacchino Del Regno)

- Add DT binding and driver support for MT6991 and MT8196 (AngeloGioacchino
  Del Regno)

* pci/controller/mediatek-gen3:
  PCI: mediatek-gen3: Add support for MediaTek MT8196 SoC
  dt-bindings: PCI: mediatek-gen3: Add support for MT6991/MT8196
  PCI: mediatek-gen3: Implement sys clock ready time setting

5 weeks agoMerge branch 'pci/controller/keystone'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:19 +0000 (12:13 -0500)]
Merge branch 'pci/controller/keystone'

- Use kcalloc() instead of kzalloc() to avoid potential integer overflow
  (Qianfeng Rong)

- Use devm_request_irq() so 'ks-pcie-error-irq' is freed when driver exits
  with error (Siddharth Vadapalli)

* pci/controller/keystone:
  PCI: keystone: Use devm_request_irq() to free "ks-pcie-error-irq" on exit
  PCI: keystone: Use kcalloc() instead of kzalloc()

5 weeks agoMerge branch 'pci/controller/j721e'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:18 +0000 (12:13 -0500)]
Merge branch 'pci/controller/j721e'

- Add MODULE_DEVICE_TABLE() so driver can be autoloaded (Siddharth
  Vadapalli)

- Power controller off before configuring the glue layer so the controller
  latches the correct values on power-on (Siddharth Vadapalli)

- Correct the error message when j721e_pcie_ctrl_init() fails (Alok Tiwari)

* pci/controller/j721e:
  PCI: j721e: Fix incorrect error message in probe()
  PCI: j721e: Fix programming sequence of "strap" settings
  PCI: j721e: Fix module autoloading

5 weeks agoMerge branch 'pci/controller/imx6'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:18 +0000 (12:13 -0500)]
Merge branch 'pci/controller/imx6'

- Enable the 3.3V Vaux supply if available so devices can request wakeup
  with either Beacon or WAKE# (Richard Zhu)

* pci/controller/imx6:
  PCI: imx6: Enable the Vaux supply if available

5 weeks agoMerge branch 'pci/controller/hv'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:17 +0000 (12:13 -0500)]
Merge branch 'pci/controller/hv'

- Remove unused hv_msi_free() parameter (Nam Cao)

* pci/controller/hv:
  PCI: hv: Remove unused parameter of hv_msi_free()

5 weeks agoMerge branch 'pci/controller/dwc-edma'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:16 +0000 (12:13 -0500)]
Merge branch 'pci/controller/dwc-edma'

- Verify that if DT specifies a single IRQ for all eDMA channels, it is
  named 'dma' (Niklas Cassel)

- Remove qcom edma.nr_irqs initialization, which is redundant since
  dw_pcie_edma_irq_verify() initializes it based on whether the DT contains
  'dma' (single IRQ) or 'dmaX' (multiple IRQs) (Niklas Cassel)

* pci/controller/dwc-edma:
  PCI: qcom-ep: Remove redundant edma.nr_irqs initialization
  PCI: dwc: Verify the single eDMA IRQ in dw_pcie_edma_irq_verify()

5 weeks agoMerge branch 'pci/controller/dwc'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:16 +0000 (12:13 -0500)]
Merge branch 'pci/controller/dwc'

- Add support for x16 in devicetree 'num-lanes' property (Konrad Dybcio)

* pci/controller/dwc:
  PCI: dwc: Support 16-lane operation

5 weeks agoMerge branch 'pci/controller/amd-mdb'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:15 +0000 (12:13 -0500)]
Merge branch 'pci/controller/amd-mdb'

- Update DT binding example to separate PERST# to a Root Port stanza to
  make multiple Root Ports possible in the future (Sai Krishna Musham)

- Add driver support for Root Port PERST# (Sai Krishna Musham)

* pci/controller/amd-mdb:
  PCI: amd-mdb: Add support for PCIe RP PERST# signal handling
  dt-bindings: PCI: amd-mdb: Add example usage of reset-gpios for PCIe RP PERST#

5 weeks agoMerge branch 'pci/endpoint'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:15 +0000 (12:13 -0500)]
Merge branch 'pci/endpoint'

- Check for errors returned from pci_epc_get(), which returns IS_ERR(), not
  NULL on error (Dan Carpenter)

- Fix pci_endpoint_test_ioctl() array underflow (Dan Carpenter)

- Document sysfs interface for BAR assignment of vNTB endpoint functions
  (Jerome Brunet)

- Drop superfluous pci_epc_features initialization for unsupported
  features; we only have to mention features that *are* supported (Niklas
  Cassel)

- Skip IRQ tests if the IRQ is out of range (Christian Bruel)

- Fix pci-epf-test for controllers with fixed-size BARs smaller than
  requested by the test (Marek Vasut)

- Restore inbound translation when disabling doorbell so the doorbell test
  case can be run more than once (Niklas Cassel)

- Check for NULL before releasing DMA channels to avoid a NULL pointer
  dereference (Shin'ichiro Kawasaki)

- Convert tegra194 interrupt number to MSI vector to fix endpoint Kselftest
  MSI_TEST test case (Niklas Cassel)

- Set tegra_pcie_epc_features.msi_capable so the pci_endpoint_test can use
  the optimal IRQ type (Niklas Cassel)

- Reset tegra194 BARs when running in endpoint mode so the BAR tests don't
  overwrite the ATU settings in BAR4 (Niklas Cassel)

- Handle errors in tegra194 BPMP transactions so we don't mistakenly skip
  future PERST# assertion (Vidya Sagar)

* pci/endpoint:
  PCI: tegra194: Handle errors in BPMP response
  PCI: tegra194: Reset BARs when running in PCIe endpoint mode
  PCI: tegra194: Set pci_epc_features::msi_capable to true
  PCI: tegra194: Fix broken tegra_pcie_ep_raise_msi_irq()
  PCI: endpoint: pci-epf-test: Add NULL check for DMA channels before release
  PCI: endpoint: pci-epf-test: Fix doorbell test support
  PCI: endpoint: pci-epf-test: Limit PCIe BAR size for fixed BARs
  selftests: pci_endpoint: Skip IRQ test if IRQ is out of range.
  misc: pci_endpoint_test: Cleanup extra 0 initialization
  misc: pci_endpoint_test: Skip IRQ tests if irq is out of range
  PCI: endpoint: Drop superfluous pci_epc_features initialization
  Documentation: PCI: endpoint: Document BAR assignment
  misc: pci_endpoint_test: Fix array underflow in pci_endpoint_test_ioctl()
  PCI: endpoint: pci-ep-msi: Fix NULL vs IS_ERR() check in pci_epf_write_msi_msg()

5 weeks agoMerge branch 'pci/dt-binding'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:14 +0000 (12:13 -0500)]
Merge branch 'pci/dt-binding'

- Correct indentation in qcom,pcie-sa8255p.yaml and
  amd,versal2-mdb-host.yaml so they indent with four spaces consistently
  (Krzysztof Kozlowski)

- Add SM8750 compatible to qcom,pcie-sm8550.yaml (Krishna Chaitanya
  Chundru)

- Add Peripheral Virtualization Unit (PVU), which restricts DMA from PCIe
  devices to specific regions of host memory, to the ti,am65 binding (Jan
  Kiszka)

- Update qcom,pcie-x1e80100.yaml to allow fifth PCIe host on Qualcomm
  Glymur, which is compatible with X1E80100 but doesn't have the
  cnoc_sf_axi clock (Qiang Yu)

* pci/dt-binding:
  dt-bindings: PCI: qcom,pcie-x1e80100: Set clocks minItems for the fifth Glymur PCIe Controller
  dt-bindings: PCI: ti,am65: Extend for use with PVU
  dt-bindings: PCI: qcom,pcie-sm8550: Add SM8750 compatible
  dt-bindings: PCI: Correct example indentation

5 weeks agoMerge branch 'pci/capability-search'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:14 +0000 (12:13 -0500)]
Merge branch 'pci/capability-search'

- Simplify __pci_find_next_cap_ttl() by replacing magic numbers with
  #defines, extracting fields with FIELD_GET(), etc (Hans Zhang)

- Convert __pci_find_next_cap_ttl() to a PCI_FIND_NEXT_CAP() macro that
  takes a config space accessor function so we can also use it in cases
  where the usual config accessors aren't available (Hans Zhang)

- Similarly convert pci_find_next_ext_capability() to a
  PCI_FIND_NEXT_EXT_CAP() macro (Hans Zhang)

- Implement dwc, dwc endpoint, and cadence capability search interfaces on
  top of PCI_FIND_NEXT_CAP() and PCI_FIND_NEXT_EXT_CAP(), replacing the
  previous duplicated code (Hans Zhang)

- Search for capabilities in the cadence core instead of hard-coding their
  offsets, which are subject to change (Hans Zhang)

* pci/capability-search:
  PCI: cadence: Use cdns_pcie_find_*capability() to avoid hardcoding offsets
  PCI: cadence: Implement capability search using PCI core APIs
  PCI: dwc: ep: Implement capability search using PCI core APIs
  PCI: dwc: Implement capability search using PCI core APIs
  PCI: Refactor extended capability search into PCI_FIND_NEXT_EXT_CAP()
  PCI: Refactor capability search into PCI_FIND_NEXT_CAP()
  PCI: Clean up __pci_find_next_cap_ttl() readability

5 weeks agoMerge branch 'pci/switchtec'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:13 +0000 (12:13 -0500)]
Merge branch 'pci/switchtec'

- Replace manual locks with guard to simplify code (Erick Karanja)

* pci/switchtec:
  PCI: switchtec: Replace manual locks with guard

5 weeks agoMerge branch 'pci/virtualization'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:12 +0000 (12:13 -0500)]
Merge branch 'pci/virtualization'

- Add rescan/remove locking when enabling/disabling SR-IOV, which solves
  list corruption on s390, where disabling SR-IOV also generates hotplug
  events (Niklas Schnelle)

- Add lockdep assertion in pci_stop_and_remove_bus_device() to catch
  device removal without appropriate locking (Niklas Schnelle)

* pci/virtualization:
  PCI: Add lockdep assertion in pci_stop_and_remove_bus_device()
  PCI/IOV: Add PCI rescan-remove locking when enabling/disabling SR-IOV

5 weeks agoMerge branch 'pci/resource'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:12 +0000 (12:13 -0500)]
Merge branch 'pci/resource'

- Ensure relaxed tail alignment does not increase min_align when computing
  bridge window size, to fix a regression (Ilpo Järvinen)

- Fix bridge window size computation to fix a regression for devices with
  undefined PCI class, e.g., Samsung [144d:a5a5] (Ilpo Järvinen)

- Fix error handling during resource resize to fix a regression in amdgpu
  (Ilpo Järvinen)

- Align m68k pcibios_enable_device() with other arches (Ilpo Järvinen)

- Remove several sparc pcibios_enable_device() implementations that don't
  do anything beyond what pci_enable_resources() does (Ilpo Järvinen)

- Remove mips pcibios_enable_resources() and use pci_enable_resources()
  instead (Ilpo Järvinen)

- Refactor and simplify find_bus_resource_of_type() (Ilpo Järvinen)

- Claim bridge windows before setting them up (Ilpo Järvinen)

- Disable non-claimed bridge windows so the kernel's view matches the
  hardware configuration (Ilpo Järvinen)

- Use pci_release_resource() instead of release_resource() to reduce code
  duplication and increase consistency (Ilpo Järvinen)

- Enable bridges even if bridge window assignment fails (Ilpo Järvinen)

- Preserve bridge window resource type flags when assignment fails because
  we may need it later (Ilpo Järvinen)

- Add bridge window selection functions to make the selection consistent
  across the several places that do this (Ilpo Järvinen)

- Warn if bridge window cannot be released when resizing BAR (Ilpo
  Järvinen)

- Set up bridge resources before enumerating children so we can check
  whether child resources are inside bridge windows (Ilpo Järvinen)

* pci/resource:
  PCI: Set up bridge resources earlier
  PCI: Don't print stale information about resource
  PCI: Alter misleading recursion to pci_bus_release_bridge_resources()
  PCI: Pass bridge window to pci_bus_release_bridge_resources()
  PCI: Add pci_setup_one_bridge_window()
  PCI: Refactor remove_dev_resources() to use pbus_select_window()
  PCI: Refactor distributing available memory to use loops
  PCI: Use pbus_select_window_for_type() during mem window sizing
  PCI: Use pbus_select_window() in space available checker
  PCI: Rename resource variable from r to res
  PCI: Use pbus_select_window_for_type() during IO window sizing
  PCI: Use pbus_select_window() during BAR resize
  PCI: Warn if bridge window cannot be released when resizing BAR
  PCI: Fix finding bridge window in pci_reassign_bridge_resources()
  PCI: Add bridge window selection functions
  PCI: Add defines for bridge window indexing
  PCI: Preserve bridge window resource type flags
  PCI: Enable bridge even if bridge window fails to assign
  PCI: Use pci_release_resource() instead of release_resource()
  PCI: Disable non-claimed bridge window
  PCI: Always claim bridge window before its setup
  PCI: Refactor find_bus_resource_of_type() logic checks
  PCI: Move find_bus_resource_of_type() earlier
  MIPS: PCI: Use pci_enable_resources()
  sparc/PCI: Remove pcibios_enable_device() as they do nothing extra
  m68k/PCI: Use pci_enable_resources() in pcibios_enable_device()
  PCI: Fix failure detection during resource resize
  PCI: Fix pdev_resources_assignable() disparity
  PCI: Ensure relaxed tail alignment does not increase min_align

5 weeks agoMerge branch 'pci/pwrctrl'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:11 +0000 (12:13 -0500)]
Merge branch 'pci/pwrctrl'

- Fix a double cleanup of regulators if devm_add_action_or_reset() fails
  (Geert Uytterhoeven)

* pci/pwrctrl:
  PCI/pwrctrl: Fix device leak at device stop
  PCI/pwrctrl: Fix device and OF node leak at bus scan
  PCI/pwrctrl: Fix device leak at registration
  PCI/pwrctrl: Fix double cleanup on devm_add_action_or_reset() failure

5 weeks agoMerge branch 'pci/pm'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:11 +0000 (12:13 -0500)]
Merge branch 'pci/pm'

- If a device has already been disconnected, e.g., by a hotplug removal,
  don't bother trying to resume it to D0 when detaching the driver (Mario
  Limonciello)

- Ensure devices are powered up before config reads for 'max_link_width',
  'current_link_speed', 'current_link_width', 'secondary_bus_number', and
  'subordinate_bus_number' sysfs files (Brian Norris)

* pci/pm:
  PCI/sysfs: Ensure devices are powered for config reads
  PCI/PM: Skip resuming to D0 if device is disconnected

5 weeks agoMerge branch 'pci/p2pdma'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:10 +0000 (12:13 -0500)]
Merge branch 'pci/p2pdma'

- Free struct p2p_pgmap, not a member within it, in the
  pci_p2pdma_add_resource() error path (Sungho Kim)

- Make pci_has_p2pmem() static (Leon Romanovsky)

* pci/p2pdma:
  PCI/P2PDMA: Reduce scope of pci_has_p2pmem()
  PCI/P2PDMA: Fix incorrect pointer usage in devm_kfree() call

5 weeks agoMerge branch 'pci/of'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:10 +0000 (12:13 -0500)]
Merge branch 'pci/of'

- Leave parent unit address 0 in 'interrupt-map' so we can build this
  property even when interrupt controllers lack 'reg' properties (Lorenzo
  Pieralisi)

* pci/of:
  PCI: of: Update parent unit address generation in of_pci_prop_intr_map()

5 weeks agoMerge branch 'pci/msi'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:09 +0000 (12:13 -0500)]
Merge branch 'pci/msi'

- Add quirk to disable MSI on RDC PCI to PCIe bridges (Marcos Del Sol
  Vives)

* pci/msi:
  PCI: Disable MSI on RDC PCI to PCIe bridges

5 weeks agoMerge branch 'pci/hotplug'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:08 +0000 (12:13 -0500)]
Merge branch 'pci/hotplug'

- Clean up whitespace in messages (Colin Ian King)

* pci/hotplug:
  PCI: hotplug: Clean up spaces in messages

5 weeks agoMerge branch 'pci/enumeration'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:08 +0000 (12:13 -0500)]
Merge branch 'pci/enumeration'

- Use PCI_HEADER_TYPE_* defines, not hard-coded values (Ilpo Järvinen)

- Clean up early_dump_pci_device() to avoid hard-coded values (Ilpo
  Järvinen)

- Clean up pci_scan_child_bus_extend() loop to avoid hard-coded values
  (Ilpo Järvinen)

- Add a Xeon 6 quirk to disable Extended Tags and limit Max Read Request
  Size to 128B to avoid a performance issue (Ilpo Järvinen)

* pci/enumeration:
  PCI: Add Extended Tag + MRRS quirk for Xeon 6
  PCI: Clean up pci_scan_child_bus_extend() loop
  PCI: Clean up early_dump_pci_device()
  PCI: Use header type defines in pci_setup_device()

5 weeks agoMerge branch 'pci/aspm'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:07 +0000 (12:13 -0500)]
Merge branch 'pci/aspm'

- Enable all ClockPM and ASPM states for devicetree platforms, since
  there's typically no firmware that enables ASPM (Manivannan Sadhasivam)

- Remove the qcom code that enabled ASPM (Manivannan Sadhasivam)

* pci/aspm:
  PCI: qcom: Remove custom ASPM enablement code
  PCI/ASPM: Enable all ClockPM and ASPM states for devicetree platforms

5 weeks agoMerge branch 'pci/aer'
Bjorn Helgaas [Fri, 3 Oct 2025 17:13:07 +0000 (12:13 -0500)]
Merge branch 'pci/aer'

- Allow drivers to request a Bus Reset on Non-Fatal Errors (Lukas Wunner)

- Send uevents for subordinate devices (not the bridge) on failure to
  recover from errors on the subordinate devices (Lukas Wunner)

- Notify drivers by calling their err_handler.error_detected() callback on
  failure to recover (Lukas Wunner)

- Update device error_state earlier after reset to align AER and EEH error
  recovery (Lukas Wunner)

- Remove obsolete comments about .link_reset(), which was removed long ago
  (Lukas Wunner)

- Emit a uevent for the beginning of error recovery if driver requests a
  reset (Niklas Schnelle)

- Emit error recover uevents on s390 as is done by EEH and AER (Niklas
  Schnelle)

- Include error_detected() result in AER uevent to align with corresponding
  uevents from EEH and s390 (Niklas Schnelle)

- Decode new errors added in PCIe r6.0 (Lukas Wunner)

- Print TLP Log for errors introduced since PCIe spec r1.1 (Lukas Wunner)

- Check for allocation failure in pci_aer_init() (Vernon Yang)

- Update error recovery documentation to match the current code and use
  consistent nomenclature (Lukas Wunner)

- Avoid NULL pointer dereference in aer_ratelimit() when GHES error info
  points to a device with no AER Capability (Breno Leitao)

* pci/aer:
  PCI/AER: Avoid NULL pointer dereference in aer_ratelimit()
  Documentation: PCI: Fix typos
  Documentation: PCI: Tidy error recovery doc's PCIe nomenclature
  Documentation: PCI: Amend error recovery doc with DPC/AER specifics
  Documentation: PCI: Sync error recovery doc with code
  Documentation: PCI: Sync AER doc with code
  PCI/AER: Fix NULL pointer access by aer_info
  PCI/AER: Print TLP Log for errors introduced since PCIe r1.1
  PCI/AER: Support errors introduced by PCIe r6.0
  powerpc/eeh: Use result of error_detected() in uevent
  s390/pci: Use pci_uevent_ers() in PCI recovery
  PCI/AER: Fix missing uevent on recovery when a reset is requested
  PCI/ERR: Remove remnants of .link_reset() callback
  PCI/ERR: Update device error_state already after reset
  PCI/ERR: Notify drivers on failure to recover
  PCI/ERR: Fix uevent on failure to recover
  PCI/AER: Allow drivers to opt in to Bus Reset on Non-Fatal Errors

5 weeks agoPCI/AER: Avoid NULL pointer dereference in aer_ratelimit()
Breno Leitao [Mon, 29 Sep 2025 09:15:47 +0000 (02:15 -0700)]
PCI/AER: Avoid NULL pointer dereference in aer_ratelimit()

When platform firmware supplies error information to the OS, e.g., via the
ACPI APEI GHES mechanism, it may identify an error source device that
doesn't advertise an AER Capability and therefore dev->aer_info, which
contains AER stats and ratelimiting data, is NULL.

pci_dev_aer_stats_incr() already checks dev->aer_info for NULL, but
aer_ratelimit() did not, leading to NULL pointer dereferences like this one
from the URL below:

  {1}[Hardware Error]: Hardware error from APEI Generic Hardware Error Source: 0
  {1}[Hardware Error]: event severity: corrected
  {1}[Hardware Error]:   device_id: 0000:00:00.0
  {1}[Hardware Error]:   vendor_id: 0x8086, device_id: 0x2020
  {1}[Hardware Error]:   aer_cor_status: 0x00001000, aer_cor_mask: 0x00002000
  BUG: kernel NULL pointer dereference, address: 0000000000000264
  RIP: 0010:___ratelimit+0xc/0x1b0
  pci_print_aer+0x141/0x360
  aer_recover_work_func+0xb5/0x130

[8086:2020] is an Intel "Sky Lake-E DMI3 Registers" device that claims to
be a Root Port but does not advertise an AER Capability.

Add a NULL check in aer_ratelimit() to avoid the NULL pointer dereference.
Note that this also prevents ratelimiting these events from GHES.

Fixes: a57f2bfb4a5863 ("PCI/AER: Ratelimit correctable and non-fatal error logging")
Link: https://lore.kernel.org/r/buduna6darbvwfg3aogl5kimyxkggu3n4romnmq6sozut6axeu@clnx7sfsy457/
Signed-off-by: Breno Leitao <leitao@debian.org>
[bhelgaas: add crash details to commit log]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20250929-aer_crash_2-v1-1-68ec4f81c356@debian.org
5 weeks agoMAINTAINERS: Add entry for ST STM32MP25 PCIe drivers
Christian Bruel [Wed, 20 Aug 2025 07:54:07 +0000 (09:54 +0200)]
MAINTAINERS: Add entry for ST STM32MP25 PCIe drivers

Add myself as maintainer of STM32MP25 PCIe host and PCIe endpoint drivers.

Signed-off-by: Christian Bruel <christian.bruel@foss.st.com>
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250820075411.1178729-8-christian.bruel@foss.st.com
5 weeks agoPCI: stm32-ep: Add PCIe Endpoint support for STM32MP25
Christian Bruel [Wed, 20 Aug 2025 07:54:06 +0000 (09:54 +0200)]
PCI: stm32-ep: Add PCIe Endpoint support for STM32MP25

Add driver to configure the STM32MP25 SoC PCIe controller based on the
DesignWare PCIe core in endpoint mode. Controller support 2.5 and 5 GT/s
data rates and uses the common reference clock provided by the host.

The PCIe core_clk receives the pipe0_clk from the ComboPHY as input,
and the ComboPHY PLL must be locked for pipe0_clk to be ready.
Consequently, PCIe core registers cannot be accessed until the ComboPHY is
fully initialised and REFCLK is enabled and ready.

Signed-off-by: Christian Bruel <christian.bruel@foss.st.com>
[mani: reworded description]
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
[bhelgaas: squash in https://patch.msgid.link/20250902122641.269725-1-christian.bruel@foss.st.com
to remove redundant link_status checks]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250820075411.1178729-7-christian.bruel@foss.st.com
5 weeks agodt-bindings: PCI: Add STM32MP25 PCIe Endpoint bindings
Christian Bruel [Wed, 20 Aug 2025 07:54:05 +0000 (09:54 +0200)]
dt-bindings: PCI: Add STM32MP25 PCIe Endpoint bindings

STM32MP25 PCIe Controller is based on the DesignWare core configured as
endpoint mode from the SYSCFG register.

Signed-off-by: Christian Bruel <christian.bruel@foss.st.com>
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Link: https://patch.msgid.link/20250820075411.1178729-6-christian.bruel@foss.st.com
5 weeks agoPCI: stm32: Add PCIe host support for STM32MP25
Christian Bruel [Wed, 20 Aug 2025 07:54:04 +0000 (09:54 +0200)]
PCI: stm32: Add PCIe host support for STM32MP25

Add driver for the STM32MP25 SoC PCIe controller based on the DesignWare
PCIe core. Controller supports 2.5 and 5 GT/s data rates, MSI via GICv2m,
Single Virtual Channel, Single Function and WAKE# GPIO.

Signed-off-by: Christian Bruel <christian.bruel@foss.st.com>
[mani: reworded description]
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
[bhelgaas: squash error handling cleanup from Christophe JAILLET
<christophe.jaillet@wanadoo.fr>:
https://patch.msgid.link/e69ade3edcec4da2d5bfc66e0d03bbcb5a857021.1759169956.git.christophe.jaillet@wanadoo.fr]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250820075411.1178729-5-christian.bruel@foss.st.com
6 weeks agoPCI: j721e: Fix incorrect error message in probe()
Alok Tiwari [Fri, 5 Sep 2025 21:14:34 +0000 (14:14 -0700)]
PCI: j721e: Fix incorrect error message in probe()

The probe() function prints "pm_runtime_get_sync failed" when
j721e_pcie_ctrl_init() returns an error. This is misleading since
the failure is not from pm_runtime, but from the controller init
routine. Update the error message to correctly reflect the source.

No functional changes.

Fixes: f3e25911a430 ("PCI: j721e: Add TI J721E PCIe driver")
Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Siddharth Vadapalli <s-vadapalli@ti.com>
Link: https://patch.msgid.link/20250905211436.3048282-1-alok.a.tiwari@oracle.com
6 weeks agoPCI: keystone: Use devm_request_irq() to free "ks-pcie-error-irq" on exit
Siddharth Vadapalli [Fri, 12 Sep 2025 10:07:58 +0000 (15:37 +0530)]
PCI: keystone: Use devm_request_irq() to free "ks-pcie-error-irq" on exit

Commit under Fixes introduced the IRQ handler for "ks-pcie-error-irq".
The interrupt is acquired using "request_irq()" but is never freed if
the driver exits due to an error. Although the section in the driver that
invokes "request_irq()" has moved around over time, the issue hasn't been
addressed until now.

Fix this by using "devm_request_irq()" which automatically frees the
interrupt if the driver exits.

Fixes: 025dd3daeda7 ("PCI: keystone: Add error IRQ handler")
Reported-by: Jiri Slaby <jirislaby@kernel.org>
Closes: https://lore.kernel.org/r/3d3a4b52-e343-42f3-9d69-94c259812143@kernel.org
Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20250912100802.3136121-2-s-vadapalli@ti.com
6 weeks agodt-bindings: PCI: qcom,pcie-x1e80100: Set clocks minItems for the fifth Glymur PCIe...
Qiang Yu [Fri, 19 Sep 2025 14:23:25 +0000 (19:53 +0530)]
dt-bindings: PCI: qcom,pcie-x1e80100: Set clocks minItems for the fifth Glymur PCIe Controller

On the Qualcomm Glymur platform, the fifth PCIe host is compatible with
the DWC controller present on the X1E80100 platform, but does not have
cnoc_sf_axi clock. Hence, set minItems of clocks and clock-names to six.

Signed-off-by: Qiang Yu <qiang.yu@oss.qualcomm.com>
Signed-off-by: Pankaj Patil <pankaj.patil@oss.qualcomm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rob Herring (Arm) <robh@kernel.org>
Link: https://patch.msgid.link/20250919142325.1090059-1-pankaj.patil@oss.qualcomm.com
6 weeks agoPCI: dwc: Support 16-lane operation
Konrad Dybcio [Fri, 26 Sep 2025 12:22:45 +0000 (14:22 +0200)]
PCI: dwc: Support 16-lane operation

Some hosts support 16 lanes of PCIe. Make num-lanes accept that number.

Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250926-topic-pcie_16ln-v1-1-c249acc18790@oss.qualcomm.com
6 weeks agoPCI: Add lockdep assertion in pci_stop_and_remove_bus_device()
Niklas Schnelle [Tue, 26 Aug 2025 08:52:09 +0000 (10:52 +0200)]
PCI: Add lockdep assertion in pci_stop_and_remove_bus_device()

Removing a PCI devices requires holding pci_rescan_remove_lock. Prompted by
this being missed in sriov_disable() and going unnoticed since its
inception, add a lockdep assert so this doesn't get missed again in the
future.

Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Reviewed-by: Julian Ruess <julianr@linux.ibm.com>
Link: https://patch.msgid.link/20250826-pci_fix_sriov_disable-v1-2-2d0bc938f2a3@linux.ibm.com
6 weeks agoPCI/IOV: Add PCI rescan-remove locking when enabling/disabling SR-IOV
Niklas Schnelle [Tue, 26 Aug 2025 08:52:08 +0000 (10:52 +0200)]
PCI/IOV: Add PCI rescan-remove locking when enabling/disabling SR-IOV

Before disabling SR-IOV via config space accesses to the parent PF,
sriov_disable() first removes the PCI devices representing the VFs.

Since commit 9d16947b7583 ("PCI: Add global pci_lock_rescan_remove()")
such removal operations are serialized against concurrent remove and
rescan using the pci_rescan_remove_lock. No such locking was ever added
in sriov_disable() however. In particular when commit 18f9e9d150fc
("PCI/IOV: Factor out sriov_add_vfs()") factored out the PCI device
removal into sriov_del_vfs() there was still no locking around the
pci_iov_remove_virtfn() calls.

On s390 the lack of serialization in sriov_disable() may cause double
remove and list corruption with the below (amended) trace being observed:

  PSW:  0704c00180000000 0000000c914e4b38 (klist_put+56)
  GPRS: 000003800313fb48 0000000000000000 0000000100000001 0000000000000001
00000000f9b520a8 0000000000000000 0000000000002fbd 00000000f4cc9480
0000000000000001 0000000000000000 0000000000000000 0000000180692828
00000000818e8000 000003800313fe2c 000003800313fb20 000003800313fad8
  #0 [3800313fb20] device_del at c9158ad5c
  #1 [3800313fb88] pci_remove_bus_device at c915105ba
  #2 [3800313fbd0] pci_iov_remove_virtfn at c9152f198
  #3 [3800313fc28] zpci_iov_remove_virtfn at c90fb67c0
  #4 [3800313fc60] zpci_bus_remove_device at c90fb6104
  #5 [3800313fca0] __zpci_event_availability at c90fb3dca
  #6 [3800313fd08] chsc_process_sei_nt0 at c918fe4a2
  #7 [3800313fd60] crw_collect_info at c91905822
  #8 [3800313fe10] kthread at c90feb390
  #9 [3800313fe68] __ret_from_fork at c90f6aa64
  #10 [3800313fe98] ret_from_fork at c9194f3f2.

This is because in addition to sriov_disable() removing the VFs, the
platform also generates hot-unplug events for the VFs. This being the
reverse operation to the hotplug events generated by sriov_enable() and
handled via pdev->no_vf_scan. And while the event processing takes
pci_rescan_remove_lock and checks whether the struct pci_dev still exists,
the lack of synchronization makes this checking racy.

Other races may also be possible of course though given that this lack of
locking persisted so long observable races seem very rare. Even on s390 the
list corruption was only observed with certain devices since the platform
events are only triggered by config accesses after the removal, so as long
as the removal finished synchronously they would not race. Either way the
locking is missing so fix this by adding it to the sriov_del_vfs() helper.

Just like PCI rescan-remove, locking is also missing in sriov_add_vfs()
including for the error case where pci_stop_and_remove_bus_device() is
called without the PCI rescan-remove lock being held. Even in the non-error
case, adding new PCI devices and buses should be serialized via the PCI
rescan-remove lock. Add the necessary locking.

Fixes: 18f9e9d150fc ("PCI/IOV: Factor out sriov_add_vfs()")
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Reviewed-by: Farhan Ali <alifm@linux.ibm.com>
Reviewed-by: Julian Ruess <julianr@linux.ibm.com>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20250826-pci_fix_sriov_disable-v1-1-2d0bc938f2a3@linux.ibm.com
6 weeks agoPCI: rcar-host: Convert struct rcar_msi mask_lock into raw spinlock
Marek Vasut [Tue, 9 Sep 2025 16:26:25 +0000 (18:26 +0200)]
PCI: rcar-host: Convert struct rcar_msi mask_lock into raw spinlock

The rcar_msi_irq_unmask() function may be called from a PCI driver
request_threaded_irq() function. This triggers kernel/irq/manage.c
__setup_irq() which locks raw spinlock &desc->lock descriptor lock
and with that descriptor lock held, calls rcar_msi_irq_unmask().

Since the &desc->lock descriptor lock is a raw spinlock, and the rcar_msi
.mask_lock is not a raw spinlock, this setup triggers 'BUG: Invalid wait
context' with CONFIG_PROVE_RAW_LOCK_NESTING=y.

Use scoped_guard() to simplify the locking.

Fixes: 83ed8d4fa656 ("PCI: rcar: Convert to MSI domains")
Reported-by: Duy Nguyen <duy.nguyen.rh@renesas.com>
Reported-by: Thuan Nguyen <thuan.nguyen-hong@banvien.com.vn>
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Marc Zyngier <maz@kernel.org>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20250909162707.13927-2-marek.vasut+renesas@mailbox.org
6 weeks agoPCI: tegra194: Rename 'root_bus' to 'root_port_bus' in tegra_pcie_downstream_dev_to_D0()
Manivannan Sadhasivam [Mon, 22 Sep 2025 08:10:57 +0000 (13:40 +0530)]
PCI: tegra194: Rename 'root_bus' to 'root_port_bus' in tegra_pcie_downstream_dev_to_D0()

In tegra_pcie_downstream_dev_to_D0(), PCI devices are transitioned to D0
state. For iterating over the devices, first the downstream bus of the Root
Port is searched from the root bus. But the name of the variable that holds
the Root Port downstream bus is named as 'root_bus', which is wrong.

Rename the variable to 'root_port_bus'. Also, move the comment on 'bringing
the devices to D0' to where the state is set exactly.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250922081057.15209-1-mani@kernel.org
6 weeks agoPCI: tegra: Convert struct tegra_msi mask_lock into raw spinlock
Marek Vasut [Mon, 22 Sep 2025 15:07:48 +0000 (17:07 +0200)]
PCI: tegra: Convert struct tegra_msi mask_lock into raw spinlock

The tegra_msi_irq_unmask() function may be called from a PCI driver
request_threaded_irq() function. This triggers kernel/irq/manage.c
__setup_irq() which locks raw spinlock &desc->lock descriptor lock
and with that descriptor lock held, calls tegra_msi_irq_unmask().

Since the &desc->lock descriptor lock is a raw spinlock, and the tegra_msi
.mask_lock is not a raw spinlock, this setup triggers 'BUG: Invalid wait
context' with CONFIG_PROVE_RAW_LOCK_NESTING=y.

Use scoped_guard() to simplify the locking.

Fixes: 2c99e55f7955 ("PCI: tegra: Convert to MSI domains")
Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
Closes: https://patchwork.kernel.org/project/linux-pci/patch/20250909162707.13927-2-marek.vasut+renesas@mailbox.org/#26574451
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20250922150811.88450-1-marek.vasut+renesas@mailbox.org
6 weeks agoPCI: rcar-gen4: Fix inverted break condition in PHY initialization
Marek Vasut [Mon, 15 Sep 2025 23:58:40 +0000 (01:58 +0200)]
PCI: rcar-gen4: Fix inverted break condition in PHY initialization

R-Car V4H Reference Manual R19UH0186EJ0130 Rev.1.30 Apr. 21, 2025 page 4581
Figure 104.3b Initial Setting of PCIEC(example), third quarter of the
figure indicates that register 0xf8 should be polled until bit 18 becomes
set to 1.

Register 0xf8, bit 18 is 0 immediately after write to PCIERSTCTRL1 and is
set to 1 in less than 1 ms afterward. The current readl_poll_timeout()
break condition is inverted and returns when register 0xf8, bit 18 is set
to 0, which in most cases means immediately. In case
CONFIG_DEBUG_LOCK_ALLOC=y, the timing changes just enough for the first
readl_poll_timeout() poll to already read register 0xf8, bit 18 as 1 and
afterward never read register 0xf8, bit 18 as 0, which leads to timeout
and failure to start the PCIe controller.

Fix this by inverting the poll condition to match the reference manual
initialization sequence.

Fixes: faf5a975ee3b ("PCI: rcar-gen4: Add support for R-Car V4H")
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://patch.msgid.link/20250915235910.47768-1-marek.vasut+renesas@mailbox.org
6 weeks agoPCI: rcar-gen4: Assure reset occurs before DBI access
Marek Vasut [Wed, 24 Sep 2025 00:55:45 +0000 (02:55 +0200)]
PCI: rcar-gen4: Assure reset occurs before DBI access

Assure the reset is latched and the core is ready for DBI access. On R-Car
V4H, the PCIe reset is asynchronous and does not take effect immediately,
but needs a short time to complete. In case DBI access happens in that
short time, that access generates an SError. Make sure that condition can
never happen, read back the state of the reset, which should turn the
asynchronous reset into a synchronous one, and wait a little over 1ms to
add additional safety margin.

Fixes: 0d0c551011df ("PCI: rcar-gen4: Add R-Car Gen4 PCIe controller support for host mode")
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://patch.msgid.link/20250924005610.96484-1-marek.vasut+renesas@mailbox.org
6 weeks agoPCI: rcar-gen4: Add missing 1ms delay after PWR reset assertion
Marek Vasut [Fri, 19 Sep 2025 13:45:58 +0000 (15:45 +0200)]
PCI: rcar-gen4: Add missing 1ms delay after PWR reset assertion

R-Car V4H Reference Manual R19UH0186EJ0130 Rev.1.30 Apr. 21, 2025 page 585
Figure 9.3.2 Software Reset flow (B) indicates that for peripherals in HSC
domain, after reset has been asserted by writing a matching reset bit into
register SRCR, it is mandatory to wait 1ms.

Because it is the controller driver which can determine whether or not the
controller is in HSC domain based on its compatible string, add the missing
delay in the controller driver.

This 1ms delay is documented on R-Car V4H and V4M; it is currently unclear
whether S4 is affected as well. This patch does apply the extra delay on
R-Car S4 as well.

Fixes: 0d0c551011df ("PCI: rcar-gen4: Add R-Car Gen4 PCIe controller support for host mode")
Suggested-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
[mani: added the missing r-b tag from Krzysztof]
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Link: https://patch.msgid.link/20250919134644.208098-1-marek.vasut+renesas@mailbox.org
6 weeks agoPCI: Set up bridge resources earlier
Ilpo Järvinen [Wed, 24 Sep 2025 13:42:27 +0000 (16:42 +0300)]
PCI: Set up bridge resources earlier

Bridge windows are read twice from PCI Config Space, the first time from
pci_read_bridge_windows(), which does not set up the device's resources.
This causes problems down the road as child resources of the bridge cannot
check whether they reside within the bridge window or not.

Set up the bridge windows already in pci_read_bridge_windows().

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250924134228.1663-2-ilpo.jarvinen@linux.intel.com
6 weeks agoPCI: rcar-host: Drop PMSR spinlock
Marek Vasut [Tue, 9 Sep 2025 16:26:24 +0000 (18:26 +0200)]
PCI: rcar-host: Drop PMSR spinlock

The pmsr_lock spinlock used to be necessary to synchronize access to the
PMSR register, because that access could have been triggered from either
config space access in rcar_pcie_config_access() or an exception handler
rcar_pcie_aarch32_abort_handler().

The rcar_pcie_aarch32_abort_handler() case is no longer applicable since
commit 6e36203bc14c ("PCI: rcar: Use PCI_SET_ERROR_RESPONSE after read
which triggered an exception"), which performs more accurate, controlled
invocation of the exception, and a fixup.

This leaves rcar_pcie_config_access() as the only call site from which
rcar_pcie_wakeup() is called. The rcar_pcie_config_access() can only be
called from the controller struct pci_ops .read and .write callbacks,
and those are serialized in drivers/pci/access.c using raw spinlock
'pci_lock' . It should be noted that CONFIG_PCI_LOCKLESS_CONFIG is never
set on this platform.

Since the 'pci_lock' is a raw spinlock , and the 'pmsr_lock' is not a
raw spinlock, this constellation triggers 'BUG: Invalid wait context'
with CONFIG_PROVE_RAW_LOCK_NESTING=y .

Remove the pmsr_lock to fix the locking.

Fixes: a115b1bd3af0 ("PCI: rcar: Add L1 link state fix into data abort hook")
Reported-by: Duy Nguyen <duy.nguyen.rh@renesas.com>
Reported-by: Thuan Nguyen <thuan.nguyen-hong@banvien.com.vn>
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20250909162707.13927-1-marek.vasut+renesas@mailbox.org
6 weeks agoPCI: dwc: Support ECAM mechanism by enabling iATU 'CFG Shift Feature'
Krishna Chaitanya Chundru [Tue, 23 Sep 2025 11:26:54 +0000 (16:56 +0530)]
PCI: dwc: Support ECAM mechanism by enabling iATU 'CFG Shift Feature'

Designware databook r5.20a, sec 3.10.10.3 documents the 'CFG Shift Feature'
of the internal Address Translation Unit (iATU). When this feature is
enabled, it shifts/maps the BDF contained in the bits [27:12] of the target
address in MEM TLP to become BDF of the CFG TLP. This essentially
implements the Enhanced Configuration Address Mapping (ECAM) mechanism as
defined in PCIe r6.0, sec 7.2.2.

Currently, the driver is not making use of this CFG shift feature, thereby
creating the iATU outbound map for each config access to the devices,
causing latency and wasting CPU cycles.

So to avoid this, configure the controller to enable CFG shift feature by
enabling the 'CFG Shift' bit of the 'iATU Control 2 Register'.

As a result of enabling CFG shift (ECAM), there is no longer a need to map
the DBI register space separately as the DBI region falls under the
'config' space used for ECAM (as DBI is used to access the Root Port).

For enabling ECAM using CFG shift, the platform has to satisfy following
requirements:

  1. Size of the 'config' memory space to be used as ECAM memory should be
     able to accommodate the number of buses defined in the 'bus-range'
     property of the host bridge DT node.

  2. The 'config' memory space should be 256 MiB aligned. This requirement
     comes from PCIe r6.0, sec 7.2.2, which says the base address of ECAM
     memory should be aligned to a 2^(n+20) byte address boundary. For the
     DWC cores, n is 8, so this results in 2^28 byte alignment requirement.

It should be noted that some DWC vendor glue drivers like pcie-al may use
their own ECAM mechanism. For those controllers, set
'dw_pcie_rp::native_ecam' flag and skip enabling the CFG Shift feature in
the DWC core.

Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
[mani: code split, reworded subject/description, comment, native_ecam flag]
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Link: https://patch.msgid.link/20250923-controller-dwc-ecam-v10-4-e84390ba75fa@kernel.org
6 weeks agoPCI: qcom: Prepare for the DWC ECAM enablement
Krishna Chaitanya Chundru [Tue, 23 Sep 2025 11:26:53 +0000 (16:56 +0530)]
PCI: qcom: Prepare for the DWC ECAM enablement

To support the DWC ECAM mechanism, prepare the driver by performing below
configurations:

  1. Since the ELBI region will be covered by the ECAM 'config' space,
     override the 'elbi_base' with the address derived from 'dbi_base' and
     the offset from PARF_SLV_DBI_ELBI register.

  2. Block the transactions from the host bridge to devices other than Root
     Port on the root bus to return all F's. This is required when the 'CFG
     Shift Feature' of iATU is enabled.

Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
[mani: code split, reworded subject/description and comments]
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Link: https://patch.msgid.link/20250923-controller-dwc-ecam-v10-3-e84390ba75fa@kernel.org
6 weeks agoPCI: dwc: Prepare the driver for enabling ECAM mechanism using iATU 'CFG Shift Feature'
Krishna Chaitanya Chundru [Tue, 23 Sep 2025 11:26:52 +0000 (16:56 +0530)]
PCI: dwc: Prepare the driver for enabling ECAM mechanism using iATU 'CFG Shift Feature'

In order to enable PCIe ECAM mechanism in DWC driver as per the 'CFG Shift
Feature' documented in Designware databook r5.20a, sec 3.10.10.3, prepare
the driver to handle the one time iATU setup and creating ECAM window.

Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
[mani: splitted the preparatory code into a separate commit for bisectability]
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Link: https://patch.msgid.link/20250923-controller-dwc-ecam-v10-2-e84390ba75fa@kernel.org
6 weeks agoPCI: dwc: Add support for ELBI resource mapping
Krishna Chaitanya Chundru [Tue, 23 Sep 2025 11:26:51 +0000 (16:56 +0530)]
PCI: dwc: Add support for ELBI resource mapping

External Local Bus Interface (ELBI) is an optional register space for all
DWC IPs containing the vendor specific registers. There is no need for the
vendor glue drivers to fetch and map the ELBI region separately.

Hence, optionally fetch and map the resource from DT in the DWC core. This
also warrants dropping the corresponding code from glue drivers. Hence,
drop the ELBI resource fetch and map logic from glue drivers and convert
them to use 'dw_pci::elbi_base'.

Note that the pcie-qcom-ep driver used devm_pci_remap_cfg_resource() to map
the ELBI resource previously. But it was a mistake since
devm_pci_remap_cfg_resource() should only be used for mapping the PCIe
config space region as it maps the region as Non-Posted. As ELBI is used to
hold vendor specific registers, there is no need to map the region as
Non-Posted. With this conversion, the region will get mapped as normal MMIO
memory.

Suggested-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
[mani: removed elbi override, converted glue drivers and reworded description]
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Link: https://patch.msgid.link/20250923-controller-dwc-ecam-v10-1-e84390ba75fa@kernel.org
6 weeks agoPCI: Don't print stale information about resource
Ilpo Järvinen [Wed, 24 Sep 2025 13:56:41 +0000 (16:56 +0300)]
PCI: Don't print stale information about resource

pbus_size_mem() logs the bridge window resource using pci_info() before the
start and end fields of the resource have been updated which then prints
stale information.

Set resource addresses earlier to make understanding logs easier.
Regrettably, this results in setting the addresses multiple times but that
seems unavoidable.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250924135641.3399-1-ilpo.jarvinen@linux.intel.com
6 weeks agoPCI: tegra194: Handle errors in BPMP response
Vidya Sagar [Mon, 22 Sep 2025 14:08:26 +0000 (16:08 +0200)]
PCI: tegra194: Handle errors in BPMP response

The return value from tegra_bpmp_transfer() indicates the success or
failure of the IPC transaction with BPMP. If the transaction succeeded, we
also need to check the actual command's result code.

If we don't have error handling for tegra_bpmp_transfer(), we will set the
pcie->ep_state to EP_STATE_ENABLED even when the tegra_bpmp_transfer()
command fails. Thus, the pcie->ep_state will get out of sync with reality,
and any further PERST# assert + deassert will be a no-op and will not
trigger the hardware initialization sequence.

This is because pex_ep_event_pex_rst_deassert() checks the current
pcie->ep_state, and does nothing if the current state is already
EP_STATE_ENABLED.

Thus, it is important to have error handling for tegra_bpmp_transfer(),
such that the pcie->ep_state can not get out of sync with reality, so that
we will try to initialize the hardware not only during the first PERST#
assert + deassert, but also during any succeeding PERST# assert + deassert.

One example where this fix is needed is when using a rock5b as host.
During the initial PERST# assert + deassert (triggered by the bootloader on
the rock5b) pex_ep_event_pex_rst_deassert() will get called, but for some
unknown reason, the tegra_bpmp_transfer() call to initialize the PHY fails.
Once Linux has been loaded on the rock5b, the PCIe driver will once again
assert + deassert PERST#. However, without tegra_bpmp_transfer() error
handling, this second PERST# assert + deassert will not trigger the
hardware initialization sequence.

With tegra_bpmp_transfer() error handling, the second PERST# assert +
deassert will once again trigger the hardware to be initialized and this
time the tegra_bpmp_transfer() succeeds.

Fixes: c57247f940e8 ("PCI: tegra: Add support for PCIe endpoint mode in Tegra194")
Signed-off-by: Vidya Sagar <vidyas@nvidia.com>
[cassel: improve commit log]
Signed-off-by: Niklas Cassel <cassel@kernel.org>
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Jon Hunter <jonathanh@nvidia.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20250922140822.519796-8-cassel@kernel.org
6 weeks agoPCI: tegra194: Reset BARs when running in PCIe endpoint mode
Niklas Cassel [Mon, 22 Sep 2025 14:08:25 +0000 (16:08 +0200)]
PCI: tegra194: Reset BARs when running in PCIe endpoint mode

Tegra already defines all BARs except BAR0 as BAR_RESERVED.  This is
sufficient for pci-epf-test to not allocate backing memory and to not call
set_bar() for those BARs. However, marking a BAR as BAR_RESERVED does not
mean that the BAR gets disabled.

The host side driver, pci_endpoint_test, simply does an ioremap for all
enabled BARs and will run tests against all enabled BARs, so it will run
tests against the BARs marked as BAR_RESERVED.

After running the BAR tests (which will write to all enabled BARs), the
inbound address translation is broken. This is because the tegra controller
exposes the ATU Port Logic Structure in BAR4, so when BAR4 is written, the
inbound address translation settings get overwritten.

To avoid this, implement the dw_pcie_ep_ops .init() callback and start off
by disabling all BARs (pci-epf-test will later enable/configure BARs that
are not defined as BAR_RESERVED).

This matches the behavior of other PCIe endpoint drivers: dra7xx, imx6,
layerscape-ep, artpec6, dw-rockchip, qcom-ep, rcar-gen4, and uniphier-ep.

With this, the PCI endpoint kselftest test case CONSECUTIVE_BAR_TEST (which
was specifically made to detect address translation issues) passes.

Fixes: c57247f940e8 ("PCI: tegra: Add support for PCIe endpoint mode in Tegra194")
Signed-off-by: Niklas Cassel <cassel@kernel.org>
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20250922140822.519796-7-cassel@kernel.org
6 weeks agoPCI/sysfs: Ensure devices are powered for config reads
Brian Norris [Wed, 24 Sep 2025 16:57:11 +0000 (09:57 -0700)]
PCI/sysfs: Ensure devices are powered for config reads

The "max_link_width", "current_link_speed", "current_link_width",
"secondary_bus_number", and "subordinate_bus_number" sysfs files all access
config registers, but they don't check the runtime PM state. If the device
is in D3cold or a parent bridge is suspended, we may see -EINVAL, bogus
values, or worse, depending on implementation details.

Wrap these access in pci_config_pm_runtime_{get,put}() like most of the
rest of the similar sysfs attributes.

Notably, "max_link_speed" does not access config registers; it returns a
cached value since d2bd39c0456b ("PCI: Store all PCIe Supported Link
Speeds").

Fixes: 56c1af4606f0 ("PCI: Add sysfs max_link_speed/width, current_link_speed/width, etc")
Signed-off-by: Brian Norris <briannorris@google.com>
Signed-off-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20250924095711.v2.1.Ibb5b6ca1e2c059e04ec53140cd98a44f2684c668@changeid
6 weeks agoPCI: tegra194: Set pci_epc_features::msi_capable to true
Niklas Cassel [Wed, 24 Sep 2025 16:20:52 +0000 (21:50 +0530)]
PCI: tegra194: Set pci_epc_features::msi_capable to true

Since the driver supports MSI, set the flag to true. This helps
pci_endpoint_test to use the optimal IRQ type when using
PCITEST_IRQ_TYPE_AUTO.

Signed-off-by: Niklas Cassel <cassel@kernel.org>
[mani: splitted this change from the bug fix]
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Link: https://patch.msgid.link/20250922140822.519796-6-cassel@kernel.org
6 weeks agoPCI: tegra194: Fix broken tegra_pcie_ep_raise_msi_irq()
Niklas Cassel [Mon, 22 Sep 2025 14:08:24 +0000 (16:08 +0200)]
PCI: tegra194: Fix broken tegra_pcie_ep_raise_msi_irq()

The pci_epc_raise_irq() supplies a MSI or MSI-X interrupt number in range
(1-N), as per the pci_epc_raise_irq() kdoc, where N is 32 for MSI.

But tegra_pcie_ep_raise_msi_irq() incorrectly uses the interrupt number as
the MSI vector. This causes wrong MSI vector to be triggered, leading to
the failure of PCI endpoint Kselftest MSI_TEST test case.

To fix this issue, convert the interrupt number to MSI vector.

Fixes: c57247f940e8 ("PCI: tegra: Add support for PCIe endpoint mode in Tegra194")
Signed-off-by: Niklas Cassel <cassel@kernel.org>
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20250922140822.519796-6-cassel@kernel.org
6 weeks agoPCI: qcom: Remove custom ASPM enablement code
Manivannan Sadhasivam [Mon, 22 Sep 2025 16:16:45 +0000 (21:46 +0530)]
PCI: qcom: Remove custom ASPM enablement code

Since the PCI subsystem has started enabling all ASPM states for all
devicetree based platforms, the ASPM enablement code from this driver can
now be dropped.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250922-pci-dt-aspm-v2-2-2a65cf84e326@oss.qualcomm.com
6 weeks agoPCI/ASPM: Enable all ClockPM and ASPM states for devicetree platforms
Manivannan Sadhasivam [Mon, 22 Sep 2025 16:16:44 +0000 (21:46 +0530)]
PCI/ASPM: Enable all ClockPM and ASPM states for devicetree platforms

So far, the PCI subsystem has honored the ASPM and Clock PM states set by
the BIOS (through LNKCTL) during device initialization, if it relies on the
default state selected using:

* Kconfig: CONFIG_PCIEASPM_DEFAULT=y, or
* cmdline: "pcie_aspm=off", or
* FADT: ACPI_FADT_NO_ASPM

This was done conservatively to avoid issues with the buggy devices that
advertise ASPM capabilities, but behave erratically if the ASPM states are
enabled. So the PCI subsystem ended up trusting the BIOS to enable only the
ASPM states that were known to work for the devices.

But this turned out to be a problem for devicetree platforms, especially
the ARM based devicetree platforms powering Embedded and *some* Compute
devices as they tend to run without any standard BIOS. So the ASPM states
on these platforms were left disabled during boot and the PCI subsystem
never bothered to enable them, unless the user has forcefully enabled the
ASPM states through Kconfig, cmdline, and sysfs or the device drivers
themselves, enabling the ASPM states through pci_enable_link_state() APIs.

This caused runtime power issues on those platforms. So a couple of
approaches were tried to mitigate this BIOS dependency without user
intervention by enabling the ASPM states in the PCI controller drivers
after device enumeration, and overriding the ASPM/Clock PM states
by the PCI controller drivers through an API before enumeration.

But it has been concluded that none of these mitigations should really be
required and the PCI subsystem should enable the ASPM states advertised by
the devices without relying on BIOS or the PCI controller drivers. If any
device is found to be misbehaving after enabling ASPM states that they
advertised, then those devices should be quirked to disable the problematic
ASPM/Clock PM states.

In an effort to do so, start by overriding the ASPM and Clock PM states set
by the BIOS for devicetree platforms first. Separate helper functions are
introduced to override the BIOS set states by enabling all of them if
of_have_populated_dt() returns true. To aid debugging, print the overridden
ASPM and Clock PM states as well.

In the future, these helpers could be extended to allow other platforms
like VMD, newer ACPI systems with a cutoff year etc... to follow the path.

Link: https://lore.kernel.org/linux-pci/20250828204345.GA958461@bhelgaas
Suggested-by: Bjorn Helgaas <helgaas@kernel.org>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
[bhelgaas: tweak comments and dmesg logs]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250922-pci-dt-aspm-v2-1-2a65cf84e326@oss.qualcomm.com
7 weeks agoPCI/PM: Skip resuming to D0 if device is disconnected
Mario Limonciello [Tue, 9 Sep 2025 03:19:15 +0000 (22:19 -0500)]
PCI/PM: Skip resuming to D0 if device is disconnected

When a device is surprise-removed (e.g., due to a dock unplug), the PCI
core unconfigures all downstream devices and sets their error state to
pci_channel_io_perm_failure. This marks them as disconnected via
pci_dev_is_disconnected().

During device removal, the runtime PM framework may attempt to resume the
device to D0 via pm_runtime_get_sync(), which calls into pci_power_up().
Since the device is already disconnected, this resume attempt is
unnecessary and results in a predictable errors like this, typically when
undocking from a TBT3 or USB4 dock with PCIe tunneling:

  pci 0000:01:00.0: Unable to change power state from D3cold to D0, device inaccessible

Avoid powering up disconnected devices by checking their status early in
pci_power_up() and returning -EIO.

Suggested-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
[bhelgaas: add typical message]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Lukas Wunner <lukas@wunner.de>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
Link: https://patch.msgid.link/20250909031916.4143121-1-superm1@kernel.org
7 weeks agoPCI: tegra194: Fix duplicate PLL disable in pex_ep_event_pex_rst_assert()
Nagarjuna Kristam [Thu, 11 Sep 2025 09:30:22 +0000 (11:30 +0200)]
PCI: tegra194: Fix duplicate PLL disable in pex_ep_event_pex_rst_assert()

During PERST# assertion tegra_pcie_bpmp_set_pll_state() is currently
called twice.

pex_ep_event_pex_rst_assert() should do the opposite of
pex_ep_event_pex_rst_deassert(), so it is obvious that the duplicate
tegra_pcie_bpmp_set_pll_state() is a mistake, and that the duplicate
tegra_pcie_bpmp_set_pll_state() call should instead be a call to
tegra_pcie_bpmp_set_ctrl_state().

With this, the uninitialization sequence also matches that of
tegra_pcie_unconfig_controller().

Fixes: a54e19073718 ("PCI: tegra194: Add Tegra234 PCIe support")
Signed-off-by: Nagarjuna Kristam <nkristam@nvidia.com>
[cassel: improve commit log]
Signed-off-by: Niklas Cassel <cassel@kernel.org>
Link: https://patch.msgid.link/20250911093021.1454385-2-cassel@kernel.org
[mani: added Fixes tag]
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
7 weeks agoPCI: sg2042: Add Sophgo SG2042 PCIe driver
Chen Wang [Fri, 12 Sep 2025 02:36:31 +0000 (10:36 +0800)]
PCI: sg2042: Add Sophgo SG2042 PCIe driver

Add support for PCIe controller in Sophgo SG2042 SoC. The controller uses
the Cadence PCIe core programmed by pcie-cadence* common driver. The PCIe
controller in SG2042 works in host mode only, supporting data rate up to 16
GT/s and lanes up to x16 or x8.

Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
[mani: reworded description and minor code cleanups]
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Link: https://patch.msgid.link/01b0a57cd9dba8bed7c1f2d52997046c2c6f042b.1757643388.git.unicorn_wang@outlook.com
7 weeks agoPCI: cadence: Check for the existence of cdns_pcie::ops before using it
Chen Wang [Fri, 12 Sep 2025 02:36:01 +0000 (10:36 +0800)]
PCI: cadence: Check for the existence of cdns_pcie::ops before using it

cdns_pcie::ops might not be populated by all the Cadence glue drivers. This
is going to be true for the upcoming Sophgo platform which doesn't set the
ops.

Hence, add a check to prevent NULL pointer dereference.

Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
[mani: reworded subject and description]
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Link: https://patch.msgid.link/35182ee1d972dfcd093a964e11205efcebbdc044.1757643388.git.unicorn_wang@outlook.com
7 weeks agodt-bindings: pci: Add Sophgo SG2042 PCIe host
Chen Wang [Fri, 12 Sep 2025 02:35:32 +0000 (10:35 +0800)]
dt-bindings: pci: Add Sophgo SG2042 PCIe host

Add binding for Sophgo SG2042 PCIe host controller.

Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Link: https://patch.msgid.link/2755f145755b6096247c26852b63671a6fea4dbf.1757643388.git.unicorn_wang@outlook.com
7 weeks agoDocumentation: PCI: Fix typos
Emilio Perez [Mon, 18 Aug 2025 02:31:21 +0000 (03:31 +0100)]
Documentation: PCI: Fix typos

The PCIe spec uses "Requester ID", not "requestor ID".  Follow the spec to
avoid confusion.

Signed-off-by: Emilio Perez <emiliopeju@gmail.com>
[bhelgaas: capitalize as a hint that the spec defines this]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250818023121.33427-1-emiliopeju@gmail.com
7 weeks agoPCI: qcom: Move host bridge 'phy' and 'reset' pointers to struct qcom_pcie_port
Manivannan Sadhasivam [Fri, 12 Sep 2025 08:35:02 +0000 (14:05 +0530)]
PCI: qcom: Move host bridge 'phy' and 'reset' pointers to struct qcom_pcie_port

DT binding allows specifying 'phy' and 'reset' properties in both host
bridge and Root Port nodes, though specifying in the host bridge node is
marked as deprecated. Still, the pcie-qcom driver should support both
combinations for maintaining the DT backwards compatibility. For this
purpose, the driver is holding the relevant pointers of these properties in
two structs: struct qcom_pcie_port and struct qcom_pcie.

However, this causes confusion and increases the driver complexity. Hence,
move the pointers from struct qcom_pcie to struct qcom_pcie_port. As a
result, even if these properties are specified in the host bridge node,
the pointers will be stored in struct qcom_pcie_port as if the properties
are specified in a single Root Port node. This logic simplifies the driver
a lot.

Suggested-by: Bjorn Helgaas <helgaas@kernel.org>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Reviewed-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250912-pci-pwrctrl-perst-v3-2-3c0ac62b032c@oss.qualcomm.com
7 weeks agoPCI: Alter misleading recursion to pci_bus_release_bridge_resources()
Ilpo Järvinen [Fri, 29 Aug 2025 13:11:13 +0000 (16:11 +0300)]
PCI: Alter misleading recursion to pci_bus_release_bridge_resources()

Recursing into pci_bus_release_bridge_resources() should not alter rel_type
because it makes no sense to change the release type within the recursion
call chain. A literal "whole_subtree" is passed into the recursion instead
of "rel_type" parameter which is misleading as the release type should
remain the same throughout the entire operation.

This is not a correctness issue because of the preceding if () that only
allows the recursion to happen if rel_type is "whole_subtree". Still,
replace the non-intuitive parameter with direct passing of "rel_type".

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250829131113.36754-25-ilpo.jarvinen@linux.intel.com
7 weeks agoPCI: Pass bridge window to pci_bus_release_bridge_resources()
Ilpo Järvinen [Fri, 29 Aug 2025 13:11:12 +0000 (16:11 +0300)]
PCI: Pass bridge window to pci_bus_release_bridge_resources()

pci_bus_release_bridge_resources() takes type, which is converted into a
bridge window resource in pci_bridge_release_resources().

Find out the correct bridge window for resource whose assignment failed.
Pass that bridge window to pci_bus_release_bridge_resources() instead of
passing the type. When recursing to subordinate, check which bridge windows
have to be released and recurse for each.

For now, use pbus_select_window_for_type() instead of pbus_select_window()
because non-bridge window resources still have their flags reset which
destroys the type information from the struct resource. The struct
pci_dev_resource holds a copy of the flags which are used instead.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250829131113.36754-24-ilpo.jarvinen@linux.intel.com
7 weeks agoPCI: Add pci_setup_one_bridge_window()
Ilpo Järvinen [Fri, 29 Aug 2025 13:11:11 +0000 (16:11 +0300)]
PCI: Add pci_setup_one_bridge_window()

pci_bridge_release_resources() contains a resource type hack to work
around the unsuitable __pci_setup_bridge() interface. Extract the
switch statement that picks the correct bridge window setup function
from pci_claim_bridge_resource() into pci_setup_one_bridge_window() and
use it also in pci_bridge_release_resources().

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250829131113.36754-23-ilpo.jarvinen@linux.intel.com
7 weeks agoPCI: Refactor remove_dev_resources() to use pbus_select_window()
Ilpo Järvinen [Fri, 29 Aug 2025 13:11:10 +0000 (16:11 +0300)]
PCI: Refactor remove_dev_resources() to use pbus_select_window()

Convert remove_dev_resources() to use pbus_select_window(). As 'available'
is not the real resources, the index has to be adjusted as only bridge
resource counterparts are present in the 'available' array.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250829131113.36754-22-ilpo.jarvinen@linux.intel.com
7 weeks agoPCI: Refactor distributing available memory to use loops
Ilpo Järvinen [Fri, 29 Aug 2025 13:11:09 +0000 (16:11 +0300)]
PCI: Refactor distributing available memory to use loops

pci_bus_distribute_available_resources() and
pci_bridge_distribute_available_resources() retain bridge window resources
and related data needed for distributing the available window in
independent variables for io, memory, and prefetchable memory windows. The
code is essentially the same for all of them and therefore repeated three
times with different variable names.

Refactor pci_bus_distribute_available_resources() to take an array. This
is complicated slightly by the function taking advantage of passing the
struct as value, which cannot be done for arrays in C. Therefore, copy the
data into a local array in the stack in the first loop.

Variable names are (hopefully) improved slightly as well.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250829131113.36754-21-ilpo.jarvinen@linux.intel.com
7 weeks agoPCI: Use pbus_select_window_for_type() during mem window sizing
Ilpo Järvinen [Fri, 29 Aug 2025 13:11:08 +0000 (16:11 +0300)]
PCI: Use pbus_select_window_for_type() during mem window sizing

__pci_bus_size_bridges() goes to great lengths of helping pbus_size_mem()
in which types it should put into a particular bridge window, requiring
passing up to three resource type into pbus_size_mem().

Instead of having complex logic in __pci_bus_size_bridges() and a
non-straightforward interface between those functions, use
pbus_select_window_for_type() and pbus_select_window() to find the correct
bridge window and compare if the resources belong to that window.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250829131113.36754-20-ilpo.jarvinen@linux.intel.com
7 weeks agoPCI: Use pbus_select_window() in space available checker
Ilpo Järvinen [Fri, 29 Aug 2025 13:11:07 +0000 (16:11 +0300)]
PCI: Use pbus_select_window() in space available checker

pbus_upstream_space_available() figures out the upstream bridge window
resources on its own. Migrate it to use pbus_select_window().

Note: pbus_select_window() -> pbus_select_window_for_type() calls
find_bus_resource_of_type() for root bus, which does not do parent check
similar to what pbus_upstream_space_available() did earlier, but the
difference does not matter because pbus_upstream_space_available() itself
stops when it encounters the root bus.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250829131113.36754-19-ilpo.jarvinen@linux.intel.com
7 weeks agoPCI: Rename resource variable from r to res
Ilpo Järvinen [Fri, 29 Aug 2025 13:11:06 +0000 (16:11 +0300)]
PCI: Rename resource variable from r to res

Resource is going to be passed in as argument aften an upcoming change.
Rename the struct resource variable from "r" to "res" to avoid using one
letter variable name in a function argument.

This rename is made separately to reduce churn in the upcoming change.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250829131113.36754-18-ilpo.jarvinen@linux.intel.com
7 weeks agoPCI: Use pbus_select_window_for_type() during IO window sizing
Ilpo Järvinen [Fri, 29 Aug 2025 13:11:05 +0000 (16:11 +0300)]
PCI: Use pbus_select_window_for_type() during IO window sizing

Convert pbus_size_io() to use pbus_select_window_for_type().

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250829131113.36754-17-ilpo.jarvinen@linux.intel.com
7 weeks agoPCI: Use pbus_select_window() during BAR resize
Ilpo Järvinen [Fri, 29 Aug 2025 13:11:04 +0000 (16:11 +0300)]
PCI: Use pbus_select_window() during BAR resize

Prior to a BAR resize, __resource_resize_store() loops through the normal
resources of the PCI device and releases those that match to the flags of
the BAR to be resized. This is necessary to allow resizing also the
upstream bridge window as only childless bridge windows can be resized.

While the flags check (mostly) works (if corner cases are ignored), the
more straightforward way is to check if the resources share the bridge
window. Change __resource_resize_store() to do the check using
pbus_select_window().

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250829131113.36754-16-ilpo.jarvinen@linux.intel.com
7 weeks agoPCI: Warn if bridge window cannot be released when resizing BAR
Ilpo Järvinen [Fri, 29 Aug 2025 13:11:03 +0000 (16:11 +0300)]
PCI: Warn if bridge window cannot be released when resizing BAR

BAR resizing calls to pci_reassign_bridge_resources(), which attempts to
release any upstream bridge window to allow them to accommodate the new BAR
size. The release can only be performed if there are no other child
resources for the bridge window. Previously the code continued silently
when other child resources were detected.

Add pci_warn() to inform user that a bridge window could not be released
because of child resources. As a small bridge window is often the reason
why BAR resize fails, this warning will help to pinpoint to the cause.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250829131113.36754-15-ilpo.jarvinen@linux.intel.com
7 weeks agoPCI: Fix finding bridge window in pci_reassign_bridge_resources()
Ilpo Järvinen [Fri, 29 Aug 2025 13:11:02 +0000 (16:11 +0300)]
PCI: Fix finding bridge window in pci_reassign_bridge_resources()

pci_reassign_bridge_resources() walks upwards in the PCI bus hierarchy,
locates the relevant bridge window on each level using flags check, and
attempts to release the bridge window. The flags-based check is fragile due
to various fallbacks in the bridge window selection logic. As such, the
algorithm might not locate the correct bridge window.

Refactor pci_reassign_bridge_resources() to determine the correct bridge
window using pbus_select_window(), which contains logic to handle all
fallback cases correctly. Change function prefix to pbus as it now inputs
struct bus and resource for which to locate the bridge window.

The main purpose is to make bridge window selection logic consistent across
the entire PCI core (one step at a time). While this technically also fixes
the commit 8bb705e3e79d ("PCI: Add pci_resize_resource() for resizing
BARs") making the bridge window walk algorithm more robust, the normal
setup having a 64-bit resizable BAR underneath bridge(s) with 64-bit
prefetchable windows does not need to use any fallbacks. As such, the
practical impact is low (requiring BAR resize use case and a non-typical
bridge device).

The way to detect if unrelated resource failed again is left to use the
type based approximation which should not behave worse than before.

Fixes: 8bb705e3e79d ("PCI: Add pci_resize_resource() for resizing BARs")
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250829131113.36754-14-ilpo.jarvinen@linux.intel.com
7 weeks agoPCI: Add bridge window selection functions
Ilpo Järvinen [Fri, 29 Aug 2025 13:11:01 +0000 (16:11 +0300)]
PCI: Add bridge window selection functions

Various places in the PCI core code independently decide into which bridge
window a child resource should be placed. It is hard to see whether these
decisions always end up in agreement, especially in the corner cases, and
in some places it requires complex logic to pass multiple resource types
and/or bridge windows around.

Add pbus_select_window() and pbus_select_window_for_type() for cases where
the former cannot be used so that eventually the same helper can be used to
select the bridge window everywhere. Using the same function ensures the
selected bridge window remains always the same and it can be easily
recalculated in-situ allowing simplifying the interfaces between internal
functions in upcoming changes.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250829131113.36754-13-ilpo.jarvinen@linux.intel.com
7 weeks agoPCI: Add defines for bridge window indexing
Ilpo Järvinen [Fri, 29 Aug 2025 13:11:00 +0000 (16:11 +0300)]
PCI: Add defines for bridge window indexing

include/linux/pci.h provides PCI_BRIDGE_{IO,MEM,PREF_MEM}_WINDOW defines,
however, they're based on the resource array indexing in the pci_dev
struct. The struct pci_bus also has pointers to those same resources but
they start from zeroth index.

Add PCI_BUS_BRIDGE_{IO,MEM,PREF_MEM}_WINDOW defines to get rid of literal
indexing.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250829131113.36754-12-ilpo.jarvinen@linux.intel.com
7 weeks agoPCI: Preserve bridge window resource type flags
Ilpo Järvinen [Fri, 29 Aug 2025 13:10:59 +0000 (16:10 +0300)]
PCI: Preserve bridge window resource type flags

When a bridge window is found unused or fails to assign, the flags of the
associated resource are cleared. Clearing flags is problematic as it also
removes the type information of the resource which is needed later.

Thus, always preserve the bridge window type flags and use IORESOURCE_UNSET
and IORESOURCE_DISABLED to indicate the status of the bridge window. Also,
when initializing resources, make sure all valid bridge windows do get
their type flags set.

Change various places that relied on resource flags being cleared to check
for IORESOURCE_UNSET and IORESOURCE_DISABLED to allow bridge window
resource to retain their type flags. Add pdev_resource_assignable() and
pdev_resource_should_fit() helpers to filter out disabled bridge windows
during resource fitting; the latter combines more common checks into the
helper.

When reading the bridge windows from the registers, instead of leaving the
resource flags cleared for bridge windows that are not enabled, always
set up the flags and set IORESOURCE_UNSET | IORESOURCE_DISABLED as needed.

When resource fitting or assignment fails for a bridge window resource, or
the bridge window is not needed, mark the resource with IORESOURCE_UNSET or
IORESOURCE_DISABLED, respectively.

Use dummy zero resource in resource_show() for backwards compatibility as
lspci will otherwise misrepresent disabled bridge windows.

This change fixes an issue which highlights the importance of keeping the
resource type flags intact:

  At the end of __assign_resources_sorted(), reset_resource() is called,
  previously clearing the flags. Later, pci_prepare_next_assign_round()
  attempted to release bridge resources using
  pci_bus_release_bridge_resources() that calls into
  pci_bridge_release_resources() that assumes type flags are still present.
  As type flags were cleared, IORESOURCE_MEM_64 was not set leading to
  resources under an incorrect bridge window to be released (idx = 1
  instead of idx = 2). While the assignments performed later covered this
  problem so that the wrongly released resources got assigned in the end,
  it was still causing extra release+assign pairs.

There are other reasons why the resource flags should be retained in
upcoming changes too.

Removing the flag reset for non-bridge window resource is left as future
work, in part because it has a much higher regression potential due to
pci_enable_resources() that will start to work also for those resources
then and due to what endpoint drivers might assume about resources.

Despite the Fixes tag, backporting this (at least any time soon) is highly
discouraged. The issue fixed is borderline cosmetic as the later
assignments normally cover the problem entirely. Also there might be
non-obvious dependencies.

Fixes: 5b28541552ef ("PCI: Restrict 64-bit prefetchable bridge windows to 64-bit resources")
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250829131113.36754-11-ilpo.jarvinen@linux.intel.com
7 weeks agoPCI: Enable bridge even if bridge window fails to assign
Ilpo Järvinen [Fri, 29 Aug 2025 13:10:58 +0000 (16:10 +0300)]
PCI: Enable bridge even if bridge window fails to assign

A normal PCI bridge has multiple bridge windows and not all of them are
always required by devices underneath the bridge. If a Root Port or bridge
does not have a device underneath, no bridge windows get assigned. Yet,
pci_enable_resources() is set to fail indiscriminantly on any resource
assignment failure if the resource is not known to be optional.

In practice, the code in pci_enable_resources() is currently largely
dormant. The kernel sets resource flags to zero for any unused bridge
window and resets flags to zero in case of an resource assignment failure,
which short-circuits pci_enable_resources() because of this check:

  if (!(r->flags & (IORESOURCE_IO | IORESOURCE_MEM)))
    continue;

However, an upcoming change to resource flags will alter how bridge window
resource flags behave activating these long dormants checks in
pci_enable_resources().

While complex logic could be built to selectively enable a bridge only
under some conditions, a few versions of such logic were tried during
development of this change and none of them worked satisfactorily. Thus, I
just gave up and decided to enable any bridge regardless of the bridge
windows as there seems to be no clear benefit from not enabling it, but a
major downside as pcieport will not be probed for the bridge if it's not
enabled.

Therefore, change pci_enable_resources() to not check if bridge window
resources remain unassigned. Resource assignment failures are pretty noisy
already so there is no need to log that for bridge windows in
pci_enable_resources().

Ignoring bridge window failures hopefully prevents an obvious source of
regressions when the upcoming change that no longer clears resource flags
for bridge windows is enacted. I've hit this problem even during my own
testing on multiple occasions so I expect it to be a quite common problem.

This can always be revisited later if somebody thinks the enable check for
bridges is not strict enough, but expect a mind-boggling number of
regressions from such a change.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250829131113.36754-10-ilpo.jarvinen@linux.intel.com
7 weeks agoPCI: Use pci_release_resource() instead of release_resource()
Ilpo Järvinen [Fri, 29 Aug 2025 13:10:57 +0000 (16:10 +0300)]
PCI: Use pci_release_resource() instead of release_resource()

A few places in setup-bus.c call release_resource() directly and end up
duplicating functionality from pci_release_resource() such as parent check,
logging, and clearing the resource. Worse yet, the way the resource is
cleared is inconsistent between different sites.

Convert release_resource() calls into pci_release_resource() to remove code
duplication. This will also make the resource start, end, and flags
behavior consistent, i.e., start address is cleared, and only
IORESOURCE_UNSET is asserted for the resource.

While at it, eliminate the unnecessary initialization of idx variable in
pci_bridge_release_resources().

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250829131113.36754-9-ilpo.jarvinen@linux.intel.com
7 weeks agoPCI: Disable non-claimed bridge window
Ilpo Järvinen [Fri, 29 Aug 2025 13:10:56 +0000 (16:10 +0300)]
PCI: Disable non-claimed bridge window

If clipping or claiming the bridge window fails, the bridge window is left
in a state that does not match the kernel's view on what the bridge window
is.

Disable the bridge window by writing the magic disable value into the Base
and Limit Registers if clipping or claiming failed. To detect if claiming
the resource was successful, add res->parent checks into the bridge setup
functions.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250829131113.36754-8-ilpo.jarvinen@linux.intel.com
7 weeks agoPCI: Always claim bridge window before its setup
Ilpo Järvinen [Fri, 29 Aug 2025 13:10:55 +0000 (16:10 +0300)]
PCI: Always claim bridge window before its setup

When the claim of a resource fails for the full range in
pci_claim_bridge_resource(), clipping the resource to a smaller size is
attempted. If clipping is successful, the new bridge window is programmed
and only as the last step the code attempts to claim the resource again.
The order of the last two steps is slightly illogical and inconsistent with
the assignment call chains.

If claiming the bridge window after clipping fails, the bridge window that
was set up is left in place.

Rework the logic such that the bridge window is claimed before calling the
relevant bridge setup function. This make the behavior consistent with
resource fitting call chains that always assign the bridge window before
programming it.

If claiming the bridge window fails, the clipped bridge window is no longer
set up but pci_claim_bridge_resource() returns without writing the bridge
window at all.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250829131113.36754-7-ilpo.jarvinen@linux.intel.com
7 weeks agoPCI: Refactor find_bus_resource_of_type() logic checks
Ilpo Järvinen [Fri, 29 Aug 2025 13:10:54 +0000 (16:10 +0300)]
PCI: Refactor find_bus_resource_of_type() logic checks

Reorder the logic checks in find_bus_resource_of_type() to simplify them.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250829131113.36754-6-ilpo.jarvinen@linux.intel.com
7 weeks agoPCI: Move find_bus_resource_of_type() earlier
Ilpo Järvinen [Fri, 29 Aug 2025 13:10:53 +0000 (16:10 +0300)]
PCI: Move find_bus_resource_of_type() earlier

Move find_bus_resource_of_type() earlier in setup-bus.c to be able to call
it in upcoming changes.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250829131113.36754-5-ilpo.jarvinen@linux.intel.com
7 weeks agoMIPS: PCI: Use pci_enable_resources()
Ilpo Järvinen [Fri, 29 Aug 2025 13:10:52 +0000 (16:10 +0300)]
MIPS: PCI: Use pci_enable_resources()

pci-legacy.c under MIPS has a copy of pci_enable_resources() named as
pcibios_enable_resources(). Having own copy of same functionality could
lead to inconsistencies in behavior, especially now as
pci_enable_resources() and the bridge window resource flags behavior are
going to be altered by upcoming changes.

The check for !r->start && r->end is already covered by the more generic
checks done in pci_enable_resources().

Call pci_enable_resources() from MIPS's pcibios_enable_device() and remove
pcibios_enable_resources().

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Link: https://patch.msgid.link/20250829131113.36754-4-ilpo.jarvinen@linux.intel.com
7 weeks agosparc/PCI: Remove pcibios_enable_device() as they do nothing extra
Ilpo Järvinen [Fri, 29 Aug 2025 13:10:51 +0000 (16:10 +0300)]
sparc/PCI: Remove pcibios_enable_device() as they do nothing extra

Under arch/sparc/ there are multiple copies of pcibios_enable_device() but
none of those seem to do anything extra beyond what pci_enable_resources()
is supposed to do. These functions could lead to inconsistencies in
behavior, especially now as pci_enable_resources() and the bridge window
resource flags behavior are going to be altered by upcoming changes.

Remove all pcibios_enable_device() from arch/sparc/ so that PCI core can
simply call into pci_enable_resources() instead using its __weak version
of pcibios_enable_device().

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250829131113.36754-3-ilpo.jarvinen@linux.intel.com
7 weeks agom68k/PCI: Use pci_enable_resources() in pcibios_enable_device()
Ilpo Järvinen [Fri, 29 Aug 2025 13:10:50 +0000 (16:10 +0300)]
m68k/PCI: Use pci_enable_resources() in pcibios_enable_device()

m68k has a resource enable (check) loop in its pcibios_enable_device()
which for some reason differs from pci_enable_resources(). This could lead
to inconsistencies in behavior, especially now as pci_enable_resources()
and the bridge window resource flags behavior are going to be altered by
upcoming changes.

The check for !r->start && r->end is already covered by the more generic
checks done in pci_enable_resources().

The entire pcibios_enable_device() suspiciously looks copy-paste from some
other arch as also indicated by the preceding comment. However, it also
enables PCI_COMMAND_IO | PCI_COMMAND_MEMORY always for bridges. It is not
clear why that is being done as the commit e93a6bbeb5a5 ("m68k: common PCI
support definitions and code") introducing this code states "Nothing
specific to any PCI implementation in any m68k class CPU hardware yet".

Replace the resource enable loop with a call to pci_enable_resources() and
adjust the Command Register afterwards as it's unclear if that is necessary
or not so keep it for now.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250829131113.36754-2-ilpo.jarvinen@linux.intel.com
7 weeks agoPCI: Fix failure detection during resource resize
Ilpo Järvinen [Mon, 30 Jun 2025 14:26:41 +0000 (17:26 +0300)]
PCI: Fix failure detection during resource resize

Since 96336ec70264 ("PCI: Perform reset_resource() and build fail list in
sync") the failed list is always built and returned to let the caller
decide what to do with the failures. The caller may want to retry resource
fitting and assignment and before that can happen, the resources should be
restored to their original state (a reset effectively clears the struct
resource), which requires returning them to the failed list so the original
state remains stored in the associated struct pci_dev_resource.

Resource resizing is different from the ordinary resource fitting and
assignment in that it only considers part of the resources. This means
failures for other resource types are not relevant at all and should be
ignored. As resize doesn't unassign such unrelated resources, those
resources ending up in the failed list implies assignment of that
resource must have failed before resize too. The check in
pci_reassign_bridge_resources() to decide if the whole assignment is
successful, however, is based on list emptiness which will cause false
negatives when the failed list has resources with an unrelated type.

If the failed list is not empty, call pci_required_resource_failed() and
extend it to be able to filter on specific resource types too (if
provided).

Calling pci_required_resource_failed() at this point is slightly
problematic because the resource itself is reset when the failed list
is constructed in __assign_resources_sorted(). As a result,
pci_resource_is_optional() does not have access to the original
resource flags. This could be worked around by restoring and
re-resetting the resource around the call to pci_resource_is_optional(),
however, it shouldn't cause issue as resource resizing is meant for
64-bit prefetchable resources according to Christian König (see the
Link which unfortunately doesn't point directly to Christian's reply
because lore didn't store that email at all).

Fixes: 96336ec70264 ("PCI: Perform reset_resource() and build fail list in sync")
Link: https://lore.kernel.org/all/c5d1b5d8-8669-5572-75a7-0b480f581ac1@linux.intel.com/
Reported-by: D Scott Phillips <scott@os.amperecomputing.com>
Closes: https://lore.kernel.org/all/86plf0lgit.fsf@scott-ph-mail.amperecomputing.com/
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Tested-by: D Scott Phillips <scott@os.amperecomputing.com>
Reviewed-by: D Scott Phillips <scott@os.amperecomputing.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: stable@vger.kernel.org # v6.15+
Link: https://patch.msgid.link/20250822123359.16305-4-ilpo.jarvinen@linux.intel.com
7 weeks agoPCI: Fix pdev_resources_assignable() disparity
Ilpo Järvinen [Mon, 30 Jun 2025 14:26:40 +0000 (17:26 +0300)]
PCI: Fix pdev_resources_assignable() disparity

pdev_sort_resources() uses pdev_resources_assignable() helper to decide if
device's resources cannot be assigned, so it ignores class 0
(PCI_CLASS_NOT_DEFINED) devices. pbus_size_mem(), on the other hand, does
not do the same check. This could lead into a situation where a resource
ends up on realloc_head list but is not on the head list, which in turn
prevents emptying the resource from the realloc_head list in
__assign_resources_sorted().

A non-empty realloc_head is unacceptable because it triggers an internal
sanity check as shown in this log with a device that has class 0
(PCI_CLASS_NOT_DEFINED):

  pci 0001:01:00.0: [144d:a5a5] type 00 class 0x000000 PCIe Endpoint
  pci 0001:01:00.0: BAR 0 [mem 0x00000000-0x000fffff 64bit]
  pci 0001:01:00.0: ROM [mem 0x00000000-0x0000ffff pref]
  pcieport 0001:00:00.0: bridge window [mem 0x00100000-0x001fffff] to [bus 01-ff] add_size 100000 add_align 100000
  pcieport 0001:00:00.0: bridge window [mem 0x40000000-0x401fffff]: assigned
  ------------[ cut here ]------------
  kernel BUG at drivers/pci/setup-bus.c:2532!
  Internal error: Oops - BUG: 00000000f2000800 [#1]  SMP
  ...
  Call trace:
   pci_assign_unassigned_bus_resources+0x110/0x114 (P)
   pci_rescan_bus+0x28/0x48

Use pdev_resources_assignable() also within pbus_size_mem() to skip
processing of non-assignable resources which removes the disparity in
between what resources pdev_sort_resources() and pbus_size_mem() consider.
As non-assignable resources are no longer processed, they are not added to
the realloc_head list, thus the sanity check no longer triggers.

This disparity problem is very old but only now became apparent after
2499f5348431 ("PCI: Rework optional resource handling") that made the ROM
resources optional when calculating bridge window sizes which required
adding the resource to the realloc_head list.  Previously, bridge windows
were just sized larger than necessary.

Fixes: 2499f5348431 ("PCI: Rework optional resource handling")
Reported-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Closes: https://lore.kernel.org/all/5f103643-5e1c-43c6-b8fe-9617d3b5447c@linaro.org/
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: stable@vger.kernel.org # v6.15+
Link: https://patch.msgid.link/20250822123359.16305-3-ilpo.jarvinen@linux.intel.com
7 weeks agoPCI: Ensure relaxed tail alignment does not increase min_align
Ilpo Järvinen [Mon, 30 Jun 2025 14:26:39 +0000 (17:26 +0300)]
PCI: Ensure relaxed tail alignment does not increase min_align

When using relaxed tail alignment for the bridge window, pbus_size_mem()
also tries to minimize min_align, which can under certain scenarios end up
increasing min_align from that found by calculate_mem_align().

Ensure min_align is not increased by the relaxed tail alignment.

Eventually, it would be better to add calculate_relaxed_head_align()
similar to calculate_mem_align() which finds out what alignment can be used
for the head without introducing any gaps into the bridge window to give
flexibility on head address too. But that looks relatively complex so it
requires much more testing than fixing the immediate problem causing a
regression.

Fixes: 67f9085596ee ("PCI: Allow relaxed bridge window tail sizing for optional resources")
Reported-by: Rio Liu <rio@r26.me>
Closes: https://lore.kernel.org/all/o2bL8MtD_40-lf8GlslTw-AZpUPzm8nmfCnJKvS8RQ3NOzOW1uq1dVCEfRpUjJ2i7G2WjfQhk2IWZ7oGp-7G-jXN4qOdtnyOcjRR0PZWK5I=@r26.me/
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Tested-by: Rio Liu <rio@r26.me>
Cc: stable@vger.kernel.org # v6.15+
Link: https://patch.msgid.link/20250822123359.16305-2-ilpo.jarvinen@linux.intel.com
7 weeks agoDocumentation: PCI: Tidy error recovery doc's PCIe nomenclature
Lukas Wunner [Mon, 15 Sep 2025 13:50:04 +0000 (15:50 +0200)]
Documentation: PCI: Tidy error recovery doc's PCIe nomenclature

Commit 11502feab423 ("Documentation: PCI: Tidy AER documentation")
replaced the terms "PCI-E", "PCI-Express" and "PCI Express" with "PCIe"
in the AER documentation.

Do the same in the documentation on PCI error recovery.  While at it,
add a missing period and a missing blank.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Link: https://patch.msgid.link/db56b7ef12043f709a04ce67c1d1e102ab5f4e19.1757942121.git.lukas@wunner.de
7 weeks agoDocumentation: PCI: Amend error recovery doc with DPC/AER specifics
Lukas Wunner [Mon, 15 Sep 2025 13:50:03 +0000 (15:50 +0200)]
Documentation: PCI: Amend error recovery doc with DPC/AER specifics

Amend the documentation on PCI error recovery with specifics about
Downstream Port Containment and Advanced Error Reporting:

* Explain that with DPC, devices are inaccessible upon an error (similar
  to EEH on powerpc) and do not become accessible until the link is
  re-enabled.

* Explain that with AER, although devices may already be accessible in the
  ->error_detected() callback, accesses should be deferred to the
  ->mmio_enabled() callback for compatibility with EEH on powerpc and with
  s390.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Link: https://patch.msgid.link/61d8eeadb20ee71c3a852f44c863bfe0209c454d.1757942121.git.lukas@wunner.de
7 weeks agoDocumentation: PCI: Sync error recovery doc with code
Lukas Wunner [Mon, 15 Sep 2025 13:50:02 +0000 (15:50 +0200)]
Documentation: PCI: Sync error recovery doc with code

Amend the documentation on PCI error recovery to fix minor inaccuracies
vis-à-vis the actual code:

* The documentation claims that a missing ->resume() or ->mmio_enabled()
  callback always leads to recovery through reset.  But none of the
  implementations do this (pcie_do_recovery(), eeh_handle_normal_event(),
  zpci_event_do_error_state_clear()).

  Drop the claim to align the documentation with the code.

* The documentation does not list PCI_ERS_RESULT_RECOVERED as a valid
  return value from ->error_detected().  But none of the implementations
  forbid this and some drivers are returning it, e.g.:
  drivers/bus/mhi/host/pci_generic.c
  drivers/infiniband/hw/hfi1/pcie.c

  Further down in the documentation it is implied that the return value is
  in fact allowed:
  "The platform will call the resume() callback on all affected device
  drivers if all drivers on the segment have returned
  PCI_ERS_RESULT_RECOVERED from one of the 3 previous callbacks."

  The "3 previous callbacks" being ->error_detected(), ->mmio_enabled()
  and ->slot_reset().

  Add it to the valid return values for consistency.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Link: https://patch.msgid.link/ed3c3385499775fcc25f1ee66f395e212919f94a.1757942121.git.lukas@wunner.de
7 weeks agoDocumentation: PCI: Sync AER doc with code
Lukas Wunner [Mon, 15 Sep 2025 13:50:01 +0000 (15:50 +0200)]
Documentation: PCI: Sync AER doc with code

The PCIe Advanced Error Reporting driver has evolved over the years but
its documentation hasn't.  Catch up with past code changes:

* The documentation claims that Correctable Errors are logged with
  KERN_INFO severity, but the code uses KERN_WARN.

  It had used KERN_WARN from the beginning with commit 6c2b374d7485
  ("PCI-Express AER implemetation: AER core and aerdriver").  In 2013,
  commit 2cced2d95961 ("aerdrv: Cleanup log output for AER") switched to
  KERN_ERR, until 2020 when it was reverted back to KERN_WARN by commit
  e83e2ca3c395 ("PCI/AER: Log correctable errors as warning, not error").

* An example log message in the documentation uses the term "Uncorrected",
  but the code uses "Uncorrectable" since commit 02a06f5f1a6a ("PCI/AER:
  Use 'Correctable' and 'Uncorrectable' spec terms for errors").

* The example contains the Requester ID "id=0500", which is omitted since
  commit 010caed4ccb6 ("PCI/AER: Decode Error Source Requester ID").

* The example contains the error name "Unsupported Request", which is
  instead reported as "UnsupReq" since commit bd237801fef2 ("PCI/AER:
  Adopt lspci names for AER error decoding").

* The example doesn't prepend "0x" to hex values from the TLP Header Log,
  as introduced by commit f68ea779d98a ("PCI: Add pcie_print_tlp_log() to
  print TLP Header and Prefix Log").

* The documentation refers to a reset_link callback which was removed by
  commit b6cf1a42f916 ("PCI/ERR: Remove service dependency in
  pcie_do_recovery()").

* Commit 579086225502 ("PCI/ERR: Recover from RCiEP AER errors") added
  support to recover Root Complex Integrated Endpoints by applying a
  Function Level Reset, alternatively to the Secondary Bus Reset which is
  applied otherwise.

* On non-fatal errors, a reset was previously never performed.  But the
  AER driver has just been amended to allow drivers to opt in to a reset.

* The documentation claims that a warning message is logged if a driver
  lacks pci_error_handlers.  But the message has been informational
  (logged with KERN_INFO severity) since its introduction with commit
  01daacfb9035 ("PCI/AER: Log which device prevents error recovery").

  The documentation claims that the message is only logged for fatal
  errors, which is incorrect.  Moreover it refers to "section 3", even
  though the documentation no longer contains section numbers since commit
  4e37f055a92e ("Documentation: PCI: convert pcieaer-howto.txt to reST").
  Section 3 is titled "Developer Guide".  That's the same section where
  the reference is located, so it is self-referential and can be dropped.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Link: https://patch.msgid.link/7501bfc5b9920193a25998a3cbcf72c47674ec63.1757942121.git.lukas@wunner.de