]> git.karo-electronics.de Git - karo-tx-linux.git/log
karo-tx-linux.git
7 years agoMerge branch 'pci/host-rockchip' into next
Bjorn Helgaas [Tue, 4 Jul 2017 16:00:59 +0000 (11:00 -0500)]
Merge branch 'pci/host-rockchip' into next

* pci/host-rockchip:
  PCI: rockchip: Use normal register bank for config accessors
  PCI: rockchip: Use local struct device pointer consistently
  PCI: rockchip: Check for clk_prepare_enable() errors during resume
  MAINTAINERS: Remove Wenrui Li as Rockchip PCIe driver maintainer
  PCI: rockchip: Configure RC's MPS setting
  PCI: rockchip: Reconfigure configuration space header type
  PCI: rockchip: Split out rockchip_pcie_cfg_configuration_accesses()
  PCI: rockchip: Move configuration accesses into rockchip_pcie_cfg_atu()
  PCI: rockchip: Rename rockchip_cfg_atu() to rockchip_pcie_cfg_atu()
  PCI: rockchip: Control vpcie0v9 for system PM

7 years agoMerge branch 'pci/host-rcar' into next
Bjorn Helgaas [Tue, 4 Jul 2017 16:00:58 +0000 (11:00 -0500)]
Merge branch 'pci/host-rcar' into next

* pci/host-rcar:
  PCI: rcar-gen2: Make of_device_ids const
  PCI: rcar: Use proper name for the R-Car SoC

7 years agoMerge branch 'pci/host-qcom' into next
Bjorn Helgaas [Tue, 4 Jul 2017 16:00:57 +0000 (11:00 -0500)]
Merge branch 'pci/host-qcom' into next

* pci/host-qcom:
  PCI: qcom: Limit TLP size to 2K to work around hardware issue
  PCI: qcom: Fix spelling mistake: "asser" -> "assert"
  PCI: qcom: Reorder to put v0 functions together, v1 functions together, etc
  PCI: qcom: Add support for IPQ4019 PCIe controller

7 years agoMerge branch 'pci/host-mediatek' into next
Bjorn Helgaas [Tue, 4 Jul 2017 16:00:57 +0000 (11:00 -0500)]
Merge branch 'pci/host-mediatek' into next

* pci/host-mediatek:
  dt-bindings: PCI: Add documentation for MediaTek PCIe
  PCI: mediatek: Add MediaTek PCIe host controller support

7 years agoMerge branch 'pci/host-kirin' into next
Bjorn Helgaas [Tue, 4 Jul 2017 16:00:56 +0000 (11:00 -0500)]
Merge branch 'pci/host-kirin' into next

* pci/host-kirin:
  PCI: kirin: Add HiSilicon Kirin SoC PCIe controller driver

7 years agoPCI: rockchip: Use normal register bank for config accessors
Shawn Lin [Mon, 3 Jul 2017 09:21:02 +0000 (17:21 +0800)]
PCI: rockchip: Use normal register bank for config accessors

Rockchip's RC has two banks of registers for the root port: a normal bank
that is strictly compatible with the PCIe spec, and a privileged bank that
can be used to change RO bits of root port registers.

When probing the RC driver, we use the privileged bank to do some basic
setup work as some RO bits are hw-inited to wrong value.  But we didn't
change to the normal bank after probing the driver.

This leads to a serious problem when the PME code tries to clear the PME
status by writing PCI_EXP_RTSTA_PME to the register of PCI_EXP_RTSTA.  Per
PCIe 3.0 spec, section 7.8.14, the PME status bit is RW1C.  So the PME code
is doing the right thing to clear the PME status but we find the RC doesn't
clear it but actually setting it to one.  So finally the system trap in
pcie_pme_work_fn() as PCI_EXP_RTSTA_PME is true now forever.  This issue
can be reproduced by booting kernel with pci=nomsi.

Use the normal register bank for the PCI config accessors.  The privileged
bank is used only internally by this driver.

Fixes: e77f847d ("PCI: rockchip: Add Rockchip PCIe controller support")
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: stable@vger.kernel.org
Cc: Jeffy Chen <jeffy.chen@rock-chips.com>
Cc: Brian Norris <briannorris@chromium.org>
7 years agodt-bindings: PCI: Add documentation for MediaTek PCIe
Ryder Lee [Sun, 21 May 2017 03:42:25 +0000 (11:42 +0800)]
dt-bindings: PCI: Add documentation for MediaTek PCIe

Add documentation for PCIe host driver available in MT7623 series SoCs.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rob Herring <robh@kernel.org>
7 years agoMerge branch 'pci/host-imx6' into next
Bjorn Helgaas [Mon, 3 Jul 2017 13:00:32 +0000 (08:00 -0500)]
Merge branch 'pci/host-imx6' into next

* pci/host-imx6:
  PCI: imx6: Add regulator support

7 years agoMerge branch 'pci/host-hv' into next
Bjorn Helgaas [Mon, 3 Jul 2017 13:00:31 +0000 (08:00 -0500)]
Merge branch 'pci/host-hv' into next

* pci/host-hv:
  PCI: hv: Use vPCI protocol version 1.2
  PCI: hv: Add vPCI version protocol negotiation
  PCI: hv: Temporary own CPU-number-to-vCPU-number infra
  PCI: hv: Use page allocation for hbus structure
  PCI: hv: Fix comment formatting and use proper integer fields

7 years agoMerge branch 'pci/host-faraday' into next
Bjorn Helgaas [Mon, 3 Jul 2017 13:00:31 +0000 (08:00 -0500)]
Merge branch 'pci/host-faraday' into next

* pci/host-faraday:
  PCI: faraday: Add clock handling
  PCI: faraday: Add clock bindings

7 years agoMerge branch 'pci/host-dra7xx' into next
Bjorn Helgaas [Mon, 3 Jul 2017 13:00:30 +0000 (08:00 -0500)]
Merge branch 'pci/host-dra7xx' into next

* pci/host-dra7xx:
  PCI: dwc: dra7xx: Use RW1C for IRQSTATUS_MSI and IRQSTATUS_MAIN
  PCI: dwc: dra7xx: Depend on appropriate SoC or compile test

7 years agoMerge branch 'pci/host-designware' into next
Bjorn Helgaas [Mon, 3 Jul 2017 13:00:30 +0000 (08:00 -0500)]
Merge branch 'pci/host-designware' into next

* pci/host-designware:
  PCI: dwc: Constify dw_pcie_host_ops structures
  PCI: host: Mark PCIe/PCI (MSI) cascade ISR as IRQF_NO_THREAD

7 years agoMerge branch 'pci/irq-fixups' into next
Bjorn Helgaas [Mon, 3 Jul 2017 13:00:29 +0000 (08:00 -0500)]
Merge branch 'pci/irq-fixups' into next

* pci/irq-fixups:
  arm64: PCI: Drop DT IRQ allocation from pcibios_alloc_irq()
  PCI: xilinx-nwl: Move to struct pci_host_bridge IRQ mapping functions
  PCI: rockchip: Move to struct pci_host_bridge IRQ mapping functions
  PCI: xgene: Move to struct pci_host_bridge IRQ mapping functions
  PCI: altera: Drop pci_fixup_irqs()
  PCI: versatile: Drop pci_fixup_irqs()
  PCI: generic: Drop pci_fixup_irqs()
  PCI: faraday: Drop pci_fixup_irqs()
  PCI: designware: Drop pci_fixup_irqs()
  PCI: iproc: Drop pci_fixup_irqs()
  PCI: rcar: Drop pci_fixup_irqs()
  PCI: xilinx: Drop pci_fixup_irqs()
  PCI: tegra: Drop pci_fixup_irqs()
  ARM/PCI: Remove pci_fixup_irqs() call for bios32 host controllers
  PCI: Add a call to pci_assign_irq() in pci_device_probe()
  OF/PCI: Update of_irq_parse_and_map_pci() comment
  PCI: Add pci_assign_irq() function and have pci_fixup_irqs() use it
  PCI: Add IRQ mapping function pointers to pci_host_bridge struct
  PCI: Build setup-irq.o on all arches
  PCI: Remove pci_scan_root_bus_msi()
  PCI: xilinx-nwl: Convert PCI scan API to pci_scan_root_bus_bridge()
  PCI: rockchip: Convert PCI scan API to pci_scan_root_bus_bridge()
  PCI: generic: Convert PCI scan API to pci_scan_root_bus_bridge()
  PCI: xgene: Convert PCI scan API to pci_scan_root_bus_bridge()
  PCI: xilinx: Convert PCI scan API to pci_scan_root_bus_bridge()
  PCI: altera: Convert PCI scan API to pci_scan_root_bus_bridge()
  PCI: versatile: Convert PCI scan API to pci_scan_root_bus_bridge()
  PCI: iproc: Convert PCI scan API to pci_scan_root_bus_bridge()
  PCI: rcar: Convert PCI scan API to pci_scan_root_bus_bridge()
  PCI: aardvark: Convert PCI scan API to pci_scan_root_bus_bridge()
  PCI: designware: Convert PCI scan API to pci_scan_root_bus_bridge()
  ARM/PCI: Convert PCI scan API to pci_scan_root_bus_bridge()
  PCI: Make pci_register_host_bridge() PCI core internal
  PCI: Add pci_scan_root_bus_bridge() interface
  PCI: tegra: Fix host bridge memory leakage
  PCI: faraday: Fix host bridge memory leakage
  PCI: Add devm_pci_alloc_host_bridge() interface
  PCI: Add pci_free_host_bridge() interface
  PCI: Initialize bridge release function at bridge allocation
  PCI: faraday: Convert IRQ masking to raw PCI config accessors
  PCI: iproc: Convert link check to raw PCI config accessors
  PCI: xilinx-nwl: Remove nwl_pcie_enable_msi() unused bus parameter

