linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC v2 00/21] PCI: Allow BAR movement during hotplug
@ 2019-01-11 15:36 Sergey Miroshnichenko
  2019-01-11 15:36 ` [PATCH RFC v2 01/21] PCI: Fix writing invalid BARs during pci_restore_state() Sergey Miroshnichenko
                   ` (20 more replies)
  0 siblings, 21 replies; 22+ messages in thread
From: Sergey Miroshnichenko @ 2019-01-11 15:36 UTC (permalink / raw)
  To: linux-pci; +Cc: linux, Sergey Miroshnichenko, Bjorn Helgaas

If the firmware or kernel has arranged memory for PCIe devices in a way that
doesn't provide enough space for BARs of a new hotplugged device, the kernel
can pause the drivers of the "obstructing" devices and move their BARs, so
new BARs can fit into the freed spaces.

When a driver is un-paused by the kernel after the PCIe rescan, it should
check if its BARs had moved, and ioremap() them if needed.

Drivers indicate their support of the feature by implementing the new
rescan_prepare() and rescan_done() hooks in the struct pci_driver. If a
driver doesn't yet support the feature, BARs of its devices will be marked
as immovable by the IORESOURCE_PCI_FIXED flag.

To re-arrange the BARs and bridge windows this patch releases all of them
after a rescan and re-assigns in the same way as during the initial PCIe
topology scan at system boot.

Tested on:
 - x86_64 with "pci=realloc,assign-busses,use_crs"
 - ppc64le POWER8 PowerNV (with extra arch-specific patches which will be
   introduced later) with "pci=realloc pcie_movable_bars=force"

Not so many platforms and test cases were covered, so all who are interested
are highly welcome to test on your setups - the more exotic the better!

Changes since v1:
 - Add a "pcie_movable_bars={ off | force }" command line argument;
 - Handle the IORESOURCE_PCI_FIXED flag properly;
 - Don't move BARs of devices which don't support the feature;
 - Guarantee that new hotplugged devices will not steal memory from working
   devices by ignoring the failing new devices with the new PCI_DEV_IGNORE
   flag;
 - Add rescan_prepare()+rescan_done() to the struct pci_driver instead of
   using the reset_prepare()+reset_done() from struct 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.

This 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 Miroshnichenko (21):
  PCI: Fix writing invalid BARs during pci_restore_state()
  PCI: Define PCI-specific version of the release_child_resources()
  PCI: hotplug: Add a flag for the movable BARs feature
  PCI: Pause the devices with movable BARs during rescan
  PCI: Release and reassign the root bridge resources during rescan
  PCI: Don't allow hotplugged devices to steal resources
  PCI: Mark immovable BARs with PCI_FIXED
  PCI: Include fixed BARs into the bus size calculating
  PCI: Don't reserve memory for hotplug when enabled movable BARs
  PCI: Allow the failed resources to be reassigned later
  PCI: Calculate fixed areas of bridge windows based on fixed BARs
  PCI: Calculate boundaries for bridge windows
  PCI: Make sure bridge windows include their fixed BARs
  PCI: Prioritize fixed BAR assigning over the movable ones
  PCI: Fix race condition in pci_enable/disable_device()
  PCI: Enable bridge's I/O and MEM access for hotplugged devices
  PCI: pciehp: Add support for the movable BARs feature
  nvme-pci: Handle movable BARs
  powerpc/pci: Fix crash with enabled movable BARs
  PCI: Wake up bridges during rescan when movable BARs enabled
  x86: enable movable BARs

 .../admin-guide/kernel-parameters.txt         |   7 +
 arch/powerpc/platforms/powernv/pci-ioda.c     |   3 +-
 arch/x86/pci/init.c                           |   2 +
 drivers/nvme/host/pci.c                       |  29 +-
 drivers/pci/bus.c                             |   7 +-
 drivers/pci/hotplug/pciehp_pci.c              |  14 +-
 drivers/pci/pci.c                             |  60 +++-
 drivers/pci/pci.h                             |  26 ++
 drivers/pci/probe.c                           | 271 +++++++++++++++++-
 drivers/pci/setup-bus.c                       | 229 +++++++++++++--
 drivers/pci/setup-res.c                       |  45 ++-
 include/linux/pci.h                           |  14 +
 12 files changed, 670 insertions(+), 37 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2019-01-11 15:44 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-11 15:36 [PATCH RFC v2 00/21] PCI: Allow BAR movement during hotplug Sergey Miroshnichenko
