OSDN Git Service

tomoyo/tomoyo-test1.git
5 years agoMerge branch 'remotes/lorenzo/pci/mediatek'
Bjorn Helgaas [Wed, 6 Mar 2019 21:30:23 +0000 (15:30 -0600)]
Merge branch 'remotes/lorenzo/pci/mediatek'

  - Fix mediatek MMIO size computation to enable full size of available
    MMIO space (Honghui Zhang)

  - Fix mediatek DMA window size computation to allow endpoint DMA access
    to full DRAM address range (Honghui Zhang)

* remotes/lorenzo/pci/mediatek:
  PCI: mediatek: Enlarge PCIe2AHB window size to support 4GB DRAM
  PCI: mediatek: Fix memory mapped IO range size computation

5 years agoMerge branch 'remotes/lorenzo/pci/hv'
Bjorn Helgaas [Wed, 6 Mar 2019 21:30:22 +0000 (15:30 -0600)]
Merge branch 'remotes/lorenzo/pci/hv'

  - Remove duplicate struct hv_vp_set in favor of struct hv_vpset (Maya
    Nakamura)

  - Rework hv_irq_unmask() to use cpumask_to_vpset() instead of open-coded
    reimplementation (Maya Nakamura)

  - Align Hyper-V struct retarget_msi_interrupt arguments (Maya Nakamura)

* remotes/lorenzo/pci/hv:
  PCI: hv: Refactor hv_irq_unmask() to use cpumask_to_vpset()
  PCI: hv: Replace hv_vp_set with hv_vpset
  PCI: hv: Add __aligned(8) to struct retarget_msi_interrupt

5 years agoMerge branch 'remotes/lorenzo/pci/endpoint'
Bjorn Helgaas [Wed, 6 Mar 2019 21:30:21 +0000 (15:30 -0600)]
Merge branch 'remotes/lorenzo/pci/endpoint'

  - Use memcpy_fromio()/memcpy_toio() instead of plain memcpy() in PCI
    endpoint framework (Wen Yang)

  - Add interface to discover supported endpoint features to replace a
    bitfield that wasn't flexible enough (Kishon Vijay Abraham I)

  - Implement the new supported-feature interface for designware-plat,
    dra7xx, rockchip, cadence (Kishon Vijay Abraham I)

  - Fix issues with 64-bit BAR in endpoints (Kishon Vijay Abraham I)

  - Add layerscape endpoint mode support (Xiaowei Bao)

* remotes/lorenzo/pci/endpoint:
  misc: pci_endpoint_test: Add the layerscape EP device support
  PCI: layerscape: Add EP mode support
  arm64: dts: Add the PCIE EP node in dts
  dt-bindings: add DT binding for the layerscape PCIe controller with EP mode
  PCI: endpoint: Remove features member in struct pci_epc
  PCI: designware-plat: Remove setting epc->features in Designware plat EP driver
  PCI: rockchip: Remove pci_epf_linkup() from Rockchip EP driver
  PCI: cadence: Remove pci_epf_linkup() from Cadence EP driver
  PCI: pci-epf-test: Use pci_epc_get_features() to get EPC features
  PCI: pci-epf-test: Do not allocate next BARs memory if current BAR is 64Bit
  PCI: pci-epf-test: Remove setting epf_bar flags in function driver
  PCI: endpoint: Fix pci_epf_alloc_space() to set correct MEM TYPE flags
  PCI: endpoint: Add helper to get first unreserved BAR
  PCI: cadence: Populate ->get_features() cdns_pcie_epc_ops
  PCI: rockchip: Populate ->get_features() dw_pcie_ep_ops
  PCI: pci-dra7xx: Populate ->get_features() dw_pcie_ep_ops
  PCI: designware-plat: Populate ->get_features() dw_pcie_ep_ops
  PCI: dwc: Add ->get_features() callback function to dw_pcie_ep_ops
  PCI: endpoint: Add new pci_epc_ops to get EPC features
  PCI: endpoint: functions: Use memcpy_fromio()/memcpy_toio()

5 years agoMerge branch 'remotes/lorenzo/pci/dwc'
Bjorn Helgaas [Wed, 6 Mar 2019 21:30:19 +0000 (15:30 -0600)]
Merge branch 'remotes/lorenzo/pci/dwc'

  - Add dra72x/dra74x/dra76x SoC compatible strings (Kishon Vijay
    Abraham I)

  - Enable x2 mode support for dra72x/dra74x/dra76x SoC (Kishon Vijay
    Abraham I)

  - Configure dra7xx PHY to PCIe mode (Kishon Vijay Abraham I)

  - Simplify dwc (remove unnecessary header includes, name variables
    consistently, reduce inverted logic, etc) (Gustavo Pimentel)

  - Add i.MX8MQ support (Andrey Smirnov)

  - Add message to help debug dwc MSI-X mask bit errors (Gustavo Pimentel)

  - Work around imx7d PCIe PLL erratum (Trent Piepho)

  - Don't assert qcom reset GPIO during probe (Bjorn Andersson)

  - Skip dwc MSI init if MSIs have been disabled (Lucas Stach)

* remotes/lorenzo/pci/dwc:
  PCI: dwc: skip MSI init if MSIs have been explicitly disabled
  PCI: dwc: Remove superfluous shifting in definitions
  PCI: dwc: Make use of GENMASK/FIELD_PREP
  PCI: dwc: Make use of BIT() in constant definitions
  PCI: dwc: Share code for dw_pcie_rd/wr_other_conf()
  PCI: dwc: Make use of IS_ALIGNED()
  PCI: imx6: Add code to request/control "pcie_aux" clock for i.MX8MQ
  dt-bindings: imx6q-pcie: Add "pcie_aux" clock for imx8mq
  PCI: qcom: Don't deassert reset GPIO during probe
  PCI: imx: Add workaround for e10728, IMX7d PCIe PLL failure
  ARM: dts: imx7d: Add node for PCIe PHY
  dt-bindings: imx6q-pcie: Add description of imx7d pcie phy
  PCI: dwc: Print debug error message when MSI-X entry control mask bit is set
  PCI: imx6: Add support for i.MX8MQ
  PCI: imx6: Convert DIRECT_SPEED_CHANGE quirk code to use a flag
  PCI: imx6: Mark PHY functions as i.MX6 specific
  PCI: imx6: Introduce drvdata
  PCI: dwc: Replace bit rotation operation (1 << bit) with BIT(bit)
  PCI: dwc: Improve code readability and simplify mask/unmask operations
  PCI: dwc: Rename variable name from data to d on dw_pcie_irq_domain_free()
  PCI: dwc: Rename variable name from data to d on dw_pci_msi_set_affinity()
  PCI: dwc: Rename variable name from data to d on dw_pci_setup_msi_msg()
  PCI: dwc: Rename variable name from data to d on dw_pci_bottom_mask/unmask()
  PCI: dwc: Remove unnecessary header include (signal.h)
  PCI: dwc: Remove unnecessary header include (of_gpio.h)
  PCI: dwc: dra7xx: Invoke phy_set_mode() API to set PHY mode to PHY_MODE_PCIE
  PCI: dwc: dra7xx: Enable x2 mode support for dra74x, dra76x and dra72x
  dt-bindings: PCI: dra7xx: Add properties to enable x2 lane in dra7
  dt-bindings: PCI: dra7xx: Add SoC specific compatible strings

5 years agoMerge branch 'remotes/lorenzo/pci/dt'
Bjorn Helgaas [Wed, 6 Mar 2019 21:30:18 +0000 (15:30 -0600)]
Merge branch 'remotes/lorenzo/pci/dt'

  - Add DT support for R-Car RZ/G2E (R8A774C0) (Fabrizio Castro)

* remotes/lorenzo/pci/dt:
  dt-bindings: PCI: rcar: Add device tree support for r8a774c0

5 years agoMerge branch 'remotes/lorenzo/pci/cadence'
Bjorn Helgaas [Wed, 6 Mar 2019 21:30:17 +0000 (15:30 -0600)]
Merge branch 'remotes/lorenzo/pci/cadence'

  - Replace Douglas with Tom Joseph as Cadence PCI host/endpoint maintainer
    (Lorenzo Pieralisi)

* remotes/lorenzo/pci/cadence:
  MAINTAINERS: Update PCI Cadence maintainer entry

5 years agoMerge branch 'remotes/lorenzo/pci/altera'
Bjorn Helgaas [Wed, 6 Mar 2019 21:30:17 +0000 (15:30 -0600)]
Merge branch 'remotes/lorenzo/pci/altera'

  - Extend altera to support Stratix 10 (Ley Foon Tan)

  - Allow building altera driver on ARM64 (Ley Foon Tan)

* remotes/lorenzo/pci/altera:
  dt-bindings: PCI: altera: Add altr,pcie-root-port-2.0
  PCI: altera: Enable driver on ARM64
  PCI: altera: Add Stratix 10 PCIe support

5 years agoMerge branch 'pci/pm'
Bjorn Helgaas [Wed, 6 Mar 2019 21:30:15 +0000 (15:30 -0600)]
Merge branch 'pci/pm'

  - Blacklist Gigabyte X299 Root Port power management to fix Thunderbolt
    hotplug (Mika Westerberg)

  - Revert runtime PM suspend/resume callbacks that broke PME on network
    cable plug (Mika Westerberg)

  - Disable Data Link State Changed interrupts to prevent wakeup
    immediately after suspend (Mika Westerberg)