7 years agoMerge branch 'pci/virtualization' into next
Bjorn Helgaas [Mon, 3 Jul 2017 13:00:29 +0000 (08:00 -0500)]
Merge branch 'pci/virtualization' into next

* pci/virtualization:
  PCI: Remove __pci_dev_reset() and pci_dev_reset()
  PCI: Split ->reset_notify() method into ->reset_prepare() and ->reset_done()
  PCI: Protect pci_error_handlers->reset_notify() usage with device_lock()
  PCI: Protect pci_driver->sriov_configure() usage with device_lock()
  PCI: Mark Intel XXV710 NIC INTx masking as broken
  PCI: Restore PRI and PASID state after Function-Level Reset
  PCI: Cache PRI and PASID bits in pci_dev

7 years agoPCI: Remove __pci_dev_reset() and pci_dev_reset()
Christoph Hellwig [Thu, 1 Jun 2017 11:10:39 +0000 (13:10 +0200)]
PCI: Remove __pci_dev_reset() and pci_dev_reset()

Implement the reset probing / reset chain directly in
__pci_probe_reset_function() and __pci_reset_function_locked()
respectively.

Link: http://lkml.kernel.org/r/20170601111039.8913-4-hch@lst.de
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: Split ->reset_notify() method into ->reset_prepare() and ->reset_done()
Christoph Hellwig [Thu, 1 Jun 2017 11:10:38 +0000 (13:10 +0200)]
PCI: Split ->reset_notify() method into ->reset_prepare() and ->reset_done()

The pci_error_handlers->reset_notify() method had a flag to indicate
whether to prepare for or clean up after a reset.  The prepare and done
cases have no shared functionality whatsoever, so split them into separate
methods.

[bhelgaas: changelog, update locking comments]
Link: http://lkml.kernel.org/r/20170601111039.8913-3-hch@lst.de
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoMerge branch 'pci/switchtec' into next
Bjorn Helgaas [Sun, 2 Jul 2017 23:51:10 +0000 (18:51 -0500)]
Merge branch 'pci/switchtec' into next

* pci/switchtec:
  switchtec: Add device IDs for additional Switchtec products
  switchtec: Add "running" status flag to fw partition info ioctl

7 years agoMerge branch 'pci/resource' into next
Bjorn Helgaas [Sun, 2 Jul 2017 23:49:49 +0000 (18:49 -0500)]
Merge branch 'pci/resource' into next

* pci/resource:
  PCI: Work around poweroff & suspend-to-RAM issue on Macbook Pro 11
  PCI: Do not disregard parent resources starting at 0x0

Conflicts:
arch/x86/pci/fixup.c

7 years agoMerge branch 'pci/portdrv' into next
Bjorn Helgaas [Sun, 2 Jul 2017 23:48:50 +0000 (18:48 -0500)]
Merge branch 'pci/portdrv' into next

* pci/portdrv:
  PCI/portdrv: Allocate MSI/MSI-X vector for Downstream Port Containment
  PCI/portdrv: Support multiple interrupts for MSI as well as MSI-X

7 years agoMerge branch 'pci/pm' into next
Bjorn Helgaas [Sun, 2 Jul 2017 23:48:49 +0000 (18:48 -0500)]
Merge branch 'pci/pm' into next

* pci/pm:
  PCI/PM: Avoid using device_may_wakeup() for runtime PM
  x86/PCI: Avoid AMD SB7xx EHCI USB wakeup defect
  PCI/PM: Restore the status of PCI devices across hibernation
  drm/radeon: make MacBook Pro d3_delay quirk more generic
  drm/amdgpu: remove unnecessary save/restore of pdev->d3_delay
  PCI/PM: Add needs_resume flag to avoid suspend complete optimization
  PCI: imx6: Fix config read timeout handling
  switchtec: Fix minor bug with partition ID register
  switchtec: Use new cdev_device_add() helper function
  PCI: endpoint: Make PCI_ENDPOINT depend on HAS_DMA

7 years agoMerge branch 'pci/msi' into next
Bjorn Helgaas [Sun, 2 Jul 2017 23:48:49 +0000 (18:48 -0500)]
Merge branch 'pci/msi' into next

* pci/msi:
  PCI/MSI: Ignore affinity if pre/post vector count is more than min_vecs

7 years agoMerge branch 'pci/misc' into next
Bjorn Helgaas [Sun, 2 Jul 2017 23:48:48 +0000 (18:48 -0500)]
Merge branch 'pci/misc' into next

* pci/misc:
  x86/PCI: Simplify Dell DMI B1 quirk
  PCI: Add domain number check to find_smbios_instance_string()
  x86/PCI: Fix whitespace in set_bios_x() printk
  PCI: Correct PCI_STD_RESOURCE_END usage
  efi/fb: Correct PCI_STD_RESOURCE_END usage
  MIPS: PCI: Remove unused busn_offset
  MIPS: Loongson: Remove unused PCI_BAR_COUNT definition

7 years agoMerge branch 'pci/enumeration' into next
Bjorn Helgaas [Sun, 2 Jul 2017 23:48:47 +0000 (18:48 -0500)]
Merge branch 'pci/enumeration' into next

* pci/enumeration:
  PCI: Enable ECRC only if device supports it
  PCI: Add sysfs max_link_speed/width, current_link_speed/width, etc
  PCI: Test INTx masking during enumeration, not at run-time

7 years agoMerge branch 'pci/dpc' into next
Bjorn Helgaas [Sun, 2 Jul 2017 23:48:47 +0000 (18:48 -0500)]
Merge branch 'pci/dpc' into next

* pci/dpc:
  PCI/DPC: Fix control register setting
  PCI/DPC: Skip DPC event if device is not present

7 years agoPCI: rockchip: Use local struct device pointer consistently
Shawn Lin [Thu, 29 Jun 2017 01:22:49 +0000 (09:22 +0800)]
PCI: rockchip: Use local struct device pointer consistently

We have a local "struct device *dev" in rockchip_pcie_probe().  Use it
consistently throughout the function.  No functional change intended.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: rockchip: Check for clk_prepare_enable() errors during resume
Arvind Yadav [Thu, 15 Jun 2017 21:41:25 +0000 (16:41 -0500)]
PCI: rockchip: Check for clk_prepare_enable() errors during resume

clk_prepare_enable() can fail here and we must check its return value.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Acked-by: Shawn Lin <shawn.lin@rock-chips.com>
7 years agoMAINTAINERS: Remove Wenrui Li as Rockchip PCIe driver maintainer
Shawn Lin [Fri, 2 Jun 2017 07:42:13 +0000 (15:42 +0800)]
MAINTAINERS: Remove Wenrui Li as Rockchip PCIe driver maintainer

Wenrui Li changed his employer and is no longer able to maintain the
Rockchip PCIe driver, so remove his email address from this file.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: rockchip: Configure RC's MPS setting
Shawn Lin [Tue, 23 May 2017 19:32:56 +0000 (14:32 -0500)]
PCI: rockchip: Configure RC's MPS setting

The default value of MPS for RC is 128 bytes, but actually it could support
256 bytes.  So this patch fixes this issue.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: rockchip: Reconfigure configuration space header type
Shawn Lin [Thu, 4 May 2017 02:24:51 +0000 (10:24 +0800)]
PCI: rockchip: Reconfigure configuration space header type

