]> git.karo-electronics.de Git - linux-beck.git/log
linux-beck.git
8 years agoMerge branch 'pci/resource' into next
Bjorn Helgaas [Tue, 15 Mar 2016 13:56:28 +0000 (08:56 -0500)]
Merge branch 'pci/resource' into next

* pci/resource:
  PCI: Simplify pci_create_attr() control flow
  PCI: Don't leak memory if sysfs_create_bin_file() fails
  PCI: Simplify sysfs ROM cleanup
  PCI: Remove unused IORESOURCE_ROM_COPY and IORESOURCE_ROM_BIOS_COPY
  MIPS: Loongson 3: Keep CPU physical (not virtual) addresses in shadow ROM resource
  MIPS: Loongson 3: Use temporary struct resource * to avoid repetition
  ia64/PCI: Keep CPU physical (not virtual) addresses in shadow ROM resource
  ia64/PCI: Use ioremap() instead of open-coded equivalent
  ia64/PCI: Use temporary struct resource * to avoid repetition
  PCI: Clean up pci_map_rom() whitespace
  PCI: Remove arch-specific IORESOURCE_ROM_SHADOW size from sysfs
  PCI: Set ROM shadow location in arch code, not in PCI core
  PCI: Don't enable/disable ROM BAR if we're using a RAM shadow copy
  PCI: Don't assign or reassign immutable resources
  PCI: Mark shadow copy of VGA ROM as IORESOURCE_PCI_FIXED
  x86/PCI: Mark Broadwell-EP Home Agent & PCU as having non-compliant BARs
  PCI: Disable IO/MEM decoding for devices with non-compliant BARs

8 years agoMerge branch 'pci/host-hv' into next
Bjorn Helgaas [Tue, 15 Mar 2016 13:56:16 +0000 (08:56 -0500)]
Merge branch 'pci/host-hv' into next

* pci/host-hv:
  PCI: hv: Add paravirtual PCI front-end for Microsoft Hyper-V VMs
  PCI: Look up IRQ domain by fwnode_handle
  PCI: Add fwnode_handle to x86 pci_sysdata

8 years agoMerge branch 'pci/host-designware' into next
Bjorn Helgaas [Tue, 15 Mar 2016 13:55:52 +0000 (08:55 -0500)]
Merge branch 'pci/host-designware' into next

* pci/host-designware:
  PCI: designware: Add driver for prototyping kits based on ARC SDP
  PCI: designware: Add default link up check if sub-driver doesn't override
  PCI: designware: Add generic dw_pcie_wait_for_link()
  ARC: Add PCI support

8 years agoMerge branches 'pci/host-altera', 'pci/host-imx6', 'pci/host-keystone', 'pci/host...
Bjorn Helgaas [Tue, 15 Mar 2016 13:55:19 +0000 (08:55 -0500)]
Merge branches 'pci/host-altera', 'pci/host-imx6', 'pci/host-keystone', 'pci/host-rcar', 'pci/host-tegra', 'pci/host-thunder', 'pci/host-vmd', 'pci/host-xilinx' and 'pci/host-xilinx-nwl' into next

* pci/host-altera:
  PCI: altera: Fix altera_pcie_link_is_up()

* pci/host-imx6:
  PCI: imx6: Add DT bindings to configure PHY Tx driver settings

* pci/host-keystone:
  PCI: keystone: Defer probing if devm_phy_get() returns -EPROBE_DEFER

* pci/host-rcar:
  PCI: rcar: Depend on ARCH_RENESAS, not ARCH_SHMOBILE

* pci/host-tegra:
  PCI: tegra: Remove misleading PHYS_OFFSET
  PCI: tegra: Track bus -> CPU mapping
  PCI: tegra: Remove unused struct tegra_pcie.num_ports field
  PCI: tegra: Implement ->{add,remove}_bus() callbacks
  PCI: Add pci_ops.{add,remove}_bus() callbacks

* pci/host-thunder:
  PCI: thunder: Add driver for ThunderX-pass{1,2} on-chip devices
  PCI: thunder: Add PCIe host driver for ThunderX processors
  PCI: generic: Expose pci_host_common_probe() for use by other drivers
  PCI: generic: Add pci_host_common_probe(), based on gen_pci_probe()
  PCI: generic: Move structure definitions to separate header file

* pci/host-vmd:
  x86/PCI: VMD: Attach VMD resources to parent domain's resource tree
  x86/PCI: VMD: Set bus resource start to 0
  x86/PCI: VMD: Document code for maintainability

* pci/host-xilinx:
  microblaze/PCI: Support generic Xilinx AXI PCIe Host Bridge IP driver
  PCI: xilinx: Update Zynq binding with Microblaze node
  PCI: xilinx: Don't call pci_fixup_irqs() on Microblaze
  PCI: xilinx: Remove dependency on ARM-specific struct hw_pci
  PCI: xilinx: Use of_pci_get_host_bridge_resources() to parse DT

* pci/host-xilinx-nwl:
  PCI: xilinx-nwl: Add support for Xilinx NWL PCIe Host Controller

8 years agoMerge branches 'pci/aer', 'pci/enumeration', 'pci/kconfig', 'pci/misc', 'pci/virtuali...
Bjorn Helgaas [Tue, 15 Mar 2016 13:55:02 +0000 (08:55 -0500)]
Merge branches 'pci/aer', 'pci/enumeration', 'pci/kconfig', 'pci/misc', 'pci/virtualization' and 'pci/vpd' into next

* pci/aer:
  PCI/AER: Log aer_inject error injections
  PCI/AER: Log actual error causes in aer_inject
  PCI/AER: Use dev_warn() in aer_inject
  PCI/AER: Fix aer_inject error codes

* pci/enumeration:
  PCI: Fix broken URL for Dell biosdevname

* pci/kconfig:
  PCI: Cleanup pci/pcie/Kconfig whitespace
  PCI: Include pci/hotplug Kconfig directly from pci/Kconfig
  PCI: Include pci/pcie/Kconfig directly from pci/Kconfig

* pci/misc:
  PCI: Add PCI_CLASS_SERIAL_USB_DEVICE definition
  PCI: Add QEMU top-level IDs for (sub)vendor & device
  unicore32: Remove unused HAVE_ARCH_PCI_SET_DMA_MASK definition
  PCI: Consolidate PCI DMA constants and interfaces in linux/pci-dma-compat.h
  PCI: Move pci_dma_* helpers to common code
  frv/PCI: Remove stray pci_{alloc,free}_consistent() declaration

* pci/virtualization:
  PCI: Wait for up to 1000ms after FLR reset
  PCI: Support SR-IOV on any function type

* pci/vpd:
  PCI: Prevent VPD access for buggy devices
  PCI: Sleep rather than busy-wait for VPD access completion
  PCI: Fold struct pci_vpd_pci22 into struct pci_vpd
  PCI: Rename VPD symbols to remove unnecessary "pci22"
  PCI: Remove struct pci_vpd_ops.release function pointer
  PCI: Move pci_vpd_release() from header file to pci/access.c
  PCI: Move pci_read_vpd() and pci_write_vpd() close to other VPD code
  PCI: Determine actual VPD size on first access
  PCI: Use bitfield instead of bool for struct pci_vpd_pci22.busy
  PCI: Allow access to VPD attributes with size 0
  PCI: Update VPD definitions

8 years agoPCI: Add PCI_CLASS_SERIAL_USB_DEVICE definition
Heikki Krogerus [Tue, 15 Mar 2016 12:06:00 +0000 (14:06 +0200)]
PCI: Add PCI_CLASS_SERIAL_USB_DEVICE definition

PCI-SIG has defined Interface FEh for Base Class 0Ch, Sub-Class 03h as "USB
Device (not host controller)".  It is already being used in various USB
device controller drivers for matching, so add PCI_CLASS_SERIAL_USB_DEVICE
and use it.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: designware: Add driver for prototyping kits based on ARC SDP
Joao Pinto [Thu, 10 Mar 2016 20:44:52 +0000 (14:44 -0600)]
PCI: designware: Add driver for prototyping kits based on ARC SDP

Add a reference platform driver for PCI RC IP Protoyping Kits based on the
ARC SDP.

[bhelgaas: changelog, split patch up, MAINTAINERS update]
Signed-off-by: Joao Pinto <jpinto@synopsys.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Pratyush Anand <pratyush.anand@gmail.com>
8 years agoPCI: designware: Add default link up check if sub-driver doesn't override
Joao Pinto [Thu, 10 Mar 2016 20:44:44 +0000 (14:44 -0600)]
PCI: designware: Add default link up check if sub-driver doesn't override

