cascardo/linux.git
9 years agoMerge branch 'pci/virtualization' into next
Bjorn Helgaas [Mon, 6 Oct 2014 15:58:37 +0000 (09:58 -0600)]
Merge branch 'pci/virtualization' into next

* pci/virtualization:
  PCI: Add ACS quirk for AMD A88X southbridge devices

9 years agoPCI: Add ACS quirk for AMD A88X southbridge devices
Marti Raudsepp [Thu, 2 Oct 2014 14:50:31 +0000 (08:50 -0600)]
PCI: Add ACS quirk for AMD A88X southbridge devices

AMD has confirmed that peer-to-peer between two southbridge functions does
not occur.

Add a quirk to indicate that these functions are isolated even though they
don't have an ACS capability.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=81841
Signed-off-by: Marti Raudsepp <marti@juffo.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Joel Schopp <joel.schopp@amd.com>
9 years agoMerge branch 'pci/host-designware' into next
Bjorn Helgaas [Wed, 1 Oct 2014 22:45:01 +0000 (16:45 -0600)]
Merge branch 'pci/host-designware' into next

* pci/host-designware:
  PCI: designware: Remove open-coded bitmap operations
  PCI: designware: Setup and clear exactly one MSI at a time

Conflicts:
drivers/pci/host/pcie-designware.c

9 years agoMerge branch 'pci/resource' into next
Bjorn Helgaas [Wed, 1 Oct 2014 22:43:41 +0000 (16:43 -0600)]
Merge branch 'pci/resource' into next

* pci/resource:
  PCI: Add missing MEM_64 mask in pci_assign_unassigned_bridge_resources()

9 years agoPCI: designware: Remove open-coded bitmap operations
Lucas Stach [Tue, 30 Sep 2014 16:36:27 +0000 (18:36 +0200)]
PCI: designware: Remove open-coded bitmap operations

Replace them by using the standard kernel bitmap ops.  No functional
change, but makes the code a lot cleaner.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Pratyush Anand <pratyush.anand@st.com>
Acked-by: Jingoo Han <jg1.han@samsung.com>
9 years agoMerge branch 'pci/msi' into next
Bjorn Helgaas [Wed, 1 Oct 2014 18:31:46 +0000 (12:31 -0600)]
Merge branch 'pci/msi' into next

* pci/msi:
  PCI/MSI: Remove unnecessary temporary variable
  PCI/MSI: Use __write_msi_msg() instead of write_msi_msg()
  MSI/powerpc: Use __read_msi_msg() instead of read_msi_msg()
  PCI/MSI: Use __get_cached_msi_msg() instead of get_cached_msi_msg()
  PCI/MSI: Add "msi_bus" sysfs MSI/MSI-X control for endpoints
  PCI/MSI: Remove "pos" from the struct msi_desc msi_attrib
  PCI/MSI: Remove unused kobject from struct msi_desc
  PCI/MSI: Rename pci_msi_check_device() to pci_msi_supported()
  PCI/MSI: Move D0 check into pci_msi_check_device()
  PCI/MSI: Remove arch_msi_check_device()
  irqchip: armada-370-xp: Remove arch_msi_check_device()
  PCI/MSI/PPC: Remove arch_msi_check_device()

Conflicts:
drivers/pci/host/pcie-designware.c

9 years agoMerge branch 'pci/host-generic' into next
Bjorn Helgaas [Wed, 1 Oct 2014 18:31:23 +0000 (12:31 -0600)]
Merge branch 'pci/host-generic' into next

* pci/host-generic:
  arm64: Add architectural support for PCI
  PCI: Add pci_remap_iospace() to map bus I/O resources
  of/pci: Add support for parsing PCI host bridge resources from DT
  of/pci: Add pci_get_new_domain_nr() and of_get_pci_domain_nr()
  PCI: Add generic domain handling
  of/pci: Fix the conversion of IO ranges into IO resources
  of/pci: Move of_pci_range_to_resource() to of/address.c
  ARM: Define PCI_IOBASE as the base of virtual PCI IO space
  of/pci: Add pci_register_io_range() and pci_pio_to_address()
  asm-generic/io.h: Fix ioport_map() for !CONFIG_GENERIC_IOMAP

Conflicts:
drivers/pci/host/pci-tegra.c

9 years agoMerge branches 'pci/aer' and 'pci/virtualization' into next
Bjorn Helgaas [Wed, 1 Oct 2014 18:30:58 +0000 (12:30 -0600)]
Merge branches 'pci/aer' and 'pci/virtualization' into next

* pci/aer:
  PCI/AER: Rename PCI_ERR_UNC_TRAIN to PCI_ERR_UNC_UND
  PCI/AER: Add additional PCIe AER error strings
  trace, RAS: Add additional PCIe AER error strings
  trace, RAS: Replace bare numbers with #defines for PCIe AER error strings

* pci/virtualization:
  PCI: Add ACS quirk for Intel 10G NICs

9 years agoPCI/MSI: Remove unnecessary temporary variable
Bjorn Helgaas [Tue, 23 Sep 2014 20:38:28 +0000 (14:38 -0600)]
PCI/MSI: Remove unnecessary temporary variable

The only use of "status" is to hold a value which is immediately returned,
so just return and remove the variable directly.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoPCI/MSI: Use __write_msi_msg() instead of write_msi_msg()
Yijing Wang [Tue, 30 Sep 2014 00:35:16 +0000 (18:35 -0600)]
PCI/MSI: Use __write_msi_msg() instead of write_msi_msg()

default_restore_msi_irq() already has the struct msi_desc pointer required
by __write_msi_msg(), so call it directly instead of having write_msi_msg()
look it up from the IRQ.

No functional change.

[bhelgaas: split into separate patch]
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoMSI/powerpc: Use __read_msi_msg() instead of read_msi_msg()
Yijing Wang [Wed, 24 Sep 2014 03:09:45 +0000 (11:09 +0800)]
MSI/powerpc: Use __read_msi_msg() instead of read_msi_msg()

rtas_setup_msi_irqs() already has the struct msi_desc pointer required by
__read_msi_msg(), so call it directly instead of having read_msi_msg() look
it up from the IRQ.

No functional change.

[bhelgaas: changelog]
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Michael Ellerman <mpe@ellerman.id.au>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: linuxppc-dev@lists.ozlabs.org
9 years agoPCI/MSI: Use __get_cached_msi_msg() instead of get_cached_msi_msg()
Yijing Wang [Tue, 23 Sep 2014 05:27:25 +0000 (13:27 +0800)]
PCI/MSI: Use __get_cached_msi_msg() instead of get_cached_msi_msg()

Both callers of get_cached_msi_msg() start with a struct irq_data pointer,
look up the corresponding IRQ number, and pass it to get_cached_msi_msg(),
which then uses irq_get_irq_data() to look up the struct irq_data again to
call __get_cached_msi_msg().

Since we already have the struct irq_data, call __get_cached_msi_msg()
directly and skip the lookup work done by get_cached_msi_msg().

No functional change.

[bhelgaas: changelog]
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Tony Luck <tony.luck@intel.com>
CC: linux-ia64@vger.kernel.org
9 years agoPCI/MSI: Add "msi_bus" sysfs MSI/MSI-X control for endpoints
Yijing Wang [Tue, 23 Sep 2014 05:27:24 +0000 (13:27 +0800)]
PCI/MSI: Add "msi_bus" sysfs MSI/MSI-X control for endpoints

The "msi_bus" sysfs file for bridges sets a bus flag to allow or disallow
future driver requests for MSI or MSI-X.  Previously, the sysfs file
existed for endpoints but did nothing.

Add "msi_bus" support for endpoints, so an administrator can prevent the
use of MSI and MSI-X for individual devices.

Note that as for bridges, these changes only affect future driver requests
for MSI or MSI-X, so drivers may need to be reloaded.

