[PATCH RFC 11/11] PCI: hotplug: movable bus numbers: compact the gaps in numbering

2019-10-24 Thread Sergey Miroshnichenko
was unplugged, the gap in bus numbers must be compacted. Let's densify the bus numbering at the beginning of a next PCI rescan. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/probe.c | 27 +++ 1 file changed, 27 insertions(+) diff --git a/drivers/pci/probe.c b

[PATCH RFC 10/11] PCI: hotplug: movable bus numbers: rename proc and sysfs entries

2019-10-24 Thread Sergey Miroshnichenko
entries and symlinks before renaming the bus, then created them back. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/probe.c | 105 +++- 1 file changed, 104 insertions(+), 1 deletion(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index

[PATCH RFC 09/11] PCI: hotplug: Add initial support for movable bus numbers

2019-10-24 Thread Sergey Miroshnichenko
Following patches will resolve the introduced issues: - fix desynchronization in /sys/devices/pci*, /sys/bus/pci/devices/* and /proc/bus/pci/* after changes in PCI topology; - compact gaps in numbering, which may appear after removing a bridge, to maintain the number continuity. Signed-off-by: Sergey

[PATCH RFC 06/11] powerpc/pci: Enable assigning bus numbers instead of reading them from DT

2019-10-24 Thread Sergey Miroshnichenko
php module to the standard pciehp driver for PCI hotplug functionality. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/kernel/pci_dn.c | 5 + arch/powerpc/platforms/powernv/eeh-powernv.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kerne

[PATCH RFC 08/11] PCI: Allow expanding the bridges

2019-10-24 Thread Sergey Miroshnichenko
will be contracted to the actual value. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/probe.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 539f5d39bb6d..3494b5d265d5 100644 --- a/drivers/pci/probe.c +++ b

[PATCH RFC 05/11] drivers: base: Add bus_disconnect_device()

2019-10-24 Thread Sergey Miroshnichenko
. Signed-off-by: Sergey Miroshnichenko --- drivers/base/bus.c | 36 include/linux/device.h | 1 + 2 files changed, 37 insertions(+) diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 8f3445cc533e..52d77fb90218 100644 --- a/drivers/base/bus.c

[PATCH RFC 07/11] powerpc/pci: Don't reduce the host bridge bus range

2019-10-24 Thread Sergey Miroshnichenko
Currently the last possible bus number of the PHB is set to the last used bus number during the boot. So when hotplugging a bridge later, no new buses can be allocated because they are limited by this value. Let the host bridge contain any number of buses up to 255. Signed-off-by: Sergey

[PATCH RFC 04/11] drivers: base: Make device_{add|remove}_class_symlinks() public

2019-10-24 Thread Sergey Miroshnichenko
the working affected devices. Signed-off-by: Sergey Miroshnichenko --- drivers/base/core.c| 6 -- include/linux/device.h | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 7bd9cd366d41..23e689fc8478 100644 --- a/drivers

[PATCH RFC 03/11] drivers: base: Make bus_add_device() public

2019-10-24 Thread Sergey Miroshnichenko
be reattached and their sysfs and proc files recreated. Signed-off-by: Sergey Miroshnichenko --- drivers/base/base.h| 1 - drivers/base/bus.c | 1 + include/linux/device.h | 2 ++ 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/base/base.h b/drivers/base/base.h index

[PATCH RFC 02/11] PCI: proc: Nullify a freed pointer

2019-10-24 Thread Sergey Miroshnichenko
-by: Sergey Miroshnichenko --- drivers/pci/proc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c index 5495537c60c2..c85654dd315b 100644 --- a/drivers/pci/proc.c +++ b/drivers/pci/proc.c @@ -443,6 +443,7 @@ int pci_proc_detach_device(struct pci_dev *dev) int

[PATCH RFC 01/11] PCI: sysfs: Nullify freed pointers

2019-10-24 Thread Sergey Miroshnichenko
time to recreate the sysfs entries. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/pci-sysfs.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 793412954529..a238935c1193 100644 --- a/drivers/pci/pci-sysfs.c

[PATCH RFC 00/11] PCI: hotplug: Movable bus numbers

2019-10-24 Thread Sergey Miroshnichenko
this: pci=realloc,movable_buses ? This code is follow-up of the "PCI: Allow BAR movement during hotplug" series (v6). Sergey Miroshnichenko (11): PCI: sysfs: Nullify freed pointers PCI: proc: Nullify a freed pointer drivers: base: Make bus_add_device() public d

[PATCH v6 29/30] PCI: pciehp: movable BARs: Trigger a domain rescan on hp events

2019-10-24 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..6d4c1ef38210 100644 --- a/drivers/pci

[PATCH v6 30/30] Revert "powerpc/powernv/pci: Work around races in PCI bridge enabling"

2019-10-24 Thread Sergey Miroshnichenko
x86 is also affected by this bug if a PCIe bridge has been hotplugged without pre-enabling by the BIOS. CC: Benjamin Herrenschmidt Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/platforms/powernv/pci-ioda.c | 37 --- 1 file changed, 37 deletions(-) diff --git a/arch/powerpc/p

[PATCH v6 27/30] nvme-pci: Handle movable BARs

2019-10-24 Thread Sergey Miroshnichenko
Christoph Hellwig Signed-off-by: Sergey Miroshnichenko --- drivers/nvme/host/pci.c | 21 - 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 869f462e6b6e..5f162ea5a5f1 100644 --- a/drivers/nvme/host/pci.c +++

[PATCH v6 28/30] PCI/portdrv: Declare support of movable BARs

2019-10-24 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 v6 26/30] PCI: hotplug: movable BARs: Enable the feature by default

2019-10-24 Thread Sergey Miroshnichenko
peer". In case of problems it is still can be overridden by the following command line option: pcie_movable_bars=off CC: Oliver O'Halloran Signed-off-by: Sergey Miroshnichenko --- drivers/pci/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/pci.c b/dri

[PATCH v6 25/30] PNP: Don't reserve BARs for PCI when enabled movable BARs

2019-10-24 Thread Sergey Miroshnichenko
When the Movable BARs feature is supported, the PCI subsystem is able to distribute existing BARs and allocate the new ones itself, without need to reserve gaps by BIOS. CC: Rafael J. Wysocki Signed-off-by: Sergey Miroshnichenko --- drivers/pnp/system.c | 4 1 file changed, 4 insertions

[PATCH v6 23/30] powerpc/pci: hotplug: Add support for movable BARs

2019-10-24 Thread Sergey Miroshnichenko
O'Halloran CC: Sam Bobroff Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/kernel/pci-hotplug.c | 43 +++ drivers/pci/probe.c | 10 +++ include/linux/pci.h | 3 +++ 3 files changed, 56 insertions(+) diff --git a/arch/powerpc

[PATCH v6 24/30] powerpc/powernv/pci: Suppress an EEH error when reading an empty slot

2019-10-24 Thread Sergey Miroshnichenko
Reading an empty slot returns all ones, which triggers a false EEH error event on PowerNV. A rescan is performed after all the PEs have been unmapped, so the reserved PE index is used for unfreezing. CC: Oliver O'Halloran CC: Sam Bobroff Signed-off-by: Sergey Miroshnichenko --- arch/powerpc

[PATCH v6 22/30] powerpc/pci: Create pci_dn on demand

2019-10-24 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. CC: Oliver O'Halloran CC: Sam Bobroff Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/kernel/pci_dn.c | 88

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

2019-10-24 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 v6 20/30] powerpc/pci: Fix crash with enabled movable BARs

2019-10-24 Thread Sergey Miroshnichenko
Add a check for the UNSET resource flag to skip the released BARs CC: Alexey Kardashevskiy CC: Oliver O'Halloran CC: Sam Bobroff Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/platforms/powernv/pci-ioda.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch

[PATCH v6 14/30] PCI: Make sure bridge windows include their fixed BARs

2019-10-24 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 | 31 +-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/drivers/pci/bus.c b

[PATCH v6 16/30] PCI: hotplug: movable BARs: Assign fixed and immovable BARs before others

2019-10-24 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 | 78 - drivers/pci/setup-res.c | 7 ++-- 3 files changed

[PATCH v6 19/30] PCI: hotplug: movable BARs: Ignore the MEM BAR offsets from bootloader

2019-10-24 Thread Sergey Miroshnichenko
on x86. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/probe.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 94bbdf9b9dc1..73452aa81417 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -305,6 +305,16 @@ int

[PATCH v6 18/30] PCI: hotplug: Configure MPS for hot-added bridges during bus rescan

2019-10-24 Thread Sergey Miroshnichenko
Assure that MPS settings are set up for bridges which are discovered during manually triggered rescan via sysfs. This sequence of bridge init (using pci_rescan_bus()) will be used for pciehp hot-add events when BARs are movable. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/probe.c | 5

[PATCH v6 17/30] PCI: hotplug: movable BARs: Don't reserve IO/mem bus space

2019-10-24 Thread Sergey Miroshnichenko
erved gaps, but via rearranging the existing BARs. Requesting a precise amount of space for bridge windows increases the chances of adding the new bridge successfully. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/setup-bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git

[PATCH v6 15/30] PCI: Fix assigning the fixed prefetchable resources

2019-10-24 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 v6 13/30] PCI: hotplug: movable BARs: Compute limits for relocated bridge windows

2019-10-24 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 a7546e02ea7c..653ba4d5f191 100644 --- a/d

[PATCH v6 12/30] PCI: hotplug: movable BARs: Calculate immovable parts of bridge windows

2019-10-24 Thread Sergey Miroshnichenko
l result OR the size of an immovable range of according type, depending on which one is larger. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/pci.h | 14 +++ drivers/pci/probe.c | 88 + drivers/pci/setup-bus.c | 17 include/linu

[PATCH v6 11/30] PCI: hotplug: movable BARs: Try to assign unassigned resources only once

2019-10-24 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 v6 10/30] PCI: Prohibit assigning BARs and bridge windows to non-direct parents

2019-10-24 Thread Sergey Miroshnichenko
Signed-off-by: Sergey Miroshnichenko --- drivers/pci/setup-bus.c | 2 ++ drivers/pci/setup-res.c | 12 2 files changed, 14 insertions(+) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index ff33b47b1bb7..cf325daae1b1 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers

[PATCH v6 09/30] PCI: Include fixed and immovable BARs into the bus size calculating

2019-10-24 Thread Sergey Miroshnichenko
assigning them to non-direct parents. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/setup-bus.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 4b538d132958..ff33b47b1bb7 100644 --- a/drivers/pci/setup

[PATCH v6 06/30] PCI: hotplug: movable BARs: Recalculate all bridge windows during rescan

2019-10-24 Thread Sergey Miroshnichenko
devices, especially if no/not enough gaps were reserved by the BIOS/bootloader/firmware. 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

[PATCH v6 08/30] PCI: hotplug: movable BARs: Don't allow added devices to steal resources

2019-10-24 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 v6 05/30] PCI: hotplug: movable BARs: Fix reassigning the released bridge windows

2019-10-24 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 2c02eb1acf5d..f2f02e6c9000 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -295,7 +295,8 @@ static

[PATCH v6 07/30] PCI: hotplug: movable BARs: Don't disable the released bridge windows

2019-10-24 Thread Sergey Miroshnichenko
operating after releasing, as they will be updated to the new values in the end of a hotplug event. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/setup-bus.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 075e8185b936

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

2019-10-24 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 v6 00/30] PCI: Allow BAR movement during hotplug

2019-10-24 Thread Sergey Miroshnichenko
ct pci_error_handlers; - Add a bugfix of a race condition; - Fixed hotplug in a 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

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

2019-10-24 Thread Sergey Miroshnichenko
ault until the final patch of the series. It can be overridden per-arch using the pci_can_move_bars=false flag or by the following command line option: pci=no_movable_bars CC: Sam Bobroff CC: Rajat Jain CC: Lukas Wunner CC: Oliver O'Halloran CC: David Laight Signed-off-by: Sergey Miro

[PATCH v6 02/30] PCI: Enable bridge's I/O and MEM access for hotplugged devices

2019-10-24 Thread Sergey Miroshnichenko
if the bridge is already pci_is_enabled(). So if the bridge was empty initially (an edge case), then hotplugged devices fail to IO/MEM. 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 v6 01/30] PCI: Fix race condition in pci_enable/disable_device()

2019-10-24 Thread Sergey Miroshnichenko
n from commit 40f11adc7cd9 ("PCI: Avoid race while enabling upstream bridges"), but adding a per-device mutexes and preventing the dev->enable_cnt from from incrementing early. CC: Srinath Mannam CC: Marta Rybczynska Signed-off-by: Sergey Miroshnichenko [1] https://lore.kernel.org/l

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

2019-10-16 Thread Sergey Miroshnichenko
On 10/16/19 1:14 AM, Bjorn Helgaas wrote: On Mon, Sep 30, 2019 at 03:59:25PM +0300, Sergey Miroshnichenko wrote: Hello Bjorn, On 9/28/19 1:02 AM, Bjorn Helgaas wrote: On Fri, Aug 16, 2019 at 07:50:41PM +0300, Sergey Miroshnichenko wrote: When hot-adding a device, the bridge may have windows

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

2019-09-30 Thread Sergey Miroshnichenko
Hello David, On 9/30/19 11:44 AM, David Laight wrote: From: Bjorn Helgaas Sent: 27 September 2019 23:02 On Fri, Aug 16, 2019 at 07:50:41PM +0300, Sergey Miroshnichenko wrote: When hot-adding a device, the bridge may have windows not big enough (or fragmented too much) for newly requested BARs

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

2019-09-30 Thread Sergey Miroshnichenko
Hello Bjorn, On 9/28/19 1:02 AM, Bjorn Helgaas wrote: On Fri, Aug 16, 2019 at 07:50:41PM +0300, Sergey Miroshnichenko wrote: When hot-adding a device, the bridge may have windows not big enough (or fragmented too much) for newly requested BARs to fit in. And expanding these bridge windows may

Re: [PATCH v5 01/23] PCI: Fix race condition in pci_enable/disable_device()

2019-09-30 Thread Sergey Miroshnichenko
Hello Bjorn, On 9/28/19 12:59 AM, Bjorn Helgaas wrote: On Fri, Aug 16, 2019 at 07:50:39PM +0300, Sergey Miroshnichenko wrote: This is a yet another approach to fix an old [1-2] concurrency issue, when: - two or more devices are being hot-added into a bridge which was initially empty

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

2019-09-06 Thread Sergey Miroshnichenko
Hi Oliver, On 9/4/19 8:37 AM, Oliver O'Halloran wrote: > On Fri, 2019-08-16 at 19:50 +0300, Sergey Miroshnichenko wrote: >> Add pcibios_rescan_prepare()/_done() hooks for the powerpc platform. Now if >> the device's driver supports movable BARs, pcibios_rescan_prepare() will be

Re: [PATCH v5 16/23] PCI: hotplug: movable BARs: Don't reserve IO/mem bus space

2019-09-04 Thread Sergey Miroshnichenko
On 9/4/19 8:42 AM, Oliver O'Halloran wrote: > On Fri, 2019-08-16 at 19:50 +0300, Sergey Miroshnichenko wrote: >> A hotplugged bridge with many hotplug-capable ports may request >> reserving more IO space than the machine has. This could be overridden >> with the "hpiosiz

[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 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 21/23] nvme-pci: Handle movable BARs

2019-08-16 Thread Sergey Miroshnichenko
e80080-3fe8008f : nvme 3fe80090-3fe80097 : 0020:18:00.0 ... During the rescanning, both READ and WRITE speeds drop to zero for a while due to driver's pause, then restore. Cc: linux-n...@lists.infradead.org Cc: Christoph Hellwig Signed-off-by: Sergey Miro

[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 19/23] PCI: hotplug: Configure MPS for hot-added bridges during bus rescan

2019-08-16 Thread Sergey Miroshnichenko
Assure that MPS settings are set up for bridges which are discovered during manually triggered rescan via sysfs. This sequence of bridge init (using pci_rescan_bus()) will be used for pciehp hot-add events when BARs are movable. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/probe.c | 5

[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 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 v5 17/23] powerpc/pci: Fix crash with enabled movable BARs

2019-08-16 Thread Sergey Miroshnichenko
Add a check for the UNSET resource flag to skip the released BARs CC: Alexey Kardashevskiy 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

[PATCH v5 16/23] PCI: hotplug: movable BARs: Don't reserve IO/mem bus space

2019-08-16 Thread Sergey Miroshnichenko
erved gaps, but via rearranging the existing BARs. Requesting a precise amount of space for bridge windows increases the chances of adding the new bridge successfully. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/setup-bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git

[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 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 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 11/23] PCI: hotplug: movable BARs: Calculate immovable parts of bridge windows

2019-08-16 Thread Sergey Miroshnichenko
l result OR the size of an immovable range of according type, depending on which one is larger. Signed-off-by: Sergey Miroshnichenko --- drivers/pci/pci.h | 14 +++ drivers/pci/probe.c | 88 + drivers/pci/setup-bus.c | 17 include/linu

[PATCH v5 09/23] PCI: Prohibit assigning BARs and bridge windows to non-direct parents

2019-08-16 Thread Sergey Miroshnichenko
Signed-off-by: Sergey Miroshnichenko --- drivers/pci/setup-bus.c | 2 ++ drivers/pci/setup-res.c | 12 2 files changed, 14 insertions(+) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 2c250efca512..aee330047121 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers

[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 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 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 06/23] PCI: hotplug: movable BARs: Recalculate all bridge windows during rescan

2019-08-16 Thread Sergey Miroshnichenko
devices, especially if no/not enough gaps were reserved by the BIOS/bootloader/firmware. 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

[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 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 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 01/23] PCI: Fix race condition in pci_enable/disable_device()

2019-08-16 Thread Sergey Miroshnichenko
n from commit 40f11adc7cd9 ("PCI: Avoid race while enabling upstream bridges"), but adding a per-device mutexes and preventing the dev->enable_cnt from from incrementing early. CC: Srinath Mannam CC: Marta Rybczynska Signed-off-by: Sergey Miroshnichenko [1] https://lore.kernel.org/l

[PATCH v5 02/23] PCI: Enable bridge's I/O and MEM access for hotplugged devices

2019-08-16 Thread Sergey Miroshnichenko
if the bridge is already pci_is_enabled(). So if the bridge was empty initially (an edge case), then hotplugged devices fail to IO/MEM. 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 v5 00/23] PCI: Allow BAR movement during hotplug

2019-08-16 Thread Sergey Miroshnichenko
d hotplug in a 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 (23): PCI: Fix race condition in pci_enable/di

[PATCH v6 5/5] powerpc/pci: Enable assigning bus numbers instead of reading them from DT

2019-08-16 Thread Sergey Miroshnichenko
php module to the standard pciehp driver for PCI hotplug functionality. Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/kernel/pci_dn.c | 5 + arch/powerpc/platforms/powernv/eeh-powernv.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kerne

[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 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 v6 2/5] powerpc/powernv/pci: Suppress an EEH error when reading an empty slot

2019-08-16 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. Reviewed-by: Oliver O'Halloran Signed-off-by: Sergey Miroshnichenko --- arch/powerpc/include/asm/ppc-pci.h | 1 + arch/powerpc/kernel/pci_dn.c

[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 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

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.

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 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 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

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 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 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 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

[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 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 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 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 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 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 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 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 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 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 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 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 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

  1   2   >