From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WiaJY-0007fN-7U for qemu-devel@nongnu.org; Thu, 08 May 2014 22:13:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WiaJQ-0001Aj-AG for qemu-devel@nongnu.org; Thu, 08 May 2014 22:13:32 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:53430) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WiaJQ-0001AX-4H for qemu-devel@nongnu.org; Thu, 08 May 2014 22:13:24 -0400 Received: by mail-pa0-f53.google.com with SMTP id kp14so3609163pab.40 for ; Thu, 08 May 2014 19:13:22 -0700 (PDT) Message-ID: <536C39BE.3020608@ozlabs.ru> Date: Fri, 09 May 2014 12:13:18 +1000 From: Alexey Kardashevskiy MIME-Version: 1.0 References: <1399442518-26303-1-git-send-email-aik@ozlabs.ru> <1399442518-26303-7-git-send-email-aik@ozlabs.ru> <536B7376.8020807@suse.de> In-Reply-To: <536B7376.8020807@suse.de> Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 6/6] xics: implement xics_ics_free() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org 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 >> --- >> 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