platform/kernel/linux-rpi.git
7 years agoMerge branch 'pci/host-xilinx' into next
Bjorn Helgaas [Tue, 21 Feb 2017 21:16:12 +0000 (15:16 -0600)]
Merge branch 'pci/host-xilinx' into next

* pci/host-xilinx:
  PCI: xilinx-nwl: Remove mask for messages not supported by AXI
  PCI: xilinx: Configure PCIe MPS settings

7 years agoMerge branch 'pci/host-xgene' into next
Bjorn Helgaas [Tue, 21 Feb 2017 21:16:08 +0000 (15:16 -0600)]
Merge branch 'pci/host-xgene' into next

* pci/host-xgene:
  PCI: xgene: Configure PCIe MPS settings
  PCI: xgene: Fix double free on init error

7 years agoMerge branch 'pci/host-versatile' into next
Bjorn Helgaas [Tue, 21 Feb 2017 21:15:54 +0000 (15:15 -0600)]
Merge branch 'pci/host-versatile' into next

* pci/host-versatile:
  PCI: versatile: Configure PCIe MPS settings

7 years agoMerge branch 'pci/host-thunder' into next
Bjorn Helgaas [Tue, 21 Feb 2017 21:15:49 +0000 (15:15 -0600)]
Merge branch 'pci/host-thunder' into next

* pci/host-thunder:
  PCI: thunder-pem: Add support for cn81xx and cn83xx SoCs

7 years agoMerge branch 'pci/host-rockchip' into next
Bjorn Helgaas [Tue, 21 Feb 2017 21:15:44 +0000 (15:15 -0600)]
Merge branch 'pci/host-rockchip' into next

* pci/host-rockchip:
  PCI: rockchip: Set vendor ID from local core config space
  PCI: rockchip: Fix rockchip_pcie_probe() error path to free resource list
  PCI: rockchip: Mark PM functions as __maybe_unused
  PCI: rockchip: Use readl_poll_timeout() instead of open-coding it
  PCI: rockchip: Disable RC's ASPM L0s based on DT "aspm-no-l0s"
  PCI: rockchip: Add system PM support

7 years agoMerge branch 'pci/host-rcar' into next
Bjorn Helgaas [Tue, 21 Feb 2017 21:15:39 +0000 (15:15 -0600)]
Merge branch 'pci/host-rcar' into next

* pci/host-rcar:
  PCI: rcar: Use of_device_get_match_data() to simplify probe
  PCI: rcar: Add compatible string for r8a7796
  PCI: rcar: Return -ENODEV from host bridge probe when no card present

7 years agoMerge branch 'pci/host-mvebu' into next
Bjorn Helgaas [Tue, 21 Feb 2017 21:15:34 +0000 (15:15 -0600)]
Merge branch 'pci/host-mvebu' into next

* pci/host-mvebu:
  PCI: mvebu: Change delay after reset to the PCIe spec mandated 100ms
  PCI: mvebu: Handle changes to the bridge windows while enabled

7 years agoMerge branch 'pci/host-layerscape' into next
Bjorn Helgaas [Tue, 21 Feb 2017 21:15:21 +0000 (15:15 -0600)]
Merge branch 'pci/host-layerscape' into next

* pci/host-layerscape:
  PCI: layerscape: Use of_device_get_match_data() to simplify probe

Conflicts:
drivers/pci/dwc/pci-layerscape.c

7 years agoMerge branch 'pci/host-iproc' into next
Bjorn Helgaas [Tue, 21 Feb 2017 21:15:05 +0000 (15:15 -0600)]
Merge branch 'pci/host-iproc' into next

* pci/host-iproc:
  PCI: Add Broadcom Northstar2 PAXC quirk for device class and MPSS
  PCI: iproc: Configure PCIe MPS settings
  PCI: iproc: Use of_device_get_match_data() to simplify probe

7 years agoMerge branch 'pci/host-imx6' into next
Bjorn Helgaas [Tue, 21 Feb 2017 21:14:53 +0000 (15:14 -0600)]
Merge branch 'pci/host-imx6' into next

* pci/host-imx6:
  PCI: imx6: Fix a typo in error message
  PCI: imx6: Remove LTSSM disable workaround
  PCI: imx6: Remove redundant "Link never came up" message

Conflicts:
drivers/pci/dwc/pci-imx6.c

7 years agoMerge branch 'pci/host-hv' into next
Bjorn Helgaas [Tue, 21 Feb 2017 21:14:31 +0000 (15:14 -0600)]
Merge branch 'pci/host-hv' into next

* pci/host-hv:
  PCI: hv: Use device serial number as PCI domain
  PCI: hv: Fix wslot_to_devfn() to fix warnings on device removal

7 years agoMerge branch 'pci/host-hisi' into next
Bjorn Helgaas [Tue, 21 Feb 2017 21:14:18 +0000 (15:14 -0600)]
Merge branch 'pci/host-hisi' into next

* pci/host-hisi:
  PCI: generic: Call pci_fixup_irqs() only on ARM
  PCI: Disable MSI for HiSilicon Hip06/Hip07 Root Ports
  PCI: hisi: Rename config space accessors to remove "acpi"
  PCI: hisi: Add DT almost-ECAM support for Hip06/Hip07 host controllers
  PCI: hisi: Use of_device_get_match_data() to simplify probe

Conflicts:
drivers/pci/dwc/pcie-hisi.c

7 years agoMerge branch 'pci/host-exynos' into next
Bjorn Helgaas [Tue, 21 Feb 2017 21:13:30 +0000 (15:13 -0600)]
Merge branch 'pci/host-exynos' into next

