[PATCH 2/5] powerpc/pci: Create pci_dn on demand

2018-09-05 Thread Sergey Miroshnichenko
The pci_dn structures can be created not only from DT, but also directly from newly discovered PCIe devices, so allocate them dynamically. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/kernel/pci_dn.c | 69 +++- 1 file changed, 52 insertions(+), 17

[PATCH 0/5] powerpc/pci/hotplug: Discover surprise-hotplugged PCIe devices during rescan

2018-09-05 Thread Sergey Miroshnichenko
CIe rescan on PowerNV III The PCI subsystem is not prepared to runtime changes of BAR addresses IV Device drivers don't track changes of their BAR addresses V Move BARs of working devices to make space for new ones VI Add support for PCIe bridge hotplug Sergey Miroshnichenko (5): powerpc/pci:

[PATCH 4/5] powerpc/powernv/pci: Enable reassigning the bus numbers

2018-09-05 Thread Sergey Miroshnichenko
PowerNV doesn't depend on PCIe topology info from DT anymore, and now it is able to enumerate the fabric and assign the bus numbers. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/platforms/powernv/pci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/platforms/powernv

[PATCH 1/5] powerpc/pci: Access PCI config space directly w/o pci_dn

2018-09-05 Thread Sergey Miroshnichenko
The pci_dn structures are retrieved from a DT, but hot-plugged PCIe devices don't have them. Don't stop PCIe I/O in absence of pci_dn, so it is now possible to discover new devices. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/kernel/rtas_pci.c | 89

[PATCH 3/5] powerpc/pci: Use DT to create pci_dn for root bridges only

2018-09-05 Thread Sergey Miroshnichenko
Endpoint's pci_dn can be created dynamically. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/kernel/pci_dn.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/pci_dn.c b/arch/powerpc/kernel/pci_dn.c index 5ce752874827..1b9f563d9461 100644

[PATCH 5/5] PCI/powerpc/eeh: Add pcibios hooks for preparing to rescan

2018-09-05 Thread Sergey Miroshnichenko
Reading an empty slot returns all ones, which triggers a false EEH error event on PowerNV. New callbacks pcibios_rescan_prepare/done are introduced to pause/resume the EEH during rescan. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/include/asm/eeh.h | 2 ++ arch/powerpc

[PATCH v2 2/5] powerpc/pci: Create pci_dn on demand

2018-09-06 Thread Sergey Miroshnichenko
The pci_dn structures can be created not only from DT, but also directly from newly discovered PCIe devices, so allocate them dynamically. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/kernel/pci_dn.c | 76 1 file changed, 59 insertions(+), 17

[PATCH v2 5/5] PCI/powerpc/eeh: Add pcibios hooks for preparing to rescan

2018-09-06 Thread Sergey Miroshnichenko
Reading an empty slot returns all ones, which triggers a false EEH error event on PowerNV. New callbacks pcibios_rescan_prepare/done are introduced to pause/resume the EEH during rescan. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/include/asm/eeh.h | 2 ++ arch/powerpc

[PATCH v2 0/5] powerpc/powernv/pci: Discover surprise-hotplugged PCIe devices during rescan

2018-09-06 Thread Sergey Miroshnichenko
Fixed code style warnings. Sergey Miroshnichenko (5): powerpc/pci: Access PCI config space directly w/o pci_dn powerpc/pci: Create pci_dn on demand powerpc/pci: Use DT to create pci_dn for root bridges only powerpc/powernv/pci: Enable reassigning the bus numbers PCI/powerpc/eeh: Add pci

[PATCH v2 1/5] powerpc/pci: Access PCI config space directly w/o pci_dn

2018-09-06 Thread Sergey Miroshnichenko
The pci_dn structures are retrieved from a DT, but hot-plugged PCIe devices don't have them. Don't stop PCIe I/O in absence of pci_dn, so it is now possible to discover new devices. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/kernel/rtas_pci.c | 97

[PATCH v2 4/5] powerpc/powernv/pci: Enable reassigning the bus numbers

2018-09-06 Thread Sergey Miroshnichenko
PowerNV doesn't depend on PCIe topology info from DT anymore, and now it is able to enumerate the fabric and assign the bus numbers. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/platforms/powernv/pci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/platforms/powernv

[PATCH v2 3/5] powerpc/pci: Use DT to create pci_dn for root bridges only

2018-09-06 Thread Sergey Miroshnichenko
Endpoint's pci_dn can be created dynamically. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/kernel/pci_dn.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/pci_dn.c b/arch/powerpc/kernel/pci_dn.c index 48ec16407835..3b4368f07c82 100644

Re: [PATCH v2 2/5] powerpc/pci: Create pci_dn on demand

2018-09-10 Thread Sergey Miroshnichenko
Hello Sam, On 9/10/18 7:47 AM, Sam Bobroff wrote: > Hi Sergey, > > On Thu, Sep 06, 2018 at 02:57:49PM +0300, Sergey Miroshnichenko wrote: >> The pci_dn structures can be created not only from DT, but also >> directly from newly discovered PCIe devices, so allocat

