spapr_pci: add PHB unrealize
commitef28b98d58121b0a9ae94c9397d1def2531166ed
authorGreg Kurz <groug@kaod.org>
Tue, 19 Feb 2019 17:18:18 +0000 (19 18:18 +0100)
committerDavid Gibson <david@gibson.dropbear.id.au>
Mon, 25 Feb 2019 22:21:25 +0000 (26 09:21 +1100)
tree3796cf255d75f2916d7dd9486785d1c433d4276e
parentad62bff6383178fe95caff3ec63a6ca4ee398dec
spapr_pci: add PHB unrealize

To support PHB hotplug we need to clean up lingering references,
memory, child properties, etc. prior to the PHB object being
finalized. Generally this will be called as a result of calling
object_unparent() on the PHB object, which in turn would normally
be called as the result of an unplug() operation.

When the PHB is finalized, child objects will be unparented in
turn, and finalized if the PHB was the only reference holder. so
we don't bother to explicitly unparent child objects of the PHB,
with the notable exception of DRCs. This is needed to avoid a QEMU
crash when unplugging a PHB and resetting the machine before the
guest could handle the event. The DRCs are removed from the QOM tree
by  pci_unregister_root_bus() and we must make sure we're not leaving
stale aliases under the global /dr-connector path.

The formula that gives the number of DMA windows is moved to an
inline function in the hw/pci-host/spapr.h header because it
will have other users.

The unrealize function is able to cope with partially realized PHBs.
It is hence used to implement proper rollback on the realize error
path.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Message-Id: <155059669881.1466090.13515030705986041517.stgit@bahia.lab.toulouse-stg.fr.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
hw/ppc/spapr_pci.c
include/hw/pci-host/spapr.h