On 05/08/2014 10:07 PM, Alexander Graf wrote: > On 05/07/2014 08:01 AM, Alexey Kardashevskiy wrote: >> Signed-off-by: Alexey Kardashevskiy <a...@ozlabs.ru> >> --- >> hw/intc/xics.c | 24 ++++++++++++++++++++++++ >> include/hw/ppc/xics.h | 1 + >> trace-events | 2 ++ >> 3 files changed, 27 insertions(+) >> >> diff --git a/hw/intc/xics.c b/hw/intc/xics.c >> index faf304c..2316519 100644 >> --- a/hw/intc/xics.c >> +++ b/hw/intc/xics.c >> @@ -755,6 +755,30 @@ int xics_alloc_block(XICSState *icp, int server, int >> num, bool lsi, bool align) >> return first + ics->offset; >> } >> +static void ics_free(ICSState *ics, int srcno, int num) >> +{ >> + int i; >> + >> + for (i = srcno; i < srcno + num; ++i) { >> + if (ICS_IRQ_FREE(ics, i)) { >> + trace_xics_ics_free_warn(ics - ics->icp->ics, i + ics->offset); >> + } >> + memset(&ics->irqs[i], 0, sizeof(ICSIRQState)); > > Why does this do something different from ics_reset?
ics_reset() resets the interrupt state which still remains allocated and assigned to some device. ics_free() clears the descriptor and this interrupt may be now returned if someone asks for a new interrupt (pci hotplug, intx->msi switch). > Alex > >> + } >> +} >> + >> +void xics_free(XICSState *icp, int server, int irq, int num) >> +{ >> + ICSState *ics = &icp->ics[server]; >> + >> + assert(server == 0); >> + >> + trace_xics_ics_free(ics - icp->ics, irq, num); >> + if (server >= 0) { >> + ics_free(ics, irq - ics->offset, num); >> + } >> +} >> + >> /* >> * Guest interfaces >> */ >> diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h >> index 0f01a21..e5d8f47 100644 >> --- a/include/hw/ppc/xics.h >> +++ b/include/hw/ppc/xics.h >> @@ -158,6 +158,7 @@ struct ICSIRQState { >> qemu_irq xics_get_qirq(XICSState *icp, int irq); >> int xics_alloc(XICSState *icp, int server, int irq_hint, bool lsi); >> int xics_alloc_block(XICSState *icp, int server, int num, bool lsi, >> bool align); >> +void xics_free(XICSState *icp, int server, int irq, int num); >> void xics_cpu_setup(XICSState *icp, PowerPCCPU *cpu); >> diff --git a/trace-events b/trace-events >> index 8cf8fb2..5ca126c 100644 >> --- a/trace-events >> +++ b/trace-events >> @@ -1179,6 +1179,8 @@ xics_alloc(int server, int irq) "server#%d, irq %d" >> xics_alloc_failed_hint(int server, int irq) "server#%d, irq %d is >> already in use" >> xics_alloc_failed_no_left(int server) "server#%d, no irq left" >> xics_alloc_block(int server, int first, int num, bool lsi, int align) >> "server#%d, first irq %d, %d irqs, lsi=%d, alignnum %d" >> +xics_ics_free(int server, int irq, int num) "server#%d, first irq %d, %d >> irqs" >> +xics_ics_free_warn(int server, int irq) "server#%d, irq %d is already free" >> # hw/ppc/spapr_iommu.c >> spapr_iommu_put(uint64_t liobn, uint64_t ioba, uint64_t tce, uint64_t >> ret) "liobn=%"PRIx64" ioba=0x%"PRIx64" tce=0x%"PRIx64" ret=%"PRId64 > -- Alexey