Per PCIe base specification (Revision 3.1a), section 7.5.3, type 1
configuration space header should be used when accessing PCIe switch.  So
we need to reconfigure the header according to the bus number we are
accessing.  Otherwise we could not visit the buses behind the switch.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: rockchip: Split out rockchip_pcie_cfg_configuration_accesses()
Shawn Lin [Thu, 4 May 2017 02:24:50 +0000 (10:24 +0800)]
PCI: rockchip: Split out rockchip_pcie_cfg_configuration_accesses()

We need to reconfigure the header type later, so split out a new function.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: rockchip: Move configuration accesses into rockchip_pcie_cfg_atu()
Shawn Lin [Thu, 4 May 2017 02:24:49 +0000 (10:24 +0800)]
PCI: rockchip: Move configuration accesses into rockchip_pcie_cfg_atu()

Configuration accesses is also part of ATU settings, so let's keep all of
them inside rockchip_pcie_cfg_atu().

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: rockchip: Rename rockchip_cfg_atu() to rockchip_pcie_cfg_atu()
Shawn Lin [Thu, 4 May 2017 02:24:48 +0000 (10:24 +0800)]
PCI: rockchip: Rename rockchip_cfg_atu() to rockchip_pcie_cfg_atu()

Rename rockchip_cfg_atu() to keep the name consistent with other functions
in pcie-rockchip.c.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: rockchip: Control vpcie0v9 for system PM
Shawn Lin [Tue, 2 May 2017 07:31:23 +0000 (15:31 +0800)]
PCI: rockchip: Control vpcie0v9 for system PM

vpcie0v9 is used for PHY, so we could disable it as we don't need PHY to
work then in S3 if folks assign it DT.  But we should note that there is a
side effect that we could not support beacon wakeup if we disable vpcie0v9
for aggressive power-saving.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Brian Norris <briannorris@chromium.org>
Cc: Jeffy Chen <jeffy.chen@rock-chips.com>
7 years agoPCI: rcar-gen2: Make of_device_ids const
Arvind Yadav [Fri, 23 Jun 2017 09:29:52 +0000 (14:59 +0530)]
PCI: rcar-gen2: Make of_device_ids const

of_device_ids are not supposed to change at runtime.  All functions working
with of_device_ids provided by <linux/of.h> work with const of_device_ids.
So mark the non-const structs as const.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Simon Horman <horms+renesas@verge.net.au>
Acked-by: Geert Uytterhoeven <geert+renesas@glider.be>
7 years agoPCI: rcar: Use proper name for the R-Car SoC
Wolfram Sang [Sun, 28 May 2017 09:30:48 +0000 (11:30 +0200)]
PCI: rcar: Use proper name for the R-Car SoC

It is 'R-Car', not 'RCar'. No code or binding changes, only descriptive
text.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Simon Horman <horms+renesas@verge.net.au>
7 years agoPCI: qcom: Limit TLP size to 2K to work around hardware issue
Srinivas Kandagatla [Thu, 29 Jun 2017 15:34:55 +0000 (17:34 +0200)]
PCI: qcom: Limit TLP size to 2K to work around hardware issue

Limit TLP size to 2K to work around a hardware bug in the v0 version of
PCIe IP.  When using default TLP size of 4K, the internal buffer gets
corrupted due to this hardware bug.

This bug was originally noticed during ssh session between APQ8064-based
board and PC.  Network packets got corrupted randomly and terminated the ssh
session due to this bug.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: qcom: Fix spelling mistake: "asser" -> "assert"
Colin Ian King [Wed, 31 May 2017 05:34:14 +0000 (06:34 +0100)]
PCI: qcom: Fix spelling mistake: "asser" -> "assert"

Trivial fix to spelling mistake in dev_err message.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: qcom: Reorder to put v0 functions together, v1 functions together, etc
Bjorn Helgaas [Wed, 24 May 2017 20:19:36 +0000 (15:19 -0500)]
PCI: qcom: Reorder to put v0 functions together, v1 functions together, etc

Previously the v0, v1, and v2 functions were not grouped together in a
consistent order.  Reorder them to make them consistent.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: qcom: Add support for IPQ4019 PCIe controller
John Crispin [Tue, 23 May 2017 20:02:28 +0000 (15:02 -0500)]
PCI: qcom: Add support for IPQ4019 PCIe controller

Add support for the IPQ4019 PCIe controller.  IPQ4019 supports Gen 1/2, one
lane, one PCIe root complex with support for MSI and legacy interrupts, and
it conforms to PCI Express Base 2.1 specification.

The core init is the same as for the MSM8996, however the clocks and reset
lines differ.

[bhelgaas: fix qcom_pcie_get_resources_v3(), qcom_pcie_init_v3() compile
issues]
Signed-off-by: John Crispin <john@phrozen.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Stanimir Varbanov <svarbanov@mm-sol.com>
Acked-by: Rob Herring <robh@kernel.org> # binding
7 years agoPCI: mediatek: Add MediaTek PCIe host controller support
Ryder Lee [Sun, 21 May 2017 03:42:24 +0000 (11:42 +0800)]
PCI: mediatek: Add MediaTek PCIe host controller support

Add support for the MediaTek PCIe Gen2 controller which can be found on
MT7623 series SoCs.

