The routines manipulating the IRQ numbers for the sPAPR machine do not have any relation with the ICSState anymore. So use a sPAPRMachineState parameter in their prototype and prefix them with spapr_irq_.
Signed-off-by: Cédric Le Goater <c...@kaod.org> --- hw/intc/xics_spapr.c | 23 ++++++++++++----------- hw/ppc/spapr.c | 5 +++-- hw/ppc/spapr_events.c | 4 ++-- hw/ppc/spapr_pci.c | 8 ++++---- hw/ppc/spapr_vio.c | 2 +- include/hw/ppc/xics.h | 13 +++++++------ 6 files changed, 29 insertions(+), 26 deletions(-) diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c index 4ba23fe5125b..3f8c937c4fa1 100644 --- a/hw/intc/xics_spapr.c +++ b/hw/intc/xics_spapr.c @@ -245,19 +245,20 @@ void xics_spapr_init(sPAPRMachineState *spapr) spapr_register_hypercall(H_IPOLL, h_ipoll); } -int spapr_ics_alloc(ICSState *ics, int irq_hint, bool lsi, Error **errp) +int spapr_irq_alloc(sPAPRMachineState *spapr, int irq_hint, bool lsi, + Error **errp) { int irq; - XICSFabricClass *xic = XICS_FABRIC_GET_CLASS(ics->xics); + XICSFabricClass *xic = XICS_FABRIC_GET_CLASS(spapr); if (irq_hint) { - if (xic->irq_test(ics->xics, irq_hint)) { + if (xic->irq_test(XICS_FABRIC(spapr), irq_hint)) { error_setg(errp, "can't allocate IRQ %d: already in use", irq_hint); return -1; } irq = irq_hint; } else { - irq = xic->irq_alloc_block(ics->xics, 1, 0, lsi); + irq = xic->irq_alloc_block(XICS_FABRIC(spapr), 1, 0, lsi); if (irq < 0) { error_setg(errp, "can't allocate IRQ: no IRQ left"); return -1; @@ -273,11 +274,11 @@ int spapr_ics_alloc(ICSState *ics, int irq_hint, bool lsi, Error **errp) * Allocate block of consecutive IRQs, and return the number of the first IRQ in * the block. If align==true, aligns the first IRQ number to num. */ -int spapr_ics_alloc_block(ICSState *ics, int num, bool lsi, +int spapr_irq_alloc_block(sPAPRMachineState *spapr, int num, bool lsi, bool align, Error **errp) { int first = -1; - XICSFabricClass *xic = XICS_FABRIC_GET_CLASS(ics->xics); + XICSFabricClass *xic = XICS_FABRIC_GET_CLASS(spapr); /* @@ -290,9 +291,9 @@ int spapr_ics_alloc_block(ICSState *ics, int num, bool lsi, if (align) { assert((num == 1) || (num == 2) || (num == 4) || (num == 8) || (num == 16) || (num == 32)); - first = xic->irq_alloc_block(ics->xics, num, num, lsi); + first = xic->irq_alloc_block(XICS_FABRIC(spapr), num, num, lsi); } else { - first = xic->irq_alloc_block(ics->xics, num, 0, lsi); + first = xic->irq_alloc_block(XICS_FABRIC(spapr), num, 0, lsi); } if (first < 0) { error_setg(errp, "can't find a free %d-IRQ block", num); @@ -304,10 +305,10 @@ int spapr_ics_alloc_block(ICSState *ics, int num, bool lsi, return first; } -void spapr_ics_free(ICSState *ics, int irq, int num) +void spapr_irq_free(sPAPRMachineState *spapr, int irq, int num) { - XICSFabricClass *xic = XICS_FABRIC_GET_CLASS(ics->xics); - xic->irq_free_block(ics->xics, irq, num); + XICSFabricClass *xic = XICS_FABRIC_GET_CLASS(spapr); + xic->irq_free_block(XICS_FABRIC(spapr), irq, num); } void spapr_dt_xics(int nr_servers, void *fdt, uint32_t phandle) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index f8224ea3e894..a5b087eb5c56 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3593,7 +3593,8 @@ static bool spapr_irq_test(XICSFabric *xi, int irq) * and then the MSIs. This allows us to keep the LSI IRQ numbers in a * well known range which is useful for PHB hotplug. */ -static int spapr_irq_alloc_block(XICSFabric *xi, int count, int align, bool lsi) +static int spapr_irq_alloc_block_xi(XICSFabric *xi, int count, int align, + bool lsi) { sPAPRMachineState *spapr = SPAPR_MACHINE(xi); sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr); @@ -3750,7 +3751,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) xic->ics_resend = spapr_ics_resend; xic->icp_get = spapr_icp_get; xic->irq_test = spapr_irq_test; - xic->irq_alloc_block = spapr_irq_alloc_block; + xic->irq_alloc_block = spapr_irq_alloc_block_xi; xic->irq_free_block = spapr_irq_free_block; xic->irq_is_lsi = spapr_irq_is_lsi; diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c index e377fc7ddea2..cead596f3e7a 100644 --- a/hw/ppc/spapr_events.c +++ b/hw/ppc/spapr_events.c @@ -718,7 +718,7 @@ void spapr_events_init(sPAPRMachineState *spapr) spapr->event_sources = spapr_event_sources_new(); spapr_event_sources_register(spapr->event_sources, EVENT_CLASS_EPOW, - spapr_ics_alloc(spapr->ics, 0, false, + spapr_irq_alloc(spapr, 0, false, &error_fatal)); /* NOTE: if machine supports modern/dedicated hotplug event source, @@ -731,7 +731,7 @@ void spapr_events_init(sPAPRMachineState *spapr) */ if (spapr->use_hotplug_event_source) { spapr_event_sources_register(spapr->event_sources, EVENT_CLASS_HOT_PLUG, - spapr_ics_alloc(spapr->ics, 0, false, + spapr_irq_alloc(spapr, 0, false, &error_fatal)); } diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 5a3122a9f9f9..e0ef77a480e5 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -314,7 +314,7 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPRMachineState *spapr, return; } - spapr_ics_free(spapr->ics, msi->first_irq, msi->num); + spapr_irq_free(spapr, msi->first_irq, msi->num); if (msi_present(pdev)) { spapr_msi_setmsg(pdev, 0, false, 0, 0); } @@ -352,7 +352,7 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPRMachineState *spapr, } /* Allocate MSIs */ - irq = spapr_ics_alloc_block(spapr->ics, req_num, false, + irq = spapr_irq_alloc_block(spapr, req_num, false, ret_intr_type == RTAS_TYPE_MSI, &err); if (err) { error_reportf_err(err, "Can't allocate MSIs for device %x: ", @@ -363,7 +363,7 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPRMachineState *spapr, /* Release previous MSIs */ if (msi) { - spapr_ics_free(spapr->ics, msi->first_irq, msi->num); + spapr_irq_free(spapr, msi->first_irq, msi->num); g_hash_table_remove(phb->msi, &config_addr); } @@ -1675,7 +1675,7 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp) uint32_t irq; Error *local_err = NULL; - irq = spapr_ics_alloc_block(spapr->ics, 1, true, false, &local_err); + irq = spapr_irq_alloc_block(spapr, 1, true, false, &local_err); if (local_err) { error_propagate(errp, local_err); error_prepend(errp, "can't allocate LSIs: "); diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c index ea3bc8bd9e21..bb7ed2c537b0 100644 --- a/hw/ppc/spapr_vio.c +++ b/hw/ppc/spapr_vio.c @@ -454,7 +454,7 @@ static void spapr_vio_busdev_realize(DeviceState *qdev, Error **errp) dev->qdev.id = id; } - dev->irq = spapr_ics_alloc(spapr->ics, dev->irq, false, &local_err); + dev->irq = spapr_irq_alloc(spapr, dev->irq, false, &local_err); if (local_err) { error_propagate(errp, local_err); return; diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index 292b929e88eb..943f6f235be1 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -184,10 +184,13 @@ typedef struct XICSFabricClass { #define XICS_IRQS_SPAPR 1024 -int spapr_ics_alloc(ICSState *ics, int irq_hint, bool lsi, Error **errp); -int spapr_ics_alloc_block(ICSState *ics, int num, bool lsi, bool align, - Error **errp); -void spapr_ics_free(ICSState *ics, int irq, int num); +typedef struct sPAPRMachineState sPAPRMachineState; + +int spapr_irq_alloc(sPAPRMachineState *spapr, int irq_hint, bool lsi, + Error **errp); +int spapr_irq_alloc_block(sPAPRMachineState *spapr, int num, bool lsi, + bool align, Error **errp); +void spapr_irq_free(sPAPRMachineState *spapr, int irq, int num); void spapr_dt_xics(int nr_servers, void *fdt, uint32_t phandle); qemu_irq xics_get_qirq(XICSFabric *xi, int irq); @@ -211,8 +214,6 @@ bool ics_is_lsi(ICSState *ics, int srno); void ics_resend(ICSState *ics); void icp_resend(ICPState *ss); -typedef struct sPAPRMachineState sPAPRMachineState; - int xics_kvm_init(sPAPRMachineState *spapr, Error **errp); void xics_spapr_init(sPAPRMachineState *spapr); -- 2.13.6