Re: [PATCH v2 5/5] PCI/powerpc/eeh: Add pcibios hooks for preparing to rescan

2018-09-10 Thread Sergey Miroshnichenko
Hello Sam, On 9/10/18 8:03 AM, Sam Bobroff wrote: > Hi Sergey, > > On Thu, Sep 06, 2018 at 02:57:52PM +0300, Sergey Miroshnichenko wrote: >> Reading an empty slot returns all ones, which triggers a false >> EEH error event on PowerNV. >> >> New call

Re: [PATCH v2 1/5] powerpc/pci: Access PCI config space directly w/o pci_dn

2018-09-10 Thread Sergey Miroshnichenko
Hello Sam, On 9/10/18 7:23 AM, Sam Bobroff wrote: > Hi Sergey, > > On Thu, Sep 06, 2018 at 02:57:48PM +0300, Sergey Miroshnichenko wrote: >> The pci_dn structures are retrieved from a DT, but hot-plugged PCIe >> devices don't have them. Don't stop PCIe I/O in absence of pc

[PATCH v3 2/6] powerpc/pci: Create pci_dn on demand

2018-09-11 Thread Sergey Miroshnichenko
The pci_dn structures can be created not only from DT, but also directly from newly discovered PCIe devices, so allocate them dynamically. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/kernel/pci_dn.c | 63 ++-- 1 file changed, 60 insertions(+), 3

[PATCH v3 5/6] PCI/powerpc/eeh: Add pcibios hooks for preparing to rescan

2018-09-11 Thread Sergey Miroshnichenko
Reading an empty slot returns all ones, which triggers a false EEH error event on PowerNV. New callbacks pcibios_rescan_prepare/done are introduced to pause/resume the EEH during rescan. In the same time it makes possible to miss a real EEH event during rescan. Signed-off-by: Sergey

[PATCH v3 1/6] powerpc/pci: Access PCI config space directly w/o pci_dn

2018-09-11 Thread Sergey Miroshnichenko
The pci_dn structures are retrieved from a DT, but hot-plugged PCIe devices don't have them. Don't stop PCIe I/O in absence of pci_dn, so it is now possible to discover new devices. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/kernel/rtas_pci.c | 97

[PATCH v3 6/6] powerpc/pci: Reduce code duplication in pci_add_device_node_info

2018-09-11 Thread Sergey Miroshnichenko
It is possible now to allocate and fill a new pdn with add_one_dev_pci_data Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/kernel/pci_dn.c | 38 +++- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/arch/powerpc/kernel/pci_dn.c b/arch

[PATCH v3 0/6] powerpc/powernv/pci: Discover surprise-hotplugged PCIe devices during rescan

2018-09-11 Thread Sergey Miroshnichenko
d; - Less code affected; - pci_add_device_node_info is refactored with add_one_dev_pci_data; - Minor code cleanup. Changes since v1: - Fixed build for ppc64le and ppc64be when CONFIG_PCI_IOV is disabled; - Fixed build for ppc64e when CONFIG_EEH is disabled; - Fixed code style warning

[PATCH v3 3/6] powerpc/pci: Use DT to create pci_dn for root bridges only

2018-09-11 Thread Sergey Miroshnichenko
Endpoint's pci_dn can be created dynamically. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/kernel/pci_dn.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/pci_dn.c b/arch/powerpc/kernel/pci_dn.c index e2b39b562b53..8bcf10fb13ad 100644

[PATCH v3 4/6] powerpc/powernv/pci: Enable reassigning the bus numbers

2018-09-11 Thread Sergey Miroshnichenko
PowerNV doesn't depend on PCIe topology info from DT anymore, and now it is able to enumerate the fabric and assign the bus numbers. This is enabled by the pci=realloc command line switch. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/kernel/pci_dn.c | 12 1 file changed

Re: [PATCH v3 0/6] powerpc/powernv/pci: Discover surprise-hotplugged PCIe devices during rescan

2018-09-14 Thread Sergey Miroshnichenko
Hello Oliver, On 9/12/18 12:49 PM, Oliver wrote: > On Tue, Sep 11, 2018 at 9:56 PM, Sergey Miroshnichenko > wrote: >> This patchset allows hotplugged PCIe devices to be enumerated during a bus >> rescan being issued via sysfs on PowerNV platforms, when the "Presence >&

Re: [PATCH 4/5] powerpc/powernv/pci: Enable reassigning the bus numbers

2018-09-14 Thread Sergey Miroshnichenko
Hello Ben, On 9/12/18 1:35 PM, Benjamin Herrenschmidt wrote: > On Wed, 2018-09-05 at 18:40 +0300, Sergey Miroshnichenko wrote: >> PowerNV doesn't depend on PCIe topology info from DT anymore, and now >> it is able to enumerate the fabric and assign the bus numbers. > >

Re: [PATCH v2 5/5] PCI/powerpc/eeh: Add pcibios hooks for preparing to rescan

