platform/kernel/linux-rpi.git
11 months agoMerge branch 'pci/controller/qcom-ep'
Bjorn Helgaas [Tue, 29 Aug 2023 16:03:54 +0000 (11:03 -0500)]
Merge branch 'pci/controller/qcom-ep'

- Log unknown Qcom Endpoint IRQ events at error level, not debug level
  (Manivannan Sadhasivam)

- Add DT and driver support for qcom interconnect bandwidth voting for
  "pcie-mem" and "cpu-pcie" interconnects (Krishna chaitanya chundru)

* pci/controller/qcom-ep:
  PCI: qcom-ep: Add ICC bandwidth voting support
  dt-bindings: PCI: qcom: ep: Add interconnects path
  PCI: qcom-ep: Treat unknown IRQ events as an error

11 months agoMerge branch 'pci/controller/qcom-edma'
Bjorn Helgaas [Tue, 29 Aug 2023 16:03:54 +0000 (11:03 -0500)]
Merge branch 'pci/controller/qcom-edma'

- Pass the Qcom Endpoint 4K alignment requirement for outbound windows to
  the EPF core so EPF drivers can use it (Manivannan Sadhasivam)

- Use alignment restriction from EPF core in Qcom EPF MHI driver
  (Manivannan Sadhasivam)

- Add Qcom Endpoint eDMA support by enabling the eDMA IRQ (Manivannan
  Sadhasivam)

- Add Qcom MHI eDMA support (Manivannan Sadhasivam)

- Add Qcom Snapdragon SM8450 support to the EPF MHI driver (Manivannan
  Sadhasivam)

- Use iATU for EPF MHI transfers smaller than 4K to avoid eDMA setup
  latency (Manivannan Sadhasivam)

- Add pci_epc_mem_init() kernel-doc (Manivannan Sadhasivam)

* pci/controller/qcom-edma:
  PCI: endpoint: Add kernel-doc for pci_epc_mem_init() API
  PCI: epf-mhi: Use iATU for small transfers
  PCI: epf-mhi: Add support for SM8450
  PCI: epf-mhi: Add eDMA support
  PCI: qcom-ep: Add eDMA support
  PCI: epf-mhi: Make use of the alignment restriction from EPF core
  PCI: qcom-ep: Pass alignment restriction to the EPF core

11 months agoMerge branch 'pci/controller/qcom'
Bjorn Helgaas [Tue, 29 Aug 2023 16:03:54 +0000 (11:03 -0500)]
Merge branch 'pci/controller/qcom'

- Configure controller so MHI bus master clock will be switched off while
  in ASPM L1.x states (Manivannan Sadhasivam)

- Add sa8775p DT binding and driver support (Mrinmay Sarkar)

- Fix broken DT SDX65 "compatible" property (Krzysztof Kozlowski)

* pci/controller/qcom:
  dt-bindings: PCI: qcom: Fix SDX65 compatible
  PCI: qcom: Add support for sa8775p SoC
  dt-bindings: PCI: qcom: Add sa8775p compatible
  PCI: qcom-ep: Switch MHI bus master clock off during L1SS

11 months agoMerge branch 'pci/controller/microchip'
Bjorn Helgaas [Tue, 29 Aug 2023 16:03:53 +0000 (11:03 -0500)]
Merge branch 'pci/controller/microchip'

- Fix DED and SEC interrupt bit offsets so interrupt handlers work
  correctly (Daire McNamara)

- Make driver buildable as a module (Daire McNamara)

- Reorganize register #defines to align with hardware docs (Daire McNamara)

- Tweak register accessors to simplify callers (Daire McNamara)

- Refactor interrupt initialisation (Daire McNamara)

- Read FPGA MSI configuration parameters from hardware instead of
  hard-coding them (Daire McNamara)

- Re-partition code between probe() and init() (Daire McNamara)

* pci/controller/microchip:
  PCI: microchip: Re-partition code between probe() and init()
  PCI: microchip: Gather MSI information from hardware config registers
  PCI: microchip: Clean up initialisation of interrupts
  PCI: microchip: Enable event handlers to access bridge and control pointers
  PCI: microchip: Align register, offset, and mask names with HW docs
  PCI: microchip: Enable building driver as a module
  PCI: microchip: Correct the DED and SEC interrupt bit offsets

11 months agoMerge branch 'pci/controller/layerscape'
Bjorn Helgaas [Tue, 29 Aug 2023 16:03:53 +0000 (11:03 -0500)]
Merge branch 'pci/controller/layerscape'

- Add support for link-down notification so the endpoint driver can process
  LINK_DOWN events (Frank Li)

- Save Link Capabilities during probe so they can be restored when handling
  a link-up event, since the controller loses the Link Width and Link Speed
  values during reset (Xiaowei Bao)

* pci/controller/layerscape:
  PCI: layerscape: Add workaround for lost link capabilities during reset
  PCI: layerscape: Add support for link-down notification

11 months agoMerge branch 'pci/controller/iproc'
Bjorn Helgaas [Tue, 29 Aug 2023 16:03:53 +0000 (11:03 -0500)]
Merge branch 'pci/controller/iproc'

- Use of_property_read_bool() instead of low-level accessors for boolean
  properties (Rob Herring)

* pci/controller/iproc:
  PCI: iproc: Use of_property_read_bool() for boolean properties

11 months agoMerge branch 'pci/controller/hv'
Bjorn Helgaas [Tue, 29 Aug 2023 16:03:52 +0000 (11:03 -0500)]
Merge branch 'pci/controller/hv'

- To avoid a NULL pointer dereference, skip MSI restore after hibernate if
  MSI/MSI-X hasn't been enabled (Dexuan Cui)

* pci/controller/hv:
  PCI: hv: Fix a crash in hv_pci_restore_msi_msg() during hibernation

11 months agoMerge branch 'pci/controller/fu740'
Bjorn Helgaas [Tue, 29 Aug 2023 16:03:52 +0000 (11:03 -0500)]
Merge branch 'pci/controller/fu740'

- Set the supported number of MSI vectors so we can use all available MSI
  interrupts (Yong-Xuan Wang)

* pci/controller/fu740:
  PCI: fu740: Set the number of MSI vectors

11 months agoMerge branch 'pci/controller/dwc'
Bjorn Helgaas [Tue, 29 Aug 2023 16:03:52 +0000 (11:03 -0500)]
Merge branch 'pci/controller/dwc'

- Add an imx6 .host_deinit() callback so we can clean up things like
  regulators on probe failure or driver unload (Mark Brown)

- Add PCIE_PME_TO_L2_TIMEOUT_US value for controller drivers that need to
  manually synchronize power removal (Frank Li)

- Add generic dwc suspend/resume APIs (dw_pcie_suspend_noirq() and
  dw_pcie_resume_noirq()) to be called by controller driver suspend/resume
  ops, and a controller callback to send PME_Turn_Off (Frank Li)

- Add layerscape suspend/resume support, including manual
  PME_Turn_off/PME_TO_Ack handshake (Hou Zhiqiang, Frank Li)

* pci/controller/dwc:
  PCI: layerscape: Add power management support for ls1028a
  PCI: dwc: Implement generic suspend/resume functionality
  PCI: Add PCIE_PME_TO_L2_TIMEOUT_US L2 ready timeout value
  PCI: dwc: Provide deinit callback for i.MX

11 months agoMerge branch 'pci/controller/brcmstb'
Bjorn Helgaas [Tue, 29 Aug 2023 16:03:51 +0000 (11:03 -0500)]
Merge branch 'pci/controller/brcmstb'

- Assert PERST# when probing BCM2711 because some bootloaders don't do it
  (Jim Quinlan)

* pci/controller/brcmstb:
  PCI: brcmstb: Remove stale comment
  PCI: brcmstb: Assert PERST# on BCM2711

11 months agoMerge branch 'pci/controller/apple'
Bjorn Helgaas [Tue, 29 Aug 2023 16:03:51 +0000 (11:03 -0500)]
Merge branch 'pci/controller/apple'

- Initialize pcie->nvecs (number of available MSIs) before use (Sven Peter)

* pci/controller/apple:
  PCI: apple: Initialize pcie->nvecs before use

11 months agoMerge branch 'pci/vpd'
Bjorn Helgaas [Tue, 29 Aug 2023 16:03:50 +0000 (11:03 -0500)]
Merge branch 'pci/vpd'

- Ensure device is accessible before VPD access via sysfs (Alex Williamson)

- Ensure device doesn't go to a low-power state while we're polling for PME
  (Alex Williamson)

* pci/vpd:
  PCI: Fix runtime PM race with PME polling
  PCI/VPD: Add runtime power management to sysfs interface

11 months agoMerge branch 'pci/vga'
Bjorn Helgaas [Tue, 29 Aug 2023 16:03:50 +0000 (11:03 -0500)]
Merge branch 'pci/vga'

- Correct parameter types for vga_str_to_iostate() and
  vga_update_device_decodes() (Sui Jingfeng)

- Simplify vga_arbiter_notify_clients() (Sui Jingfeng)

- Simplify vga_client_register() (Sui Jingfeng)

- Replace MIT license text with SPDX identifier (Sui Jingfeng)

- Fix lots of comment typos (Sui Jingfeng)

* pci/vga:
  PCI/VGA: Fix typos
  PCI/VGA: Replace full MIT license text with SPDX identifier
  PCI/VGA: Simplify vga_client_register()
  PCI/VGA: Simplify vga_arbiter_notify_clients()
  PCI/VGA: Correct vga_update_device_decodes() parameter type
  PCI/VGA: Correct vga_str_to_iostate() io_state parameter type

11 months agoMerge branch 'pci/virtualization'
Bjorn Helgaas [Tue, 29 Aug 2023 16:03:50 +0000 (11:03 -0500)]
Merge branch 'pci/virtualization'

- Avoid bus resets on NVIDIA T4 GPUs because they don't seem to recover (Wu
  Zongyong)

* pci/virtualization:
  PCI: Mark NVIDIA T4 GPUs to avoid bus reset

11 months agoMerge branch 'pci/pm'
Bjorn Helgaas [Tue, 29 Aug 2023 16:03:49 +0000 (11:03 -0500)]
Merge branch 'pci/pm'

- Only read PCI_PM_CTRL register when available, to avoid reading the wrong
  register and corrupting dev->current_state (Feiyang Chen)

* pci/pm:
  PCI/PM: Only read PCI_PM_CTRL register when available