Add a default DesignWare "link_up" test for use when a sub-driver doesn't
supply its own pcie_host_ops.link_up() method.

[bhelgaas: changelog, split into its own patch]
Signed-off-by: Joao Pinto <jpinto@synopsys.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Pratyush Anand <pratyush.anand@gmail.com>
8 years agoPCI: designware: Add generic dw_pcie_wait_for_link()
Joao Pinto [Thu, 10 Mar 2016 20:44:35 +0000 (14:44 -0600)]
PCI: designware: Add generic dw_pcie_wait_for_link()

Several DesignWare-based drivers (dra7xx, exynos, imx6, keystone, qcom, and
spear13xx) had similar loops waiting for the link to come up.

Add a generic dw_pcie_wait_for_link() for use by all these drivers so the
waiting is done consistently, e.g., always using usleep_range() rather than
mdelay() and using similar timeouts and retry counts.

Note that this changes the Keystone link training/wait for link strategy,
so we initiate link training, then wait longer for the link to come up
before re-initiating link training.

[bhelgaas: changelog, split into its own patch, update pci-keystone.c, pcie-qcom.c]
Signed-off-by: Joao Pinto <jpinto@synopsys.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Pratyush Anand <pratyush.anand@gmail.com>
8 years agoPCI: Cleanup pci/pcie/Kconfig whitespace
Andreas Ziegler [Tue, 15 Mar 2016 11:28:32 +0000 (12:28 +0100)]
PCI: Cleanup pci/pcie/Kconfig whitespace

Clean up style issues in drivers/pci/pcie/Kconfig, in particular all
indentation is now done using tabs, not spaces, and the definition of
PCIEASPM_DEBUG is now separated from the definition of PCIEASPM with a
newline.

Signed-off-by: Andreas Ziegler <andreas.ziegler@fau.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: Simplify pci_create_attr() control flow
Bjorn Helgaas [Thu, 10 Mar 2016 20:36:34 +0000 (14:36 -0600)]
PCI: Simplify pci_create_attr() control flow

Return error immediately to simplify the control flow in pci_create_attr().
No functional change intended.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: Don't leak memory if sysfs_create_bin_file() fails
Bjorn Helgaas [Thu, 10 Mar 2016 20:36:28 +0000 (14:36 -0600)]
PCI: Don't leak memory if sysfs_create_bin_file() fails

If sysfs_create_bin_file() fails, pci_create_attr() leaks the struct
bin_attribute it allocated previously.

Free the struct bin_attribute if pci_create_attr() fails.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: Simplify sysfs ROM cleanup
Bjorn Helgaas [Tue, 1 Mar 2016 15:37:10 +0000 (09:37 -0600)]
PCI: Simplify sysfs ROM cleanup

The value of pdev->rom_attr is the definitive indicator of the fact that
we're created a sysfs attribute.  Check that rather than rom_size, which is
only used incidentally when deciding whether to create a sysfs attribute.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: Remove unused IORESOURCE_ROM_COPY and IORESOURCE_ROM_BIOS_COPY
Bjorn Helgaas [Thu, 3 Mar 2016 03:46:50 +0000 (21:46 -0600)]
PCI: Remove unused IORESOURCE_ROM_COPY and IORESOURCE_ROM_BIOS_COPY

The IORESOURCE_ROM_COPY and IORESOURCE_ROM_BIOS_COPY bits are unused.
Remove them and code that depends on them.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoMIPS: Loongson 3: Keep CPU physical (not virtual) addresses in shadow ROM resource
Bjorn Helgaas [Thu, 3 Mar 2016 03:42:04 +0000 (21:42 -0600)]
MIPS: Loongson 3: Keep CPU physical (not virtual) addresses in shadow ROM resource

Loongson 3 used the IORESOURCE_ROM_COPY flag for its ROM resource.  There
are two problems with this:

  - When IORESOURCE_ROM_COPY is set, pci_map_rom() assumes the resource
    contains virtual addresses, so it doesn't ioremap the resource.  This
    implies loongson_sysconf.vgabios_addr is a virtual address.  That's a
    problem because resources should contain CPU *physical* addresses not
    virtual addresses.

  - When IORESOURCE_ROM_COPY is set, pci_cleanup_rom() calls kfree() on the
    resource.  We did not kmalloc() the loongson_sysconf.vgabios_addr area,
    so it is incorrect to kfree() it.

If we're using a shadow copy in RAM for the Loongson 3 VGA BIOS area,
disable the ROM BAR and release the address space it was consuming.

Use IORESOURCE_ROM_SHADOW instead of IORESOURCE_ROM_COPY.  This means the
struct resource contains CPU physical addresses, and pci_map_rom() will
ioremap() it as needed.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoMIPS: Loongson 3: Use temporary struct resource * to avoid repetition
Bjorn Helgaas [Thu, 3 Mar 2016 03:38:29 +0000 (21:38 -0600)]
MIPS: Loongson 3: Use temporary struct resource * to avoid repetition

Use a temporary struct resource pointer to avoid needless repetition of
"pdev->resource[PCI_ROM_RESOURCE]".  No functional change intended.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoia64/PCI: Keep CPU physical (not virtual) addresses in shadow ROM resource
Bjorn Helgaas [Wed, 2 Mar 2016 22:06:32 +0000 (16:06 -0600)]
ia64/PCI: Keep CPU physical (not virtual) addresses in shadow ROM resource

A struct resource contains CPU physical addresses, not virtual addresses.
But sn_acpi_slot_fixup() and sn_io_slot_fixup() stored the virtual address
of a shadow ROM copy in the resource.  To compensate, pci_map_rom() had a
special case that returned the resource address directly rather than
calling ioremap() on it.

When we're using a shadow copy in RAM or PROM, disable the ROM BAR and
release the address space it was consuming.

Store the CPU physical (not virtual) address in the shadow ROM resource,
and mark the resource as IORESOURCE_ROM_SHADOW so we use the normal
pci_map_rom() path that ioremaps the copy.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoia64/PCI: Use ioremap() instead of open-coded equivalent
Bjorn Helgaas [Wed, 2 Mar 2016 22:20:18 +0000 (16:20 -0600)]
ia64/PCI: Use ioremap() instead of open-coded equivalent

Depositing __IA64_UNCACHED_OFFSET in the upper address bits is essentially
equivalent to ioremap(): it converts a CPU physical address to a virtual
address using the ia64 uncacheable identity map.

Call ioremap() instead of doing the phys-to-virt conversion manually with
__IA64_UNCACHED_OFFSET.

Note that this makes it obvious that (a) we're putting a virtual address in
a struct resource, and (b) we're passing a virtual address to ioremap()
below in the PCI_ROM_RESOURCE case.  These are both pre-existing problems
that I'll resolve next.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoia64/PCI: Use temporary struct resource * to avoid repetition
Bjorn Helgaas [Wed, 2 Mar 2016 22:16:03 +0000 (16:16 -0600)]
ia64/PCI: Use temporary struct resource * to avoid repetition

Use a temporary struct resource pointer to avoid needless repetition of
"dev->resource[idx]".  No functional change intended.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: Clean up pci_map_rom() whitespace
Bjorn Helgaas [Tue, 1 Mar 2016 17:13:30 +0000 (11:13 -0600)]
PCI: Clean up pci_map_rom() whitespace

Remove unnecessary indentation in pci_map_rom().  This is logically part of
the previous patch; I split it out to make the critical changes in that
patch more obvious.  No functional change intended.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: Remove arch-specific IORESOURCE_ROM_SHADOW size from sysfs
Bjorn Helgaas [Sat, 12 Mar 2016 11:48:08 +0000 (05:48 -0600)]
PCI: Remove arch-specific IORESOURCE_ROM_SHADOW size from sysfs

When pci_create_sysfs_dev_files() created the "rom" sysfs file, it set the
sysfs file size to the actual size of a ROM BAR, or if there was no ROM BAR
but the platform provided a shadow copy in RAM, to 0x20000.  0x20000 is an
arch-specific length that should not be baked into the PCI core.

Every place that sets IORESOURCE_ROM_SHADOW also sets the size of the
PCI_ROM_RESOURCE, so use the resource length always.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: thunder: Add driver for ThunderX-pass{1,2} on-chip devices
David Daney [Fri, 4 Mar 2016 22:31:48 +0000 (14:31 -0800)]
PCI: thunder: Add driver for ThunderX-pass{1,2} on-chip devices

The cavium,pci-thunder-ecam devices are exactly ECAM-based PCI root
complexes.  These root complexes (loosely referred to as ECAM units in the
hardware manuals) are used to access the Thunder on-chip devices.  They
are special in that all the BARs on devices behind these root complexes are
at fixed addresses.