2018-09-14 Thread Sergey Miroshnichenko
On 9/12/18 1:39 PM, wrote: > On Mon, 2018-09-10 at 19:00 +0300, Sergey Miroshnichenko wrote: >> >> Yes, missing a real EEH event is possible, unfortunately, and it is >> indeed worth mentioning. >> >> To reduce this probability the next patchset I'll post in

Re: [PATCH RFC 1/4] PCI: hotplug: Add parameter to put devices to reset during rescan

2018-09-18 Thread Sergey Miroshnichenko
On 9/18/18 1:59 AM, Bjorn Helgaas wrote: > [+cc Russell, Ben, Oliver, linuxppc-dev] > > On Mon, Sep 17, 2018 at 11:55:43PM +0300, Sergey Miroshnichenko wrote: >> Hello Sam, >> >> On 9/17/18 8:28 AM, Sam Bobroff wrote: >>> Hi Sergey, >>> >>

Re: [PATCH RFC v4 03/21] PCI: Enable bridge's I/O and MEM access for hotplugged devices

2019-03-27 Thread Sergey Miroshnichenko
On 3/26/19 10:13 PM, Bjorn Helgaas wrote: > On Mon, Mar 11, 2019 at 04:31:04PM +0300, Sergey Miroshnichenko wrote: >> After updating the bridge window resources, the PCI_COMMAND_IO and >> PCI_COMMAND_MEMORY bits of the bridge must be addressed as well. >> >> Signed-of

Re: [PATCH RFC v4 12/21] PCI: Don't allow hotplugged devices to steal resources

2019-03-27 Thread Sergey Miroshnichenko
On 3/26/19 11:55 PM, Bjorn Helgaas wrote: > On Mon, Mar 11, 2019 at 04:31:13PM +0300, Sergey Miroshnichenko wrote: >> When movable BARs are enabled, the PCI subsystem at first releases >> all the bridge windows and then performs an attempt to assign new >> requested re

Re: [PATCH RFC v4 08/21] nvme-pci: Handle movable BARs

2019-03-27 Thread Sergey Miroshnichenko
On 3/26/19 11:20 PM, Bjorn Helgaas wrote: > [+cc Keith, Jens, Christoph, Sagi, linux-nvme, LKML] > > On Mon, Mar 11, 2019 at 04:31:09PM +0300, Sergey Miroshnichenko wrote: >> Hotplugged devices can affect the existing ones by moving their BARs. >> PCI subsystem will inform

Re: [PATCH RFC v4 11/21] PCI: Release and reassign the root bridge resources during rescan

2019-03-27 Thread Sergey Miroshnichenko
On 3/26/19 11:41 PM, Bjorn Helgaas wrote: > On Mon, Mar 11, 2019 at 04:31:12PM +0300, Sergey Miroshnichenko wrote: >> When the movable BARs feature is enabled, don't rely on the memory gaps >> reserved by the BIOS/bootloader/firmware, but instead rearrange the BARs >> and br

Re: [PATCH RFC v4 02/21] PCI: Fix race condition in pci_enable/disable_device()

2019-03-27 Thread Sergey Miroshnichenko
On 3/26/19 10:00 PM, Bjorn Helgaas wrote: > [+cc Srinath, Marta, LKML] > > On Mon, Mar 11, 2019 at 04:31:03PM +0300, Sergey Miroshnichenko wrote: >> CPU0 CPU1 >> >> pci_enable_device_mem() pci_enable_device_me

Re: [PATCH RFC v4 05/21] PCI: hotplug: Add a flag for the movable BARs feature

2019-03-27 Thread Sergey Miroshnichenko
On 3/26/19 10:24 PM, Bjorn Helgaas wrote: > On Mon, Mar 11, 2019 at 04:31:06PM +0300, Sergey Miroshnichenko wrote: >> If a new PCIe device has been hot-plugged between the two active ones >> without big enough gap between their BARs, > > Just to speak precisely her

Re: [PATCH RFC v4 09/21] PCI: Mark immovable BARs with PCI_FIXED

2019-03-27 Thread Sergey Miroshnichenko
On 3/27/19 8:03 PM, David Laight wrote: > From: Bjorn Helgaas >> Sent: 26 March 2019 20:29 >> >> On Mon, Mar 11, 2019 at 04:31:10PM +0300, Sergey Miroshnichenko wrote: >>> If a PCIe device driver doesn't yet have support for movable BARs, >>> mark device's BA

[PATCH RFC v4 9/9] powerpc/powernv/pci: Enable reassigning the bus numbers

2019-03-01 Thread Sergey Miroshnichenko
DT anymore. This makes possible to re-enumerate the fabric, assign the new bus numbers and switch from the pnv_php module to the standard pciehp driver for PCIe hotplug functionality. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/kernel/pci_dn.c | 12 1 file changed, 12 insertions(+)

[PATCH RFC v4 5/9] powerpc/powernv/ioda: Fix using uninitialized IOMMU group

2019-03-01 Thread Sergey Miroshnichenko
Otherwise there will be a NULL pointer dereferencing in iommu_add_device() later during activating a newly created VF. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/platforms/powernv/pci-ioda.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/powerpc/platforms/powernv/pci

