Bjorn Helgaas [Wed, 8 Jan 2014 00:34:39 +0000 (17:34 -0700)]
Merge branch 'pci/msi' into next
* pci/msi:
PCI/MSI: Add pci_enable_msi_range() and pci_enable_msix_range()
PCI/MSI: Add pci_msix_vec_count()
PCI/MSI: Remove pci_enable_msi_block_auto()
PCI/MSI: Add pci_msi_vec_count()
Bjorn Helgaas [Wed, 8 Jan 2014 00:34:33 +0000 (17:34 -0700)]
Merge branch 'pci/misc' into next
* pci/misc:
PCI: Update documentation 00-INDEX file
PCI: Convert ioapic to be builtin only, not modular
Bjorn Helgaas [Wed, 8 Jan 2014 00:34:14 +0000 (17:34 -0700)]
Merge branch 'pci/host-mvebu' into next
* pci/host-mvebu:
PCI: mvebu: Use max_t() instead of max(resource_size_t,)
PCI: mvebu: Call pci_ioremap_io() at startup instead of dynamically
Bjorn Helgaas [Wed, 8 Jan 2014 00:34:06 +0000 (17:34 -0700)]
Merge branch 'pci/host-designware' into next
* pci/host-designware:
PCI: designware: Fix indent code style
Erik Ekman [Wed, 1 Jan 2014 21:15:25 +0000 (22:15 +0100)]
PCI: Update documentation 00-INDEX file
The PCI-DMA-mapping.txt moved to general docs and became DMA-API-HOWTO.txt
in
5e07c2c7301b ("Documentation: rename PCI/PCI-DMA-mapping.txt to
DMA-API-HOWTO.txt"). Add new file about PCI Express I/O Virtualization.
Signed-off-by: Erik Ekman <erik@kryo.se>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Alexander Gordeev [Mon, 30 Dec 2013 07:28:16 +0000 (08:28 +0100)]
PCI/MSI: Add pci_enable_msi_range() and pci_enable_msix_range()
This adds pci_enable_msi_range(), which supersedes the pci_enable_msi()
and pci_enable_msi_block() MSI interfaces.
It also adds pci_enable_msix_range(), which supersedes the
pci_enable_msix() MSI-X interface.
The old interfaces have three categories of return values:
negative: failure; caller should not retry
positive: failure; value indicates number of interrupts that *could*
have been allocated, and caller may retry with a smaller request
zero: success; at least as many interrupts allocated as requested
It is error-prone to handle these three cases correctly in drivers.
The new functions return either a negative error code or a number of
successfully allocated MSI/MSI-X interrupts, which is expected to lead to
clearer device driver code.
pci_enable_msi(), pci_enable_msi_block() and pci_enable_msix() still exist
unchanged, but are deprecated and may be removed after callers are updated.
[bhelgaas: tweak changelog]
Suggested-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Tejun Heo <tj@kernel.org>
Alexander Gordeev [Mon, 30 Dec 2013 07:28:15 +0000 (08:28 +0100)]
PCI/MSI: Add pci_msix_vec_count()
This creates an MSI-X counterpart for pci_msi_vec_count(). Device drivers
can use this function to obtain maximum number of MSI-X interrupts the
device supports and use that number in a subsequent call to
pci_enable_msix().
pci_msix_vec_count() supersedes pci_msix_table_size() and returns a
negative errno if device does not support MSI-X interrupts. After this
update, callers must always check the returned value.
The only user of pci_msix_table_size() was the PCI-Express port driver,
which is also updated by this change.
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Tejun Heo <tj@kernel.org>
Alexander Gordeev [Mon, 30 Dec 2013 07:28:14 +0000 (08:28 +0100)]
PCI/MSI: Remove pci_enable_msi_block_auto()
The new pci_msi_vec_count() interface makes pci_enable_msi_block_auto()
superfluous.
Drivers can use pci_msi_vec_count() to learn the maximum number of MSIs
supported by the device, and then call pci_enable_msi_block().
pci_enable_msi_block_auto() was introduced recently, and its only user is
the AHCI driver, which is also updated by this change.
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Tejun Heo <tj@kernel.org>
Alexander Gordeev [Mon, 30 Dec 2013 07:28:13 +0000 (08:28 +0100)]
PCI/MSI: Add pci_msi_vec_count()
Device drivers can use this interface to obtain the maximum number of MSI
interrupts the device supports and use that number, e.g., in a subsequent
call to pci_enable_msi_block().
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Tejun Heo <tj@kernel.org>
Yinghai Lu [Fri, 3 Jan 2014 00:05:57 +0000 (16:05 -0800)]
PCI: Convert ioapic to be builtin only, not modular
Convert pci/ioapic.c to be builtin only, with no module option, so we can
support IO-APIC hotplug. Also make it depend on X86_IO_APIC.
[bhelgaas: changelog]
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Jingoo Han [Fri, 27 Dec 2013 00:30:25 +0000 (09:30 +0900)]
PCI: designware: Fix indent code style
Fix indent code style and replace 'MSI interrupt controller' of comment
with 'MSI controller' to fix the following checkpatch issues:
ERROR: code indent should use tabs where possible
WARNING: please, no spaces at the start of a line
WARNING: line over 80 characters
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Jingoo Han [Fri, 27 Dec 2013 00:34:36 +0000 (09:34 +0900)]
PCI: mvebu: Use max_t() instead of max(resource_size_t,)
Use max_t() instead of max(resource_size_t,) in order to fix
the following checkpatch warning.
WARNING: max() should probably be max_t(resource_size_t, SZ_64K, size)
WARNING: max() should probably be max_t(resource_size_t, SZ_1M, size)
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Jason Cooper <jason@lakedaemon.net>
Thomas Petazzoni [Thu, 26 Dec 2013 15:52:41 +0000 (16:52 +0100)]
PCI: mvebu: Call pci_ioremap_io() at startup instead of dynamically
The mvebu PCI host controller driver uses an emulated PCI-to-PCI bridge to
leverage the core PCI kernel enumeration logic to dynamically create and
remove the MBus windows needed to access the memory and I/O regions of each
PCI interface.
In the context of this PCI-to-PCI bridge emulation, the driver emulates
all reads and writes to the PCI bridge registers. Upon a write to the
registers configuring the I/O base and limit, the driver was creating the
MBus window and calling pci_ioremap_io() to setup the mapping.
However, it turns out that accesses to these registers are made in an IRQ
disabled context, while pci_ioremap_io() is a potentially sleeping
function. Not only this is wrong, but it is causing fairly loud warnings
at boot time when the appropriate kernel hacking options are enabled.
This patch solves this by moving the pci_ioremap_io() call to the startup
of the driver. At this point, we don't know how many PCI interfaces will
be enabled, so we are simply remapping the entire PCI I/O space to virtual
addresses. This is reasonable since this I/O space is limited to 1 MB in
size, and also because the MBus windows continue to be created in a dynamic
fashion only when devices need them.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Bjorn Helgaas [Fri, 20 Dec 2013 19:51:52 +0000 (12:51 -0700)]
Merge branch 'pci/misc' into next
* pci/misc:
PCI/checkpatch: Deprecate DEFINE_PCI_DEVICE_TABLE
Bjorn Helgaas [Fri, 20 Dec 2013 19:41:40 +0000 (12:41 -0700)]
Merge branch 'pci/msi' into next
* pci/msi:
PCI/MSI: Make pci_enable_msi/msix() 'nvec' argument type as int
PCI/MSI: Return -ENOSYS for unimplemented interfaces, not -1
PCI/MSI: Return msix_capability_init() failure if populate_msi_sysfs() fails
s390/PCI: Remove superfluous check of MSI type
s390/PCI: Fix single MSI only check
PCI/MSI: Export MSI mode using attributes, not kobjects
Bjorn Helgaas [Fri, 20 Dec 2013 19:41:18 +0000 (12:41 -0700)]
Merge branch 'pci/deletion' into next
* pci/deletion:
PCI/portdrv: Remove extra get_device()/put_device() for pcie_device
PCI/portdrv: Add put_device() after device_register() failure
PCI/portdrv: Cleanup error paths
Bjorn Helgaas [Fri, 20 Dec 2013 19:41:01 +0000 (12:41 -0700)]
Merge branch 'pci/host-designware' into next
* pci/host-designware:
PCI: designware: Fix I/O transfers by using CPU (not realio) address
PCI: designware: Add dw_pcie prefix before cfg_read/write
PCI: designware: Fix missing MSI IRQs
Bjorn Helgaas [Fri, 20 Dec 2013 19:40:54 +0000 (12:40 -0700)]
Merge branch 'pci/host-mvebu' into next
* pci/host-mvebu:
PCI: mvebu: Remove redundant of_match_ptr
Bjorn Helgaas [Fri, 20 Dec 2013 19:38:07 +0000 (12:38 -0700)]
Merge branch 'pci/host-imx6' into next
* pci/host-imx6:
PCI: imx6: Fix bugs in PCIe startup code
PCI: imx6: Start link in Gen1 before negotiating for Gen2 mode
PCI: imx6: Factor out link up wait loop
PCI: imx6: Factor out PHY reset
PCI: imx6: Report "link up" only after link training completes
PCI: imx6: Make reset-gpio optional
Alexander Gordeev [Mon, 16 Dec 2013 08:34:58 +0000 (09:34 +0100)]
PCI/MSI: Make pci_enable_msi/msix() 'nvec' argument type as int
Make pci_enable_msi_block(), pci_enable_msi_block_auto() and
pci_enable_msix() consistent with regard to the type of 'nvec' argument.
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Tejun Heo <tj@kernel.org>
Alexander Gordeev [Mon, 16 Dec 2013 08:34:57 +0000 (09:34 +0100)]
PCI/MSI: Return -ENOSYS for unimplemented interfaces, not -1
Suggested-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Tejun Heo <tj@kernel.org>
Alexander Gordeev [Mon, 16 Dec 2013 08:34:56 +0000 (09:34 +0100)]
PCI/MSI: Return msix_capability_init() failure if populate_msi_sysfs() fails
If populate_msi_sysfs() function failed msix_capability_init() must return
the error code, but it returns the success instead. This update fixes the
described misbehaviour.
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Tejun Heo <tj@kernel.org>
Alexander Gordeev [Mon, 16 Dec 2013 08:34:55 +0000 (09:34 +0100)]
s390/PCI: Remove superfluous check of MSI type
arch_setup_msi_irqs() hook can only be called from the generic MSI code
which ensures correct MSI type parameter.
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Alexander Gordeev [Mon, 16 Dec 2013 08:34:54 +0000 (09:34 +0100)]
s390/PCI: Fix single MSI only check
Multiple MSIs have never been supported on s390 architecture, but the
platform code fails to report single MSI only.
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Pratyush Anand [Wed, 11 Dec 2013 09:38:33 +0000 (15:08 +0530)]
PCI: designware: Fix I/O transfers by using CPU (not realio) address
pp->io_base, which is the input of the outbound IO address translation
unit, should be the CPU address. It was incorrectly programmed to the
realio address.
We should pass global_io_offset rather than sys->io_offset to
pci_ioremap_io(), so we map the new window into the first available spot in
the Linux view of the I/O space.
We must also pass CPU address instead of realio address to pci_ioremap_io().
This patch fixes above issue. It has been tested with Lecroy PTC in AIC
mode and Pericom PI7C9X2G303EL PCIe switch, which does not work otherwise.
Tested-by: Mohit Kumar <mohit.kumar@st.com>
Tested-by: Tim Harvey <tharvey@gateworks.com>
Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Marek Vasut <marex@denx.de
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Jingoo Han <jg1.han@samsung.com>
Cc: Richard Zhu <Hong-Xing.Zhu@freescale.com>
Pratyush Anand [Wed, 11 Dec 2013 09:38:32 +0000 (15:08 +0530)]
PCI: designware: Add dw_pcie prefix before cfg_read/write
The cfg_read/write functions are DesignWare-specific. Add dw_pcie prefix
to avoid collision in global name space.
Tested-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
Acked-by: Jingoo Han <jg1.han@samsung.com>
Harro Haan [Thu, 12 Dec 2013 18:29:03 +0000 (19:29 +0100)]
PCI: designware: Fix missing MSI IRQs
The interrupts were cleared after the IRQ handler was called. This means
that new interrupts that occur after the handler handled the previous IRQ
but before the interrupt is cleared will be missed.
Tested-by: Marek Vasut <marex@denx.de>
Tested-by: Matthias Mann <m.mann@arkona-technologies.de>
Signed-off-by: Harro Haan <hrhaan@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Jingoo Han <jg1.han@samsung.com>
Acked-by: Mohit Kumar <mohit.kumar@st.com>
Cc: Richard Zhu <hong-xing.zhu@freescale.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
Cc: Pratyush Anand <pratyush.anand@st.com>
Cc: Tim Harvey <tharvey@gateworks.com>
Cc: Juergen Beisert <jbe@pengutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Siva Reddy Kallam <siva.kallam@samsung.com>
Cc: Srikanth T Shivanand <ts.srikanth@samsung.com>
Cc: Sean Cross <xobs@kosagi.com>
Greg Kroah-Hartman [Thu, 19 Dec 2013 20:30:17 +0000 (12:30 -0800)]
PCI/MSI: Export MSI mode using attributes, not kobjects
The PCI MSI sysfs code is a mess with kobjects for things that don't really
need to be kobjects. This patch creates attributes dynamically for the MSI
interrupts instead of using kobjects.
Note, this removes a directory from sysfs. Old MSI kobjects:
pci_device
└── msi_irqs
└── 40
└── mode
New MSI attributes:
pci_device
└── msi_irqs
└── 40
As there was only one file "mode" with the kobject model, the interrupt
number is now a file that returns the "mode" of the interrupt (msi vs.
msix).
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Bjorn Helgaas [Thu, 19 Dec 2013 21:24:13 +0000 (14:24 -0700)]
PCI/portdrv: Remove extra get_device()/put_device() for pcie_device
Previously pcie_device_init() called get_device() if device_register() for
the new pcie_device succeeded, and remove_iter() called put_device() when
removing before unregistering the device.
But device_register() already increments the reference count in
device_add(), so we don't need to do it again here.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Levente Kurusa [Thu, 19 Dec 2013 21:22:35 +0000 (14:22 -0700)]
PCI/portdrv: Add put_device() after device_register() failure
This is required so that we give up the last reference to the device.
Removed the kfree() as put_device will result in release_pcie_device()
being called and hence the container of the device will be kfree'd.
[bhelgaas: fix conflict after my previous cleanup]
Signed-off-by: Levente Kurusa <levex@linux.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Bjorn Helgaas [Thu, 19 Dec 2013 21:20:09 +0000 (14:20 -0700)]
PCI/portdrv: Cleanup error paths
Make the straightline path the normal no-error path. Check for errors and
return them directly, instead of checking for success and putting the
normal path in an "if" body.
No functional change.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Sachin Kamat [Thu, 19 Dec 2013 09:04:59 +0000 (14:34 +0530)]
PCI: mvebu: Remove redundant of_match_ptr
mvebu_pcie_of_match_table is always compiled in. Hence of_match_ptr is not
required.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Richard Zhu [Thu, 12 Dec 2013 21:50:03 +0000 (22:50 +0100)]
PCI: imx6: Fix bugs in PCIe startup code
LTSSM shouldn't be set once in assert_core_reset(). Move peripheral reset
just before LTSSM start.
Signed-off-by: Richard Zhu <r65037@freescale.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
Cc: Frank Li <lznuaa@gmail.com>
Cc: Harro Haan <hrhaan@gmail.com>
Cc: Jingoo Han <jg1.han@samsung.com>
Cc: Mohit KUMAR <Mohit.KUMAR@st.com>
Cc: Pratyush Anand <pratyush.anand@st.com>
Cc: Richard Zhu <r65037@freescale.com>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Sean Cross <xobs@kosagi.com>
Cc: Siva Reddy Kallam <siva.kallam@samsung.com>
Cc: Srikanth T Shivanand <ts.srikanth@samsung.com>
Cc: Tim Harvey <tharvey@gateworks.com>
Cc: Troy Kisky <troy.kisky@boundarydevices.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Marek Vasut [Thu, 12 Dec 2013 21:50:02 +0000 (22:50 +0100)]
PCI: imx6: Start link in Gen1 before negotiating for Gen2 mode
This patch first forces the link into Gen1 mode before starting up the link
and, only after the link is up, start negotiating possible Gen2 mode
operation. This is because without such sequence, some PCIe switches are
not detected at all.
Signed-off-by: Marek Vasut <marex@denx.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
Cc: Frank Li <lznuaa@gmail.com>
Cc: Harro Haan <hrhaan@gmail.com>
Cc: Jingoo Han <jg1.han@samsung.com>
Cc: Mohit KUMAR <Mohit.KUMAR@st.com>
Cc: Pratyush Anand <pratyush.anand@st.com>
Cc: Richard Zhu <r65037@freescale.com>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Sean Cross <xobs@kosagi.com>
Cc: Siva Reddy Kallam <siva.kallam@samsung.com>
Cc: Srikanth T Shivanand <ts.srikanth@samsung.com>
Cc: Tim Harvey <tharvey@gateworks.com>
Cc: Troy Kisky <troy.kisky@boundarydevices.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Marek Vasut [Thu, 12 Dec 2013 21:50:01 +0000 (22:50 +0100)]
PCI: imx6: Factor out link up wait loop
Split the function that waits for the PCIe link to come up from the rest if
the host init function. We will find this change useful in the subsequent
patch, since this will be called twice then.
No functional change.
[bhelgaas: remove useless "return;"]
Signed-off-by: Marek Vasut <marex@denx.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
Cc: Frank Li <lznuaa@gmail.com>
Cc: Harro Haan <hrhaan@gmail.com>
Cc: Jingoo Han <jg1.han@samsung.com>
Cc: Mohit KUMAR <Mohit.KUMAR@st.com>
Cc: Pratyush Anand <pratyush.anand@st.com>
Cc: Richard Zhu <r65037@freescale.com>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Sean Cross <xobs@kosagi.com>
Cc: Siva Reddy Kallam <siva.kallam@samsung.com>
Cc: Srikanth T Shivanand <ts.srikanth@samsung.com>
Cc: Tim Harvey <tharvey@gateworks.com>
Cc: Troy Kisky <troy.kisky@boundarydevices.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Marek Vasut [Thu, 12 Dec 2013 21:50:00 +0000 (22:50 +0100)]
PCI: imx6: Factor out PHY reset
Split the PCIe PHY reset from the link up function to make the code a
little more structured.
No functional change.
Signed-off-by: Marek Vasut <marex@denx.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
Cc: Frank Li <lznuaa@gmail.com>
Cc: Harro Haan <hrhaan@gmail.com>
Cc: Jingoo Han <jg1.han@samsung.com>
Cc: Mohit KUMAR <Mohit.KUMAR@st.com>
Cc: Pratyush Anand <pratyush.anand@st.com>
Cc: Richard Zhu <r65037@freescale.com>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Sean Cross <xobs@kosagi.com>
Cc: Siva Reddy Kallam <siva.kallam@samsung.com>
Cc: Srikanth T Shivanand <ts.srikanth@samsung.com>
Cc: Tim Harvey <tharvey@gateworks.com>
Cc: Troy Kisky <troy.kisky@boundarydevices.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Marek Vasut [Thu, 12 Dec 2013 21:49:59 +0000 (22:49 +0100)]
PCI: imx6: Report "link up" only after link training completes
While waiting for the PHY to report the PCIe link is up, we might hit a
situation where the link training is still in progress, while the PHY
already reports the link is up. Add additional check for this condition.
Signed-off-by: Marek Vasut <marex@denx.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
Cc: Frank Li <lznuaa@gmail.com>
Cc: Harro Haan <hrhaan@gmail.com>
Cc: Jingoo Han <jg1.han@samsung.com>
Cc: Mohit KUMAR <Mohit.KUMAR@st.com>
Cc: Pratyush Anand <pratyush.anand@st.com>
Cc: Richard Zhu <r65037@freescale.com>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Sean Cross <xobs@kosagi.com>
Cc: Siva Reddy Kallam <siva.kallam@samsung.com>
Cc: Srikanth T Shivanand <ts.srikanth@samsung.com>
Cc: Tim Harvey <tharvey@gateworks.com>
Cc: Troy Kisky <troy.kisky@boundarydevices.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Marek Vasut [Thu, 12 Dec 2013 21:49:58 +0000 (22:49 +0100)]
PCI: imx6: Make reset-gpio optional
Some boards do not have a PCIe reset GPIO. To avoid probe failure on these
boards, make the reset GPIO optional as well.
[bhelgaas: whitespace fixes]
Signed-off-by: Marek Vasut <marex@denx.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Jingoo Han <jg1.han@samsung.com>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
Cc: Frank Li <lznuaa@gmail.com>
Cc: Harro Haan <hrhaan@gmail.com>
Cc: Mohit KUMAR <Mohit.KUMAR@st.com>
Cc: Pratyush Anand <pratyush.anand@st.com>
Cc: Richard Zhu <r65037@freescale.com>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Sean Cross <xobs@kosagi.com>
Cc: Siva Reddy Kallam <siva.kallam@samsung.com>
Cc: Srikanth T Shivanand <ts.srikanth@samsung.com>
Cc: Tim Harvey <tharvey@gateworks.com>
Cc: Troy Kisky <troy.kisky@boundarydevices.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Bjorn Helgaas [Wed, 18 Dec 2013 21:04:35 +0000 (14:04 -0700)]
Merge branch 'pci/vc' into next
* pci/vc:
PCI: Rename PCI_VC_PORT_REG1/2 to PCI_VC_PORT_CAP1/2
PCI: Add Virtual Channel to save/restore support
PCI: Add support for save/restore of extended capabilities
PCI: Add pci_wait_for_pending() (refactor pci_wait_for_pending_transaction())
Bjorn Helgaas [Wed, 18 Dec 2013 21:04:29 +0000 (14:04 -0700)]
Merge branch 'pci/pciehp' into next
* pci/pciehp:
PCI: pciehp: Move Attention & Power Indicator support tests to accessors
PCI: pciehp: Use symbolic constants for Slot Control fields
PCI: pciehp: Use symbolic constants, not hard-coded bitmask
PCI: pciehp: Simplify "Power Fault Detected" checking/clearing
PCI: pciehp: Announce slot capabilities (slot #, button, LEDs, etc)
PCI: pciehp: Make various functions void since they can't fail
PCI: pciehp: Remove error checks when accessing PCIe Capability
PCI: pciehp: Drop pciehp_readw()/pciehp_writew() wrappers
Bjorn Helgaas [Wed, 18 Dec 2013 21:04:20 +0000 (14:04 -0700)]
Merge branch 'pci/host-tegra' into next
* pci/host-tegra:
PCI: Disable Gen2 for Tegra20 and Tegra30
Bjorn Helgaas [Wed, 18 Dec 2013 21:04:15 +0000 (14:04 -0700)]
Merge branch 'pci/host-rcar' into next
* pci/host-rcar:
PCI: rcar: Add runtime PM support
PCI: rcar: Fix rcar_pci_probe() return value check
Bjorn Helgaas [Wed, 18 Dec 2013 21:04:09 +0000 (14:04 -0700)]
Merge branch 'pci/host-mvebu' into next
* pci/host-mvebu:
PCI: mvebu: Remove duplicate of_clk_get_by_name() call
PCI: mvebu: Support a bridge with no IO port window
PCI: mvebu: Obey bridge PCI_COMMAND_MEM and PCI_COMMAND_IO bits
PCI: mvebu: Drop writes to bridge Secondary Status register
Bjorn Helgaas [Wed, 18 Dec 2013 21:04:04 +0000 (14:04 -0700)]
Merge branch 'pci/host-imx6' into next
* pci/host-imx6:
PCI: imx6: Remove unneeded 'goto err'
PCI: imx6: Remove unneeded check of platform_get_resource()
Bjorn Helgaas [Wed, 18 Dec 2013 21:03:57 +0000 (14:03 -0700)]
Merge branch 'pci/host-designware' into next
* pci/host-designware:
PCI: designware: Use typical "for" loop idiom
PCI: designware: Remove redundant call to pci_write_config_word()
PCI: designware: Fix crash in dw_msi_teardown_irq()
Bjorn Helgaas [Wed, 18 Dec 2013 21:03:38 +0000 (14:03 -0700)]
Merge branch 'pci/deletion' into next
* pci/deletion:
PCI: Remove from bus_list and release resources in pci_release_dev()
PCI: Move pci_proc_attach_device() to pci_bus_add_device()
PCI: Use device_release_driver() in pci_stop_root_bus()
PCI: Move device_del() from pci_stop_dev() to pci_destroy_dev()
Conflicts:
drivers/pci/remove.c
Bjorn Helgaas [Wed, 18 Dec 2013 21:01:20 +0000 (14:01 -0700)]
Merge branch 'pci/aer' into next
* pci/aer:
PCI/AER: Consolidate HEST error source parsers
PCI/AER: Ignore non-PCIe AER error sources in aer_hest_parse()
PCI/AER: Clean up error printing code a bit
PCI/AER: Add a TLP header print helper
Bjorn Helgaas [Wed, 18 Dec 2013 21:00:56 +0000 (14:00 -0700)]
Merge branch 'eisa' into next
* eisa:
EISA: Call put_device() if device_register() fails
Yinghai Lu [Sat, 30 Nov 2013 22:40:29 +0000 (14:40 -0800)]
PCI: Remove from bus_list and release resources in pci_release_dev()
Previously we removed the pci_dev from the bus_list and released its
resources in pci_destroy_dev(). But that's too early: it's possible to
call pci_destroy_dev() twice for the same device (e.g., via sysfs), and
that will cause an oops when we try to remove it from bus_list the second
time.
We should remove it from the bus_list only when the last reference to the
pci_dev has been released, i.e., in pci_release_dev().
[bhelgaas: changelog]
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Yinghai Lu [Sat, 30 Nov 2013 22:40:28 +0000 (14:40 -0800)]
PCI: Move pci_proc_attach_device() to pci_bus_add_device()
4f535093cf8f ("PCI: Put pci_dev in device tree as early as possible")
moved pci_proc_attach_device() from pci_bus_add_device() to
pci_device_add().
This moves it back to pci_bus_add_device(), essentially reverting that
part of
4f535093cf8f. This makes it symmetric with pci_stop_dev(),
where we call pci_proc_detach_device() and pci_remove_sysfs_dev_files()
and set dev->is_added = 0.
[bhelgaas: changelog, create sysfs then attach proc for symmetry]
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Yinghai Lu [Sat, 30 Nov 2013 22:40:27 +0000 (14:40 -0800)]
PCI: Use device_release_driver() in pci_stop_root_bus()
To be consistent with
4bff6749905d ("PCI: Move device_del() from
pci_stop_dev() to pci_destroy_dev()", this changes pci_stop_root_bus()
to use device_release_driver() instead of device_del().
This also changes pci_remove_root_bus() to use device_unregister()
instead of put_device() so it corresponds with the device_register()
call in pci_create_root_bus().
[bhelgaas: changelog]
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Rafael J. Wysocki [Wed, 18 Dec 2013 20:53:32 +0000 (13:53 -0700)]
PCI: Move device_del() from pci_stop_dev() to pci_destroy_dev()
After commit
bcdde7e221a8 (sysfs: make __sysfs_remove_dir() recursive)
I'm seeing traces analogous to the one below in Thunderbolt testing:
WARNING: CPU: 3 PID: 76 at /scratch/rafael/work/linux-pm/fs/sysfs/group.c:214 sysfs_remove_group+0x59/0xe0()
sysfs group
ffffffff81c6c500 not found for kobject '0000:08'
Modules linked in: ...
CPU: 3 PID: 76 Comm: kworker/u16:7 Not tainted 3.13.0-rc1+ #76
Hardware name: Acer Aspire S5-391/Venus , BIOS V1.02 05/29/2012
Workqueue: kacpi_hotplug acpi_hotplug_work_fn
0000000000000009 ffff8801644b9ac8 ffffffff816b23bf 0000000000000007
ffff8801644b9b18 ffff8801644b9b08 ffffffff81046607 ffff88016925b800
0000000000000000 ffffffff81c6c500 ffff88016924f928 ffff88016924f800
Call Trace:
[<
ffffffff816b23bf>] dump_stack+0x4e/0x71
[<
ffffffff81046607>] warn_slowpath_common+0x87/0xb0
[<
ffffffff810466d1>] warn_slowpath_fmt+0x41/0x50
[<
ffffffff811e42ef>] ? sysfs_get_dirent_ns+0x6f/0x80
[<
ffffffff811e5389>] sysfs_remove_group+0x59/0xe0
[<
ffffffff8149f00b>] dpm_sysfs_remove+0x3b/0x50
[<
ffffffff81495818>] device_del+0x58/0x1c0
[<
ffffffff814959c8>] device_unregister+0x48/0x60
[<
ffffffff813254fe>] pci_remove_bus+0x6e/0x80
[<
ffffffff81325548>] pci_remove_bus_device+0x38/0x110
[<
ffffffff8132555d>] pci_remove_bus_device+0x4d/0x110
[<
ffffffff81325639>] pci_stop_and_remove_bus_device+0x19/0x20
[<
ffffffff813418d0>] disable_slot+0x20/0xe0
[<
ffffffff81341a38>] acpiphp_check_bridge+0xa8/0xd0
[<
ffffffff813427ad>] hotplug_event+0x17d/0x220
[<
ffffffff81342880>] hotplug_event_work+0x30/0x70
[<
ffffffff8136d665>] acpi_hotplug_work_fn+0x18/0x24
[<
ffffffff81061331>] process_one_work+0x261/0x450
[<
ffffffff81061a7e>] worker_thread+0x21e/0x370
[<
ffffffff81061860>] ? rescuer_thread+0x300/0x300
[<
ffffffff81068342>] kthread+0xd2/0xe0
[<
ffffffff81068270>] ? flush_kthread_worker+0x70/0x70
[<
ffffffff816c19bc>] ret_from_fork+0x7c/0xb0
[<
ffffffff81068270>] ? flush_kthread_worker+0x70/0x70
(Mika Westerberg sees them too in his tests).
Some investigation documented in kernel bug #65281 led me to the
conclusion that the source of the problem is the device_del() in
pci_stop_dev() as it now causes the sysfs directory of the device to be
removed recursively along with all of its subdirectories. That includes
the sysfs directory of the device's subordinate bus (dev->subordinate) and
its "power" group.
Consequently, when pci_remove_bus() is called for dev->subordinate in
pci_remove_bus_device(), it calls device_unregister(&bus->dev), but at this
point the sysfs directory of bus->dev doesn't exist any more and its
"power" group doesn't exist either. Thus, when dpm_sysfs_remove() called
from device_del() tries to remove that group, it triggers the above
warning.
That indicates a logical mistake in the design of
pci_stop_and_remove_bus_device(), which causes bus device objects to be
left behind their parents (bridge device objects) and can be fixed by
moving the device_del() from pci_stop_dev() into pci_destroy_dev(), so
pci_remove_bus() can be called for the device's subordinate bus before the
device itself is unregistered from the hierarchy. Still, the driver, if
any, should be detached from the device in pci_stop_dev(), so use
device_release_driver() directly from there.
References: https://bugzilla.kernel.org/show_bug.cgi?id=65281#c6
Reported-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Alex Williamson [Tue, 17 Dec 2013 23:43:57 +0000 (16:43 -0700)]
PCI: Rename PCI_VC_PORT_REG1/2 to PCI_VC_PORT_CAP1/2
These are set of two capability registers, it's pretty much given that
they're registers, so reflect their purpose in the name.
Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Alex Williamson [Tue, 17 Dec 2013 23:43:51 +0000 (16:43 -0700)]
PCI: Add Virtual Channel to save/restore support
While we don't really have any infrastructure for making use of VC
support, the system BIOS can configure the topology to non-default
VC values prior to boot. This may be due to silicon bugs, desire to
reserve traffic classes, or perhaps just BIOS bugs. When we reset
devices, the VC configuration may return to default values, which can
be incompatible with devices upstream. For instance, Nvidia GRID
cards provide a PCIe switch and some number of GPUs, all supporting
VC. The power-on default for VC is to support TC0-7 across VC0,
however some platforms will only enable TC0/VC0 mapping across the
topology. When we do a secondary bus reset on the downstream switch
port, the GPU is reset to a TC0-7/VC0 mapping while the opposite end
of the link only enables TC0/VC0. If the GPU attempts to use TC1-7,
it fails.
This patch attempts to provide complete support for VC save/restore,
even beyond the minimally required use case above. This includes
save/restore and reload of the arbitration table, save/restore and
reload of the port arbitration tables, and re-enabling of the
channels for VC, VC9, and MFVC capabilities.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Alex Williamson [Tue, 17 Dec 2013 23:43:45 +0000 (16:43 -0700)]
PCI: Add support for save/restore of extended capabilities
Current save/restore is specific to standard capabilities.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Alex Williamson [Tue, 17 Dec 2013 23:43:39 +0000 (16:43 -0700)]
PCI: Add pci_wait_for_pending() (refactor pci_wait_for_pending_transaction())
We currently have two instance of this loop which waits for a pending bit
to clear in a status dword. Generalize the function for future users.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Bjorn Helgaas [Mon, 16 Dec 2013 00:23:54 +0000 (17:23 -0700)]
PCI: pciehp: Move Attention & Power Indicator support tests to accessors
Previously, the caller checked ATTN_LED() or PWR_LED() to see whether the
slot has indicators before setting the indicator state. That clutters the
caller unnecessarily, so this moves the test inside the callees. The test
may not even be necessary; per spec it should be harmless to try to turn on
a non-existent LED. But checking first does avoid unnecessary hotplug
commands.
No functional change.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Bjorn Helgaas [Sat, 14 Dec 2013 20:06:53 +0000 (13:06 -0700)]
PCI: pciehp: Use symbolic constants for Slot Control fields
Add symbolic constants for the PCIe Slot Control indicator and power
control fields defined by spec and use them instead of open-coded hex
constants.
No functional change.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Bjorn Helgaas [Sat, 14 Dec 2013 20:06:47 +0000 (13:06 -0700)]
PCI: pciehp: Use symbolic constants, not hard-coded bitmask
Use the PCI_EXP_SLTSTA definitions, not 0x1f, when clearing Slot Status
bits.
No functional change.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Bjorn Helgaas [Sat, 14 Dec 2013 20:06:40 +0000 (13:06 -0700)]
PCI: pciehp: Simplify "Power Fault Detected" checking/clearing
It's simpler to test the PCI_EXP_SLTSTA_PFD bit directly and to write the
constant back to PCI_EXP_SLTSTA.
No functional change.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Bjorn Helgaas [Sat, 14 Dec 2013 20:06:36 +0000 (13:06 -0700)]
PCI: pciehp: Announce slot capabilities (slot #, button, LEDs, etc)
We already have the vendor/device IDs from pci_setup_device(), so drop that
info and print things that will be more useful for debugging: the slot
number and presence of button/indicators/link active reporting/etc.
No functional change.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Bjorn Helgaas [Sat, 14 Dec 2013 20:06:16 +0000 (13:06 -0700)]
PCI: pciehp: Make various functions void since they can't fail
These functions:
pcie_enable_notification()
pciehp_power_off_slot()
pciehp_get_power_status()
pciehp_get_attention_status()
pciehp_set_attention_status()
pciehp_get_latch_status()
pciehp_get_adapter_status()
pcie_write_cmd()
now always return success, so this patch makes them void and drops the
error-checking code in their callers.
No functional change.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Bjorn Helgaas [Sat, 14 Dec 2013 20:06:07 +0000 (13:06 -0700)]
PCI: pciehp: Remove error checks when accessing PCIe Capability
There's not much point in checking the return value from every config space
access because the only likely errors are design-time things like unaligned
accesses or invalid register numbers. The checking clutters the code
significantly, so this patch removes it.
No functional change.
Reference: http://lkml.kernel.org/r/CA+55aFzP4xEbcNmZ+MS0SQ3LrULzSq+dBiT_X9U-bPpR-Ukgrw@mail.gmail.com
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Bjorn Helgaas [Thu, 9 May 2013 17:26:16 +0000 (11:26 -0600)]
PCI: pciehp: Drop pciehp_readw()/pciehp_writew() wrappers
The pciehp_readw() and pciehp_writew() wrappers only look up the pci_dev
and call the PCIe Capability accessors, so we can make things a little
more straightforward by just using the PCIe Capability accessors directly.
No functional change.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Bjorn Helgaas [Fri, 13 Dec 2013 22:42:53 +0000 (15:42 -0700)]
PCI/AER: Consolidate HEST error source parsers
aer_hest_parse() and aer_hest_parse_aff() are almost identical. We use
aer_hest_parse() to check the ACPI_HEST_FIRMWARE_FIRST flag for a specific
device, and we use aer_hest_parse_aff() to check to see if any device sets
the flag.
This drops aer_hest_parse_aff() and enhances aer_hest_parse() so it
collects the union of the PCIe ACPI_HEST_FIRMWARE_FIRST flag settings when
no specific device is supplied.
No functional change.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Betty Dall <betty.dall@hp.com>
Betty Dall [Fri, 13 Dec 2013 15:23:16 +0000 (08:23 -0700)]
PCI/AER: Ignore non-PCIe AER error sources in aer_hest_parse()
aer_set_firmware_first() searches the HEST for an error source descriptor
matching the specified PCI device. It uses the apei_hest_parse() iterator
to call aer_hest_parse() for every descriptor in the HEST.
Previously, aer_hest_parse() incorrectly assumed every descriptor was for a
PCIe error source. This patch adds a check to avoid that error.
[bhelgaas: factor check into helper, use in aer_hest_parse_aff(), changelog]
Signed-off-by: Betty Dall <betty.dall@hp.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Borislav Petkov [Fri, 13 Dec 2013 21:40:03 +0000 (14:40 -0700)]
PCI/AER: Clean up error printing code a bit
Save one indentation level in aer_print_error() for the generic case where
we have info->status of an error, disregard 80 cols rule a bit for the sake
of better readability, fix alignment.
No functionality change.
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Borislav Petkov [Fri, 13 Dec 2013 21:39:56 +0000 (14:39 -0700)]
PCI/AER: Add a TLP header print helper
... and call it instead of duplicating the large printk format
statement.
No functionality change.
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Levente Kurusa [Fri, 13 Dec 2013 18:39:54 +0000 (19:39 +0100)]
EISA: Call put_device() if device_register() fails
We need to give up the last reference to edev->dev, so we need to call
put_device().
Signed-off-by: Levente Kurusa <levex@linux.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Joe Perches [Fri, 13 Dec 2013 18:36:22 +0000 (11:36 -0700)]
PCI/checkpatch: Deprecate DEFINE_PCI_DEVICE_TABLE
Prefer use of the direct definition of struct pci_device_id instead of
indirection via macro DEFINE_PCI_DEVICE_TABLE.
Update the PCI documentation to deprecate DEFINE_PCI_DEVICE_TABLE. Update
checkpatch adding --fix option.
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Jingoo Han <jg1.han@samsung.com>
Bjorn Helgaas [Fri, 13 Dec 2013 18:01:27 +0000 (11:01 -0700)]
Merge branch 'pci/yijing-dev_is_pci' into next
* pci/yijing-dev_is_pci:
alpha/PCI: Use dev_is_pci() to identify PCI devices
arm/PCI: Use dev_is_pci() to identify PCI devices
arm/PCI: Use dev_is_pci() to identify PCI devices
parisc/PCI: Use dev_is_pci() to identify PCI devices
sparc/PCI: Use dev_is_pci() to identify PCI devices
ia64/PCI: Use dev_is_pci() to identify PCI devices
x86/PCI: Use dev_is_pci() to identify PCI devices
PCI: Use dev_is_pci() to identify PCI devices
Bjorn Helgaas [Fri, 13 Dec 2013 17:20:05 +0000 (10:20 -0700)]
Merge branch 'pci/misc' into next
* pci/misc:
PCI: Stop clearing bridge Secondary Status when setting up I/O aperture
PCI: Prevent bus conflicts while checking for bridge apertures
PCI: Drop "irq" param from *_restore_msi_irqs()
PCI/portdrv: Remove superfluous name cast
PCI: Clear NumVFs when disabling SR-IOV in sriov_init()
Bjorn Helgaas [Fri, 13 Dec 2013 17:19:43 +0000 (10:19 -0700)]
Merge branch 'for-linus' into next
* for-linus:
MAINTAINERS: Add DesignWare, i.MX6, Armada, R-Car PCI host maintainers
PCI: Disable Bus Master only on kexec reboot
PCI: mvebu: Return 'unsupported' for Interrupt Line and Interrupt Pin
PCI: Omit PCI ID macro strings to shorten quirk names
PCI: Move device_del() from pci_stop_dev() to pci_destroy_dev()
Revert "workqueue: allow work_on_cpu() to be called recursively"
PCI: Avoid unnecessary CPU switch when calling driver .probe() method
Bjorn Helgaas [Thu, 28 Nov 2013 00:24:50 +0000 (17:24 -0700)]
PCI: Stop clearing bridge Secondary Status when setting up I/O aperture
pci_setup_bridge_io() accessed PCI_IO_BASE and PCI_IO_LIMIT using dword
(32-bit) reads and writes, which also access the Secondary Status register.
Since the Secondary Status register is in the upper 16 bits of the dword,
and we preserved those upper 16 bits, this had the effect of clearing any
of the write-1-to-clear bits that happened to be set in the Secondary
Status register.
That's not what we want, so use word (16-bit) accesses to update only
PCI_IO_BASE and PCI_IO_LIMIT.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Bjorn Helgaas [Wed, 27 Nov 2013 22:31:07 +0000 (15:31 -0700)]
PCI: Prevent bus conflicts while checking for bridge apertures
pci_bridge_check_ranges() determines whether the bridge supports an I/O
aperture and a prefetchable memory aperture.
Previously, if the I/O aperture was unsupported, disabled, or configured at
[io 0x0000-0x0fff], we wrote 0xf0 to PCI_IO_BASE and PCI_IO_LIMIT, which,
if the bridge supports it, enables the I/O aperture at [io 0xf000-0xffff].
The enabled aperture may conflict with other devices in the system.
Similarly, we wrote 0xfff0 to PCI_PREF_MEMORY_BASE and
PCI_PREF_MEMORY_LIMIT, which enables the prefetchable memory aperture at
[mem 0xfff00000-0xffffffff], and that may also conflict with other devices.
All we need to know is whether the base and limit registers are writable,
so we can use values that leave the apertures disabled, e.g., PCI_IO_BASE =
0xf0, PCI_IO_LIMIT = 0xe0, PCI_PREF_MEMORY_BASE = 0xfff0,
PCI_PREF_MEMORY_LIMIT = 0xffe0.
Writing non-zero values to both the base and limit registers means we
detect whether either or both are writable, as we did before.
Reported-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Based-on-patch-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
DuanZhenzhong [Wed, 4 Dec 2013 05:09:16 +0000 (13:09 +0800)]
PCI: Drop "irq" param from *_restore_msi_irqs()
Change x86_msi.restore_msi_irqs(struct pci_dev *dev, int irq) to
x86_msi.restore_msi_irqs(struct pci_dev *dev).
restore_msi_irqs() restores multiple MSI-X IRQs, so param 'int irq' is
unneeded. This makes code more consistent between vm and bare metal.
Dom0 MSI-X restore code can also be optimized as XEN only has a hypercall
to restore all MSI-X vectors at one time.
Tested-by: Sucheta Chakraborty <sucheta.chakraborty@qlogic.com>
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@oracle.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Geert Uytterhoeven [Tue, 12 Nov 2013 19:07:17 +0000 (20:07 +0100)]
PCI/portdrv: Remove superfluous name cast
device_driver.name is "const char *"
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Yijing Wang [Thu, 5 Dec 2013 12:04:41 +0000 (20:04 +0800)]
alpha/PCI: Use dev_is_pci() to identify PCI devices
Use dev_is_pci() instead of checking bus type directly.
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Yijing Wang [Thu, 5 Dec 2013 12:03:25 +0000 (20:03 +0800)]
arm/PCI: Use dev_is_pci() to identify PCI devices
Use dev_is_pci() instead of checking bus type directly.
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Yijing Wang [Thu, 5 Dec 2013 12:02:23 +0000 (20:02 +0800)]
arm/PCI: Use dev_is_pci() to identify PCI devices
Use dev_is_pci() instead of checking bus type directly.
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Yijing Wang [Thu, 5 Dec 2013 11:59:38 +0000 (19:59 +0800)]
parisc/PCI: Use dev_is_pci() to identify PCI devices
Use dev_is_pci() instead of equivalent local function.
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Yijing Wang [Wed, 11 Dec 2013 06:00:26 +0000 (14:00 +0800)]
sparc/PCI: Use dev_is_pci() to identify PCI devices
Use dev_is_pci() instead of checking bus type directly.
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Bjorn Helgaas [Wed, 11 Dec 2013 17:40:59 +0000 (10:40 -0700)]
MAINTAINERS: Add DesignWare, i.MX6, Armada, R-Car PCI host maintainers
Add entries for PCI host controller drivers in drivers/pci/host/.
Signed-off-by: Mohit Kumar <mohit.kumar@st.com> # DESIGNWARE
Signed-off-by: Pratyush Anand <pratyush.anand@st.com> # DESIGNWARE
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Simon Horman <horms+renesas@verge.net.au> # R-CAR
Double-Plus-Acked-by: Jason Cooper <jason@lakedaemon.net> # MVEBU
Acked-by: Jingoo Han <jg1.han@samsung.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Acked-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Richard Zhu <r65037@freescale.com> # IMX6
Yijing Wang [Thu, 5 Dec 2013 11:56:39 +0000 (19:56 +0800)]
ia64/PCI: Use dev_is_pci() to identify PCI devices
Use dev_is_pci() instead of checking bus type directly.
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Yijing Wang [Thu, 5 Dec 2013 11:54:34 +0000 (19:54 +0800)]
x86/PCI: Use dev_is_pci() to identify PCI devices
Use dev_is_pci() instead of checking bus type directly.
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Yijing Wang [Thu, 5 Dec 2013 11:52:53 +0000 (19:52 +0800)]
PCI: Use dev_is_pci() to identify PCI devices
Use dev_is_pci() instead of checking bus type directly.
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Andrew Lunn [Wed, 4 Dec 2013 17:30:41 +0000 (18:30 +0100)]
PCI: mvebu: Remove duplicate of_clk_get_by_name() call
Probably due to a merge conflict resolution gone bad, the PCI clock is
got twice. Remove the redundant call of of_clk_get_by_name().
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Jingoo Han <jg1.han@samsung.com>
Acked-by: Jason Cooper <jason@lakedaemon.net>
Valentine Barshak [Wed, 4 Dec 2013 16:33:35 +0000 (20:33 +0400)]
PCI: rcar: Add runtime PM support
If runtime PM is enabled in the kernel config, the PCI clocks are not
forced on at start-up, and thus, are never enabled. Use
pm_runtime_get_sync() to enable the clocks.
While at it, use dev_info() instead of pr_info() since now we have the
device pointer available in the PCI setup callback.
Signed-off-by: Valentine Barshak <valentine.barshak@cogentembedded.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Fabio Estevam [Mon, 2 Dec 2013 03:39:35 +0000 (01:39 -0200)]
PCI: imx6: Remove unneeded 'goto err'
There is no need to use 'goto err' as we can directly return the errors.
No functional change.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Bjorn Helgaas [Mon, 9 Dec 2013 22:11:25 +0000 (15:11 -0700)]
PCI: designware: Use typical "for" loop idiom
It's conventional to use "for" rather than "while" for simple iteration.
No functional change.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Bjørn Erik Nilsen [Fri, 29 Nov 2013 13:35:25 +0000 (14:35 +0100)]
PCI: designware: Remove redundant call to pci_write_config_word()
write_msi_msg() does exactly the same so there is no need to explicitly
call pci_write_config_word() and do the same twice.
Tested-by: Mohit Kumar <mohit.kumar@st.com>
Signed-off-by: Bjørn Erik Nilsen <ben@datarespons.no>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Marek Vasut <marex@denx.de>
Acked-by: Jingoo Han <jg1.han@samsung.com>
Bjørn Erik Nilsen [Fri, 29 Nov 2013 13:35:24 +0000 (14:35 +0100)]
PCI: designware: Fix crash in dw_msi_teardown_irq()
904d0e788993 ("PCI: designware: Add irq_create_mapping()") resulted in
pre-allocated irq descs. Problem was that in assign_irq() these descs were
explicitly allocated and hence also freed, resulting in a crash. We also
need to clear the entire irq range in teardown. With this commit the
teardown basically does exactly the opposite of what was done in setup.
The crash this fixes looks like:
Unable to handle kernel NULL pointer dereference at virtual address
00000020
PC is at dw_msi_teardown_irq+0x40/0x118
LR is at trace_hardirqs_on_caller+0xf4/0x1c0
Backtrace:
[<
802c401c>] (dw_msi_teardown_irq+0x0/0x118) from [<
802c1844>] (arch_teardown_msi_irq+0x3c/0x40)
[<
802c1808>] (arch_teardown_msi_irq+0x0/0x40) from [<
802c1a08>] (default_teardown_msi_irqs+0x68/0x84)
[<
802c19a0>] (default_teardown_msi_irqs+0x0/0x84) from [<
802c1a34>] (arch_teardown_msi_irqs+0x10/0x14)
[<
802c1a24>] (arch_teardown_msi_irqs+0x0/0x14) from [<
802c1ad0>] (free_msi_irqs+0x98/0x144)
[<
802c1a38>] (free_msi_irqs+0x0/0x144) from [<
802c2570>] (pci_disable_msi+0x48/0x60)
[<
802c2528>] (pci_disable_msi+0x0/0x60) from [<
7f0057d4>] (sxdma_irq_free+0x44/0x48 [sxdma])
[bhelgaas: add crash info]
Tested-by: Mohit Kumar <mohit.kumar@st.com>
Signed-off-by: Bjørn Erik Nilsen <ben@datarespons.no>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Marek Vasut <marex@denx.de>
Acked-by: Jingoo Han <jg1.han@samsung.com>
Fabio Estevam [Mon, 2 Dec 2013 03:39:34 +0000 (01:39 -0200)]
PCI: imx6: Remove unneeded check of platform_get_resource()
When using devm_ioremap_resource(), we do not need to check the return
value of platform_get_resource(), so just remove it.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Marek Vasut <marex@denx.de>
Wei Yongjun [Tue, 19 Nov 2013 03:40:28 +0000 (11:40 +0800)]
PCI: rcar: Fix rcar_pci_probe() return value check
In case of error, the function devm_ioremap_resource() returns ERR_PTR()
and never returns NULL. The NULL test in the return value check should
be replaced with IS_ERR().
Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Jingoo Han <jg1.han@samsung.com>
Eric Brower [Mon, 18 Nov 2013 22:55:06 +0000 (14:55 -0800)]
PCI: Disable Gen2 for Tegra20 and Tegra30
Tegra20 and Tegra30 do not support gen2 PCIe, so correct the
register setting to disable it.
Signed-off-by: Eric Brower <ebrower@nvidia.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Khalid Aziz [Wed, 27 Nov 2013 22:19:25 +0000 (15:19 -0700)]
PCI: Disable Bus Master only on kexec reboot
Add a flag to tell the PCI subsystem that kernel is shutting down in
preparation to kexec a kernel. Add code in PCI subsystem to use this flag
to clear Bus Master bit on PCI devices only in case of kexec reboot.
This fixes a power-off problem on Acer Aspire V5-573G and likely other
machines and avoids any other issues caused by clearing Bus Master bit on
PCI devices in normal shutdown path. The problem was introduced by
b566a22c2332 ("PCI: disable Bus Master on PCI device shutdown").
This patch is based on discussion at
http://marc.info/?l=linux-pci&m=
138425645204355&w=2
Link: https://bugzilla.kernel.org/show_bug.cgi?id=63861
Reported-by: Chang Liu <cl91tp@gmail.com>
Signed-off-by: Khalid Aziz <khalid.aziz@oracle.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Konstantin Khlebnikov <koct9i@gmail.com>
Cc: stable@vger.kernel.org # v3.5+
Jason Gunthorpe [Tue, 26 Nov 2013 18:02:55 +0000 (11:02 -0700)]
PCI: mvebu: Support a bridge with no IO port window
Make pcie-io-aperture and the IO port MBUS ID in ranges optional. If not
provided the bridge reports to Linux that IO space mapping is not supported
and refuses to configure an IO MBUS window.
This allows both complete disable (do not specify pcie-io-aperture) and
per-port disable (do not specify a IO target ranges entry for the port).
Most PCIe devices these days do not require IO support to function, so
having an option to disable it in the driver is useful.
Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Jason Cooper <jason@lakedaemon.net>
Jason Gunthorpe [Tue, 26 Nov 2013 18:02:54 +0000 (11:02 -0700)]
PCI: mvebu: Obey bridge PCI_COMMAND_MEM and PCI_COMMAND_IO bits
When PCI_COMMAND_MEMORY/PCI_COMMAND_IO are cleared, the bridge should not
allocate windows or even look at the window limit/base registers.
Otherwise we may set up bogus windows while the PCI core code performs
discovery. The core will leave PCI_COMMAND_IO cleared if it doesn't need
an IO window.
Have mvebu_pcie_handle_*_change respect the bits, and call the change
function whenever the bits changes.
Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Jason Cooper <jason@lakedaemon.net>
Jason Gunthorpe [Tue, 26 Nov 2013 18:27:28 +0000 (11:27 -0700)]
PCI: mvebu: Return 'unsupported' for Interrupt Line and Interrupt Pin
The emulated bridge does not support interrupts, so it should return the
value 0 for Interrupt Line and Interrupt Pin. This indicates that
interrupts are not supported.
Since Max_Lat and Min_Gnt are also in the same 32-bit word, we return
0 for them, which means "do not care."
This corrects an error message from the kernel:
pci 0000:00:01.0: of_irq_parse_pci() failed with rc=135
Which is due to the default return of 0xFFFFFFFF indicating that
interrupts are supported.
The error message regression was caused by
16b84e5a505 ("of/irq: Create
of_irq_parse_and_map_pci() to consolidate arch code.")
Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Jason Cooper <jason@lakedaemon.net>
Jason Gunthorpe [Tue, 26 Nov 2013 18:02:52 +0000 (11:02 -0700)]
PCI: mvebu: Drop writes to bridge Secondary Status register
There are no writable bits in the secondary status register, only RO and
RW1C (write-1-to-clear) bits. The driver never sets any of the RW1C bits,
so the status register should always be 0, just remove the set from the
write path.
Someday the RW1C bits should be copied/cleared directly from registers in
the HW.
[bhelgaas: changelog tweaks]
Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Jason Cooper <jason@lakedaemon.net>