11 months agoMerge branch 'pci/pcie-rmw'
Bjorn Helgaas [Tue, 29 Aug 2023 16:03:49 +0000 (11:03 -0500)]
Merge branch 'pci/pcie-rmw'

- Add locking for read/modify/write PCIe Capability Register accessors for
  Link Control and Root Control (Ilpo Järvinen)

- Use PCIe RMW accessors for Link Control updates in PCI core, pciehp,
  amdgpu, radeon, mlx5, ath10k, ath11k, ath12k (Ilpo Järvinen)

- Convert PCIBIOS error values in mlx5 to generic errnos (Ilpo Järvinen)

- Simplify pcie_capability_clear_and_set_word() control flow (Bjorn
  Helgaas)

* pci/pcie-rmw:
  PCI: Simplify pcie_capability_clear_and_set_word() control flow
  net/mlx5: Convert PCI error values to generic errnos
  PCI: Document the Capability accessor RMW improvements
  wifi: ath10k: Use RMW accessors for changing LNKCTL
  wifi: ath12k: Use RMW accessors for changing LNKCTL
  wifi: ath11k: Use RMW accessors for changing LNKCTL
  net/mlx5: Use RMW accessors for changing LNKCTL
  drm/radeon: Use RMW accessors for changing LNKCTL
  drm/amdgpu: Use RMW accessors for changing LNKCTL
  PCI/ASPM: Use RMW accessors for changing LNKCTL
  PCI: pciehp: Use RMW accessors for changing LNKCTL
  PCI: Make link retraining use RMW accessors for changing LNKCTL
  PCI: Add locking to RMW PCI Express Capability Register accessors

11 months agoMerge branch 'pci/ioport'
Bjorn Helgaas [Tue, 29 Aug 2023 16:03:49 +0000 (11:03 -0500)]
Merge branch 'pci/ioport'

- Make I/O resources depend on CONFIG_HAS_IOPORT so inw() and friends can
  be completely omitted on architectures without I/O port support (Niklas
  Schnelle)

* pci/ioport:
  PCI/sysfs: Make I/O resource depend on HAS_IOPORT
  PCI: Make quirk using inw() depend on HAS_IOPORT

11 months agoMerge branch 'pci/hotplug'
Bjorn Helgaas [Tue, 29 Aug 2023 16:03:48 +0000 (11:03 -0500)]
Merge branch 'pci/hotplug'

- Make ibmphp read-only arrays static instead of putting them on the stack
  (Colin Ian King)

* pci/hotplug:
  PCI: ibmphp: Make read-only arrays static

11 months agoMerge branch 'pci/aer'
Bjorn Helgaas [Tue, 29 Aug 2023 16:03:48 +0000 (11:03 -0500)]
Merge branch 'pci/aer'

- Remove pci_disable_pcie_error_reporting() (unused) and unexport
  pci_enable_pcie_error_reporting().  This all done by the PCI core now
  (Bjorn Helgaas)

* pci/aer:
  PCI/AER: Unexport pci_enable_pcie_error_reporting()
  PCI/AER: Drop unused pci_disable_pcie_error_reporting()

11 months agoPCI: qcom-ep: Add ICC bandwidth voting support
Krishna chaitanya chundru [Wed, 19 Jul 2023 07:20:18 +0000 (12:50 +0530)]
PCI: qcom-ep: Add ICC bandwidth voting support

Add support for voting interconnect (ICC) bandwidth based
on the link speed and width.

