qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH RFC 4/4] sPAPR: Remove EEH callbacks in sPAPRPHBClas


From: Gavin Shan
Subject: [Qemu-devel] [PATCH RFC 4/4] sPAPR: Remove EEH callbacks in sPAPRPHBClass
Date: Fri, 18 Sep 2015 16:30:16 +1000

Currently, the EEH operations implemented in the callbacks in
sPAPRPHBClass, which will be dropped soon. This makes those
functions corresponding to the EEH callbacks in sPAPRPHBClass
public so that they can be called directly.

Signed-off-by: Gavin Shan <address@hidden>
---
 hw/ppc/spapr_pci.c          | 44 ++++----------------------------------------
 hw/ppc/spapr_pci_vfio.c     | 33 +++++++++++----------------------
 include/hw/pci-host/spapr.h | 11 +++++++----
 3 files changed, 22 insertions(+), 66 deletions(-)

diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 93d55ab..5e63ee5 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -431,7 +431,6 @@ static void rtas_ibm_set_eeh_option(PowerPCCPU *cpu,
                                     target_ulong rets)
 {
     sPAPRPHBState *sphb;
-    sPAPRPHBClass *spc;
     PCIDevice *pdev;
     uint32_t addr, option;
     uint64_t buid;
@@ -456,12 +455,7 @@ static void rtas_ibm_set_eeh_option(PowerPCCPU *cpu,
         goto param_error_exit;
     }
 
-    spc = SPAPR_PCI_HOST_BRIDGE_GET_CLASS(sphb);
-    if (!spc->eeh_set_option) {
-        goto param_error_exit;
-    }
-
-    ret = spc->eeh_set_option(sphb, addr, option);
+    ret = spapr_phb_vfio_eeh_set_option(sphb, addr, option);
     rtas_st(rets, 0, ret);
     return;
 
@@ -476,7 +470,6 @@ static void rtas_ibm_get_config_addr_info2(PowerPCCPU *cpu,
                                            target_ulong rets)
 {
     sPAPRPHBState *sphb;
-    sPAPRPHBClass *spc;
     PCIDevice *pdev;
     int groupid;
     uint32_t addr, option;
@@ -492,11 +485,6 @@ static void rtas_ibm_get_config_addr_info2(PowerPCCPU *cpu,
         goto param_error_exit;
     }
 
-    spc = SPAPR_PCI_HOST_BRIDGE_GET_CLASS(sphb);
-    if (!spc->eeh_set_option) {
-        goto param_error_exit;
-    }
-
     option = rtas_ld(args, 3);
     switch (option) {
     case RTAS_GET_PE_ADDR:
@@ -538,7 +526,6 @@ static void rtas_ibm_read_slot_reset_state2(PowerPCCPU *cpu,
                                             target_ulong rets)
 {
     sPAPRPHBState *sphb;
-    sPAPRPHBClass *spc;
     uint32_t addr;
     uint64_t buid;
     int state, ret;
@@ -554,12 +541,7 @@ static void rtas_ibm_read_slot_reset_state2(PowerPCCPU 
*cpu,
         goto param_error_exit;
     }
 
-    spc = SPAPR_PCI_HOST_BRIDGE_GET_CLASS(sphb);
-    if (!spc->eeh_get_state) {
-        goto param_error_exit;
-    }
-
-    ret = spc->eeh_get_state(sphb, addr, &state);
+    ret = spapr_phb_vfio_eeh_get_state(sphb, addr, &state);
     rtas_st(rets, 0, ret);
     if (ret != RTAS_OUT_SUCCESS) {
         return;
@@ -584,7 +566,6 @@ static void rtas_ibm_set_slot_reset(PowerPCCPU *cpu,
                                     target_ulong rets)
 {
     sPAPRPHBState *sphb;
-    sPAPRPHBClass *spc;
     uint32_t addr, option;
     uint64_t buid;
     int ret;
@@ -601,12 +582,7 @@ static void rtas_ibm_set_slot_reset(PowerPCCPU *cpu,
         goto param_error_exit;
     }
 
-    spc = SPAPR_PCI_HOST_BRIDGE_GET_CLASS(sphb);
-    if (!spc->eeh_reset) {
-        goto param_error_exit;
-    }
-
-    ret = spc->eeh_reset(sphb, addr, option);
+    ret = spapr_phb_vfio_eeh_reset(sphb, addr, option);
     rtas_st(rets, 0, ret);
     return;
 
@@ -621,7 +597,6 @@ static void rtas_ibm_configure_pe(PowerPCCPU *cpu,
                                   target_ulong rets)
 {
     sPAPRPHBState *sphb;
-    sPAPRPHBClass *spc;
     uint32_t addr;
     uint64_t buid;
     int ret;
@@ -637,12 +612,7 @@ static void rtas_ibm_configure_pe(PowerPCCPU *cpu,
         goto param_error_exit;
     }
 
-    spc = SPAPR_PCI_HOST_BRIDGE_GET_CLASS(sphb);
-    if (!spc->eeh_configure) {
-        goto param_error_exit;
-    }
-
-    ret = spc->eeh_configure(sphb, addr);
+    ret = spapr_phb_vfio_eeh_configure(sphb, addr);
     rtas_st(rets, 0, ret);
     return;
 
@@ -658,7 +628,6 @@ static void rtas_ibm_slot_error_detail(PowerPCCPU *cpu,
                                        target_ulong rets)
 {
     sPAPRPHBState *sphb;
-    sPAPRPHBClass *spc;
     int option;
     uint64_t buid;
 
@@ -672,11 +641,6 @@ static void rtas_ibm_slot_error_detail(PowerPCCPU *cpu,
         goto param_error_exit;
     }
 
-    spc = SPAPR_PCI_HOST_BRIDGE_GET_CLASS(sphb);
-    if (!spc->eeh_set_option) {
-        goto param_error_exit;
-    }
-
     option = rtas_ld(args, 7);
     switch (option) {
     case RTAS_SLOT_TEMP_ERR_LOG:
diff --git a/hw/ppc/spapr_pci_vfio.c b/hw/ppc/spapr_pci_vfio.c
index 8579ace..a99c7b3 100644
--- a/hw/ppc/spapr_pci_vfio.c
+++ b/hw/ppc/spapr_pci_vfio.c
@@ -108,10 +108,9 @@ static void spapr_phb_vfio_reset(DeviceState *qdev)
     spapr_phb_vfio_eeh_reenable(SPAPR_PCI_VFIO_HOST_BRIDGE(qdev));
 }
 
-static int spapr_phb_vfio_eeh_set_option(sPAPRPHBState *sphb,
-                                         unsigned int addr, int option)
+int spapr_phb_vfio_eeh_set_option(sPAPRPHBState *sphb,
+                                  unsigned int addr, int option)
 {
-    sPAPRPHBVFIOState *svphb = SPAPR_PCI_VFIO_HOST_BRIDGE(sphb);
     int flags, groupid = addr - 1;
     struct vfio_eeh_pe_op op = { .argsz = sizeof(op) };
     int ret;
@@ -161,8 +160,7 @@ static int spapr_phb_vfio_eeh_set_option(sPAPRPHBState 
*sphb,
 
     op.flags |= flags;
     op.groupid = groupid;
-    ret = vfio_container_ioctl(&svphb->phb.iommu_as, svphb->iommugroupid,
-                               VFIO_EEH_PE_OP, &op);
+    ret = vfio_container_ioctl(&sphb->iommu_as, groupid, VFIO_EEH_PE_OP, &op);
     if (ret < 0) {
         return RTAS_OUT_HW_ERROR;
     }
@@ -170,11 +168,9 @@ static int spapr_phb_vfio_eeh_set_option(sPAPRPHBState 
*sphb,
     return RTAS_OUT_SUCCESS;
 }
 
-static int spapr_phb_vfio_eeh_get_state(sPAPRPHBState *sphb,
-                                        unsigned int addr,
-                                        int *state)
+int spapr_phb_vfio_eeh_get_state(sPAPRPHBState *sphb,
+                                 unsigned int addr, int *state)
 {
-    sPAPRPHBVFIOState *svphb = SPAPR_PCI_VFIO_HOST_BRIDGE(sphb);
     struct vfio_eeh_pe_op op = { .argsz = sizeof(op) };
     int flags, ret;
 
@@ -186,7 +182,7 @@ static int spapr_phb_vfio_eeh_get_state(sPAPRPHBState *sphb,
     op.op = VFIO_EEH_PE_GET_STATE;
     op.flags |= flags;
     op.groupid = addr - 1;
-    ret = vfio_container_ioctl(&svphb->phb.iommu_as, svphb->iommugroupid,
+    ret = vfio_container_ioctl(&sphb->iommu_as, op.groupid,
                                VFIO_EEH_PE_OP, &op);
     if (ret < 0) {
         return RTAS_OUT_PARAM_ERROR;
@@ -239,10 +235,9 @@ static void spapr_phb_vfio_eeh_pre_reset(sPAPRPHBState 
*sphb)
        pci_for_each_bus(phb->bus, spapr_phb_vfio_eeh_clear_bus_msix, NULL);
 }
 
-static int spapr_phb_vfio_eeh_reset(sPAPRPHBState *sphb,
-                                    unsigned int addr, int option)
+int spapr_phb_vfio_eeh_reset(sPAPRPHBState *sphb,
+                             unsigned int addr, int option)
 {
-    sPAPRPHBVFIOState *svphb = SPAPR_PCI_VFIO_HOST_BRIDGE(sphb);
     struct vfio_eeh_pe_op op = { .argsz = sizeof(op) };
     int flags, ret;
 
@@ -269,7 +264,7 @@ static int spapr_phb_vfio_eeh_reset(sPAPRPHBState *sphb,
 
     op.flags |= flags;
     op.groupid = addr - 1;
-    ret = vfio_container_ioctl(&svphb->phb.iommu_as, svphb->iommugroupid,
+    ret = vfio_container_ioctl(&sphb->iommu_as, op.groupid,
                                VFIO_EEH_PE_OP, &op);
     if (ret < 0) {
         return RTAS_OUT_HW_ERROR;
@@ -278,10 +273,8 @@ static int spapr_phb_vfio_eeh_reset(sPAPRPHBState *sphb,
     return RTAS_OUT_SUCCESS;
 }
 
-static int spapr_phb_vfio_eeh_configure(sPAPRPHBState *sphb,
-                                        unsigned int addr)
+int spapr_phb_vfio_eeh_configure(sPAPRPHBState *sphb, unsigned int addr)
 {
-    sPAPRPHBVFIOState *svphb = SPAPR_PCI_VFIO_HOST_BRIDGE(sphb);
     struct vfio_eeh_pe_op op = { .argsz = sizeof(op) };
     int flags, ret;
 
@@ -293,7 +286,7 @@ static int spapr_phb_vfio_eeh_configure(sPAPRPHBState *sphb,
     op.op = VFIO_EEH_PE_CONFIGURE;
     op.flags |= flags;
     op.groupid = addr - 1;
-    ret = vfio_container_ioctl(&svphb->phb.iommu_as, svphb->iommugroupid,
+    ret = vfio_container_ioctl(&sphb->iommu_as, op.groupid,
                                VFIO_EEH_PE_OP, &op);
     if (ret < 0) {
         return RTAS_OUT_PARAM_ERROR;
@@ -310,10 +303,6 @@ static void spapr_phb_vfio_class_init(ObjectClass *klass, 
void *data)
     dc->props = spapr_phb_vfio_properties;
     dc->reset = spapr_phb_vfio_reset;
     spc->finish_realize = spapr_phb_vfio_finish_realize;
-    spc->eeh_set_option = spapr_phb_vfio_eeh_set_option;
-    spc->eeh_get_state = spapr_phb_vfio_eeh_get_state;
-    spc->eeh_reset = spapr_phb_vfio_eeh_reset;
-    spc->eeh_configure = spapr_phb_vfio_eeh_configure;
 }
 
 static const TypeInfo spapr_phb_vfio_info = {
diff --git a/include/hw/pci-host/spapr.h b/include/hw/pci-host/spapr.h
index e01bb74..488d807 100644
--- a/include/hw/pci-host/spapr.h
+++ b/include/hw/pci-host/spapr.h
@@ -49,10 +49,6 @@ struct sPAPRPHBClass {
     PCIHostBridgeClass parent_class;
 
     void (*finish_realize)(sPAPRPHBState *sphb, Error **errp);
-    int (*eeh_set_option)(sPAPRPHBState *sphb, unsigned int addr, int option);
-    int (*eeh_get_state)(sPAPRPHBState *sphb, unsigned int addr, int *state);
-    int (*eeh_reset)(sPAPRPHBState *sphb, unsigned int addr, int option);
-    int (*eeh_configure)(sPAPRPHBState *sphb, unsigned int addr);
 };
 
 typedef struct spapr_pci_msi {
@@ -136,5 +132,12 @@ void spapr_pci_rtas_init(void);
 sPAPRPHBState *spapr_pci_find_phb(sPAPRMachineState *spapr, uint64_t buid);
 PCIDevice *spapr_pci_find_dev(sPAPRMachineState *spapr, uint64_t buid,
                               uint32_t config_addr);
+int spapr_phb_vfio_eeh_set_option(sPAPRPHBState *sphb,
+                                  unsigned int addr, int option);
+int spapr_phb_vfio_eeh_get_state(sPAPRPHBState *sphb,
+                                 unsigned int addr, int *state);
+int spapr_phb_vfio_eeh_reset(sPAPRPHBState *sphb,
+                             unsigned int addr, int option);
+int spapr_phb_vfio_eeh_configure(sPAPRPHBState *sphb, unsigned int addr);
 
 #endif /* __HW_SPAPR_PCI_H__ */
-- 
2.1.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]