[bhelgaas: fold in mtk_pcie_parse_and_add_res() bugfix from
http://lkml.kernel.org/r/1496644078-27122-1-git-send-email-ryder.lee@mediatek.com]
[bhelgaas: fold in MAINTAINERS update from
http://lkml.kernel.org/r/1497588789-28607-1-git-send-email-ryder.lee@mediatek.com]
[bhelgaas: fold in pci_scan_root_bus_bridge() update and leak fix from
http://lkml.kernel.org/r/1498555451-55073-2-git-send-email-ryder.lee@mediatek.com]
[bhelgaas: fold in powerup fixes from
http://lkml.kernel.org/r/1497866400-41844-2-git-send-email-ryder.lee@mediatek.com]
[bhelgaas: fold in poweroff when link down fixes from
http://lkml.kernel.org/r/1497866400-41844-3-git-send-email-ryder.lee@mediatek.com]
[bhelgaas: fold in optional property fixes from
http://lkml.kernel.org/r/1497866400-41844-4-git-send-email-ryder.lee@mediatek.com]
[bhelgaas: set host->map_irq and host->swizzle_irq and drop
pci_fixup_irqs(), remove unnecessary "return", rename mtk_pcie_link_is_up()
to mtk_pcie_link_up() for consistency, add local struct device pointer]
[bhelgaas: fold in pci_add_flags() removal from
http://lkml.kernel.org/r/1499061300-55951-1-git-send-email-ryder.lee@mediatek.com]
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: kirin: Add HiSilicon Kirin SoC PCIe controller driver
Xiaowei Song [Mon, 19 Jun 2017 10:23:48 +0000 (18:23 +0800)]
PCI: kirin: Add HiSilicon Kirin SoC PCIe controller driver

Hisilicon PCIe driver shares the common functions for PCIe dw-host.

The poweron functions are developed on hi3660 SoC, while other functions
are common for Kirin series SoCs.

Low power mode (L1 sub-state and Suspend/Resume), hotplug and MSI feature
are not supported currently.

Signed-off-by: Xiaowei Song <songxiaowei@hisilicon.com>
[bhelgaas: fold in MAINTAINERS update from
http://lkml.kernel.org/r/20170704021516.96575-1-songxiaowei@hisilicon.com]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Jingoo Han <jingoohan1@gmail.com>
Cc: Guodong Xu <guodong.xu@linaro.org>
7 years agoPCI: imx6: Add regulator support
Quentin Schulz [Thu, 8 Jun 2017 08:07:42 +0000 (10:07 +0200)]
PCI: imx6: Add regulator support

Some boards might require to control a regulator to power the PCIe port.

Add support for an optional regulator defined in Device Tree linked in the
PCIe controller under `vpcie-supply`.  If present, the regulator will be
disabled and then enabled as part of the PCIe host initialization process
and will be disabled when shutting down.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
[bhelgaas: use dev_err() instead of pr_err() in
imx6_pcie_assert_core_reset()]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rob Herring <robh@kernel.org>
Acked-by: Richard Zhu <hongxing.zhu@nxp.com>
7 years agoPCI: hv: Use vPCI protocol version 1.2
Jork Loeser [Wed, 24 May 2017 20:41:28 +0000 (13:41 -0700)]
PCI: hv: Use vPCI protocol version 1.2

Update the Hyper-V vPCI driver to use the Server-2016 version of the vPCI
protocol, fixing MSI creation and retargeting issues.

Signed-off-by: Jork Loeser <jloeser@microsoft.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
Acked-by: K. Y. Srinivasan <kys@microsoft.com>
7 years agoPCI: hv: Add vPCI version protocol negotiation
Jork Loeser [Wed, 24 May 2017 20:41:27 +0000 (13:41 -0700)]
PCI: hv: Add vPCI version protocol negotiation

Hyper-V vPCI offers different protocol versions.  Add the infra for
negotiating the one to use.

Signed-off-by: Jork Loeser <jloeser@microsoft.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
Acked-by: K. Y. Srinivasan <kys@microsoft.com>
7 years agoPCI: hv: Temporary own CPU-number-to-vCPU-number infra
Jork Loeser [Wed, 24 May 2017 20:41:26 +0000 (13:41 -0700)]
PCI: hv: Temporary own CPU-number-to-vCPU-number infra

To ease parallel effort to centralize CPU-number-to-vCPU-number conversion,
temporarily stand up own version, file-local hv_tmp_cpu_nr_to_vp_nr().
Once the changes have merged, this work-around can be removed, and the
calls replaced with hv_cpu_number_to_vp_number().

Signed-off-by: Jork Loeser <jloeser@microsoft.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
Acked-by: K. Y. Srinivasan <kys@microsoft.com>
7 years agoPCI: hv: Use page allocation for hbus structure
Jork Loeser [Wed, 24 May 2017 20:41:25 +0000 (13:41 -0700)]
PCI: hv: Use page allocation for hbus structure

The hv_pcibus_device structure contains an in-memory hypercall argument
that must not cross a page boundary.  Allocate the structure as a page to
ensure that.

Signed-off-by: Jork Loeser <jloeser@microsoft.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
Acked-by: K. Y. Srinivasan <kys@microsoft.com>
7 years agoPCI: hv: Fix comment formatting and use proper integer fields
Jork Loeser [Wed, 24 May 2017 20:41:24 +0000 (13:41 -0700)]
PCI: hv: Fix comment formatting and use proper integer fields

Fix comment formatting and use proper integer fields.

Signed-off-by: Jork Loeser <jloeser@microsoft.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
Acked-by: K. Y. Srinivasan <kys@microsoft.com>
7 years agoPCI: faraday: Add clock handling
Linus Walleij [Mon, 15 May 2017 17:23:24 +0000 (19:23 +0200)]
PCI: faraday: Add clock handling

Add some optional clock handling to the Faraday FTPCI100.  We just get and
prepare+enable the clocks right now, if they exist.  We can add more
elaborate clock handling later.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
[bhelgaas: folded in "Make clocks compulsory" fix from
http://lkml.kernel.org/r/20170621085730.28804-1-linus.walleij@linaro.org
Also folded in the clock max/cur speed fixes from
http://lkml.kernel.org/r/20170621162651.25315-1-linus.walleij@linaro.org]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: faraday: Add clock bindings
Linus Walleij [Mon, 15 May 2017 17:23:12 +0000 (19:23 +0200)]
PCI: faraday: Add clock bindings

The Faraday FTPCI100 controller has two clock ports, PCLK and PCICLK.  Add
bindings for these two clocks so we can assign them in the device tree.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rob Herring <robh@kernel.org>
7 years agoPCI: dwc: dra7xx: Use RW1C for IRQSTATUS_MSI and IRQSTATUS_MAIN
Arvind Yadav [Mon, 19 Jun 2017 09:51:36 +0000 (15:21 +0530)]
PCI: dwc: dra7xx: Use RW1C for IRQSTATUS_MSI and IRQSTATUS_MAIN

Previously, we tried to clear interrupt requests by clearing bits in the
PCIECTRL_DRA7XX_CONF_IRQSTATUS_MSI and PCIECTRL_DRA7XX_CONF_IRQSTATUS_MAIN
registers.  But per the TRM, these fields are RW1C, so we must *set* bits
to clear the interrupt bits.

Fixes: 47ff3de911a7 ("PCI: dra7xx: Add TI DRA7xx PCIe driver")
Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
[bhelgaas: changelog]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agoPCI: dwc: dra7xx: Depend on appropriate SoC or compile test
Peter Robinson [Mon, 15 May 2017 12:26:17 +0000 (13:26 +0100)]
PCI: dwc: dra7xx: Depend on appropriate SoC or compile test

The PCI controller attached to a SoC isn't much use if the core SoC isn't
enabled, unless of course it's compile testing, so add appropriate
dependency.

Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agoPCI: dwc: Constify dw_pcie_host_ops structures
Jisheng Zhang [Mon, 5 Jun 2017 08:53:46 +0000 (16:53 +0800)]
PCI: dwc: Constify dw_pcie_host_ops structures

The dw_pcie_host_ops structures are never modified.  Constify these
structures such that these can be write-protected.

Signed-off-by: Jisheng Zhang <jszhang@marvell.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Jingoo Han <jingoohan1@gmail.com>
Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agoPCI: host: Mark PCIe/PCI (MSI) cascade ISR as IRQF_NO_THREAD
Jisheng Zhang [Thu, 20 Apr 2017 10:27:18 +0000 (18:27 +0800)]
PCI: host: Mark PCIe/PCI (MSI) cascade ISR as IRQF_NO_THREAD

Similar as commit 8ff0ef996ca0 ("PCI: host: Mark PCIe/PCI (MSI) IRQ cascade
handlers as IRQF_NO_THREAD"), we should mark PCIe/PCI (MSI) IRQ cascade
handlers in designware, qcom, and vmd as IRQF_NO_THREAD explicitly.

Signed-off-by: Jisheng Zhang <jszhang@marvell.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Keith Busch <keith.busch@intel.com> # vmd
Acked-by: Jingoo Han <jingoohan1@gmail.com> # pcie-designware-plat.c
7 years agoarm64: PCI: Drop DT IRQ allocation from pcibios_alloc_irq()
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:14:12 +0000 (15:14 -0500)]
arm64: PCI: Drop DT IRQ allocation from pcibios_alloc_irq()

With the introduction of struct pci_host_bridge.map_irq pointer it is
possible to assign IRQs for all devices originating from a PCI host bridge
at probe time; this is implemented through pci_assign_irq() that relies on
the struct pci_host_bridge.map_irq pointer to map IRQ for a given device.

The benefits this brings are twofold:

  - the IRQ for a device is assigned once at probe time
  - the IRQ assignment works also for hotplugged devices

With all DT based PCI host bridges converted to the struct
pci_host_bridge.{map/swizzle}_irq hooks mechanism the DT IRQ allocation in
ARM64 pcibios_alloc_irq() is now redundant and can be removed.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Will Deacon <will.deacon@arm.com>
7 years agoPCI: xilinx-nwl: Move to struct pci_host_bridge IRQ mapping functions
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:14:11 +0000 (15:14 -0500)]
PCI: xilinx-nwl: Move to struct pci_host_bridge IRQ mapping functions

struct pci_host_bridge gained hooks to map/swizzle IRQs, so that the IRQ
mapping can be done automatically by PCI core code through the
pci_assign_irq() function instead of resorting to arch-specific
implementation callbacks to carry out the same task which force PCI host
bridge drivers implementation to implement per-arch kludges to carry out a
task that is inherently architecture agnostic.

Add map/swizzle IRQs hooks to the xilinx-nwl PCI host driver to move the
IRQ allocation into core code and stop relying on arch-specific callbacks.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Bharat Kumar Gogada <bharat.kumar.gogada@xilinx.com>
7 years agoPCI: rockchip: Move to struct pci_host_bridge IRQ mapping functions
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:14:11 +0000 (15:14 -0500)]
PCI: rockchip: Move to struct pci_host_bridge IRQ mapping functions

struct pci_host_bridge gained hooks to map/swizzle IRQs, so that the IRQ
mapping can be done automatically by PCI core code through the
pci_assign_irq() function instead of resorting to arch-specific
implementation callbacks to carry out the same task which force PCI host
bridge drivers implementation to implement per-arch kludges to carry out a
task that is inherently architecture agnostic.

Add map/swizzle IRQs hooks to the rockchip PCI host driver to move the IRQ
allocation into core code and stop relying on arch-specific callbacks.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Wenrui Li <wenrui.li@rock-chips.com>
Cc: Shawn Lin <shawn.lin@rock-chips.com>
7 years agoPCI: xgene: Move to struct pci_host_bridge IRQ mapping functions
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:14:10 +0000 (15:14 -0500)]
PCI: xgene: Move to struct pci_host_bridge IRQ mapping functions

struct pci_host_bridge gained hooks to map/swizzle IRQs, so that the IRQ
mapping can be done automatically by PCI core code through the
pci_assign_irq() function instead of resorting to arch-specific
implementation callbacks to carry out the same task which force PCI host
bridge drivers implementation to implement per-arch kludges to carry out a
task that is inherently architecture agnostic.

Add map/swizzle IRQs hooks to the xgene PCI host driver to move the IRQ
allocation into core code and stop relying on arch-specific callbacks.

Tested-by: Khuong Dinh <kdinh@apm.com> # with e1000e
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Tanmay Inamdar <tinamdar@apm.com>
7 years agoPCI: altera: Drop pci_fixup_irqs()
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:14:10 +0000 (15:14 -0500)]
PCI: altera: Drop pci_fixup_irqs()

Since, through struct pci_host_bridge.map/swizzle_irq hooks, IRQs are now
allocated in the pci_assign_irq() callback automatically, PCI host bridge
drivers can stop relying on pci_fixup_irqs() for IRQ allocation.

Drop pci_fixup_irqs() usage from PCI altera host bridge driver.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Ley Foon Tan <lftan@altera.com>
7 years agoPCI: versatile: Drop pci_fixup_irqs()
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:14:09 +0000 (15:14 -0500)]
PCI: versatile: Drop pci_fixup_irqs()

Since, through struct pci_host_bridge.map/swizzle_irq hooks, IRQs are now
allocated in the pci_assign_irq() callback automatically, PCI host bridge
drivers can stop relying on pci_fixup_irqs() for IRQ allocation.

Drop pci_fixup_irqs() usage from PCI versatile host bridge driver.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
[bhelgaas: folded in typo fix from Arnd Bergmann <arnd@arndb.de>:
http://lkml.kernel.org/r/20170621215323.3921382-4-arnd@arndb.de]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Rob Herring <robh@kernel.org>
7 years agoPCI: generic: Drop pci_fixup_irqs()
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:14:09 +0000 (15:14 -0500)]
PCI: generic: Drop pci_fixup_irqs()

Since, through struct pci_host_bridge.map/swizzle_irq hooks, IRQs are now
allocated in the pci_assign_irq() callback automatically, PCI host bridge
drivers can stop relying on pci_fixup_irqs() for IRQ allocation.

Drop pci_fixup_irqs() usage from PCI host-common bridge driver.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Will Deacon <will.deacon@arm.com>
7 years agoPCI: faraday: Drop pci_fixup_irqs()
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:14:08 +0000 (15:14 -0500)]
PCI: faraday: Drop pci_fixup_irqs()

Since, through struct pci_host_bridge.map/swizzle_irq hooks, IRQs are now
allocated in the pci_assign_irq() callback automatically, PCI host bridge
drivers can stop relying on pci_fixup_irqs() for IRQ allocation.

Drop pci_fixup_irqs() usage from PCI ftpci100 host bridge driver.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
7 years agoPCI: designware: Drop pci_fixup_irqs()
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:14:07 +0000 (15:14 -0500)]
PCI: designware: Drop pci_fixup_irqs()

Since, through struct pci_host_bridge.map/swizzle_irq hooks, IRQs are now
allocated in the pci_assign_irq() callback automatically, PCI host bridge
drivers can stop relying on pci_fixup_irqs() for IRQ allocation.

Drop pci_fixup_irqs() usage from PCI designware host bridge driver.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Jingoo Han <jingoohan1@gmail.com>
Cc: Joao Pinto <Joao.Pinto@synopsys.com>
7 years agoPCI: iproc: Drop pci_fixup_irqs()
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:14:07 +0000 (15:14 -0500)]
PCI: iproc: Drop pci_fixup_irqs()

Since, through struct pci_host_bridge.map/swizzle_irq hooks, IRQs are now
allocated in the pci_assign_irq() callback automatically, PCI host bridge
drivers can stop relying on pci_fixup_irqs() for IRQ allocation.

Drop pci_fixup_irqs() usage from PCI iproc host bridge driver.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Scott Branden <sbranden@broadcom.com>
Cc: Ray Jui <rjui@broadcom.com>
Cc: Jon Mason <jonmason@broadcom.com>
7 years agoPCI: rcar: Drop pci_fixup_irqs()
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:14:06 +0000 (15:14 -0500)]
PCI: rcar: Drop pci_fixup_irqs()

