From patchwork Sat Sep 19 07:18:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 519638 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A46B31401F0 for ; Sat, 19 Sep 2015 17:23:44 +1000 (AEST) Received: from localhost ([::1]:44148 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZdCUo-0008Hu-Ak for incoming@patchwork.ozlabs.org; Sat, 19 Sep 2015 03:23:42 -0400 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 Received: from ozlabs.org ([103.22.144.67]:51746) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZdCPd-0003r5-4t; Sat, 19 Sep 2015 03:18:21 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 411D214090B; Sat, 19 Sep 2015 17:18:17 +1000 (AEST) From: David Gibson To: gwshan@linux.vnet.ibm.com, alex.williamson@redhat.com, aik@ozlabs.ru Date: Sat, 19 Sep 2015 17:18:31 +1000 Message-Id: <1442647117-2726-9-git-send-email-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.4.3 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> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 103.22.144.67 Cc: lvivier@redhat.com, thuth@redhat.com, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, David Gibson Subject: [Qemu-devel] [RFC PATCH 08/14] spapr_pci: Fold spapr_phb_vfio_eeh_configure() into spapr_pci code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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; }