* pci/pm:
  PCI/PME: Fix possible use-after-free on remove
  PCI/PME: Fix hotplug/sysfs remove deadlock in pcie_pme_remove()
  PCI: pciehp: Disable Data Link Layer State Changed event on suspend
  Revert "PCI/PME: Implement runtime PM callbacks"
  PCI: Blacklist power management of Gigabyte X299 DESIGNARE EX PCIe ports

5 years agoMerge branch 'pci/portdrv'
Bjorn Helgaas [Wed, 6 Mar 2019 21:30:14 +0000 (15:30 -0600)]
Merge branch 'pci/portdrv'

  - Allow portdrv to claim subtractive decode Ports so PCIe services will
    work for them (Honghui Zhang)

  - Report PCIe links that become degraded at run-time (Alexandru Gagniuc)

* pci/portdrv:
  PCI/LINK: Report degraded links via link bandwidth notification
  PCI/portdrv: Support PCIe services on subtractive decode bridges
  PCI/portdrv: Use conventional Device ID table formatting

5 years agoMerge branch 'pci/misc'
Bjorn Helgaas [Wed, 6 Mar 2019 21:30:13 +0000 (15:30 -0600)]
Merge branch 'pci/misc'

  - Mark expected switch fall-through (Mathieu Malaterre)

  - Use of_node_name_eq() for node name comparisons (Rob Herring)

  - Add ACS and pciehp quirks for HXT SD4800 (Shunyong Yang)

  - Consolidate Rohm Vendor ID definitions (Andy Shevchenko)

  - Use u32 (not __u32) for things not exposed to userspace (Logan
    Gunthorpe)

  - Fix locking semantics of bus and slot reset interfaces (Alex
    Williamson)

  - Update PCIEPORTBUS Kconfig help text (Hou Zhiqiang)

* pci/misc:
  PCI: Update PCIEPORTBUS Kconfig help text
  PCI: Fix "try" semantics of bus and slot reset
  PCI: Clean up usage of __u32 type
  genirq/msi: Clean up usage of __u8/__u16 types
  PCI: Move Rohm Vendor ID to generic list
  PCI: pciehp: Add HXT quirk for Command Completed errata
  PCI: Add ACS quirk for HXT SD4800
  PCI: Add HXT vendor ID
  PCI: Use of_node_name_eq() for node name comparisons
  PCI: Mark expected switch fall-through

5 years agoMerge branch 'pci/hotplug'
Bjorn Helgaas [Wed, 6 Mar 2019 21:30:12 +0000 (15:30 -0600)]
Merge branch 'pci/hotplug'

  - Reorder pciehp cached state/hardware state updates to avoid missed
    interrupts (Mika Westerberg)

  - Turn ibmphp semaphores into completions or mutexes (Arnd Bergmann)

* pci/hotplug:
  PCI: ibmphp: Turn semaphores into completions or mutexes
  PCI: pciehp: Assign ctrl->slot_ctrl before writing it to hardware

5 years agoMerge branch 'pci/enumeration'
Bjorn Helgaas [Wed, 6 Mar 2019 21:30:11 +0000 (15:30 -0600)]
Merge branch 'pci/enumeration'

  - Probe bridge window attributes only once at enumeration-time to fix
    device accesses during rescan (Bjorn Helgaas)

  - Return BAR size (not "size -1 ") from pci_size() to simplify code (Du
    Changbin)

  - Use config header type (not class code) identify bridges more reliably
    (Honghui Zhang)

  - Work around Intel Denverton incorrect Trace Hub BAR size reporting
    (Alexander Shishkin)

* pci/enumeration:
  x86/PCI: Fixup RTIT_BAR of Intel Denverton Trace Hub
  PCI: Rely on config space header type, not class code
  PCI: Make pci_size() return real BAR size
  PCI: Probe bridge window attributes once at enumeration-time

5 years agoMerge branch 'pci/dpc'
Bjorn Helgaas [Wed, 6 Mar 2019 21:30:10 +0000 (15:30 -0600)]
Merge branch 'pci/dpc'

  - Fix DPC use of uninitialized data (Dongdong Liu)

* pci/dpc:
  PCI/DPC: Fix print AER status in DPC event handling

5 years agoMerge branch 'pci/aspm'
Bjorn Helgaas [Wed, 6 Mar 2019 21:30:09 +0000 (15:30 -0600)]
Merge branch 'pci/aspm'

  - Use Latency Tolerance Reporting if already enabled by platform (Bjorn
    Helgaas)

  - Save/restore LTR info for suspend/resume (Bjorn Helgaas)

* pci/aspm:
  PCI/ASPM: Save LTR Capability for suspend/resume
  PCI/ASPM: Use LTR if already enabled by platform

5 years agoMerge branch 'pci/aer'
Bjorn Helgaas [Wed, 6 Mar 2019 21:30:07 +0000 (15:30 -0600)]
Merge branch 'pci/aer'

  - Use match_string() instead of reimplementing it (Andy Shevchenko)

  - Enable SERR# forwarding for all bridges (Bharat Kumar Gogada)

* pci/aer:
  PCI: Enable SERR# forwarding for all bridges
  PCI/AER: Use match_string() helper to simplify the code

5 years agoPCI: Update PCIEPORTBUS Kconfig help text
Hou Zhiqiang [Wed, 6 Mar 2019 06:09:46 +0000 (06:09 +0000)]
PCI: Update PCIEPORTBUS Kconfig help text

The Virtual Channel service has been removed and Downstream Port
Containment has been added, so update the symbol description to be
consistent with the current code.

Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
5 years agoPCI: Fix "try" semantics of bus and slot reset
Alex Williamson [Mon, 18 Feb 2019 19:46:46 +0000 (12:46 -0700)]
PCI: Fix "try" semantics of bus and slot reset

The commit referenced below introduced device locking around save and
restore of state for each device during a PCI bus "try" reset, making it
decidely non-"try" and prone to deadlock in the event that a device is
already locked.  Restore __pci_reset_bus() and __pci_reset_slot() to their
advertised locking semantics by pushing the save and restore functions into
the branch where the entire tree is already locked.  Extend the helper
function names with "_locked" and update the comment to reflect this
calling requirement.

Fixes: b014e96d1abb ("PCI: Protect pci_error_handlers->reset_notify() usage with device_lock()")
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Sinan Kaya <okaya@kernel.org>
5 years agoPCI/LINK: Report degraded links via link bandwidth notification
Alexandru Gagniuc [Wed, 27 Feb 2019 20:58:17 +0000 (14:58 -0600)]
PCI/LINK: Report degraded links via link bandwidth notification

A warning is generated when a PCIe device is probed with a degraded link,
but there was no similar mechanism to warn when the link becomes degraded
after probing.  The Link Bandwidth Notification provides this mechanism.

Use the Link Bandwidth Management Interrupt to detect bandwidth changes,
and rescan the bandwidth, looking for the weakest point.  This is the same
logic used in probe().

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Lukas Wunner <lukas@wunner.de>
5 years agodt-bindings: PCI: altera: Add altr,pcie-root-port-2.0
Ley Foon Tan [Thu, 28 Feb 2019 10:52:52 +0000 (18:52 +0800)]
dt-bindings: PCI: altera: Add altr,pcie-root-port-2.0

Add support for altr,pcie-root-port-2.0.

Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Rob Herring <robh@kernel.org>
5 years agoPCI: altera: Enable driver on ARM64
Ley Foon Tan [Thu, 28 Feb 2019 10:52:51 +0000 (18:52 +0800)]
PCI: altera: Enable driver on ARM64

Enable PCIE_ALTERA on ARM64 platform.

Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
5 years agoPCI: altera: Add Stratix 10 PCIe support
Ley Foon Tan [Thu, 28 Feb 2019 10:52:50 +0000 (18:52 +0800)]
PCI: altera: Add Stratix 10 PCIe support

Add PCIe Root Port support for Stratix 10 device.

Main differences compared to the PCIe Root Port IP on Cyclone V
and Arria 10 devices:

- HIP interface to access Root Port configuration register
- TLP programming flow:
  - One REG0 register
  - Don't need to check alignment

Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
5 years agoPCI/PME: Fix possible use-after-free on remove
Sven Van Asbroeck [Fri, 1 Mar 2019 16:54:19 +0000 (11:54 -0500)]
PCI/PME: Fix possible use-after-free on remove

In remove(), ensure that the PME work cannot run after kfree() is called.
Otherwise, this could result in a use-after-free.

This issue was detected with the help of Coccinelle.

Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Sinan Kaya <okaya@kernel.org>
Cc: Frederick Lawler <fred@fredlawl.com>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Keith Busch <keith.busch@intel.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
5 years agoPCI: dwc: skip MSI init if MSIs have been explicitly disabled
Lucas Stach [Wed, 27 Feb 2019 16:52:19 +0000 (17:52 +0100)]
PCI: dwc: skip MSI init if MSIs have been explicitly disabled

Since 7c5925afbc58 (PCI: dwc: Move MSI IRQs allocation to IRQ domains
hierarchical API) the MSI init claims one of the controller IRQs as a
chained IRQ line for the MSI controller. On some designs, like the i.MX6,
this line is shared with a PCIe legacy IRQ. When the line is claimed for
the MSI domain, any device trying to use this legacy IRQs will fail to
request this IRQ line.

As MSI and legacy IRQs are already mutually exclusive on the DWC core,
as the core won't forward any legacy IRQs once any MSI has been enabled,
users wishing to use legacy IRQs already need to explictly disable MSI
support (usually via the pci=nomsi kernel commandline option). To avoid
any issues with MSI conflicting with legacy IRQs, just skip all of the
DWC MSI initalization, including the IRQ line claim, when MSI is disabled.

