[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [RFC PATCH 03/14] spapr_pci: Expose and generalize spapr_phb_
From: |
David Gibson |
Subject: |
[Qemu-ppc] [RFC PATCH 03/14] spapr_pci: Expose and generalize spapr_phb_check_vfio_group() |
Date: |
Sat, 19 Sep 2015 17:18:26 +1000 |
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 <address@hidden>
---
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
- [Qemu-ppc] [RFC PATCH 00/14] Allow EEH on "normal" sPAPR PCI host bridge, David Gibson, 2015/09/19
- [Qemu-ppc] [RFC PATCH 03/14] spapr_pci: Expose and generalize spapr_phb_check_vfio_group(),
David Gibson <=
- [Qemu-ppc] [RFC PATCH 04/14] spapr_pci: Fold spapr_phb_vfio_eeh_configure() into spapr_pci code, David Gibson, 2015/09/19
- [Qemu-ppc] [RFC PATCH 09/14] vfio: Expose a VFIO PCI device's group for EEH, David Gibson, 2015/09/19
- [Qemu-ppc] [RFC PATCH 02/14] spapr_pci: Switch EEH to vfio_eeh_op() interface, David Gibson, 2015/09/19
- [Qemu-ppc] [RFC PATCH 14/14] vfio: Eliminate vfio_container_ioctl(), David Gibson, 2015/09/19
- [Qemu-ppc] [RFC PATCH 05/14] spapr_pci: Fold spapr_phb_vfio_eeh_reset() into spapr_pci code, David Gibson, 2015/09/19
- [Qemu-ppc] [RFC PATCH 06/14] spapr_pci: Fold spapr_phb_vfio_eeh_get_state() into spapr_pci code, David Gibson, 2015/09/19
- [Qemu-ppc] [RFC PATCH 08/14] spapr_pci: Fold spapr_phb_vfio_eeh_configure() into spapr_pci code, David Gibson, 2015/09/19