This commit is inspired from the basic interconnect support added
to pcie-qcom driver in commit c4860af88d0c ("PCI: qcom: Add basic
interconnect support").

The interconnect support is kept optional to be backward compatible
with legacy device trees.

[kwilczynski: add missing kernel-doc for the icc_mem variable]
Link: https://lore.kernel.org/linux-pci/1689751218-24492-5-git-send-email-quic_krichai@quicinc.com
Signed-off-by: Krishna chaitanya chundru <quic_krichai@quicinc.com>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
11 months agodt-bindings: PCI: qcom: ep: Add interconnects path
Krishna chaitanya chundru [Wed, 19 Jul 2023 07:20:15 +0000 (12:50 +0530)]
dt-bindings: PCI: qcom: ep: Add interconnects path

Some platforms may not boot if a device driver doesn't
initialize the interconnect path. Mostly it is handled
by the bootloader but we have starting to see cases
where bootloader simply ignores them.

Add the "pcie-mem" & "cpu-pcie" interconnect path as a required
property to the bindings.

Link: https://lore.kernel.org/linux-pci/1689751218-24492-2-git-send-email-quic_krichai@quicinc.com
Signed-off-by: Krishna chaitanya chundru <quic_krichai@quicinc.com>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Acked-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
11 months agoPCI: qcom-ep: Treat unknown IRQ events as an error
Manivannan Sadhasivam [Wed, 26 Jul 2023 15:29:31 +0000 (20:59 +0530)]
PCI: qcom-ep: Treat unknown IRQ events as an error

Sometimes, the Qcom PCIe EP controller can receive some interrupts
unknown to the driver, like safety interrupts in newer SoCs. In those
cases, if the driver doesn't clear the interrupts, it will end up in an
interrupt storm. However, the users will not know about it because the
log is treated as a debug message.

So let's treat the unknown event log as an error so that it at least
makes the user aware, thereby getting fixed eventually.

[kwilczynski: commit log]
Link: https://lore.kernel.org/linux-pci/20230726152931.18134-1-manivannan.sadhasivam@linaro.org
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
11 months agodt-bindings: PCI: qcom: Fix SDX65 compatible
Krzysztof Kozlowski [Sun, 27 Aug 2023 08:53:51 +0000 (10:53 +0200)]
dt-bindings: PCI: qcom: Fix SDX65 compatible

Commit c0aba9f32801 ("dt-bindings: PCI: qcom: Add SDX65 SoC") adding
SDX65 was never tested and is clearly bogus.  The qcom,sdx65-pcie-ep
compatible is followed by a fallback in DTS, and there is no driver
matched by this compatible.  Driver matches by its fallback
qcom,sdx55-pcie-ep.  This also fixes dtbs_check warnings like:

  qcom-sdx65-mtp.dtb: pcie-ep@1c00000: compatible: ['qcom,sdx65-pcie-ep', 'qcom,sdx55-pcie-ep'] is too long

[kwilczynski: commit log]
Fixes: c0aba9f32801 ("dt-bindings: PCI: qcom: Add SDX65 SoC")
Link: https://lore.kernel.org/linux-pci/20230827085351.21932-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Cc: stable@vger.kernel.org
11 months agoPCI: endpoint: Add kernel-doc for pci_epc_mem_init() API
Manivannan Sadhasivam [Mon, 17 Jul 2023 06:54:59 +0000 (12:24 +0530)]
PCI: endpoint: Add kernel-doc for pci_epc_mem_init() API

Add missing kernel-doc for pci_epc_mem_init() API.

Link: https://lore.kernel.org/linux-pci/20230717065459.14138-8-manivannan.sadhasivam@linaro.org
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
11 months agoPCI: epf-mhi: Use iATU for small transfers
Manivannan Sadhasivam [Mon, 17 Jul 2023 06:54:58 +0000 (12:24 +0530)]
PCI: epf-mhi: Use iATU for small transfers

For transfers below 4K, let's use iATU since using eDMA for such small
transfers is inefficient.

This is mainly because setting up an eDMA transfer and waiting for
completion adds some latency. This latency is negligible for large
transfers but not for the smaller ones.

With using iATU, there is an increase in ~50Mbps throughput on both MHI
UL (Uplink) and DL (Downlink) channels.

[kwilczynski: commit log]
Link: https://lore.kernel.org/linux-pci/20230717065459.14138-7-manivannan.sadhasivam@linaro.org
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
11 months agoPCI: epf-mhi: Add support for SM8450
Manivannan Sadhasivam [Mon, 17 Jul 2023 06:54:57 +0000 (12:24 +0530)]
PCI: epf-mhi: Add support for SM8450

Add support for Qualcomm Snapdragon SM8450 SoC to the EPF driver. SM8450
has the dedicated PID (0x0306) and supports eDMA. Currently, it has no
fixed PCI class, so it is being advertised as "PCI_CLASS_OTHERS".

Link: https://lore.kernel.org/linux-pci/20230717065459.14138-6-manivannan.sadhasivam@linaro.org
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
11 months agoPCI: epf-mhi: Add eDMA support
Manivannan Sadhasivam [Mon, 17 Jul 2023 06:54:56 +0000 (12:24 +0530)]
PCI: epf-mhi: Add eDMA support

Add support for Embedded DMA (eDMA) available in the DesignWare PCIe IP
to transfer the MHI buffers between the host and the endpoint. The eDMA
use helps achieve greater throughput as the transfers are offloaded from
CPUs.

For differentiating the iATU and eDMA APIs, the pci_epf_mhi_{read/write}
APIs are renamed to pci_epf_mhi_iatu_{read/write} and separate eDMA
specific APIs pci_epf_mhi_edma_{read/write} are introduced.

Platforms that require eDMA support can pass the MHI_EPF_USE_DMA flag
through pci_epf_mhi_ep_info.

[kwilczynski: commit log]
Link: https://lore.kernel.org/linux-pci/20230717065459.14138-5-manivannan.sadhasivam@linaro.org
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
11 months agoPCI: qcom-ep: Add eDMA support
Manivannan Sadhasivam [Mon, 17 Jul 2023 06:54:55 +0000 (12:24 +0530)]
PCI: qcom-ep: Add eDMA support

Qualcomm PCIe Endpoint controllers have the in-built Embedded DMA (eDMA)
peripheral for offloading the data transfer between the PCIe bus and
memory.

Let's add support for it by enabling the eDMA IRQ in the driver. The
eDMA DMA Engine driver will handle the rest of the functionality.

Since the eDMA on Qualcomm platforms only uses a single IRQ for all
channels, use 1 for edma.nr_irqs.

[kwilczynski: commit log]
Link: https://lore.kernel.org/linux-pci/20230717065459.14138-4-manivannan.sadhasivam@linaro.org
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
11 months agoPCI: epf-mhi: Make use of the alignment restriction from EPF core
Manivannan Sadhasivam [Mon, 17 Jul 2023 06:54:54 +0000 (12:24 +0530)]
PCI: epf-mhi: Make use of the alignment restriction from EPF core

Instead of hardcoding the alignment restriction in the EPF_MHI driver, make
use of the info available from the EPF core that reflects the alignment
restriction of the endpoint controller.

For this purpose, let's introduce the get_align_offset() static function.

[kwilczynski: update get_align_offset() to avoid issues on 32-bit architectures]
Link: https://lore.kernel.org/linux-pci/20230717065459.14138-3-manivannan.sadhasivam@linaro.org
Link: https://lore.kernel.org/linux-pci/20230826150626.23309-1-manivannan.sadhasivam@linaro.org
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
11 months agoPCI/PM: Only read PCI_PM_CTRL register when available
Feiyang Chen [Thu, 24 Aug 2023 01:37:38 +0000 (09:37 +0800)]
PCI/PM: Only read PCI_PM_CTRL register when available

For a device with no Power Management Capability, pci_power_up() previously
returned 0 (success) if the platform was able to put the device in D0,
which led to pci_set_full_power_state() trying to read PCI_PM_CTRL, even
though it doesn't exist.

Since dev->pm_cap == 0 in this case, pci_set_full_power_state() actually
read the wrong register, interpreted it as PCI_PM_CTRL, and corrupted
dev->current_state.  This led to messages like this in some cases:

  pci 0000:01:00.0: Refused to change power state from D3hot to D0

To prevent this, make pci_power_up() always return a negative failure code
if the device lacks a Power Management Capability, even if non-PCI platform
power management has been able to put the device in D0.  The failure will
prevent pci_set_full_power_state() from trying to access PCI_PM_CTRL.

Fixes: e200904b275c ("PCI/PM: Split pci_power_up()")
Link: https://lore.kernel.org/r/20230824013738.1894965-1-chenfeiyang@loongson.cn
Signed-off-by: Feiyang Chen <chenfeiyang@loongson.cn>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: stable@vger.kernel.org # v5.19+
11 months agoPCI: qcom: Add support for sa8775p SoC
Mrinmay Sarkar [Fri, 21 Jul 2023 17:24:33 +0000 (22:54 +0530)]
PCI: qcom: Add support for sa8775p SoC

Add support for sa8775p SoC that uses controller version 5.90
reusing the 1.9.0 config.

Link: https://lore.kernel.org/linux-pci/1689960276-29266-3-git-send-email-quic_msarkar@quicinc.com
Signed-off-by: Mrinmay Sarkar <quic_msarkar@quicinc.com>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Reviewed-by: Bjorn Andersson <andersson@kernel.org>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
11 months agodt-bindings: PCI: qcom: Add sa8775p compatible
Mrinmay Sarkar [Fri, 21 Jul 2023 17:24:32 +0000 (22:54 +0530)]
dt-bindings: PCI: qcom: Add sa8775p compatible

Add sa8775p platform to the binding.

Link: https://lore.kernel.org/linux-pci/1689960276-29266-2-git-send-email-quic_msarkar@quicinc.com
Signed-off-by: Mrinmay Sarkar <quic_msarkar@quicinc.com>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Acked-by: Manivannan Sadhasivam <mani@kernel.org>
11 months agoPCI: qcom-ep: Pass alignment restriction to the EPF core
Manivannan Sadhasivam [Mon, 17 Jul 2023 06:54:53 +0000 (12:24 +0530)]
PCI: qcom-ep: Pass alignment restriction to the EPF core

Qcom PCIe EP controllers have 4K alignment restriction for the outbound
window address. Hence, pass this info to the EPF core so that the EPF
drivers can make use of this info.

Link: https://lore.kernel.org/linux-pci/20230717065459.14138-2-manivannan.sadhasivam@linaro.org
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
11 months agoPCI: Simplify pcie_capability_clear_and_set_word() control flow
Bjorn Helgaas [Thu, 24 Aug 2023 18:40:29 +0000 (13:40 -0500)]
PCI: Simplify pcie_capability_clear_and_set_word() control flow

Return early for errors in pcie_capability_clear_and_set_word_unlocked()
and pcie_capability_clear_and_set_dword() to simplify the control flow.

No functional change intended.

Link: https://lore.kernel.org/r/20230824193712.542167-13-helgaas@kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
11 months agoPCI/VGA: Fix typos
Sui Jingfeng [Tue, 8 Aug 2023 22:34:07 +0000 (06:34 +0800)]
PCI/VGA: Fix typos

Fix typos, rewrap to fill 78 columns, convert to conventional multi-line
style.

[bhelgaas: squash and add more fixes]
Link: https://lore.kernel.org/r/20230808223412.1743176-7-sui.jingfeng@linux.dev
Link: https://lore.kernel.org/r/20230808223412.1743176-9-sui.jingfeng@linux.dev
Link: https://lore.kernel.org/r/20230808223412.1743176-10-sui.jingfeng@linux.dev
Link: https://lore.kernel.org/r/20230808223412.1743176-11-sui.jingfeng@linux.dev
Signed-off-by: Sui Jingfeng <suijingfeng@loongson.cn>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
11 months agoPCI: brcmstb: Remove stale comment
Jim Quinlan [Fri, 23 Jun 2023 14:40:58 +0000 (10:40 -0400)]
PCI: brcmstb: Remove stale comment

A comment says that Multi-MSI is not supported by the driver.
A past commit [1] added this feature, so the comment is
incorrect and is removed.

[1] commit 198acab1772f22f2 ("PCI: brcmstb: Enable Multi-MSI")

Link: https://lore.kernel.org/r/20230623144100.34196-6-james.quinlan@broadcom.com
Signed-off-by: Jim Quinlan <james.quinlan@broadcom.com>
Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
11 months agoPCI: brcmstb: Assert PERST# on BCM2711
Jim Quinlan [Fri, 23 Jun 2023 14:40:57 +0000 (10:40 -0400)]
PCI: brcmstb: Assert PERST# on BCM2711

The current PCIe driver assumes PERST# is asserted when probe() is invoked.
Some older versions of the 2711/RPi bootloader left PERST# unasserted, as
the Raspian OS does assert PERST# on probe().  For this reason, we assert
PERST# for BCM2711 SOCs (i.e. RPi).

Link: https://lore.kernel.org/r/20230623144100.34196-5-james.quinlan@broadcom.com
Signed-off-by: Jim Quinlan <james.quinlan@broadcom.com>
Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
11 months agoPCI: layerscape: Add power management support for ls1028a
Hou Zhiqiang [Mon, 21 Aug 2023 18:48:15 +0000 (14:48 -0400)]
PCI: layerscape: Add power management support for ls1028a

Add PME_Turn_off/PME_TO_Ack handshake sequence for ls1028a platform.

Implemented on top of common dwc dw_pcie_suspend(resume)_noirq()
functions to handle system enter/exit suspend states.

Link: https://lore.kernel.org/r/20230821184815.2167131-4-Frank.Li@nxp.com
Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
Acked-by: Manivannan Sadhasivam <mani@kernel.org>
11 months agoPCI: dwc: Implement generic suspend/resume functionality
Frank Li [Mon, 21 Aug 2023 18:48:14 +0000 (14:48 -0400)]
PCI: dwc: Implement generic suspend/resume functionality

Introduce an helper function (dw_pcie_get_ltssm()) to retrieve
SMLH_LTSS_STATE.

Add common dw_pcie_suspend(resume)_noirq() API to implement the DWC
controller generic suspend/resume functionality.

Add a controller specific callback to send the PME_Turn_Off message
(ie .pme_turn_off) for controller platform specific PME handling.

Link: https://lore.kernel.org/r/20230821184815.2167131-3-Frank.Li@nxp.com
Signed-off-by: Frank Li <Frank.Li@nxp.com>
[lpieralisi@kernel.org: commit log]
Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
Acked-by: Manivannan Sadhasivam <mani@kernel.org>
11 months agoPCI: Add PCIE_PME_TO_L2_TIMEOUT_US L2 ready timeout value
Frank Li [Mon, 21 Aug 2023 18:48:13 +0000 (14:48 -0400)]
PCI: Add PCIE_PME_TO_L2_TIMEOUT_US L2 ready timeout value

Add the PCIE_PME_TO_L2_TIMEOUT_US macro to define the L2 ready timeout
as described in the PCI specifications.

Link: https://lore.kernel.org/r/20230821184815.2167131-2-Frank.Li@nxp.com
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
Acked-by: Manivannan Sadhasivam <mani@kernel.org>
11 months agoPCI: layerscape: Add workaround for lost link capabilities during reset
Xiaowei Bao [Thu, 20 Jul 2023 13:58:34 +0000 (09:58 -0400)]
PCI: layerscape: Add workaround for lost link capabilities during reset

The endpoint controller loses the Maximum Link Width and Supported Link Speed
value from the Link Capabilities Register - initially configured by the Reset
Configuration Word (RCW) - during a link-down or hot reset event.

Address this issue in the endpoint event handler.

Link: https://lore.kernel.org/r/20230720135834.1977616-2-Frank.Li@nxp.com
Fixes: a805770d8a22 ("PCI: layerscape: Add EP mode support")
Signed-off-by: Xiaowei Bao <xiaowei.bao@nxp.com>
Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
Acked-by: Manivannan Sadhasivam <mani@kernel.org>
11 months agoPCI: layerscape: Add support for link-down notification
Frank Li [Thu, 20 Jul 2023 13:58:33 +0000 (09:58 -0400)]
PCI: layerscape: Add support for link-down notification

Add support to pass link-down notification to the endpoint function
driver so that it can process the LINK_DOWN event.

Link: https://lore.kernel.org/r/20230720135834.1977616-1-Frank.Li@nxp.com
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
Acked-by: Manivannan Sadhasivam <mani@kernel.org>
11 months agoPCI/VGA: Replace full MIT license text with SPDX identifier
Sui Jingfeng [Tue, 8 Aug 2023 22:34:12 +0000 (06:34 +0800)]
PCI/VGA: Replace full MIT license text with SPDX identifier

Per Documentation/process/license-rules.rst, the SPDX MIT identifier is
equivalent to including the entire MIT license text from
LICENSES/preferred/MIT.

Replace the MIT license text with the equivalent SPDX identifier.

Link: https://lore.kernel.org/r/20230808223412.1743176-12-sui.jingfeng@linux.dev
Signed-off-by: Sui Jingfeng <suijingfeng@loongson.cn>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>
11 months agoPCI/VGA: Simplify vga_client_register()
Sui Jingfeng [Tue, 8 Aug 2023 22:34:08 +0000 (06:34 +0800)]
PCI/VGA: Simplify vga_client_register()

Reorganize vga_client_register() to avoid the goto and the need to save the
return value.  Update the kernel-doc to reflect -ENODEV on failure.  No
functional change intended.

[bhelgaas: drop "ret" variable, commit log]
Link: https://lore.kernel.org/r/20230808223412.1743176-8-sui.jingfeng@linux.dev
Signed-off-by: Sui Jingfeng <suijingfeng@loongson.cn>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
11 months agoPCI/VGA: Simplify vga_arbiter_notify_clients()
Sui Jingfeng [Tue, 8 Aug 2023 22:34:06 +0000 (06:34 +0800)]
PCI/VGA: Simplify vga_arbiter_notify_clients()

In vga_arbiter_notify_clients(), "new_state" was computed during every loop
iteration even though it doesn't depend on anything that changes during the
loop.   Move the computation outside the loop.

[bhelgaas: drop renames that obscure the purpose, commit log]
Link: https://lore.kernel.org/r/20230808223412.1743176-6-sui.jingfeng@linux.dev
Signed-off-by: Sui Jingfeng <suijingfeng@loongson.cn>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
11 months agoPCI/VGA: Correct vga_update_device_decodes() parameter type
Sui Jingfeng [Tue, 8 Aug 2023 22:34:05 +0000 (06:34 +0800)]
PCI/VGA: Correct vga_update_device_decodes() parameter type

Previously vga_update_device_decodes() took "int new_decodes", but the
callers pass "unsigned int new_decodes".  Correct the
vga_update_device_decodes() parameter type to "unsigned int" to match.

In vga_arbiter_notify_clients(), the return from vgadev->set_decode() is
"unsigned int" but was stored as "uint32_t new_decodes".  Correct the
new_decodes type to "unsigned int".

[bhelgaas: use correct type for ->set_decode() return, commit log]
Link: https://lore.kernel.org/r/20230808223412.1743176-5-sui.jingfeng@linux.dev
Signed-off-by: Sui Jingfeng <suijingfeng@loongson.cn>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
11 months agoPCI/VGA: Correct vga_str_to_iostate() io_state parameter type
Sui Jingfeng [Tue, 8 Aug 2023 22:34:02 +0000 (06:34 +0800)]
PCI/VGA: Correct vga_str_to_iostate() io_state parameter type

Previously vga_str_to_iostate() took "int *io_state", but vga_arb_write()
is the only caller and it passes "unsigned int *".  Make the
vga_str_to_iostate() parameter type "unsigned int *" to match.

[bhelgaas: commit log]
Link: https://lore.kernel.org/r/20230808223412.1743176-2-sui.jingfeng@linux.dev
Signed-off-by: Sui Jingfeng <suijingfeng@loongson.cn>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
11 months agoPCI: fu740: Set the number of MSI vectors
Yong-Xuan Wang [Mon, 7 Aug 2023 05:56:21 +0000 (05:56 +0000)]
PCI: fu740: Set the number of MSI vectors

The iMSI-RX module of the DW PCIe controller provides multiple sets of
MSI_CTRL_INT_i_* registers, and each set is capable of handling 32 MSI
interrupts. However, the fu740 PCIe controller driver only enabled one set
of MSI_CTRL_INT_i_* registers, as the total number of supported interrupts
was not specified.

Set the supported number of MSI vectors to enable all the MSI_CTRL_INT_i_*
registers on the fu740 PCIe core, allowing the system to fully utilize the
available MSI interrupts.

Link: https://lore.kernel.org/r/20230807055621.2431-1-yongxuan.wang@sifive.com
Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com>
Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
11 months agoPCI: hv: Fix a crash in hv_pci_restore_msi_msg() during hibernation
Dexuan Cui [Wed, 16 Aug 2023 17:59:39 +0000 (10:59 -0700)]
PCI: hv: Fix a crash in hv_pci_restore_msi_msg() during hibernation

When a Linux VM with an assigned PCI device runs on Hyper-V, if the PCI
device driver is not loaded yet (i.e. MSI-X/MSI is not enabled on the
device yet), doing a VM hibernation triggers a panic in
hv_pci_restore_msi_msg() -> msi_lock_descs(&pdev->dev), because
pdev->dev.msi.data is still NULL.

Avoid the panic by checking if MSI-X/MSI is enabled.

Link: https://lore.kernel.org/r/20230816175939.21566-1-decui@microsoft.com
Fixes: dc2b453290c4 ("PCI: hv: Rework MSI handling")
Signed-off-by: Dexuan Cui <decui@microsoft.com>
Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
Reviewed-by: sathyanarayanan.kuppuswamy@linux.intel.com
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Cc: stable@vger.kernel.org
11 months agonet/mlx5: Convert PCI error values to generic errnos
Ilpo Järvinen [Mon, 14 Aug 2023 13:27:20 +0000 (16:27 +0300)]
net/mlx5: Convert PCI error values to generic errnos

mlx5_pci_link_toggle() returns a mix of PCI-specific error codes and
generic errnos.

Convert the PCI-specific error values to generic errno using
pcibios_err_to_errno() before returning them.

Fixes: eabe8e5e88f5 ("net/mlx5: Handle sync reset now event")
Fixes: 212b4d7251c1 ("net/mlx5: Wait for firmware to enable CRS before pci_restore_state")
Link: https://lore.kernel.org/r/20230814132721.26608-1-ilpo.jarvinen@linux.intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
[bhelgaas: rebase to pci/pcie-rmw, also convert in mlx5_check_dev_ids()]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
11 months agoPCI: Document the Capability accessor RMW improvements
Ilpo Järvinen [Mon, 17 Jul 2023 12:05:03 +0000 (15:05 +0300)]
PCI: Document the Capability accessor RMW improvements

Documentation claims port service drivers should play nice with respect to
PCIe Capability changes, but the concurrency control is now provided in the
Capability accessors as long as the correct ones are used.

Update the documention to match the RMW accessor behavior.

Link: https://lore.kernel.org/r/20230717120503.15276-12-ilpo.jarvinen@linux.intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
11 months agowifi: ath10k: Use RMW accessors for changing LNKCTL
Ilpo Järvinen [Mon, 17 Jul 2023 12:05:02 +0000 (15:05 +0300)]
wifi: ath10k: Use RMW accessors for changing LNKCTL

Don't assume that only the driver would be accessing LNKCTL. ASPM policy
changes can trigger write to LNKCTL outside of driver's control.

Use RMW capability accessors which does proper locking to avoid losing
concurrent updates to the register value. On restore, clear the ASPMC field
properly.

Suggested-by: Lukas Wunner <lukas@wunner.de>
Fixes: 76d870ed09ab ("ath10k: enable ASPM")
Link: https://lore.kernel.org/r/20230717120503.15276-11-ilpo.jarvinen@linux.intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Acked-by: Kalle Valo <kvalo@kernel.org>
11 months agowifi: ath12k: Use RMW accessors for changing LNKCTL
Ilpo Järvinen [Mon, 17 Jul 2023 12:05:01 +0000 (15:05 +0300)]
wifi: ath12k: Use RMW accessors for changing LNKCTL

Don't assume that only the driver would be accessing LNKCTL. ASPM policy
changes can trigger write to LNKCTL outside of driver's control.

Use RMW capability accessors which do proper locking to avoid losing
concurrent updates to the register value. On restore, clear the ASPMC field
properly.

Suggested-by: Lukas Wunner <lukas@wunner.de>
Fixes: d889913205cf ("wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices")
Link: https://lore.kernel.org/r/20230717120503.15276-10-ilpo.jarvinen@linux.intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Acked-by: Kalle Valo <kvalo@kernel.org>
11 months agowifi: ath11k: Use RMW accessors for changing LNKCTL
Ilpo Järvinen [Mon, 17 Jul 2023 12:05:00 +0000 (15:05 +0300)]
wifi: ath11k: Use RMW accessors for changing LNKCTL

Don't assume that only the driver would be accessing LNKCTL. ASPM policy
changes can trigger write to LNKCTL outside of driver's control.

Use RMW capability accessors which do proper locking to avoid losing
concurrent updates to the register value. On restore, clear the ASPMC field
properly.

Suggested-by: Lukas Wunner <lukas@wunner.de>
Fixes: e9603f4bdcc0 ("ath11k: pci: disable ASPM L0sLs before downloading firmware")
Link: https://lore.kernel.org/r/20230717120503.15276-9-ilpo.jarvinen@linux.intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Acked-by: Kalle Valo <kvalo@kernel.org>
11 months agonet/mlx5: Use RMW accessors for changing LNKCTL
Ilpo Järvinen [Mon, 17 Jul 2023 12:04:59 +0000 (15:04 +0300)]
net/mlx5: Use RMW accessors for changing LNKCTL

Don't assume that only the driver would be accessing LNKCTL of the upstream
bridge. ASPM policy changes can trigger write to LNKCTL outside of driver's
control.

Use RMW capability accessors which do proper locking to avoid losing
concurrent updates to the register value.

Suggested-by: Lukas Wunner <lukas@wunner.de>
Fixes: eabe8e5e88f5 ("net/mlx5: Handle sync reset now event")
Link: https://lore.kernel.org/r/20230717120503.15276-8-ilpo.jarvinen@linux.intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
11 months agodrm/radeon: Use RMW accessors for changing LNKCTL
Ilpo Järvinen [Mon, 17 Jul 2023 12:04:58 +0000 (15:04 +0300)]
drm/radeon: Use RMW accessors for changing LNKCTL

Don't assume that only the driver would be accessing LNKCTL. ASPM policy
changes can trigger write to LNKCTL outside of driver's control.  And in
the case of upstream bridge, the driver does not even own the device it's
changing the registers for.

Use RMW capability accessors which do proper locking to avoid losing
concurrent updates to the register value.

Suggested-by: Lukas Wunner <lukas@wunner.de>
Fixes: 8a7cd27679d0 ("drm/radeon/cik: add support for pcie gen1/2/3 switching")
Fixes: b9d305dfb66c ("drm/radeon: implement pcie gen2/3 support for SI")
Link: https://lore.kernel.org/r/20230717120503.15276-7-ilpo.jarvinen@linux.intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
11 months agodrm/amdgpu: Use RMW accessors for changing LNKCTL
Ilpo Järvinen [Mon, 17 Jul 2023 12:04:57 +0000 (15:04 +0300)]
drm/amdgpu: Use RMW accessors for changing LNKCTL

Don't assume that only the driver would be accessing LNKCTL. ASPM policy
changes can trigger write to LNKCTL outside of driver's control.  And in
the case of upstream bridge, the driver does not even own the device it's
changing the registers for.

Use RMW capability accessors which do proper locking to avoid losing
concurrent updates to the register value.

Suggested-by: Lukas Wunner <lukas@wunner.de>
Fixes: a2e73f56fa62 ("drm/amdgpu: Add support for CIK parts")
Fixes: 62a37553414a ("drm/amdgpu: add si implementation v10")
Link: https://lore.kernel.org/r/20230717120503.15276-6-ilpo.jarvinen@linux.intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
11 months agoPCI: Fix runtime PM race with PME polling
Alex Williamson [Thu, 3 Aug 2023 17:12:33 +0000 (11:12 -0600)]
PCI: Fix runtime PM race with PME polling

Testing that a device is not currently in a low power state provides no
guarantees that the device is not imminently transitioning to such a state.
Increment the PM usage counter before accessing the device.  Since we don't
wish to wake the device for PME polling, do so only if the device is
already active by using pm_runtime_get_if_active().

Link: https://lore.kernel.org/r/20230803171233.3810944-3-alex.williamson@redhat.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
11 months agoPCI/VPD: Add runtime power management to sysfs interface
Alex Williamson [Thu, 3 Aug 2023 17:12:32 +0000 (11:12 -0600)]
PCI/VPD: Add runtime power management to sysfs interface

Unlike default access to config space through sysfs, the VPD read and write
functions don't actively manage the runtime power management state of the
device during access.  Since commit 7ab5e10eda02 ("vfio/pci: Move the
unused device into low power state with runtime PM"), the vfio-pci driver
will use runtime power management and release unused devices to make use of
low power states.  Attempting to access VPD information in D3cold can
result in incorrect information or kernel crashes depending on the system
behavior.

Wrap the VPD read/write bin attribute handlers in runtime PM and take into
account the potential quirk to select the correct device to wake.

Link: https://lore.kernel.org/r/20230803171233.3810944-2-alex.williamson@redhat.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
[bhelgaas: tweak pci_dev_put() test to match the pci_get_func0_dev() test]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
11 months agoPCI/ASPM: Use RMW accessors for changing LNKCTL
Ilpo Järvinen [Mon, 17 Jul 2023 12:04:56 +0000 (15:04 +0300)]
PCI/ASPM: Use RMW accessors for changing LNKCTL

Don't assume that the device is fully under the control of ASPM and use RMW
capability accessors which do proper locking to avoid losing concurrent
updates to the register values.

If configuration fails in pcie_aspm_configure_common_clock(), the
function attempts to restore the old PCI_EXP_LNKCTL_CCC settings. Store
only the old PCI_EXP_LNKCTL_CCC bit for the relevant devices rather
than the content of the whole LNKCTL registers. It aligns better with
how pcie_lnkctl_clear_and_set() expects its parameter and makes the
code more obvious to understand.

Suggested-by: Lukas Wunner <lukas@wunner.de>
Fixes: 2a42d9dba784 ("PCIe: ASPM: Break out of endless loop waiting for PCI config bits to switch")
Fixes: 7d715a6c1ae5 ("PCI: add PCI Express ASPM support")
Link: https://lore.kernel.org/r/20230717120503.15276-5-ilpo.jarvinen@linux.intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: "Rafael J. Wysocki" <rafael@kernel.org>
11 months agoPCI: pciehp: Use RMW accessors for changing LNKCTL
Ilpo Järvinen [Mon, 17 Jul 2023 12:04:55 +0000 (15:04 +0300)]
PCI: pciehp: Use RMW accessors for changing LNKCTL

As hotplug is not the only driver touching LNKCTL, use the RMW capability
accessor which handles concurrent changes correctly.

Suggested-by: Lukas Wunner <lukas@wunner.de>
Fixes: 7f822999e12a ("PCI: pciehp: Add Disable/enable link functions")
Link: https://lore.kernel.org/r/20230717120503.15276-4-ilpo.jarvinen@linux.intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: "Rafael J. Wysocki" <rafael@kernel.org>
11 months agoPCI: Make link retraining use RMW accessors for changing LNKCTL
Ilpo Järvinen [Mon, 17 Jul 2023 12:04:54 +0000 (15:04 +0300)]
PCI: Make link retraining use RMW accessors for changing LNKCTL

Don't assume that the device is fully under the control of PCI core.  Use
RMW capability accessors in link retraining which do proper locking to
avoid losing concurrent updates to the register values.

Suggested-by: Lukas Wunner <lukas@wunner.de>
Fixes: 4ec73791a64b ("PCI: Work around Pericom PCIe-to-PCI bridge Retrain Link erratum")
Fixes: 7d715a6c1ae5 ("PCI: add PCI Express ASPM support")
Link: https://lore.kernel.org/r/20230717120503.15276-3-ilpo.jarvinen@linux.intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: "Rafael J. Wysocki" <rafael@kernel.org>
11 months agoPCI: Add locking to RMW PCI Express Capability Register accessors
Ilpo Järvinen [Mon, 17 Jul 2023 12:04:53 +0000 (15:04 +0300)]
PCI: Add locking to RMW PCI Express Capability Register accessors

Many places in the kernel write the Link Control and Root Control PCI
Express Capability Registers without proper concurrency control and this
could result in losing the changes one of the writers intended to make.

Add pcie_cap_lock spinlock into the struct pci_dev and use it to protect
bit changes made in the RMW capability accessors. Protect only a selected
set of registers by differentiating the RMW accessor internally to
locked/unlocked variants using a wrapper which has the same signature as
pcie_capability_clear_and_set_word(). As the Capability Register (pos)
given to the wrapper is always a constant, the compiler should be able to
simplify all the dead-code away.

So far only the Link Control Register (ASPM, hotplug, link retraining,
various drivers) and the Root Control Register (AER & PME) seem to
require RMW locking.

Suggested-by: Lukas Wunner <lukas@wunner.de>
Fixes: c7f486567c1d ("PCI PM: PCIe PME root port service driver")
Fixes: f12eb72a268b ("PCI/ASPM: Use PCI Express Capability accessors")
Fixes: 7d715a6c1ae5 ("PCI: add PCI Express ASPM support")
Fixes: affa48de8417 ("staging/rdma/hfi1: Add support for enabling/disabling PCIe ASPM")
Fixes: 849a9366cba9 ("misc: rtsx: Add support new chip rts5228 mmc: rtsx: Add support MMC_CAP2_NO_MMC")
Fixes: 3d1e7aa80d1c ("misc: rtsx: Use pcie_capability_clear_and_set_word() for PCI_EXP_LNKCTL")
Fixes: c0e5f4e73a71 ("misc: rtsx: Add support for RTS5261")
Fixes: 3df4fce739e2 ("misc: rtsx: separate aspm mode into MODE_REG and MODE_CFG")
Fixes: 121e9c6b5c4c ("misc: rtsx: modify and fix init_hw function")
Fixes: 19f3bd548f27 ("mfd: rtsx: Remove LCTLR defination")
Fixes: 773ccdfd9cc6 ("mfd: rtsx: Read vendor setting from config space")
Fixes: 8275b77a1513 ("mfd: rts5249: Add support for RTS5250S power saving")
Fixes: 5da4e04ae480 ("misc: rtsx: Add support for RTS5260")
Fixes: 0f49bfbd0f2e ("tg3: Use PCI Express Capability accessors")
Fixes: 5e7dfd0fb94a ("tg3: Prevent corruption at 10 / 100Mbps w CLKREQ")
Fixes: b726e493e8dc ("r8169: sync existing 8168 device hardware start sequences with vendor driver")
Fixes: e6de30d63eb1 ("r8169: more 8168dp support.")
Fixes: 8a06127602de ("Bluetooth: hci_bcm4377: Add new driver for BCM4377 PCIe boards")
Fixes: 6f461f6c7c96 ("e1000e: enable/disable ASPM L0s and L1 and ERT according to hardware errata")
Fixes: 1eae4eb2a1c7 ("e1000e: Disable L1 ASPM power savings for 82573 mobile variants")
Fixes: 8060e169e02f ("ath9k: Enable extended synch for AR9485 to fix L0s recovery issue")
Fixes: 69ce674bfa69 ("ath9k: do btcoex ASPM disabling at initialization time")
Fixes: f37f05503575 ("mt76: mt76x2e: disable pcie_aspm by default")
Link: https://lore.kernel.org/r/20230717120503.15276-2-ilpo.jarvinen@linux.intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: "Rafael J. Wysocki" <rafael@kernel.org>
12 months agoPCI: Mark NVIDIA T4 GPUs to avoid bus reset
Wu Zongyong [Mon, 10 Apr 2023 12:34:11 +0000 (20:34 +0800)]
PCI: Mark NVIDIA T4 GPUs to avoid bus reset

NVIDIA T4 GPUs do not work with SBR. This problem is found when the T4 card
is direct attached to a Root Port only. Avoid bus reset by marking T4 GPUs
PCI_DEV_FLAGS_NO_BUS_RESET.

Fixes: 4c207e7121fa ("PCI: Mark some NVIDIA GPUs to avoid bus reset")
Link: https://lore.kernel.org/r/2dcebea53a6eb9bd212ec6d8974af2e5e0333ef6.1681129861.git.wuzongyong@linux.alibaba.com
Signed-off-by: Wu Zongyong <wuzongyong@linux.alibaba.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
12 months agoPCI: dwc: Provide deinit callback for i.MX
Mark Brown [Mon, 31 Jul 2023 11:55:01 +0000 (12:55 +0100)]
PCI: dwc: Provide deinit callback for i.MX

The i.MX integration for the DesignWare PCI controller has a _host_exit()
operation which undoes everything that the _host_init() operation does but
does not wire this up as the host_deinit callback for the core, or call it
in any path other than suspend. This means that if we ever unwind the
initial probe of the device, for example because it fails, the regulator
core complains that the regulators for the device were left enabled:

imx6q-pcie 33800000.pcie: iATU: unroll T, 4 ob, 4 ib, align 64K, limit 16G
imx6q-pcie 33800000.pcie: Phy link never came up
imx6q-pcie 33800000.pcie: Phy link never came up
imx6q-pcie: probe of 33800000.pcie failed with error -110
------------[ cut here ]------------
WARNING: CPU: 2 PID: 46 at drivers/regulator/core.c:2396 _regulator_put+0x110/0x128

Wire up the callback so that the core can clean up after itself.

Link: https://lore.kernel.org/r/20230731-pci-imx-regulator-cleanup-v2-1-fc8fa5c9893d@kernel.org
Tested-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
Reviewed-by: Richard Zhu <hongxing.zhu@nxp.com>
Acked-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
12 months agoPCI: microchip: Re-partition code between probe() and init()
Daire McNamara [Fri, 28 Jul 2023 13:14:01 +0000 (14:14 +0100)]
PCI: microchip: Re-partition code between probe() and init()

Continuing to use pci_host_common_probe() for the PCIe Root Complex on
PolarFire SoC is leading to an extremely large _init() function and some
unnatural code flow. Re-partition the code so that some tasks are done
in a _probe() routine, which calls pci_host_common_probe() and then use
a much smaller _init() function, mainly to enable interrupts after
address translation tables are set up.

Link: https://lore.kernel.org/r/20230728131401.1615724-8-daire.mcnamara@microchip.com
Signed-off-by: Daire McNamara <daire.mcnamara@microchip.com>
Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
12 months agoPCI: microchip: Gather MSI information from hardware config registers
Daire McNamara [Fri, 28 Jul 2023 13:14:00 +0000 (14:14 +0100)]
PCI: microchip: Gather MSI information from hardware config registers

The PCIe Root Complex on PolarFire SoC is configured at bitstream creation
time using Libero. Key MSI-related parameters include the number of
MSIs (1/2/4/8/16/32) and the MSI address. In the device driver, extract
this information from hardware registers at init time, and use it to configure
MSI system, including configuring MSI capability structure correctly in
configuration space.

Link: https://lore.kernel.org/r/20230728131401.1615724-7-daire.mcnamara@microchip.com
Signed-off-by: Daire McNamara <daire.mcnamara@microchip.com>
Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
12 months agoPCI: microchip: Clean up initialisation of interrupts
Daire McNamara [Fri, 28 Jul 2023 13:13:59 +0000 (14:13 +0100)]
PCI: microchip: Clean up initialisation of interrupts

Refactor interrupt handling in _init() function into
disable_interrupts(), init_interrupts(), clear_sec_errors() and clear
ded_errors() because current code is unwieldy and prone to bugs.

Disable interrupts as soon as possible and only enable interrupts after
address translation is setup to prevent spurious axi2pcie and pcie2axi
translation errors being reported.

Link: https://lore.kernel.org/r/20230728131401.1615724-6-daire.mcnamara@microchip.com
Signed-off-by: Daire McNamara <daire.mcnamara@microchip.com>
Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
12 months agoPCI: microchip: Enable event handlers to access bridge and control pointers
Daire McNamara [Fri, 28 Jul 2023 13:13:58 +0000 (14:13 +0100)]
PCI: microchip: Enable event handlers to access bridge and control pointers

Minor re-organisation so that event handlers can access both a pointer
to the bridge area of the PCIe Root Port and the control area of the PCIe
Root Port.

Link: https://lore.kernel.org/r/20230728131401.1615724-5-daire.mcnamara@microchip.com
Signed-off-by: Daire McNamara <daire.mcnamara@microchip.com>
Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
12 months agoPCI: microchip: Align register, offset, and mask names with HW docs
Daire McNamara [Fri, 28 Jul 2023 13:13:57 +0000 (14:13 +0100)]
PCI: microchip: Align register, offset, and mask names with HW docs

Minor code re-organisation so that macros representing registers ascend in
numerical order and use the same names as their hardware documentation.
Removed registers not used by the driver.

Link: https://lore.kernel.org/r/20230728131401.1615724-4-daire.mcnamara@microchip.com
Signed-off-by: Daire McNamara <daire.mcnamara@microchip.com>
Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
12 months agoPCI: microchip: Enable building driver as a module
Daire McNamara [Fri, 28 Jul 2023 13:13:56 +0000 (14:13 +0100)]
PCI: microchip: Enable building driver as a module

Enable building driver as a module. The expected use case is the
driver is built as a module, is installed when needed, and cannot be
removed once installed since it is not possible to clean-up
the irq_chip data structures on removal, as described in:

https://lore.kernel.org/linux-pci/87y1wgbah8.wl-maz@kernel.org/

The driver has .suppress_bind_attrs set to true for the same
reasons (ie prevent unbinding, that would leave the kernel
with stale IRQ configuration that cannot be cleaned up).

Link: https://lore.kernel.org/linux-pci/87y1wgbah8.wl-maz@kernel.org/
Link: https://lore.kernel.org/r/20230728131401.1615724-3-daire.mcnamara@microchip.com
Suggested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Daire McNamara <daire.mcnamara@microchip.com>
Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
12 months agoPCI: microchip: Correct the DED and SEC interrupt bit offsets
Daire McNamara [Fri, 28 Jul 2023 13:13:55 +0000 (14:13 +0100)]
PCI: microchip: Correct the DED and SEC interrupt bit offsets

The SEC and DED interrupt bits are laid out the wrong way round so the SEC
interrupt handler attempts to mask, unmask, and clear the DED interrupt
and vice versa. Correct the bit offsets so that each interrupt handler
operates properly.

Link: https://lore.kernel.org/r/20230728131401.1615724-2-daire.mcnamara@microchip.com
Fixes: 6f15a9c9f941 ("PCI: microchip: Add Microchip PolarFire PCIe controller driver")
Signed-off-by: Daire McNamara <daire.mcnamara@microchip.com>
Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
12 months agoPCI/sysfs: Make I/O resource depend on HAS_IOPORT
Niklas Schnelle [Mon, 3 Jul 2023 13:52:55 +0000 (15:52 +0200)]
PCI/sysfs: Make I/O resource depend on HAS_IOPORT

If legacy I/O spaces are not supported simply return an error when
trying to access them via pci_resource_io(). This allows inb() and
friends to become undefined when they are known at compile time to be
non-functional in a later patch.

Co-developed-by: Arnd Bergmann <arnd@kernel.org>
Link: https://lore.kernel.org/r/20230703135255.2202721-3-schnelle@linux.ibm.com
Signed-off-by: Arnd Bergmann <arnd@kernel.org>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
12 months agoPCI: Make quirk using inw() depend on HAS_IOPORT
Niklas Schnelle [Mon, 3 Jul 2023 13:52:54 +0000 (15:52 +0200)]
PCI: Make quirk using inw() depend on HAS_IOPORT

In the future inw() and friends will not be compiled on architectures
without I/O port support.

Co-developed-by: Arnd Bergmann <arnd@kernel.org>
Link: https://lore.kernel.org/r/20230703135255.2202721-2-schnelle@linux.ibm.com
Signed-off-by: Arnd Bergmann <arnd@kernel.org>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
12 months agoPCI: ibmphp: Make read-only arrays static
Colin Ian King [Tue, 27 Jun 2023 12:56:12 +0000 (13:56 +0100)]
PCI: ibmphp: Make read-only arrays static

Don't populate the arrays on the stack; instead make them static const.

Link: https://lore.kernel.org/r/20230627125612.724764-1-colin.i.king@gmail.com
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
12 months agoPCI: qcom-ep: Switch MHI bus master clock off during L1SS
Manivannan Sadhasivam [Tue, 27 Jun 2023 14:10:36 +0000 (19:40 +0530)]
PCI: qcom-ep: Switch MHI bus master clock off during L1SS

Currently, as part of the qcom_pcie_perst_deassert() function, instead
of writing the updated value to clear PARF_MSTR_AXI_CLK_EN, the variable
"val" is re-read.

This must be fixed to ensure that the master clock supplied to the MHI
bus is correctly gated during L1.1/L1.2 to save power.

Thus, replace the line that re-reads "val" with a line that writes the
updated value to the register to clear PARF_MSTR_AXI_CLK_EN.

[kwilczynski: commit log]
Fixes: c457ac029e44 ("PCI: qcom-ep: Gate Master AXI clock to MHI bus during L1SS")
Link: https://lore.kernel.org/linux-pci/20230627141036.11600-1-manivannan.sadhasivam@linaro.org
Reported-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
12 months agoPCI: iproc: Use of_property_read_bool() for boolean properties
Rob Herring [Fri, 9 Jun 2023 19:33:25 +0000 (13:33 -0600)]
PCI: iproc: Use of_property_read_bool() for boolean properties

Replace low-level property access functions like of_get_property() and
of_find_property() with their typed equivalents (i.e., of_property_read_<type>
functions), as it's preferred to use typed property access functions for
reading properties.

[kwilczynski: commit log]
Link: https://lore.kernel.org/linux-pci/20230609193326.1963542-1-robh@kernel.org
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Acked-by: Ray Jui <ray.jui@broadcom.com>
12 months agoPCI: apple: Initialize pcie->nvecs before use
Sven Peter [Sat, 11 Mar 2023 13:34:53 +0000 (14:34 +0100)]
PCI: apple: Initialize pcie->nvecs before use

The apple_pcie_setup_port() function computes ilog2(pcie->nvecs) to set
up the number of MSIs available for each port. However, it's called
before apple_msi_init(), which initializes pcie->nvecs.

Luckily, pcie->nvecs is part of kzalloc()-ed structure and, as such,
initialized as zero. ilog2(0) happens to be 0xffffffff which then simply
configures more MSIs in hardware than we have. This doesn't break
anything because we never hand out those vectors.

Thus, swap the order of the two calls so that the correctly initialized
value is then used.

[kwilczynski: commit log]
Link: https://lore.kernel.org/linux-pci/20230311133453.63246-1-sven@svenpeter.dev
Fixes: 476c41ed4597 ("PCI: apple: Implement MSI support")
Signed-off-by: Sven Peter <sven@svenpeter.dev>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Reviewed-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Eric Curtin <ecurtin@redhat.com>
12 months agoPCI/AER: Unexport pci_enable_pcie_error_reporting()
Bjorn Helgaas [Mon, 10 Jul 2023 23:21:36 +0000 (18:21 -0500)]
PCI/AER: Unexport pci_enable_pcie_error_reporting()

pci_enable_pcie_error_reporting() is used only inside aer.c.  Stop exposing
it outside the file.

Link: https://lore.kernel.org/r/20230710232136.233034-3-helgaas@kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
12 months agoPCI/AER: Drop unused pci_disable_pcie_error_reporting()
Bjorn Helgaas [Mon, 10 Jul 2023 23:21:35 +0000 (18:21 -0500)]
PCI/AER: Drop unused pci_disable_pcie_error_reporting()

pci_disable_pcie_error_reporting() has no callers.  Remove it.

Link: https://lore.kernel.org/r/20230710232136.233034-2-helgaas@kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
13 months agoLinux 6.5-rc1
Linus Torvalds [Sun, 9 Jul 2023 20:53:13 +0000 (13:53 -0700)]
Linux 6.5-rc1

13 months agoMAINTAINERS 2: Electric Boogaloo
Linus Torvalds [Sun, 9 Jul 2023 17:29:53 +0000 (10:29 -0700)]
MAINTAINERS 2: Electric Boogaloo

We just sorted the entries and fields last release, so just out of a
perverse sense of curiosity, I decided to see if we can keep things
ordered for even just one release.

The answer is "No. No we cannot".

I suggest that all kernel developers will need weekly training sessions,
involving a lot of Big Bird and Sesame Street.  And at the yearly
maintainer summit, we will all sing the alphabet song together.

I doubt I will keep doing this.  At some point "perverse sense of
curiosity" turns into just a cold dark place filled with sadness and
despair.

Repeats: 80e62bc8487b ("MAINTAINERS: re-sort all entries and fields")
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
13 months agoMerge tag 'dma-mapping-6.5-2023-07-09' of git://git.infradead.org/users/hch/dma-mapping
Linus Torvalds [Sun, 9 Jul 2023 17:24:22 +0000 (10:24 -0700)]
Merge tag 'dma-mapping-6.5-2023-07-09' of git://git.infradead.org/users/hch/dma-mapping

Pull dma-mapping fixes from Christoph Hellwig:

 - swiotlb area sizing fixes (Petr Tesarik)

* tag 'dma-mapping-6.5-2023-07-09' of git://git.infradead.org/users/hch/dma-mapping:
  swiotlb: reduce the number of areas to match actual memory pool size
  swiotlb: always set the number of areas before allocating the pool

13 months agoMerge tag 'irq_urgent_for_v6.5_rc1' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 9 Jul 2023 17:16:04 +0000 (10:16 -0700)]
Merge tag 'irq_urgent_for_v6.5_rc1' of git://git./linux/kernel/git/tip/tip

Pull irq update from Borislav Petkov:

 - Optimize IRQ domain's name assignment

* tag 'irq_urgent_for_v6.5_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  irqdomain: Use return value of strreplace()

13 months agoMerge tag 'x86_urgent_for_v6.5_rc1' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 9 Jul 2023 17:13:32 +0000 (10:13 -0700)]
Merge tag 'x86_urgent_for_v6.5_rc1' of git://git./linux/kernel/git/tip/tip