[PATCH RFC v4 6/9] powerpc/pci/IOV: Add support for runtime enabling the VFs

2019-03-01 Thread Sergey Miroshnichenko
When called within pcibios_sriov_enable(), the pci_sriov_get_totalvfs(pdev) returns zero, because the device is yet preparing to enable the VFs. With this patch it becomes possible to enable VFs via sysfs "sriov_numvfs" on PowerNV. Signed-off-by: Sergey Miroshnichenko --- arch/power

[PATCH RFC v4 4/9] powerpc/pci: Reduce code duplication in pci_add_device_node_info

2019-03-01 Thread Sergey Miroshnichenko
It is possible now to allocate and fill a new pdn with add_one_dev_pci_data Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/kernel/pci_dn.c | 38 +++- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/arch/powerpc/kernel/pci_dn.c b/arch

[PATCH RFC v4 1/9] powerpc/pci: Access PCI config space directly w/o pci_dn

2019-03-01 Thread Sergey Miroshnichenko
To fetch an updated DT for the newly hotplugged device, OS must explicitly request it from the firmware via the pnv_php driver. If pnv_php wasn't triggered/loaded, it is still possible to discover new devices if PCIe I/O will not stop in absence of the pci_dn structure. Signed-off-by: Sergey

[PATCH RFC v4 8/9] powerpc/powernv/pci: Hook up the writes to PCI_SECONDARY_BUS register

2019-03-01 Thread Sergey Miroshnichenko
such change of its address. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/platforms/powernv/pci.c | 118 ++- 1 file changed, 116 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c index 73c2d0aed996

[PATCH RFC v4 2/9] powerpc/powernv/pci: Suppress an EEH error when reading an empty slot

2019-03-01 Thread Sergey Miroshnichenko
Reading an empty slot returns all ones, which triggers a false EEH error event on PowerNV. This patch unfreezes the bus where it has happened. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/include/asm/ppc-pci.h | 1 + arch/powerpc/kernel/pci_dn.c | 2 +- arch/powerpc

[PATCH RFC v4 3/9] powerpc/pci: Create pci_dn on demand

2019-03-01 Thread Sergey Miroshnichenko
If a struct pci_dn hasn't yet been created for the PCIe device (there was no DT node for it), allocate this structure and fill with info read from the device directly. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/kernel/pci_dn.c | 79 1 file changed

[PATCH RFC v4 7/9] powerpc/pci: Don't rely on DT is the PCI_REASSIGN_ALL_BUS is set

2019-03-01 Thread Sergey Miroshnichenko
If supported by the platform, endpoint's pci_dn can be created dynamically, without need to wait for DT updates from the firmware. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/kernel/pci_dn.c | 6 -- arch/powerpc/platforms/powernv/eeh-powernv.c | 2 +- 2 files

[PATCH RFC v4 0/9] powerpc/powernv/pci: Make hotplug self-sufficient, independent of FW and DT

2019-03-01 Thread Sergey Miroshnichenko
disabled; - Fixed code style warnings. [1] https://www.spinics.net/lists/linux-pci/msg79995.html [2] https://lists.ozlabs.org/pipermail/linuxppc-dev/2018-September/178053.html Sergey Miroshnichenko (9): powerpc/pci: Access PCI config space directly w/o pci_dn powerpc/powernv/pci: Suppress an

Re: [PATCH RFC v4 2/9] powerpc/powernv/pci: Suppress an EEH error when reading an empty slot

2019-03-05 Thread Sergey Miroshnichenko
On 3/5/19 9:14 AM, Oliver wrote: > On Sat, Mar 2, 2019 at 3:04 AM Sergey Miroshnichenko > wrote: >> >> Reading an empty slot returns all ones, which triggers a false >> EEH error event on PowerNV. This patch unfreezes the bus where >> it has happened. >> >

Re: [PATCH RFC v4 3/9] powerpc/pci: Create pci_dn on demand

2019-03-05 Thread Sergey Miroshnichenko
On 3/5/19 11:04 AM, Oliver wrote: > On Sat, Mar 2, 2019 at 3:04 AM Sergey Miroshnichenko > wrote: >> >> If a struct pci_dn hasn't yet been created for the PCIe device (there was >> no DT node for it), allocate this structure and fill with info read from >> the dev

[PATCH v5 8/8] powerpc/powernv/pci: Enable reassigning the bus numbers

2019-03-11 Thread Sergey Miroshnichenko
DT anymore. This makes possible to re-enumerate the fabric, assign the new bus numbers and switch from the pnv_php module to the standard pciehp driver for PCIe hotplug functionality. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/kernel/pci_dn.c | 12 1 file changed, 12 insertions(+)

[PATCH RFC v4 06/21] PCI: Pause the devices with movable BARs during rescan

2019-03-11 Thread Sergey Miroshnichenko
Drivers indicate their support of movable BARs by implementing the new rescan_prepare() and rescan_done() hooks in the struct pci_driver. All device's activity must be stopped during a rescan, and iounmap() +ioremap() must be applied to every used BAR. Signed-off-by: Sergey Miroshnichenko

