Received: from eggs.gnu.org ([2001:4830:134:3::10]:33090) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WksoF-0005B7-Sq for qemu-devel@nongnu.org; Thu, 15 May 2014 06:22:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wkso9-0004ee-V0 for qemu-devel@nongnu.org; Thu, 15 May 2014 06:22:43 -0400 Received: from e23smtp09.au.ibm.com ([202.81.31.142]:43116) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WksST-0005iG-F3 for qemu-devel@nongnu.org; Thu, 15 May 2014 06:00:14 -0400 Received: from /spool/local by e23smtp09.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 15 May 2014 20:00:10 +1000 From: Alexey Kardashevskiy Date: Thu, 15 May 2014 19:59:58 +1000 Message-Id: <1400147999-4793-8-git-send-email-aik@ozlabs.ru> In-Reply-To: <1400147999-4793-1-git-send-email-aik@ozlabs.ru> References: <1400147999-4793-1-git-send-email-aik@ozlabs.ru> Subject: [Qemu-devel] [PATCH v2 7/8] xics: Implement xics_ics_free() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alexey Kardashevskiy , qemu-ppc@nongnu.org, Alexander Graf This implements interrupt release function so IRQs can be returned back to the pool for reuse in cases such as PCI hot plug. Signed-off-by: Alexey Kardashevskiy --- hw/intc/xics.c | 25 +++++++++++++++++++++++++ include/hw/ppc/xics.h | 1 + trace-events | 2 ++ 3 files changed, 28 insertions(+) diff --git a/hw/intc/xics.c b/hw/intc/xics.c index 1a8cfd7..f6a2066 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -766,6 +766,31 @@ int xics_alloc_block(XICSState *icp, int src, int num, bool lsi, bool align) return first; } +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)); + } +} + +void xics_free(XICSState *icp, int src, int irq, int num) +{ + ICSState *ics = &icp->ics[src]; + + /* FIXME: implement multiple sources */ + assert(src == 0); + + trace_xics_ics_free(ics - icp->ics, irq, num); + if (src >= 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 0d8af1b..267d045 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -159,6 +159,7 @@ struct ICSIRQState { qemu_irq xics_get_qirq(XICSState *icp, int irq); int xics_alloc(XICSState *icp, int src, int irq_hint, bool lsi); int xics_alloc_block(XICSState *icp, int src, int num, bool lsi, bool align); +void xics_free(XICSState *icp, int src, int irq, int num); void xics_cpu_setup(XICSState *icp, PowerPCCPU *cpu); diff --git a/trace-events b/trace-events index d8e83cc..0a66c71 100644 --- a/trace-events +++ b/trace-events @@ -1182,6 +1182,8 @@ xics_alloc(int src, int irq) "source#%d, irq %d" xics_alloc_failed_hint(int src, int irq) "source#%d, irq %d is already in use" xics_alloc_failed_no_left(int src) "source#%d, no irq left" xics_alloc_block(int src, int first, int num, bool lsi, int align) "source#%d, first irq %d, %d irqs, lsi=%d, alignnum %d" +xics_ics_free(int src, int irq, int num) "Source#%d, first irq %d, %d irqs" +xics_ics_free_warn(int src, int irq) "Source#%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 -- 1.9.rc0