Since, through struct pci_host_bridge.map/swizzle_irq hooks, IRQs are now
allocated in the pci_assign_irq() callback automatically, PCI host bridge
drivers can stop relying on pci_fixup_irqs() for IRQ allocation.

Drop pci_fixup_irqs() usage from PCI rcar host bridge driver.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Simon Horman <horms@verge.net.au>
7 years agoPCI: xilinx: Drop pci_fixup_irqs()
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:14:06 +0000 (15:14 -0500)]
PCI: xilinx: Drop pci_fixup_irqs()

Since, through struct pci_host_bridge.map/swizzle_irq hooks, IRQs are now
allocated in the pci_assign_irq() callback automatically, PCI host bridge
drivers can stop relying on pci_fixup_irqs() for IRQ allocation.

Drop pci_fixup_irqs() usage from PCI xilinx host bridge driver.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Michal Simek <michal.simek@xilinx.com>
7 years agoPCI: tegra: Drop pci_fixup_irqs()
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:14:05 +0000 (15:14 -0500)]
PCI: tegra: Drop pci_fixup_irqs()

Since, through struct pci_host_bridge.map/swizzle_irq hooks, IRQs are now
allocated in the pci_assign_irq() callback automatically, PCI host bridge
drivers can stop relying on pci_fixup_irqs() for IRQ allocation

Drop pci_fixup_irqs() usage from PCI tegra host bridge driver.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
7 years agoARM/PCI: Remove pci_fixup_irqs() call for bios32 host controllers
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:14:04 +0000 (15:14 -0500)]
ARM/PCI: Remove pci_fixup_irqs() call for bios32 host controllers

Legacy PCI host controllers (ie host controllers that set-up the PCI bus
through the ARM pci_common_init() API) are currently relying on
pci_fixup_irqs() to assign legacy PCI irqs to devices.  This is not ideal
in that pci_fixup_irqs() assigns IRQs for all PCI devices present in a given
system some of which may well be enabled by the time pci_fixup_irqs() is
called (ie a system with multiple host controllers).  With the introduction
of struct pci_host_bridge.(*map_irq) pointer it is possible to assign IRQs
for all devices originating from a PCI host bridge at probe time; this is
implemented through pci_assign_irq() that relies on the struct
pci_host_bridge.map_irq pointer to map IRQ for a given device.

The benefits this brings are twofold:

  - the IRQ for a device is assigned once at probe time
  - the IRQ assignment works also for hotplugged devices

Remove pci_fixup_irqs() call from bios32 code and rely on pci_assign_irq()
to carry out the IRQ mapping at device probe time.

The map_irq() and swizzle_irq() struct pci_host_bridge callbacks are set-up
in the struct pci_host_bridge created in the bios32 pcibios_init_hw()
function and mach-* code paths (for PCI mach implementations that require a
specific struct hw_pci.(*scan) function callback).

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
[bhelgaas: folded in fixes from Lorenzo:
http://lkml.kernel.org/r/20170701140629.GC8977@red-moon]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Andrew Lunn <andrew@lunn.ch>
7 years agoPCI: Add a call to pci_assign_irq() in pci_device_probe()
Matthew Minter [Wed, 28 Jun 2017 20:14:04 +0000 (15:14 -0500)]
PCI: Add a call to pci_assign_irq() in pci_device_probe()

The pci_assign_irq() function allows assignment of an IRQ to devices during
device enable time rather than only at boot.  Therefore call it in the
pci_device_probe() function during the enable device code path so this
assignment can be performed.

This patch will do nothing on arches which do not set the IRQ mapping
function pointers and is therefore currently a nop, however as support for
these function pointers is added to arch-specific code this will cause IRQ
assignment to migrate to device enable time allowing the new code paths to
be used.

Signed-off-by: Matthew Minter <matt@masarand.com>
[lorenzo.pieralisi@arm.com: moved pci_assign_irq() call site]
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoOF/PCI: Update of_irq_parse_and_map_pci() comment
Matthew Minter [Wed, 28 Jun 2017 20:14:03 +0000 (15:14 -0500)]
OF/PCI: Update of_irq_parse_and_map_pci() comment

With the introduction of struct pci_host_bridge.(*map_irq) function pointer
add another direct usage of of_irq_parse_and_map_pci().

Update the function comment to reflect this behaviour.

Signed-off-by: Matthew Minter <matt@masarand.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: Add pci_assign_irq() function and have pci_fixup_irqs() use it
Matthew Minter [Wed, 28 Jun 2017 20:14:02 +0000 (15:14 -0500)]
PCI: Add pci_assign_irq() function and have pci_fixup_irqs() use it

Here we delete the static pdev_fixup_irq() function which is currently what
pci_fixup_irqs() uses to actually assign the IRQs and replace it with the
pci_assign_irq() function which changes the interface and uses the new
function pointers stored in the host bridge structure.

Eventually this will allow pci_fixup_irqs() to be removed entirely and the
new deferred assignment code path will call pci_assign_irq() directly.
However to ensure current users continue to work, a new implementation of
pci_fixup_irqs() is introduced which simply wraps the functionality of
pci_assign_irq().

Signed-off-by: Matthew Minter <matt@masarand.com>
[lorenzo.pieralisi@arm.com: reworked comments/log]
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: Add IRQ mapping function pointers to pci_host_bridge struct
Matthew Minter [Wed, 28 Jun 2017 20:14:02 +0000 (15:14 -0500)]
PCI: Add IRQ mapping function pointers to pci_host_bridge struct

In order to defer IRQ assignment arches must be able to register functions
to map and swizzle interrupts.  These registered functions are stored in
the pci_host_bridge struct.

Signed-off-by: Matthew Minter <matt@masarand.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: Build setup-irq.o on all arches
Matthew Minter [Wed, 28 Jun 2017 20:14:02 +0000 (15:14 -0500)]
PCI: Build setup-irq.o on all arches

The functions included in setup-irq.o currently apply only to a selection
of architectures which share common IRQ assignment code.  However this code
needs to be generalised for all arches to allow deferred IRQ assignment.
So the first step is to build it on all architectures.

Signed-off-by: Matthew Minter <matt@masarand.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: Remove pci_scan_root_bus_msi()
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:14:01 +0000 (15:14 -0500)]
PCI: Remove pci_scan_root_bus_msi()