Pull x86 fpu fix from Borislav Petkov:

 - Do FPU AP initialization on Xen PV too which got missed by the recent
   boot reordering work

* tag 'x86_urgent_for_v6.5_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/xen: Fix secondary processors' FPU initialization

13 months agoMerge tag 'x86-core-2023-07-09' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sun, 9 Jul 2023 17:08:38 +0000 (10:08 -0700)]
Merge tag 'x86-core-2023-07-09' of git://git./linux/kernel/git/tip/tip

Pull x86 fix from Thomas Gleixner:
 "A single fix for the mechanism to park CPUs with an INIT IPI.

  On shutdown or kexec, the kernel tries to park the non-boot CPUs with
  an INIT IPI. But the same code path is also used by the crash utility.
  If the CPU which panics is not the boot CPU then it sends an INIT IPI
  to the boot CPU which resets the machine.

  Prevent this by validating that the CPU which runs the stop mechanism
  is the boot CPU. If not, leave the other CPUs in HLT"

* tag 'x86-core-2023-07-09' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/smp: Don't send INIT to boot CPU

13 months agoMerge tag 'mips_6.5_1' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux
Linus Torvalds [Sun, 9 Jul 2023 17:02:49 +0000 (10:02 -0700)]
Merge tag 'mips_6.5_1' of git://git./linux/kernel/git/mips/linux