Fixes: 7c5925afbc58 ("PCI: dwc: Move MSI IRQs allocation to IRQ domains hierarchical API")
Tested-by: Tim Harvey <tharvey@gateworks.com>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Cc: stable@vger.kernel.org
5 years agoPCI: hv: Refactor hv_irq_unmask() to use cpumask_to_vpset()
Maya Nakamura [Fri, 1 Mar 2019 07:04:17 +0000 (07:04 +0000)]
PCI: hv: Refactor hv_irq_unmask() to use cpumask_to_vpset()

Remove the duplicate implementation of cpumask_to_vpset() and use the
shared implementation. Export hv_max_vp_index, which is required by
cpumask_to_vpset().

Signed-off-by: Maya Nakamura <m.maya.nakamura@gmail.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Tested-by: Vitaly Kuznetsov <vkuznets@redhat.com>
5 years agoPCI: hv: Replace hv_vp_set with hv_vpset
Maya Nakamura [Fri, 1 Mar 2019 06:59:02 +0000 (06:59 +0000)]
PCI: hv: Replace hv_vp_set with hv_vpset

Remove a duplicate definition of VP set (hv_vp_set) and use the common
definition (hv_vpset) that is used in other places.

Change the order of the members in struct hv_pcibus_device so that the
declaration of retarget_msi_interrupt_params is the last member. Struct
hv_vpset, which contains a flexible array, is nested two levels deep in
struct hv_pcibus_device via retarget_msi_interrupt_params.

Add a comment that retarget_msi_interrupt_params should be the last
member of struct hv_pcibus_device.

Signed-off-by: Maya Nakamura <m.maya.nakamura@gmail.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Tested-by: Vitaly Kuznetsov <vkuznets@redhat.com>
5 years agoPCI: hv: Add __aligned(8) to struct retarget_msi_interrupt
Maya Nakamura [Fri, 1 Mar 2019 06:56:24 +0000 (06:56 +0000)]
PCI: hv: Add __aligned(8) to struct retarget_msi_interrupt

Because Hyper-V requires that hypercall arguments be aligned on an 8
byte boundary, add __aligned(8) to struct retarget_msi_interrupt.

Link: https://lore.kernel.org/lkml/87k1hlqlby.fsf@vitty.brq.redhat.com/
Signed-off-by: Maya Nakamura <m.maya.nakamura@gmail.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
5 years agoPCI: mediatek: Enlarge PCIe2AHB window size to support 4GB DRAM
Honghui Zhang [Fri, 1 Feb 2019 05:36:07 +0000 (13:36 +0800)]
PCI: mediatek: Enlarge PCIe2AHB window size to support 4GB DRAM

The PCIE_AXI_WINDOW0 register defines the inbound window size for
requests coming from PCI endpoints. Requests outside of this window will
be treated as unsupported requests.

Enlarge this window size from 2^31 to 2^33 to support a 8GB address
space (which gives endpoints DMA access to full 4GB DRAM address range
- physical DRAM starts at 0x40000000).

Reported-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Honghui Zhang <honghui.zhang@mediatek.com>
[lorenzo.pieralisi@arm.com: updated commit log]
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
5 years agoPCI: mediatek: Fix memory mapped IO range size computation
Honghui Zhang [Fri, 1 Feb 2019 05:36:06 +0000 (13:36 +0800)]
PCI: mediatek: Fix memory mapped IO range size computation

Mediatek's HW assigns a MMIO address range (typically starts from
0x20000000 to 0x2fffffff for both mt2712 and mt7622) for PCI usage.

This MMIO address space represents the address space that can
be allocated to PCI devices through Base Address Registers.

Even though the full MMIO address range is available to be allocated, it
should be enabled by the PCIE_AHB_TRANS_BASE register in the host
controller and the size that is enabled is determined by AHB2PCIE_SIZE
bits in this register.

Owing to a bug in the MMIO window size computation, current code does
not enable the full size of the available MMIO address range in the
PCI host controller; if the PCI devices BARs requested size exceeds the
size enabled through the PCIE_AHB_TRANS_BASE register the requests
targeting the disabled address address space will be blocked by the root
complex causing a system error.

Existing code has never run into a system error in production because
even half of the enabled MMIO range (128MB) is big enough for typical
devices BAR requests (4MB) but the full MMIO address range should
be enabled regardless.

Fix the MMIO window size computation by using resource_size(mem) instead
of mem->end - mem->start.

Since the MMIO window size for both MT2712 and MT7622 is 0x10000000,
this change will update the parameter passed to fls() from 0xfffffff to
0x10000000 and calculate the whole memory mapped IO range size
correctly.

Detected through coccinelle semantic patch (and related warning):

scripts/coccinelle/api/resource_size.cocci:

pcie-mediatek.c:720:13-16: WARNING: Suspicious code. resource_size is maybe missing with mem

Signed-off-by: Honghui Zhang <honghui.zhang@mediatek.com>
[lorenzo.pieralisi@arm.com: rewrote the commit log]
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
5 years agoPCI: dwc: Remove superfluous shifting in definitions
Andrey Smirnov [Tue, 19 Feb 2019 20:02:42 +0000 (12:02 -0800)]
PCI: dwc: Remove superfluous shifting in definitions

Surrounding definitions no longer use explicit shift, so "<< 0" here
serve no purpose. Remove them. No functional change intended.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Chris Healy <cphealy@gmail.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Leonard Crestez <leonard.crestez@nxp.com>
Cc: "A.s. Dong" <aisheng.dong@nxp.com>
Cc: Richard Zhu <hongxing.zhu@nxp.com>
Cc: linux-imx@nxp.com
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-pci@vger.kernel.org
5 years agoPCI: dwc: Make use of GENMASK/FIELD_PREP
Andrey Smirnov [Tue, 19 Feb 2019 20:02:41 +0000 (12:02 -0800)]
PCI: dwc: Make use of GENMASK/FIELD_PREP

Convert various multi-bit fields to be defined using GENMASK/FIELD_PREP.
This way bit field boundaries are defined in a single place only, as
well as defined in a way that makes it easier to verify them against the
reference manual. No functional change intended.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Chris Healy <cphealy@gmail.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Leonard Crestez <leonard.crestez@nxp.com>
Cc: "A.s. Dong" <aisheng.dong@nxp.com>
Cc: Richard Zhu <hongxing.zhu@nxp.com>
Cc: linux-imx@nxp.com
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-pci@vger.kernel.org
5 years agoPCI: dwc: Make use of BIT() in constant definitions
Andrey Smirnov [Tue, 19 Feb 2019 20:02:40 +0000 (12:02 -0800)]
PCI: dwc: Make use of BIT() in constant definitions

Avoid using explicit left shifts and convert various definitions to
use BIT() instead. No functional change intended.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
[lorenzo.pieralisi@arm.com: fixed PORT_LOGIC_SPEED_CHANGE redefinition]
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Chris Healy <cphealy@gmail.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Leonard Crestez <leonard.crestez@nxp.com>
Cc: "A.s. Dong" <aisheng.dong@nxp.com>
Cc: Richard Zhu <hongxing.zhu@nxp.com>
Cc: linux-imx@nxp.com
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-pci@vger.kernel.org
5 years agoPCI: dwc: Share code for dw_pcie_rd/wr_other_conf()
Andrey Smirnov [Tue, 19 Feb 2019 20:02:39 +0000 (12:02 -0800)]
PCI: dwc: Share code for dw_pcie_rd/wr_other_conf()

Default implementation of pcie_rd_other_conf() and
dw_pcie_wd_other_conf() share more than 80% of their code. Move shared
code into a dedicated subroutine and convert pcie_rd_other_conf() and
dw_pcie_wd_other_conf() to use it. No functional change intended.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Chris Healy <cphealy@gmail.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Leonard Crestez <leonard.crestez@nxp.com>
Cc: "A.s. Dong" <aisheng.dong@nxp.com>
Cc: Richard Zhu <hongxing.zhu@nxp.com>
Cc: linux-imx@nxp.com
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-pci@vger.kernel.org
5 years agoPCI: dwc: Make use of IS_ALIGNED()
Andrey Smirnov [Tue, 19 Feb 2019 20:02:38 +0000 (12:02 -0800)]
PCI: dwc: Make use of IS_ALIGNED()

Make the intent a bit more clear as well as get rid of explicit
arithmetic by using IS_ALIGNED() to determine if "addr" is aligned to
"size". No functional change intended.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Chris Healy <cphealy@gmail.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Leonard Crestez <leonard.crestez@nxp.com>
Cc: "A.s. Dong" <aisheng.dong@nxp.com>
Cc: Richard Zhu <hongxing.zhu@nxp.com>
Cc: linux-imx@nxp.com
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-pci@vger.kernel.org
5 years agoPCI: imx6: Add code to request/control "pcie_aux" clock for i.MX8MQ
Andrey Smirnov [Tue, 12 Feb 2019 01:51:08 +0000 (17:51 -0800)]
PCI: imx6: Add code to request/control "pcie_aux" clock for i.MX8MQ