The pci_scan_root_bus_bridge() function allows passing a parameterized
struct pci_host_bridge and scanning the resulting PCI bus; since the struct
msi_controller is part of the struct pci_host_bridge and the struct
pci_host_bridge can now be passed to pci_scan_root_bus_bridge() explicitly,
there is no need for a scan interface with a MSI controller parameter.

With all PCI host controller drivers and platform code relying on
pci_scan_root_bus_msi() converted over to pci_scan_root_bus_bridge() the
pci_scan_root_bus_msi() becomes obsolete and can be removed.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: xilinx-nwl: Convert PCI scan API to pci_scan_root_bus_bridge()
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:14:01 +0000 (15:14 -0500)]
PCI: xilinx-nwl: Convert PCI scan API to pci_scan_root_bus_bridge()

The introduction of pci_scan_root_bus_bridge() provides a PCI core API to
scan a PCI root bus backed by an already initialized struct pci_host_bridge
object, which simplifies the bus scan interface and makes the PCI scan root
bus interface easier to generalize as members are added to the struct
pci_host_bridge.

Convert PCI xilinx-nwl host code to pci_scan_root_bus_bridge() to improve
the PCI root bus scanning interface.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Bharat Kumar Gogada <bharat.kumar.gogada@xilinx.com>
7 years agoPCI: rockchip: Convert PCI scan API to pci_scan_root_bus_bridge()
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:14:00 +0000 (15:14 -0500)]
PCI: rockchip: Convert PCI scan API to pci_scan_root_bus_bridge()

The introduction of pci_scan_root_bus_bridge() provides a PCI core API to
scan a PCI root bus backed by an already initialized struct pci_host_bridge
object, which simplifies the bus scan interface and makes the PCI scan root
bus interface easier to generalize as members are added to the struct
pci_host_bridge.

Convert PCI rockchip host code to pci_scan_root_bus_bridge() to improve the
PCI root bus scanning interface.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Wenrui Li <wenrui.li@rock-chips.com>
Cc: Shawn Lin <shawn.lin@rock-chips.com>
7 years agoPCI: generic: Convert PCI scan API to pci_scan_root_bus_bridge()
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:14:00 +0000 (15:14 -0500)]
PCI: generic: Convert PCI scan API to pci_scan_root_bus_bridge()

The introduction of pci_scan_root_bus_bridge() provides a PCI core API to
scan a PCI root bus backed by an already initialized struct pci_host_bridge
object, which simplifies the bus scan interface and makes the PCI scan root
bus interface easier to generalize as members are added to the struct
pci_host_bridge.

Convert PCI host-common code to pci_scan_root_bus_bridge() to improve the
PCI root bus scanning interface.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Will Deacon <will.deacon@arm.com>
7 years agoPCI: xgene: Convert PCI scan API to pci_scan_root_bus_bridge()
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:13:59 +0000 (15:13 -0500)]
PCI: xgene: Convert PCI scan API to pci_scan_root_bus_bridge()

The introduction of pci_scan_root_bus_bridge() provides a PCI core API to
scan a PCI root bus backed by an already initialized struct pci_host_bridge
object, which simplifies the bus scan interface and makes the PCI scan root
bus interface easier to generalize as members are added to the struct
pci_host_bridge.

Convert PCI xgene host code to pci_scan_root_bus_bridge() to improve the
PCI root bus scanning interface.

Tested-by: Khuong Dinh <kdinh@apm.com> # with e1000e
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Tanmay Inamdar <tinamdar@apm.com>
7 years agoPCI: xilinx: Convert PCI scan API to pci_scan_root_bus_bridge()
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:13:59 +0000 (15:13 -0500)]
PCI: xilinx: Convert PCI scan API to pci_scan_root_bus_bridge()

The introduction of pci_scan_root_bus_bridge() provides a PCI core API to
scan a PCI root bus backed by an already initialized struct pci_host_bridge
object, which simplifies the bus scan interface and makes the PCI scan root
bus interface easier to generalize as members are added to the struct
pci_host_bridge.

Convert PCI xilinx host code to pci_scan_root_bus_bridge() to improve the
PCI root bus scanning interface.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Michal Simek <michal.simek@xilinx.com>
7 years agoPCI: altera: Convert PCI scan API to pci_scan_root_bus_bridge()
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:13:58 +0000 (15:13 -0500)]
PCI: altera: Convert PCI scan API to pci_scan_root_bus_bridge()

The introduction of pci_scan_root_bus_bridge() provides a PCI core API to
scan a PCI root bus backed by an already initialized struct pci_host_bridge
object, which simplifies the bus scan interface and makes the PCI scan root
bus interface easier to generalize as members are added to the struct
pci_host_bridge.

Convert PCI altera host code to pci_scan_root_bus_bridge() to improve the
PCI root bus scanning interface.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Ley Foon Tan <lftan@altera.com>
7 years agoPCI: versatile: Convert PCI scan API to pci_scan_root_bus_bridge()
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:13:58 +0000 (15:13 -0500)]
PCI: versatile: Convert PCI scan API to pci_scan_root_bus_bridge()

The introduction of pci_scan_root_bus_bridge() provides a PCI core API to
scan a PCI root bus backed by an already initialized struct pci_host_bridge
object, which simplifies the bus scan interface and makes the PCI scan root
bus interface easier to generalize as members are added to the struct
pci_host_bridge.

Convert PCI versatile host code to pci_scan_root_bus_bridge() to improve
the PCI root bus scanning interface.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
[bhelgaas: folded in fix from Arnd Bergmann <arnd@arndb.de>:
http://lkml.kernel.org/r/20170621215323.3921382-3-arnd@arndb.de]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Rob Herring <robh@kernel.org>
7 years agoPCI: iproc: Convert PCI scan API to pci_scan_root_bus_bridge()
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:13:57 +0000 (15:13 -0500)]
PCI: iproc: Convert PCI scan API to pci_scan_root_bus_bridge()

The introduction of pci_scan_root_bus_bridge() provides a PCI core API to
scan a PCI root bus backed by an already initialized struct pci_host_bridge
object, which simplifies the bus scan interface and makes the PCI scan root
bus interface easier to generalize as members are added to the struct
pci_host_bridge.

Convert PCI iproc host code to pci_scan_root_bus_bridge() to improve the
PCI root bus scanning interface.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Scott Branden <sbranden@broadcom.com>
Cc: Ray Jui <rjui@broadcom.com>
Cc: Jon Mason <jonmason@broadcom.com>
7 years agoPCI: rcar: Convert PCI scan API to pci_scan_root_bus_bridge()
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:13:57 +0000 (15:13 -0500)]
PCI: rcar: Convert PCI scan API to pci_scan_root_bus_bridge()

The introduction of pci_scan_root_bus_bridge() provides a PCI core API to
scan a PCI root bus backed by an already initialized struct pci_host_bridge
object, which simplifies the bus scan interface and makes the PCI scan root
bus interface easier to generalize as members are added to the struct
pci_host_bridge.