[PATCH RFC v4 05/21] PCI: hotplug: Add a flag for the movable BARs feature

2019-03-11 Thread Sergey Miroshnichenko
for the PCIe hotplug. The PCI_MOVABLE_BARS flag is set by the platform is this feature is supported and tested, but can be overridden by the following command line option: pcie_movable_bars={ off | force } Signed-off-by: Sergey Miroshnichenko --- .../admin-guide/kernel-parameters.txt

[PATCH RFC v4 09/21] PCI: Mark immovable BARs with PCI_FIXED

2019-03-11 Thread Sergey Miroshnichenko
If a PCIe device driver doesn't yet have support for movable BARs, mark device's BARs with IORESOURCE_PCI_FIXED. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/probe.c | 15 +++ 1 file changed, 15 insertions(+) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index

[PATCH RFC v4 13/21] PCI: Include fixed BARs into the bus size calculating

2019-03-11 Thread Sergey Miroshnichenko
The only difference between the fixed and movable BARs is an offset preservation during the release+reassign procedure on PCIe rescan. When fixed BARs are included into the result of pbus_size_mem(), these BARs can be restricted: assign them to direct parents only. Signed-off-by: Sergey

[PATCH RFC v4 16/21] PCI: Calculate fixed areas of bridge windows based on fixed BARs

2019-03-11 Thread Sergey Miroshnichenko
us's fixed_range_hard-> | | <- bus's bridge window -> | These ranges will be later used to arrange bridge windows in a way which covers every immovable BAR as well as the movable ones during hotplug. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/pci.h | 1

[PATCH RFC v4 18/21] PCI: Make sure bridge windows include their fixed BARs

2019-03-11 Thread Sergey Miroshnichenko
Consider previously calculated boundaries when allocating a bridge window, setting the lowest allowed address and checking the result. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/bus.c | 2 +- drivers/pci/setup-res.c | 31 +-- 2 files changed, 30

[PATCH v5 4/8] powerpc/pci: Reduce code duplication in pci_add_device_node_info

2019-03-11 Thread Sergey Miroshnichenko
It is possible now to allocate and fill a new pdn with add_one_dev_pci_data Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/kernel/pci_dn.c | 38 +++- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/arch/powerpc/kernel/pci_dn.c b/arch

[PATCH RFC v4 10/21] PCI: Fix assigning of fixed prefetchable resources

2019-03-11 Thread Sergey Miroshnichenko
Allow matching them to non-prefetchable windows, as it is done for movable resources. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/setup-bus.c | 13 + 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index

[PATCH RFC v4 00/21] PCI: Allow BAR movement during hotplug

2019-03-11 Thread Sergey Miroshnichenko
non-pre-enabled (by BIOS/firmware) bridge; - Fix the compatibility of the feature with pm_runtime and D3-state; - Hotplug events from pciehp also can move BARs; - Add support of the feature to the NVME driver. Sergey Miroshnichenko (21): PCI: Fix writing invalid BARs during pci_restore_state() PCI: Fix r

[PATCH RFC v4 12/21] PCI: Don't allow hotplugged devices to steal resources

2019-03-11 Thread Sergey Miroshnichenko
-by: Sergey Miroshnichenko --- drivers/pci/bus.c | 5 ++ drivers/pci/pci.h | 11 + drivers/pci/probe.c | 100 +++- drivers/pci/setup-bus.c | 15 ++ include/linux/pci.h | 1 + 5 files changed, 130 insertions(+), 2 deletions

[PATCH RFC v4 03/21] PCI: Enable bridge's I/O and MEM access for hotplugged devices

2019-03-11 Thread Sergey Miroshnichenko
After updating the bridge window resources, the PCI_COMMAND_IO and PCI_COMMAND_MEMORY bits of the bridge must be addressed as well. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/pci.c | 8 1 file changed, 8 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index

[PATCH RFC v4 08/21] nvme-pci: Handle movable BARs

2019-03-11 Thread Sergey Miroshnichenko
Hotplugged devices can affect the existing ones by moving their BARs. PCI subsystem will inform the NVME driver about this by invoking reset_prepare()+reset_done(), then iounmap()+ioremap() must be called. Signed-off-by: Sergey Miroshnichenko --- drivers/nvme/host/pci.c | 29

[PATCH RFC v4 11/21] PCI: Release and reassign the root bridge resources during rescan

2019-03-11 Thread Sergey Miroshnichenko
by the pci_assign_unassigned_root_bus_resources(). The last step of writing the recalculated windows to the bridges is done by the new pci_setup_bridges() function. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/pci.h | 1 + drivers/pci/probe.c | 22 ++ drivers/pci/setup-bus.c | 11

[PATCH RFC v4 17/21] PCI: Calculate boundaries for bridge windows

2019-03-11 Thread Sergey Miroshnichenko
ard --> | | <-- fixed_range_hard.end - window size --> | | <-- fixed_range_hard.start + window size --> | | <--bus's fixed_range_soft--> | Signed-off-by: Sergey Miroshnichenko --- driv