Pull MIPS fixes from Thomas Bogendoerfer:

 - fixes for KVM

 - fix for loongson build and cpu probing

 - DT fixes

* tag 'mips_6.5_1' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux:
  MIPS: kvm: Fix build error with KVM_MIPS_DEBUG_COP0_COUNTERS enabled
  MIPS: dts: add missing space before {
  MIPS: Loongson: Fix build error when make modules_install
  MIPS: KVM: Fix NULL pointer dereference
  MIPS: Loongson: Fix cpu_probe_loongson() again

13 months agoMerge tag 'xfs-6.5-merge-6' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
Linus Torvalds [Sun, 9 Jul 2023 16:50:42 +0000 (09:50 -0700)]
Merge tag 'xfs-6.5-merge-6' of git://git./fs/xfs/xfs-linux

Pull xfs fix from Darrick Wong:
 "Nothing exciting here, just getting rid of a gcc warning that I got
  tired of seeing when I turn on gcov"

* tag 'xfs-6.5-merge-6' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
  xfs: fix uninit warning in xfs_growfs_data

13 months agoMerge tag '6.5-rc-smb3-client-fixes-part2' of git://git.samba.org/sfrench/cifs-2.6
Linus Torvalds [Sun, 9 Jul 2023 16:45:32 +0000 (09:45 -0700)]
Merge tag '6.5-rc-smb3-client-fixes-part2' of git://git.samba.org/sfrench/cifs-2.6

Pull more smb client updates from Steve French:

 - fix potential use after free in unmount

 - minor cleanup

 - add worker to cleanup stale directory leases

* tag '6.5-rc-smb3-client-fixes-part2' of git://git.samba.org/sfrench/cifs-2.6:
  cifs: Add a laundromat thread for cached directories
  smb: client: remove redundant pointer 'server'
  cifs: fix session state transition to avoid use-after-free issue

13 months agoMerge tag 'ntb-6.5' of https://github.com/jonmason/ntb
Linus Torvalds [Sun, 9 Jul 2023 16:35:51 +0000 (09:35 -0700)]
Merge tag 'ntb-6.5' of https://github.com/jonmason/ntb

Pull NTB updates from Jon Mason:
 "Fixes for pci_clean_master, error handling in driver inits, and
  various other issues/bugs"

* tag 'ntb-6.5' of https://github.com/jonmason/ntb:
  ntb: hw: amd: Fix debugfs_create_dir error checking
  ntb.rst: Fix copy and paste error
  ntb_netdev: Fix module_init problem
  ntb: intel: Remove redundant pci_clear_master
  ntb: epf: Remove redundant pci_clear_master
  ntb_hw_amd: Remove redundant pci_clear_master
  ntb: idt: drop redundant pci_enable_pcie_error_reporting()
  MAINTAINERS: git://github -> https://github.com for jonmason
  NTB: EPF: fix possible memory leak in pci_vntb_probe()
  NTB: ntb_tool: Add check for devm_kcalloc
  NTB: ntb_transport: fix possible memory leak while device_register() fails
  ntb: intel: Fix error handling in intel_ntb_pci_driver_init()
  NTB: amd: Fix error handling in amd_ntb_pci_driver_init()
  ntb: idt: Fix error handling in idt_pci_driver_init()

13 months agomm: lock newly mapped VMA with corrected ordering
Hugh Dickins [Sat, 8 Jul 2023 23:04:00 +0000 (16:04 -0700)]
mm: lock newly mapped VMA with corrected ordering

Lockdep is certainly right to complain about

  (&vma->vm_lock->lock){++++}-{3:3}, at: vma_start_write+0x2d/0x3f
                 but task is already holding lock:
  (&mapping->i_mmap_rwsem){+.+.}-{3:3}, at: mmap_region+0x4dc/0x6db

Invert those to the usual ordering.

Fixes: 33313a747e81 ("mm: lock newly mapped VMA which can be modified after it becomes visible")
Cc: stable@vger.kernel.org
Signed-off-by: Hugh Dickins <hughd@google.com>
Tested-by: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
13 months agoMerge tag 'mm-hotfixes-stable-2023-07-08-10-43' of git://git.kernel.org/pub/scm/linux...
Linus Torvalds [Sat, 8 Jul 2023 21:30:25 +0000 (14:30 -0700)]
Merge tag 'mm-hotfixes-stable-2023-07-08-10-43' of git://git./linux/kernel/git/akpm/mm

Pull hotfixes from Andrew Morton:
 "16 hotfixes. Six are cc:stable and the remainder address post-6.4
  issues"

The merge undoes the disabling of the CONFIG_PER_VMA_LOCK feature, since
it was all hopefully fixed in mainline.

* tag 'mm-hotfixes-stable-2023-07-08-10-43' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm:
  lib: dhry: fix sleeping allocations inside non-preemptable section
  kasan, slub: fix HW_TAGS zeroing with slub_debug
  kasan: fix type cast in memory_is_poisoned_n
  mailmap: add entries for Heiko Stuebner
  mailmap: update manpage link
  bootmem: remove the vmemmap pages from kmemleak in free_bootmem_page
  MAINTAINERS: add linux-next info
  mailmap: add Markus Schneider-Pargmann
  writeback: account the number of pages written back
  mm: call arch_swap_restore() from do_swap_page()
  squashfs: fix cache race with migration
  mm/hugetlb.c: fix a bug within a BUG(): inconsistent pte comparison
  docs: update ocfs2-devel mailing list address
  MAINTAINERS: update ocfs2-devel mailing list address
  mm: disable CONFIG_PER_VMA_LOCK until its fixed
  fork: lock VMAs of the parent process when forking

13 months agofork: lock VMAs of the parent process when forking
Suren Baghdasaryan [Sat, 8 Jul 2023 19:12:12 +0000 (12:12 -0700)]
fork: lock VMAs of the parent process when forking

When forking a child process, the parent write-protects anonymous pages
and COW-shares them with the child being forked using copy_present_pte().

We must not take any concurrent page faults on the source vma's as they
are being processed, as we expect both the vma and the pte's behind it
to be stable.  For example, the anon_vma_fork() expects the parents
vma->anon_vma to not change during the vma copy.

A concurrent page fault on a page newly marked read-only by the page
copy might trigger wp_page_copy() and a anon_vma_prepare(vma) on the
source vma, defeating the anon_vma_clone() that wasn't done because the
parent vma originally didn't have an anon_vma, but we now might end up
copying a pte entry for a page that has one.

Before the per-vma lock based changes, the mmap_lock guaranteed
exclusion with concurrent page faults.  But now we need to do a
vma_start_write() to make sure no concurrent faults happen on this vma
while it is being processed.

This fix can potentially regress some fork-heavy workloads.  Kernel
build time did not show noticeable regression on a 56-core machine while
a stress test mapping 10000 VMAs and forking 5000 times in a tight loop
shows ~5% regression.  If such fork time regression is unacceptable,
disabling CONFIG_PER_VMA_LOCK should restore its performance.  Further
optimizations are possible if this regression proves to be problematic.

Suggested-by: David Hildenbrand <david@redhat.com>
Reported-by: Jiri Slaby <jirislaby@kernel.org>
Closes: https://lore.kernel.org/all/dbdef34c-3a07-5951-e1ae-e9c6e3cdf51b@kernel.org/
Reported-by: Holger Hoffstätte <holger@applied-asynchrony.com>
Closes: https://lore.kernel.org/all/b198d649-f4bf-b971-31d0-e8433ec2a34c@applied-asynchrony.com/
Reported-by: Jacob Young <jacobly.alt@gmail.com>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217624
Fixes: 0bff0aaea03e ("x86/mm: try VMA lock-based page fault handling first")
Cc: stable@vger.kernel.org
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
13 months agomm: lock newly mapped VMA which can be modified after it becomes visible
Suren Baghdasaryan [Sat, 8 Jul 2023 19:12:11 +0000 (12:12 -0700)]
mm: lock newly mapped VMA which can be modified after it becomes visible

mmap_region adds a newly created VMA into VMA tree and might modify it
afterwards before dropping the mmap_lock.  This poses a problem for page
faults handled under per-VMA locks because they don't take the mmap_lock
and can stumble on this VMA while it's still being modified.  Currently
this does not pose a problem since post-addition modifications are done
only for file-backed VMAs, which are not handled under per-VMA lock.
However, once support for handling file-backed page faults with per-VMA
locks is added, this will become a race.

Fix this by write-locking the VMA before inserting it into the VMA tree.
Other places where a new VMA is added into VMA tree do not modify it
after the insertion, so do not need the same locking.

Cc: stable@vger.kernel.org
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
13 months agomm: lock a vma before stack expansion
Suren Baghdasaryan [Sat, 8 Jul 2023 19:12:10 +0000 (12:12 -0700)]
mm: lock a vma before stack expansion

With recent changes necessitating mmap_lock to be held for write while
expanding a stack, per-VMA locks should follow the same rules and be
write-locked to prevent page faults into the VMA being expanded. Add
the necessary locking.

Cc: stable@vger.kernel.org
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
13 months agoMerge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Linus Torvalds [Sat, 8 Jul 2023 19:35:18 +0000 (12:35 -0700)]
Merge tag 'scsi-misc' of git://git./linux/kernel/git/jejb/scsi

Pull more SCSI updates from James Bottomley:
 "A few late arriving patches that missed the initial pull request. It's
  mostly bug fixes (the dt-bindings is a fix for the initial pull)"

* tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
  scsi: ufs: core: Remove unused function declaration
  scsi: target: docs: Remove tcm_mod_builder.py
  scsi: target: iblock: Quiet bool conversion warning with pr_preempt use
  scsi: dt-bindings: ufs: qcom: Fix ICE phandle
  scsi: core: Simplify scsi_cdl_check_cmd()
  scsi: isci: Fix comment typo
  scsi: smartpqi: Replace one-element arrays with flexible-array members
  scsi: target: tcmu: Replace strlcpy() with strscpy()
  scsi: ncr53c8xx: Replace strlcpy() with strscpy()
  scsi: lpfc: Fix lpfc_name struct packing

13 months agoMerge tag 'i2c-for-6.5-rc1-part2' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sat, 8 Jul 2023 19:28:00 +0000 (12:28 -0700)]
Merge tag 'i2c-for-6.5-rc1-part2' of git://git./linux/kernel/git/wsa/linux

