From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43799) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZdCPc-0008Eo-VS for qemu-devel@nongnu.org; Sat, 19 Sep 2015 03:18:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZdCPc-0003pa-1T for qemu-devel@nongnu.org; Sat, 19 Sep 2015 03:18:20 -0400 From: David Gibson Date: Sat, 19 Sep 2015 17:18:26 +1000 Message-Id: <1442647117-2726-4-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 03/14] spapr_pci: Expose and generalize spapr_phb_check_vfio_group() 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 At the moment spapr_phb_check_vfio_group() assumes it is always passed an instance of "spapr-pci-vfio-host-bridge", which it is. However we want to unify more of the code with core PAPR PCI, so this changes it to be safe on any "spapr-pci-host-bridge" instance. For now we just return an error if it's not a VFIO host bridge. We also expose the function, because we'll be needing it elsewhere. Signed-off-by: David Gibson --- hw/ppc/spapr_pci_vfio.c | 6 +++++- include/hw/pci-host/spapr.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr_pci_vfio.c b/hw/ppc/spapr_pci_vfio.c index a2b1093..047fb30 100644 --- a/hw/ppc/spapr_pci_vfio.c +++ b/hw/ppc/spapr_pci_vfio.c @@ -31,10 +31,14 @@ static Property spapr_phb_vfio_properties[] = { DEFINE_PROP_END_OF_LIST(), }; -static int spapr_phb_check_vfio_group(sPAPRPHBState *phb, VFIOGroup **gpp) +int spapr_phb_check_vfio_group(sPAPRPHBState *phb, VFIOGroup **gpp) { VFIOGroup *group; + if (!object_dynamic_cast(OBJECT(phb), "spapr-pci-vfio-host-bridge")) { + return RTAS_OUT_PARAM_ERROR; + } + /* FIXME: this is an abstraction violation */ group = vfio_get_group(SPAPR_PCI_VFIO_HOST_BRIDGE(phb)->iommugroupid, &phb->iommu_as); diff --git a/include/hw/pci-host/spapr.h b/include/hw/pci-host/spapr.h index 7de5e02..68cf99b 100644 --- a/include/hw/pci-host/spapr.h +++ b/include/hw/pci-host/spapr.h @@ -26,6 +26,7 @@ #include "hw/pci/pci.h" #include "hw/pci/pci_host.h" #include "hw/ppc/xics.h" +#include "hw/vfio/vfio-eeh.h" #define TYPE_SPAPR_PCI_HOST_BRIDGE "spapr-pci-host-bridge" #define TYPE_SPAPR_PCI_VFIO_HOST_BRIDGE "spapr-pci-vfio-host-bridge" @@ -133,6 +134,7 @@ void spapr_pci_msi_init(sPAPRMachineState *spapr, hwaddr addr); void spapr_pci_rtas_init(void); +int spapr_phb_check_vfio_group(sPAPRPHBState *phb, VFIOGroup **gpp); sPAPRPHBState *spapr_pci_find_phb(sPAPRMachineState *spapr, uint64_t buid); PCIDevice *spapr_pci_find_dev(sPAPRMachineState *spapr, uint64_t buid, uint32_t config_addr); -- 2.4.3