[PATCH v5 1/8] powerpc/pci: Access PCI config space directly w/o pci_dn

2019-03-11 Thread Sergey Miroshnichenko
To fetch an updated DT for the newly hotplugged device, OS must explicitly request it from the firmware via the pnv_php driver. If pnv_php wasn't triggered/loaded, it is still possible to discover new devices if PCIe I/O will not stop in absence of the pci_dn structure. Signed-off-by: Sergey

[PATCH v5 2/8] powerpc/powernv/pci: Suppress an EEH error when reading an empty slot

2019-03-11 Thread Sergey Miroshnichenko
Reading an empty slot returns all ones, which triggers a false EEH error event on PowerNV. This patch unfreezes the bus where it has happened. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/include/asm/ppc-pci.h | 1 + arch/powerpc/kernel/pci_dn.c | 2 +- arch/powerpc

[PATCH RFC v4 01/21] PCI: Fix writing invalid BARs during pci_restore_state()

2019-03-11 Thread Sergey Miroshnichenko
If BAR movement has happened (due to PCIe hotplug) after pci_save_state(), the saved addresses will become outdated. Restore them the most recently calculated values, not the ones stored in an arbitrary moment. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/pci.c | 2 +- 1 file changed, 1

[PATCH RFC v4 07/21] PCI: Wake up bridges during rescan when movable BARs enabled

2019-03-11 Thread Sergey Miroshnichenko
Use the PM runtime methods to wake up the bridges before accessing their config space. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/probe.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 88350dd56344..dc935f82a595 100644

[PATCH RFC v4 14/21] PCI: Don't reserve memory for hotplug when enabled movable BARs

2019-03-11 Thread Sergey Miroshnichenko
pbus_size_mem() returns a precise amount of memory required to fit all the requested BARs and windows of children bridges. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/setup-bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci

[PATCH RFC v4 21/21] powerpc/pci: Fix crash with enabled movable BARs

2019-03-11 Thread Sergey Miroshnichenko
Check a resource for the UNSET flags. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/platforms/powernv/pci-ioda.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index

[PATCH v5 3/8] powerpc/pci: Create pci_dn on demand

2019-03-11 Thread Sergey Miroshnichenko
If a struct pci_dn hasn't yet been created for the PCIe device (there was no DT node for it), allocate this structure and fill with info read from the device directly. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/kernel/pci_dn.c | 88 ++-- 1 file changed

[PATCH v5 7/8] powerpc/powernv/pci: Hook up the writes to PCI_SECONDARY_BUS register

2019-03-11 Thread Sergey Miroshnichenko
such change of its address. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/platforms/powernv/pci.c | 118 ++- 1 file changed, 116 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c index 8cc6661781e2

[PATCH v5 6/8] powerpc/pci: Don't rely on DT is the PCI_REASSIGN_ALL_BUS is set

2019-03-11 Thread Sergey Miroshnichenko
If supported by the platform, endpoint's pci_dn can be created dynamically, without need to wait for DT updates from the firmware. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/kernel/pci_dn.c | 6 -- arch/powerpc/platforms/powernv/eeh-powernv.c | 2 +- 2 files

[PATCH RFC v4 04/21] PCI: Define PCI-specific version of the release_child_resources()

2019-03-11 Thread Sergey Miroshnichenko
Make the released resources of a bridge valid for later re-assignment: clear the STARTALIGN flag. Resources marked with PCI_FIXED must preserve their offset and size. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/setup-bus.c | 47 - 1 file changed

[PATCH RFC v4 15/21] PCI: Allow the failed resources to be reassigned later

2019-03-11 Thread Sergey Miroshnichenko
Don't lose the size of the requested EP's BAR if it can't be fit in a current trial, so this can be retried. But a failed bridge window must be dropped and recalculated in the next trial. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/setup-bus.c | 3 ++- drivers/pci/setup-res.c | 12

[PATCH RFC v4 19/21] PCI: Prioritize fixed BAR assigning over the movable ones