The PCIe IP block has an additional clock, "pcie_aux", that needs to
be controlled by the driver. Add code to support it.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Chris Healy <cphealy@gmail.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Leonard Crestez <leonard.crestez@nxp.com>
Cc: "A.s. Dong" <aisheng.dong@nxp.com>
Cc: Richard Zhu <hongxing.zhu@nxp.com>
Cc: linux-imx@nxp.com
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-pci@vger.kernel.org
Cc: Rob Herring <robh@kernel.org>
Cc: devicetree@vger.kernel.org
5 years agoPCI/PME: Fix hotplug/sysfs remove deadlock in pcie_pme_remove()
Rafael J. Wysocki [Thu, 28 Feb 2019 19:56:27 +0000 (13:56 -0600)]
PCI/PME: Fix hotplug/sysfs remove deadlock in pcie_pme_remove()

Dongdong reported a deadlock triggered by a hotplug event during a sysfs
"remove" operation:

  pciehp 0000:00:0c.0:pcie004: Slot(0-1): Link Up
  # echo 1 > 0000:00:0c.0/remove

  PME and hotplug share an MSI/MSI-X vector.  The sysfs "remove" side is:

    remove_store
       pci_stop_and_remove_bus_device_locked
 pci_lock_rescan_remove
 pci_stop_and_remove_bus_device
   ...
   pcie_pme_remove
     pcie_pme_suspend
       synchronize_irq        # wait for hotplug IRQ handler
 pci_unlock_rescan_remove

  The hotplug side is:

    pciehp_ist
       pciehp_handle_presence_or_link_change
 pciehp_configure_device
   pci_lock_rescan_remove     # wait for pci_unlock_rescan_remove()

  INFO: task bash:10913 blocked for more than 120 seconds.

  # ps -ax |grep D
   PID TTY      STAT   TIME COMMAND
  10913 ttyAMA0  Ds+    0:00 -bash
  14022 ?        D      0:00 [irq/745-pciehp]

  # cat /proc/14022/stack
  __switch_to+0x94/0xd8
  pci_lock_rescan_remove+0x20/0x28
  pciehp_configure_device+0x30/0x140
  pciehp_handle_presence_or_link_change+0x324/0x458
  pciehp_ist+0x1dc/0x1e0

  # cat /proc/10913/stack
  __switch_to+0x94/0xd8
  synchronize_irq+0x8c/0xc0
  pcie_pme_suspend+0xa4/0x118
  pcie_pme_remove+0x20/0x40
  pcie_port_remove_service+0x3c/0x58
  ...
  pcie_port_device_remove+0x2c/0x48
  pcie_portdrv_remove+0x68/0x78
  pci_device_remove+0x48/0x120
  ...
  pci_stop_bus_device+0x84/0xc0
  pci_stop_and_remove_bus_device_locked+0x24/0x40
  remove_store+0xa4/0xb8
  dev_attr_store+0x44/0x60
  sysfs_kf_write+0x58/0x80

It is incorrect to call pcie_pme_suspend() from pcie_pme_remove() for two
reasons.

First, pcie_pme_suspend() calls synchronize_irq(), which will wait for the
native hotplug interrupt handler as well as for the PME one, because they
share one IRQ (as per the spec).  That may deadlock if hotplug is signaled
while pcie_pme_remove() is running and the latter calls
pci_lock_rescan_remove() before the former.