Pull more i2c updates from Wolfram Sang:

 - xiic patch should have been in the original pull but slipped through

 - mpc patch fixes a build regression

 - nomadik cleanup

* tag 'i2c-for-6.5-rc1-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
  i2c: mpc: Drop unused variable
  i2c: nomadik: Remove a useless call in the remove function
  i2c: xiic: Don't try to handle more interrupt events after error

13 months agoMerge tag 'hardening-v6.5-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sat, 8 Jul 2023 19:08:39 +0000 (12:08 -0700)]
Merge tag 'hardening-v6.5-rc1-fixes' of git://git./linux/kernel/git/kees/linux

Pull hardening fixes from Kees Cook:

 - Check for NULL bdev in LoadPin (Matthias Kaehlcke)

 - Revert unwanted KUnit FORTIFY build default

 - Fix 1-element array causing boot warnings with xhci-hub

* tag 'hardening-v6.5-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
  usb: ch9: Replace bmSublinkSpeedAttr 1-element array with flexible array
  Revert "fortify: Allow KUnit test to build without FORTIFY"
  dm: verity-loadpin: Add NULL pointer check for 'bdev' parameter

13 months agontb: hw: amd: Fix debugfs_create_dir error checking
Anup Sharma [Fri, 12 May 2023 20:24:34 +0000 (01:54 +0530)]
ntb: hw: amd: Fix debugfs_create_dir error checking

