@@ -1533,10 +1533,30 @@ static int spapr_phb_children_reset(Object *child, void *opaque)
return 0;
}
+static void spapr_phb_eeh_reenable(sPAPRPHBState *phb)
+{
+ VFIOGroup *group;
+ int ret;
+
+ ret = spapr_phb_check_vfio_group(phb, &group);
+ if (ret != RTAS_OUT_SUCCESS) {
+ return;
+ }
+ vfio_eeh_op(group, VFIO_EEH_PE_ENABLE);
+}
+
static void spapr_phb_reset(DeviceState *qdev)
{
/* Reset the IOMMU state */
object_child_foreach(OBJECT(qdev), spapr_phb_children_reset, NULL);
+
+ /*
+ * The PE might be in frozen state. To reenable the EEH
+ * functionality on it will clean the frozen state, which
+ * ensures that the contained PCI devices will work properly
+ * after reboot.
+ */
+ spapr_phb_eeh_reenable(SPAPR_PCI_HOST_BRIDGE(qdev));
}
static Property spapr_phb_properties[] = {
@@ -91,36 +91,12 @@ static void spapr_phb_vfio_finish_realize(sPAPRPHBState *sphb, Error **errp)
spapr_tce_get_iommu(tcet));
}
-static void spapr_phb_vfio_eeh_reenable(sPAPRPHBVFIOState *svphb)
-{
- VFIOGroup *group;
- int ret;
-
- ret = spapr_phb_check_vfio_group(SPAPR_PCI_HOST_BRIDGE(svphb), &group);
- if (ret != RTAS_OUT_SUCCESS) {
- return;
- }
- vfio_eeh_op(group, VFIO_EEH_PE_ENABLE);
-}
-
-static void spapr_phb_vfio_reset(DeviceState *qdev)
-{
- /*
- * The PE might be in frozen state. To reenable the EEH
- * functionality on it will clean the frozen state, which
- * ensures that the contained PCI devices will work properly
- * after reboot.
- */
- spapr_phb_vfio_eeh_reenable(SPAPR_PCI_VFIO_HOST_BRIDGE(qdev));
-}
-
static void spapr_phb_vfio_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
sPAPRPHBClass *spc = SPAPR_PCI_HOST_BRIDGE_CLASS(klass);
dc->props = spapr_phb_vfio_properties;
- dc->reset = spapr_phb_vfio_reset;
spc->finish_realize = spapr_phb_vfio_finish_realize;
}
Because spapr_phb_check_vfio_group() now safely returns an error on a non VFIO papr host bridge, it becomes safe to call spapr_phb_vfio_eeh_reenable() on any host bridge, not just the special VFIO host bridges. Thus the same is true of spapr_phb_vfio_reset() which does nothing but call spapr_phb_vfio_eeh_reenable(). So, we can call spapr_phb_vfio_eeh_reenable() from the normal PAPR host bridge reset hook, instead of overriding the hook in spapr-pci-vfio-host-bridge to only call it there. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> --- hw/ppc/spapr_pci.c | 20 ++++++++++++++++++++ hw/ppc/spapr_pci_vfio.c | 24 ------------------------ 2 files changed, 20 insertions(+), 24 deletions(-)