Convert PCI rcar host code to pci_scan_root_bus_bridge() to improve the PCI
root bus scanning interface.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Simon Horman <horms@verge.net.au>
7 years agoPCI: aardvark: Convert PCI scan API to pci_scan_root_bus_bridge()
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:13:56 +0000 (15:13 -0500)]
PCI: aardvark: Convert PCI scan API to pci_scan_root_bus_bridge()

The introduction of pci_scan_root_bus_bridge() provides a PCI core API to
scan a PCI root bus backed by an already initialized struct pci_host_bridge
object, which simplifies the bus scan interface and makes the PCI scan root
bus interface easier to generalize as members are added to the struct
pci_host_bridge.

Convert PCI aardvark host code to pci_scan_root_bus_bridge() to improve the
PCI root bus scanning interface.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
7 years agoPCI: designware: Convert PCI scan API to pci_scan_root_bus_bridge()
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:13:56 +0000 (15:13 -0500)]
PCI: designware: Convert PCI scan API to pci_scan_root_bus_bridge()

The introduction of pci_scan_root_bus_bridge() provides a PCI core API to
scan a PCI root bus backed by an already initialized struct pci_host_bridge
object, which simplifies the bus scan interface and makes the PCI scan root
bus interface easier to generalize as members are added to the struct
pci_host_bridge.

Convert PCI designware host code to pci_scan_root_bus_bridge() to improve
the PCI root bus scanning interface.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Jingoo Han <jingoohan1@gmail.com>
Cc: Joao Pinto <Joao.Pinto@synopsys.com>
7 years agoPCI/PM: Avoid using device_may_wakeup() for runtime PM
Rafael J. Wysocki [Fri, 23 Jun 2017 12:58:11 +0000 (14:58 +0200)]
PCI/PM: Avoid using device_may_wakeup() for runtime PM

pci_target_state() calls device_may_wakeup() which checks whether or not
the device may wake up the system from sleep states, but pci_target_state()
is used for runtime PM too.

Since runtime PM is expected to always enable remote wakeup if possible,
modify pci_target_state() to take additional argument indicating whether or
not it should look for a state from which the device can signal wakeup and
pass either the return value of device_can_wakeup(), or "false" (if the
device itself is not wakeup-capable) to it from the code related to runtime
PM.

While at it, fix the comment in pci_dev_run_wake() which is not about sleep
states.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
7 years agox86/PCI: Avoid AMD SB7xx EHCI USB wakeup defect
Kai-Heng Feng [Fri, 16 Jun 2017 09:40:54 +0000 (17:40 +0800)]
x86/PCI: Avoid AMD SB7xx EHCI USB wakeup defect

On an AMD Carrizo laptop, when EHCI runtime PM is enabled, EHCI ports do
not assert PME# for device plug/unplug events while in D3.

As Alan Stern points out [1], the PME signal is not enabled when controller
is in D3, therefore it's not being woken up when new devices get plugged
in.

Testing shows PME signal works when the EHCI power state is D2.

Clear the PCI_PM_CAP_PME_D3 and PCI_PM_CAP_PME_D3cold bits in
dev->pme_support to indicate the device will not assert PME# from those
states.

[1] http://lkml.kernel.org/r/Pine.LNX.4.44L0.1706121010010.2092-100000@iolanthe.rowland.org
Link: https://bugzilla.kernel.org/show_bug.cgi?id=196091
Link: https://support.amd.com/TechDocs/46837.pdf
Link: https://support.amd.com/TechDocs/42413.pdf
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
[bhelgaas: changelog, add parens in quirk]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI/PM: Restore the status of PCI devices across hibernation
Chen Yu [Thu, 25 May 2017 08:49:07 +0000 (16:49 +0800)]
PCI/PM: Restore the status of PCI devices across hibernation

Currently we saw a lot of "No irq handler" errors during hibernation, which
caused the system hang finally:

  ata4.00: qc timeout (cmd 0xec)
  ata4.00: failed to IDENTIFY (I/O error, err_mask=0x4)
  ata4.00: revalidation failed (errno=-5)
  ata4: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
  do_IRQ: 31.151 No irq handler for vector

According to above logs, there is an interrupt triggered and it is
dispatched to CPU31 with a vector number 151, but there is no handler for
it, thus this IRQ will not get acked and will cause an IRQ flood which
kills the system.  To be more specific, the 31.151 is an interrupt from the
AHCI host controller.

After some investigation, the reason why this issue is triggered is because
the thaw_noirq() function does not restore the MSI/MSI-X settings across
hibernation.

The scenario is illustrated below:

  1. Before hibernation, IRQ 34 is the handler for the AHCI device, which
     is bound to CPU31.

  2. Hibernation starts, the AHCI device is put into low power state.

  3. All the nonboot CPUs are put offline, so IRQ 34 has to be migrated to
     the last alive one - CPU0.

  4. After the snapshot has been created, all the nonboot CPUs are brought
     up again; IRQ 34 remains bound to CPU0.

  5. AHCI devices are put into D0.

  6. The snapshot is written to the disk.

The issue is triggered in step 6.  The AHCI interrupt should be delivered
to CPU0, however it is delivered to the original CPU31 instead, which
causes the "No irq handler" issue.

Ying Huang has provided a clue that, in step 3 it is possible that writing
to the register might not take effect as the PCI devices have been
suspended.

In step 3, the IRQ 34 affinity should be modified from CPU31 to CPU0, but
in fact it is not.  In __pci_write_msi_msg(), if the device is already in
low power state, the low level MSI message entry will not be updated but
cached.  During the device restore process after a normal suspend/resume,
pci_restore_msi_state() writes the cached MSI back to the hardware.

But this is not the case for hibernation.  pci_restore_msi_state() is not
currently called in pci_pm_thaw_noirq(), although pci_save_state() has
saved the necessary PCI cached information in pci_pm_freeze_noirq().

Restore the PCI status for the device during hibernation.  Otherwise the
status might be lost across hibernation (for example, settings for MSI,
MSI-X, ATS, ACS, IOV, etc.), which might cause problems during hibernation.

Suggested-by: Ying Huang <ying.huang@intel.com>
Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Chen Yu <yu.c.chen@intel.com>
[bhelgaas: changelog]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: stable@vger.kernel.org
Cc: Len Brown <len.brown@intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Rui Zhang <rui.zhang@intel.com>
Cc: Ying Huang <ying.huang@intel.com>
7 years agodrm/radeon: make MacBook Pro d3_delay quirk more generic
Bjorn Helgaas [Tue, 9 May 2017 15:10:18 +0000 (10:10 -0500)]
drm/radeon: make MacBook Pro d3_delay quirk more generic

The PCI Power Management Spec, r1.2, sec 5.6.1, requires a 10 millisecond
delay when powering on a device, i.e., transitioning from state D3hot to
D0.