Add a driver for these devices that synthesizes Enhanced Allocation (EA)
capability entries for each BAR.

Since this EA synthesis is needed for exactly two chip models, we can hard-
code some assumptions about the device topology and the layout of the
config space of specific DEVFNs in the driver.

[bhelgaas: changelog, whitespace]
Signed-off-by: David Daney <david.daney@cavium.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rob Herring <robh@kernel.org>
8 years agoPCI: thunder: Add PCIe host driver for ThunderX processors
David Daney [Fri, 4 Mar 2016 22:31:47 +0000 (14:31 -0800)]
PCI: thunder: Add PCIe host driver for ThunderX processors

The root complexes used to access off-chip PCIe devices (called PEM units
in the hardware manuals) on some Cavium ThunderX processors require quirky
access methods for the config space of the PCIe bridge.

Add a driver to provide these config space accessor functions.  Use the
pci-host-common code to configure the PCI machinery.

Signed-off-by: David Daney <david.daney@cavium.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rob Herring <robh@kernel.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
8 years agoPCI: generic: Expose pci_host_common_probe() for use by other drivers
David Daney [Fri, 11 Mar 2016 21:35:55 +0000 (15:35 -0600)]
PCI: generic: Expose pci_host_common_probe() for use by other drivers

Move pci_host_common_probe() and associated functions to pci-host-common.c,
where it can be shared with other drivers.  Make it public (not static)
and update Kconfig and Makefile to build it.  No functional change
intended.

[bhelgaas: split into separate patch, changelog]
Signed-off-by: David Daney <david.daney@cavium.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Will Deacon <will.deacon@arm.com>
8 years agoPCI: generic: Add pci_host_common_probe(), based on gen_pci_probe()
David Daney [Fri, 11 Mar 2016 21:25:13 +0000 (15:25 -0600)]
PCI: generic: Add pci_host_common_probe(), based on gen_pci_probe()

Factor gen_pci_probe(), moving most of it into pci_host_common_probe()
where it can be shared with other drivers that have slightly different
config accessors.  No functional change intended.

[bhelgaas: split into separate patch, changelog]
Signed-off-by: David Daney <david.daney@cavium.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Will Deacon <will.deacon@arm.com>
8 years agoPCI: generic: Move structure definitions to separate header file
David Daney [Fri, 11 Mar 2016 21:18:38 +0000 (15:18 -0600)]
PCI: generic: Move structure definitions to separate header file

Move definitions for generic PCI host controller driver structures to a
separate header file so we can share them with other drivers.  No
functional change intended.

[bhelgaas: split into separate patch, changelog]
Signed-off-by: David Daney <david.daney@cavium.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Will Deacon <will.deacon@arm.com>
8 years agoPCI: xilinx-nwl: Add support for Xilinx NWL PCIe Host Controller
Bharat Kumar Gogada [Sun, 6 Mar 2016 16:32:14 +0000 (22:02 +0530)]
PCI: xilinx-nwl: Add support for Xilinx NWL PCIe Host Controller

Add PCIe Root Port driver for Xilinx PCIe NWL bridge IP.