Add documentation for the "msi_bus" sysfs file.

[bhelgaas: changelog, comments, add "subordinate", add endpoint printk,
rework bus_flags setting, make bus_flags printk unconditional]
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoPCI/MSI: Remove "pos" from the struct msi_desc msi_attrib
Yijing Wang [Tue, 23 Sep 2014 17:02:42 +0000 (11:02 -0600)]
PCI/MSI: Remove "pos" from the struct msi_desc msi_attrib

"msi_attrib.pos" is only used for MSI (not MSI-X), and we already cache the
MSI capability offset in "dev->msi_cap".

Remove "pos" from the struct msi_attrib and use "dev->msi_cap" directly.

[bhelgaas: changelog, fix whitespace]
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoPCI/MSI: Remove unused kobject from struct msi_desc
Yijing Wang [Tue, 23 Sep 2014 05:27:22 +0000 (13:27 +0800)]
PCI/MSI: Remove unused kobject from struct msi_desc

After commit 1c51b50c2995 ("PCI/MSI: Export MSI mode using attributes, not
kobjects"), the kobject in struct msi_desc is unused.

Remove the unused struct kobject from struct msi_desc.

[bhelgaas: changelog]
Fixes: 1c51b50c2995 ("PCI/MSI: Export MSI mode using attributes, not kobjects")
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoPCI/MSI: Rename pci_msi_check_device() to pci_msi_supported()
Alexander Gordeev [Tue, 23 Sep 2014 18:45:58 +0000 (12:45 -0600)]
PCI/MSI: Rename pci_msi_check_device() to pci_msi_supported()

Rename pci_msi_check_device() to pci_msi_supported() for clarity.  Note
that pci_msi_supported() returns true if MSI/MSI-X is supported, so code
like:

  if (pci_msi_supported(...))

reads naturally.

[bhelgaas: changelog, split to separate patch, reverse sense]
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoPCI/MSI: Move D0 check into pci_msi_check_device()
Alexander Gordeev [Tue, 23 Sep 2014 20:25:11 +0000 (14:25 -0600)]
PCI/MSI: Move D0 check into pci_msi_check_device()

Both callers of pci_msi_check_device() check that the device is in D0
state, so move the check from the callers into pci_msi_check_device()
itself.

In pci_enable_msi_range(), note that pci_msi_check_device() never returns a
positive value any more, so the loop that called it until it returns zero
or negative is no longer necessary.

[bhelgaas: changelog, split to separate patch]
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoPCI/MSI: Remove arch_msi_check_device()
Alexander Gordeev [Tue, 23 Sep 2014 18:39:54 +0000 (12:39 -0600)]
PCI/MSI: Remove arch_msi_check_device()

No architectures implement arch_msi_check_device() or the struct msi_chip
.check_device() method, so remove them.

Remove the "type" parameter to pci_msi_check_device() because it was only
used to call arch_msi_check_device() and is no longer needed.

[bhelgaas: changelog, split to separate patch]
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoirqchip: armada-370-xp: Remove arch_msi_check_device()
Alexander Gordeev [Sun, 7 Sep 2014 18:57:54 +0000 (20:57 +0200)]
irqchip: armada-370-xp: Remove arch_msi_check_device()

Move MSI checks from arch_msi_check_device() to arch_setup_msi_irqs().
This makes the code more compact and allows removing
arch_msi_check_device() from generic MSI code.

Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Jason Cooper <jason@lakedaemon.net>
CC: Thomas Gleixner <tglx@linutronix.de>
9 years agoPCI/MSI/PPC: Remove arch_msi_check_device()
Alexander Gordeev [Sun, 7 Sep 2014 18:57:53 +0000 (20:57 +0200)]
PCI/MSI/PPC: Remove arch_msi_check_device()

Move MSI checks from arch_msi_check_device() to arch_setup_msi_irqs().
This makes the code more compact and allows removing
arch_msi_check_device() from generic MSI code.

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Michael Ellerman <mpe@ellerman.id.au>
9 years agoarm64: Add architectural support for PCI
Liviu Dudau [Mon, 29 Sep 2014 14:29:31 +0000 (15:29 +0100)]
arm64: Add architectural support for PCI

Use the generic PCI domain and OF functions to provide support for PCI
on arm64.

[bhelgaas: Change comments to use generic PCI, not just PCIe.  Nothing at
this level is PCIe-specific.]
Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
9 years agoPCI: Add pci_remap_iospace() to map bus I/O resources
Liviu Dudau [Mon, 29 Sep 2014 14:29:30 +0000 (15:29 +0100)]
PCI: Add pci_remap_iospace() to map bus I/O resources

Add pci_remap_iospace() to map bus I/O resources into the CPU virtual
address space.  Architectures with special needs may provide their own
version, but most should be able to use this one.

This function is useful for PCI host bridge drivers that need to map the
PCI I/O resources into virtual memory space.

[bhelgaas: phys_addr description, drop temporary "err" variable]
Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
CC: Arnd Bergmann <arnd@arndb.de>
9 years agoof/pci: Add support for parsing PCI host bridge resources from DT
Liviu Dudau [Mon, 29 Sep 2014 14:29:28 +0000 (15:29 +0100)]
of/pci: Add support for parsing PCI host bridge resources from DT

Provide a function to parse the PCI DT ranges that can be used to create a
pci_host_bridge structure together with its associated bus.

Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
[make io_base parameter optional]
Signed-off-by: Robert Richter <rrichter@cavium.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Arnd Bergmann <arnd@arndb.de>
CC: Grant Likely <grant.likely@linaro.org>
CC: Rob Herring <robh+dt@kernel.org>
CC: Catalin Marinas <catalin.marinas@arm.com>
9 years agoof/pci: Add pci_get_new_domain_nr() and of_get_pci_domain_nr()
Liviu Dudau [Mon, 29 Sep 2014 14:29:27 +0000 (15:29 +0100)]
of/pci: Add pci_get_new_domain_nr() and of_get_pci_domain_nr()

Add pci_get_new_domain_nr() to allocate a new domain number and
of_get_pci_domain_nr() to retrieve the PCI domain number of a given device
from DT.  Host bridge drivers or architecture-specific code can choose to
implement their PCI domain number policy using these two functions.

Using of_get_pci_domain_nr() guarantees a stable PCI domain number on every
boot provided that all host bridge controllers are assigned a number in the
device tree using "linux,pci-domain" property.  Mixing use of
pci_get_new_domain_nr() and of_get_pci_domain_nr() is not recommended as it
can lead to potentially conflicting domain numbers being assigned to root
buses behind different host bridges.

Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Arnd Bergmann <arnd@arndb.de>
CC: Grant Likely <grant.likely@linaro.org>
CC: Rob Herring <robh+dt@kernel.org>
CC: Catalin Marinas <catalin.marinas@arm.com>
9 years agoPCI: Add generic domain handling
Catalin Marinas [Mon, 29 Sep 2014 14:29:26 +0000 (15:29 +0100)]
PCI: Add generic domain handling

The handling of PCI domains (or PCI segments in ACPI speak) is usually a
straightforward affair but its implementation is currently left to the
architectural code, with pci_domain_nr(b) querying the value of the domain
associated with bus b.

This patch introduces CONFIG_PCI_DOMAINS_GENERIC as an option that can be
selected if an architecture wants a simple implementation where the value
of the domain associated with a bus is stored in struct pci_bus.

The architectures that select CONFIG_PCI_DOMAINS_GENERIC will then have to
implement pci_bus_assign_domain_nr() as a way of setting the domain number
associated with a root bus.  All child buses except the root bus will
inherit the domain_nr value from their parent.

Signed-off-by: Catalin Marinas <Catalin.Marinas@arm.com>
[Renamed pci_set_domain_nr() to pci_bus_assign_domain_nr()]
Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Arnd Bergmann <arnd@arndb.de>
9 years agoof/pci: Fix the conversion of IO ranges into IO resources
Liviu Dudau [Mon, 29 Sep 2014 14:29:25 +0000 (15:29 +0100)]
of/pci: Fix the conversion of IO ranges into IO resources

The ranges property for a host bridge controller in DT describes the
mapping between the PCI bus address and the CPU physical address.  The
resources framework however expects that the IO resources start at a pseudo
"port" address 0 (zero) and have a maximum size of IO_SPACE_LIMIT.  The
conversion from PCI ranges to resources failed to take that into account,
returning a CPU physical address instead of a port number.

Also fix all the drivers that depend on the old behaviour by fetching the
CPU physical address based on the port number where it is being needed.

Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
CC: Grant Likely <grant.likely@linaro.org>
CC: Rob Herring <robh+dt@kernel.org>
CC: Arnd Bergmann <arnd@arndb.de>
CC: Thierry Reding <thierry.reding@gmail.com>
CC: Simon Horman <horms@verge.net.au>
CC: Catalin Marinas <catalin.marinas@arm.com>
9 years agoPCI: designware: Setup and clear exactly one MSI at a time
Lucas Stach [Tue, 30 Sep 2014 16:36:26 +0000 (18:36 +0200)]
PCI: designware: Setup and clear exactly one MSI at a time

The setup_irq function is supposed to set up exactly one MSI IRQ.  Multiple
IRQ setup is handled differently, to respect the choices made by the upper
layers.

Also only clear one MSI IRQ at a time; the PCI core will call into this
function multiple times if it has to tear down more than one MSI IRQ.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Pratyush Anand <pratyush.anand@st.com>
Acked-by: Jingoo Han <jg1.han@samsung.com>
9 years agoPCI: Add missing MEM_64 mask in pci_assign_unassigned_bridge_resources()
Yinghai Lu [Sat, 23 Aug 2014 01:15:07 +0000 (18:15 -0700)]
PCI: Add missing MEM_64 mask in pci_assign_unassigned_bridge_resources()

In 5b28541552ef ("PCI: Restrict 64-bit prefetchable bridge windows to
64-bit resources"), we added IORESOURCE_MEM_64 to the mask in
pci_assign_unassigned_root_bus_resources(), but not to the mask in
pci_assign_unassigned_bridge_resources().

Add IORESOURCE_MEM_64 to the pci_assign_unassigned_bridge_resources() type
mask.

Fixes: 5b28541552ef ("PCI: Restrict 64-bit prefetchable bridge windows to 64-bit resources")
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: stable@vger.kernel.org # v3.16+
9 years agoof/pci: Move of_pci_range_to_resource() to of/address.c
Liviu Dudau [Mon, 29 Sep 2014 14:29:24 +0000 (15:29 +0100)]
of/pci: Move of_pci_range_to_resource() to of/address.c

We need to enhance of_pci_range_to_resources() enough that it won't make
sense for it to be inline anymore.  Move it to drivers/of/address.c, under
#ifdef CONFIG_PCI.

of_address.h previously implemented of_pci_range_to_resources()
unconditionally, regardless of any config options.  The implementation in
address.c is defined only when CONFIG_OF_ADDRESS=y and CONFIG_PCI=y,
so add a dummy version to avoid build errors when CONFIG_OF or
CONFIG_OF_ADDRESS is not defined.

[bhelgaas: drop extra detail from changelog, move def under CONFIG_PCI,
add dummy of_pci_range_to_resource() for build errors (from Arnd)]
Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Grant Likely <grant.likely@linaro.org>
CC: Rob Herring <robh+dt@kernel.org>
CC: Arnd Bergmann <arnd@arndb.de>
CC: Catalin Marinas <catalin.marinas@arm.com>
9 years agoARM: Define PCI_IOBASE as the base of virtual PCI IO space
Liviu Dudau [Mon, 29 Sep 2014 14:29:22 +0000 (15:29 +0100)]
ARM: Define PCI_IOBASE as the base of virtual PCI IO space

This is needed for calls into OF code that parses PCI ranges.  It signals
support for memory mapped PCI I/O accesses that are described by device
trees.

Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
CC: Russell King <linux@arm.linux.org.uk>
CC: Rob Herring <robh+dt@kernel.org>
9 years agoof/pci: Add pci_register_io_range() and pci_pio_to_address()
Liviu Dudau [Mon, 29 Sep 2014 14:29:21 +0000 (15:29 +0100)]
of/pci: Add pci_register_io_range() and pci_pio_to_address()

Some architectures do not have a simple view of the PCI I/O space and
instead use a range of CPU addresses that map to bus addresses.  For some
architectures these ranges will be expressed by OF bindings in a device
tree file.

This patch introduces a pci_register_io_range() helper function with a
generic implementation that can be used by such architectures to keep track
of the I/O ranges described by the PCI bindings.  If the PCI_IOBASE macro
is not defined, that signals lack of support for PCI and we return an
error.

In order to retrieve the CPU address associated with an I/O port, a new
helper function pci_pio_to_address() is introduced.  This will search in
the list of ranges registered with pci_register_io_range() and return the
CPU address that corresponds to the given port.

[arnd: add dummy !CONFIG_OF pci_pio_to_address() to fix build errors]
Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Rob Herring <robh@kernel.org>
CC: Grant Likely <grant.likely@linaro.org>
9 years agoasm-generic/io.h: Fix ioport_map() for !CONFIG_GENERIC_IOMAP
Liviu Dudau [Mon, 29 Sep 2014 14:29:20 +0000 (15:29 +0100)]
asm-generic/io.h: Fix ioport_map() for !CONFIG_GENERIC_IOMAP

The !CONFIG_GENERIC_IOMAP version of ioport_map() is wrong.  It returns a
mapped, i.e., virtual, address that can start from zero and completely
ignores the PCI_IOBASE and IO_SPACE_LIMIT that most architectures that use
!CONFIG_GENERIC_MAP define.

Tested-by: Tanmay Inamdar <tinamdar@apm.com>
Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
9 years agoPCI: Add ACS quirk for Intel 10G NICs
Alex Williamson [Fri, 26 Sep 2014 23:07:59 +0000 (17:07 -0600)]
PCI: Add ACS quirk for Intel 10G NICs

Intel has verified there is no peer-to-peer between functions for the below
selection of 82598, 82599, and X520 10G NICs.  These NICs lack an ACS
capability, so we're not able to determine this isolation without the help
of quirks.

Generalize the Solarflare quirk and add these Intel 10G NICs.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: John Ronciak <John.ronciak@intel.com>
9 years agoMerge branch 'pci/host-designware' into next
Bjorn Helgaas [Mon, 29 Sep 2014 19:24:24 +0000 (13:24 -0600)]
Merge branch 'pci/host-designware' into next

* pci/host-designware:
  PCI: designware: Add get_msi_data() to pcie_host_ops
  PCI: designware: Rename get_msi_data() to get_msi_addr()
  PCI: designware: Fix IO resource end address calculation
  PCI: designware: Fix configuration base address when using 'reg'
  PCI: designware: Use NULL instead of false

[bhelgaas: Fixup keystone for "PCI: designware: Rename get_msi_data() to
get_msi_addr()"]

9 years agoMerge branches 'pci/enumeration', 'pci/virtualization' and 'pci/cleanup' into next
Bjorn Helgaas [Thu, 25 Sep 2014 19:52:02 +0000 (13:52 -0600)]
Merge branches 'pci/enumeration', 'pci/virtualization' and 'pci/cleanup' into next

* pci/enumeration:
  PCI: Generate uppercase hex for modalias interface class

* pci/virtualization:
  PCI: Add ACS quirk for Solarflare SFC9120 & SFC9140
  PCI: Remove unused pci_get_dma_source()
  PCI: Remove unused pci_find_upstream_pcie_bridge()

* pci/cleanup:
  PCI: Remove assignment from complicated "if" conditions
  PCI: Remove assignment from "if" conditions
  PCI: Remove unnecessary curly braces
  PCI: Add space before open parenthesis

9 years agoMerge branches 'pci/host-mvebu' and 'pci/host-spear' into next
Bjorn Helgaas [Thu, 25 Sep 2014 19:51:55 +0000 (13:51 -0600)]
Merge branches 'pci/host-mvebu' and 'pci/host-spear' into next

* pci/host-mvebu:
  PCI: mvebu: Fix uninitialized variable in mvebu_get_tgt_attr()

* pci/host-spear:
  PCI: spear: Pass config resource through reg property

9 years agoPCI/AER: Rename PCI_ERR_UNC_TRAIN to PCI_ERR_UNC_UND
Chen, Gong [Wed, 13 Aug 2014 06:22:40 +0000 (02:22 -0400)]
PCI/AER: Rename PCI_ERR_UNC_TRAIN to PCI_ERR_UNC_UND

In PCIe r1.0, sec 5.10.2, bit 0 of the Uncorrectable Error Status, Mask,
and Severity Registers was for "Training Error." In PCIe r1.1, sec 7.10.2,
bit 0 was redefined to be "Undefined."

Rename PCI_ERR_UNC_TRAIN to PCI_ERR_UNC_UND to reflect this change.

No functional change.

[bhelgaas: changelog]
Signed-off-by: Chen, Gong <gong.chen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoPCI/AER: Add additional PCIe AER error strings
Chen, Gong [Thu, 25 Sep 2014 15:36:43 +0000 (09:36 -0600)]
PCI/AER: Add additional PCIe AER error strings

Add strings for all AER error bits defined in PCIe r3.0.

[bhelgaas: changelog, drop designated initializer change]
Signed-off-by: Chen, Gong <gong.chen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agotrace, RAS: Add additional PCIe AER error strings
Chen, Gong [Wed, 13 Aug 2014 06:22:39 +0000 (02:22 -0400)]
trace, RAS: Add additional PCIe AER error strings

Add all AER error bits defined in PCIe r3.0.

[bhelgaas: changelog]
Signed-off-by: Chen, Gong <gong.chen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agotrace, RAS: Replace bare numbers with #defines for PCIe AER error strings
Chen, Gong [Wed, 13 Aug 2014 06:22:37 +0000 (02:22 -0400)]
trace, RAS: Replace bare numbers with #defines for PCIe AER error strings

Replace bare numbers like "BIT(0)" with the existing #defines, e.g.,
PCI_ERR_COR_RCVR, to improve maintainability.  This way grep will find more
uses of the #defines.

No functional change.

[bhelgaas: changelog]
Signed-off-by: Chen, Gong <gong.chen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoMerge branches 'pci/hotplug', 'pci/initdata' and 'pci/misc' into next
Bjorn Helgaas [Wed, 24 Sep 2014 20:36:11 +0000 (14:36 -0600)]
Merge branches 'pci/hotplug', 'pci/initdata' and 'pci/misc' into next

* pci/hotplug:
  PCI: pciehp: Stop disabling notifications during init
  PCI: pciehp: Add more Slot Control debug output
  PCI: pciehp: Fix wait time in timeout message

* pci/initdata:
  x86/PCI: Mark PCI BIOS initialization code as such
  x86/PCI: Constify pci_mmcfg_probes[] array
  x86/PCI: Mark constants of pci_mmcfg_nvidia_mcp55() as __initconst
  x86/PCI: Move __init annotation to the correct place
  x86/PCI: Mark DMI tables as initialization data

* pci/misc:
  PCI: Move PCI_VENDOR_ID_VMWARE to pci_ids.h

9 years agoPCI: Move PCI_VENDOR_ID_VMWARE to pci_ids.h
Francesco Ruggeri [Wed, 24 Sep 2014 17:12:41 +0000 (10:12 -0700)]
PCI: Move PCI_VENDOR_ID_VMWARE to pci_ids.h

Move PCI_VENDOR_ID_VMWARE from device-specific files to pci_ids.h.
It is useful to always have access to it, especially when accessing
subsystem_vendor_id on emulated devices.

[bhelgaas: keep pci_ids.h sorted and use lower-case hex]
Signed-off-by: Francesco Ruggeri <fruggeri@arista.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoPCI: Remove assignment from complicated "if" conditions
Quentin Lambert [Sun, 7 Sep 2014 18:04:28 +0000 (20:04 +0200)]
PCI: Remove assignment from complicated "if" conditions

The modifications effectively change the value of len_tmp
in the case where the first condition is not met.

Signed-off-by: Quentin Lambert <lambert.quentin@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoPCI: Remove assignment from "if" conditions
Quentin Lambert [Sun, 7 Sep 2014 18:03:32 +0000 (20:03 +0200)]
PCI: Remove assignment from "if" conditions

The following Coccinelle semantic patch was used to find and correct cases
of assignments in "if" conditions:

@@
expression var, expr;
statement S;
@@

+ var = expr;
  if(
- (var = expr)
+ var
  ) S

Signed-off-by: Quentin Lambert <lambert.quentin@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoPCI: Remove unnecessary curly braces
Quentin Lambert [Sun, 7 Sep 2014 18:02:47 +0000 (20:02 +0200)]
PCI: Remove unnecessary curly braces

Remove curly braces in simple "if" cases.

No functional change.

Signed-off-by: Quentin Lambert <lambert.quentin@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoPCI: Add space before open parenthesis
Quentin Lambert [Sun, 7 Sep 2014 18:02:04 +0000 (20:02 +0200)]
PCI: Add space before open parenthesis

Add space before open parenthesis as is conventional.

No functional change.

[bhelgaas: fix a few more in ibmphp, shpchp]
Signed-off-by: Quentin Lambert <lambert.quentin@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoPCI: designware: Add get_msi_data() to pcie_host_ops
Minghuan Lian [Tue, 23 Sep 2014 14:28:59 +0000 (22:28 +0800)]
PCI: designware: Add get_msi_data() to pcie_host_ops

Add a struct pcie_host_ops .get_msi_data() method for platforms to return
their special MSI message data.

Signed-off-by: Minghuan Lian <Minghuan.Lian@freescale.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Mohit KUMAR <mohit.kumar@st.com>
9 years agoPCI: designware: Rename get_msi_data() to get_msi_addr()
Minghuan Lian [Tue, 23 Sep 2014 14:28:58 +0000 (22:28 +0800)]
PCI: designware: Rename get_msi_data() to get_msi_addr()

The struct pcie_host_ops .get_msi_data() method returns the MSI message
address.  To accurately express its purpose, rename it to .get_msi_addr().

Signed-off-by: Minghuan Lian <Minghuan.Lian@freescale.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Mohit KUMAR <mohit.kumar@st.com>
9 years agoPCI: designware: Fix IO resource end address calculation
Minghuan Lian [Tue, 23 Sep 2014 14:28:57 +0000 (22:28 +0800)]
PCI: designware: Fix IO resource end address calculation

End address should be equal to start_addr + size - 1.  Fix PCI IO resource
end address calculation.

Signed-off-by: Minghuan Lian <Minghuan.Lian@freescale.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Mohit KUMAR <mohit.kumar@st.com>
9 years agoPCI: designware: Fix configuration base address when using 'reg'
Minghuan Lian [Tue, 23 Sep 2014 14:28:56 +0000 (22:28 +0800)]
PCI: designware: Fix configuration base address when using 'reg'

The code has calculated cfg0_base and cfg1_base when parsing 'reg' or
'ranges' property of PCI DTS node, so remove duplicate calculation.  When
using 'reg', resource cfg is not used, so this code computed an incorrect
configuration base.

Signed-off-by: Minghuan Lian <Minghuan.Lian@freescale.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Mohit KUMAR <mohit.kumar@st.com>
9 years agox86/PCI: Mark PCI BIOS initialization code as such
Mathias Krause [Mon, 25 Aug 2014 21:26:39 +0000 (23:26 +0200)]
x86/PCI: Mark PCI BIOS initialization code as such

The pci_find_bios() function is only ever called from initialization code,
therefore can be marked as such, too.  This, in turn, allows marking other
functions called only in this context as well.

The bios32_indirect variable can be marked as __initdata as it is only
referenced from __init functions now.

Signed-off-by: Mathias Krause <minipli@googlemail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Ingo Molnar <mingo@kernel.org>
9 years agox86/PCI: Constify pci_mmcfg_probes[] array
Mathias Krause [Mon, 25 Aug 2014 21:26:38 +0000 (23:26 +0200)]
x86/PCI: Constify pci_mmcfg_probes[] array

The pci_mmcfg_probes[] array is only ever read, therefore make it const.

Signed-off-by: Mathias Krause <minipli@googlemail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Ingo Molnar <mingo@kernel.org>
9 years agox86/PCI: Mark constants of pci_mmcfg_nvidia_mcp55() as __initconst
Mathias Krause [Mon, 25 Aug 2014 21:26:37 +0000 (23:26 +0200)]
x86/PCI: Mark constants of pci_mmcfg_nvidia_mcp55() as __initconst

The constants in pci_mmcfg_nvidia_mcp55() need to be marked as __initconst
or they will remain in memory after init memory was released.

Signed-off-by: Mathias Krause <minipli@googlemail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Ingo Molnar <mingo@kernel.org>
9 years agox86/PCI: Move __init annotation to the correct place
Mathias Krause [Mon, 25 Aug 2014 21:26:36 +0000 (23:26 +0200)]
x86/PCI: Move __init annotation to the correct place

According to include/linux/init.h, the __init annotation should be added
immediately before the function name.  However, for quite a few functions
in mmconfig-shared.c this is not the case.  It's either before the return
type or even in the middle of it.  Beside gcc still getting it right, we
should change them to comply to the rules of include/linux/init.h.

Signed-off-by: Mathias Krause <minipli@googlemail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Ingo Molnar <mingo@kernel.org>
9 years agoPCI: pciehp: Stop disabling notifications during init
Yinghai Lu [Sat, 23 Aug 2014 01:15:12 +0000 (18:15 -0700)]
PCI: pciehp: Stop disabling notifications during init

During pciehp initialization, we previously wrote two hotplug commands:

  pciehp_probe
    pcie_init
      pcie_disable_notification
        pcie_write_cmd           # command 1
    pcie_init_notification
      pcie_enable_notification
        pcie_write_cmd           # command 2

For controllers with errata like Intel CF118, we previously waited for a
timeout before issuing the second hotplug command because the first command
only updates interrupt enable bits and is not a "real" hotplug command, so
the controller doesn't report Command Completed for it.

But there's no need to disable notifications in the first place.  If BIOS
left them enabled, we could easily take an interrupt before disabling them,
so there's no benefit in disabling them for the tiny window before we
enable them.

Drop the unnecessary pcie_disable_notification() call.

[bhelgaas: changelog]
Link: http://www.intel.com/content/www/us/en/processors/xeon/xeon-e7-v2-spec-update.html
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoPCI: pciehp: Add more Slot Control debug output
Yinghai Lu [Tue, 23 Sep 2014 02:36:09 +0000 (20:36 -0600)]
PCI: pciehp: Add more Slot Control debug output

Add more Slot Control debug output and move one print after
pcie_write_cmd() to be consistent with other debug output.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoPCI: pciehp: Fix wait time in timeout message
Yinghai Lu [Tue, 23 Sep 2014 02:07:35 +0000 (20:07 -0600)]
PCI: pciehp: Fix wait time in timeout message

When we warned about a timeout on a hotplug command, we previously printed
the time between calls to pcie_write_cmd(), without accounting for any time
spent actually waiting.  Consider this sequence:

  pcie_write_cmd
    write SLTCTL
    cmd_started = jiffies          # T1

  pcie_write_cmd
    pcie_wait_cmd
      now = jiffies                # T2
      wait_event_timeout           # we may wait here
      if (timeout)
        ctrl_info("Timeout on command issued %u msec ago",
                  jiffies_to_msecs(now - cmd_started))

We previously printed (T2 - T1), but that doesn't include the time spent in
wait_event_timeout().

Fix this by using the current jiffies value, not the one cached before
calling wait_event_timeout().

[bhelgaas: changelog, use current jiffies instead of adding timeout]
Fixes: 40b960831cfa ("PCI: pciehp: Compute timeout from hotplug command start time")
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoMerge branch 'pci/hotplug' into next
Bjorn Helgaas [Tue, 23 Sep 2014 16:03:18 +0000 (10:03 -0600)]
Merge branch 'pci/hotplug' into next

* pci/hotplug:
  PCI: pciehp: Prevent NULL dereference during probe
  PCI: pciehp: Reduce PCIe slot_ctrl to 16 bits
  PCI: Configure *all* devices, not just hot-added ones
  PCI: Preserve MPS and MRRS when applying _HPX settings
  PCI: Apply _HPP settings to all hot-added PCI devices
  PCI: Preserve BIOS PCI_COMMAND_SERR and PCI_COMMAND_PARITY settings
  PCI: Apply _HPP settings to PCIe devices as well as PCI and PCI-X
  PCI: Remove unused pci_configure_slot()
  ACPI / hotplug / PCI: Remove pci_configure_slot() usage
  PCI: shpchp: Remove pci_configure_slot() usage
  PCI: pciehp: Remove pci_configure_slot() usage
  PCI: Add pci_configure_device() during enumeration
  PCI: Move pci_configure_slot() to drivers/pci/probe.c
  PCI: Shuffle pci-acpi.c functions to group them logically
  PCI: Whitespace cleanup in pci-acpi.c
  PCI: Move pci_get_hp_params() to drivers/pci/pci-acpi.c
  PCI: pciehp: Configure hot-added display devices
  PCI: Remove "no hotplug settings from platform" warning

9 years agoPCI: Add ACS quirk for Solarflare SFC9120 & SFC9140
Alex Williamson [Wed, 17 Sep 2014 14:59:36 +0000 (08:59 -0600)]
PCI: Add ACS quirk for Solarflare SFC9120 & SFC9140

Solarflare confirms that these devices do not allow peer-to-peer between
functions.  Quirk them to allow IOMMU grouping to expose this isolation.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Robert Stonehouse <rstonehouse@solarflare.com>
9 years agoPCI: designware: Use NULL instead of false
Fabio Estevam [Mon, 22 Sep 2014 20:52:07 +0000 (14:52 -0600)]
PCI: designware: Use NULL instead of false

of_get_address() expects pointers in the third and fourth parameters.

Pass NULL in order to fix the following sparse warnings:

  drivers/pci/host/pcie-designware.c:433:51: warning: Using plain integer as NULL pointer
  drivers/pci/host/pcie-designware.c:433:58: warning: Using plain integer as NULL pointer

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Lucas Stach <l.stach@pengutronix.de>
Acked-by: Jingoo Han <jg1.han@samsung.com>
9 years agoPCI: Remove unused pci_get_dma_source()
Alex Williamson [Wed, 17 Sep 2014 16:41:13 +0000 (10:41 -0600)]
PCI: Remove unused pci_get_dma_source()

pci_get_dma_source() is unused, so remove it.  We now have
dma_alias_devfn() to describe this.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoPCI: Remove unused pci_find_upstream_pcie_bridge()
Alex Williamson [Mon, 22 Sep 2014 20:46:13 +0000 (14:46 -0600)]
PCI: Remove unused pci_find_upstream_pcie_bridge()

pci_find_upstream_pcie_bridge() is unused, so remove it.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoPCI: mvebu: Fix uninitialized variable in mvebu_get_tgt_attr()
Thomas Petazzoni [Wed, 17 Sep 2014 15:58:27 +0000 (17:58 +0200)]
PCI: mvebu: Fix uninitialized variable in mvebu_get_tgt_attr()

Geert Uytterhoeven reported a warning when building pci-mvebu:

  drivers/pci/host/pci-mvebu.c: In function 'mvebu_get_tgt_attr':
  drivers/pci/host/pci-mvebu.c:887:39: warning: 'rtype' may be used uninitialized in this function [-Wmaybe-uninitialized]
     if (slot == PCI_SLOT(devfn) && type == rtype) {
 ^

And indeed, the code of mvebu_get_tgt_attr() may lead to the usage of rtype
when being uninitialized, even though it would only happen if we had
entries other than I/O space and 32 bits memory space.

This commit fixes that by simply skipping the current DT range being
considered, if it doesn't match the resource type we're looking for.

Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: stable@vger.kernel.org # v3.12+
9 years agox86/PCI: Mark DMI tables as initialization data
Mathias Krause [Mon, 25 Aug 2014 21:26:35 +0000 (23:26 +0200)]
x86/PCI: Mark DMI tables as initialization data

The DMI tables are only used in __init code, thereby can be marked as
initialization data, too.  The same is true for the callback functions
referenced from the DMI tables.

This moves ~9.6 kB of code and r/o data to the init sections, marking the
memory for release after initialization.

Signed-off-by: Mathias Krause <minipli@googlemail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Ingo Molnar <mingo@kernel.org>
9 years agoPCI: spear: Pass config resource through reg property
Pratyush Anand [Wed, 3 Sep 2014 05:20:49 +0000 (10:50 +0530)]
PCI: spear: Pass config resource through reg property

PCIe configuration space should be passed through reg property, rather than
through ranges property.  This patch does the correction for SPEAr13XX
SOCs.

Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Mohit Kumar <mohit.kumar@st.com>
9 years agoPCI: Generate uppercase hex for modalias interface class
Ricardo Ribalda Delgado [Wed, 27 Aug 2014 12:57:57 +0000 (14:57 +0200)]
PCI: Generate uppercase hex for modalias interface class

Some implementations of modprobe fail to load the driver for a PCI device
automatically because the "interface" part of the modalias from the kernel
is lowercase, and the modalias from file2alias is uppercase.

The "interface" is the low-order byte of the Class Code, defined in PCI
r3.0, Appendix D.  Most interface types defined in the spec do not use
alpha characters, so they won't be affected.  For example, 00h, 01h, 10h,
20h, etc. are unaffected.

Print the "interface" byte of the Class Code in uppercase hex, as we
already do for the Vendor ID, Device ID, Class, etc.

[bhelgaas: changelog]
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
CC: stable@vger.kernel.org
9 years agoMerge branches 'pci/host-designware', 'pci/host-imx6', 'pci/host-keystone', 'pci...
Bjorn Helgaas [Mon, 22 Sep 2014 18:31:10 +0000 (12:31 -0600)]
Merge branches 'pci/host-designware', 'pci/host-imx6', 'pci/host-keystone', 'pci/host-tegra' and 'pci/host-xilinx' into next

* pci/host-designware:
  PCI: designware: Fold struct pcie_port_info into struct pcie_port

* pci/host-imx6:
  PCI: imx6: Delay enabling reference clock for SS until it stabilizes

* pci/host-keystone:
  PCI: keystone: Set device ID based on SoC to support multiple ports
  PCI: keystone: Assume controller is already in RC mode
  PCI: keystone: Limit MRSS for all downstream devices

* pci/host-tegra:
  PCI: tegra: Add Tegra124 support
  PCI: tegra: Make sure the PCIe PLL is really reset
  PCI: tegra: Fix extended configuration space mapping
  PCI: tegra: Clear CLKREQ# enable on port disable

* pci/host-xilinx:
  PCI: xilinx: Fix xilinx_pcie_assign_msi() return value test

9 years agoMerge branches 'pci/enumeration', 'pci/misc' and 'pci/virtualization' into next
Bjorn Helgaas [Mon, 22 Sep 2014 18:31:01 +0000 (12:31 -0600)]
Merge branches 'pci/enumeration', 'pci/misc' and 'pci/virtualization' into next

* pci/enumeration:
  PCI: Enable CRS Software Visibility for root port if it is supported
  PCI: Check only the Vendor ID to identify Configuration Request Retry

* pci/misc:
  PCI: Parenthesize PCI_DEVID and PCI_VPD_LRDT_ID parameters
  PCI: Increase IBM ipr SAS Crocodile BARs to at least system page size
  PCI/AER: Make <linux/aer.h> standalone includable

* pci/virtualization:
  PCI: Use device flag helper functions
  xen/pciback: Use PCI device flag helper functions
  KVM: Use PCI device flag helper functions
  PCI: Add device flag helper functions
  PCI: Assume all Mellanox devices have broken INTx masking

9 years agoPCI: xilinx: Fix xilinx_pcie_assign_msi() return value test
Dan Carpenter [Tue, 9 Sep 2014 12:11:50 +0000 (15:11 +0300)]
PCI: xilinx: Fix xilinx_pcie_assign_msi() return value test

We should be testing "hwirq" instead of "irq".  "irq" is unsigned so it's
never less than zero.  Also it's uninitialized.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Srikanth Thokala <sthokal@xilinx.com>
9 years agoPCI: Parenthesize PCI_DEVID and PCI_VPD_LRDT_ID parameters
Megan Kamiya [Sat, 6 Sep 2014 03:19:10 +0000 (20:19 -0700)]
PCI: Parenthesize PCI_DEVID and PCI_VPD_LRDT_ID parameters

Add parentheses around parameters in PCI_DEVID and PCI_VPD_LRDT_ID macros
to prevent possible expansion errors as described by the CERT Secure Coding
Standard: PRE01-C: Use parentheses within macros around parameter names

Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Megan Kamiya <megan.a.kamiya@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoPCI: tegra: Add Tegra124 support
Thierry Reding [Tue, 26 Aug 2014 15:11:38 +0000 (17:11 +0200)]
PCI: tegra: Add Tegra124 support

The PCIe controller on Tegra124 has two root ports that can be used in a
x4/x1 or x2/x1 configuration and can run at PCIe 2.0 link speeds (up to
5 GT/s).  The PHY programming has been moved into a separate controller, so
the driver now needs to request an external PHY referenced using the device
tree.

Tested-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoPCI: tegra: Make sure the PCIe PLL is really reset
Eric Yuen [Tue, 26 Aug 2014 15:11:37 +0000 (17:11 +0200)]
PCI: tegra: Make sure the PCIe PLL is really reset

Depending on the prior state of the controller, the PLL reset may not be
pulsed.  Clear the register bit and set it after a small delay to ensure
that the PLL is really reset.

Tested-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Eric Yuen <eyuen@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoPCI: tegra: Fix extended configuration space mapping
Peter Daifuku [Tue, 26 Aug 2014 15:11:36 +0000 (17:11 +0200)]
PCI: tegra: Fix extended configuration space mapping

The 16 chunks of 64 KiB that need to be stitched together to make up the
configuration space for one bus (1 MiB) are located 24 bits (== 16 MiB)
apart in physical address space.  This is determined by the start of the
extended register field (bits 24-27) in the physical mapping.

Tested-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Peter Daifuku <pdaifuku@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoPCI: tegra: Clear CLKREQ# enable on port disable
Thierry Reding [Tue, 26 Aug 2014 15:11:35 +0000 (17:11 +0200)]
PCI: tegra: Clear CLKREQ# enable on port disable

When a root port is disabled, disable the CLKREQ# signal if available.

Tested-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoPCI: Increase IBM ipr SAS Crocodile BARs to at least system page size
Douglas Lehr [Wed, 20 Aug 2014 23:26:52 +0000 (09:26 +1000)]
PCI: Increase IBM ipr SAS Crocodile BARs to at least system page size

The Crocodile chip occasionally comes up with 4k and 8k BAR sizes.  Due to
an erratum, setting the SR-IOV page size causes the physical function BARs
to expand to the system page size.  Since ppc64 uses 64k pages, when Linux
tries to assign the smaller resource sizes to the now 64k BARs the address
will be truncated and the BARs will overlap.

Force Linux to allocate the resource as a full page, which avoids the
overlap.

[bhelgaas: print expanded resource, too]
Signed-off-by: Douglas Lehr <dllehr@us.ibm.com>
Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Milton Miller <miltonm@us.ibm.com>
CC: stable@vger.kernel.org
9 years agoPCI/AER: Make <linux/aer.h> standalone includable
Thierry Reding [Tue, 5 Aug 2014 12:08:55 +0000 (14:08 +0200)]
PCI/AER: Make <linux/aer.h> standalone includable

The header file references u16 and u32 types, but they are not defined in
the header nor does the header pull in the necessary includes for them.
This causes build breakage when the file is included without any of the
dependencies being satisfied from somewhere else.

Fix this by including linux/types.h (for u16 and u32).

[bhelgaas: removed pci_dev declaration (already added by 5ccb8225abf2)]
Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoPCI: Use device flag helper functions
Ethan Zhao [Tue, 9 Sep 2014 02:21:28 +0000 (10:21 +0800)]
PCI: Use device flag helper functions

Use PCI device flag helper functions when checking whether a device is
assigned.  No functional change.

Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoxen/pciback: Use PCI device flag helper functions
Ethan Zhao [Tue, 9 Sep 2014 02:21:27 +0000 (10:21 +0800)]
xen/pciback: Use PCI device flag helper functions

Use PCI device flag helper functions when assigning or releasing device.
No functional change.

Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: David Vrabel <david.vrabel@citrix.com>
9 years agoKVM: Use PCI device flag helper functions
Ethan Zhao [Tue, 9 Sep 2014 02:21:26 +0000 (10:21 +0800)]
KVM: Use PCI device flag helper functions

Use PCI device flag helper functions when assigning or releasing device.
No functional change.

Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9 years agoPCI: Add device flag helper functions
Ethan Zhao [Tue, 9 Sep 2014 02:21:25 +0000 (10:21 +0800)]
PCI: Add device flag helper functions

Add helper functions to hide direct device flag operations:

    void pci_set_dev_assigned(struct pci_dev *dev);
    void pci_clear_dev_assigned(struct pci_dev *dev);
    bool pci_is_dev_assigned(struct pci_dev *dev);

Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoPCI: keystone: Set device ID based on SoC to support multiple ports
Murali Karicheri [Wed, 10 Sep 2014 17:12:39 +0000 (13:12 -0400)]
PCI: keystone: Set device ID based on SoC to support multiple ports

K2E SoC has two PCI ports.  The SATA controller is connected to second PCI
port (port 1).  To support multiple port handling in Keystone PCI driver,
read the PCI device ID dynamically by iomap/read/unmap during probe and
save it in driver's private data and update it in host init code.  The PCI
device ID field in the RC's config space is not filled by default by the
hardware and has to be updated by the PCI driver by reading the same from
the SoC register indicated by reg index #2 in DT bindings.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoPCI: keystone: Assume controller is already in RC mode
Murali Karicheri [Wed, 10 Sep 2014 17:12:38 +0000 (13:12 -0400)]
PCI: keystone: Assume controller is already in RC mode

Keystone PCI hardware supports both RC and EP modes and devcfg register has
bits to boot strap the device to either of these modes.  It seems proper to
add this functionality to the boot loader rather than in the driver as
device will be operating in either mode, not both any time.  Currently the
driver supports only RC mode and hence register configuration in the driver
is not needed and the driver can assume the hardware is in RC mode.

Also update the DT documentation accordingly.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
9 years agoPCI: keystone: Limit MRSS for all downstream devices
Murali Karicheri [Mon, 8 Sep 2014 17:03:34 +0000 (13:03 -0400)]
PCI: keystone: Limit MRSS for all downstream devices

Keystone PCIe controller has a limitation that memory read request size
must not exceed 256 bytes.  This is a hardware limitation.  Add a quirk to
force this limit on all downstream devices by updating MRRS.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoPCI: pciehp: Prevent NULL dereference during probe
Andreas Noever [Tue, 16 Sep 2014 21:16:02 +0000 (15:16 -0600)]
PCI: pciehp: Prevent NULL dereference during probe

pciehp assumes that dev->subordinate, the struct pci_bus for a bridge's
secondary bus, exists.  But we do not create that bus if we run out of bus
numbers during enumeration.  This leads to a NULL dereference in
init_slot() (and other places).

Change pciehp_probe() to return -ENODEV when no secondary bus is present.

Signed-off-by: Andreas Noever <andreas.noever@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: stable@vger.kernel.org # v3.2+
9 years agoPCI: pciehp: Reduce PCIe slot_ctrl to 16 bits
Bjorn Helgaas [Fri, 15 Aug 2014 23:18:44 +0000 (17:18 -0600)]
PCI: pciehp: Reduce PCIe slot_ctrl to 16 bits

4283c70e91dc ("PCI: pciehp: Make pcie_wait_cmd() self-contained") added
a cache of the most recent command written to the Slot Control register.
This register is only 16 bits wide, but the cache ("slot_ctrl") is 32 bits.

Reduce slot_ctrl to a u16 so it matches the register size.  No functional
change.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoPCI: Configure *all* devices, not just hot-added ones
Bjorn Helgaas [Sat, 30 Aug 2014 13:23:01 +0000 (07:23 -0600)]
PCI: Configure *all* devices, not just hot-added ones

There's not really a good way to determine whether firmware has already
configured a device with _HPP/_HPX settings.  On legacy systems, the BIOS
has probably configured everything, but on UEFI systems it is not required
to do so.

Per the PCI Firmware Specification, rev 3.1, sec 3.5, if PCI_COMMAND_IO or
PCI_COMMAND_MEMORY is set, we can assume firmware has set the corresponding
BARs and maybe we can assume it has configured the rest of the device.  And
if a bridge has PCI_COMMAND_PARITY or PCI_COMMAND_SERR set, we can assume
firmware has configured the bridge.  But we can't tell much about devices
without BARs.

I think it should be safe to apply _HPP and _HPX settings anyway, even if
firmware has already configured the device, so configure everything we
find.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Yinghai Lu <yinghai@kernel.org>
9 years agoPCI: Preserve MPS and MRRS when applying _HPX settings
Bjorn Helgaas [Wed, 3 Sep 2014 19:26:29 +0000 (13:26 -0600)]
PCI: Preserve MPS and MRRS when applying _HPX settings

Linux manages MPS and MRRS settings to keep them consistent across the PCIe
fabric.  BIOS doesn't participate in this Linux management, so ignore that
part of any _HPX settings it supplies.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Yinghai Lu <yinghai@kernel.org>
9 years agoPCI: Apply _HPP settings to all hot-added PCI devices
Bjorn Helgaas [Sat, 30 Aug 2014 13:22:13 +0000 (07:22 -0600)]
PCI: Apply _HPP settings to all hot-added PCI devices

We currently apply _HPP settings only to:

    - non-bridge devices, and
    - PCI-to-PCI bridges

i.e., we do not apply them to PCI-to-ISA bridges and the like.  It has been
that way since _HPP support was added by 40abb96c51bb ("pciehp: Fix
programming hotplug parameters"), but I don't think there's any reason to
exclude these other bridges.

Apply _HPP settings to hot-added PCI devices of any type.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Yinghai Lu <yinghai@kernel.org>
9 years agoPCI: Preserve BIOS PCI_COMMAND_SERR and PCI_COMMAND_PARITY settings
Bjorn Helgaas [Wed, 27 Aug 2014 20:38:14 +0000 (14:38 -0600)]
PCI: Preserve BIOS PCI_COMMAND_SERR and PCI_COMMAND_PARITY settings

Do not clear PCI_COMMAND_SERR or PCI_COMMAND_PARITY based on _HPP.  The
spec (ACPI rev 5.0, sec 6.2.7) says that when "Enable SERR" is set to 1,
we should enable SERR in the command register.  It says nothing about
*disabling* SERR or PERR; in fact, the example in 6.2.7.1 says we should
leave PERR alone unless "Enable PERR" is 1.

For hot-added devices, this probably doesn't matter because they power up
with these bits cleared.  But in addition to hot-plugged devices, the spec
allows the platform to use _HPP for "configuration of PCI devices not
configured by the BIOS at system boot," and it may make a difference for
devices present at boot.

This change means that if BIOS enables SERR or PERR on a device, and it
supplies _HPP or _HPX with the SERR or PERR bits *cleared*, we will now
leave SERR or PERR reporting enabled on that device instead of disabling it
as we previously did.

See also 40abb96c51bb ("pciehp: Fix programming hotplug parameters"), where
this code was first added.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Yinghai Lu <yinghai@kernel.org>
9 years agoPCI: Apply _HPP settings to PCIe devices as well as PCI and PCI-X
Bjorn Helgaas [Sat, 30 Aug 2014 00:10:19 +0000 (18:10 -0600)]
PCI: Apply _HPP settings to PCIe devices as well as PCI and PCI-X

The ACPI _HPP method was defined before PCIe existed, so its documentation
only mentions PCI.  The _HPX Type 0 setting record is essentially identical
to _HPP, but the spec (ACPI rev 5.0, sec 6.2.8.1) says it should be applied
to PCI, PCI-X, and PCIe devices, with settings being ignored if they are
not applicable.

Some platforms with both conventional PCI and PCIe devices provide only
_HPP (not _HPX), so treat _HPP the same way as an _HPX Type 0 record and
apply it to PCIe devices as well as PCI and PCI-X.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Yinghai Lu <yinghai@kernel.org>
9 years agoPCI: Remove unused pci_configure_slot()
Bjorn Helgaas [Thu, 28 Aug 2014 18:21:44 +0000 (12:21 -0600)]
PCI: Remove unused pci_configure_slot()

All pci_configure_slot() uses have been removed, so remove the definition
as well.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Yinghai Lu <yinghai@kernel.org>
9 years agoACPI / hotplug / PCI: Remove pci_configure_slot() usage
Bjorn Helgaas [Thu, 28 Aug 2014 17:59:41 +0000 (11:59 -0600)]
ACPI / hotplug / PCI: Remove pci_configure_slot() usage

We now configure each PCI device as it is enumerated, in pci_device_add(),
so remove the configuration done in acpiphp.

That configuration, in pci_configure_device(), does not include the
MPS/MRRS configuration done by pcie_bus_configure_settings(), so keep
that here.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Yinghai Lu <yinghai@kernel.org>
9 years agoPCI: shpchp: Remove pci_configure_slot() usage
Bjorn Helgaas [Thu, 28 Aug 2014 18:18:37 +0000 (12:18 -0600)]
PCI: shpchp: Remove pci_configure_slot() usage

We now configure each PCI device as it is enumerated, in pci_device_add(),
so remove the configuration done in shpchp.

That configuration, in pci_configure_device(), does not include the
MPS/MRRS configuration done by pcie_bus_configure_settings(), so keep
that here.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Yinghai Lu <yinghai@kernel.org>
9 years agoPCI: pciehp: Remove pci_configure_slot() usage
Bjorn Helgaas [Thu, 28 Aug 2014 18:13:51 +0000 (12:13 -0600)]
PCI: pciehp: Remove pci_configure_slot() usage

We now configure each PCI device as it is enumerated, in pci_device_add(),
so remove the configuration done in pciehp.

That configuration, in pci_configure_device(), does not include the
MPS/MRRS configuration done by pcie_bus_configure_settings(), so keep
that here.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Yinghai Lu <yinghai@kernel.org>
9 years agoPCI: Add pci_configure_device() during enumeration
Bjorn Helgaas [Wed, 27 Aug 2014 20:29:47 +0000 (14:29 -0600)]
PCI: Add pci_configure_device() during enumeration

Some platforms can tell the OS how to configure PCI devices, e.g., how to
set cache line size, error reporting enables, etc.  ACPI defines _HPP and
_HPX methods for this purpose.

This configuration was previously done by some of the hotplug drivers using
pci_configure_slot().  But not all hotplug drivers did this, and per the
spec (ACPI rev 5.0, sec 6.2.7), we can also do it for "devices not
configured by the BIOS at system boot."

Move this configuration into the PCI core by adding pci_configure_device()
and calling it from pci_device_add(), so we do this for all devices as we
enumerate them.

This is based on pci_configure_slot(), which is used by hotplug drivers.
I omitted:

  - pcie_bus_configure_settings() because it configures MPS and MRRS, which
    requires global knowledge of the fabric and must be done later, and

  - configuration of subordinate devices; that will happen when we call
    pci_device_add() for those devices.

Because pci_configure_slot() was only done by hotplug drivers, this initial
version of pci_configure_device() only configures hot-added devices,
ignoring anything added during boot.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Yinghai Lu <yinghai@kernel.org>
9 years agoPCI: Move pci_configure_slot() to drivers/pci/probe.c
Bjorn Helgaas [Sat, 13 Sep 2014 02:02:00 +0000 (20:02 -0600)]
PCI: Move pci_configure_slot() to drivers/pci/probe.c

Move pci_configure_slot() and related functions from
drivers/pci/hotplug/pcihp_slot to drivers/pci/probe.c.

This is to prepare for doing device configuration during the normal
enumeration process instead of just after hot-add.

No functional change.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoPCI: Shuffle pci-acpi.c functions to group them logically
Bjorn Helgaas [Fri, 12 Sep 2014 21:36:29 +0000 (15:36 -0600)]
PCI: Shuffle pci-acpi.c functions to group them logically

Move code around to put all the ACPI power management stuff together and
all the pieces related to ACPI methods (_CBA, _HPP, _HPX) together.

No functional change.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoPCI: Whitespace cleanup in pci-acpi.c
Bjorn Helgaas [Fri, 12 Sep 2014 21:29:55 +0000 (15:29 -0600)]
PCI: Whitespace cleanup in pci-acpi.c

Whitespace fixes only; no functional change.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoPCI: Move pci_get_hp_params() to drivers/pci/pci-acpi.c
Bjorn Helgaas [Fri, 12 Sep 2014 21:23:14 +0000 (15:23 -0600)]
PCI: Move pci_get_hp_params() to drivers/pci/pci-acpi.c

Move pci_get_hp_params() and related functions from
drivers/pci/hotplug/acpi_pcihp.c to drivers/pci/pci-acpi.c.

Previously, pci_get_hp_params() was used only by hotplug drivers.  But
future changes will move this into the normal device enumeration process,
so it will be used even when CONFIG_HOTPLUG_PCI is not set.

No functional change.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
9 years agoPCI: pciehp: Configure hot-added display devices
Bjorn Helgaas [Thu, 28 Aug 2014 17:12:50 +0000 (11:12 -0600)]
PCI: pciehp: Configure hot-added display devices

We configure cache line size and other settings of hot-added devices, e.g.,
based on ACPI _HPP or _HPX methods.  Previously we skipped this for display
devices, but ACPI rev 5.0, sec 6.2.7 and 6.2.8 have no requirement to skip
them.

Remove the check so we configure display devices the same way we configure
other devices.

See also ac81860ea073 ("PCI: hotplug: pciehp: Removed check for hotplug of
display devices").

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Yinghai Lu <yinghai@kernel.org>