2019-03-11 Thread Sergey Miroshnichenko
and bridge windows. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/setup-bus.c | 69 - 1 file changed, 55 insertions(+), 14 deletions(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index f4737339d5ec..932a6c020d10 100644

[PATCH v5 0/8] powerpc/powernv/pci: Make hotplug self-sufficient, independent of FW and DT

2019-03-11 Thread Sergey Miroshnichenko
abled; - Fixed build for ppc64e when CONFIG_EEH is disabled; - Fixed code style warnings. [1] https://lists.ozlabs.org/pipermail/skiboot/2019-March/013571.html [2] https://www.spinics.net/lists/linux-pci/msg79995.html [3] https://lists.ozlabs.org/pipermail/linuxppc-dev/2018-September/178053.html Ser

[PATCH v5 5/8] powerpc/pci/IOV: Add support for runtime enabling the VFs

2019-03-11 Thread Sergey Miroshnichenko
When called within pcibios_sriov_enable(), the pci_sriov_get_totalvfs(pdev) returns zero, because the device is yet preparing to enable the VFs. With this patch it becomes possible to enable VFs via sysfs "sriov_numvfs" on PowerNV. Signed-off-by: Sergey Miroshnichenko --- arch/power

[PATCH RFC v4 02/21] PCI: Fix race condition in pci_enable/disable_device()

2019-03-11 Thread Sergey Miroshnichenko
otects the pci_enable/disable_device() and pci_enable_bridge() with mutexes. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/pci.c | 26 ++ drivers/pci/probe.c | 1 + include/linux/pci.h | 1 + 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/pci/p

[PATCH RFC v4 20/21] PCI: pciehp: Add support for the movable BARs feature

2019-03-11 Thread Sergey Miroshnichenko
With movable BARs, adding a hotplugged device may affect all the PCIe domain starting from the root, so use a pci_rescan_bus() function which handles the rearrangement of existing BARs and bridge windows. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/hotplug/pciehp_pci.c | 14

[PATCH RFC v3 21/21] powerpc/pci: Fix crash with enabled movable BARs

2019-02-04 Thread Sergey Miroshnichenko
Check a resource for the UNSET flags. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/platforms/powernv/pci-ioda.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index

[PATCH RFC v3 00/21] PCI: Allow BAR movement during hotplug

2019-02-04 Thread Sergey Miroshnichenko
s patchset is a part of our work on adding support for hotplugging bridges full of NVME and GPU devices (without special requirement such as Hot-Plug Controller, reservation of bus numbers and memory regions by firmware, etc.). Next patchset will implement the movable bus numbers. Sergey Miroshnic

[PATCH RFC v3 02/21] PCI: Fix race condition in pci_enable/disable_device()

2019-02-04 Thread Sergey Miroshnichenko
otects the pci_enable/disable_device() and pci_enable_bridge() with mutexes. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/pci.c | 26 ++ drivers/pci/probe.c | 1 + include/linux/pci.h | 1 + 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/pci/p

[PATCH RFC v3 06/21] PCI: Pause the devices with movable BARs during rescan

2019-02-04 Thread Sergey Miroshnichenko
Drivers indicate their support of movable BARs by implementing the new rescan_prepare() and rescan_done() hooks in the struct pci_driver. All device's activity must be stopped during a rescan, and iounmap() +ioremap() must be applied to every used BAR. Signed-off-by: Sergey Miroshnichenko

[PATCH RFC v3 05/21] PCI: hotplug: Add a flag for the movable BARs feature

2019-02-04 Thread Sergey Miroshnichenko
for the PCIe hotplug. The PCI_MOVABLE_BARS flag is set by the platform is this feature is supported and tested, but can be overridden by the following command line option: pcie_movable_bars={ off | force } Signed-off-by: Sergey Miroshnichenko --- .../admin-guide/kernel-parameters.txt

Re: [PATCH v5 5/8] powerpc/pci/IOV: Add support for runtime enabling the VFs

2019-05-14 Thread Sergey Miroshnichenko
On 4/30/19 9:00 AM, Oliver O'Halloran wrote: > On Mon, 2019-03-11 at 14:52 +0300, Sergey Miroshnichenko wrote: > >> When called within pcibios_sriov_enable(), the pci_sriov_get_totalvfs(pdev) >> returns zero, because the device is yet preparing to enable the VFs.

[PATCH v5 03/23] PCI: hotplug: Add a flag for the movable BARs feature

2019-08-16 Thread Sergey Miroshnichenko
lloran CC: David Laight Signed-off-by: Sergey Miroshnichenko --- .../admin-guide/kernel-parameters.txt | 7 ++ drivers/pci/pci-driver.c | 2 + drivers/pci/pci.c | 24 ++ drivers/pci/pci.h | 2 + drivers/p

[PATCH v5 07/23] PCI: hotplug: movable BARs: Don't allow added devices to steal resources

2019-08-16 Thread Sergey Miroshnichenko
failure) - B. As a result, A will not get BARs while it could. This issue is only relevant when hotplugging two and more devices simultaneously. Add a new res_mask bitmask to the struct pci_dev for storing the indices of assigned BARs. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/pci.h

[PATCH v5 12/23] PCI: hotplug: movable BARs: Compute limits for relocated bridge windows

2019-08-16 Thread Sergey Miroshnichenko
n. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/setup-bus.c | 67 + include/linux/pci.h | 6 2 files changed, 73 insertions(+) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 420510a1a257..586aaa9578b2 100644 --- a/d

[PATCH v5 15/23] PCI: hotplug: movable BARs: Assign fixed and immovable BARs before others

2019-08-16 Thread Sergey Miroshnichenko
able to assign all types of BARs, so the pdev_assign_fixed_resources() became unused and thus removed. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/pci.h | 2 ++ drivers/pci/setup-bus.c | 79 - drivers/pci/setup-res.c | 8 +++-- 3 files

[PATCH v6 3/5] powerpc/pci: Create pci_dn on demand