2019-01-11 15:36 ` [PATCH RFC v2 01/21] PCI: Fix writing invalid BARs during pci_restore_state() Sergey Miroshnichenko
2019-01-11 15:36 ` [PATCH RFC v2 02/21] PCI: Define PCI-specific version of the release_child_resources() Sergey Miroshnichenko
2019-01-11 15:36 ` [PATCH RFC v2 03/21] PCI: hotplug: Add a flag for the movable BARs feature Sergey Miroshnichenko
2019-01-11 15:36 ` [PATCH RFC v2 04/21] PCI: Pause the devices with movable BARs during rescan Sergey Miroshnichenko
2019-01-11 15:36 ` [PATCH RFC v2 05/21] PCI: Release and reassign the root bridge resources " Sergey Miroshnichenko
2019-01-11 15:36 ` [PATCH RFC v2 06/21] PCI: Don't allow hotplugged devices to steal resources Sergey Miroshnichenko
2019-01-11 15:36 ` [PATCH RFC v2 07/21] PCI: Mark immovable BARs with PCI_FIXED Sergey Miroshnichenko
2019-01-11 15:36 ` [PATCH RFC v2 08/21] PCI: Include fixed BARs into the bus size calculating Sergey Miroshnichenko
2019-01-11 15:36 ` [PATCH RFC v2 09/21] PCI: Don't reserve memory for hotplug when enabled movable BARs Sergey Miroshnichenko
2019-01-11 15:36 ` [PATCH RFC v2 10/21] PCI: Allow the failed resources to be reassigned later Sergey Miroshnichenko
2019-01-11 15:36 ` [PATCH RFC v2 11/21] PCI: Calculate fixed areas of bridge windows based on fixed BARs Sergey Miroshnichenko
2019-01-11 15:36 ` [PATCH RFC v2 12/21] PCI: Calculate boundaries for bridge windows Sergey Miroshnichenko
2019-01-11 15:36 ` [PATCH RFC v2 13/21] PCI: Make sure bridge windows include their fixed BARs Sergey Miroshnichenko
2019-01-11 15:37 ` [PATCH RFC v2 14/21] PCI: Prioritize fixed BAR assigning over the movable ones Sergey Miroshnichenko
2019-01-11 15:37 ` [PATCH RFC v2 15/21] PCI: Fix race condition in pci_enable/disable_device() Sergey Miroshnichenko
2019-01-11 15:37 ` [PATCH RFC v2 16/21] PCI: Enable bridge's I/O and MEM access for hotplugged devices Sergey Miroshnichenko
2019-01-11 15:37 ` [PATCH RFC v2 17/21] PCI: pciehp: Add support for the movable BARs feature Sergey Miroshnichenko
2019-01-11 15:37 ` [PATCH RFC v2 18/21] nvme-pci: Handle movable BARs Sergey Miroshnichenko
2019-01-11 15:37 ` [PATCH RFC v2 19/21] powerpc/pci: Fix crash with enabled " Sergey Miroshnichenko
2019-01-11 15:37 ` [PATCH RFC v2 20/21] PCI: Wake up bridges during rescan when movable BARs enabled Sergey Miroshnichenko
2019-01-11 15:37 ` [PATCH RFC v2 21/21] x86: enable movable BARs Sergey Miroshnichenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).