Second, if pcie_pme_suspend() figures out that wakeup needs to be enabled
for the port, it will return without disabling the interrupt as expected by
pcie_pme_remove() which was overlooked by commit c7b5a4e6e8fb ("PCI / PM:
Fix native PME handling during system suspend/resume").

To fix that, rework pcie_pme_remove() to disable the PME interrupt, clear
its status and prevent the PME worker function from re-enabling it before
calling free_irq() on it, which should be sufficient.

Fixes: c7b5a4e6e8fb ("PCI / PM: Fix native PME handling during system suspend/resume")
Link: https://lore.kernel.org/linux-pci/c7697e7c-e1af-13e4-8491-0a3996e6ab5d@huawei.com
Reported-by: Dongdong Liu <liudongdong3@huawei.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
[bhelgaas: add URL and deadlock details from Dongdong]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
5 years agodt-bindings: imx6q-pcie: Add "pcie_aux" clock for imx8mq
Andrey Smirnov [Tue, 12 Feb 2019 01:51:07 +0000 (17:51 -0800)]
dt-bindings: imx6q-pcie: Add "pcie_aux" clock for imx8mq

Add a binding for an extra clock required on i.MX8MQ.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Chris Healy <cphealy@gmail.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Leonard Crestez <leonard.crestez@nxp.com>
Cc: "A.s. Dong" <aisheng.dong@nxp.com>
Cc: Richard Zhu <hongxing.zhu@nxp.com>
Cc: linux-imx@nxp.com
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-pci@vger.kernel.org
Cc: Rob Herring <robh@kernel.org>
Cc: devicetree@vger.kernel.org
5 years agoPCI: qcom: Don't deassert reset GPIO during probe
Bjorn Andersson [Fri, 25 Jan 2019 23:26:16 +0000 (15:26 -0800)]
PCI: qcom: Don't deassert reset GPIO during probe

Acquiring the reset GPIO low means that reset is being deasserted, this
is followed almost immediately with qcom_pcie_host_init() asserting it,
initializing it and then finally deasserting it again, for the link to
come up.

Some PCIe devices requires a minimum time between the initial deassert
and subsequent reset cycles. In a platform that boots with the reset
GPIO asserted this requirement is being violated by this deassert/assert
pulse.

Acquire the reset GPIO high to prevent this situation by matching the
state to the subsequent asserted state.

Fixes: 82a823833f4e ("PCI: qcom: Add Qualcomm PCIe controller driver")
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
[lorenzo.pieralisi@arm.com: updated commit log]
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Stanimir Varbanov <svarbanov@mm-sol.com>
Cc: stable@vger.kernel.org
5 years agoPCI/DPC: Fix print AER status in DPC event handling
Dongdong Liu [Mon, 11 Feb 2019 07:02:59 +0000 (15:02 +0800)]
PCI/DPC: Fix print AER status in DPC event handling

Previously dpc_handler() called aer_get_device_error_info() without
initializing info->severity, so aer_get_device_error_info() relied on
uninitialized data.

Add dpc_get_aer_uncorrect_severity() to read the port's AER status, mask,
and severity registers and set info->severity.

Also, clear the port's AER fatal error status bits.

Fixes: 8aefa9b0d910 ("PCI/DPC: Print AER status in DPC event handling")
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
[bhelgaas: changelog]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Keith Busch <keith.busch@intel.com>
Cc: stable@vger.kernel.org # v4.19+
5 years agomisc: pci_endpoint_test: Add the layerscape EP device support
Xiaowei Bao [Thu, 21 Feb 2019 03:16:20 +0000 (11:16 +0800)]
misc: pci_endpoint_test: Add the layerscape EP device support

Add the layerscape EP device support in pci_endpoint_test driver.

Signed-off-by: Xiaowei Bao <xiaowei.bao@nxp.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Minghuan Lian <minghuan.lian@nxp.com>
Reviewed-by: Zhiqiang Hou <zhiqiang.hou@nxp.com>
Reviewed-by: Greg KH <gregkh@linuxfoundation.org>
5 years agoPCI: layerscape: Add EP mode support
Xiaowei Bao [Thu, 21 Feb 2019 03:16:19 +0000 (11:16 +0800)]
PCI: layerscape: Add EP mode support

Add the PCIe EP mode support to the layerscape platform controller.

Signed-off-by: Xiaowei Bao <xiaowei.bao@nxp.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Minghuan Lian <minghuan.lian@nxp.com>
Reviewed-by: Zhiqiang Hou <zhiqiang.hou@nxp.com>
Reviewed-by: Kishon Vijay Abraham I <kishon@ti.com>
5 years agoarm64: dts: Add the PCIE EP node in dts
Xiaowei Bao [Thu, 21 Feb 2019 03:16:18 +0000 (11:16 +0800)]
arm64: dts: Add the PCIE EP node in dts

Add the PCIE EP node in dts for ls1046a.

Signed-off-by: Xiaowei Bao <xiaowei.bao@nxp.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Minghuan Lian <minghuan.lian@nxp.com>
Reviewed-by: Zhiqiang Hou <zhiqiang.hou@nxp.com>
Reviewed-by: Rob Herring <robh+dt@kernel.org>
5 years agodt-bindings: add DT binding for the layerscape PCIe controller with EP mode
Xiaowei Bao [Thu, 21 Feb 2019 03:16:17 +0000 (11:16 +0800)]
dt-bindings: add DT binding for the layerscape PCIe controller with EP mode

Add the documentation for the Device Tree binding for the layerscape PCIe
controller with EP mode.

Signed-off-by: Xiaowei Bao <xiaowei.bao@nxp.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Minghuan Lian <minghuan.lian@nxp.com>
Reviewed-by: Zhiqiang Hou <zhiqiang.hou@nxp.com>
Reviewed-by: Rob Herring <robh+dt@kernel.org>
5 years agoMAINTAINERS: Update PCI Cadence maintainer entry
Lorenzo Pieralisi [Wed, 13 Feb 2019 14:42:01 +0000 (14:42 +0000)]
MAINTAINERS: Update PCI Cadence maintainer entry

Replace Alan Douglas with Tom Joseph as the current PCI
Cadence host/endpoint controller maintainer.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Tom Joseph <tjoseph@cadence.com>
5 years agoPCI: pciehp: Disable Data Link Layer State Changed event on suspend
Mika Westerberg [Thu, 31 Jan 2019 17:07:46 +0000 (20:07 +0300)]
PCI: pciehp: Disable Data Link Layer State Changed event on suspend

Commit 0e157e528604 ("PCI/PME: Implement runtime PM callbacks") tried to
solve an issue where the hierarchy immediately wakes up when it is
transitioned into D3cold.  However, it turns out to prevent PME
propagation on some systems that do not support D3cold.

I looked more closely at what might cause the immediate wakeup.  It happens
when the ACPI power resource of the root port is turned off.  The AML code
associated with the _OFF() method of the ACPI power resource starts a PCIe
L2/L3 Ready transition and waits for it to complete.  Right after the L2/L3
Ready transition is started the root port receives a PME from the
downstream port.

The simplest hierarchy where this happens looks like this:

  00:1d.0 PCIe Root Port
    ^
    |
    v
    05:00.0 PCIe switch #1 upstream port
      06:01.0 PCIe switch #1 downstream hotplug port
        ^
        |
        v
        08:00.0 PCIe switch #2 upstream port

It seems that the PCIe link between the two switches, before
PME_Turn_Off/PME_TO_Ack is complete for the whole hierarchy, goes
inactive and triggers PME towards the root port bringing it back to D0.
The L2/L3 Ready sequence is described in PCIe r4.0 spec sections 5.2 and
5.3.3 but unfortunately they do not state what happens if DLLSCE is
enabled during the sequence.

Disabling Data Link Layer State Changed event (DLLSCE) seems to prevent
the issue and still allows the downstream hotplug port to notice when a
device is plugged/unplugged.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=202593
Fixes: 0e157e528604 ("PCI/PME: Implement runtime PM callbacks")
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
CC: stable@vger.kernel.org # v4.20+
5 years agoPCI/portdrv: Support PCIe services on subtractive decode bridges
Honghui Zhang [Thu, 14 Feb 2019 05:21:17 +0000 (13:21 +0800)]
PCI/portdrv: Support PCIe services on subtractive decode bridges

The Class Code for subtractive decode PCI-to-PCI bridge is 060401h; add an
entry to make portdrv support this type of bridge.  This allows use of PCIe
services on subtractive decode ports.

Signed-off-by: Honghui Zhang <honghui.zhang@mediatek.com>
[bhelgaas: add braces surrounding entry]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
5 years agoPCI/portdrv: Use conventional Device ID table formatting
Bjorn Helgaas [Fri, 15 Feb 2019 19:49:18 +0000 (13:49 -0600)]
PCI/portdrv: Use conventional Device ID table formatting

The pci_device_id table was technically correct, but unusually formatted,
which made adding entries error-prone.  Change the format so it's obvious
how to add entries.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
5 years agoPCI: endpoint: Remove features member in struct pci_epc
Kishon Vijay Abraham I [Mon, 14 Jan 2019 11:15:13 +0000 (16:45 +0530)]
PCI: endpoint: Remove features member in struct pci_epc

Since EPC features are now implemented using pci_epc_features and
all the EPC drivers are moved to using pci_epc_features, remove
features member in struct pci_epc and all the helper macros for
configuring the features.

Tested-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
5 years agoPCI: designware-plat: Remove setting epc->features in Designware plat EP driver
Kishon Vijay Abraham I [Mon, 14 Jan 2019 11:15:12 +0000 (16:45 +0530)]
PCI: designware-plat: Remove setting epc->features in Designware plat EP driver

Now that pci-epf-test uses get_features callback and
dw_plat_pcie_epc_features in Designware plat EP driver already indicates
it doesn't support linkup notification and is MSIX capable, remove setting
epc->features which is not used anymore by the endpoint function driver.

Tested-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
5 years agoPCI: rockchip: Remove pci_epf_linkup() from Rockchip EP driver
Kishon Vijay Abraham I [Mon, 14 Jan 2019 11:15:11 +0000 (16:45 +0530)]
PCI: rockchip: Remove pci_epf_linkup() from Rockchip EP driver

pci_epf_linkup() is intended to be invoked if the EPC supports linkup
notification. Now that pci-epf-test uses get_features callback, which
indicates Rockchip EP driver doesn't support linkup notification, remove
pci_epf_linkup() from Rockchip EP driver.

Tested-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Shawn Lin <shawn.lin@rock-chips.com>
5 years agoPCI: cadence: Remove pci_epf_linkup() from Cadence EP driver
Kishon Vijay Abraham I [Mon, 14 Jan 2019 11:15:10 +0000 (16:45 +0530)]
PCI: cadence: Remove pci_epf_linkup() from Cadence EP driver

pci_epf_linkup() is intended to be invoked if the EPC supports linkup
notification. Now that pci-epf-test uses the get_features() callback,
which indicates Cadence EP driver doesn't support the linkup notification,
remove pci_epf_linkup() from Cadence EP driver.

Tested-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
5 years agoPCI: pci-epf-test: Use pci_epc_get_features() to get EPC features
Kishon Vijay Abraham I [Mon, 14 Jan 2019 11:15:09 +0000 (16:45 +0530)]
PCI: pci-epf-test: Use pci_epc_get_features() to get EPC features

Use pci_epc_get_features() to get EPC features such as linkup
notifier support, MSI/MSIX capable, BAR configuration etc and use it
for configuring pci-epf-test. Since these features are now obtained
directly from EPC driver, remove pci_epf_test_data which was initially
added to have EPC features in endpoint function driver.

Tested-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
5 years agoPCI: pci-epf-test: Do not allocate next BARs memory if current BAR is 64Bit
Kishon Vijay Abraham I [Mon, 14 Jan 2019 11:15:08 +0000 (16:45 +0530)]
PCI: pci-epf-test: Do not allocate next BARs memory if current BAR is 64Bit

It's useless to allocate memory for next BAR if the current BAR is a
64Bit BAR. Stop allocating memory for the next BAR, if the current
BARs flag indicates this is a 64Bit BAR.

Tested-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
5 years agoPCI: pci-epf-test: Remove setting epf_bar flags in function driver
Kishon Vijay Abraham I [Mon, 14 Jan 2019 11:15:07 +0000 (16:45 +0530)]
PCI: pci-epf-test: Remove setting epf_bar flags in function driver

Now that pci_epf_alloc_space() sets BAR MEM TYPE flags as 64Bit or
32Bit based on size, remove setting it in function driver.

Tested-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
5 years agoPCI: endpoint: Fix pci_epf_alloc_space() to set correct MEM TYPE flags
Kishon Vijay Abraham I [Mon, 14 Jan 2019 11:15:06 +0000 (16:45 +0530)]
PCI: endpoint: Fix pci_epf_alloc_space() to set correct MEM TYPE flags

pci_epf_alloc_space() sets the MEM TYPE flags to indicate a 32-bit
Base Address Register irrespective of the size. Fix it here to indicate
64-bit BAR if the size is > 2GB.

Tested-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
5 years agoPCI: endpoint: Add helper to get first unreserved BAR
Kishon Vijay Abraham I [Mon, 14 Jan 2019 11:15:05 +0000 (16:45 +0530)]
PCI: endpoint: Add helper to get first unreserved BAR

Add a helper function pci_epc_get_first_free_bar() to get the first
unreserved BAR that can be used for endpoint function.

Tested-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
5 years agoRevert "PCI/PME: Implement runtime PM callbacks"
Mika Westerberg [Thu, 31 Jan 2019 17:07:45 +0000 (20:07 +0300)]
Revert "PCI/PME: Implement runtime PM callbacks"

This reverts commit 0e157e52860441cb26051f131dd0b5ae3187a07b.

Heiner reported that the commit in question prevents his network adapter
from triggering PME and waking up when network cable is plugged.

The commit tried to prevent root port waking up from D3cold immediately but
looks like disabing root port PME interrupt is not the right way to fix
that issue so revert it now.  The patch following proposes an alternative
solution to that issue.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=202103
Fixes: 0e157e528604 ("PCI/PME: Implement runtime PM callbacks")
Reported-by: Heiner Kallweit <hkallweit1@gmail.com>
Tested-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
CC: stable@vger.kernel.org # v4.20+
5 years agoPCI: cadence: Populate ->get_features() cdns_pcie_epc_ops
Kishon Vijay Abraham I [Mon, 14 Jan 2019 11:15:04 +0000 (16:45 +0530)]
PCI: cadence: Populate ->get_features() cdns_pcie_epc_ops

Populate ->get_features() dw_pcie_ep_ops to return the EPC features
supported by Cadence PCIe endpoint controller.

Tested-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
5 years agoPCI: rockchip: Populate ->get_features() dw_pcie_ep_ops
Kishon Vijay Abraham I [Mon, 14 Jan 2019 11:15:03 +0000 (16:45 +0530)]
PCI: rockchip: Populate ->get_features() dw_pcie_ep_ops

Populate ->get_features() dw_pcie_ep_ops to return the EPC features
supported by Rockchip PCIe endpoint controller.

Tested-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
5 years agoPCI: pci-dra7xx: Populate ->get_features() dw_pcie_ep_ops
Kishon Vijay Abraham I [Mon, 14 Jan 2019 11:15:02 +0000 (16:45 +0530)]
PCI: pci-dra7xx: Populate ->get_features() dw_pcie_ep_ops

Populate ->get_features() dw_pcie_ep_ops to return the EPC features
supported by DRA7xx PCIe endpoint controller.

Tested-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
5 years agoPCI: designware-plat: Populate ->get_features() dw_pcie_ep_ops
Kishon Vijay Abraham I [Mon, 14 Jan 2019 11:15:01 +0000 (16:45 +0530)]
PCI: designware-plat: Populate ->get_features() dw_pcie_ep_ops

Populate ->get_features() dw_pcie_ep_ops to return the EPC features
supported by Designware PCIe endpoint controller.

Tested-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
5 years agoPCI: dwc: Add ->get_features() callback function to dw_pcie_ep_ops
Kishon Vijay Abraham I [Mon, 14 Jan 2019 11:15:00 +0000 (16:45 +0530)]
PCI: dwc: Add ->get_features() callback function to dw_pcie_ep_ops

Each platform using Designware PCIe core can support different set of
endpoint features. Add a new callback function ->get_features() in
dw_pcie_ep_ops so that each platform using Designware PCIe core can
advertise its supported features to the endpoint function driver.

Tested-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
5 years agoPCI: endpoint: Add new pci_epc_ops to get EPC features
Kishon Vijay Abraham I [Mon, 14 Jan 2019 11:14:59 +0000 (16:44 +0530)]
PCI: endpoint: Add new pci_epc_ops to get EPC features

Add a new pci_epc_ops ->get_features() to get the features
supported by the EPC. Since EPC can provide different features to
different functions, the ->get_features() ops takes _func_no_ as
an argument.

Tested-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
5 years agoPCI: endpoint: functions: Use memcpy_fromio()/memcpy_toio()
Wen Yang [Mon, 11 Feb 2019 09:04:00 +0000 (17:04 +0800)]
PCI: endpoint: functions: Use memcpy_fromio()/memcpy_toio()

Functions copying from/to IO addresses should use the
memcpy_fromio()/memcpy_toio() API rather than plain memcpy().

Fix the issue detected through the sparse tool.

Fixes: 349e7a85b25f ("PCI: endpoint: functions: Add an EP function to test PCI")
Suggested-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
[lorenzo.pieralisi@arm.com: updated log]
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
CC: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
CC: Bjorn Helgaas <bhelgaas@google.com>
CC: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
CC: Niklas Cassel <niklas.cassel@axis.com>
CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
CC: Cyrille Pitchen <cyrille.pitchen@free-electrons.com>
CC: linux-pci@vger.kernel.org
CC: linux-kernel@vger.kernel.org
5 years agoPCI: imx: Add workaround for e10728, IMX7d PCIe PLL failure
Trent Piepho [Tue, 5 Feb 2019 00:17:41 +0000 (00:17 +0000)]
PCI: imx: Add workaround for e10728, IMX7d PCIe PLL failure

This implements the workound described in the NXP IMX7d erratum e10728.

Initial VCO oscillation may fail under corner conditions such as cold
temperature. It causes PCIe PLL to fail to lock in the initialization
phase, which results in the PCIe link failing to come up.

The workaround is to disable Duty-Cycle Corrector (DCC) calibration
after G_RST.

To do this it is necessary to gain access to the undocumented and
currently unused PCIe PHY register bank. A new device tree node of type
"fsl,imx7d-pcie-phy" is created for the PHY block and the existing PCIe
device uses a phandle named "fsl,imx7d-pcie-phy" to point to it.

Signed-off-by: Trent Piepho <tpiepho@impinj.com>
[lorenzo.pieralisi@arm.com: updated log string, commit log]
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
5 years agoARM: dts: imx7d: Add node for PCIe PHY
Trent Piepho [Tue, 5 Feb 2019 00:17:40 +0000 (00:17 +0000)]
ARM: dts: imx7d: Add node for PCIe PHY

This adds the PHY as a new node. The PCI-e controller node gains a
phandle property that points to it.

There isn't yet any code in the kernel that uses this device's
registers, but it will be added for a PCIe PLL erratum workaround.

Signed-off-by: Trent Piepho <tpiepho@impinj.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
5 years agodt-bindings: imx6q-pcie: Add description of imx7d pcie phy
Trent Piepho [Tue, 5 Feb 2019 00:17:39 +0000 (00:17 +0000)]
dt-bindings: imx6q-pcie: Add description of imx7d pcie phy

There is a separate PHY device with its own registers on imx7d.  It's
currently unused, but a PCIe erratum on imx7d will require it for the
workaround.

Signed-off-by: Trent Piepho <tpiepho@impinj.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Lucas Stach <l.stach@pengutronix.de>
5 years agoPCI: dwc: Print debug error message when MSI-X entry control mask bit is set
Gustavo Pimentel [Fri, 7 Dec 2018 17:24:37 +0000 (18:24 +0100)]
PCI: dwc: Print debug error message when MSI-X entry control mask bit is set

Add debug error message when MSI-X entry control mask bit is set, to help
debug the reason why a MSI-X interrupt is not being triggered.

Signed-off-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Jingoo Han <jingoohan1@gmail.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Joao Pinto <joao.pinto@synopsys.com>
5 years agoPCI/ASPM: Save LTR Capability for suspend/resume
Bjorn Helgaas [Wed, 9 Jan 2019 14:22:08 +0000 (08:22 -0600)]
PCI/ASPM: Save LTR Capability for suspend/resume

Latency Tolerance Reporting (LTR) allows Endpoints and Switch Upstream
Ports to report their latency requirements to upstream components.  If ASPM
L1 PM substates are enabled, the LTR information helps determine when a
Link enters L1.2 [1].

Software must set the maximum latency values in the LTR Capability based on
characteristics of the platform, then set LTR Mechanism Enable in the
Device Control 2 register in the PCIe Capability.  The device can then use
LTR to report its latency tolerance.

If the device reports a maximum latency value of zero, that means the
device requires the highest possible performance and the ASPM L1.2 substate
is effectively disabled.

We put devices in D3 for suspend, and we assume their internal state is
lost.  On resume, previously we did not restore the LTR Capability, but we
did restore the LTR Mechanism Enable bit, so devices would request the
highest possible performance and ASPM L1.2 wouldn't be used.

[1] PCIe r4.0, sec 5.5.1
Link: https://bugzilla.kernel.org/show_bug.cgi?id=201469
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
5 years agoPCI: Blacklist power management of Gigabyte X299 DESIGNARE EX PCIe ports
Mika Westerberg [Thu, 31 Jan 2019 16:38:56 +0000 (19:38 +0300)]
PCI: Blacklist power management of Gigabyte X299 DESIGNARE EX PCIe ports

Gigabyte X299 DESIGNARE EX motherboard has one PCIe root port that is
connected to an Alpine Ridge Thunderbolt controller.  This port has slot
implemented bit set in the config space but other than that it is not
hotplug capable in the sense we are expecting in Linux (it has
dev->is_hotplug_bridge set to 0):

  00:1c.4 PCI bridge: Intel Corporation 200 Series PCH PCI Express Root Port #5
    Bus: primary=00, secondary=05, subordinate=46, sec-latency=0
    Memory behind bridge: 78000000-8fffffff [size=384M]
    Prefetchable memory behind bridge: 00003800f8000000-00003800ffffffff [size=128M]
    ...
    Capabilities: [40] Express (v2) Root Port (Slot+), MSI 00
    ...
      SltCap: AttnBtn- PwrCtrl- MRL- AttnInd- PwrInd- HotPlug- Surprise-
      Slot #8, PowerLimit 25.000W; Interlock- NoCompl+
      SltCtl: Enable: AttnBtn- PwrFlt- MRL- PresDet- CmdCplt- HPIrq- LinkChg-
      Control: AttnInd Unknown, PwrInd Unknown, Power- Interlock-
      SltSta: Status: AttnBtn- PowerFlt- MRL- CmdCplt- PresDet- Interlock-
      Changed: MRL- PresDet+ LinkState+

This system is using ACPI based hotplug to notify the OS that it needs to
rescan the PCI bus (ACPI hotplug).

If there is nothing connected in any of the Thunderbolt ports the root port
will not have any runtime PM active children and is thus automatically
runtime suspended pretty soon after boot by PCI PM core.  Now, when a
device is connected the BIOS SMI handler responsible for enumerating newly
added devices is not able to find anything because the port is in D3.

Prevent this from happening by blacklisting PCI power management of this
particular Gigabyte system.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=202031
Reported-by: Kedar A Dongre <kedar.a.dongre@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
5 years agoPCI/ASPM: Use LTR if already enabled by platform
Bjorn Helgaas [Fri, 4 Jan 2019 23:59:07 +0000 (17:59 -0600)]
PCI/ASPM: Use LTR if already enabled by platform

RussianNeuroMancer reported that the Intel 7265 wifi on a Dell Venue 11 Pro
7140 table stopped working after wakeup from suspend and bisected the
problem to 9ab105deb60f ("PCI/ASPM: Disable ASPM L1.2 Substate if we don't
have LTR").  David Ward reported the same problem on a Dell Latitude 7350.

After af8bb9f89838 ("PCI/ACPI: Request LTR control from platform before
using it"), we don't enable LTR unless the platform has granted LTR control
to us.  In addition, we don't notice if the platform had already enabled
LTR itself.

After 9ab105deb60f ("PCI/ASPM: Disable ASPM L1.2 Substate if we don't have
LTR"), we avoid using LTR if we don't think the path to the device has LTR
enabled.

The combination means that if the platform itself enables LTR but declines
to give the OS control over LTR, we unnecessarily avoided using ASPM L1.2.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=201469
Fixes: 9ab105deb60f ("PCI/ASPM: Disable ASPM L1.2 Substate if we don't have LTR")
Fixes: af8bb9f89838 ("PCI/ACPI: Request LTR control from platform before using it")
Reported-by: RussianNeuroMancer <russianneuromancer@ya.ru>
Reported-by: David Ward <david.ward@ll.mit.edu>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: stable@vger.kernel.org # v4.18+
5 years agoPCI: Clean up usage of __u32 type
Logan Gunthorpe [Fri, 8 Feb 2019 16:54:39 +0000 (09:54 -0700)]
PCI: Clean up usage of __u32 type

The double underscore types are meant for compatibility in userspace
headers which does not apply here. Therefore, change to use the standard
no-underscore types.

The origin of the double underscore types dates back to before the git era
so I was not able to find a commit to see the original justification.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
5 years agogenirq/msi: Clean up usage of __u8/__u16 types
Logan Gunthorpe [Fri, 8 Feb 2019 16:54:38 +0000 (09:54 -0700)]
genirq/msi: Clean up usage of __u8/__u16 types

The double underscore types are meant for compatibility in userspace
headers which does not apply here. Therefore, change to use the standard
no-underscore types.

The origin of the double underscore types dates back to before the git era
so I was not able to find a commit to see the original justification.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
5 years agox86/PCI: Fixup RTIT_BAR of Intel Denverton Trace Hub
Alexander Shishkin [Thu, 7 Feb 2019 13:30:05 +0000 (15:30 +0200)]
x86/PCI: Fixup RTIT_BAR of Intel Denverton Trace Hub

On Denverton's integration of the Intel(R) Trace Hub (for a reference and
overview see Documentation/trace/intel_th.rst) the reported size of one of
its resources (RTIT_BAR) doesn't match its actual size, which leads to
overlaps with other devices' resources.

In practice, it overlaps with XHCI MMIO space, which results in the xhci
driver bailing out after seeing its registers as 0xffffffff, and perceived
disappearance of all USB devices:

  intel_th_pci 0000:00:1f.7: enabling device (0004 -> 0006)
  xhci_hcd 0000:00:15.0: xHCI host controller not responding, assume dead
  xhci_hcd 0000:00:15.0: xHC not responding in xhci_irq, assume controller is dead
  xhci_hcd 0000:00:15.0: HC died; cleaning up
  usb 1-1: USB disconnect, device number 2

For this reason, we need to resize the RTIT_BAR on Denverton to its actual
size, which in this case is 4MB.  The corresponding erratum is DNV36 at the
link below:

  DNV36.       Processor Host Root Complex May Incorrectly Route Memory
               Accesses to Intel® Trace Hub

  Problem:     The Intel® Trace Hub RTIT_BAR (B0:D31:F7 offset 20h) is
       reported as a 2KB memory range.  Due to this erratum, the
       processor Host Root Complex will forward addresses from
       RTIT_BAR to RTIT_BAR + 4MB -1 to Intel® Trace Hub.

  Implication: Devices assigned within the RTIT_BAR to RTIT_BAR + 4MB -1
               space may not function correctly.

  Workaround:  A BIOS code change has been identified and may be
               implemented as a workaround for this erratum.

  Status:      No Fix.

Note that 5118ccd34780 ("intel_th: pci: Add Denverton SOC support") updates
the Trace Hub driver so it claims the Denverton device, but the resource
overlap exists regardless of whether that driver is loaded or that commit
is included.

Link: https://www.intel.com/content/dam/www/public/us/en/documents/specification-updates/atom-c3000-family-spec-update.pdf
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
[bhelgaas: include erratum text, clarify relationship with 5118ccd34780]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: stable@vger.kernel.org
5 years agodt-bindings: PCI: rcar: Add device tree support for r8a774c0
Fabrizio Castro [Tue, 18 Dec 2018 12:02:42 +0000 (12:02 +0000)]
dt-bindings: PCI: rcar: Add device tree support for r8a774c0

Add PCIe support for the RZ/G2E (a.k.a. R8A774C0).

Signed-off-by: Fabrizio Castro <fabrizio.castro@bp.renesas.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Rob Herring <robh@kernel.org>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
5 years agoPCI: imx6: Add support for i.MX8MQ
Andrey Smirnov [Sat, 2 Feb 2019 00:15:23 +0000 (16:15 -0800)]
PCI: imx6: Add support for i.MX8MQ

Add code needed to support i.MX8MQ variant.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Chris Healy <cphealy@gmail.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Leonard Crestez <leonard.crestez@nxp.com>
Cc: "A.s. Dong" <aisheng.dong@nxp.com>
Cc: Richard Zhu <hongxing.zhu@nxp.com>
5 years agoPCI: imx6: Convert DIRECT_SPEED_CHANGE quirk code to use a flag
Andrey Smirnov [Sat, 2 Feb 2019 00:15:22 +0000 (16:15 -0800)]
PCI: imx6: Convert DIRECT_SPEED_CHANGE quirk code to use a flag

Both i.MX7D and i.MX8MQ have the same behaviour when it comes to
clearing DIRECT_SPEED_CHANGE bit when no speed change occurs, so to
handle variants correctly add a flag instead of checking the IP block
variant.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
[lorenzo.pieralisi@arm.com: updated log]
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Chris Healy <cphealy@gmail.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Leonard Crestez <leonard.crestez@nxp.com>
Cc: "A.s. Dong" <aisheng.dong@nxp.com>
Cc: Richard Zhu <hongxing.zhu@nxp.com>
5 years agoPCI: imx6: Mark PHY functions as i.MX6 specific
Andrey Smirnov [Sat, 2 Feb 2019 00:15:21 +0000 (16:15 -0800)]
PCI: imx6: Mark PHY functions as i.MX6 specific

PCIe PHY IP block on i.MX7D differs from the one used on i.MX6 family,
so none of the code in the current implementation of
imx6_setup_phy_mpll() or imx6_pcie_reset_phy() is applicable.

Introduce IMX6_PCIE_FLAG_IMX6_PHY and check for it in the aforementioned
functions to make sure they are only executed on appropriate PCIe IP
variants.

Tested-by: Trent Piepho <tpiepho@impinj.com>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
[lorenzo.pieralisi@arm.com: updated log]
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Chris Healy <cphealy@gmail.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Leonard Crestez <leonard.crestez@nxp.com>
Cc: "A.s. Dong" <aisheng.dong@nxp.com>
Cc: Richard Zhu <hongxing.zhu@nxp.com>
5 years agoPCI: imx6: Introduce drvdata
Andrey Smirnov [Sat, 2 Feb 2019 00:15:20 +0000 (16:15 -0800)]
PCI: imx6: Introduce drvdata

Introduce driver data struct. This will simplify handling of device
specific differences.

Signed-off-by: Stefan Agner <stefan@agner.ch>
[andrew.smirnov@gmail.com reformatted drvdata, to simplify future diffs]
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Chris Healy <cphealy@gmail.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Leonard Crestez <leonard.crestez@nxp.com>
Cc: "A.s. Dong" <aisheng.dong@nxp.com>
Cc: Richard Zhu <hongxing.zhu@nxp.com>
5 years agoPCI: Enable SERR# forwarding for all bridges
Bharat Kumar Gogada [Wed, 14 Nov 2018 14:47:01 +0000 (20:17 +0530)]
PCI: Enable SERR# forwarding for all bridges

As per Figure 6-3 in PCIe r4.0, sec 6.2.6, ERR_ messages will be forwarded
from the secondary interface to the primary interface, if the SERR# Enable
bit in the Bridge Control register is set.

It seems clear that an ACPI hotplug parameter method (_HPP or _HPX) that
tells us to "enable SERR in the command register" (ACPI v6.2, sec 6.2.8,
6.2.9.1) refers to PCI_COMMAND_SERR, which enables reporting of errors by
the function itself.

For bridges, we also interpreted that to mean we should enable
PCI_BRIDGE_CTL_SERR, which enables *forwarding* of errors by the bridge.
But we didn't enable PCI_BRIDGE_CTL_SERR anywhere else, which means we
never enabled it for non-ACPI systems or ACPI systems that didn't supply
hotplug parameters.

That means errors reported below bridges were often never forwarded up to a
Root Port where they could be signaled via AER.

Enable PCI_BRIDGE_CTL_SERR for all bridges so we can get better error
reporting for downstream devices.

Signed-off-by: Bharat Kumar Gogada <bharat.kumar.gogada@xilinx.com>
[bhelgaas: changelog]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
5 years agoPCI: Move Rohm Vendor ID to generic list
Andy Shevchenko [Fri, 1 Feb 2019 23:24:52 +0000 (17:24 -0600)]
PCI: Move Rohm Vendor ID to generic list

Move the Rohm Vendor ID to pci_ids.h instead of defining it in several
drivers.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Mark Brown <broonie@kernel.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
5 years agoPCI: pciehp: Add HXT quirk for Command Completed errata
Shunyong Yang [Wed, 7 Nov 2018 07:25:05 +0000 (15:25 +0800)]
PCI: pciehp: Add HXT quirk for Command Completed errata

The HXT SD4800 PCI controller does not set the Command Completed bit unless
writes to the Slot Command register change "Control" bits.

Add SD4800 to the quirk.

Signed-off-by: Shunyong Yang <shunyong.yang@hxt-semitech.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Joey Zheng <yu.zheng@hxt-semitech.com>
5 years agoPCI: Add ACS quirk for HXT SD4800
Shunyong Yang [Fri, 1 Feb 2019 23:13:10 +0000 (17:13 -0600)]
PCI: Add ACS quirk for HXT SD4800

The design of HXT SD4800 ACS feature is the same as QCOM QDF2xxx.  Add an
ACS quirk for the SD4800.

Signed-off-by: Shunyong Yang <shunyong.yang@hxt-semitech.com>
[bhelgaas: split to separate patch]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Sinan Kaya <okaya@kernel.org>
CC: Joey Zheng <yu.zheng@hxt-semitech.com>
5 years agoPCI: Add HXT vendor ID
Shunyong Yang [Fri, 1 Feb 2019 23:11:14 +0000 (17:11 -0600)]
PCI: Add HXT vendor ID

Add the HXT vendor ID to pci_ids.h.

Signed-off-by: Shunyong Yang <shunyong.yang@hxt-semitech.com>
[bhelgaas: split to separate patch]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Sinan Kaya <okaya@kernel.org>
CC: Joey Zheng <yu.zheng@hxt-semitech.com>
5 years agoPCI: dwc: Replace bit rotation operation (1 << bit) with BIT(bit)
Gustavo Pimentel [Thu, 31 Jan 2019 18:17:07 +0000 (19:17 +0100)]
PCI: dwc: Replace bit rotation operation (1 << bit) with BIT(bit)

Replace bit rotation operation (1 << bit) with BIT(bit), which
simplifies code reading.

No functional change is intended.

Signed-off-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Joao Pinto <jpinto@synopsys.com>
Cc: Jingoo Han <jingoohan1@gmail.com>
5 years agoPCI: dwc: Improve code readability and simplify mask/unmask operations
Gustavo Pimentel [Thu, 31 Jan 2019 18:17:06 +0000 (19:17 +0100)]
PCI: dwc: Improve code readability and simplify mask/unmask operations

Improve code readability and simplifies mask/unmask operations by
inverting the applied logic (no functional change is intended).

Replace variable name from irq_status to irq_mask, since its goal is to
keep track of which interrupts are masked or not.

Signed-off-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Joao Pinto <jpinto@synopsys.com>
Cc: Jingoo Han <jingoohan1@gmail.com>
5 years agoPCI: dwc: Rename variable name from data to d on dw_pcie_irq_domain_free()
Gustavo Pimentel [Thu, 31 Jan 2019 18:17:05 +0000 (19:17 +0100)]
PCI: dwc: Rename variable name from data to d on dw_pcie_irq_domain_free()

Rename variable from data to d to maintain consistency between driver
functions.

No functional change is intended.

Signed-off-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Joao Pinto <jpinto@synopsys.com>
Cc: Jingoo Han <jingoohan1@gmail.com>
5 years agoPCI: dwc: Rename variable name from data to d on dw_pci_msi_set_affinity()
Gustavo Pimentel [Thu, 31 Jan 2019 18:17:04 +0000 (19:17 +0100)]
PCI: dwc: Rename variable name from data to d on dw_pci_msi_set_affinity()

Rename variable from data to d to maintain consistency between driver
functions.

No functional change is intended.

Signed-off-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Joao Pinto <jpinto@synopsys.com>
Cc: Jingoo Han <jingoohan1@gmail.com>
5 years agoPCI: dwc: Rename variable name from data to d on dw_pci_setup_msi_msg()
Gustavo Pimentel [Thu, 31 Jan 2019 18:17:03 +0000 (19:17 +0100)]
PCI: dwc: Rename variable name from data to d on dw_pci_setup_msi_msg()

Rename variable from data to d to maintain consistency between driver
functions, such as dw_pci_setup_msi_msg().

No functional change is intended.

Signed-off-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Joao Pinto <jpinto@synopsys.com>
Cc: Jingoo Han <jingoohan1@gmail.com>
5 years agoPCI: dwc: Rename variable name from data to d on dw_pci_bottom_mask/unmask()
Gustavo Pimentel [Thu, 31 Jan 2019 18:17:02 +0000 (19:17 +0100)]
PCI: dwc: Rename variable name from data to d on dw_pci_bottom_mask/unmask()

Rename variable from data to d to maintain consistency between driver
functions, such as dw_msi_mask_irq() and dw_msi_unmask_irq().

No functional change is intended.

Signed-off-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Joao Pinto <jpinto@synopsys.com>
Cc: Jingoo Han <jingoohan1@gmail.com>
5 years agoPCI: dwc: Remove unnecessary header include (signal.h)
Gustavo Pimentel [Thu, 31 Jan 2019 18:17:01 +0000 (19:17 +0100)]
PCI: dwc: Remove unnecessary header include (signal.h)

Remove unnecessary header include (signal.h) since it doesn't provide
any needed symbols.

Signed-off-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Joao Pinto <jpinto@synopsys.com>
Cc: Jingoo Han <jingoohan1@gmail.com>
5 years agoPCI: dwc: Remove unnecessary header include (of_gpio.h)
Gustavo Pimentel [Thu, 31 Jan 2019 18:17:00 +0000 (19:17 +0100)]
PCI: dwc: Remove unnecessary header include (of_gpio.h)

Remove unnecessary header include (of_gpio.h) since it doesn't provide
any needed symbols.

Signed-off-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Joao Pinto <jpinto@synopsys.com>
Cc: Jingoo Han <jingoohan1@gmail.com>
5 years agoPCI: dwc: dra7xx: Invoke phy_set_mode() API to set PHY mode to PHY_MODE_PCIE
Kishon Vijay Abraham I [Thu, 24 Jan 2019 10:45:37 +0000 (16:15 +0530)]
PCI: dwc: dra7xx: Invoke phy_set_mode() API to set PHY mode to PHY_MODE_PCIE

Certain PHYs used with PCIe controller can also be used with other
controllers such as USB or SATA. In order to configure the PHY
to work with PCIe controller, invoke phy_set_mode() API with mode
set to PHY_MODE_PCIE.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
[lorenzo.pieralisi@arm.com: updated commit log]
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
5 years agoPCI: dwc: dra7xx: Enable x2 mode support for dra74x, dra76x and dra72x
Kishon Vijay Abraham I [Thu, 24 Jan 2019 08:29:57 +0000 (13:59 +0530)]
PCI: dwc: dra7xx: Enable x2 mode support for dra74x, dra76x and dra72x

dra74x/dra76x and dra72x have separate compatible strings. Add support
for these compatible strings in pci-dra7xx driver to perform syscon
configurations required to get x2 mode working.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
5 years agodt-bindings: PCI: dra7xx: Add properties to enable x2 lane in dra7
Kishon Vijay Abraham I [Thu, 24 Jan 2019 08:29:56 +0000 (13:59 +0530)]
dt-bindings: PCI: dra7xx: Add properties to enable x2 lane in dra7

Add syscon properties required for configuring PCIe in x2 lane mode.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Rob Herring <robh@kernel.org>
5 years agodt-bindings: PCI: dra7xx: Add SoC specific compatible strings
Kishon Vijay Abraham I [Thu, 24 Jan 2019 08:29:55 +0000 (13:59 +0530)]
dt-bindings: PCI: dra7xx: Add SoC specific compatible strings

Add new compatible strings for dra74x SoC (also used by dra76x) and
dra72x. This can be used to perform SoC specific configuration
(like configuring PCIe in x2 lane mode).

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Rob Herring <robh@kernel.org>
5 years agoPCI: Rely on config space header type, not class code
Honghui Zhang [Tue, 16 Oct 2018 10:44:43 +0000 (18:44 +0800)]
PCI: Rely on config space header type, not class code

The PCI configuration space header type tells us whether the device is a
bridge, a CardBus bridge, or a normal device, and defines the layout of the
rest of the header (PCI r3.0 sec 6.1, PCIe r4.0 sec 7.5.1.1.9).

When we rely on the header format, e.g., when we're dealing with bridge
windows, we should check the header type, not the class code.  The class
code is loosely related to the header type, but is often incorrect and the
spec doesn't actually require it to be related to the header format.

Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Honghui Zhang <honghui.zhang@mediatek.com>
[bhelgaas: changelog, keep the PCI_CLASS_BRIDGE_HOST check]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
5 years agoPCI: Make pci_size() return real BAR size
Du Changbin [Sat, 13 Oct 2018 00:49:19 +0000 (08:49 +0800)]
PCI: Make pci_size() return real BAR size

Currently, the pci_size() function actually returns 'size-1'.  Make it
return real size to avoid confusion.

Signed-off-by: Du Changbin <changbin.du@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
5 years agoPCI: ibmphp: Turn semaphores into completions or mutexes
Arnd Bergmann [Mon, 10 Dec 2018 21:49:10 +0000 (22:49 +0100)]
PCI: ibmphp: Turn semaphores into completions or mutexes

The sem_exit variable is conceptually a completion, so it should be called
that.

Similarly, the semOperations semaphore is a simple mutex, and can be
changed into that, respectively.

With both converted, the ibmphp_hpc_initvars() function is no longer used
and can be removed.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
5 years agoPCI/AER: Use match_string() helper to simplify the code
Andy Shevchenko [Mon, 28 Jan 2019 11:57:28 +0000 (13:57 +0200)]
PCI/AER: Use match_string() helper to simplify the code

match_string() returns the array index of a matching string.  Use it
instead of the open-coded implementation.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
5 years agoPCI: Use of_node_name_eq() for node name comparisons
Rob Herring [Wed, 5 Dec 2018 19:50:34 +0000 (13:50 -0600)]
PCI: Use of_node_name_eq() for node name comparisons

Convert string compares of DT node names to use of_node_name_eq() helper
instead.  This removes direct access to the node name pointer.

Signed-off-by: Rob Herring <robh@kernel.org>
[bhelgaas: drop similar rpaphp_core.c change to avoid merge conflict]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>