All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 00/14] spapr: add support for pci hotplug
@ 2013-12-05  1:19 Michael Roth
  2013-12-05  1:19 ` [Qemu-devel] [PATCH 01/14] spapr_pci: add set-indicator RTAS interface Michael Roth
                   ` (13 more replies)
  0 siblings, 14 replies; 21+ messages in thread
From: Michael Roth @ 2013-12-05  1:19 UTC (permalink / raw)
  To: qemu-devel; +Cc: aik, agraf, ncmike, paulus, tyreld, nfont, qemu-ppc

This patches are based on ppc-next, and can also be obtained from:

https://github.com/mdroth/qemu/commits/spapr-pci-hotplug-r4-ppc-next

OVERVIEW

These patches add support for PCI hotplug for SPAPR guests. We advertise
each PHB as DR-capable (as defined by PAPR 13.5/13.6) with 32 hotpluggable
PCI slots per PHB, which models a standard PCI expansion device for Power
machines where the DRC name/loc-code/index for each slot are generated
based on bus/slot number.

This is compatible with existing guest kernel's via the rpaphp hotplug
module, and existing userspace tools such as drmgr/librtas/rtas_errd for
managing devices, in theory...

NOTES / ADDITIONAL DEPENDENCIES

Due to an issue with rpaphp, a workaround must be used for older guest
kernels which relies on using bus rescan / remove sysfs interfaces instead
of rpaphp-provided hotplug interfaces.

Guest kernel fixes for rpaphp are in progress and available for testing
here (there's still currently a benign issue with duplicate eeh sysfs
entries with these, but the full guest-driven hotplug workflow is
functional):

  https://github.com/mdroth/linux/commits/pci-hotplug-fixes

Alternatively, there are updated userspace tools which add a "-v" option
to drmgr to utilize bus rescan/remove instead of relying on rpaphp:

  https://github.com/tyreld/powerpc-utils/commits/hotplug

It's possible to test guest-driven hotplug without either of these using
a workaround (see USAGE below), but not recommended.

PAPR does not currently define a mechanism for generating PCI
hotplug/unplug events, and relies on guest-driven management of devices,
so as part of this series we also introduce an extension to the existing
EPOW power event reporting mechanism (where a guest will query for events
via check-exception RTAS calls in response to an external interrupt) to
surface hotplug/unplug events with the information needed to manage the
devices automatically via the rtas_errd guest service. In order to enable
this qemu-driven hotplug/unplug workflow (for parity with ACPI/SHPC-based
guests), updated versions of librtas/ppc64-diag are required, which are
available here:

  https://github.com/tyreld/ppc64-diag/commits/hotplug
  https://github.com/tyreld/librtas/commits/hotplug

Lacking those, users must manage device hotplug/unplug manually.

Additionally, PAPR requires the presence of additional OF properties
(ibm,my-drc-index and loc-code) for hotpluggable slots that have already
been populated at the time of boot to support unplug, so an updated SLOF
is required to allow for device unplug after a guest reboot. (these
properties cannot currently be added to boot-time FDT, since they will
conflict with SLOF-generated device nodes, so we either need to teach
SLOF to re-use/merge existing entries, or simply have it generate the
required properties values for board-qemu, which is the approach taken
here). A patch for SLOF is available below, along with a pre-built
SLOF binary which includes it (for testing):

  https://github.com/mdroth/SLOF/commit/2e09a2950db0ce8ed464b80cccfea56dccf85d66
  https://github.com/mdroth/qemu/blob/19a390e3270a7defc7158ce29e52ff2b27d666ae/pc-bios/slof.bin

PATCH LAYOUT

Patches 1-4   add RTAS interfaces required for device configuration
        5-6   advertise PHBs and associated slots as hotpluggable to guests
        8-10  add helpers and a possible fix for BAR-assignment handling
        11    enables device_add/device_del for spapr machines and
              guest-driven hotplug
        12-14 define hotplug event structure and emit them in response to
              device_add/device_del

USAGE

With unmodified guests:
  hotplug:
    qemu:
      device_add e1000,id=slot0
    guest:
      drmgr -c pci -s "Slot 0" -n -a
      echo 1 >/sys/bus/pci/rescan
  unplug:
    guest:
      drmgr -c pci -s "Slot 0" -n -r
      echo 1 >/sys/bus/pci/devices/0000:00:00.0/remove
    qemu:
      device_del slot0

