From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35724) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJXC3-00086E-Li for qemu-devel@nongnu.org; Mon, 18 Aug 2014 20:22:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XJXBt-0003uC-TL for qemu-devel@nongnu.org; Mon, 18 Aug 2014 20:22:31 -0400 Received: from e31.co.us.ibm.com ([32.97.110.149]:50206) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJXBt-0003u6-NH for qemu-devel@nongnu.org; Mon, 18 Aug 2014 20:22:21 -0400 Received: from /spool/local by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 18 Aug 2014 18:22:20 -0600 From: Michael Roth Date: Mon, 18 Aug 2014 19:21:46 -0500 Message-Id: <1408407718-10835-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH v3 00/12] spapr: add support for pci hotplug List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aik@ozlabs.ru, agraf@suse.de, ncmike@ncultra.org, qemu-ppc@nongnu.org, tyreld@linux.vnet.ibm.com, nfont@linux.vnet.ibm.com These patches are based on ppc-next, and can also be obtained from: https://github.com/mdroth/qemu/commits/spapr-pci-hotplug-v3-ppc-next v3: * dropped emulation of firmware-managed BAR allocation. this will be introduced via a follow-up series via a -machine flag and tied to a separate hotplug event to avoid a race condition with guest vs. "firmware"-managed BAR allocation, in conjunction with required fixes to rpaphp hotplug kernel module to utilize this mode. * moved drc_table into sPAPREnvironment (Alexey) * moved INDICATOR_* constants and friends into spapr_pci.c (Alexey) * use prefixes for global types (DrcEntry/ConfigureConnectorState) (Alexey) * updated for new hotplug interface (Alexey) * fixed get-power-level to report current power-level rather than desired (Alexey) * rebased to latest ppc-next v2: * re-ordered patches to fix build bisectability (Alexey) * replaced g_warning with DPRINTF in RTAS calls for guest errors (Alexey) * replaced g_warning with fprintf for qemu errors (Alexey) * updated RTAS calls to use pre-existing error/success macros (Alexey) * replaced DR_*/SENSOR_* macros with INDICATOR_* for set-indicator/ get-sensor-state (Alexey) 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 This series relies on v1.2.19 or later of powerppc-utils (drmgr, rtas_errd, ppc64-diag, and librtas components, specificially), which will automate guest-side hotplug setup in response to an EPOW event emitted by QEMU. For guests with older versions of powerpc-utils, a manual workaround must be used (documented below). PATCH LAYOUT Patches 1-3 advertise PHBs and associated slots as hotpluggable to guests 4-7 add RTAS interfaces required for device configuration 8 fix for ppc (and other) guests that allocate IO bars starting at 0x0 9 enables device_add/device_del for spapr machines and guest-driven hotplug 10-12 define hotplug event structure and emit them in response to device_add/device_del USAGE For guests with powerpc-utils 1.2.19+: hotplug: qemu: device_add e1000,id=slot0 unplug: qemu: device_del slot0 For guests with powerpc-utils prior to 1.2.19: 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 hw/pci/pci.c | 2 +- hw/ppc/spapr.c | 172 +++++++++++++++++++++++++++++++++- hw/ppc/spapr_events.c | 224 ++++++++++++++++++++++++++++++++++++-------- hw/ppc/spapr_pci.c | 689 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- include/hw/pci-host/spapr.h | 1 + include/hw/ppc/spapr.h | 46 ++++++++- 6 files changed, 1083 insertions(+), 51 deletions(-)