Apparently some devices require more time, and d1f9809ed131 ("drm/radeon:
add quirk for d3 delay during switcheroo poweron for apple macbooks") added
an additional delay for the Radeon device in a MacBook Pro.  4807c5a8a0c8
("drm/radeon: add a PX quirk list") made the affected device more explicit.

Add a generic PCI quirk to increase the d3_delay.  This means we will use
the additional delay for *all* wakeups from D3, not just those initiated by
radeon_switcheroo_set_state().

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Andreas Boll <andreas.boll.dev@gmail.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
CC: Maarten Lankhorst <maarten.lankhorst@canonical.com>
7 years agodrm/amdgpu: remove unnecessary save/restore of pdev->d3_delay
Bjorn Helgaas [Tue, 9 May 2017 15:08:58 +0000 (10:08 -0500)]
drm/amdgpu: remove unnecessary save/restore of pdev->d3_delay

Remove unnecessary save/restore of pdev->d3_delay.

The only assignments to pdev->d3_delay are in radeon_switcheroo_set_state()
and some quirks, none of which should be relevant in the
amdgpu_switcheroo_set_state() path.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Andreas Boll <andreas.boll.dev@gmail.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
7 years agoPCI: Work around poweroff & suspend-to-RAM issue on Macbook Pro 11
Bjorn Helgaas [Fri, 19 Aug 2016 08:30:25 +0000 (16:30 +0800)]
PCI: Work around poweroff & suspend-to-RAM issue on Macbook Pro 11

Neither soft poweroff (transition to ACPI power state S5) nor
suspend-to-RAM (transition to state S3) works on the Macbook Pro 11,4 and
11,5.

The problem is related to the [mem 0x7fa00000-0x7fbfffff] space.  When we
use that space, e.g., by assigning it to the 00:1c.0 Root Port, the ACPI
Power Management 1 Control Register (PM1_CNT) at [io 0x1804] doesn't work
anymore.

Linux does a soft poweroff (transition to S5) by writing to PM1_CNT.  The
theory about why this doesn't work is:

  - The write to PM1_CNT causes an SMI
  - The BIOS SMI handler depends on something in
    [mem 0x7fa00000-0x7fbfffff]
  - When Linux assigns [mem 0x7fa00000-0x7fbfffff] to the 00:1c.0 Port, it
    covers up whatever the SMI handler uses, so the SMI handler no longer
    works correctly

Reserve the [mem 0x7fa00000-0x7fbfffff] space so we don't assign it to
anything.

This is voodoo programming, since we don't know what the real conflict is,
but we've failed to find the root cause.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=103211
Tested-by: thejoe@gmail.com
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: stable@vger.kernel.org
Cc: Rafael J. Wysocki <rafael@kernel.org>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Chen Yu <yu.c.chen@intel.com>
7 years agoPCI: Enable ECRC only if device supports it
Bjorn Helgaas [Tue, 21 Mar 2017 18:01:30 +0000 (13:01 -0500)]
PCI: Enable ECRC only if device supports it

John reported that an Intel QuickAssist crypto accelerator didn't work in a
Dell PowerEdge R730.  The problem seems to be that we enabled ECRC when the
device doesn't support it:

  85:00.0 Co-processor [0b40]: Intel Corporation DH895XCC Series QAT [8086:0435]
    Capabilities: [100 v1] Advanced Error Reporting
      AERCap: First Error Pointer: 00, GenCap- CGenEn+ ChkCap- ChkEn+

1302fcf0d03e ("PCI: Configure *all* devices, not just hot-added ones")
exposed the problem because it applies settings from the _HPX method to all
devices, not just hot-added ones.  The R730 supplies an _HPX method that
allows the kernel to enable ECRC.

Only enable ECRC if the device advertises support for it.

Link: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1571798
Fixes: 1302fcf0d03e ("PCI: Configure *all* devices, not just hot-added ones")
Reported-by: John Mazzie <john_mazzie@dell.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoARM/PCI: Convert PCI scan API to pci_scan_root_bus_bridge()
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:13:55 +0000 (15:13 -0500)]
ARM/PCI: Convert PCI scan API to pci_scan_root_bus_bridge()

The introduction of pci_scan_root_bus_bridge() provides a PCI core API to
scan a PCI root bus backed by an already initialized struct pci_host_bridge
object, which simplifies the bus scan interface and makes the PCI scan root
bus interface easier to generalize as members are added to the struct
pci_host_bridge.

Convert ARM bios32 code to pci_scan_root_bus_bridge() to improve the PCI
root bus scanning interface.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
[bhelgaas: fold in warning fix from Arnd Bergmann <arnd@arndb.de>:
http://lkml.kernel.org/r/20170621215323.3921382-1-arnd@arndb.de]
[bhelgaas: set bridge->ops for mv78xx0]
[bhelgaas: fold in fixes from Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>:
http://lkml.kernel.org/r/20170701135457.GB8977@red-moon]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Andrew Lunn <andrew@lunn.ch>
7 years agoPCI: Make pci_register_host_bridge() PCI core internal
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:13:55 +0000 (15:13 -0500)]
PCI: Make pci_register_host_bridge() PCI core internal

With the introduction of pci_scan_root_bus_bridge() there is no need to
export pci_register_host_bridge() to other kernel subsystems other than the
PCI compilation unit that needs it.

Make pci_register_host_bridge() static to its compilation unit and convert
the existing drivers usage over to pci_scan_root_bus_bridge().

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Arnd Bergmann <arnd@arndb.de>
7 years agoPCI: Add pci_scan_root_bus_bridge() interface
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:13:55 +0000 (15:13 -0500)]
PCI: Add pci_scan_root_bus_bridge() interface

The current pci_scan_root_bus() interface is made up of two main code
paths:

  - pci_create_root_bus()
  - pci_scan_child_bus()

pci_create_root_bus() is a wrapper function that allows to create a struct
pci_host_bridge structure, initialize it with the passed parameters and
register it with the kernel.

As the struct pci_host_bridge require additional struct members,
pci_create_root_bus() parameters list has grown in time, making it unwieldy
to add further parameters to it in case the struct pci_host_bridge gains
more members fields to augment its functionality.

Since PCI core code provides functions to allocate struct pci_host_bridge,
instead of forcing the pci_create_root_bus() interface to add new
parameters to cater for new struct pci_host_bridge functionality, it is
more suitable to add an interface in PCI core code to scan a PCI bus
straight from a struct pci_host_bridge created and customized by each
specific PCI host controller driver.

Add a pci_scan_root_bus_bridge() function to allow PCI host controller
drivers to create and initialize struct pci_host_bridge and scan the
resulting bus.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Arnd Bergmann <arnd@arndb.de>
7 years agoPCI: tegra: Fix host bridge memory leakage
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:13:54 +0000 (15:13 -0500)]
PCI: tegra: Fix host bridge memory leakage

When probing the PCI host controller driver, if an error occurs, the probe
function code does not free memory allocated for the struct pci_host_bridge
resulting in memory leakage.

Move the struct pci_host_bridge allocation over to the respective devm
interface to fix the issue.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Arnd Bergmann <arnd@arndb.de>
7 years agoPCI: faraday: Fix host bridge memory leakage
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:13:53 +0000 (15:13 -0500)]
PCI: faraday: Fix host bridge memory leakage

When probing the PCI host controller driver, if an error occurs, the probe
function code does not free memory allocated for the struct pci_host_bridge
resulting in memory leakage.

Move the struct pci_host_bridge allocation over to the respective devm
interface to fix the issue.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Cc: Arnd Bergmann <arnd@arndb.de>
7 years agoPCI: Add devm_pci_alloc_host_bridge() interface
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:13:53 +0000 (15:13 -0500)]
PCI: Add devm_pci_alloc_host_bridge() interface

Struct pci_host_bridge can be allocated by PCI host bridge drivers which
usually allocate and map memory through devm managed interfaces.

Add a devm version for the pci_alloc_host_bridge() interface to simplify
PCI host controller driver porting and simplify the driver failure paths.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Arnd Bergmann <arnd@arndb.de>
7 years agoPCI: Add pci_free_host_bridge() interface
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:13:52 +0000 (15:13 -0500)]
PCI: Add pci_free_host_bridge() interface

Commit a52d1443bba1 ("PCI: Export host bridge registration interface")
exported the pci_alloc_host_bridge() interface so that PCI host controllers
drivers can make use of it.

Introduce pci_alloc_host_bridge() kernel counterpart to free the host
bridge data structures, pci_free_host_bridge(), export it and update kernel
functions releasing host bridge objects allocated memory to make use of it.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Arnd Bergmann <arnd@arndb.de>
7 years agoPCI: Initialize bridge release function at bridge allocation
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:13:52 +0000 (15:13 -0500)]
PCI: Initialize bridge release function at bridge allocation

The introduction of pci_register_host_bridge() kernel interface allows PCI
host controller drivers to create the struct pci_host_bridge object,
initialize it and register it with the kernel so that its corresponding PCI
bus can be scanned and its devices probed.

The host bridge device release function pci_release_host_bridge_dev() is a
static function common for all struct pci_host_bridge allocated objects, so
in its current form cannot be used by PCI host bridge controllers drivers
to initialize the allocated struct pci_host_bridge, which leaves struct
pci_host_bridge devices release function uninitialized.

Since pci_release_host_bridge_dev() is a function common to all PCI host
bridge objects, initialize it in pci_alloc_host_bridge() (ie common host
bridge allocation interface) so that all struct pci_host_bridge objects
have their release function initialized by default at allocation time,
removing the need for exporting the common pci_release_host_bridge_dev()
function to other compilation units.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Arnd Bergmann <arnd@arndb.de>
7 years agoPCI: faraday: Convert IRQ masking to raw PCI config accessors
Lorenzo Pieralisi [Wed, 28 Jun 2017 20:13:51 +0000 (15:13 -0500)]
PCI: faraday: Convert IRQ masking to raw PCI config accessors

Current ftpci100 driver host bridge controller driver requires struct
pci_bus to be created in order to mask and clear IRQs using standard PCI
bus config accessors.

This struct pci_bus dependency is fictitious and burdens the driver with
unneeded constraints (eg to use separate APIs to create and scan the root
bus).

Add PCI raw config space accessors to PCIe ftpci100 driver and remove the
fictitious struct pci_bus dependency.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
[bhelgaas: folded in raw PCI read accessor from
http://lkml.kernel.org/r/20170621162651.25315-1-linus.walleij@linaro.org
The clock piece of the above posting goes with the separate "Add clock
handling" patch.]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>