[bhelgaas: wait for link like dw_pcie_wait_for_link(), simplify bitmap
error path, typos, whitespace, fold in Dan Carpenter's PTR_ERR() fix]
Signed-off-by: Bharat Kumar Gogada <bharatku@xilinx.com>
Signed-off-by: Ravi Kiran Gummaluri <rgummal@xilinx.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
Acked-by: Rob Herring <robh@kernel.org>
8 years agoPCI: keystone: Defer probing if devm_phy_get() returns -EPROBE_DEFER
Shawn Lin [Mon, 7 Mar 2016 04:32:21 +0000 (12:32 +0800)]
PCI: keystone: Defer probing if devm_phy_get() returns -EPROBE_DEFER

A SerDes PHY is optional, so if devm_phy_get() doesn't find one at all,
that's fine.  But if devm_phy_get() finds a PHY that doesn't have a driver
yet, it returns -EPROBE_DEFER.  In that case, defer probing the Keystone
driver.  We may be able to load it later after a PHY driver is loaded.

[bhelgaas: changelog, check for -EPROBE_DEFER first]
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: altera: Fix altera_pcie_link_is_up()
Ley Foon Tan [Wed, 2 Mar 2016 09:43:07 +0000 (17:43 +0800)]
PCI: altera: Fix altera_pcie_link_is_up()

Originally altera_pcie_link_is_up() decided the link was up if any of the
low four bits of the LTSSM register were set.  But the link is only up if
the LTSSM state is L0, so check for that exact value.

[bhelgaas: changelog]
Signed-off-by: Ley Foon Tan <lftan@altera.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: rcar: Depend on ARCH_RENESAS, not ARCH_SHMOBILE
Simon Horman [Thu, 25 Feb 2016 00:45:56 +0000 (09:45 +0900)]
PCI: rcar: Depend on ARCH_RENESAS, not ARCH_SHMOBILE

Make the R-Car drivers depend on ARCH_RENESAS instead of ARCH_SHMOBILE.

This is part of an ongoing process to migrate from ARCH_SHMOBILE to
ARCH_RENESAS.  The motivation is that RENESAS seems to be a more
appropriate name than SHMOBILE for the majority of Renesas ARM-based SoCs.

Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Geert Uytterhoeven <geert+renesas@glider.be>
8 years agox86/PCI: VMD: Attach VMD resources to parent domain's resource tree
Jon Derrick [Wed, 24 Feb 2016 17:06:37 +0000 (10:06 -0700)]
x86/PCI: VMD: Attach VMD resources to parent domain's resource tree

Attach the new VMD domain's resources to the VMD device's resources.  This
allows /proc/iomem to display a more complete picture.

Before:
  c0000000-c1ffffff : 0000:5d:05.5
  c2000000-c3ffffff : 0000:5d:05.5
    c2010000-c2013fff : nvme
  c4000000-c40fffff : 0000:5d:05.5

After:
  c0000000-c1ffffff : 0000:5d:05.5
  c2000000-c3ffffff : 0000:5d:05.5
    c2000000-c3ffffff : VMD MEMBAR1
      c2000000-c22fffff : PCI Bus 10000:01
        c2000000-c200ffff : 10000:01:00.0
        c2010000-c2013fff : 10000:01:00.0
          c2010000-c2013fff : nvme
      c2300000-c24fffff : PCI Bus 10000:01
  c4000000-c40fffff : 0000:5d:05.5
    c4002000-c40fffff : VMD MEMBAR2

Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Keith Busch <keith.busch@intel.com>
8 years agox86/PCI: VMD: Set bus resource start to 0
Keith Busch [Wed, 2 Mar 2016 22:31:04 +0000 (15:31 -0700)]
x86/PCI: VMD: Set bus resource start to 0

The bus always starts at 0.  Due to alignment and down-casting, this
happened to work before, but looked alarmingly incorrect in kernel logs.

Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agox86/PCI: VMD: Document code for maintainability
Keith Busch [Wed, 2 Mar 2016 22:31:03 +0000 (15:31 -0700)]
x86/PCI: VMD: Document code for maintainability

Comment the less obvious portion of the code for setting up memory windows,
and the platform dependency for initializing the h/w with appropriate
resources.

Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: Wait for up to 1000ms after FLR reset
Alex Williamson [Mon, 22 Feb 2016 20:05:48 +0000 (13:05 -0700)]
PCI: Wait for up to 1000ms after FLR reset

Some devices take longer than the spec indicates to return from FLR reset,
a notable case of this is Intel integrated graphics (IGD), which can often
take an additional 300ms powering down an attached LCD panel as part of the
FLR.  Allow devices up to 1000ms, testing every 100ms whether the second
dword of config space is read as -1.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoARC: Add PCI support
Joao Pinto [Thu, 10 Mar 2016 20:44:13 +0000 (14:44 -0600)]
ARC: Add PCI support

Add PCI support to ARC and update drivers/pci Makefile enabling the ARC
arch to use the generic PCI setup functions.

[bhelgaas: fold in Joao's pci-dma-compat.h & pci-bridge.h build fix (I
should have caught this myself, sorry]
Signed-off-by: Joao Pinto <jpinto@synopsys.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Vineet Gupta <vgupta@synopsys.com>
8 years agoPCI: Prevent VPD access for buggy devices
Babu Moger [Mon, 15 Feb 2016 08:42:02 +0000 (09:42 +0100)]
PCI: Prevent VPD access for buggy devices

On some devices, reading or writing VPD causes a system panic.
This can be easily reproduced by running "lspci -vvv" or
"cat /sys/bus/devices/XX../vpd".

Blacklist these devices so we don't access VPD data at all.

[bhelgaas: changelog, comment, drop pci/access.c changes]
Link: https://bugzilla.kernel.org/show_bug.cgi?id=110681
Tested-by: Shane Seymour <shane.seymour@hpe.com>
Tested-by: Babu Moger <babu.moger@oracle.com>
Signed-off-by: Babu Moger <babu.moger@oracle.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Alexander Duyck <alexander.duyck@gmail.com>
8 years agoPCI: Sleep rather than busy-wait for VPD access completion
Bjorn Helgaas [Mon, 22 Feb 2016 20:58:18 +0000 (14:58 -0600)]
PCI: Sleep rather than busy-wait for VPD access completion

Use usleep_range() instead of udelay() while waiting for a VPD access to
complete.  This is not a performance path, so no need to hog the CPU.

Rationale for usleep_range() parameters:

  We clear PCI_VPD_ADDR_F for a read (or set it for a write), then wait for
  the device to change it.  For a device that updates PCI_VPD_ADDR between
  our config write and subsequent config read, we won't sleep at all and
  can get the device's maximum rate.

  Sleeping a minimum of 10 usec per 4-byte access limits throughput to
  about 400Kbytes/second.  VPD is small (32K bytes at most), and most
  devices use only a fraction of that.

  We back off exponentially up to 1024 usec per iteration.  If we reach
  1024, we've already waited up to 1008 usec (16 + 32 + ... + 512), so if
  we miss an update and wait an extra 1024 usec, we can still get about
  1/2 of the device's maximum rate.

Tested-by: Shane Seymour <shane.seymour@hpe.com>
Tested-by: Babu Moger <babu.moger@oracle.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
8 years agoPCI: Add QEMU top-level IDs for (sub)vendor & device
Robin H. Johnson [Sun, 6 Mar 2016 22:02:30 +0000 (22:02 +0000)]
PCI: Add QEMU top-level IDs for (sub)vendor & device

Introduce PCI_VENDOR/PCI_SUBVENDOR/PCI_SUBDEVICE defines to replace the
constants scattered in the kernel already used to detect QEMU.

They are defined in the QEMU codebase per docs/specs/pci-ids.txt.

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
8 years agoPCI/AER: Log aer_inject error injections
Jean Delvare [Thu, 18 Feb 2016 12:54:02 +0000 (13:54 +0100)]
PCI/AER: Log aer_inject error injections

Log successful error injections so that injected errors can be
differentiated from real errors.

Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Borislav Petkov <bp@suse.de>
8 years agoPCI/AER: Log actual error causes in aer_inject
Jean Delvare [Thu, 18 Feb 2016 12:52:46 +0000 (13:52 +0100)]
PCI/AER: Log actual error causes in aer_inject

The aer_inject driver is very quiet.  In most cases, it merely returns an
error code to user-space, leaving the user with little clue about the
actual reason for the failure.

So, log error messages for 4 of the most frequent causes of failure:
* Can't find the root port of the specified device.
* Device doesn't support AER.
* Root port doesn't support AER.
* AER device not found.

This gives the user a chance to understand why aer-inject failed.

Based on a preliminary patch by Thomas Renninger.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Borislav Petkov <bp@suse.de>
CC: Thomas Renninger <trenn@suse.de>
8 years agoPCI/AER: Use dev_warn() in aer_inject
Jean Delvare [Thu, 18 Feb 2016 12:52:01 +0000 (13:52 +0100)]
PCI/AER: Use dev_warn() in aer_inject

dev_warn() is better than printk(LOG_WARNING...) as it records which device
the message relates to.  Also add a prefix "aer_inject:" to help
differentiate real errors from injected errors.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Borislav Petkov <bp@suse.de>
8 years agoPCI/AER: Fix aer_inject error codes
Jean Delvare [Thu, 18 Feb 2016 12:50:45 +0000 (13:50 +0100)]
PCI/AER: Fix aer_inject error codes

EPERM means "Operation not permitted", which doesn't reflect the lack of
support for AER.  EPROTONOSUPPORT (Protocol not supported) is a better
choice of error code if the device or its root port lack support for AER.

Likewise, EINVAL means "Invalid argument", which is not suitable for cases
where the AER error device is missing or unusable.  ENODEV and
EPROTONOSUPPORT, respectively, fit better.

Suggested-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Borislav Petkov <bp@suse.de>
CC: Prarit Bhargava <prarit@redhat.com>
8 years agoPCI: tegra: Remove misleading PHYS_OFFSET
Thierry Reding [Tue, 9 Feb 2016 14:52:33 +0000 (15:52 +0100)]
PCI: tegra: Remove misleading PHYS_OFFSET

BARs are disabled when the size register is 0, so it's misleading to write
a base address into the start register.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: tegra: Track bus -> CPU mapping
Thierry Reding [Tue, 9 Feb 2016 14:52:32 +0000 (15:52 +0100)]
PCI: tegra: Track bus -> CPU mapping

Track the offsets of the bus -> CPU mapping for I/O and memory.  This is
cosmetic for current Tegra chips because the offset is always 0.  But to
properly support legacy use-cases, like VGA, this would be needed so that
PCI bus addresses can be relocated.

While at it, also request the I/O resource both in physical memory and I/O
space to make /proc/iomem consistent, as well as add the I/O region to the
list of host bridge resources.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: tegra: Remove unused struct tegra_pcie.num_ports field
Thierry Reding [Tue, 9 Feb 2016 14:52:31 +0000 (15:52 +0100)]
PCI: tegra: Remove unused struct tegra_pcie.num_ports field

The num_ports field of the tegra_pcie structure is never used so remove it.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: tegra: Implement ->{add,remove}_bus() callbacks
Thierry Reding [Tue, 9 Feb 2016 14:30:48 +0000 (15:30 +0100)]
PCI: tegra: Implement ->{add,remove}_bus() callbacks

The configuration space mapping on Tegra is somewhat special, and in order
to avoid wasting virtual address space the configuration space for each bus
needs to be stitched together from several blocks which form a single
continuous virtual address range for accessors.

Currently the configuration space is mapped upon the first access to one of
its registers.  However, the mapping operation may sleep under certain
circumstances, so doing it from the configuration space accessors (they are
protected by a spin lock) will trigger a warning.

To avoid the warning, use the ->add_bus() callback to perform the mapping
at enumeration time when the operation is allowed to sleep.  Also add an
implementation of ->remove_bus() that undoes the mapping established by the
->add_bus() callback.  While it isn't currently possible to unload the
module, there is work underway to remedy this, and this code will come in
handy when that happens.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: Add pci_ops.{add,remove}_bus() callbacks
Thierry Reding [Tue, 9 Feb 2016 14:30:47 +0000 (15:30 +0100)]
PCI: Add pci_ops.{add,remove}_bus() callbacks

Add pci_ops.{add,remove}_bus() callbacks, which will be called on every
newly created bus and when a bus is being removed, respectively.  This can
be used by drivers to implement driver-specific initialization and teardown
of the bus, in addition to the architecture-specifics implemented by the
pcibios_add_bus() and the pcibios_remove_bus() functions.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: Include pci/hotplug Kconfig directly from pci/Kconfig
Bjorn Helgaas [Tue, 8 Mar 2016 20:57:21 +0000 (14:57 -0600)]
PCI: Include pci/hotplug Kconfig directly from pci/Kconfig

Include pci/hotplug/Kconfig directly from pci/Kconfig, so arches don't
have to source both pci/Kconfig and pci/hotplug/Kconfig.

Note that this effectively adds pci/hotplug/Kconfig to the following
arches, because they already sourced drivers/pci/Kconfig but they
previously did not source drivers/pci/hotplug/Kconfig:

  alpha
  arm
  avr32
  frv
  m68k
  microblaze
  mn10300
  sparc
  unicore32

Inspired-by-patch-from: Bogicevic Sasa <brutallesale@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: Include pci/pcie/Kconfig directly from pci/Kconfig
Bogicevic Sasa [Wed, 3 Feb 2016 21:24:22 +0000 (13:24 -0800)]
PCI: Include pci/pcie/Kconfig directly from pci/Kconfig

Include pci/pcie/Kconfig directly from pci/Kconfig, so arches don't
have to source both pci/Kconfig and pci/pcie/Kconfig.

Note that this effectively adds pci/pcie/Kconfig to the following
arches, because they already sourced drivers/pci/Kconfig but they
previously did not source drivers/pci/pcie/Kconfig:

  alpha
  avr32
  blackfin
  frv
  m32r
  m68k
  microblaze
  mn10300
  parisc
  sparc
  unicore32
  xtensa

[bhelgaas: changelog, source pci/pcie/Kconfig at top of pci/Kconfig, whitespace]
Signed-off-by: Sasa Bogicevic <brutallesale@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agomicroblaze/PCI: Support generic Xilinx AXI PCIe Host Bridge IP driver
Bharat Kumar Gogada [Thu, 11 Feb 2016 16:28:11 +0000 (21:58 +0530)]
microblaze/PCI: Support generic Xilinx AXI PCIe Host Bridge IP driver

Modify the Microblaze PCI subsystem to work with the generic
drivers/pci/host/pcie-xilinx.c driver on Microblaze and Zynq.

[bhelgaas: changelog]
Signed-off-by: Bharat Kumar Gogada <bharatku@xilinx.com>
Signed-off-by: Ravi Kiran Gummaluri <rgummal@xilinx.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Michal Simek <michal.simek@xilinx.com>
8 years agoPCI: xilinx: Update Zynq binding with Microblaze node
Bharat Kumar Gogada [Thu, 11 Feb 2016 16:28:10 +0000 (21:58 +0530)]
PCI: xilinx: Update Zynq binding with Microblaze node

Update Zynq PCI binding documentation with Microblaze node.

[bhelgaas: fix "microbalze_0_intc" typo]
Signed-off-by: Bharat Kumar Gogada <bharatku@xilinx.com>
Signed-off-by: Ravi Kiran Gummaluri <rgummal@xilinx.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rob Herring <robh@kernel.org>
Acked-by: Michal Simek <michal.simek@xilinx.com>
8 years agoPCI: xilinx: Don't call pci_fixup_irqs() on Microblaze
Bharat Kumar Gogada [Thu, 11 Feb 2016 16:28:09 +0000 (21:58 +0530)]
PCI: xilinx: Don't call pci_fixup_irqs() on Microblaze

The Xilinx AXI PCIe Host Bridge Soft IP driver was previously only
supported on ARM (in particular, on ARCH_ZYNC), and pci_fixup_irqs() is
available there.  But Microblaze will do IRQ fixup in pcibios_add_device(),
so pci_fixup_irqs() is not available on Microblaze.

Don't call pci_fixup_irqs() on Microblaze, so the driver can work on both
Zynq and Microblaze Architectures.

[bhelgaas: revise changelog to show similarity to bdb8a1844f31 ("PCI: iproc: Call pci_fixup_irqs() for ARM64 as well as ARM")]
Signed-off-by: Bharat Kumar Gogada <bharatku@xilinx.com>
Signed-off-by: Ravi Kiran Gummaluri <rgummal@xilinx.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Michal Simek <michal.simek@xilinx.com>
8 years agoPCI: xilinx: Remove dependency on ARM-specific struct hw_pci
Bharat Kumar Gogada [Thu, 11 Feb 2016 16:28:08 +0000 (21:58 +0530)]
PCI: xilinx: Remove dependency on ARM-specific struct hw_pci

The Xilinx PCIe host controller driver uses pci_common_init_dev(), which
is ARM-specific and requires the ARM struct hw_pci.  The part of
pci_common_init_dev() that is needed is limited and can be done here
without using hw_pci.

Create and scan the root bus directly without using the ARM
pci_common_init_dev() interface.

[bhelgaas: revise changelog to show similarity to 79953dd22c1d ("PCI: rcar: Remove dependency on ARM-specific struct hw_pci")]
Signed-off-by: Bharat Kumar Gogada <bharatku@xilinx.com>
Signed-off-by: Ravi Kiran Gummaluri <rgummal@xilinx.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Michal Simek <michal.simek@xilinx.com>
8 years agoPCI: xilinx: Use of_pci_get_host_bridge_resources() to parse DT
Bharat Kumar Gogada [Thu, 11 Feb 2016 16:28:07 +0000 (21:58 +0530)]
PCI: xilinx: Use of_pci_get_host_bridge_resources() to parse DT

Use the new of_pci_get_host_bridge_resources() API in place of the PCI OF
DT parser.

[bhelgaas: revise changelog to show similarity to 0021d22b73d6 ("PCI: designware: Use of_pci_get_host_bridge_resources() to parse DT")]
Signed-off-by: Bharat Kumar Gogada <bharatku@xilinx.com>
Signed-off-by: Ravi Kiran Gummaluri <rgummal@xilinx.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Michal Simek <michal.simek@xilinx.com>
8 years agoPCI: Set ROM shadow location in arch code, not in PCI core
Bjorn Helgaas [Tue, 1 Mar 2016 17:38:46 +0000 (11:38 -0600)]
PCI: Set ROM shadow location in arch code, not in PCI core

IORESOURCE_ROM_SHADOW means there is a copy of a device's option ROM in
RAM.  The existence of such a copy and its location are arch-specific.
Previously the IORESOURCE_ROM_SHADOW flag was set in arch code, but the
0xC0000-0xDFFFF location was hard-coded into the PCI core.

If we're using a shadow copy in RAM, disable the ROM BAR and release the
address space it was consuming.  Move the location information from the PCI
core to the arch code that sets IORESOURCE_ROM_SHADOW.  Save the location
of the RAM copy in the struct resource for PCI_ROM_RESOURCE.

After this change, pci_map_rom() will call pci_assign_resource() and
pci_enable_rom() for these IORESOURCE_ROM_SHADOW resources, which we did
not do before.  This is safe because:

  - pci_assign_resource() will do nothing because the resource is marked
    IORESOURCE_PCI_FIXED, which means we can't move it, and

  - pci_enable_rom() will not turn on the ROM BAR's enable bit because the
    resource is marked IORESOURCE_ROM_SHADOW, which means it is in RAM
    rather than in PCI memory space.

Storing the location in the struct resource means "lspci" will show the
shadow location, not the value from the ROM BAR.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: Don't enable/disable ROM BAR if we're using a RAM shadow copy
Bjorn Helgaas [Thu, 3 Mar 2016 14:53:47 +0000 (08:53 -0600)]
PCI: Don't enable/disable ROM BAR if we're using a RAM shadow copy

If we're using a RAM shadow copy instead of the ROM BAR, we don't need to
touch the ROM BAR enable bit.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: Don't assign or reassign immutable resources
Bjorn Helgaas [Tue, 1 Mar 2016 16:58:04 +0000 (10:58 -0600)]
PCI: Don't assign or reassign immutable resources

IORESOURCE_PCI_FIXED means the resource can't be moved, so if it's set,
don't bother trying to assign or reassign the resource.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: Mark shadow copy of VGA ROM as IORESOURCE_PCI_FIXED
Bjorn Helgaas [Tue, 1 Mar 2016 17:32:29 +0000 (11:32 -0600)]
PCI: Mark shadow copy of VGA ROM as IORESOURCE_PCI_FIXED

A shadow copy of an option ROM is placed by the BIOS as a fixed address.
Set IORESOURCE_PCI_FIXED to indicate that we can't move the shadow copy.
This prevents warnings like the following when we assign resources:

  BAR 6: [??? 0x00000000 flags 0x2] has bogus alignment

This warning is emitted by pdev_sort_resources(), which already ignores
IORESOURCE_PCI_FIXED resources.

Link: http://lkml.kernel.org/r/CA+55aFyVMfTBB0oz_yx8+eQOEJnzGtCsYSj9QuhEpdZ9BHdq5A@mail.gmail.com
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agox86/PCI: Mark Broadwell-EP Home Agent & PCU as having non-compliant BARs
Bjorn Helgaas [Fri, 26 Feb 2016 15:15:11 +0000 (09:15 -0600)]
x86/PCI: Mark Broadwell-EP Home Agent & PCU as having non-compliant BARs

The Home Agent and PCU PCI devices in Broadwell-EP have a non-BAR register
where a BAR should be.  We don't know what the side effects of sizing the
"BAR" would be, and we don't know what address space the "BAR" might appear
to describe.

Mark these devices as having non-compliant BARs so the PCI core doesn't
touch them.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Tested-by: Andi Kleen <ak@linux.intel.com>
CC: stable@vger.kernel.org
8 years agounicore32: Remove unused HAVE_ARCH_PCI_SET_DMA_MASK definition
Bjorn Helgaas [Mon, 7 Mar 2016 16:53:16 +0000 (10:53 -0600)]
unicore32: Remove unused HAVE_ARCH_PCI_SET_DMA_MASK definition

HAVE_ARCH_PCI_SET_DMA_MASK is unused, so remove the #define for it.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: GUAN Xuetao <gxt@mprc.pku.edu.cn>
8 years agoPCI: Consolidate PCI DMA constants and interfaces in linux/pci-dma-compat.h
Bjorn Helgaas [Mon, 7 Mar 2016 17:39:16 +0000 (11:39 -0600)]
PCI: Consolidate PCI DMA constants and interfaces in linux/pci-dma-compat.h

Christoph added a generic include/linux/pci-dma-compat.h, so now there's
one place with most of the PCI DMA interfaces.  Move more PCI DMA-related
things there:

  - The PCI_DMA_* direction constants from linux/pci.h
  - The pci_set_dma_max_seg_size() and pci_set_dma_seg_boundary()
    CONFIG_PCI implementations from drivers/pci/pci.c
  - The pci_set_dma_max_seg_size() and pci_set_dma_seg_boundary()
    !CONFIG_PCI stubs from linux/pci.h
  - The pci_set_dma_mask() and pci_set_consistent_dma_mask()
    !CONFIG_PCI stubs from linux/pci.h

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: Move pci_dma_* helpers to common code
Christoph Hellwig [Mon, 7 Mar 2016 16:40:02 +0000 (10:40 -0600)]
PCI: Move pci_dma_* helpers to common code

For a long time all architectures implement the pci_dma_* functions using
the generic DMA API, and they all use the same header to do so.

Move this header, pci-dma-compat.h, to include/linux and include it from
the generic pci.h instead of having each arch duplicate this include.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agofrv/PCI: Remove stray pci_{alloc,free}_consistent() declaration
Christoph Hellwig [Sun, 6 Mar 2016 15:17:53 +0000 (16:17 +0100)]
frv/PCI: Remove stray pci_{alloc,free}_consistent() declaration

FRV doesn't implement pci_{alloc,free}_consistent(), so remove the
declarations for them.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: David S. Miller <davem@davemloft.net>
Acked-by: David Howells <dhowells@redhat.com>
8 years agoPCI: Fold struct pci_vpd_pci22 into struct pci_vpd
Bjorn Helgaas [Mon, 22 Feb 2016 20:09:52 +0000 (14:09 -0600)]
PCI: Fold struct pci_vpd_pci22 into struct pci_vpd

We only support one flavor of VPD, so there's no need to complicate things
by having a "generic" struct pci_vpd and a more specific struct
pci_vpd_pci22.

Fold struct pci_vpd_pci22 directly into struct pci_vpd.

[bhelgaas: remove NULL check before kfree of dev->vpd (per kfreeaddr.cocci)]
Tested-by: Shane Seymour <shane.seymour@hpe.com>
Tested-by: Babu Moger <babu.moger@oracle.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
8 years agoPCI: Rename VPD symbols to remove unnecessary "pci22"
Bjorn Helgaas [Mon, 22 Feb 2016 19:58:37 +0000 (13:58 -0600)]
PCI: Rename VPD symbols to remove unnecessary "pci22"

There's only one kind of VPD, so we don't need to qualify it as "the
version described by PCI spec rev 2.2."

Rename the following symbols to remove unnecessary "pci22":

  PCI_VPD_PCI22_SIZE -> PCI_VPD_MAX_SIZE
  pci_vpd_pci22_size() -> pci_vpd_size()
  pci_vpd_pci22_wait() -> pci_vpd_wait()
  pci_vpd_pci22_read() -> pci_vpd_read()
  pci_vpd_pci22_write() -> pci_vpd_write()
  pci_vpd_pci22_ops -> pci_vpd_ops
  pci_vpd_pci22_init() -> pci_vpd_init()

Tested-by: Shane Seymour <shane.seymour@hpe.com>
Tested-by: Babu Moger <babu.moger@oracle.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
8 years agoPCI: Remove struct pci_vpd_ops.release function pointer
Bjorn Helgaas [Mon, 22 Feb 2016 19:58:20 +0000 (13:58 -0600)]
PCI: Remove struct pci_vpd_ops.release function pointer

The struct pci_vpd_ops.release function pointer is always
pci_vpd_pci22_release(), so there's no need for the flexibility of a
function pointer.

Inline the pci_vpd_pci22_release() body into pci_vpd_release() and remove
pci_vpd_pci22_release() and the struct pci_vpd_ops.release function
pointer.

Tested-by: Shane Seymour <shane.seymour@hpe.com>
Tested-by: Babu Moger <babu.moger@oracle.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
8 years agoPCI: Move pci_vpd_release() from header file to pci/access.c
Bjorn Helgaas [Mon, 22 Feb 2016 19:58:06 +0000 (13:58 -0600)]
PCI: Move pci_vpd_release() from header file to pci/access.c

Move pci_vpd_release() so it's next to the other VPD functions.  This puts
it next to pci_vpd_pci22_init(), which allocates the space freed by
pci_vpd_release().

Tested-by: Shane Seymour <shane.seymour@hpe.com>
Tested-by: Babu Moger <babu.moger@oracle.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
8 years agoPCI: Move pci_read_vpd() and pci_write_vpd() close to other VPD code
Bjorn Helgaas [Mon, 22 Feb 2016 19:57:50 +0000 (13:57 -0600)]
PCI: Move pci_read_vpd() and pci_write_vpd() close to other VPD code

pci_read_vpd() and pci_write_vpd() were stranded in the middle of config
accessor functions.  Move them close to the other VPD code in the file.
No functional change.

Tested-by: Shane Seymour <shane.seymour@hpe.com>
Tested-by: Babu Moger <babu.moger@oracle.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
8 years agoPCI: Determine actual VPD size on first access
Hannes Reinecke [Mon, 15 Feb 2016 08:42:01 +0000 (09:42 +0100)]
PCI: Determine actual VPD size on first access

PCI-2.2 VPD entries have a maximum size of 32k, but might actually be
smaller than that.  To figure out the actual size one has to read the VPD
area until the 'end marker' is reached.

Per spec, reading outside of the VPD space is "not allowed."  In practice,
it may cause simple read errors or even crash the card.  To make matters
worse not every PCI card implements this properly, leaving us with no 'end'
marker or even completely invalid data.

Try to determine the size of the VPD data when it's first accessed.  If no
valid data can be read an I/O error will be returned when reading or
writing the sysfs attribute.

As the amount of VPD data is unknown initially the size of the sysfs
attribute will always be set to '0'.

[bhelgaas: changelog, use 0/1 (not false/true) for bitfield, tweak
pci_vpd_pci22_read() error checking]
Tested-by: Shane Seymour <shane.seymour@hpe.com>
Tested-by: Babu Moger <babu.moger@oracle.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Alexander Duyck <alexander.duyck@gmail.com>
8 years agoPCI: Use bitfield instead of bool for struct pci_vpd_pci22.busy
Bjorn Helgaas [Mon, 22 Feb 2016 20:04:07 +0000 (14:04 -0600)]
PCI: Use bitfield instead of bool for struct pci_vpd_pci22.busy

Make struct pci_vpd_pci22.busy a 1-bit field instead of a bool.  We intend
to add another flag, and two bitfields are cheaper than two bools.

Tested-by: Shane Seymour <shane.seymour@hpe.com>
Tested-by: Babu Moger <babu.moger@oracle.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
8 years agoPCI: Allow access to VPD attributes with size 0
Hannes Reinecke [Mon, 15 Feb 2016 08:42:00 +0000 (09:42 +0100)]
PCI: Allow access to VPD attributes with size 0

It is not always possible to determine the actual size of the VPD
data, so allow access to them if the size is set to '0'.

Tested-by: Shane Seymour <shane.seymour@hpe.com>
Tested-by: Babu Moger <babu.moger@oracle.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Alexander Duyck <alexander.duyck@gmail.com>
8 years agoPCI: imx6: Add DT bindings to configure PHY Tx driver settings
Justin Waters [Fri, 15 Jan 2016 15:24:35 +0000 (10:24 -0500)]
PCI: imx6: Add DT bindings to configure PHY Tx driver settings

The settings in GPR8 are dependent upon the particular layout of the
hardware platform.  As such, they should be configurable via the device
tree.

Look up PHY Tx driver settings from the device tree.  Fall back to the
original hard-coded values if they are not specified in the device tree.

Signed-off-by: Justin Waters <justin.waters@timesys.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Lucas Stach <l.stach@pengutronix.de>
8 years agoPCI: Fix broken URL for Dell biosdevname
Naga Venkata Sai Indubhaskar Jupudi [Tue, 9 Feb 2016 22:10:16 +0000 (14:10 -0800)]
PCI: Fix broken URL for Dell biosdevname

Dell developed a way to consistently name devices, and their last proposal
was accepted under the name biosdevname.  Fix a broken URL to biosdevname
documentation.

Signed-off-by: Naga Venkata Sai Indubhaskar Jupudi <njupudi@ucsc.edu>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: Support SR-IOV on any function type
Kelly Zytaruk [Tue, 9 Feb 2016 18:08:58 +0000 (13:08 -0500)]
PCI: Support SR-IOV on any function type

Previously, we only supported SR-IOV on PCI Express Endpoints and Root
Complex Integrated Endpoints.  This restriction has been present since
d1b054da8f59 ("PCI: initialize and release SR-IOV capability") added SR-IOV
support, but the spec does not require it.  In fact, the SR-IOV spec r1.1,
sec 3.3, says the SR-IOV extended capability may be present for any Type 0
function.

Remove the function type test, so we can support SR-IOV on any function.

Some AMD GPUs have display outputs, use the VGA class code, are Legacy
Endpoints, and support SR-IOV.  This change allows Linux to enable SR-IOV
on these devices.

[bhelgaas: changelog]
Link: https://bugzilla.kernel.org/show_bug.cgi?id=112221
Signed-off-by: Kelly Zytaruk <kelly.zytaruk@amd.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: Disable IO/MEM decoding for devices with non-compliant BARs
Bjorn Helgaas [Thu, 25 Feb 2016 20:35:57 +0000 (14:35 -0600)]
PCI: Disable IO/MEM decoding for devices with non-compliant BARs

The PCI config header (first 64 bytes of each device's config space) is
defined by the PCI spec so generic software can identify the device and
manage its usage of I/O, memory, and IRQ resources.

Some non-spec-compliant devices put registers other than BARs where the
BARs should be.  When the PCI core sizes these "BARs", the reads and writes
it does may have unwanted side effects, and the "BAR" may appear to
describe non-sensical address space.

Add a flag bit to mark non-compliant devices so we don't touch their BARs.
Turn off IO/MEM decoding to prevent the devices from consuming address
space, since we can't read the BARs to find out what that address space
would be.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Tested-by: Andi Kleen <ak@linux.intel.com>
CC: stable@vger.kernel.org
8 years agoPCI: Update VPD definitions
Hannes Reinecke [Mon, 15 Feb 2016 08:41:59 +0000 (09:41 +0100)]
PCI: Update VPD definitions

The 'end' tag is actually 0x0f; it's the representation as a small resource
data type tag that's 0x78 (i.e., shifted by 3).  Correct PCI_VPD_STIN_END
and PCI_VPD_SRDT_END accordingly.

Also, add helper functions to extract the resource data type tags for both
large and small resource data types.

[bhelgaas: changelog]
Tested-by: Shane Seymour <shane.seymour@hpe.com>
Tested-by: Babu Moger <babu.moger@oracle.com>
Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Alexander Duyck <alexander.duyck@gmail.com>
8 years agoPCI: hv: Add paravirtual PCI front-end for Microsoft Hyper-V VMs
Jake Oshins [Tue, 16 Feb 2016 21:56:23 +0000 (21:56 +0000)]
PCI: hv: Add paravirtual PCI front-end for Microsoft Hyper-V VMs

Add a new driver which exposes a root PCI bus whenever a PCI Express device
is passed through to a guest VM under Hyper-V.  The device can be single-
or multi-function.  The interrupts for the devices are managed by an IRQ
domain, implemented within the driver.

[bhelgaas: fold in race condition fix (http://lkml.kernel.org/r/1456340196-13717-1-git-send-email-jakeo@microsoft.com)]
Signed-off-by: Jake Oshins <jakeo@microsoft.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: Look up IRQ domain by fwnode_handle
Jake Oshins [Tue, 16 Feb 2016 21:56:22 +0000 (21:56 +0000)]
PCI: Look up IRQ domain by fwnode_handle

If pci_host_bridge_msi_domain() can't find an IRQ domain through the OF
tree, try to look it up directly through the fwnode_handle.

[bhelgaas: changelog]
Signed-off-by: Jake Oshins <jakeo@microsoft.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: Add fwnode_handle to x86 pci_sysdata
Jake Oshins [Tue, 16 Feb 2016 21:56:21 +0000 (21:56 +0000)]
PCI: Add fwnode_handle to x86 pci_sysdata

Add an fwnode_handle to the x86 struct pci_sysdata, which will be used to
locate an IRQ domain associated with a root PCI bus.

[bhelgaas: changelog]
Signed-off-by: Jake Oshins <jakeo@microsoft.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoMerge branches 'pci/host-designware', 'pci/host-imx6', 'pci/host-layerscape' and...
Bjorn Helgaas [Tue, 9 Feb 2016 18:54:03 +0000 (12:54 -0600)]
Merge branches 'pci/host-designware', 'pci/host-imx6', 'pci/host-layerscape' and 'pci/host-rcar' into next

* pci/host-designware:
  PCI: designware: Remove PCI_PROBE_ONLY handling
  PCI: designware: Explain why we don't program ATU for some platforms

* pci/host-imx6:
  PCI: imx6: Move link up check into imx6_pcie_wait_for_link()
  PCI: imx6: Remove broken Gen2 workaround
  PCI: imx6: Move PHY reset into imx6_pcie_establish_link()
  PCI: imx6: Move imx6_pcie_reset_phy() near other PHY handling functions

* pci/host-layerscape:
  PCI: layerscape: Add "fsl,ls2085a-pcie" compatible ID

* pci/host-rcar:
  PCI: rcar: Remove PCI_PROBE_ONLY handling

8 years agoMerge branches 'pci/aer', 'pci/misc' and 'pci/virtualization' into next
Bjorn Helgaas [Tue, 9 Feb 2016 18:45:58 +0000 (12:45 -0600)]
Merge branches 'pci/aer', 'pci/misc' and 'pci/virtualization' into next

* pci/aer:
  PCI/AER: Use list_first_entry_or_null() to simplify code
  PCI/AER: Restore pci_ops pointer while calling original pci_ops
  PCI/AER: Rename pci_ops_aer to aer_inj_pci_ops

* pci/misc:
  PCI: Remove includes of asm/pci-bridge.h
  PCI: Remove empty asm-generic/pci-bridge.h
  ARM64: PCI: Remove generated include of asm-generic/pci-bridge.h
  PCI: Remove includes of empty asm-generic/pci-bridge.h
  PCI: Move pci_set_flags() from asm-generic/pci-bridge.h to linux/pci.h
  PCI/PME: Restructure pcie_pme_suspend() to prevent compiler warning
  PCI/PME: Remove redundant port lookup
  PCI: Check device_attach() return value always

* pci/virtualization:
  PCI: Add ACS quirk for all Cavium devices

8 years agoPCI: designware: Remove PCI_PROBE_ONLY handling
Lorenzo Pieralisi [Fri, 29 Jan 2016 11:29:32 +0000 (11:29 +0000)]
PCI: designware: Remove PCI_PROBE_ONLY handling

The PCIe designware host driver is not used in system configurations
requiring the PCI_PROBE_ONLY flag to be set to prevent resources
assignment, therefore the driver code handling the flag can be removed
from the kernel.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Pratyush Anand <pratyush.anand@gmail.com>
Acked-by: Jingoo Han Jingoo Han <jingoohan1@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Gabriele Paoloni <gabriele.paoloni@huawei.com>
Cc: Zhou Wang <wangzhou1@hisilicon.com>
8 years agoPCI: designware: Explain why we don't program ATU for some platforms
Jisheng Zhang [Thu, 7 Jan 2016 06:12:38 +0000 (14:12 +0800)]
PCI: designware: Explain why we don't program ATU for some platforms

Some platforms don't support ATU, e.g., pci-keystone.c.  These platforms
use their own address translation component rather than ATU, and they
provide the rd_other_conf and wr_other_conf methods to program the
translation component and perform the access.

Add a comment to explain why we don't program the ATU for these platforms.

[bhelgaas: changelog]
Signed-off-by: Jisheng Zhang <jszhang@marvell.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: Remove includes of asm/pci-bridge.h
Bjorn Helgaas [Fri, 5 Feb 2016 20:58:12 +0000 (14:58 -0600)]
PCI: Remove includes of asm/pci-bridge.h

Drivers should include asm/pci-bridge.h only when they need the arch-
specific things provided there.  Outside of the arch/ directories, the only
drivers that actually need things provided by asm/pci-bridge.h are the
powerpc RPA hotplug drivers in drivers/pci/hotplug/rpa*.

Remove the includes of asm/pci-bridge.h from the other drivers, adding an
include of linux/pci.h if necessary.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: Remove empty asm-generic/pci-bridge.h
Bjorn Helgaas [Fri, 5 Feb 2016 20:58:07 +0000 (14:58 -0600)]
PCI: Remove empty asm-generic/pci-bridge.h

include/asm-generic/pci-bridge.h is empty, and nobody includes it, so
remove it.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoARM64: PCI: Remove generated include of asm-generic/pci-bridge.h
Bjorn Helgaas [Fri, 5 Feb 2016 20:58:02 +0000 (14:58 -0600)]
ARM64: PCI: Remove generated include of asm-generic/pci-bridge.h

arm64 generates asm/pci-bridge.h, which merely includes the now-empty
asm-generic/pci-bridge.h.  Stop generating asm/pci-bridge.h, and stop
including it.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Will Deacon <will.deacon@arm.com>
8 years agoPCI: Remove includes of empty asm-generic/pci-bridge.h
Bjorn Helgaas [Fri, 5 Feb 2016 20:57:54 +0000 (14:57 -0600)]
PCI: Remove includes of empty asm-generic/pci-bridge.h

include/asm-generic/pci-bridge.h is now empty, so remove every #include of
it.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Will Deacon <will.deacon@arm.com> (arm64)
8 years agoPCI: Move pci_set_flags() from asm-generic/pci-bridge.h to linux/pci.h
Bjorn Helgaas [Fri, 5 Feb 2016 20:57:47 +0000 (14:57 -0600)]
PCI: Move pci_set_flags() from asm-generic/pci-bridge.h to linux/pci.h

The PCI flag management constants and functions were previously declared in
include/asm-generic/pci-bridge.h.  But they are not specific to bridges,
and arches did not include pci-bridge.h consistently.

Move the following interfaces and related constants to include/linux/pci.h
and remove pci-bridge.h:

  pci_set_flags()
  pci_add_flags()
  pci_clear_flags()
  pci_has_flag()

This fixes these warnings when building for some arches:

  drivers/pci/host/pcie-designware.c:562:20: error: 'PCI_PROBE_ONLY' undeclared (first use in this function)
  drivers/pci/host/pcie-designware.c:562:7: error: implicit declaration of function 'pci_has_flag' [-Werror=implicit-function-declaration]

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI/PME: Restructure pcie_pme_suspend() to prevent compiler warning
Bjorn Helgaas [Fri, 5 Feb 2016 20:57:19 +0000 (14:57 -0600)]
PCI/PME: Restructure pcie_pme_suspend() to prevent compiler warning

Previously we had this:

  if (wakeup)
    ret = enable_irq_wake(...);
  if (!wakeup || ret)
    ...

"ret" is only evaluated when "wakeup" is true, and it is always initialized
in that case, but gcc isn't smart enough to figure that out and warns:

  drivers/pci/pcie/pme.c:414:14: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]

Restructure the code slightly to make it easier for gcc (and maybe for
humans as well).

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com
8 years agoPCI/PME: Remove redundant port lookup
Bjorn Helgaas [Fri, 5 Feb 2016 20:57:12 +0000 (14:57 -0600)]
PCI/PME: Remove redundant port lookup

We've already looked up srv->port a few lines earlier, and there's no need
to do it again.  Remove the redundant lookup.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com
8 years agoPCI: Check device_attach() return value always
Bjorn Helgaas [Wed, 27 Jan 2016 13:35:07 +0000 (07:35 -0600)]
PCI: Check device_attach() return value always

Previously we checked the device_attach() return value only when
CONFIG_BUG=y.  That caused this warning in builds where CONFIG_BUG is not
set:

  drivers/pci/bus.c:237:6: warning: variable 'retval' set but not used [-Wunused-but-set-variable]

Check the return value of device_attach() always and clean up after
failure.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
8 years agoPCI: layerscape: Add "fsl,ls2085a-pcie" compatible ID
Yang Shi [Wed, 27 Jan 2016 17:32:05 +0000 (09:32 -0800)]
PCI: layerscape: Add "fsl,ls2085a-pcie" compatible ID

The Layerscape PCI host driver must recognize ls2085a compatible when using
firmware with ls2085a compatible property, otherwise the PCI bus won't be
detected even though ls2085a compatible is included by the dts.

Signed-off-by: Yang Shi <yang.shi@linaro.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: rcar: Remove PCI_PROBE_ONLY handling
Lorenzo Pieralisi [Fri, 29 Jan 2016 11:29:31 +0000 (11:29 +0000)]
PCI: rcar: Remove PCI_PROBE_ONLY handling

The PCIe rcar host driver is not used in system configurations requiring
the PCI_PROBE_ONLY flag to be set to prevent resources assignment,
therefore the driver code handling the flag can be removed from the kernel.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Simon Horman <horms+renesas@verge.net.au>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Phil Edworthy <phil.edworthy@renesas.com>
8 years agoPCI: Add ACS quirk for all Cavium devices
Manish Jaggi [Fri, 29 Jan 2016 20:03:58 +0000 (01:33 +0530)]
PCI: Add ACS quirk for all Cavium devices

Cavium devices matching this quirk do not perform peer-to-peer with other
functions, allowing masking out these bits as if they were unimplemented in
the ACS capability.

Signed-off-by: Manish Jaggi <mjaggi@caviumnetworks.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Tirumalesh Chalamarla <tchalamarla@cavium.com>
8 years agoPCI/AER: Use list_first_entry_or_null() to simplify code
Geliang Tang [Fri, 22 Jan 2016 14:50:19 +0000 (22:50 +0800)]
PCI/AER: Use list_first_entry_or_null() to simplify code

Use list_first_entry_or_null() instead of list_empty() + list_entry() to
simplify the code.

Signed-off-by: Geliang Tang <geliangtang@163.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI/AER: Restore pci_ops pointer while calling original pci_ops
David Daney [Tue, 22 Dec 2015 21:44:51 +0000 (13:44 -0800)]
PCI/AER: Restore pci_ops pointer while calling original pci_ops

The aer_inject module intercepts config space accesses by replacing the
bus->ops pointer.  If it forwards accesses to the original pci_ops, and
those original ops use bus->ops, they see the aer_pci_ops instead of their
own pci_ops, which can cause a crash.

For example, pci_generic_config_read() uses the bus->ops->map_bus pointer.
If bus->ops is set to aer_pci_ops, which doesn't supply .map_bus,
pci_generic_config_read() will dereference an invalid pointer and cause a
crash.

Temporarily restore the original bus->ops pointer while calling ops->read()
or ops->write().  Callers of these functions already hold pci_lock, which
prevents other users of bus->ops until we're finished.

[bhelgaas: changelog]
Signed-off-by: David Daney <david.daney@cavium.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI/AER: Rename pci_ops_aer to aer_inj_pci_ops
Bjorn Helgaas [Thu, 4 Feb 2016 20:02:45 +0000 (14:02 -0600)]
PCI/AER: Rename pci_ops_aer to aer_inj_pci_ops

Rename

  pci_ops_aer     to aer_inj_pci_ops
  pci_read_aer()  to aer_inj_read_config()
  pci_write_aer() to aer_inj_write_config()

This is more conventional and more informative.  No functional change.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: imx6: Move link up check into imx6_pcie_wait_for_link()
Lucas Stach [Mon, 25 Jan 2016 22:50:02 +0000 (16:50 -0600)]
PCI: imx6: Move link up check into imx6_pcie_wait_for_link()

imx6_pcie_link_up() previously used usleep_range() to wait for the link to
come up.  Since it may be called while holding the config spinlock, the
sleep causes a "BUG: scheduling while atomic" error.

Instead of waiting for the link to come up in imx6_pcie_link_up(), do the
waiting in imx6_pcie_wait_for_link(), where we're not holding a lock and
sleeping is allowed.

[bhelgaas: changelog, references to bugzilla and f95d3ae77191]
Link: https://bugzilla.kernel.org/show_bug.cgi?id=100031
Fixes: f95d3ae77191 ("PCI: imx6: Wait for retraining")
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: imx6: Remove broken Gen2 workaround
Lucas Stach [Mon, 25 Jan 2016 22:49:57 +0000 (16:49 -0600)]
PCI: imx6: Remove broken Gen2 workaround

Remove the remnants of the workaround for erratum ERR005184 which was never
completely implemented.  The checks alone don't carry any value as we don't
act properly on the result.

A workaround should be added to the lane speed change in establish_link
later.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
8 years agoPCI: imx6: Move PHY reset into imx6_pcie_establish_link()
Lucas Stach [Mon, 25 Jan 2016 22:49:53 +0000 (16:49 -0600)]
PCI: imx6: Move PHY reset into imx6_pcie_establish_link()

This adds the PHY reset into a common error path of
imx6_pcie_establish_link(), deduplicating some of the debug prints.  Also
reduce the severity of the "no-link" message in the one place where it is
expected to be hit when no peripheral is attached.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>