The debugfs_create_dir function returns ERR_PTR in case of error, and the
only correct way to check if an error occurred is 'IS_ERR' inline function.
This patch will replace the null-comparison with IS_ERR.

Signed-off-by: Anup Sharma <anupnewsmail@gmail.com>
Suggested-by: Ivan Orlov <ivan.orlov0322@gmail.com>
Signed-off-by: Jon Mason <jdmason@kudzu.us>
13 months agoMerge tag 'perf-tools-for-v6.5-2-2023-07-06' of git://git.kernel.org/pub/scm/linux...
Linus Torvalds [Sat, 8 Jul 2023 17:21:51 +0000 (10:21 -0700)]
Merge tag 'perf-tools-for-v6.5-2-2023-07-06' of git://git./linux/kernel/git/perf/perf-tools-next

Pull more perf tools updates from Namhyung Kim:
 "These are remaining changes and fixes for this cycle.

  Build:

   - Allow generating vmlinux.h from BTF using `make GEN_VMLINUX_H=1`
     and skip if the vmlinux has no BTF.

   - Replace deprecated clang -target xxx option by --target=xxx.

  perf record:

   - Print event attributes with well known type and config symbols in
     the debug output like below:

       # perf record -e cycles,cpu-clock -C0 -vv true
       <SNIP>
       ------------------------------------------------------------
       perf_event_attr:
         type                             0 (PERF_TYPE_HARDWARE)
         size                             136
         config                           0 (PERF_COUNT_HW_CPU_CYCLES)
         { sample_period, sample_freq }   4000
         sample_type                      IP|TID|TIME|CPU|PERIOD|IDENTIFIER
         read_format                      ID
         disabled                         1
         inherit                          1
         freq                             1
         sample_id_all                    1
         exclude_guest                    1
       ------------------------------------------------------------
       sys_perf_event_open: pid -1  cpu 0  group_fd -1  flags 0x8 = 5
       ------------------------------------------------------------
       perf_event_attr:
         type                             1 (PERF_TYPE_SOFTWARE)
         size                             136
         config                           0 (PERF_COUNT_SW_CPU_CLOCK)
         { sample_period, sample_freq }   4000
         sample_type                      IP|TID|TIME|CPU|PERIOD|IDENTIFIER
         read_format                      ID
         disabled                         1
         inherit                          1
         freq                             1
         sample_id_all                    1
         exclude_guest                    1

   - Update AMD IBS event error message since it now support per-process
     profiling but no priviledge filters.

       $ sudo perf record -e ibs_op//k -C 0
       Error:
       AMD IBS doesn't support privilege filtering. Try again without
       the privilege modifiers (like 'k') at the end.

  perf lock contention:

   - Support CSV style output using -x option

       $ sudo perf lock con -ab -x, sleep 1
       # output: contended, total wait, max wait, avg wait, type, caller
       19, 194232, 21415, 10222, spinlock, process_one_work+0x1f0
       15, 162748, 23843, 10849, rwsem:R, do_user_addr_fault+0x40e
       4, 86740, 23415, 21685, rwlock:R, ep_poll_callback+0x2d
       1, 84281, 84281, 84281, mutex, iwl_mvm_async_handlers_wk+0x135
       8, 67608, 27404, 8451, spinlock, __queue_work+0x174
       3, 58616, 31125, 19538, rwsem:W, do_mprotect_pkey+0xff
       3, 52953, 21172, 17651, rwlock:W, do_epoll_wait+0x248
       2, 30324, 19704, 15162, rwsem:R, do_madvise+0x3ad
       1, 24619, 24619, 24619, spinlock, rcu_core+0xd4

   - Add --output option to save the data to a file not to be interfered
     by other debug messages.

  Test:

   - Fix event parsing test on ARM where there's no raw PMU nor supports
     PERF_PMU_CAP_EXTENDED_HW_TYPE.

   - Update the lock contention test case for CSV output.

   - Fix a segfault in the daemon command test.

  Vendor events (JSON):

   - Add has_event() to check if the given event is available on system
     at runtime. On Intel machines, some transaction events may not be
     present when TSC extensions are disabled.

   - Update Intel event metrics.

  Misc:

   - Sort symbols by name using an external array of pointers instead of
     a rbtree node in the symbol. This will save 16-bytes or 24-bytes
     per symbol whether the sorting is actually requested or not.

   - Fix unwinding DWARF callstacks using libdw when --symfs option is
     used"

* tag 'perf-tools-for-v6.5-2-2023-07-06' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next: (38 commits)
  perf test: Fix event parsing test when PERF_PMU_CAP_EXTENDED_HW_TYPE isn't supported.
  perf test: Fix event parsing test on Arm
  perf evsel amd: Fix IBS error message
  perf: unwind: Fix symfs with libdw
  perf symbol: Fix uninitialized return value in symbols__find_by_name()
  perf test: Test perf lock contention CSV output
  perf lock contention: Add --output option
  perf lock contention: Add -x option for CSV style output
  perf lock: Remove stale comments
  perf vendor events intel: Update tigerlake to 1.13
  perf vendor events intel: Update skylakex to 1.31
  perf vendor events intel: Update skylake to 57
  perf vendor events intel: Update sapphirerapids to 1.14
  perf vendor events intel: Update icelakex to 1.21
  perf vendor events intel: Update icelake to 1.19
  perf vendor events intel: Update cascadelakex to 1.19
  perf vendor events intel: Update meteorlake to 1.03
  perf vendor events intel: Add rocketlake events/metrics
  perf vendor metrics intel: Make transaction metrics conditional
  perf jevents: Support for has_event function
  ...