2019-08-16 Thread Sergey Miroshnichenko
If a struct pci_dn hasn't yet been created for the PCIe device (there was no DT node for it), allocate this structure and fill with info read from the device directly. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/kernel/pci_dn.c | 88 ++-- 1 file changed

[PATCH v5 04/23] PCI: Define PCI-specific version of the release_child_resources()

2019-08-16 Thread Sergey Miroshnichenko
with the PCI_FIXED and the immovable ones - which are bound by drivers without support of the movable BARs feature. Add the pci_release_child_resources() to replace release_child_resources() in handling the described PCI-specific cases. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/setup-bus.c | 54

[PATCH v5 10/23] PCI: hotplug: movable BARs: Try to assign unassigned resources only once

2019-08-16 Thread Sergey Miroshnichenko
of failures the pci_reassign_root_bus_resources() disables BARs for one of the hotplugged devices and tries the assignment again. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/setup-bus.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup

[PATCH v5 14/23] PCI: Fix assigning the fixed prefetchable resources

2019-08-16 Thread Sergey Miroshnichenko
Allow matching IORESOURCE_PCI_FIXED prefetchable BARs to non-prefetchable windows, so they follow the same rules as immovable BARs. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/setup-bus.c | 13 + 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/pci

[PATCH v5 23/23] PCI: pciehp: movable BARs: Trigger a domain rescan on hp events

2019-08-16 Thread Sergey Miroshnichenko
(pci_bus_add_devices()). CC: Lukas Wunner Signed-off-by: Sergey Miroshnichenko --- drivers/pci/hotplug/pciehp_pci.c | 5 + 1 file changed, 5 insertions(+) diff --git a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c index d17f3bf36f70..66c4e6d88fe3 100644 --- a/drivers/pci

[PATCH v6 1/5] powerpc/pci: Access PCI config space directly w/o pci_dn

2019-08-16 Thread Sergey Miroshnichenko
O'Halloran Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/kernel/rtas_pci.c | 97 +++- arch/powerpc/platforms/powernv/pci.c | 64 -- 2 files changed, 109 insertions(+), 52 deletions(-) diff --git a/arch/powerpc/kernel/rtas_pci.c b/arch/powerpc

[PATCH v5 20/23] PCI: hotplug: movable BARs: Enable the feature by default

2019-08-16 Thread Sergey Miroshnichenko
uot;pci=realloc,pcie_bus_peer2peer". In case of problems it is still can be overridden by the following command line option: pcie_movable_bars=off Signed-off-by: Sergey Miroshnichenko --- drivers/pci/pci-driver.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/pci/pci-driver.c b/driv

[PATCH v5 22/23] PCI/portdrv: Declare support of movable BARs

2019-08-16 Thread Sergey Miroshnichenko
Switch's BARs are not used by the portdrv driver, but they are still considered as immovable until the .rescan_prepare() and .rescan_done() hooks are added. Add these hooks to increase chances to allocate new BARs. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/pcie/portdrv_pci.c | 11

[PATCH v5 08/23] PCI: Include fixed and immovable BARs into the bus size calculating

2019-08-16 Thread Sergey Miroshnichenko
assigning them to non-direct parents. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/setup-bus.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 1a731002ce18..2c250efca512 100644 --- a/drivers/pci/setup

[PATCH v5 13/23] PCI: Make sure bridge windows include their fixed BARs

2019-08-16 Thread Sergey Miroshnichenko
of struct pci_bus, which is calculated during the preparation to the rescan. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/bus.c | 2 +- drivers/pci/setup-res.c | 28 ++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/drivers/pci/bus.c b/drivers

[PATCH v6 4/5] powerpc/powernv/pci: Hook up the writes to PCI_SECONDARY_BUS register

2019-08-16 Thread Sergey Miroshnichenko
such change of its address. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/platforms/powernv/pci.c | 118 ++- 1 file changed, 116 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c index a5b04410c8b4

[PATCH v5 05/23] PCI: hotplug: movable BARs: Fix reassigning the released bridge windows

2019-08-16 Thread Sergey Miroshnichenko
-by: Sergey Miroshnichenko --- drivers/pci/setup-bus.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 6cb8b293c576..7c2c57f77c6f 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -295,7 +295,8 @@ static

[PATCH v5 18/23] powerpc/pci: Handle BAR movement

2019-08-16 Thread Sergey Miroshnichenko
, so it it safe to rebuild the EEH address cache during that. CC: Oliver O'Halloran Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/kernel/pci-hotplug.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/arch/powerpc/kernel/pci-hotplug.c b/arch/powerpc/kernel/pci-hotplug.c

[PATCH v6 0/5] powerpc/powernv/pci: Make hotplug self-sufficient, independent of FW and DT

2019-08-16 Thread Sergey Miroshnichenko
_dev_pci_data; - Minor code cleanup. Changes since v1: - Fixed build for ppc64le and ppc64be when CONFIG_PCI_IOV is disabled; - Fixed build for ppc64e when CONFIG_EEH is disabled; - Fixed code style warnings. Sergey Miroshnichenko (5): powerpc/pci: Access PCI config space directly w/o p

  1   2   >