With only updated guest kernel:
  hotplug:
    qemu:
      device_add e1000,id=slot0
    guest:
      modprobe rpaphp
      drmgr -c pci -s "Slot 0" -n -a
  unplug:
    guest:
      drmgr -c pci -s "Slot 0" -n -r
    qemu:
      device_del slot0

With only updated powerpc-utils/drmgr:
  hotplug:
    qemu:
      device_add e1000,id=slot0
    guest:
      drmgr -c pci -s "Slot 0" -n -v -a
  unplug:
    guest:
      drmgr -c pci -s "Slot 0" -n -v -r
    qemu:
      device_del slot0

With updated librtas/ppc64-diag and either an updated guest kernel or drmgr:
  hotplug:
    qemu:
      device_add e1000,id=slot0
  unplug:
    qemu:
      device_del slot0

 hw/pci/pci.c                |    5 +-
 hw/ppc/spapr.c              |  174 +++++++++-
 hw/ppc/spapr_events.c       |  228 ++++++++++---
 hw/ppc/spapr_pci.c          |  768 ++++++++++++++++++++++++++++++++++++++++++-
 include/exec/memory.h       |   34 ++
 include/hw/pci-host/spapr.h |    1 +
 include/hw/pci/pci.h        |    1 +
 include/hw/ppc/spapr.h      |   77 ++++-
 memory.c                    |   50 +++
 9 files changed, 1286 insertions(+), 52 deletions(-)

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

end of thread, other threads:[~2013-12-05 17:30 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-05  1:19 [Qemu-devel] [PATCH 00/14] spapr: add support for pci hotplug Michael Roth
2013-12-05  1:19 ` [Qemu-devel] [PATCH 01/14] spapr_pci: add set-indicator RTAS interface Michael Roth
2013-12-05  2:33   ` Alexey Kardashevskiy
2013-12-05 17:05     ` Michael Roth
2013-12-05  1:19 ` [Qemu-devel] [PATCH 02/14] spapr_pci: add get/set-power-level RTAS interfaces Michael Roth
2013-12-05  1:19 ` [Qemu-devel] [PATCH 03/14] spapr_pci: add get-sensor-state RTAS interface Michael Roth
2013-12-05  2:47   ` Alexey Kardashevskiy
2013-12-05 17:29     ` Michael Roth
2013-12-05  1:19 ` [Qemu-devel] [PATCH 04/14] spapr_pci: add ibm, configure-connector " Michael Roth
2013-12-05  1:19 ` [Qemu-devel] [PATCH 05/14] spapr: populate DRC entries for root dt node Michael Roth
2013-12-05  1:19 ` [Qemu-devel] [PATCH 06/14] spapr_pci: populate DRC dt entries for PHBs Michael Roth
2013-12-05  1:19 ` [Qemu-devel] [PATCH 07/14] spapr: add helper to retrieve a PHB/device DrcEntry Michael Roth
2013-12-05  2:30   ` Alexey Kardashevskiy
2013-12-05 17:29     ` Michael Roth
2013-12-05  1:19 ` [Qemu-devel] [PATCH 08/14] memory: add memory_region_find_subregion Michael Roth
2013-12-05  1:19 ` [Qemu-devel] [PATCH 09/14] pci: make pci_bar useable outside pci.c Michael Roth
2013-12-05  1:19 ` [Qemu-devel] [PATCH 10/14] pci: allow 0 address for PCI IO regions Michael Roth
2013-12-05  1:19 ` [Qemu-devel] [PATCH 11/14] spapr_pci: enable basic hotplug operations Michael Roth
2013-12-05  1:19 ` [Qemu-devel] [PATCH 12/14] spapr_events: re-use EPOW event infrastructure for hotplug events Michael Roth
2013-12-05  1:19 ` [Qemu-devel] [PATCH 13/14] spapr_events: event-scan RTAS interface Michael Roth
2013-12-05  1:19 ` [Qemu-devel] [PATCH 14/14] spapr_pci: emit hotplug add/remove events during hotplug Michael Roth

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.