Received: from eggs.gnu.org ([2001:4830:134:3::10]:43964) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZdCPg-0008Ft-Dz for qemu-devel@nongnu.org; Sat, 19 Sep 2015 03:18:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZdCPd-0003sZ-Gk for qemu-devel@nongnu.org; Sat, 19 Sep 2015 03:18:24 -0400 From: David Gibson Date: Sat, 19 Sep 2015 17:18:31 +1000 Message-Id: <1442647117-2726-9-git-send-email-david@gibson.dropbear.id.au> In-Reply-To: <1442647117-2726-1-git-send-email-david@gibson.dropbear.id.au> References: <1442647117-2726-1-git-send-email-david@gibson.dropbear.id.au> Subject: [Qemu-devel] [RFC PATCH 08/14] spapr_pci: Fold spapr_phb_vfio_eeh_configure() into spapr_pci code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: gwshan@linux.vnet.ibm.com, alex.williamson@redhat.com, aik@ozlabs.ru Cc: lvivier@redhat.com, thuth@redhat.com, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, David Gibson 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 --- hw/ppc/spapr_pci.c | 20 ++++++++++++++++++++ hw/ppc/spapr_pci_vfio.c | 24 ------------------------ 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 446770c..3a1ebea 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -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[] = { diff --git a/hw/ppc/spapr_pci_vfio.c b/hw/ppc/spapr_pci_vfio.c index 0c34283..b61923c 100644 --- a/hw/ppc/spapr_pci_vfio.c +++ b/hw/ppc/spapr_pci_vfio.c @@ -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; } -- 2.4.3