* pci/host-exynos:
  PCI: exynos: Support the PHY generic framework
  Documentation: binding: Modify the exynos5440 PCIe binding
  phy: phy-exynos-pcie: Add support for Exynos PCIe PHY
  Documentation: samsung-phy: Add exynos-pcie-phy binding
  PCI: exynos: Refactor to make it easier to support other SoCs
  PCI: exynos: Remove duplicated code
  PCI: exynos: Use the bitops BIT() macro to build bitmasks
  PCI: exynos: Remove unnecessary local variables
  PCI: exynos: Replace the *_blk/*_phy/*_elb accessors
  PCI: exynos: Rename all pointer names from "exynos_pcie" to "ep"

Conflicts:
drivers/pci/dwc/pci-exynos.c

7 years agoMerge branch 'pci/host-altera' into next
Bjorn Helgaas [Tue, 21 Feb 2017 21:12:18 +0000 (15:12 -0600)]
Merge branch 'pci/host-altera' into next

* pci/host-altera:
  PCI: altera: Extract TLP completion status correctly

7 years agoMerge branch 'pci/host-designware' into next
Bjorn Helgaas [Tue, 21 Feb 2017 21:12:18 +0000 (15:12 -0600)]
Merge branch 'pci/host-designware' into next

* pci/host-designware:
  PCI: dwc: Remove dependency of designware on CONFIG_PCI
  PCI: dwc: Add CONFIG_PCIE_DW_HOST to enable PCI dwc host
  PCI: dwc: Split pcie-designware.c into host and core files
  PCI: dwc: designware: Fix style errors in pcie-designware.c
  PCI: dwc: designware: Parse "num-lanes" property in dw_pcie_setup_rc()
  PCI: dwc: all: Split struct pcie_port into host-only and core structures
  PCI: dwc: designware: Get device pointer at the start of dw_pcie_host_init()
  PCI: dwc: all: Rename cfg_read/cfg_write to read/write
  PCI: dwc: all: Use platform_set_drvdata() to save private data
  PCI: dwc: designware: Move register defines to designware header file
  PCI: dwc: Use PTR_ERR_OR_ZERO to simplify code
  PCI: dra7xx: Group PHY API invocations
  PCI: dra7xx: Enable MSI and legacy interrupts simultaneously
  PCI: dra7xx: Add support to force RC to work in GEN1 mode
  PCI: dra7xx: Simplify probe code with devm_gpiod_get_optional()
  PCI: Move DesignWare IP support to new drivers/pci/dwc/ directory
  PCI: designware: Check for iATU unroll only on platforms that use ATU

7 years agoPCI: dwc: Remove dependency of designware on CONFIG_PCI
Kishon Vijay Abraham I [Wed, 15 Feb 2017 13:18:19 +0000 (18:48 +0530)]
PCI: dwc: Remove dependency of designware on CONFIG_PCI

CONFIG_PCI is used to enable host mode PCI. In preparation for adding
endpoint mode support to designware driver, remove the dependency of
designware on CONFIG_PCI and make only the host-specific part depend on
CONFIG_PCI.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: dwc: Add CONFIG_PCIE_DW_HOST to enable PCI dwc host
Kishon Vijay Abraham I [Wed, 15 Feb 2017 13:18:18 +0000 (18:48 +0530)]
PCI: dwc: Add CONFIG_PCIE_DW_HOST to enable PCI dwc host

Now that PCI designware host has a separate file, add a new PCIE_DW_HOST
config symbol to select the host-only driver. This will enable to
independently select host support and endpoint support (when it's added).

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: dwc: Split pcie-designware.c into host and core files
Kishon Vijay Abraham I [Wed, 15 Feb 2017 13:18:17 +0000 (18:48 +0530)]
PCI: dwc: Split pcie-designware.c into host and core files

Split pcie-designware.c into pcie-designware-host.c that contains the host
specific parts of the driver and pcie-designware.c that contains the parts
used by both host driver and endpoint driver.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: dwc: designware: Fix style errors in pcie-designware.c
Kishon Vijay Abraham I [Wed, 15 Feb 2017 13:18:16 +0000 (18:48 +0530)]
PCI: dwc: designware: Fix style errors in pcie-designware.c

No functional change. Fix all checkpatch warnings and check errors in
pcie-designware.c

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-By: Joao Pinto <jpinto@synopsys.com>
7 years agoPCI: dwc: designware: Parse "num-lanes" property in dw_pcie_setup_rc()
Kishon Vijay Abraham I [Wed, 15 Feb 2017 13:18:15 +0000 (18:48 +0530)]
PCI: dwc: designware: Parse "num-lanes" property in dw_pcie_setup_rc()

The "num-lanes" DT property is parsed in dw_pcie_host_init(). However
num-lanes is applicable to both root complex mode and endpoint mode. As a
first step, move the parsing of this property outside dw_pcie_host_init().
This is in preparation for splitting pcie-designware.c to pcie-designware.c
and pcie-designware-host.c

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: dwc: all: Split struct pcie_port into host-only and core structures
Kishon Vijay Abraham I [Wed, 15 Feb 2017 13:18:14 +0000 (18:48 +0530)]
PCI: dwc: all: Split struct pcie_port into host-only and core structures

Keep only the host-specific members in struct pcie_port and move the common
members (i.e common to both host and endpoint) to struct dw_pcie.  This is
in preparation for adding endpoint mode support to designware driver.

While at that also fix checkpatch warnings.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Jingoo Han <jingoohan1@gmail.com>
CC: Richard Zhu <hongxing.zhu@nxp.com>
CC: Lucas Stach <l.stach@pengutronix.de>
CC: Murali Karicheri <m-karicheri2@ti.com>
CC: Minghuan Lian <minghuan.Lian@freescale.com>
CC: Mingkai Hu <mingkai.hu@freescale.com>
CC: Roy Zang <tie-fei.zang@freescale.com>
CC: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
CC: Niklas Cassel <niklas.cassel@axis.com>
CC: Jesper Nilsson <jesper.nilsson@axis.com>
CC: Joao Pinto <Joao.Pinto@synopsys.com>
CC: Zhou Wang <wangzhou1@hisilicon.com>
CC: Gabriele Paoloni <gabriele.paoloni@huawei.com>
CC: Stanimir Varbanov <svarbanov@mm-sol.com>
CC: Pratyush Anand <pratyush.anand@gmail.com>
7 years agoPCI: dwc: designware: Get device pointer at the start of dw_pcie_host_init()
Kishon Vijay Abraham I [Wed, 15 Feb 2017 13:18:13 +0000 (18:48 +0530)]
PCI: dwc: designware: Get device pointer at the start of dw_pcie_host_init()

No functional change. Get device pointer at the beginning of
dw_pcie_host_init() instead of getting it all over dw_pcie_host_init().
This is in preparation for splitting struct pcie_port into host and core
structures (once split pcie_port will not have device pointer).

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: dwc: all: Rename cfg_read/cfg_write to read/write
Kishon Vijay Abraham I [Wed, 15 Feb 2017 13:18:12 +0000 (18:48 +0530)]
PCI: dwc: all: Rename cfg_read/cfg_write to read/write

No functional change. dw_pcie_cfg_read()/dw_pcie_cfg_write() doesn't do
anything specific to access configuration space. It can be just renamed to
dw_pcie_read()/dw_pcie_write() and used to read/write data to dbi space.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-By: Joao Pinto <jpinto@synopsys.com>
CC: Jingoo Han <jingoohan1@gmail.com>
CC: Murali Karicheri <m-karicheri2@ti.com>
CC: Stanimir Varbanov <svarbanov@mm-sol.com>
CC: Pratyush Anand <pratyush.anand@gmail.com>
7 years agoPCI: dwc: all: Use platform_set_drvdata() to save private data
Kishon Vijay Abraham I [Wed, 15 Feb 2017 13:18:11 +0000 (18:48 +0530)]
PCI: dwc: all: Use platform_set_drvdata() to save private data

Add platform_set_drvdata() in all designware-based drivers to store the
private data structure of the driver so that dev_set_drvdata() can be used
to get back private data structure in add_pcie_port/host_init.  This is in
preparation for splitting struct pcie_port into core and host only
structures. After the split pcie_port will not be part of the driver's
private data structure and *container_of* used now to get the private data
pointer cannot be used.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Jingoo Han <jingoohan1@gmail.com>
CC: Richard Zhu <hongxing.zhu@nxp.com>
CC: Lucas Stach <l.stach@pengutronix.de>
CC: Murali Karicheri <m-karicheri2@ti.com>
CC: Minghuan Lian <minghuan.Lian@freescale.com>
CC: Mingkai Hu <mingkai.hu@freescale.com>
CC: Roy Zang <tie-fei.zang@freescale.com>
CC: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
CC: Niklas Cassel <niklas.cassel@axis.com>
CC: Jesper Nilsson <jesper.nilsson@axis.com>
CC: Joao Pinto <Joao.Pinto@synopsys.com>
CC: Zhou Wang <wangzhou1@hisilicon.com>
CC: Gabriele Paoloni <gabriele.paoloni@huawei.com>
CC: Stanimir Varbanov <svarbanov@mm-sol.com>
CC: Pratyush Anand <pratyush.anand@gmail.com>
7 years agoPCI: dwc: designware: Move register defines to designware header file
Kishon Vijay Abraham I [Wed, 15 Feb 2017 13:18:10 +0000 (18:48 +0530)]
PCI: dwc: designware: Move register defines to designware header file

No functional change. Move the register defines and other macros from
pcie-designware.c to pcie-designware.h. This is in preparation to split the
pcie-designware.c file into designware core file and host-specific file.

While at that also fix a checkpatch warning.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-By: Joao Pinto <jpinto@synopsys.com>
7 years agoPCI: dwc: Use PTR_ERR_OR_ZERO to simplify code
Fengguang Wu [Sat, 4 Feb 2017 01:35:32 +0000 (09:35 +0800)]
PCI: dwc: Use PTR_ERR_OR_ZERO to simplify code

Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR to avoid the
following warnings found by scripts/coccinelle/api/ptr_ret.cocci:

  drivers/pci/dwc/pcie-qcom.c:215:1-3: WARNING: PTR_ERR_OR_ZERO can be used
  drivers/pci/dwc/pcie-qcom.c:247:1-3: WARNING: PTR_ERR_OR_ZERO can be used
  drivers/pci/dwc/pcie-qcom.c:481:1-3: WARNING: PTR_ERR_OR_ZERO can be used

Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Kishon Vijay Abraham I <kishon@ti.com>
7 years agoPCI: dra7xx: Group PHY API invocations
Kishon Vijay Abraham I [Wed, 11 Jan 2017 12:06:55 +0000 (17:36 +0530)]
PCI: dra7xx: Group PHY API invocations

No functional change.  PHY APIs like phy_init()/phy_power_on() are invoked
from multiple places.  Group all the PHY APIs in dra7xx_pcie_enable_phy()
and dra7xx_pcie_disable_phy() and use these functions for enabling or
disabling the PHY.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: dra7xx: Enable MSI and legacy interrupts simultaneously
Kishon Vijay Abraham I [Wed, 11 Jan 2017 12:06:54 +0000 (17:36 +0530)]
PCI: dra7xx: Enable MSI and legacy interrupts simultaneously

pci-dra7xx driver had a bug in that if CONFIG_PCI_MSI config is enabled, it
doesn't support legacy interrupt.  Fix it here so that both MSI and legacy
interrupts can be enabled simultaneously and the interrupt mechanism
supported by the endpoint device will be used.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: dra7xx: Add support to force RC to work in GEN1 mode
Kishon Vijay Abraham I [Wed, 11 Jan 2017 12:06:53 +0000 (17:36 +0530)]
PCI: dra7xx: Add support to force RC to work in GEN1 mode

PCIe in AM57x/DRA7x devices is by default configured to work in GEN2 mode.
However there may be situations when working in GEN1 mode is desired.  One
example is limitation i925 (PCIe GEN2 mode not supported at junction
temperatures < 0C).

Add support to force Root Complex to work in GEN1 mode if so desired, but
don't force GEN1 mode on any board just yet.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: dra7xx: Simplify probe code with devm_gpiod_get_optional()
Kishon Vijay Abraham I [Wed, 11 Jan 2017 12:06:52 +0000 (17:36 +0530)]
PCI: dra7xx: Simplify probe code with devm_gpiod_get_optional()

No functional change.  Use the new devm_gpiod_get_optional() to simplify
the probe code.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: Move DesignWare IP support to new drivers/pci/dwc/ directory
Kishon Vijay Abraham I [Fri, 6 Jan 2017 12:52:48 +0000 (18:22 +0530)]
PCI: Move DesignWare IP support to new drivers/pci/dwc/ directory

Group all the PCI drivers that use DesignWare core in dwc directory.
dwc IP is capable of operating in both host mode and device mode and
keeping it inside the *host* directory is misleading.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Jingoo Han <jingoohan1@gmail.com>
Acked-By: Joao Pinto <jpinto@synopsys.com>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Minghuan Lian <minghuan.Lian@freescale.com>
Cc: Mingkai Hu <mingkai.hu@freescale.com>
Cc: Roy Zang <tie-fei.zang@freescale.com>
Cc: Richard Zhu <hongxing.zhu@nxp.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Murali Karicheri <m-karicheri2@ti.com>
Cc: Pratyush Anand <pratyush.anand@gmail.com>
Cc: Niklas Cassel <niklas.cassel@axis.com>
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: Zhou Wang <wangzhou1@hisilicon.com>
Cc: Gabriele Paoloni <gabriele.paoloni@huawei.com>
Cc: Stanimir Varbanov <svarbanov@mm-sol.com>
7 years agoMerge branch 'for-linus' into pci/host-designware
Bjorn Helgaas [Tue, 21 Feb 2017 20:59:14 +0000 (14:59 -0600)]
Merge branch 'for-linus' into pci/host-designware

* for-linus:
  PCI: designware: Check for iATU unroll only on platforms that use ATU

7 years agoPCI: exynos: Support the PHY generic framework
Jaehoon Chung [Mon, 13 Feb 2017 08:26:13 +0000 (17:26 +0900)]
PCI: exynos: Support the PHY generic framework

Switch the pci-exynos driver to generic PHY framework.  At the same time
backward compatibility is preserved: Warning will be printed for old DTB.

Refer to the binding file:
- Documentation/devicetree/bindings/pci/samsung,exynos5440-pcie.txt

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Pankaj Dubey <pankaj.dubey@samsung.com>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Acked-by: Krzysztof Kozlowski <krzk@kernel.org>
Acked-by: Jingoo Han <jingoohan1@gmail.com>
7 years agoDocumentation: binding: Modify the exynos5440 PCIe binding
Jaehoon Chung [Mon, 13 Feb 2017 08:26:12 +0000 (17:26 +0900)]
Documentation: binding: Modify the exynos5440 PCIe binding

According to using PHY framework, updates the exynos5440-pcie binding.  For
maintaining backward compatibility, leaves the current dt-binding.  (It
should be deprecated.)

Recommends to use the PHY Framework and "config" property to follow the
designware-pcie binding.  If you use the old way, can see "missing *config*
reg space" message.  Because the getting configuration space address from
range is old way.

NOTE: When use the "config" property, first name of 'reg-names' must be set
to "elbi".  Otherwise driver can't maintain the backward capability.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Pankaj Dubey <pankaj.dubey@samsung.com>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Acked-by: Rob Herring <robh@kernel.org>
7 years agophy: phy-exynos-pcie: Add support for Exynos PCIe PHY
Jaehoon Chung [Mon, 13 Feb 2017 08:26:11 +0000 (17:26 +0900)]
phy: phy-exynos-pcie: Add support for Exynos PCIe PHY

Add support for Generic PHY framework about Exynos SoCs.  Current Exynos
PCIe driver doesn't use the PHY framework, which makes it difficult to
upstream the other Exynos variants because of different PHY registers.

Move the codes relevant to PHY from Exnyos PCIe driver to PHY Exynos PCIe
driver.

[bhelgaas: depend on "OF && (ARCH_EXYNOS || COMPILE_TEST)", update
copyright year, both per Vivek]
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Acked-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Jingoo Han <jingoohan1@gmail.com>
Reviewed-by: Pankaj Dubey <pankaj.dubey@samsung.com>
Reviewed-by: Vivek Gautam <vivek.gautam@codeaurora.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoDocumentation: samsung-phy: Add exynos-pcie-phy binding
Jaehoon Chung [Mon, 13 Feb 2017 08:26:10 +0000 (17:26 +0900)]
Documentation: samsung-phy: Add exynos-pcie-phy binding

Add the exynos-pcie-phy binding for Exynos PCIe PHY.  This is for using
generic PHY framework.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rob Herring <robh@kernel.org>
7 years agoPCI: altera: Extract TLP completion status correctly
Yadi Hu [Fri, 17 Feb 2017 20:20:26 +0000 (14:20 -0600)]
PCI: altera: Extract TLP completion status correctly

Previously we extracted 'Completion Status' from b14:12, but it is actually
b15:13.  Extract it from the correct bits.

Signed-off-by: Hu Yadi<yadi.hu@windriver.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Ley Foon Tan <ley.foon.tan@intel.com>
7 years agoPCI: rockchip: Set vendor ID from local core config space
Shawn Lin [Thu, 16 Feb 2017 07:29:35 +0000 (15:29 +0800)]
PCI: rockchip: Set vendor ID from local core config space

The TRM says the vendor ID in the RC's configure space can be rewritten
and the value must be the same as the value read from the local core
configure space.  But we misread that and didn't notice it before.  Actually
we should only able to rewrite it from the local core configure space.

Fix that issue to make lspci show the correct IP vendor infomation.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: hv: Use device serial number as PCI domain
Haiyang Zhang [Mon, 13 Feb 2017 18:10:11 +0000 (18:10 +0000)]
PCI: hv: Use device serial number as PCI domain

Use the device serial number as the PCI domain.  The serial numbers start
with 1 and are unique within a VM.  So names, such as VF NIC names, that
include domain number as part of the name, can be shorter than that based
on part of bus UUID previously.  The new names will also stay same for VMs
created with copied VHD and same number of devices.

Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
7 years agoMerge branch 'pci/vpd' into next
Bjorn Helgaas [Wed, 15 Feb 2017 17:56:12 +0000 (11:56 -0600)]
Merge branch 'pci/vpd' into next

* pci/vpd:
  PCI: Increase VPD access timeout to 125ms

7 years agoMerge branch 'pci/virtualization' into next
Bjorn Helgaas [Wed, 15 Feb 2017 17:56:11 +0000 (11:56 -0600)]
Merge branch 'pci/virtualization' into next

* pci/virtualization:
  PCI: Lock each enable/disable num_vfs operation in sysfs
  PCI: Add ACS quirk for Intel Union Point

7 years agoMerge branch 'pci/resource' into next
Bjorn Helgaas [Wed, 15 Feb 2017 17:56:10 +0000 (11:56 -0600)]
Merge branch 'pci/resource' into next

* pci/resource:
  PCI: Remove res_to_dev_res() debug message

7 years agoMerge branch 'pci/msi' into next
Bjorn Helgaas [Wed, 15 Feb 2017 17:56:10 +0000 (11:56 -0600)]
Merge branch 'pci/msi' into next

* pci/msi:
  PCI/MSI: Update MSI/MSI-X bits in PCIEBUS-HOWTO
  PCI/MSI: Document pci_alloc_irq_vectors(), deprecate pci_enable_msi()
  PCI/MSI: Return -ENOSPC if pci_enable_msi_range() can't get enough vectors
  PCI/portdrv: Use pci_irq_alloc_vectors()
  PCI/MSI: Check that we have a legacy interrupt line before using it
  PCI/MSI: Remove pci_msi_domain_{alloc,free}_irqs()
  PCI/MSI: Remove unused pci_msi_create_default_irq_domain()
  PCI/MSI: Return failure when msix_setup_entries() fails
  PCI/MSI: Remove pci_enable_msi_{exact,range}()
  amd-xgbe: Update PCI support to use new IRQ functions
  [media] cobalt: use pci_irq_allocate_vectors()
  PCI/MSI: Fix msi_capability_init() kernel-doc warnings

7 years agoMerge branch 'pci/hotplug' into next
Bjorn Helgaas [Wed, 15 Feb 2017 17:56:09 +0000 (11:56 -0600)]
Merge branch 'pci/hotplug' into next

* pci/hotplug:
  PCI: acpiphp_ibm: Make ibm_apci_table_attr __ro_after_init
  PCI: rpadlpar: Remove unnecessary return statement

7 years agoMerge branch 'pci/enumeration' into next
Bjorn Helgaas [Wed, 15 Feb 2017 17:56:08 +0000 (11:56 -0600)]
Merge branch 'pci/enumeration' into next

* pci/enumeration:
  PCI: Remove duplicate check for positive return value from probe() functions
  PCI: Enable PCIe Extended Tags if supported
  PCI: Avoid possible deadlock on pci_lock and p->pi_lock
  PCI/ACPI: Fix bus range comparison in pci_mcfg_lookup()
  PCI: Apply _HPX settings only to relevant devices

7 years agoMerge branch 'pci/dpc' into next
Bjorn Helgaas [Wed, 15 Feb 2017 17:56:07 +0000 (11:56 -0600)]
Merge branch 'pci/dpc' into next

* pci/dpc:
  PCI/DPC: Wait for Root Port busy to clear
  PCI/DPC: Decode extended reasons

7 years agoMerge branch 'pci/aspm' into next
Bjorn Helgaas [Wed, 15 Feb 2017 17:56:07 +0000 (11:56 -0600)]
Merge branch 'pci/aspm' into next

* pci/aspm:
  PCI/ASPM: Add comment about L1 substate latency
  PCI/ASPM: Configure L1 substate settings
  PCI/ASPM: Calculate and save the L1.2 timing parameters
  PCI/ASPM: Read and set up L1 substate capabilities
  PCI/ASPM: Add support for L1 substates
  PCI/ASPM: Add L1 substate capability structure register definitions

7 years agoMerge branch 'pci/aer' into next
Bjorn Helgaas [Wed, 15 Feb 2017 17:56:06 +0000 (11:56 -0600)]
Merge branch 'pci/aer' into next

* pci/aer:
  PCI/AER: Remove unused .link_reset() callback

7 years agoPCI/MSI: Update MSI/MSI-X bits in PCIEBUS-HOWTO
Christoph Hellwig [Wed, 15 Feb 2017 07:58:23 +0000 (08:58 +0100)]
PCI/MSI: Update MSI/MSI-X bits in PCIEBUS-HOWTO

Update the MSI/MSI-X bits in PCIEBUS-HOWTO.  Stop talking about low-level
details that mention deprecated APIs and concentrate on what service
drivers should do and why.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI/MSI: Document pci_alloc_irq_vectors(), deprecate pci_enable_msi()
Christoph Hellwig [Wed, 15 Feb 2017 07:58:22 +0000 (08:58 +0100)]
PCI/MSI: Document pci_alloc_irq_vectors(), deprecate pci_enable_msi()

Document pci_alloc_irq_vectors() instead of the deprecated pci_enable_msi()
and pci_enable_msix() APIs.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI/ASPM: Add comment about L1 substate latency
Rajat Jain [Tue, 3 Jan 2017 06:34:15 +0000 (22:34 -0800)]
PCI/ASPM: Add comment about L1 substate latency

Since the exit latencies for L1 substates are not advertised by a device,
it is not clear in spec how to do a L1 substate exit latency check.  We
assume that the L1 exit latencies advertised by a device include L1
substate latencies (and hence do not do any check).  If that is not true,
we should do some sort of check here.

(I'm not clear about what that check should like currently. I'd be glad to
take up any suggestions).

Signed-off-by: Rajat Jain <rajatja@google.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI/ASPM: Configure L1 substate settings
Rajat Jain [Tue, 3 Jan 2017 06:34:14 +0000 (22:34 -0800)]
PCI/ASPM: Configure L1 substate settings

Configure the L1 substate settings on the upstream and downstream devices,
while taking care of the rules dictated by the PCIe spec.

[bhelgaas: drop "inline"]
Signed-off-by: Rajat Jain <rajatja@google.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI/ASPM: Calculate and save the L1.2 timing parameters
Rajat Jain [Tue, 3 Jan 2017 06:34:13 +0000 (22:34 -0800)]
PCI/ASPM: Calculate and save the L1.2 timing parameters

Calculate and save the timing parameters that need to be programmed if we
need to enable L1.2 substates later.

We use the same logic (and a constant value for 1 of the parameters) as
used by Intel's coreboot:

  https://www.coreboot.org/pipermail/coreboot-gerrit/2015-March/021134.html
  https://review.coreboot.org/#/c/8832/

Signed-off-by: Rajat Jain <rajatja@google.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI/ASPM: Read and set up L1 substate capabilities
Rajat Jain [Tue, 3 Jan 2017 06:34:12 +0000 (22:34 -0800)]
PCI/ASPM: Read and set up L1 substate capabilities

The PCIe spec (r3.1, sec 7.33) says the L1 PM Substates Capability may be
implemented only in function 0.

Read the L1 substate capability structures of upstream and downstream
components of the link and set it up in the device structure.

[bhelgaas: add specific spec reference]
Signed-off-by: Rajat Jain <rajatja@google.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI/ASPM: Add support for L1 substates
Rajat Jain [Tue, 3 Jan 2017 06:34:11 +0000 (22:34 -0800)]
PCI/ASPM: Add support for L1 substates

Add support for ASPM L1 substates.  For details about L1 substates, see the
PCIe r3.1 spec, which includes the ECN below in secs 5.5 and 7.33.

Add macros for the 4 new L1 substates, and add a new ASPM "POWER_SUPERSAVE"
policy that can be used to enable L1 substates on a system if desired.  The
new policy is in a sense, a superset of the existing POWERSAVE policy.  The
4 policies are now:

  DEFAULT: Reads and uses whatever ASPM states BIOS enabled
  PERFORMANCE: Everything except L0 disabled.
  POWERSAVE: L0s and L1 enabled (but not L1 substates)
  POWER_SUPERSAVE: L0s + L1 + L1 substates also enabled

[bhelgaas: add PCIe r3.1 spec reference]
Link: https://pcisig.com/sites/default/files/specification_documents/ECN_L1_PM_Substates_with_CLKREQ_31_May_2013_Rev10a.pdf
Signed-off-by: Rajat Jain <rajatja@google.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI/ASPM: Add L1 substate capability structure register definitions
Rajat Jain [Tue, 3 Jan 2017 06:34:10 +0000 (22:34 -0800)]
PCI/ASPM: Add L1 substate capability structure register definitions

Add L1 substate capability structure register definitions for use in
subsequent patches.  See the PCIe r3.1 spec, sec 7.33.

[bhelgaas: add PCIe spec reference]
Signed-off-by: Rajat Jain <rajatja@google.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: exynos: Refactor to make it easier to support other SoCs
Niyas Ahmed S T [Wed, 1 Feb 2017 04:43:06 +0000 (10:13 +0530)]
PCI: exynos: Refactor to make it easier to support other SoCs

Currently the Exynos PCIe driver only supports the Exynos5440 SoC.
Refactor the driver to allow support for other Exynos SoC.

Following are the main changes in this patch:

1) Add separate structs for memory, clock resources

  Future Exynos SoC will have different hardware resources such as iomem,
  clocks, regmap handles, etc., so keeping these resources in separate
  structs will let us initialize them via per-SoC ops and avoid littering
  the code with of_machine_is_compatible().

2) Add exynos_pcie_ops struct which will allow us to support the
   differences in resources in different Exynos SoC.

No functional change intended.

Signed-off-by: Niyas Ahmed S T <niyas.ahmed@samsung.com>
Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
Acked-by: Krzysztof Kozlowski <krzk@kernel.org>
Acked-by: Jingoo Han <jingoohan1@gmail.com>
7 years agoPCI/MSI: Return -ENOSPC if pci_enable_msi_range() can't get enough vectors
Dennis Chen [Thu, 1 Dec 2016 02:15:04 +0000 (10:15 +0800)]
PCI/MSI: Return -ENOSPC if pci_enable_msi_range() can't get enough vectors

If device doesn't support as many MSI vectors as the driver requested, we
previously returned -EINVAL from __pci_enable_msi_range() and
pci_enable_msi_range().  In other similar situations in both
__pci_enable_msi_range() and __pci_enable_msix_range(), we returned
-ENOSPC.

Return -ENOSPC from __pci_enable_msi_range() so we do it consistently.

[bhelgaas: changelog]
Signed-off-by: Dennis Chen <dennis.chen@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Tejun Heo <tj@kernel.org>
CC: Christoph Hellwig <hch@lst.de>
CC: Tom Long Nguyen <tom.l.nguyen@intel.com>
CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
CC: Marc Zyngier <marc.zyngier@arm.com>
CC: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
CC: Steve Capper <steve.capper@arm.com>
7 years agoPCI/portdrv: Use pci_irq_alloc_vectors()
Christoph Hellwig [Wed, 1 Feb 2017 13:41:43 +0000 (14:41 +0100)]
PCI/portdrv: Use pci_irq_alloc_vectors()

Use pci_irq_alloc_vectors() and greatly simplify the code by managing the
vector number for the subservices directly.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI/MSI: Check that we have a legacy interrupt line before using it
Christoph Hellwig [Wed, 1 Feb 2017 13:41:42 +0000 (14:41 +0100)]
PCI/MSI: Check that we have a legacy interrupt line before using it

It seems like there are some devices (e.g. the PCIe root port driver) that
may not always have a INTx interrupt.  Check for dev->irq before returning
a legacy interrupt in pci_irq_alloc_vectors to properly handle this case.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: rockchip: Fix rockchip_pcie_probe() error path to free resource list
Shawn Lin [Fri, 10 Feb 2017 06:52:02 +0000 (14:52 +0800)]
PCI: rockchip: Fix rockchip_pcie_probe() error path to free resource list

rockchip_pcie_probe() calls of_pci_get_host_bridge_resources() to parse
resources from DT and build a resource list.  The caller is responsible for
disposing of the resource list.  This is normally done by
pci_release_host_bridge_dev() when the host bridge is removed.

If the host bridge probe fails, dispose of the resource list in the probe
error path.

[bhelgaas: changelog]
Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: imx6: Fix a typo in error message
Andrey Smirnov [Tue, 7 Feb 2017 15:50:25 +0000 (07:50 -0800)]
PCI: imx6: Fix a typo in error message

Fix a typo in the "pcie_inbound_axi clock missing or invalid" error
message.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Lucas Stach <l.stach@pengutronix.de>
CC: yurovsky@gmail.com
CC: Fabio Estevam <fabio.estevam@nxp.com>
7 years agoPCI: hv: Fix wslot_to_devfn() to fix warnings on device removal
Dexuan Cui [Fri, 10 Feb 2017 21:18:46 +0000 (15:18 -0600)]
PCI: hv: Fix wslot_to_devfn() to fix warnings on device removal

The devfn of 00:02.0 is 0x10.  devfn_to_wslot(0x10) == 0x2, and
wslot_to_devfn(0x2) should be 0x10, while it's 0x2 in the current code.

Due to this, hv_eject_device_work() -> pci_get_domain_bus_and_slot()
returns NULL and pci_stop_and_remove_bus_device() is not called.

Later when the real device driver's .remove() is invoked by
hv_pci_remove() -> pci_stop_root_bus(), some warnings can be noticed
because the VM has lost the access to the underlying device at that
time.

Signed-off-by: Jake Oshins <jakeo@microsoft.com>
Signed-off-by: Dexuan Cui <decui@microsoft.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Haiyang Zhang <haiyangz@microsoft.com>
CC: stable@vger.kernel.org
CC: K. Y. Srinivasan <kys@microsoft.com>
CC: Stephen Hemminger <sthemmin@microsoft.com>
7 years agoPCI: Remove duplicate check for positive return value from probe() functions
Gabriel Krisman Bertazi [Mon, 6 Feb 2017 15:34:14 +0000 (13:34 -0200)]
PCI: Remove duplicate check for positive return value from probe() functions

Function __pci_device_probe() tries to be careful about a PCI driver
probe() hook returning a positive value, but this is not really necessary,
since the same fix up is already done in local_pci_probe() (preceded by a
noisy warning), which renders this instance dead code.

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI/DPC: Wait for Root Port busy to clear
Keith Busch [Fri, 3 Feb 2017 21:46:13 +0000 (16:46 -0500)]
PCI/DPC: Wait for Root Port busy to clear

Per PCIe r3.1, sec 6.2.10 and sec 7.13.4, on Root Ports that support "RP
Extensions for DPC",

  When the DPC Trigger Status bit is Set and the DPC RP Busy bit is Set,
  software must leave the Root Port in DPC until the DPC RP Busy bit reads
  0b.

Wait up to 1 second for the Root Port to become non-busy.

[bhelgaas: changelog, spec references]
Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI/DPC: Decode extended reasons
Keith Busch [Fri, 3 Feb 2017 21:46:12 +0000 (16:46 -0500)]
PCI/DPC: Decode extended reasons

Decode the currently defined extended event reasons rather than just using
the generic "extended" explanation.

Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI/MSI: Remove pci_msi_domain_{alloc,free}_irqs()
Christoph Hellwig [Wed, 8 Feb 2017 17:17:44 +0000 (18:17 +0100)]
PCI/MSI: Remove pci_msi_domain_{alloc,free}_irqs()

Just call the msi_* version directly instead of having trivial wrappers for
one or two callsites.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
7 years agoPCI/MSI: Remove unused pci_msi_create_default_irq_domain()
Christoph Hellwig [Wed, 8 Feb 2017 17:17:43 +0000 (18:17 +0100)]
PCI/MSI: Remove unused pci_msi_create_default_irq_domain()

pci_msi_create_default_irq_domain() is never called in the whole tree, so
remove it as well as all the supporting code for a default PCI MSI domain.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
7 years agoPCI: xilinx-nwl: Remove mask for messages not supported by AXI
Bharat Kumar Gogada [Tue, 31 Jan 2017 08:59:30 +0000 (14:29 +0530)]
PCI: xilinx-nwl: Remove mask for messages not supported by AXI

Remove support for vendor-defined messages which are not supported by AXI.

Signed-off-by: Bharat Kumar Gogada <bharatku@xilinx.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI/MSI: Return failure when msix_setup_entries() fails
Christophe JAILLET [Fri, 27 Jan 2017 15:14:53 +0000 (16:14 +0100)]
PCI/MSI: Return failure when msix_setup_entries() fails

If alloc_msi_entry() fails, we free resources and set ret = -ENOMEM.

However, msix_setup_entries() returns 0 unconditionally.  Return the error
code instead.

Fixes: e75eafb9b039 ("genirq/msi: Switch to new irq spreading infrastructure")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: xgene: Configure PCIe MPS settings
Bjorn Helgaas [Wed, 8 Feb 2017 21:43:45 +0000 (15:43 -0600)]
PCI: xgene: Configure PCIe MPS settings

Make sure PCIe MPS settings are valid when we enumerate a new hierarchy.

Based-on-patch-by: Jon Mason <jon.mason@broadcom.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: Enable PCIe Extended Tags if supported
Sinan Kaya [Fri, 20 Jan 2017 14:16:51 +0000 (09:16 -0500)]
PCI: Enable PCIe Extended Tags if supported

Every PCIe device can generate 5-bit transaction Tags, which allow up to 32
concurrent requests.  Some devices can generate 8-bit Extended Tags, which
allow up to 256 concurrent requests.

Per the ECN mentioned below, all PCIe Receivers are expected to support
Extended Tags, so devices are allowed (but not required) to enable them by
default.

If a device supports Extended Tags but does not enable them by default,
enable them.  This allows the device to have up to 256 outstanding
transactions at a time, which may improve performance.

[bhelgaas: changelog, check for PCIe device]
Link: https://pcisig.com/sites/default/files/specification_documents/ECN_Extended_Tag_Enable_Default_05Sept2008_final.pdf
Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI/AER: Remove unused .link_reset() callback
Michael S. Tsirkin [Tue, 24 Jan 2017 17:35:56 +0000 (19:35 +0200)]
PCI/AER: Remove unused .link_reset() callback

No hardware seems to actually call .link_reset(), and no driver implements
it as more than a nop stub.

Drop mentions of the callback from everywhere.  It's dropped from the
documentation as well, but the doc really needs to be updated to reflect
reality better (e.g., on PCIe, slot reset is the link reset).  This will be
done in a later patch.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: generic: Call pci_fixup_irqs() only on ARM
Dongdong Liu [Thu, 12 Jan 2017 06:28:24 +0000 (14:28 +0800)]
PCI: generic: Call pci_fixup_irqs() only on ARM

pci_fixup_irqs() is problematic because:

  - it's called when we enumerate a host bridge, so we don't fixup IRQs for
    hot-added PCI devices, and

  - it fixes up IRQs for all PCI devices in the system, so if we call it
    multiple times, e.g., if we have several host controllers, we may
    reallocate an IRQ for a device after a driver has already claimed it.

We plan to replace pci_fixup_irqs() soon, but we still need it on ARM
because we don't have any other generic method for doing this.

On ARM64, we don't need pci_fixup_irqs() because we do IRQ setup when we
bind a driver to the device (in the pci_device_probe() ->
pcibios_alloc_irq() path).

pci-host-common.c is currently only used on ARM and ARM64.  In principle,
it could be used on x86, and we wouldn't want pci_fixup_irqs() there
either, because x86 does IRQ setup in the pci_enable_device() path.

[bhelgaas: changelog, use #ifdef ARM, not #ifndef ARM64]
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Gabriele Paoloni <gabriele.paoloni@huawei.com>
Reviewed-by: Zhou Wang <wangzhou1@hisilicon.com>
Acked-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
7 years agoPCI: Disable MSI for HiSilicon Hip06/Hip07 Root Ports
Dongdong Liu [Fri, 3 Feb 2017 21:02:07 +0000 (15:02 -0600)]
PCI: Disable MSI for HiSilicon Hip06/Hip07 Root Ports

The PCIe Root Port in Hip06/Hip07 SoCs advertises an MSI capability, but it
cannot generate MSIs.  It can transfer MSI/MSI-X from downstream devices,
but does not support MSI/MSI-X itself.

Add a quirk to prevent use of MSI/MSI-X by the Root Port.

[bhelgaas: changelog, sort vendor ID #define, drop device ID #define]
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Gabriele Paoloni <gabriele.paoloni@huawei.com>
Reviewed-by: Zhou Wang <wangzhou1@hisilicon.com>
7 years agoPCI: hisi: Rename config space accessors to remove "acpi"
Bjorn Helgaas [Tue, 7 Feb 2017 14:41:09 +0000 (08:41 -0600)]
PCI: hisi: Rename config space accessors to remove "acpi"

There's nothing ACPI-specific about the config space accessors
hisi_pcie_acpi_rd_conf() and hisi_pcie_acpi_wr_conf(), and they're used for
both the ACPI and the DT driver model.

Rename them to hisi_pcie_rd_conf() and hisi_pcie_wr_conf().  No functional
change intended.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: Add Broadcom Northstar2 PAXC quirk for device class and MPSS
Jon Mason [Fri, 27 Jan 2017 21:44:09 +0000 (16:44 -0500)]
PCI: Add Broadcom Northstar2 PAXC quirk for device class and MPSS

The Broadcom Northstar2 SoC has a number of quirks for the PAXC
(internal/fake) PCI bus.  Specifically, the PCI config space is shared
between the root port and the first PF (ie., PF0), and a number of fields
are tied to zero (thus preventing them from being set).  These cannot be
"fixed" in device firmware, so we must fix them with a quirk.

Signed-off-by: Jon Mason <jon.mason@broadcom.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: versatile: Configure PCIe MPS settings
Bjorn Helgaas [Wed, 8 Feb 2017 21:42:26 +0000 (15:42 -0600)]
PCI: versatile: Configure PCIe MPS settings

Make sure PCIe MPS settings are valid when we enumerate a new hierarchy.

Based-on-patch-by: Jon Mason <jon.mason@broadcom.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: xilinx: Configure PCIe MPS settings
Bjorn Helgaas [Wed, 8 Feb 2017 21:37:47 +0000 (15:37 -0600)]
PCI: xilinx: Configure PCIe MPS settings

Make sure PCIe MPS settings are valid when we enumerate a new hierarchy.

Based-on-patch-by: Jon Mason <jon.mason@broadcom.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: iproc: Configure PCIe MPS settings
Jon Mason [Fri, 27 Jan 2017 21:44:08 +0000 (16:44 -0500)]
PCI: iproc: Configure PCIe MPS settings

Make sure PCIe MPS settings are valid when we enumerate a new hierarchy.

[bhelgaas: changelog]
Signed-off-by: Jon Mason <jon.mason@broadcom.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Ray Jui <ray.jui@broadcom.com>
7 years agoPCI: exynos: Remove duplicated code
Jaehoon Chung [Mon, 16 Jan 2017 06:31:38 +0000 (15:31 +0900)]
PCI: exynos: Remove duplicated code

Remove duplicated register reads and writes.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Pankaj Dubey <pankaj.dubey@samsung.com>
Acked-by: Krzysztof Kozlowski <krzk@kernel.org>
Acked-by: Jingoo Han <jingoohan1@gmail.com>
7 years agoPCI: exynos: Use the bitops BIT() macro to build bitmasks
Jaehoon Chung [Mon, 16 Jan 2017 06:31:37 +0000 (15:31 +0900)]
PCI: exynos: Use the bitops BIT() macro to build bitmasks

Use the bitops BIT() macro to build bitmasks.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Pankaj Dubey <pankaj.dubey@samsung.com>
Acked-by: Krzysztof Kozlowski <krzk@kernel.org>
Acked-by: Jingoo Han <jingoohan1@gmail.com>
7 years agoPCI: exynos: Remove unnecessary local variables
Jaehoon Chung [Mon, 16 Jan 2017 06:31:36 +0000 (15:31 +0900)]
PCI: exynos: Remove unnecessary local variables

Remove unnecessary local variables: elbi_base, phy_base, block_base.  We
need one resource structure for assigning each resource.  Reuse the single
'res' variable for all.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Pankaj Dubey <pankaj.dubey@samsung.com>
Acked-by: Krzysztof Kozlowski <krzk@kernel.org>
Acked-by: Jingoo Han <jingoohan1@gmail.com>
7 years agoPCI: exynos: Replace the *_blk/*_phy/*_elb accessors
Jaehoon Chung [Mon, 16 Jan 2017 06:31:35 +0000 (15:31 +0900)]
PCI: exynos: Replace the *_blk/*_phy/*_elb accessors

There is no reason to maintain *_blk/phy/elbi_* as register accessors.
They can be replaced by one accessor to make maintenance easier.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Pankaj Dubey <pankaj.dubey@samsung.com>
Acked-by: Krzysztof Kozlowski <krzk@kernel.org>
Acked-by: Jingoo Han <jingoohan1@gmail.com>
7 years agoPCI: mvebu: Change delay after reset to the PCIe spec mandated 100ms
Lucas Stach [Thu, 2 Feb 2017 17:15:31 +0000 (18:15 +0100)]
PCI: mvebu: Change delay after reset to the PCIe spec mandated 100ms

The current default of 20ms cause some devices, which are slow to
initialize, to not show up during the bus scanning.  Change this to the
PCIe spec mandated 100ms and document this in the DT binding.

From PCIe base spec rev 3.0, chapter "6.6.1. Conventional Reset":

  To allow components to perform internal initialization, system software
  must wait a specified minimum period following the end of a Conventional
  Reset of one or more devices before it is permitted to issue
  Configuration Requests to those devices.

  With a Downstream Port that does not support Link speeds greater than 5.0
  GT/s, software must wait a minimum of 100 ms before sending a
  Configuration Request to the device immediately below that Port.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Jason Cooper <jason@lakedaemon.net>
7 years agoPCI: hisi: Add DT almost-ECAM support for Hip06/Hip07 host controllers
Dongdong Liu [Mon, 6 Feb 2017 06:25:04 +0000 (14:25 +0800)]
PCI: hisi: Add DT almost-ECAM support for Hip06/Hip07 host controllers

The PCIe controller in HiSilicon Hip06/Hip07 SoCs is not completely
ECAM-compliant.  It is non-ECAM only for the RC bus config space; for any
other bus underneath the root bus it does support ECAM access.

Add DT support for the almost-ECAM Hip06/Hip07 controllers.

[bhelgaas: drop dev->of_node test, driver name "hisi-pcie-almost-ecam"]
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Gabriele Paoloni <gabriele.paoloni@huawei.com>
Reviewed-by: Zhou Wang <wangzhou1@hisilicon.com>
7 years agoPCI: hisi: Use of_device_get_match_data() to simplify probe
Shailendra Verma [Tue, 31 Jan 2017 20:00:48 +0000 (14:00 -0600)]
PCI: hisi: Use of_device_get_match_data() to simplify probe

The only way to call hisi_pcie_probe() is to match an entry in
hisi_pcie_of_match[], so match cannot be NULL.

Use of_device_get_match_data() to retrieve the soc_ops pointer.  No
functional change intended.

[bhelgaas: use of_device_get_match_data(), changelog]
Based-on-suggestion-from: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: Lock each enable/disable num_vfs operation in sysfs
Emil Tantilov [Fri, 6 Jan 2017 21:59:08 +0000 (13:59 -0800)]
PCI: Lock each enable/disable num_vfs operation in sysfs

Enabling/disabling SRIOV via sysfs by echo-ing multiple values
simultaneously:

  # echo 63 > /sys/class/net/ethX/device/sriov_numvfs&
  # echo 63 > /sys/class/net/ethX/device/sriov_numvfs

  # sleep 5

  # echo 0 > /sys/class/net/ethX/device/sriov_numvfs&
  # echo 0 > /sys/class/net/ethX/device/sriov_numvfs

results in the following bug:

  kernel BUG at drivers/pci/iov.c:495!
  invalid opcode: 0000 [#1] SMP
  CPU: 1 PID: 8050 Comm: bash Tainted: G   W   4.9.0-rc7-net-next #2092
  RIP: 0010:[<ffffffff813b1647>]
    [<ffffffff813b1647>] pci_iov_release+0x57/0x60

  Call Trace:
   [<ffffffff81391726>] pci_release_dev+0x26/0x70
   [<ffffffff8155be6e>] device_release+0x3e/0xb0
   [<ffffffff81365ee7>] kobject_cleanup+0x67/0x180
   [<ffffffff81365d9d>] kobject_put+0x2d/0x60
   [<ffffffff8155bc27>] put_device+0x17/0x20
   [<ffffffff8139c08a>] pci_dev_put+0x1a/0x20
   [<ffffffff8139cb6b>] pci_get_dev_by_id+0x5b/0x90
   [<ffffffff8139cca5>] pci_get_subsys+0x35/0x40
   [<ffffffff8139ccc8>] pci_get_device+0x18/0x20
   [<ffffffff8139ccfb>] pci_get_domain_bus_and_slot+0x2b/0x60
   [<ffffffff813b09e7>] pci_iov_remove_virtfn+0x57/0x180
   [<ffffffff813b0b95>] pci_disable_sriov+0x65/0x140
   [<ffffffffa00a1af7>] ixgbe_disable_sriov+0xc7/0x1d0 [ixgbe]
   [<ffffffffa00a1e9d>] ixgbe_pci_sriov_configure+0x3d/0x170 [ixgbe]
   [<ffffffff8139d28c>] sriov_numvfs_store+0xdc/0x130
  ...
  RIP  [<ffffffff813b1647>] pci_iov_release+0x57/0x60

Use the existing mutex lock to protect each enable/disable operation.

Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
CC: Alexander Duyck <alexander.h.duyck@intel.com>
7 years agoPCI: Increase VPD access timeout to 125ms
Matthew R. Ochs [Tue, 29 Nov 2016 18:00:40 +0000 (12:00 -0600)]
PCI: Increase VPD access timeout to 125ms

The PCI core uses a fixed 50ms timeout when waiting for VPD accesses to
complete.  When an access does not complete within this period, a warning
is logged and an error returned to the caller.

While this default timeout is valid for most hardware, some devices can
experience longer access delays under certain circumstances.  For example,
one of the IBM CXL Flash devices can take up to ~120ms in a worst-case
scenario.  These types of devices can benefit from an extended timeout.

To support devices with a longer access delay, increase the timeout in
pci_vpd_wait() to 125ms.  The PCI specification is silent with respect to
VPD delays, therefore there is no concern for violating a threshold.

Tested-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Signed-off-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
7 years agoPCI: iproc: Use of_device_get_match_data() to simplify probe
Bjorn Helgaas [Tue, 31 Jan 2017 22:36:32 +0000 (16:36 -0600)]
PCI: iproc: Use of_device_get_match_data() to simplify probe

The only way to call iproc_pcie_pltfm_probe() is to match an entry in
iproc_pcie_of_match_table[], so match cannot be NULL.

Use of_device_get_match_data() to retrieve the pcie->type.  No functional
change intended.

Based-on-suggestion-from: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: layerscape: Use of_device_get_match_data() to simplify probe
Bjorn Helgaas [Tue, 31 Jan 2017 22:36:11 +0000 (16:36 -0600)]
PCI: layerscape: Use of_device_get_match_data() to simplify probe

The only way to call ls_pcie_probe() is to match an entry in
ls_pcie_of_match[], so match cannot be NULL.

Use of_device_get_match_data() to retrieve the drvdata pointer.  No
functional change intended.

Based-on-suggestion-from: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: rcar: Use of_device_get_match_data() to simplify probe
Bjorn Helgaas [Tue, 31 Jan 2017 22:35:42 +0000 (16:35 -0600)]
PCI: rcar: Use of_device_get_match_data() to simplify probe

This is a DT-only driver, so the only way to call rcar_pcie_probe() is to
match an entry in rcar_pcie_of_match[], so of_id cannot be NULL.

Furthermore, of_id->data can only be NULL if an rcar_pcie_of_match[] entry
has a NULL .data member.  That's a driver defect, and we don't want to
return -EINVAL, which is easy to ignore.  We'd rather take the NULL pointer
dereference so we notice the problem and fix it.

Use of_device_get_match_data() to retrieve the hw_init_fn pointer.  No
functional change intended.

Suggested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Simon Horman <horms+renesas@verge.net.au>
7 years agoPCI: xgene: Fix double free on init error
Dan Carpenter [Sat, 21 Jan 2017 04:49:49 +0000 (07:49 +0300)]
PCI: xgene: Fix double free on init error

The "port" variable was allocated with devm_kzalloc() so if we free it with
kfree() it will be freed twice.  Also I changed it to propogate the error
from devm_ioremap_resource() instead of returning -ENOMEM.

Fixes: c5d460396100 ("PCI: Add MCFG quirks for X-Gene host controller")
Also-posted-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Tanmay Inamdar <tinamdar@apm.com>
7 years agoPCI: imx6: Remove LTSSM disable workaround
Lucas Stach [Fri, 20 Jan 2017 15:58:37 +0000 (16:58 +0100)]
PCI: imx6: Remove LTSSM disable workaround

This causes CPU hangs when the system is reset by the watchdog, as the GPRs
aren't cleared, but the clocks are back to disabled state.

If the bootloader uses PCIe, it must take care to bring it down into a safe
state, before passing control to the Linux kernel.  This is the only way to
get a properly operating system at all times and circumstances.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: Avoid possible deadlock on pci_lock and p->pi_lock
Bjorn Helgaas [Sat, 14 Jan 2017 00:05:12 +0000 (18:05 -0600)]
PCI: Avoid possible deadlock on pci_lock and p->pi_lock

pci_lock is an IRQ-safe spinlock that protects all accesses to PCI
configuration space (see PCI_OP_READ() and PCI_OP_WRITE() in pci/access.c).

The pci_cfg_access_unlock() path acquires pci_lock, then p->pi_lock (inside
wake_up_all()).  According to lockdep, there is a possible path involving
snbep_uncore_pci_read_counter() that could acquire them in the reverse
order: acquiring p->pi_lock, then pci_lock, which could result in a
deadlock.  Lockdep details are in the bugzilla below.

Avoid the possible deadlock by dropping pci_lock before waking up any
config access waiters.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=192901
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: rockchip: Mark PM functions as __maybe_unused
Arnd Bergmann [Fri, 20 Jan 2017 16:24:30 +0000 (17:24 +0100)]
PCI: rockchip: Mark PM functions as __maybe_unused

When CONFIG_PM_SLEEP is disabled, we get harmless build warnings:

  host/pcie-rockchip.c:1267:12: error: 'rockchip_pcie_resume_noirq' defined but not used [-Werror=unused-function]
  host/pcie-rockchip.c:1240:12: error: 'rockchip_pcie_suspend_noirq' defined but not used [-Werror=unused-function]

Marking both functions as __maybe_unused avoids the warning without the
need for #ifdef around them.

Fixes: 013dd3d5e183 ("PCI: rockchip: Add system PM support")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Shawn Lin <shawn.lin@rock-chips.com>
7 years agoPCI: rockchip: Use readl_poll_timeout() instead of open-coding it
Shawn Lin [Wed, 18 Jan 2017 08:29:15 +0000 (16:29 +0800)]
PCI: rockchip: Use readl_poll_timeout() instead of open-coding it

Use readl_poll_timeout() instead of open-coding it.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: mvebu: Handle changes to the bridge windows while enabled
Jason Gunthorpe [Mon, 12 Dec 2016 18:30:20 +0000 (11:30 -0700)]
PCI: mvebu: Handle changes to the bridge windows while enabled

The PCI core will write to the bridge window config multiple times while
they are enabled.  This can lead to mbus failures like this:

 mvebu_mbus: cannot add window '4:e8', conflicts with another window
 mvebu-pcie mbus:pex@e0000000: Could not create MBus window at [mem 0xe0000000-0xe00fffff]: -22

For me this is happening during a hotplug cycle.  The PCI core is not
changing the values, just writing them twice while active.

The patch addresses the general case of any change to an active window, but
not atomically.  The code is slightly refactored so io and mem can share
more of the window logic.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Jason Cooper <jason@lakedaemon.net>
7 years agoPCI: exynos: Rename all pointer names from "exynos_pcie" to "ep"
Jaehoon Chung [Mon, 16 Jan 2017 06:31:34 +0000 (15:31 +0900)]
PCI: exynos: Rename all pointer names from "exynos_pcie" to "ep"

Rename the simple pointer name as "ep" instead of "exynos_pcie".  After
applying this patch, it can save the 10 characthers within one line.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Pankaj Dubey <pankaj.dubey@samsung.com>
Acked-by: Krzysztof Kozlowski <krzk@kernel.org>
Acked-by: Jingoo Han <jingoohan1@gmail.com>
7 years agoPCI: Add ACS quirk for Intel Union Point
Alex Williamson [Thu, 19 Jan 2017 15:51:30 +0000 (08:51 -0700)]
PCI: Add ACS quirk for Intel Union Point

Intel 200-series chipsets have the same errata as 100-series: the ACS
capability doesn't follow the PCIe spec, the capability and control
registers are dwords rather than words.  Add PCIe root port device IDs to
existing quirk.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>