On 02/23/2017 03:39 AM, David Gibson wrote: > On Thu, Feb 16, 2017 at 02:47:35PM +0100, Cédric Le Goater wrote: >> Let's add two new handlers for ICPs. One is to get an ICP object from >> a server number and a second is to resend the irqs when needed. >> >> Signed-off-by: Cédric Le Goater <c...@kaod.org> >> --- >> hw/intc/xics.c | 2 +- >> hw/ppc/spapr.c | 20 ++++++++++++++++++++ >> include/hw/ppc/xics.h | 3 +++ >> 3 files changed, 24 insertions(+), 1 deletion(-) >> >> diff --git a/hw/intc/xics.c b/hw/intc/xics.c >> index 5131587ce088..7168c2cfd8a1 100644 >> --- a/hw/intc/xics.c >> +++ b/hw/intc/xics.c >> @@ -216,7 +216,7 @@ static void icp_check_ipi(ICPState *ss) >> qemu_irq_raise(ss->output); >> } >> >> -static void icp_resend(XICSInterface *xi, ICPState *ss) >> +void icp_resend(XICSInterface *xi, ICPState *ss) >> { >> XICSInterfaceClass *xic = XICS_INTERFACE_GET_CLASS(xi); >> >> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c >> index d1946ebcac69..eb7da32296d8 100644 >> --- a/hw/ppc/spapr.c >> +++ b/hw/ppc/spapr.c >> @@ -2915,6 +2915,24 @@ static void spapr_ics_resend(XICSInterface *dev) >> ics_resend(spapr->ics); >> } >> >> +static ICPState *spapr_icp_get(XICSInterface *xi, int server) >> +{ >> + sPAPRMachineState *spapr = SPAPR_MACHINE(xi); >> + >> + return (server < spapr->xics->nr_servers) ? &spapr->xics->ss[server] : >> + NULL; >> +} >> + >> +static void spapr_icp_resend(XICSInterface *xi) >> +{ >> + sPAPRMachineState *spapr = SPAPR_MACHINE(xi); >> + int i; >> + >> + for (i = 0; i < spapr->xics->nr_servers; i++) { >> + icp_resend(xi, &spapr->xics->ss[i]); >> + } >> +} > > I'm not quite sure where you plan to use the resend hook. AFAICT all > the existing users of this path can do fine using icp_get() then > icp_resend() directly.
This is for ics_simple_post_load(). C. > >> + >> static void spapr_machine_class_init(ObjectClass *oc, void *data) >> { >> MachineClass *mc = MACHINE_CLASS(oc); >> @@ -2959,6 +2977,8 @@ static void spapr_machine_class_init(ObjectClass *oc, >> void *data) >> vhc->hypercall = emulate_spapr_hypercall; >> xic->ics_get = spapr_ics_get; >> xic->ics_resend = spapr_ics_resend; >> + xic->icp_get = spapr_icp_get; >> + xic->icp_resend = spapr_icp_resend; >> } >> >> static const TypeInfo spapr_machine_info = { >> diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h >> index c15d8e2a8ae6..7004c851e250 100644 >> --- a/include/hw/ppc/xics.h >> +++ b/include/hw/ppc/xics.h >> @@ -191,6 +191,8 @@ typedef struct XICSInterfaceClass { >> InterfaceClass parent; >> ICSState *(*ics_get)(XICSInterface *xi, int irq); >> void (*ics_resend)(XICSInterface *xi); >> + ICPState *(*icp_get)(XICSInterface *xi, int server); >> + void (*icp_resend)(XICSInterface *xi); >> } XICSInterfaceClass; >> >> #define XICS_IRQS_SPAPR 1024 >> @@ -221,5 +223,6 @@ void ics_simple_write_xive(ICSState *ics, int nr, int >> server, >> void ics_set_irq_type(ICSState *ics, int srcno, bool lsi); >> >> void ics_resend(ICSState *ics); >> +void icp_resend(XICSInterface *xi, ICPState *ss); >> >> #endif /* XICS_H */ >