From patchwork Wed Sep 25 06:45:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 11160063 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F2C021599 for ; Wed, 25 Sep 2019 06:49:51 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BE33F217F4 for ; Wed, 25 Sep 2019 06:49:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="OmTOq1hG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BE33F217F4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:45994 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD17W-0002Fh-4z for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Sep 2019 02:49:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38528) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD13g-0008H0-PH for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:45:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iD13f-0003Rg-El for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:45:52 -0400 Received: from bilbo.ozlabs.org ([2401:3900:2:1::2]:60149 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iD13e-0003Ox-W0; Wed, 25 Sep 2019 02:45:51 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 46dT8m58Lsz9sPc; Wed, 25 Sep 2019 16:45:44 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1569393944; bh=YoZ6nDBhhOntdGlFmN4sT1V55L3hT1F130IYLZSQyK8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OmTOq1hGfCdnWA/LtKZHz9ejWuZ5UxQQRETwGrOHEdS7RHmc53aA4dGNEPTD9bUsC Me0ErMku2l/SOrBwdXpXjCizhWphn8w/envuDL81ANGnyyRYGMm86jhvcwGuobifO6 VKlzdnar4qi7LVJzRJLy8M7FunLzVRG7E/KMuS3o= From: David Gibson To: qemu-ppc@nongnu.org, clg@kaod.org, qemu-devel@nongnu.org Subject: [PATCH 01/20] xics: Use incomplete type for XICSFabric Date: Wed, 25 Sep 2019 16:45:15 +1000 Message-Id: <20190925064534.19155-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190925064534.19155-1-david@gibson.dropbear.id.au> References: <20190925064534.19155-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Riku Voipio , groug@kaod.org, Laurent Vivier , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , philmd@redhat.com, David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Interface instances should never be directly dereferenced. So, the common practice is to make them incomplete types to make sure no-one does that. XICSFrabric, however, had a dummy type which is less safe. Signed-off-by: David Gibson Reviewed-by: Greg Kurz --- include/hw/ppc/xics.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index 64a2c8862a..1ae34ce9cd 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -147,9 +147,7 @@ struct ICSIRQState { uint8_t flags; }; -struct XICSFabric { - Object parent; -}; +typedef struct XICSFabric XICSFabric; #define TYPE_XICS_FABRIC "xics-fabric" #define XICS_FABRIC(obj) \ From patchwork Wed Sep 25 06:45:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 11160067 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5679E1599 for ; Wed, 25 Sep 2019 06:49:54 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2D67C217F4 for ; Wed, 25 Sep 2019 06:49:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="HJXfokuK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2D67C217F4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:45998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD17X-0002GX-6R for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Sep 2019 02:49:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38547) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD13h-0008H6-2q for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:45:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iD13f-0003Ry-HF for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:45:52 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:54715) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iD13e-0003Or-Rk; Wed, 25 Sep 2019 02:45:51 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 46dT8m3vk4z9sPK; Wed, 25 Sep 2019 16:45:44 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1569393944; bh=CuklW7pHlQKk16RfasIZmBkH36hMA8755uTdgHwinIY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HJXfokuKZvFRsVlb5qHg2Zy2QCb1rcxt+62cC6MUp0UQqLespLt9Za6a1+PGfDpNP 0JtmON5iQpduVj55UmSvh+bfBYQCd8Qffv/jW9zywjiED7fbpLrn1AZsoVZQSS2LEN +/+OdE8qh2PfmjcXbFPc5izeJjWfgqmP7JsPsEro= From: David Gibson To: qemu-ppc@nongnu.org, clg@kaod.org, qemu-devel@nongnu.org Subject: [PATCH 02/20] xics: Eliminate 'reject', 'resend' and 'eoi' class hooks Date: Wed, 25 Sep 2019 16:45:16 +1000 Message-Id: <20190925064534.19155-3-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190925064534.19155-1-david@gibson.dropbear.id.au> References: <20190925064534.19155-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Riku Voipio , groug@kaod.org, Laurent Vivier , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , philmd@redhat.com, David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Currently ics_reject(), ics_resend() and ics_eoi() indirect through class methods. But there's only one implementation of each method, the one in TYPE_ICS_SIMPLE. TYPE_ICS_BASE has no implementation, but it's never instantiated, and has no other subtypes. So clean up by eliminating the method and just having ics_reject(), ics_resend() and ics_eoi() contain the logic directly. Signed-off-by: David Gibson Reviewed-by: Cédric Le Goater Reviewed-by: Greg Kurz --- hw/intc/trace-events | 4 ++-- hw/intc/xics.c | 54 +++++++++++-------------------------------- include/hw/ppc/xics.h | 4 ---- 3 files changed, 15 insertions(+), 47 deletions(-) diff --git a/hw/intc/trace-events b/hw/intc/trace-events index 719f46b516..fdc716c2cc 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -70,8 +70,8 @@ xics_ics_simple_set_irq_msi(int srcno, int nr) "set_irq_msi: srcno %d [irq 0x%x] xics_masked_pending(void) "set_irq_msi: masked pending" xics_ics_simple_set_irq_lsi(int srcno, int nr) "set_irq_lsi: srcno %d [irq 0x%x]" xics_ics_simple_write_xive(int nr, int srcno, int server, uint8_t priority) "ics_write_xive: irq 0x%x [src %d] server 0x%x prio 0x%x" -xics_ics_simple_reject(int nr, int srcno) "reject irq 0x%x [src %d]" -xics_ics_simple_eoi(int nr) "ics_eoi: irq 0x%x" +xics_ics_reject(int nr, int srcno) "reject irq 0x%x [src %d]" +xics_ics_eoi(int nr) "ics_eoi: irq 0x%x" # s390_flic_kvm.c flic_create_device(int err) "flic: create device failed %d" diff --git a/hw/intc/xics.c b/hw/intc/xics.c index b2fca2975c..93139b0189 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -98,32 +98,8 @@ void ics_pic_print_info(ICSState *ics, Monitor *mon) #define XISR(icp) (((icp)->xirr) & XISR_MASK) #define CPPR(icp) (((icp)->xirr) >> 24) -static void ics_reject(ICSState *ics, uint32_t nr) -{ - ICSStateClass *k = ICS_BASE_GET_CLASS(ics); - - if (k->reject) { - k->reject(ics, nr); - } -} - -void ics_resend(ICSState *ics) -{ - ICSStateClass *k = ICS_BASE_GET_CLASS(ics); - - if (k->resend) { - k->resend(ics); - } -} - -static void ics_eoi(ICSState *ics, int nr) -{ - ICSStateClass *k = ICS_BASE_GET_CLASS(ics); - - if (k->eoi) { - k->eoi(ics, nr); - } -} +static void ics_reject(ICSState *ics, uint32_t nr); +static void ics_eoi(ICSState *ics, uint32_t nr); static void icp_check_ipi(ICPState *icp) { @@ -427,7 +403,7 @@ Object *icp_create(Object *cpu, const char *type, XICSFabric *xi, Error **errp) /* * ICS: Source layer */ -static void ics_simple_resend_msi(ICSState *ics, int srcno) +static void ics_resend_msi(ICSState *ics, int srcno) { ICSIRQState *irq = ics->irqs + srcno; @@ -440,7 +416,7 @@ static void ics_simple_resend_msi(ICSState *ics, int srcno) } } -static void ics_simple_resend_lsi(ICSState *ics, int srcno) +static void ics_resend_lsi(ICSState *ics, int srcno) { ICSIRQState *irq = ics->irqs + srcno; @@ -478,7 +454,7 @@ static void ics_simple_set_irq_lsi(ICSState *ics, int srcno, int val) } else { irq->status &= ~XICS_STATUS_ASSERTED; } - ics_simple_resend_lsi(ics, srcno); + ics_resend_lsi(ics, srcno); } void ics_simple_set_irq(void *opaque, int srcno, int val) @@ -512,7 +488,7 @@ static void ics_simple_write_xive_msi(ICSState *ics, int srcno) static void ics_simple_write_xive_lsi(ICSState *ics, int srcno) { - ics_simple_resend_lsi(ics, srcno); + ics_resend_lsi(ics, srcno); } void ics_simple_write_xive(ICSState *ics, int srcno, int server, @@ -534,11 +510,11 @@ void ics_simple_write_xive(ICSState *ics, int srcno, int server, } } -static void ics_simple_reject(ICSState *ics, uint32_t nr) +static void ics_reject(ICSState *ics, uint32_t nr) { ICSIRQState *irq = ics->irqs + nr - ics->offset; - trace_xics_ics_simple_reject(nr, nr - ics->offset); + trace_xics_ics_reject(nr, nr - ics->offset); if (irq->flags & XICS_FLAGS_IRQ_MSI) { irq->status |= XICS_STATUS_REJECTED; } else if (irq->flags & XICS_FLAGS_IRQ_LSI) { @@ -546,26 +522,26 @@ static void ics_simple_reject(ICSState *ics, uint32_t nr) } } -static void ics_simple_resend(ICSState *ics) +void ics_resend(ICSState *ics) { int i; for (i = 0; i < ics->nr_irqs; i++) { /* FIXME: filter by server#? */ if (ics->irqs[i].flags & XICS_FLAGS_IRQ_LSI) { - ics_simple_resend_lsi(ics, i); + ics_resend_lsi(ics, i); } else { - ics_simple_resend_msi(ics, i); + ics_resend_msi(ics, i); } } } -static void ics_simple_eoi(ICSState *ics, uint32_t nr) +static void ics_eoi(ICSState *ics, uint32_t nr) { int srcno = nr - ics->offset; ICSIRQState *irq = ics->irqs + srcno; - trace_xics_ics_simple_eoi(nr); + trace_xics_ics_eoi(nr); if (ics->irqs[srcno].flags & XICS_FLAGS_IRQ_LSI) { irq->status &= ~XICS_STATUS_SENT; @@ -617,10 +593,6 @@ static void ics_simple_class_init(ObjectClass *klass, void *data) &isc->parent_realize); device_class_set_parent_reset(dc, ics_simple_reset, &isc->parent_reset); - - isc->reject = ics_simple_reject; - isc->resend = ics_simple_resend; - isc->eoi = ics_simple_eoi; } static const TypeInfo ics_simple_info = { diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index 1ae34ce9cd..d7d8e846b4 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -106,10 +106,6 @@ struct ICSStateClass { DeviceRealize parent_realize; DeviceReset parent_reset; - - void (*reject)(ICSState *s, uint32_t irq); - void (*resend)(ICSState *s); - void (*eoi)(ICSState *s, uint32_t irq); }; struct ICSState { From patchwork Wed Sep 25 06:45:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 11160081 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F0AD51599 for ; Wed, 25 Sep 2019 06:57:24 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C6625217F4 for ; Wed, 25 Sep 2019 06:57:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="nOKJc5tl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C6625217F4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:46064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD1Ep-0001Il-4B for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Sep 2019 02:57:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38653) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD13k-0008IJ-Rh for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:45:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iD13i-0003UW-GT for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:45:56 -0400 Received: from ozlabs.org ([203.11.71.1]:57689) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iD13h-0003SO-Ss; Wed, 25 Sep 2019 02:45:54 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 46dT8n2rwdz9sPn; Wed, 25 Sep 2019 16:45:44 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1569393945; bh=4xdy/rEvHjqqeKjhYNL5jzHm1cia7ZS1dcNY6C+Nvr0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nOKJc5tlYB3bPYIyKiI2/lh9sH7bMiqtnbqneWaDxVMuXNZOPlCvwkqpRU4WsmzWq auLhxgm68YDhWlmm3usKml5ywnqNfRyEHTgkMgfFCcD8oW7ehwa1Is91c8wml1xDLg SlKMqJf4jjWW6ZuPm4kiQmHyMGkc+q8rTHbgo9j4= From: David Gibson To: qemu-ppc@nongnu.org, clg@kaod.org, qemu-devel@nongnu.org Subject: [PATCH 03/20] xics: Rename misleading ics_simple_*() functions Date: Wed, 25 Sep 2019 16:45:17 +1000 Message-Id: <20190925064534.19155-4-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190925064534.19155-1-david@gibson.dropbear.id.au> References: <20190925064534.19155-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Riku Voipio , groug@kaod.org, Laurent Vivier , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , philmd@redhat.com, David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" There are a number of ics_simple_*() functions that aren't actually specific to TYPE_XICS_SIMPLE at all, and are equally valid on TYPE_XICS_BASE. Rename them to ics_*() accordingly. Signed-off-by: David Gibson Reviewed-by: Cédric Le Goater Reviewed-by: Greg Kurz --- hw/intc/trace-events | 6 +++--- hw/intc/xics.c | 29 ++++++++++++++--------------- hw/intc/xics_spapr.c | 12 ++++++------ hw/ppc/pnv_psi.c | 4 ++-- hw/ppc/spapr_irq.c | 2 +- include/hw/ppc/xics.h | 6 +++--- 6 files changed, 29 insertions(+), 30 deletions(-) diff --git a/hw/intc/trace-events b/hw/intc/trace-events index fdc716c2cc..527c3f76ca 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -66,10 +66,10 @@ xics_icp_accept(uint32_t old_xirr, uint32_t new_xirr) "icp_accept: XIRR 0x%"PRIx xics_icp_eoi(int server, uint32_t xirr, uint32_t new_xirr) "icp_eoi: server %d given XIRR 0x%"PRIx32" new XIRR 0x%"PRIx32 xics_icp_irq(int server, int nr, uint8_t priority) "cpu %d trying to deliver irq 0x%"PRIx32" priority 0x%x" xics_icp_raise(uint32_t xirr, uint8_t pending_priority) "raising IRQ new XIRR=0x%x new pending priority=0x%x" -xics_ics_simple_set_irq_msi(int srcno, int nr) "set_irq_msi: srcno %d [irq 0x%x]" +xics_ics_set_irq_msi(int srcno, int nr) "set_irq_msi: srcno %d [irq 0x%x]" xics_masked_pending(void) "set_irq_msi: masked pending" -xics_ics_simple_set_irq_lsi(int srcno, int nr) "set_irq_lsi: srcno %d [irq 0x%x]" -xics_ics_simple_write_xive(int nr, int srcno, int server, uint8_t priority) "ics_write_xive: irq 0x%x [src %d] server 0x%x prio 0x%x" +xics_ics_set_irq_lsi(int srcno, int nr) "set_irq_lsi: srcno %d [irq 0x%x]" +xics_ics_write_xive(int nr, int srcno, int server, uint8_t priority) "ics_write_xive: irq 0x%x [src %d] server 0x%x prio 0x%x" xics_ics_reject(int nr, int srcno) "reject irq 0x%x [src %d]" xics_ics_eoi(int nr) "ics_eoi: irq 0x%x" diff --git a/hw/intc/xics.c b/hw/intc/xics.c index 93139b0189..310dc72b46 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -428,11 +428,11 @@ static void ics_resend_lsi(ICSState *ics, int srcno) } } -static void ics_simple_set_irq_msi(ICSState *ics, int srcno, int val) +static void ics_set_irq_msi(ICSState *ics, int srcno, int val) { ICSIRQState *irq = ics->irqs + srcno; - trace_xics_ics_simple_set_irq_msi(srcno, srcno + ics->offset); + trace_xics_ics_set_irq_msi(srcno, srcno + ics->offset); if (val) { if (irq->priority == 0xff) { @@ -444,11 +444,11 @@ static void ics_simple_set_irq_msi(ICSState *ics, int srcno, int val) } } -static void ics_simple_set_irq_lsi(ICSState *ics, int srcno, int val) +static void ics_set_irq_lsi(ICSState *ics, int srcno, int val) { ICSIRQState *irq = ics->irqs + srcno; - trace_xics_ics_simple_set_irq_lsi(srcno, srcno + ics->offset); + trace_xics_ics_set_irq_lsi(srcno, srcno + ics->offset); if (val) { irq->status |= XICS_STATUS_ASSERTED; } else { @@ -457,7 +457,7 @@ static void ics_simple_set_irq_lsi(ICSState *ics, int srcno, int val) ics_resend_lsi(ics, srcno); } -void ics_simple_set_irq(void *opaque, int srcno, int val) +void ics_set_irq(void *opaque, int srcno, int val) { ICSState *ics = (ICSState *)opaque; @@ -467,13 +467,13 @@ void ics_simple_set_irq(void *opaque, int srcno, int val) } if (ics->irqs[srcno].flags & XICS_FLAGS_IRQ_LSI) { - ics_simple_set_irq_lsi(ics, srcno, val); + ics_set_irq_lsi(ics, srcno, val); } else { - ics_simple_set_irq_msi(ics, srcno, val); + ics_set_irq_msi(ics, srcno, val); } } -static void ics_simple_write_xive_msi(ICSState *ics, int srcno) +static void ics_write_xive_msi(ICSState *ics, int srcno) { ICSIRQState *irq = ics->irqs + srcno; @@ -486,13 +486,13 @@ static void ics_simple_write_xive_msi(ICSState *ics, int srcno) icp_irq(ics, irq->server, srcno + ics->offset, irq->priority); } -static void ics_simple_write_xive_lsi(ICSState *ics, int srcno) +static void ics_write_xive_lsi(ICSState *ics, int srcno) { ics_resend_lsi(ics, srcno); } -void ics_simple_write_xive(ICSState *ics, int srcno, int server, - uint8_t priority, uint8_t saved_priority) +void ics_write_xive(ICSState *ics, int srcno, int server, + uint8_t priority, uint8_t saved_priority) { ICSIRQState *irq = ics->irqs + srcno; @@ -500,13 +500,12 @@ void ics_simple_write_xive(ICSState *ics, int srcno, int server, irq->priority = priority; irq->saved_priority = saved_priority; - trace_xics_ics_simple_write_xive(ics->offset + srcno, srcno, server, - priority); + trace_xics_ics_write_xive(ics->offset + srcno, srcno, server, priority); if (ics->irqs[srcno].flags & XICS_FLAGS_IRQ_LSI) { - ics_simple_write_xive_lsi(ics, srcno); + ics_write_xive_lsi(ics, srcno); } else { - ics_simple_write_xive_msi(ics, srcno); + ics_write_xive_msi(ics, srcno); } } diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c index 6577be0d92..3e9444813a 100644 --- a/hw/intc/xics_spapr.c +++ b/hw/intc/xics_spapr.c @@ -179,7 +179,7 @@ static void rtas_set_xive(PowerPCCPU *cpu, SpaprMachineState *spapr, } srcno = nr - ics->offset; - ics_simple_write_xive(ics, srcno, server, priority, priority); + ics_write_xive(ics, srcno, server, priority, priority); rtas_st(rets, 0, RTAS_OUT_SUCCESS); } @@ -243,8 +243,8 @@ static void rtas_int_off(PowerPCCPU *cpu, SpaprMachineState *spapr, } srcno = nr - ics->offset; - ics_simple_write_xive(ics, srcno, ics->irqs[srcno].server, 0xff, - ics->irqs[srcno].priority); + ics_write_xive(ics, srcno, ics->irqs[srcno].server, 0xff, + ics->irqs[srcno].priority); rtas_st(rets, 0, RTAS_OUT_SUCCESS); } @@ -276,9 +276,9 @@ static void rtas_int_on(PowerPCCPU *cpu, SpaprMachineState *spapr, } srcno = nr - ics->offset; - ics_simple_write_xive(ics, srcno, ics->irqs[srcno].server, - ics->irqs[srcno].saved_priority, - ics->irqs[srcno].saved_priority); + ics_write_xive(ics, srcno, ics->irqs[srcno].server, + ics->irqs[srcno].saved_priority, + ics->irqs[srcno].saved_priority); rtas_st(rets, 0, RTAS_OUT_SUCCESS); } diff --git a/hw/ppc/pnv_psi.c b/hw/ppc/pnv_psi.c index 88ba8e7b9b..8ea81e9d8e 100644 --- a/hw/ppc/pnv_psi.c +++ b/hw/ppc/pnv_psi.c @@ -311,7 +311,7 @@ static void pnv_psi_set_xivr(PnvPsi *psi, uint32_t reg, uint64_t val) * do for now but a more accurate implementation would instead * use a fixed server/prio and a remapper of the generated irq. */ - ics_simple_write_xive(ics, src, server, prio, prio); + ics_write_xive(ics, src, server, prio, prio); } static uint64_t pnv_psi_reg_read(PnvPsi *psi, uint32_t offset, bool mmio) @@ -514,7 +514,7 @@ static void pnv_psi_power8_realize(DeviceState *dev, Error **errp) ics_set_irq_type(ics, i, true); } - psi->qirqs = qemu_allocate_irqs(ics_simple_set_irq, ics, ics->nr_irqs); + psi->qirqs = qemu_allocate_irqs(ics_set_irq, ics, ics->nr_irqs); /* XSCOM region for PSI registers */ pnv_xscom_region_init(&psi->xscom_regs, OBJECT(dev), &pnv_psi_xscom_ops, diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c index d8f46b6797..ac189c5796 100644 --- a/hw/ppc/spapr_irq.c +++ b/hw/ppc/spapr_irq.c @@ -210,7 +210,7 @@ static void spapr_irq_set_irq_xics(void *opaque, int srcno, int val) { SpaprMachineState *spapr = opaque; - ics_simple_set_irq(spapr->ics, srcno, val); + ics_set_irq(spapr->ics, srcno, val); } static void spapr_irq_reset_xics(SpaprMachineState *spapr, Error **errp) diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index d7d8e846b4..e72fb67968 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -169,9 +169,9 @@ uint32_t icp_accept(ICPState *ss); uint32_t icp_ipoll(ICPState *ss, uint32_t *mfrr); void icp_eoi(ICPState *icp, uint32_t xirr); -void ics_simple_write_xive(ICSState *ics, int nr, int server, - uint8_t priority, uint8_t saved_priority); -void ics_simple_set_irq(void *opaque, int srcno, int val); +void ics_write_xive(ICSState *ics, int nr, int server, + uint8_t priority, uint8_t saved_priority); +void ics_set_irq(void *opaque, int srcno, int val); static inline bool ics_irq_free(ICSState *ics, uint32_t srcno) { From patchwork Wed Sep 25 06:45:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 11160071 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DF5591599 for ; Wed, 25 Sep 2019 06:53:49 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B5DAB217F4 for ; Wed, 25 Sep 2019 06:53:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="GXqyej7s" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B5DAB217F4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:46022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD1BL-0005rx-TI for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Sep 2019 02:53:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38542) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD13g-0008H5-SO for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:45:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iD13f-0003S4-HI for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:45:52 -0400 Received: from ozlabs.org ([203.11.71.1]:60485) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iD13e-0003P4-Ee; Wed, 25 Sep 2019 02:45:51 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 46dT8m6LLsz9sPS; Wed, 25 Sep 2019 16:45:44 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1569393944; bh=P0np1w4XgBOhb+kntSg8w2qO0Xl6W7irJK27KvLJAYc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GXqyej7sJklRlHi8hNOmCLmWw87EJc+xoKdwb0bZrr3Mg+BUk2dCItwJqVyDkmNd3 BKCWNvnoEmmi5/fiYHkZtaMBkeXEuVyYL4kZbAwkiTlayoAsF9hHuroUedr72+SNiH YROzdVZqZhYQ5gLTVFGwWanqwuTD05/2/07sAmEE= From: David Gibson To: qemu-ppc@nongnu.org, clg@kaod.org, qemu-devel@nongnu.org Subject: [PATCH 04/20] xics: Eliminate reset hook Date: Wed, 25 Sep 2019 16:45:18 +1000 Message-Id: <20190925064534.19155-5-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190925064534.19155-1-david@gibson.dropbear.id.au> References: <20190925064534.19155-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Riku Voipio , groug@kaod.org, Laurent Vivier , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , philmd@redhat.com, David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Currently TYPE_XICS_BASE and TYPE_XICS_SIMPLE have their own reset methods, using the standard technique for having the subtype call the supertype's methods before doing its own thing. But TYPE_XICS_SIMPLE is the only subtype of TYPE_XICS_BASE ever instantiated, so there's no point having the split here. Merge them together into just an ics_reset() function. Signed-off-by: David Gibson Reviewed-by: Cédric Le Goater Reviewed-by: Greg Kurz --- hw/intc/xics.c | 57 ++++++++++++++++++------------------------- include/hw/ppc/xics.h | 1 - 2 files changed, 24 insertions(+), 34 deletions(-) diff --git a/hw/intc/xics.c b/hw/intc/xics.c index 310dc72b46..82e6f09259 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -547,11 +547,28 @@ static void ics_eoi(ICSState *ics, uint32_t nr) } } -static void ics_simple_reset(DeviceState *dev) +static void ics_reset_irq(ICSIRQState *irq) { - ICSStateClass *icsc = ICS_BASE_GET_CLASS(dev); + irq->priority = 0xff; + irq->saved_priority = 0xff; +} - icsc->parent_reset(dev); +static void ics_reset(DeviceState *dev) +{ + ICSState *ics = ICS_BASE(dev); + int i; + uint8_t flags[ics->nr_irqs]; + + for (i = 0; i < ics->nr_irqs; i++) { + flags[i] = ics->irqs[i].flags; + } + + memset(ics->irqs, 0, sizeof(ICSIRQState) * ics->nr_irqs); + + for (i = 0; i < ics->nr_irqs; i++) { + ics_reset_irq(ics->irqs + i); + ics->irqs[i].flags = flags[i]; + } if (kvm_irqchip_in_kernel()) { Error *local_err = NULL; @@ -563,9 +580,9 @@ static void ics_simple_reset(DeviceState *dev) } } -static void ics_simple_reset_handler(void *dev) +static void ics_reset_handler(void *dev) { - ics_simple_reset(dev); + ics_reset(dev); } static void ics_simple_realize(DeviceState *dev, Error **errp) @@ -580,7 +597,7 @@ static void ics_simple_realize(DeviceState *dev, Error **errp) return; } - qemu_register_reset(ics_simple_reset_handler, ics); + qemu_register_reset(ics_reset_handler, ics); } static void ics_simple_class_init(ObjectClass *klass, void *data) @@ -590,8 +607,6 @@ static void ics_simple_class_init(ObjectClass *klass, void *data) device_class_set_parent_realize(dc, ics_simple_realize, &isc->parent_realize); - device_class_set_parent_reset(dc, ics_simple_reset, - &isc->parent_reset); } static const TypeInfo ics_simple_info = { @@ -602,30 +617,6 @@ static const TypeInfo ics_simple_info = { .class_size = sizeof(ICSStateClass), }; -static void ics_reset_irq(ICSIRQState *irq) -{ - irq->priority = 0xff; - irq->saved_priority = 0xff; -} - -static void ics_base_reset(DeviceState *dev) -{ - ICSState *ics = ICS_BASE(dev); - int i; - uint8_t flags[ics->nr_irqs]; - - for (i = 0; i < ics->nr_irqs; i++) { - flags[i] = ics->irqs[i].flags; - } - - memset(ics->irqs, 0, sizeof(ICSIRQState) * ics->nr_irqs); - - for (i = 0; i < ics->nr_irqs; i++) { - ics_reset_irq(ics->irqs + i); - ics->irqs[i].flags = flags[i]; - } -} - static void ics_base_realize(DeviceState *dev, Error **errp) { ICSState *ics = ICS_BASE(dev); @@ -726,7 +717,7 @@ static void ics_base_class_init(ObjectClass *klass, void *data) dc->realize = ics_base_realize; dc->props = ics_base_properties; - dc->reset = ics_base_reset; + dc->reset = ics_reset; dc->vmsd = &vmstate_ics_base; } diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index e72fb67968..18fcd2b11c 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -105,7 +105,6 @@ struct ICSStateClass { DeviceClass parent_class; DeviceRealize parent_realize; - DeviceReset parent_reset; }; struct ICSState { From patchwork Wed Sep 25 06:45:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 11160065 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AFE3C1747 for ; Wed, 25 Sep 2019 06:49:52 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 864F6217F4 for ; Wed, 25 Sep 2019 06:49:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="ir+yYPW4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 864F6217F4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:45996 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD17W-0002Fw-IS for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Sep 2019 02:49:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38548) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD13h-0008H7-3J for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:45:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iD13f-0003Rs-Gh for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:45:53 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:58107) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iD13e-0003PA-G3; Wed, 25 Sep 2019 02:45:51 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 46dT8n0jRjz9sPl; Wed, 25 Sep 2019 16:45:44 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1569393945; bh=hmkKiwZWe5LKQOs1LvkyxaBcD2k813TYoRSYzgwZcnk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ir+yYPW4sCpyDcsqIdq05OHYKFkG7bdnwSWWQoYtyhrAQ9N7EZm4BsFBMySMWXDdv WRc1HsswxwZJO2MoIi9A3zqxwDYN3o+Ro4fxFMg/5u7JsjDAASLZT6Sr/oj0IlXrZS CDLbslTw/sw0M2sVxlQ36NfruKRr5xEXgIgVrisM= From: David Gibson To: qemu-ppc@nongnu.org, clg@kaod.org, qemu-devel@nongnu.org Subject: [PATCH 05/20] xics: Merge TYPE_ICS_BASE and TYPE_ICS_SIMPLE classes Date: Wed, 25 Sep 2019 16:45:19 +1000 Message-Id: <20190925064534.19155-6-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190925064534.19155-1-david@gibson.dropbear.id.au> References: <20190925064534.19155-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Riku Voipio , groug@kaod.org, Laurent Vivier , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , philmd@redhat.com, David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" TYPE_ICS_SIMPLE is the only subtype of TYPE_ICS_BASE that's ever instantiated, and the only one we're ever likely to want. The existence of different classes is just a hang over from when we (misguidedly) had separate subtypes for the KVM and non-KVM version of the device. So, collapse the two classes together into just TYPE_ICS. Signed-off-by: David Gibson Reviewed-by: Greg Kurz Reviewed-by: Cédric Le Goater --- hw/intc/xics.c | 86 ++++++++++++++----------------------------- hw/ppc/pnv_psi.c | 2 +- hw/ppc/spapr_irq.c | 4 +- include/hw/ppc/xics.h | 16 +++----- 4 files changed, 36 insertions(+), 72 deletions(-) diff --git a/hw/intc/xics.c b/hw/intc/xics.c index 82e6f09259..dfe7dbd254 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -555,7 +555,7 @@ static void ics_reset_irq(ICSIRQState *irq) static void ics_reset(DeviceState *dev) { - ICSState *ics = ICS_BASE(dev); + ICSState *ics = ICS(dev); int i; uint8_t flags[ics->nr_irqs]; @@ -573,7 +573,7 @@ static void ics_reset(DeviceState *dev) if (kvm_irqchip_in_kernel()) { Error *local_err = NULL; - ics_set_kvm_state(ICS_BASE(dev), &local_err); + ics_set_kvm_state(ICS(dev), &local_err); if (local_err) { error_report_err(local_err); } @@ -585,47 +585,15 @@ static void ics_reset_handler(void *dev) ics_reset(dev); } -static void ics_simple_realize(DeviceState *dev, Error **errp) +static void ics_realize(DeviceState *dev, Error **errp) { - ICSState *ics = ICS_SIMPLE(dev); - ICSStateClass *icsc = ICS_BASE_GET_CLASS(ics); + ICSState *ics = ICS(dev); Error *local_err = NULL; - - icsc->parent_realize(dev, &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } - - qemu_register_reset(ics_reset_handler, ics); -} - -static void ics_simple_class_init(ObjectClass *klass, void *data) -{ - DeviceClass *dc = DEVICE_CLASS(klass); - ICSStateClass *isc = ICS_BASE_CLASS(klass); - - device_class_set_parent_realize(dc, ics_simple_realize, - &isc->parent_realize); -} - -static const TypeInfo ics_simple_info = { - .name = TYPE_ICS_SIMPLE, - .parent = TYPE_ICS_BASE, - .instance_size = sizeof(ICSState), - .class_init = ics_simple_class_init, - .class_size = sizeof(ICSStateClass), -}; - -static void ics_base_realize(DeviceState *dev, Error **errp) -{ - ICSState *ics = ICS_BASE(dev); Object *obj; - Error *err = NULL; - obj = object_property_get_link(OBJECT(dev), ICS_PROP_XICS, &err); + obj = object_property_get_link(OBJECT(dev), ICS_PROP_XICS, &local_err); if (!obj) { - error_propagate_prepend(errp, err, + error_propagate_prepend(errp, local_err, "required link '" ICS_PROP_XICS "' not found: "); return; @@ -637,16 +605,18 @@ static void ics_base_realize(DeviceState *dev, Error **errp) return; } ics->irqs = g_malloc0(ics->nr_irqs * sizeof(ICSIRQState)); + + qemu_register_reset(ics_reset_handler, ics); } -static void ics_base_instance_init(Object *obj) +static void ics_instance_init(Object *obj) { - ICSState *ics = ICS_BASE(obj); + ICSState *ics = ICS(obj); ics->offset = XICS_IRQ_BASE; } -static int ics_base_pre_save(void *opaque) +static int ics_pre_save(void *opaque) { ICSState *ics = opaque; @@ -657,7 +627,7 @@ static int ics_base_pre_save(void *opaque) return 0; } -static int ics_base_post_load(void *opaque, int version_id) +static int ics_post_load(void *opaque, int version_id) { ICSState *ics = opaque; @@ -675,7 +645,7 @@ static int ics_base_post_load(void *opaque, int version_id) return 0; } -static const VMStateDescription vmstate_ics_base_irq = { +static const VMStateDescription vmstate_ics_irq = { .name = "ics/irq", .version_id = 2, .minimum_version_id = 1, @@ -689,45 +659,44 @@ static const VMStateDescription vmstate_ics_base_irq = { }, }; -static const VMStateDescription vmstate_ics_base = { +static const VMStateDescription vmstate_ics = { .name = "ics", .version_id = 1, .minimum_version_id = 1, - .pre_save = ics_base_pre_save, - .post_load = ics_base_post_load, + .pre_save = ics_pre_save, + .post_load = ics_post_load, .fields = (VMStateField[]) { /* Sanity check */ VMSTATE_UINT32_EQUAL(nr_irqs, ICSState, NULL), VMSTATE_STRUCT_VARRAY_POINTER_UINT32(irqs, ICSState, nr_irqs, - vmstate_ics_base_irq, + vmstate_ics_irq, ICSIRQState), VMSTATE_END_OF_LIST() }, }; -static Property ics_base_properties[] = { +static Property ics_properties[] = { DEFINE_PROP_UINT32("nr-irqs", ICSState, nr_irqs, 0), DEFINE_PROP_END_OF_LIST(), }; -static void ics_base_class_init(ObjectClass *klass, void *data) +static void ics_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - dc->realize = ics_base_realize; - dc->props = ics_base_properties; + dc->realize = ics_realize; + dc->props = ics_properties; dc->reset = ics_reset; - dc->vmsd = &vmstate_ics_base; + dc->vmsd = &vmstate_ics; } -static const TypeInfo ics_base_info = { - .name = TYPE_ICS_BASE, +static const TypeInfo ics_info = { + .name = TYPE_ICS, .parent = TYPE_DEVICE, - .abstract = true, .instance_size = sizeof(ICSState), - .instance_init = ics_base_instance_init, - .class_init = ics_base_class_init, + .instance_init = ics_instance_init, + .class_init = ics_class_init, .class_size = sizeof(ICSStateClass), }; @@ -767,8 +736,7 @@ void ics_set_irq_type(ICSState *ics, int srcno, bool lsi) static void xics_register_types(void) { - type_register_static(&ics_simple_info); - type_register_static(&ics_base_info); + type_register_static(&ics_info); type_register_static(&icp_info); type_register_static(&xics_fabric_info); } diff --git a/hw/ppc/pnv_psi.c b/hw/ppc/pnv_psi.c index 8ea81e9d8e..a997f16bb4 100644 --- a/hw/ppc/pnv_psi.c +++ b/hw/ppc/pnv_psi.c @@ -469,7 +469,7 @@ static void pnv_psi_power8_instance_init(Object *obj) Pnv8Psi *psi8 = PNV8_PSI(obj); object_initialize_child(obj, "ics-psi", &psi8->ics, sizeof(psi8->ics), - TYPE_ICS_SIMPLE, &error_abort, NULL); + TYPE_ICS, &error_abort, NULL); } static const uint8_t irq_to_xivr[] = { diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c index ac189c5796..6c45d2a3c0 100644 --- a/hw/ppc/spapr_irq.c +++ b/hw/ppc/spapr_irq.c @@ -98,7 +98,7 @@ static void spapr_irq_init_xics(SpaprMachineState *spapr, int nr_irqs, Object *obj; Error *local_err = NULL; - obj = object_new(TYPE_ICS_SIMPLE); + obj = object_new(TYPE_ICS); object_property_add_child(OBJECT(spapr), "ics", obj, &error_abort); object_property_add_const_link(obj, ICS_PROP_XICS, OBJECT(spapr), &error_fatal); @@ -109,7 +109,7 @@ static void spapr_irq_init_xics(SpaprMachineState *spapr, int nr_irqs, return; } - spapr->ics = ICS_BASE(obj); + spapr->ics = ICS(obj); xics_spapr_init(spapr); } diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index 18fcd2b11c..5a9b73d144 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -89,17 +89,13 @@ struct PnvICPState { uint32_t links[3]; }; -#define TYPE_ICS_BASE "ics-base" -#define ICS_BASE(obj) OBJECT_CHECK(ICSState, (obj), TYPE_ICS_BASE) +#define TYPE_ICS "ics" +#define ICS(obj) OBJECT_CHECK(ICSState, (obj), TYPE_ICS) -/* Retain ics for sPAPR for migration from existing sPAPR guests */ -#define TYPE_ICS_SIMPLE "ics" -#define ICS_SIMPLE(obj) OBJECT_CHECK(ICSState, (obj), TYPE_ICS_SIMPLE) - -#define ICS_BASE_CLASS(klass) \ - OBJECT_CLASS_CHECK(ICSStateClass, (klass), TYPE_ICS_BASE) -#define ICS_BASE_GET_CLASS(obj) \ - OBJECT_GET_CLASS(ICSStateClass, (obj), TYPE_ICS_BASE) +#define ICS_CLASS(klass) \ + OBJECT_CLASS_CHECK(ICSStateClass, (klass), TYPE_ICS) +#define ICS_GET_CLASS(obj) \ + OBJECT_GET_CLASS(ICSStateClass, (obj), TYPE_ICS) struct ICSStateClass { DeviceClass parent_class; From patchwork Wed Sep 25 06:45:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 11160077 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9C3D31599 for ; Wed, 25 Sep 2019 06:53:53 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 724A1217F4 for ; Wed, 25 Sep 2019 06:53:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="mSaPmtj7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 724A1217F4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:46028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD1BP-0005uL-Gh for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Sep 2019 02:53:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38620) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD13k-0008Hx-9l for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:45:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iD13i-0003Ui-JV for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:45:56 -0400 Received: from ozlabs.org ([203.11.71.1]:52295) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iD13h-0003SU-UL; Wed, 25 Sep 2019 02:45:54 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 46dT8p1tg0z9sQp; Wed, 25 Sep 2019 16:45:44 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1569393946; bh=r5YnFIVkectCLdzcoIkGqWKVvJZ0h5KrmCUxeKF8vY0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mSaPmtj7qTBLnv7hX+M5bxwlyjBZOAtauoJoq0gavA/NVEVjJh0g1kzScvBeHVhoJ xjCrttZrUlxwloZG+1lYM+/Lw2i4RZQbepjJ3Isu12HYf8rIYSO7+aqyIep5580eA+ w8V59bU9z79cAFUsTDwcTK/mjsC6AtTddmUSh+uw= From: David Gibson To: qemu-ppc@nongnu.org, clg@kaod.org, qemu-devel@nongnu.org Subject: [PATCH 06/20] xics: Create sPAPR specific ICS subtype Date: Wed, 25 Sep 2019 16:45:20 +1000 Message-Id: <20190925064534.19155-7-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190925064534.19155-1-david@gibson.dropbear.id.au> References: <20190925064534.19155-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Riku Voipio , groug@kaod.org, Laurent Vivier , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , philmd@redhat.com, David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" We create a subtype of TYPE_ICS specifically for sPAPR. For now all this does is move the setup of the PAPR specific hcalls and RTAS calls to the realize() function for this, rather than requiring the PAPR code to explicitly call xics_spapr_init(). In future it will have some more function. Signed-off-by: David Gibson Reviewed-by: Cédric Le Goater --- hw/intc/xics_spapr.c | 34 +++++++++++++++++++++++++++++++++- hw/ppc/spapr_irq.c | 6 ++---- include/hw/ppc/xics_spapr.h | 4 +++- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c index 3e9444813a..e6dd004587 100644 --- a/hw/intc/xics_spapr.c +++ b/hw/intc/xics_spapr.c @@ -283,8 +283,18 @@ static void rtas_int_on(PowerPCCPU *cpu, SpaprMachineState *spapr, rtas_st(rets, 0, RTAS_OUT_SUCCESS); } -void xics_spapr_init(SpaprMachineState *spapr) +static void ics_spapr_realize(DeviceState *dev, Error **errp) { + ICSState *ics = ICS_SPAPR(dev); + ICSStateClass *icsc = ICS_GET_CLASS(ics); + Error *local_err = NULL; + + icsc->parent_realize(dev, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + spapr_rtas_register(RTAS_IBM_SET_XIVE, "ibm,set-xive", rtas_set_xive); spapr_rtas_register(RTAS_IBM_GET_XIVE, "ibm,get-xive", rtas_get_xive); spapr_rtas_register(RTAS_IBM_INT_OFF, "ibm,int-off", rtas_int_off); @@ -319,3 +329,25 @@ void spapr_dt_xics(SpaprMachineState *spapr, uint32_t nr_servers, void *fdt, _FDT(fdt_setprop_cell(fdt, node, "linux,phandle", phandle)); _FDT(fdt_setprop_cell(fdt, node, "phandle", phandle)); } + +static void ics_spapr_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + ICSStateClass *isc = ICS_CLASS(klass); + + device_class_set_parent_realize(dc, ics_spapr_realize, + &isc->parent_realize); +} + +static const TypeInfo ics_spapr_info = { + .name = TYPE_ICS_SPAPR, + .parent = TYPE_ICS, + .class_init = ics_spapr_class_init, +}; + +static void xics_spapr_register_types(void) +{ + type_register_static(&ics_spapr_info); +} + +type_init(xics_spapr_register_types) diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c index 6c45d2a3c0..8c26fa2d1e 100644 --- a/hw/ppc/spapr_irq.c +++ b/hw/ppc/spapr_irq.c @@ -98,7 +98,7 @@ static void spapr_irq_init_xics(SpaprMachineState *spapr, int nr_irqs, Object *obj; Error *local_err = NULL; - obj = object_new(TYPE_ICS); + obj = object_new(TYPE_ICS_SPAPR); object_property_add_child(OBJECT(spapr), "ics", obj, &error_abort); object_property_add_const_link(obj, ICS_PROP_XICS, OBJECT(spapr), &error_fatal); @@ -109,9 +109,7 @@ static void spapr_irq_init_xics(SpaprMachineState *spapr, int nr_irqs, return; } - spapr->ics = ICS(obj); - - xics_spapr_init(spapr); + spapr->ics = ICS_SPAPR(obj); } static int spapr_irq_claim_xics(SpaprMachineState *spapr, int irq, bool lsi, diff --git a/include/hw/ppc/xics_spapr.h b/include/hw/ppc/xics_spapr.h index 5dabc9a138..691a6d00f7 100644 --- a/include/hw/ppc/xics_spapr.h +++ b/include/hw/ppc/xics_spapr.h @@ -31,11 +31,13 @@ #define XICS_NODENAME "interrupt-controller" +#define TYPE_ICS_SPAPR "ics-spapr" +#define ICS_SPAPR(obj) OBJECT_CHECK(ICSState, (obj), TYPE_ICS_SPAPR) + void spapr_dt_xics(SpaprMachineState *spapr, uint32_t nr_servers, void *fdt, uint32_t phandle); int xics_kvm_connect(SpaprMachineState *spapr, Error **errp); void xics_kvm_disconnect(SpaprMachineState *spapr, Error **errp); bool xics_kvm_has_broken_disconnect(SpaprMachineState *spapr); -void xics_spapr_init(SpaprMachineState *spapr); #endif /* XICS_SPAPR_H */ From patchwork Wed Sep 25 06:45:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 11160069 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2554E1599 for ; Wed, 25 Sep 2019 06:49:57 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F071C217F4 for ; Wed, 25 Sep 2019 06:49:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="aiqtfJUq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F071C217F4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:46000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD17b-0002KH-38 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Sep 2019 02:49:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38619) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD13k-0008Hv-7y for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:45:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iD13i-0003V5-Mu for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:45:56 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:57717) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iD13i-0003SQ-7e; Wed, 25 Sep 2019 02:45:54 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 46dT8n4yV2z9sPf; Wed, 25 Sep 2019 16:45:45 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1569393945; bh=FXv4yeGIF2b8djYs7hDdY6FUu4HojCrn6XMfRuQihUA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aiqtfJUqafubqf65iUVUu7Lg9geT1dGRTMRIqPJYY1azQV/kauefQOUEbf5wa1Das Ro4JtS8rii99NT60IZ2qUflJHf48OxKi3OzMb8zrJRwvDRgCClXCKFMRimlc2W6AGd JiZDRk+J+AcaZiGsX0rdzfwOppucJJrqOn8rwQEQ= From: David Gibson To: qemu-ppc@nongnu.org, clg@kaod.org, qemu-devel@nongnu.org Subject: [PATCH 07/20] spapr: Fold spapr_phb_lsi_qirq() into its single caller Date: Wed, 25 Sep 2019 16:45:21 +1000 Message-Id: <20190925064534.19155-8-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190925064534.19155-1-david@gibson.dropbear.id.au> References: <20190925064534.19155-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Riku Voipio , groug@kaod.org, Laurent Vivier , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , philmd@redhat.com, David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" No point having a two-line helper that's used exactly once, and not likely to be used anywhere else in future. Signed-off-by: David Gibson Reviewed-by: Cédric Le Goater Reviewed-by: Greg Kurz Reviewed-by: Philippe Mathieu-Daudé --- hw/ppc/spapr_pci.c | 3 ++- include/hw/pci-host/spapr.h | 7 ------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 7b71ad7c74..6934d506a7 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -721,9 +721,10 @@ static void pci_spapr_set_irq(void *opaque, int irq_num, int level) * corresponding qemu_irq. */ SpaprPhbState *phb = opaque; + SpaprMachineState *spapr = SPAPR_MACHINE(qdev_get_machine()); trace_spapr_pci_lsi_set(phb->dtbusname, irq_num, phb->lsi_table[irq_num].irq); - qemu_set_irq(spapr_phb_lsi_qirq(phb, irq_num), level); + qemu_set_irq(spapr_qirq(spapr, phb->lsi_table[irq_num].irq), level); } static PCIINTxRoute spapr_route_intx_pin_to_irq(void *opaque, int pin) diff --git a/include/hw/pci-host/spapr.h b/include/hw/pci-host/spapr.h index abd87605b2..23506f05d9 100644 --- a/include/hw/pci-host/spapr.h +++ b/include/hw/pci-host/spapr.h @@ -128,13 +128,6 @@ struct SpaprPhbState { #define SPAPR_PCI_NV2ATSD_WIN_SIZE (NVGPU_MAX_NUM * NVGPU_MAX_LINKS * \ 64 * KiB) -static inline qemu_irq spapr_phb_lsi_qirq(struct SpaprPhbState *phb, int pin) -{ - SpaprMachineState *spapr = SPAPR_MACHINE(qdev_get_machine()); - - return spapr_qirq(spapr, phb->lsi_table[pin].irq); -} - int spapr_dt_phb(SpaprPhbState *phb, uint32_t intc_phandle, void *fdt, uint32_t nr_msis, int *node_offset); From patchwork Wed Sep 25 06:45:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 11160079 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3DD181599 for ; Wed, 25 Sep 2019 06:57:18 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 13A85217F4 for ; Wed, 25 Sep 2019 06:57:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="awM6cuH4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 13A85217F4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:46062 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD1Ei-0001C9-DC for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Sep 2019 02:57:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38649) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD13k-0008I6-O3 for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:45:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iD13i-0003VS-Te for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:45:56 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:45543) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iD13i-0003Sc-4A; Wed, 25 Sep 2019 02:45:54 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 46dT8n5jljz9sPw; Wed, 25 Sep 2019 16:45:45 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1569393945; bh=BcmueR7w6CCIumnw0eyfOPOhH/ia0+r7VZZA4nGPfOE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=awM6cuH4fWL3Vx+ohdqfVUCUzpd6vsj3oOtq/glTun+GqeZmOnbRlVYY5dUPfO0rr DIkqbV5LIAnlynHndqv6teAHxnt0ctGHtpx1mU3pf8sDrkTFnfbOuG1eo4yuROBivh pQ1MhaemgiMLUt4xsaSkIM0haHXmX+1xzoALVlD8= From: David Gibson To: qemu-ppc@nongnu.org, clg@kaod.org, qemu-devel@nongnu.org Subject: [PATCH 08/20] spapr: Replace spapr_vio_qirq() helper with spapr_vio_irq_pulse() helper Date: Wed, 25 Sep 2019 16:45:22 +1000 Message-Id: <20190925064534.19155-9-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190925064534.19155-1-david@gibson.dropbear.id.au> References: <20190925064534.19155-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Riku Voipio , groug@kaod.org, Laurent Vivier , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , philmd@redhat.com, David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Every caller of spapr_vio_qirq() immediately calls qemu_irq_pulse() with the result, so we might as well just fold that into the helper. Signed-off-by: David Gibson Reviewed-by: Cédric Le Goater Reviewed-by: Greg Kurz Reviewed-by: Philippe Mathieu-Daudé --- hw/char/spapr_vty.c | 3 +-- hw/net/spapr_llan.c | 3 +-- hw/ppc/spapr_vio.c | 3 +-- include/hw/ppc/spapr_vio.h | 5 +++-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/hw/char/spapr_vty.c b/hw/char/spapr_vty.c index 087c93e4fa..8f4d9fe472 100644 --- a/hw/char/spapr_vty.c +++ b/hw/char/spapr_vty.c @@ -5,7 +5,6 @@ #include "cpu.h" #include "migration/vmstate.h" #include "chardev/char-fe.h" -#include "hw/irq.h" #include "hw/ppc/spapr.h" #include "hw/ppc/spapr_vio.h" #include "hw/qdev-properties.h" @@ -37,7 +36,7 @@ static void vty_receive(void *opaque, const uint8_t *buf, int size) if ((dev->in == dev->out) && size) { /* toggle line to simulate edge interrupt */ - qemu_irq_pulse(spapr_vio_qirq(&dev->sdev)); + spapr_vio_irq_pulse(&dev->sdev); } for (i = 0; i < size; i++) { if (dev->in - dev->out >= VTERM_BUFSIZE) { diff --git a/hw/net/spapr_llan.c b/hw/net/spapr_llan.c index 701e6e1514..3d96884d66 100644 --- a/hw/net/spapr_llan.c +++ b/hw/net/spapr_llan.c @@ -27,7 +27,6 @@ #include "qemu/osdep.h" #include "cpu.h" -#include "hw/irq.h" #include "qemu/log.h" #include "qemu/module.h" #include "net/net.h" @@ -267,7 +266,7 @@ static ssize_t spapr_vlan_receive(NetClientState *nc, const uint8_t *buf, } if (sdev->signal_state & 1) { - qemu_irq_pulse(spapr_vio_qirq(sdev)); + spapr_vio_irq_pulse(sdev); } return size; diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c index 0803649658..554de9930d 100644 --- a/hw/ppc/spapr_vio.c +++ b/hw/ppc/spapr_vio.c @@ -23,7 +23,6 @@ #include "qemu/error-report.h" #include "qapi/error.h" #include "qapi/visitor.h" -#include "hw/irq.h" #include "qemu/log.h" #include "hw/loader.h" #include "elf.h" @@ -294,7 +293,7 @@ int spapr_vio_send_crq(SpaprVioDevice *dev, uint8_t *crq) dev->crq.qnext = (dev->crq.qnext + 16) % dev->crq.qsize; if (dev->signal_state & 1) { - qemu_irq_pulse(spapr_vio_qirq(dev)); + spapr_vio_irq_pulse(dev); } return 0; diff --git a/include/hw/ppc/spapr_vio.h b/include/hw/ppc/spapr_vio.h index 875be28cdd..72762ed16b 100644 --- a/include/hw/ppc/spapr_vio.h +++ b/include/hw/ppc/spapr_vio.h @@ -24,6 +24,7 @@ #include "hw/ppc/spapr.h" #include "sysemu/dma.h" +#include "hw/irq.h" #define TYPE_VIO_SPAPR_DEVICE "vio-spapr-device" #define VIO_SPAPR_DEVICE(obj) \ @@ -84,11 +85,11 @@ extern SpaprVioDevice *spapr_vio_find_by_reg(SpaprVioBus *bus, uint32_t reg); void spapr_dt_vdevice(SpaprVioBus *bus, void *fdt); extern gchar *spapr_vio_stdout_path(SpaprVioBus *bus); -static inline qemu_irq spapr_vio_qirq(SpaprVioDevice *dev) +static inline void spapr_vio_irq_pulse(SpaprVioDevice *dev) { SpaprMachineState *spapr = SPAPR_MACHINE(qdev_get_machine()); - return spapr_qirq(spapr, dev->irq); + qemu_irq_pulse(spapr_qirq(spapr, dev->irq)); } static inline bool spapr_vio_dma_valid(SpaprVioDevice *dev, uint64_t taddr, From patchwork Wed Sep 25 06:45:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 11160075 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 44B9C1747 for ; Wed, 25 Sep 2019 06:53:52 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1BEEC21D7E for ; Wed, 25 Sep 2019 06:53:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="pMO20GiV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1BEEC21D7E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:46024 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD1BO-0005to-Ba for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Sep 2019 02:53:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38667) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD13l-0008Il-GI for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:45:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iD13i-0003VJ-P4 for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:45:57 -0400 Received: from ozlabs.org ([203.11.71.1]:40135) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iD13i-0003SR-06; Wed, 25 Sep 2019 02:45:54 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 46dT8p0M8Lz9sQn; Wed, 25 Sep 2019 16:45:45 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1569393946; bh=IHGcrQU1reFNy4AxUUzMCKp3Wn0UitoCJr7qV/Iu/fY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pMO20GiVq1m5URE0TncOVDzldt4+9SYPW5rkuB3MVpyqeMKz+Okn0bR8p0WY8OAx/ z7SK9rOtiMB3l8w+gu+k4X56MfFwD2dhvKT1ny38qQ2dOBaapuvOGlAGixalMKMbZD isw4VZveaM0aGKQ9ha2PpLVCOXF/kh0/6CpKOuUE= From: David Gibson To: qemu-ppc@nongnu.org, clg@kaod.org, qemu-devel@nongnu.org Subject: [PATCH 09/20] spapr: Clarify and fix handling of nr_irqs Date: Wed, 25 Sep 2019 16:45:23 +1000 Message-Id: <20190925064534.19155-10-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190925064534.19155-1-david@gibson.dropbear.id.au> References: <20190925064534.19155-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Riku Voipio , groug@kaod.org, Laurent Vivier , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , philmd@redhat.com, David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Both the XICS and XIVE interrupt backends have a "nr-irqs" property, but it means slightly different things. For XICS (or, strictly, the ICS) it indicates the number of "real" external IRQs. Those start at XICS_IRQ_BASE (0x1000) and don't include the special IPI vector. For XIVE, however, it includes the whole IRQ space, including XIVE's many IPI vectors. The spapr code currently doesn't handle this sensibly, with the nr_irqs value in SpaprIrq having different meanings depending on the backend. We fix this by renaming nr_irqs to nr_xirqs and making it always indicate just the number of external irqs, adjusting the value we pass to XIVE accordingly. We also use move to using common constants in most of the irq configurations, to make it clearer that the IRQ space looks the same to the guest (and emulated devices), even if the backend is different. Signed-off-by: David Gibson Reviewed-by: Cédric Le Goater Reviewed-by: Greg Kurz --- hw/ppc/spapr_irq.c | 48 +++++++++++++++----------------------- include/hw/ppc/spapr_irq.h | 19 +++++++++------ 2 files changed, 31 insertions(+), 36 deletions(-) diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c index 8c26fa2d1e..5190a33e08 100644 --- a/hw/ppc/spapr_irq.c +++ b/hw/ppc/spapr_irq.c @@ -92,7 +92,7 @@ static void spapr_irq_init_kvm(SpaprMachineState *spapr, * XICS IRQ backend. */ -static void spapr_irq_init_xics(SpaprMachineState *spapr, int nr_irqs, +static void spapr_irq_init_xics(SpaprMachineState *spapr, int nr_xirqs, Error **errp) { Object *obj; @@ -102,7 +102,7 @@ static void spapr_irq_init_xics(SpaprMachineState *spapr, int nr_irqs, object_property_add_child(OBJECT(spapr), "ics", obj, &error_abort); object_property_add_const_link(obj, ICS_PROP_XICS, OBJECT(spapr), &error_fatal); - object_property_set_int(obj, nr_irqs, "nr-irqs", &error_fatal); + object_property_set_int(obj, nr_xirqs, "nr-irqs", &error_fatal); object_property_set_bool(obj, true, "realized", &local_err); if (local_err) { error_propagate(errp, local_err); @@ -234,13 +234,9 @@ static void spapr_irq_init_kvm_xics(SpaprMachineState *spapr, Error **errp) } } -#define SPAPR_IRQ_XICS_NR_IRQS 0x1000 -#define SPAPR_IRQ_XICS_NR_MSIS \ - (XICS_IRQ_BASE + SPAPR_IRQ_XICS_NR_IRQS - SPAPR_IRQ_MSI) - SpaprIrq spapr_irq_xics = { - .nr_irqs = SPAPR_IRQ_XICS_NR_IRQS, - .nr_msis = SPAPR_IRQ_XICS_NR_MSIS, + .nr_xirqs = SPAPR_NR_XIRQS, + .nr_msis = SPAPR_NR_MSIS, .ov5 = SPAPR_OV5_XIVE_LEGACY, .init = spapr_irq_init_xics, @@ -260,7 +256,7 @@ SpaprIrq spapr_irq_xics = { /* * XIVE IRQ backend. */ -static void spapr_irq_init_xive(SpaprMachineState *spapr, int nr_irqs, +static void spapr_irq_init_xive(SpaprMachineState *spapr, int nr_xirqs, Error **errp) { uint32_t nr_servers = spapr_max_server_number(spapr); @@ -268,7 +264,7 @@ static void spapr_irq_init_xive(SpaprMachineState *spapr, int nr_irqs, int i; dev = qdev_create(NULL, TYPE_SPAPR_XIVE); - qdev_prop_set_uint32(dev, "nr-irqs", nr_irqs); + qdev_prop_set_uint32(dev, "nr-irqs", nr_xirqs + SPAPR_XIRQ_BASE); /* * 8 XIVE END structures per CPU. One for each available priority */ @@ -308,7 +304,7 @@ static qemu_irq spapr_qirq_xive(SpaprMachineState *spapr, int irq) { SpaprXive *xive = spapr->xive; - if (irq >= xive->nr_irqs) { + if ((irq < SPAPR_XIRQ_BASE) || (irq >= xive->nr_irqs)) { return NULL; } @@ -409,12 +405,9 @@ static void spapr_irq_init_kvm_xive(SpaprMachineState *spapr, Error **errp) * with XICS. */ -#define SPAPR_IRQ_XIVE_NR_IRQS 0x2000 -#define SPAPR_IRQ_XIVE_NR_MSIS (SPAPR_IRQ_XIVE_NR_IRQS - SPAPR_IRQ_MSI) - SpaprIrq spapr_irq_xive = { - .nr_irqs = SPAPR_IRQ_XIVE_NR_IRQS, - .nr_msis = SPAPR_IRQ_XIVE_NR_MSIS, + .nr_xirqs = SPAPR_NR_XIRQS, + .nr_msis = SPAPR_NR_MSIS, .ov5 = SPAPR_OV5_XIVE_EXPLOIT, .init = spapr_irq_init_xive, @@ -450,18 +443,18 @@ static SpaprIrq *spapr_irq_current(SpaprMachineState *spapr) &spapr_irq_xive : &spapr_irq_xics; } -static void spapr_irq_init_dual(SpaprMachineState *spapr, int nr_irqs, +static void spapr_irq_init_dual(SpaprMachineState *spapr, int nr_xirqs, Error **errp) { Error *local_err = NULL; - spapr_irq_xics.init(spapr, spapr_irq_xics.nr_irqs, &local_err); + spapr_irq_xics.init(spapr, spapr_irq_xics.nr_xirqs, &local_err); if (local_err) { error_propagate(errp, local_err); return; } - spapr_irq_xive.init(spapr, spapr_irq_xive.nr_irqs, &local_err); + spapr_irq_xive.init(spapr, spapr_irq_xive.nr_xirqs, &local_err); if (local_err) { error_propagate(errp, local_err); return; @@ -586,12 +579,9 @@ static const char *spapr_irq_get_nodename_dual(SpaprMachineState *spapr) /* * Define values in sync with the XIVE and XICS backend */ -#define SPAPR_IRQ_DUAL_NR_IRQS 0x2000 -#define SPAPR_IRQ_DUAL_NR_MSIS (SPAPR_IRQ_DUAL_NR_IRQS - SPAPR_IRQ_MSI) - SpaprIrq spapr_irq_dual = { - .nr_irqs = SPAPR_IRQ_DUAL_NR_IRQS, - .nr_msis = SPAPR_IRQ_DUAL_NR_MSIS, + .nr_xirqs = SPAPR_NR_XIRQS, + .nr_msis = SPAPR_NR_MSIS, .ov5 = SPAPR_OV5_XIVE_BOTH, .init = spapr_irq_init_dual, @@ -693,10 +683,10 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp) spapr_irq_msi_init(spapr, spapr->irq->nr_msis); } - spapr->irq->init(spapr, spapr->irq->nr_irqs, errp); + spapr->irq->init(spapr, spapr->irq->nr_xirqs, errp); spapr->qirqs = qemu_allocate_irqs(spapr->irq->set_irq, spapr, - spapr->irq->nr_irqs); + spapr->irq->nr_xirqs + SPAPR_XIRQ_BASE); } int spapr_irq_claim(SpaprMachineState *spapr, int irq, bool lsi, Error **errp) @@ -804,11 +794,11 @@ int spapr_irq_find(SpaprMachineState *spapr, int num, bool align, Error **errp) return first + ics->offset; } -#define SPAPR_IRQ_XICS_LEGACY_NR_IRQS 0x400 +#define SPAPR_IRQ_XICS_LEGACY_NR_XIRQS 0x400 SpaprIrq spapr_irq_xics_legacy = { - .nr_irqs = SPAPR_IRQ_XICS_LEGACY_NR_IRQS, - .nr_msis = SPAPR_IRQ_XICS_LEGACY_NR_IRQS, + .nr_xirqs = SPAPR_IRQ_XICS_LEGACY_NR_XIRQS, + .nr_msis = SPAPR_IRQ_XICS_LEGACY_NR_XIRQS, .ov5 = SPAPR_OV5_XIVE_LEGACY, .init = spapr_irq_init_xics, diff --git a/include/hw/ppc/spapr_irq.h b/include/hw/ppc/spapr_irq.h index 5db305165c..a8f9a2ab11 100644 --- a/include/hw/ppc/spapr_irq.h +++ b/include/hw/ppc/spapr_irq.h @@ -16,13 +16,18 @@ * IRQ range offsets per device type */ #define SPAPR_IRQ_IPI 0x0 -#define SPAPR_IRQ_EPOW 0x1000 /* XICS_IRQ_BASE offset */ -#define SPAPR_IRQ_HOTPLUG 0x1001 -#define SPAPR_IRQ_VIO 0x1100 /* 256 VIO devices */ -#define SPAPR_IRQ_PCI_LSI 0x1200 /* 32+ PHBs devices */ -#define SPAPR_IRQ_MSI 0x1300 /* Offset of the dynamic range covered - * by the bitmap allocator */ +#define SPAPR_XIRQ_BASE XICS_IRQ_BASE /* 0x1000 */ +#define SPAPR_IRQ_EPOW (SPAPR_XIRQ_BASE + 0x0000) +#define SPAPR_IRQ_HOTPLUG (SPAPR_XIRQ_BASE + 0x0001) +#define SPAPR_IRQ_VIO (SPAPR_XIRQ_BASE + 0x0100) /* 256 VIO devices */ +#define SPAPR_IRQ_PCI_LSI (SPAPR_XIRQ_BASE + 0x0200) /* 32+ PHBs devices */ + +/* Offset of the dynamic range covered by the bitmap allocator */ +#define SPAPR_IRQ_MSI (SPAPR_XIRQ_BASE + 0x0300) + +#define SPAPR_NR_XIRQS 0x1000 +#define SPAPR_NR_MSIS (SPAPR_XIRQ_BASE + SPAPR_NR_XIRQS - SPAPR_IRQ_MSI) typedef struct SpaprMachineState SpaprMachineState; @@ -32,7 +37,7 @@ int spapr_irq_msi_alloc(SpaprMachineState *spapr, uint32_t num, bool align, void spapr_irq_msi_free(SpaprMachineState *spapr, int irq, uint32_t num); typedef struct SpaprIrq { - uint32_t nr_irqs; + uint32_t nr_xirqs; uint32_t nr_msis; uint8_t ov5; From patchwork Wed Sep 25 06:45:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 11160091 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9CA571747 for ; Wed, 25 Sep 2019 07:04:29 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7302421D7C for ; Wed, 25 Sep 2019 07:04:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="BSDM4djY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7302421D7C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:46130 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD1Lf-0008Lv-5H for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Sep 2019 03:04:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38665) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD13l-0008Ij-BX for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:45:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iD13i-0003VX-Sz for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:45:56 -0400 Received: from ozlabs.org ([203.11.71.1]:38505) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iD13i-0003So-4m; Wed, 25 Sep 2019 02:45:54 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 46dT8q0wMzz9sQy; Wed, 25 Sep 2019 16:45:45 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1569393947; bh=JMryXFCQX+83LWf9xNsxwGC7o+eXObjPgPdxWMajCwM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BSDM4djYZR4g7tN/9/QLGIFgDpwGsBFGcl0YnnkHKSnlO2L7jW9H8ZmRBTl/Dq8Hv cRMq7yEpUV2N76QL8AhLA3WtXuALhNOz7FWb9Ru3N3qoJ8KirYnPdBiL1Os7eM7IX2 ALDwt5nh9nueMFoNYTJS3sI9jjqfYu6btD4n2Usw= From: David Gibson To: qemu-ppc@nongnu.org, clg@kaod.org, qemu-devel@nongnu.org Subject: [PATCH 10/20] spapr: Eliminate nr_irqs parameter to SpaprIrq::init Date: Wed, 25 Sep 2019 16:45:24 +1000 Message-Id: <20190925064534.19155-11-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190925064534.19155-1-david@gibson.dropbear.id.au> References: <20190925064534.19155-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Riku Voipio , groug@kaod.org, Laurent Vivier , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , philmd@redhat.com, David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" The only reason this parameter was needed was to work around the inconsistent meaning of nr_irqs between xics and xive. Now that we've fixed that, we can consistently use the number directly in the SpaprIrq configuration. Signed-off-by: David Gibson Reviewed-by: Cédric Le Goater Reviewed-by: Greg Kurz --- hw/ppc/spapr_irq.c | 21 ++++++++++----------- include/hw/ppc/spapr_irq.h | 2 +- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c index 5190a33e08..300c65be3a 100644 --- a/hw/ppc/spapr_irq.c +++ b/hw/ppc/spapr_irq.c @@ -92,8 +92,7 @@ static void spapr_irq_init_kvm(SpaprMachineState *spapr, * XICS IRQ backend. */ -static void spapr_irq_init_xics(SpaprMachineState *spapr, int nr_xirqs, - Error **errp) +static void spapr_irq_init_xics(SpaprMachineState *spapr, Error **errp) { Object *obj; Error *local_err = NULL; @@ -102,7 +101,8 @@ static void spapr_irq_init_xics(SpaprMachineState *spapr, int nr_xirqs, object_property_add_child(OBJECT(spapr), "ics", obj, &error_abort); object_property_add_const_link(obj, ICS_PROP_XICS, OBJECT(spapr), &error_fatal); - object_property_set_int(obj, nr_xirqs, "nr-irqs", &error_fatal); + object_property_set_int(obj, spapr->irq->nr_xirqs, + "nr-irqs", &error_fatal); object_property_set_bool(obj, true, "realized", &local_err); if (local_err) { error_propagate(errp, local_err); @@ -256,15 +256,15 @@ SpaprIrq spapr_irq_xics = { /* * XIVE IRQ backend. */ -static void spapr_irq_init_xive(SpaprMachineState *spapr, int nr_xirqs, - Error **errp) +static void spapr_irq_init_xive(SpaprMachineState *spapr, Error **errp) { uint32_t nr_servers = spapr_max_server_number(spapr); DeviceState *dev; int i; dev = qdev_create(NULL, TYPE_SPAPR_XIVE); - qdev_prop_set_uint32(dev, "nr-irqs", nr_xirqs + SPAPR_XIRQ_BASE); + qdev_prop_set_uint32(dev, "nr-irqs", + spapr->irq->nr_xirqs + SPAPR_XIRQ_BASE); /* * 8 XIVE END structures per CPU. One for each available priority */ @@ -443,18 +443,17 @@ static SpaprIrq *spapr_irq_current(SpaprMachineState *spapr) &spapr_irq_xive : &spapr_irq_xics; } -static void spapr_irq_init_dual(SpaprMachineState *spapr, int nr_xirqs, - Error **errp) +static void spapr_irq_init_dual(SpaprMachineState *spapr, Error **errp) { Error *local_err = NULL; - spapr_irq_xics.init(spapr, spapr_irq_xics.nr_xirqs, &local_err); + spapr_irq_xics.init(spapr, &local_err); if (local_err) { error_propagate(errp, local_err); return; } - spapr_irq_xive.init(spapr, spapr_irq_xive.nr_xirqs, &local_err); + spapr_irq_xive.init(spapr, &local_err); if (local_err) { error_propagate(errp, local_err); return; @@ -683,7 +682,7 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp) spapr_irq_msi_init(spapr, spapr->irq->nr_msis); } - spapr->irq->init(spapr, spapr->irq->nr_xirqs, errp); + spapr->irq->init(spapr, errp); spapr->qirqs = qemu_allocate_irqs(spapr->irq->set_irq, spapr, spapr->irq->nr_xirqs + SPAPR_XIRQ_BASE); diff --git a/include/hw/ppc/spapr_irq.h b/include/hw/ppc/spapr_irq.h index a8f9a2ab11..7e26288fcd 100644 --- a/include/hw/ppc/spapr_irq.h +++ b/include/hw/ppc/spapr_irq.h @@ -41,7 +41,7 @@ typedef struct SpaprIrq { uint32_t nr_msis; uint8_t ov5; - void (*init)(SpaprMachineState *spapr, int nr_irqs, Error **errp); + void (*init)(SpaprMachineState *spapr, Error **errp); int (*claim)(SpaprMachineState *spapr, int irq, bool lsi, Error **errp); void (*free)(SpaprMachineState *spapr, int irq, int num); qemu_irq (*qirq)(SpaprMachineState *spapr, int irq); From patchwork Wed Sep 25 06:45:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 11160103 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A9883924 for ; Wed, 25 Sep 2019 07:08:37 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 808A821D7E for ; Wed, 25 Sep 2019 07:08:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="A6SGD5dv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 808A821D7E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:46204 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD1Pg-0003et-C8 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Sep 2019 03:08:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38788) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD13p-0008ME-Uv for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:46:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iD13n-0003aA-2K for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:46:00 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:44959) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iD13l-0003Vz-FA; Wed, 25 Sep 2019 02:45:58 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 46dT8q68dNz9sR6; Wed, 25 Sep 2019 16:45:45 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1569393947; bh=gDYidKYz7y8EfQr8lqJklSntW5UscHFQLNhJmsIONnw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A6SGD5dvd/AHAT/8gB92QrM1lX8zuTOduhxkVhidPDvmmuxoE7ZWieZvnpxJeNXeD dVz3Tqn+HkaN4XfIoXVVN4RrBpUspZcBTMrQkwOLNE22CGFmymDgrRJ/jvGDGggcIW caxWhtoYOMGPe1BIFxVTPp3rBpIzeJRbkuXc2cSQ= From: David Gibson To: qemu-ppc@nongnu.org, clg@kaod.org, qemu-devel@nongnu.org Subject: [PATCH 11/20] spapr: Fix indexing of XICS irqs Date: Wed, 25 Sep 2019 16:45:25 +1000 Message-Id: <20190925064534.19155-12-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190925064534.19155-1-david@gibson.dropbear.id.au> References: <20190925064534.19155-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Riku Voipio , groug@kaod.org, Laurent Vivier , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , philmd@redhat.com, David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" spapr global irq numbers are different from the source numbers on the ICS when using XICS - they're offset by XICS_IRQ_BASE (0x1000). But spapr_irq_set_irq_xics() was passing through the global irq number to the ICS code unmodified. We only got away with this because of a counteracting bug - we were incorrectly adjusting the qemu_irq we returned for a requested global irq number. That approach mostly worked but is very confusing, incorrectly relies on the way the qemu_irq array is allocated, and undermines the intention of having the global array of qemu_irqs for spapr have a consistent meaning regardless of irq backend. So, fix both set_irq and qemu_irq indexing. We rename some parameters at the same time to make it clear that they are referring to spapr global irq numbers. Signed-off-by: David Gibson Reviewed-by: Cédric Le Goater Reviewed-by: Greg Kurz --- hw/ppc/spapr_irq.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c index 300c65be3a..9a9e486eb5 100644 --- a/hw/ppc/spapr_irq.c +++ b/hw/ppc/spapr_irq.c @@ -153,10 +153,9 @@ static void spapr_irq_free_xics(SpaprMachineState *spapr, int irq, int num) static qemu_irq spapr_qirq_xics(SpaprMachineState *spapr, int irq) { ICSState *ics = spapr->ics; - uint32_t srcno = irq - ics->offset; if (ics_valid_irq(ics, irq)) { - return spapr->qirqs[srcno]; + return spapr->qirqs[irq]; } return NULL; @@ -204,9 +203,10 @@ static int spapr_irq_post_load_xics(SpaprMachineState *spapr, int version_id) return 0; } -static void spapr_irq_set_irq_xics(void *opaque, int srcno, int val) +static void spapr_irq_set_irq_xics(void *opaque, int irq, int val) { SpaprMachineState *spapr = opaque; + uint32_t srcno = irq - spapr->ics->offset; ics_set_irq(spapr->ics, srcno, val); } @@ -377,14 +377,14 @@ static void spapr_irq_reset_xive(SpaprMachineState *spapr, Error **errp) spapr_xive_mmio_set_enabled(spapr->xive, true); } -static void spapr_irq_set_irq_xive(void *opaque, int srcno, int val) +static void spapr_irq_set_irq_xive(void *opaque, int irq, int val) { SpaprMachineState *spapr = opaque; if (kvm_irqchip_in_kernel()) { - kvmppc_xive_source_set_irq(&spapr->xive->source, srcno, val); + kvmppc_xive_source_set_irq(&spapr->xive->source, irq, val); } else { - xive_source_set_irq(&spapr->xive->source, srcno, val); + xive_source_set_irq(&spapr->xive->source, irq, val); } } @@ -563,11 +563,11 @@ static void spapr_irq_reset_dual(SpaprMachineState *spapr, Error **errp) spapr_irq_current(spapr)->reset(spapr, errp); } -static void spapr_irq_set_irq_dual(void *opaque, int srcno, int val) +static void spapr_irq_set_irq_dual(void *opaque, int irq, int val) { SpaprMachineState *spapr = opaque; - spapr_irq_current(spapr)->set_irq(spapr, srcno, val); + spapr_irq_current(spapr)->set_irq(spapr, irq, val); } static const char *spapr_irq_get_nodename_dual(SpaprMachineState *spapr) From patchwork Wed Sep 25 06:45:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 11160085 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 11C8F1599 for ; Wed, 25 Sep 2019 06:58:47 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DC11A217F4 for ; Wed, 25 Sep 2019 06:58:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="XBTZB/56" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DC11A217F4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:46068 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD1G9-0003Z3-8D for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Sep 2019 02:58:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38669) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD13l-0008Io-ID for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:45:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iD13j-0003Vg-0f for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:45:57 -0400 Received: from ozlabs.org ([203.11.71.1]:56047) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iD13i-0003Sb-9i; Wed, 25 Sep 2019 02:45:54 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 46dT8p65Cbz9sR4; Wed, 25 Sep 2019 16:45:45 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1569393946; bh=87aArDsIH1kv8YDMPpbVVsKjdvS7WIR74uaACPSqMhs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XBTZB/56HH0rQe/KxJwmu5ygx1oTVrXoyklGyzn5M/2Zirv2/n7j7nWOYhX1x19yp vL8E6r/uhyMfesGgFOIIyyMKmWTcSP8L8QnkrdZcXWemU5xypNor2mnRwHWeNMOG+g nTLivUPpaivKNozqlIBch1LKfm1o5yqdQOpAyQBU= From: David Gibson To: qemu-ppc@nongnu.org, clg@kaod.org, qemu-devel@nongnu.org Subject: [PATCH 12/20] spapr: Simplify spapr_qirq() handling Date: Wed, 25 Sep 2019 16:45:26 +1000 Message-Id: <20190925064534.19155-13-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190925064534.19155-1-david@gibson.dropbear.id.au> References: <20190925064534.19155-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Riku Voipio , groug@kaod.org, Laurent Vivier , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , philmd@redhat.com, David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Currently spapr_qirq() used to find the qemu_irq for an spapr global irq number, redirects through the SpaprIrq::qirq method. But the array of qemu_irqs is allocated in the PAPR layer, not the backends, and so the method implementations all return the same thing, just differing in the preliminary checks they make. So, we can remove the method, and just implement spapr_qirq() directly, including all the relevant checks in one place. We change all those checks into assert()s as well, since a failure here indicates an error in the calling code. Signed-off-by: David Gibson Reviewed-by: Cédric Le Goater Reviewed-by: Greg Kurz Reviewed-by: Philippe Mathieu-Daudé --- hw/ppc/spapr_irq.c | 47 ++++++++++---------------------------- include/hw/ppc/spapr_irq.h | 1 - 2 files changed, 12 insertions(+), 36 deletions(-) diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c index 9a9e486eb5..038bfffff4 100644 --- a/hw/ppc/spapr_irq.c +++ b/hw/ppc/spapr_irq.c @@ -150,17 +150,6 @@ static void spapr_irq_free_xics(SpaprMachineState *spapr, int irq, int num) } } -static qemu_irq spapr_qirq_xics(SpaprMachineState *spapr, int irq) -{ - ICSState *ics = spapr->ics; - - if (ics_valid_irq(ics, irq)) { - return spapr->qirqs[irq]; - } - - return NULL; -} - static void spapr_irq_print_info_xics(SpaprMachineState *spapr, Monitor *mon) { CPUState *cs; @@ -242,7 +231,6 @@ SpaprIrq spapr_irq_xics = { .init = spapr_irq_init_xics, .claim = spapr_irq_claim_xics, .free = spapr_irq_free_xics, - .qirq = spapr_qirq_xics, .print_info = spapr_irq_print_info_xics, .dt_populate = spapr_dt_xics, .cpu_intc_create = spapr_irq_cpu_intc_create_xics, @@ -300,20 +288,6 @@ static void spapr_irq_free_xive(SpaprMachineState *spapr, int irq, int num) } } -static qemu_irq spapr_qirq_xive(SpaprMachineState *spapr, int irq) -{ - SpaprXive *xive = spapr->xive; - - if ((irq < SPAPR_XIRQ_BASE) || (irq >= xive->nr_irqs)) { - return NULL; - } - - /* The sPAPR machine/device should have claimed the IRQ before */ - assert(xive_eas_is_valid(&xive->eat[irq])); - - return spapr->qirqs[irq]; -} - static void spapr_irq_print_info_xive(SpaprMachineState *spapr, Monitor *mon) { @@ -413,7 +387,6 @@ SpaprIrq spapr_irq_xive = { .init = spapr_irq_init_xive, .claim = spapr_irq_claim_xive, .free = spapr_irq_free_xive, - .qirq = spapr_qirq_xive, .print_info = spapr_irq_print_info_xive, .dt_populate = spapr_dt_xive, .cpu_intc_create = spapr_irq_cpu_intc_create_xive, @@ -487,11 +460,6 @@ static void spapr_irq_free_dual(SpaprMachineState *spapr, int irq, int num) spapr_irq_xive.free(spapr, irq, num); } -static qemu_irq spapr_qirq_dual(SpaprMachineState *spapr, int irq) -{ - return spapr_irq_current(spapr)->qirq(spapr, irq); -} - static void spapr_irq_print_info_dual(SpaprMachineState *spapr, Monitor *mon) { spapr_irq_current(spapr)->print_info(spapr, mon); @@ -586,7 +554,6 @@ SpaprIrq spapr_irq_dual = { .init = spapr_irq_init_dual, .claim = spapr_irq_claim_dual, .free = spapr_irq_free_dual, - .qirq = spapr_qirq_dual, .print_info = spapr_irq_print_info_dual, .dt_populate = spapr_irq_dt_populate_dual, .cpu_intc_create = spapr_irq_cpu_intc_create_dual, @@ -700,7 +667,18 @@ void spapr_irq_free(SpaprMachineState *spapr, int irq, int num) qemu_irq spapr_qirq(SpaprMachineState *spapr, int irq) { - return spapr->irq->qirq(spapr, irq); + assert(irq >= SPAPR_XIRQ_BASE); + assert(irq < (spapr->irq->nr_xirqs + SPAPR_XIRQ_BASE)); + + if (spapr->ics) { + assert(ics_valid_irq(spapr->ics, irq)); + } + if (spapr->xive) { + assert(irq < spapr->xive->nr_irqs); + assert(xive_eas_is_valid(&spapr->xive->eat[irq])); + } + + return spapr->qirqs[irq]; } int spapr_irq_post_load(SpaprMachineState *spapr, int version_id) @@ -803,7 +781,6 @@ SpaprIrq spapr_irq_xics_legacy = { .init = spapr_irq_init_xics, .claim = spapr_irq_claim_xics, .free = spapr_irq_free_xics, - .qirq = spapr_qirq_xics, .print_info = spapr_irq_print_info_xics, .dt_populate = spapr_dt_xics, .cpu_intc_create = spapr_irq_cpu_intc_create_xics, diff --git a/include/hw/ppc/spapr_irq.h b/include/hw/ppc/spapr_irq.h index 7e26288fcd..a4e790ef60 100644 --- a/include/hw/ppc/spapr_irq.h +++ b/include/hw/ppc/spapr_irq.h @@ -44,7 +44,6 @@ typedef struct SpaprIrq { void (*init)(SpaprMachineState *spapr, Error **errp); int (*claim)(SpaprMachineState *spapr, int irq, bool lsi, Error **errp); void (*free)(SpaprMachineState *spapr, int irq, int num); - qemu_irq (*qirq)(SpaprMachineState *spapr, int irq); void (*print_info)(SpaprMachineState *spapr, Monitor *mon); void (*dt_populate)(SpaprMachineState *spapr, uint32_t nr_servers, void *fdt, uint32_t phandle); From patchwork Wed Sep 25 06:45:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 11160083 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D04BD1709 for ; Wed, 25 Sep 2019 06:57:54 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 63B08217F4 for ; Wed, 25 Sep 2019 06:57:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="JaBn/QlM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 63B08217F4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:46066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD1FI-00024Q-EF for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Sep 2019 02:57:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38674) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD13l-0008J8-ME for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:45:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iD13j-0003Vp-3E for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:45:57 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:56525) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iD13i-0003Sh-CI; Wed, 25 Sep 2019 02:45:55 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 46dT8p3vxbz9sPq; Wed, 25 Sep 2019 16:45:45 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1569393946; bh=MWyjaNqGeiZxSx2ghrsuLbE75RKkfcGeLPbhW/hfzCU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JaBn/QlMP4fkzRW2WrKR8m+DwvsHLahByHRQ8vxh+IaxPjisL0E3aRBwJc0cfRaZ2 QnPquIKfNqHWgvofj9axw5UKuVLSU5H1c/p9KOEe2Ofmf3aC2G3bHh6SN64+Js78gI LZjRTqEBCRK97YgfqcBJtFAt8mDqz1h/YpoStKsE= From: David Gibson To: qemu-ppc@nongnu.org, clg@kaod.org, qemu-devel@nongnu.org Subject: [PATCH 13/20] spapr: Eliminate SpaprIrq:get_nodename method Date: Wed, 25 Sep 2019 16:45:27 +1000 Message-Id: <20190925064534.19155-14-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190925064534.19155-1-david@gibson.dropbear.id.au> References: <20190925064534.19155-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Riku Voipio , groug@kaod.org, Laurent Vivier , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , philmd@redhat.com, David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This method is used to determine the name of the irq backend's node in the device tree, so that we can find its phandle (after SLOF may have modified it from the phandle we initially gave it). But, in the two cases the only difference between the node name is the presence of a unit address. Searching for a node name without considering unit address is standard practice for the device tree, and fdt_subnode_offset() will do exactly that. So, the method is unnecessary. Signed-off-by: David Gibson Reviewed-by: Cédric Le Goater Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Greg Kurz --- hw/ppc/spapr_irq.c | 25 +++---------------------- include/hw/ppc/spapr_irq.h | 1 - 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c index 038bfffff4..79167ccc68 100644 --- a/hw/ppc/spapr_irq.c +++ b/hw/ppc/spapr_irq.c @@ -211,11 +211,6 @@ static void spapr_irq_reset_xics(SpaprMachineState *spapr, Error **errp) } } -static const char *spapr_irq_get_nodename_xics(SpaprMachineState *spapr) -{ - return XICS_NODENAME; -} - static void spapr_irq_init_kvm_xics(SpaprMachineState *spapr, Error **errp) { if (kvm_enabled()) { @@ -237,7 +232,6 @@ SpaprIrq spapr_irq_xics = { .post_load = spapr_irq_post_load_xics, .reset = spapr_irq_reset_xics, .set_irq = spapr_irq_set_irq_xics, - .get_nodename = spapr_irq_get_nodename_xics, .init_kvm = spapr_irq_init_kvm_xics, }; @@ -362,11 +356,6 @@ static void spapr_irq_set_irq_xive(void *opaque, int irq, int val) } } -static const char *spapr_irq_get_nodename_xive(SpaprMachineState *spapr) -{ - return spapr->xive->nodename; -} - static void spapr_irq_init_kvm_xive(SpaprMachineState *spapr, Error **errp) { if (kvm_enabled()) { @@ -393,7 +382,6 @@ SpaprIrq spapr_irq_xive = { .post_load = spapr_irq_post_load_xive, .reset = spapr_irq_reset_xive, .set_irq = spapr_irq_set_irq_xive, - .get_nodename = spapr_irq_get_nodename_xive, .init_kvm = spapr_irq_init_kvm_xive, }; @@ -538,11 +526,6 @@ static void spapr_irq_set_irq_dual(void *opaque, int irq, int val) spapr_irq_current(spapr)->set_irq(spapr, irq, val); } -static const char *spapr_irq_get_nodename_dual(SpaprMachineState *spapr) -{ - return spapr_irq_current(spapr)->get_nodename(spapr); -} - /* * Define values in sync with the XIVE and XICS backend */ @@ -560,7 +543,6 @@ SpaprIrq spapr_irq_dual = { .post_load = spapr_irq_post_load_dual, .reset = spapr_irq_reset_dual, .set_irq = spapr_irq_set_irq_dual, - .get_nodename = spapr_irq_get_nodename_dual, .init_kvm = NULL, /* should not be used */ }; @@ -697,13 +679,13 @@ void spapr_irq_reset(SpaprMachineState *spapr, Error **errp) int spapr_irq_get_phandle(SpaprMachineState *spapr, void *fdt, Error **errp) { - const char *nodename = spapr->irq->get_nodename(spapr); + const char *nodename = "interrupt-controller"; int offset, phandle; offset = fdt_subnode_offset(fdt, 0, nodename); if (offset < 0) { - error_setg(errp, "Can't find node \"%s\": %s", nodename, - fdt_strerror(offset)); + error_setg(errp, "Can't find node \"%s\": %s", + nodename, fdt_strerror(offset)); return -1; } @@ -787,6 +769,5 @@ SpaprIrq spapr_irq_xics_legacy = { .post_load = spapr_irq_post_load_xics, .reset = spapr_irq_reset_xics, .set_irq = spapr_irq_set_irq_xics, - .get_nodename = spapr_irq_get_nodename_xics, .init_kvm = spapr_irq_init_kvm_xics, }; diff --git a/include/hw/ppc/spapr_irq.h b/include/hw/ppc/spapr_irq.h index a4e790ef60..9b60378e28 100644 --- a/include/hw/ppc/spapr_irq.h +++ b/include/hw/ppc/spapr_irq.h @@ -52,7 +52,6 @@ typedef struct SpaprIrq { int (*post_load)(SpaprMachineState *spapr, int version_id); void (*reset)(SpaprMachineState *spapr, Error **errp); void (*set_irq)(void *opaque, int srcno, int val); - const char *(*get_nodename)(SpaprMachineState *spapr); void (*init_kvm)(SpaprMachineState *spapr, Error **errp); } SpaprIrq; From patchwork Wed Sep 25 06:45:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 11160087 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E706E1599 for ; Wed, 25 Sep 2019 07:03:20 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 79BB221D7C for ; Wed, 25 Sep 2019 07:03:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="Ix3h4Cqj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 79BB221D7C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:46124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD1KY-0007Pd-Gr for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Sep 2019 03:03:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38756) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD13o-0008LP-6o for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:46:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iD13m-0003Zg-M8 for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:45:59 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:55503) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iD13l-0003Vk-0k; Wed, 25 Sep 2019 02:45:58 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 46dT8q2m3yz9sQv; Wed, 25 Sep 2019 16:45:46 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1569393947; bh=/zwjFMEAaBULPaD+OgxpT0tmoLDpWE8TI3G+IoxSq1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ix3h4CqjzSQUTvJLfRmm5R+2CilzV2Wz1rDiYxdBqxCU0yI/ITPgS+DjUVncPP7Z3 hdQH7yXqix8mkuXdZJqNDMBIos1RdSLYFb5+vZIr9UJThYofFvu3buxMF8j+hUC7aq jBH5QMV1+oUBUL4rszng8jrPHwxvId/zBCr12bD4= From: David Gibson To: qemu-ppc@nongnu.org, clg@kaod.org, qemu-devel@nongnu.org Subject: [PATCH 14/20] spapr: Remove unhelpful tracepoints from spapr_irq_free_xics() Date: Wed, 25 Sep 2019 16:45:28 +1000 Message-Id: <20190925064534.19155-15-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190925064534.19155-1-david@gibson.dropbear.id.au> References: <20190925064534.19155-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Riku Voipio , groug@kaod.org, Laurent Vivier , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , philmd@redhat.com, David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" These traces contain some useless information (the always-0 source#) and have no equivalents for XIVE mode. For now just remove them, and we can put back something more sensible if and when we need it. Signed-off-by: David Gibson Reviewed-by: Cédric Le Goater Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Greg Kurz --- hw/ppc/spapr_irq.c | 4 ---- hw/ppc/trace-events | 4 ---- 2 files changed, 8 deletions(-) diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c index 79167ccc68..db6755f3ab 100644 --- a/hw/ppc/spapr_irq.c +++ b/hw/ppc/spapr_irq.c @@ -140,11 +140,7 @@ static void spapr_irq_free_xics(SpaprMachineState *spapr, int irq, int num) int i; if (ics_valid_irq(ics, irq)) { - trace_spapr_irq_free(0, irq, num); for (i = srcno; i < srcno + num; ++i) { - if (ics_irq_free(ics, i)) { - trace_spapr_irq_free_warn(0, i); - } memset(&ics->irqs[i], 0, sizeof(ICSIRQState)); } } diff --git a/hw/ppc/trace-events b/hw/ppc/trace-events index 96dad767a1..9ea620f23c 100644 --- a/hw/ppc/trace-events +++ b/hw/ppc/trace-events @@ -13,10 +13,6 @@ spapr_pci_msi_retry(unsigned config_addr, unsigned req_num, unsigned max_irqs) " spapr_cas_failed(unsigned long n) "DT diff buffer is too small: %ld bytes" spapr_cas_continue(unsigned long n) "Copy changes to the guest: %ld bytes" -# spapr_irq.c -spapr_irq_free(int src, int irq, int num) "Source#%d, first irq %d, %d irqs" -spapr_irq_free_warn(int src, int irq) "Source#%d, irq %d is already free" - # spapr_hcall.c spapr_cas_pvr(uint32_t cur_pvr, bool explicit_match, uint32_t new_pvr) "current=0x%x, explicit_match=%u, new=0x%x" spapr_h_resize_hpt_prepare(uint64_t flags, uint64_t shift) "flags=0x%"PRIx64", shift=%"PRIu64 From patchwork Wed Sep 25 06:45:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 11160101 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C6854924 for ; Wed, 25 Sep 2019 07:07:54 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9BFB921D7C for ; Wed, 25 Sep 2019 07:07:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="YWwkeYfu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9BFB921D7C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:46191 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD1Oz-0002qm-1P for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Sep 2019 03:07:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38805) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD13p-0008MV-4x for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:46:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iD13n-0003aN-3G for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:46:00 -0400 Received: from ozlabs.org ([203.11.71.1]:58927) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iD13l-0003Vt-8G; Wed, 25 Sep 2019 02:45:58 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 46dT8q3pKmz9sR5; Wed, 25 Sep 2019 16:45:46 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1569393947; bh=qzWCECiW3SZYCp/MyCzF23lwrQKJGr9u6PHBmtIcAtg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YWwkeYfuOBJBlo0zBanX8iiPKp0U2ptGs7IshxsWWGEUkcvPvXUIIBqWTdrjlXJyL uiJs1LVQo8xiOqog6tOJglCEduPQ5fG+4s91GHN3T6piXDewdyM5GTBXe/aKVBisoV kx/YTAKDPQ8bAb5Bh4uWvxg0NTiwBzazVwdDDcEk= From: David Gibson To: qemu-ppc@nongnu.org, clg@kaod.org, qemu-devel@nongnu.org Subject: [PATCH 15/20] spapr: Handle freeing of multiple irqs in frontend only Date: Wed, 25 Sep 2019 16:45:29 +1000 Message-Id: <20190925064534.19155-16-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190925064534.19155-1-david@gibson.dropbear.id.au> References: <20190925064534.19155-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Riku Voipio , groug@kaod.org, Laurent Vivier , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , philmd@redhat.com, David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" spapr_irq_free() can be used to free multiple irqs at once. That's useful for its callers, but there's no need to make the individual backend hooks handle this. We can loop across the irqs in spapr_irq_free() itself and have the hooks just do one at time. Signed-off-by: David Gibson Reviewed-by: Cédric Le Goater Reviewed-by: Greg Kurz --- hw/ppc/spapr_irq.c | 27 ++++++++++++--------------- include/hw/ppc/spapr_irq.h | 2 +- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c index db6755f3ab..c40357a985 100644 --- a/hw/ppc/spapr_irq.c +++ b/hw/ppc/spapr_irq.c @@ -133,16 +133,13 @@ static int spapr_irq_claim_xics(SpaprMachineState *spapr, int irq, bool lsi, return 0; } -static void spapr_irq_free_xics(SpaprMachineState *spapr, int irq, int num) +static void spapr_irq_free_xics(SpaprMachineState *spapr, int irq) { ICSState *ics = spapr->ics; uint32_t srcno = irq - ics->offset; - int i; if (ics_valid_irq(ics, irq)) { - for (i = srcno; i < srcno + num; ++i) { - memset(&ics->irqs[i], 0, sizeof(ICSIRQState)); - } + memset(&ics->irqs[srcno], 0, sizeof(ICSIRQState)); } } @@ -269,13 +266,9 @@ static int spapr_irq_claim_xive(SpaprMachineState *spapr, int irq, bool lsi, return 0; } -static void spapr_irq_free_xive(SpaprMachineState *spapr, int irq, int num) +static void spapr_irq_free_xive(SpaprMachineState *spapr, int irq) { - int i; - - for (i = irq; i < irq + num; ++i) { - spapr_xive_irq_free(spapr->xive, i); - } + spapr_xive_irq_free(spapr->xive, irq); } static void spapr_irq_print_info_xive(SpaprMachineState *spapr, @@ -438,10 +431,10 @@ static int spapr_irq_claim_dual(SpaprMachineState *spapr, int irq, bool lsi, return ret; } -static void spapr_irq_free_dual(SpaprMachineState *spapr, int irq, int num) +static void spapr_irq_free_dual(SpaprMachineState *spapr, int irq) { - spapr_irq_xics.free(spapr, irq, num); - spapr_irq_xive.free(spapr, irq, num); + spapr_irq_xics.free(spapr, irq); + spapr_irq_xive.free(spapr, irq); } static void spapr_irq_print_info_dual(SpaprMachineState *spapr, Monitor *mon) @@ -640,7 +633,11 @@ int spapr_irq_claim(SpaprMachineState *spapr, int irq, bool lsi, Error **errp) void spapr_irq_free(SpaprMachineState *spapr, int irq, int num) { - spapr->irq->free(spapr, irq, num); + int i; + + for (i = irq; i < (irq + num); i++) { + spapr->irq->free(spapr, irq); + } } qemu_irq spapr_qirq(SpaprMachineState *spapr, int irq) diff --git a/include/hw/ppc/spapr_irq.h b/include/hw/ppc/spapr_irq.h index 9b60378e28..ed88b4599a 100644 --- a/include/hw/ppc/spapr_irq.h +++ b/include/hw/ppc/spapr_irq.h @@ -43,7 +43,7 @@ typedef struct SpaprIrq { void (*init)(SpaprMachineState *spapr, Error **errp); int (*claim)(SpaprMachineState *spapr, int irq, bool lsi, Error **errp); - void (*free)(SpaprMachineState *spapr, int irq, int num); + void (*free)(SpaprMachineState *spapr, int irq); void (*print_info)(SpaprMachineState *spapr, Monitor *mon); void (*dt_populate)(SpaprMachineState *spapr, uint32_t nr_servers, void *fdt, uint32_t phandle); From patchwork Wed Sep 25 06:45:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 11160113 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CC7461709 for ; Wed, 25 Sep 2019 07:16:03 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9ED8C205F4 for ; Wed, 25 Sep 2019 07:16:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="mMuijqRG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9ED8C205F4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:46270 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD1Wr-00022K-O5 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Sep 2019 03:16:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38861) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD13q-0008Nw-Ti for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:46:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iD13o-0003c8-Qi for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:46:02 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:33849) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iD13n-0003WM-VY; Wed, 25 Sep 2019 02:46:00 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 46dT8r6Q3Kz9sR8; Wed, 25 Sep 2019 16:45:46 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1569393948; bh=7/ZmWbpKthqCsg3F29+02eHkS47QSKj87SxvyMLlZjw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mMuijqRGkNTILbC2Jxe4rUHCfoSJGBLXMhe6wTfiatQYRxyxZOrUXTuO0bZqB9NFt dVSHlOnCjzlBO8U2s/Sw9ZBaT+kXcHO5qkdxk5gsgWOyNXC4pd0XgihnAgyNqUBL6U 4mlr40wXaVQ1PQO25WTaOOBSOLhWUTX1jYbxTjUs= From: David Gibson To: qemu-ppc@nongnu.org, clg@kaod.org, qemu-devel@nongnu.org Subject: [PATCH 16/20] spapr, xics, xive: Better use of assert()s on irq claim/free paths Date: Wed, 25 Sep 2019 16:45:30 +1000 Message-Id: <20190925064534.19155-17-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190925064534.19155-1-david@gibson.dropbear.id.au> References: <20190925064534.19155-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Riku Voipio , groug@kaod.org, Laurent Vivier , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , philmd@redhat.com, David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" The irq claim and free paths for both XICS and XIVE check for some validity conditions. Some of these represent genuine runtime failures, however others - particularly checking that the basic irq number is in a sane range - could only fail in the case of bugs in the callin code. Therefore use assert()s instead of runtime failures for those. In addition the non backend-specific part of the claim/free paths should only be used for PAPR external irqs, that is in the range SPAPR_XIRQ_BASE to the maximum irq number. Put assert()s for that into the top level dispatchers as well. Signed-off-by: David Gibson Reviewed-by: Cédric Le Goater Reviewed-by: Greg Kurz --- hw/intc/spapr_xive.c | 8 ++------ hw/ppc/spapr_irq.c | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c index c1c97192a7..47b5ec0b56 100644 --- a/hw/intc/spapr_xive.c +++ b/hw/intc/spapr_xive.c @@ -532,9 +532,7 @@ bool spapr_xive_irq_claim(SpaprXive *xive, uint32_t lisn, bool lsi) { XiveSource *xsrc = &xive->source; - if (lisn >= xive->nr_irqs) { - return false; - } + assert(lisn < xive->nr_irqs); /* * Set default values when allocating an IRQ number @@ -559,9 +557,7 @@ bool spapr_xive_irq_claim(SpaprXive *xive, uint32_t lisn, bool lsi) bool spapr_xive_irq_free(SpaprXive *xive, uint32_t lisn) { - if (lisn >= xive->nr_irqs) { - return false; - } + assert(lisn < xive->nr_irqs); xive->eat[lisn].w &= cpu_to_be64(~EAS_VALID); return true; diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c index c40357a985..261d66ba17 100644 --- a/hw/ppc/spapr_irq.c +++ b/hw/ppc/spapr_irq.c @@ -118,11 +118,7 @@ static int spapr_irq_claim_xics(SpaprMachineState *spapr, int irq, bool lsi, ICSState *ics = spapr->ics; assert(ics); - - if (!ics_valid_irq(ics, irq)) { - error_setg(errp, "IRQ %d is invalid", irq); - return -1; - } + assert(ics_valid_irq(ics, irq)); if (!ics_irq_free(ics, irq - ics->offset)) { error_setg(errp, "IRQ %d is not free", irq); @@ -138,9 +134,9 @@ static void spapr_irq_free_xics(SpaprMachineState *spapr, int irq) ICSState *ics = spapr->ics; uint32_t srcno = irq - ics->offset; - if (ics_valid_irq(ics, irq)) { - memset(&ics->irqs[srcno], 0, sizeof(ICSIRQState)); - } + assert(ics_valid_irq(ics, irq)); + + memset(&ics->irqs[srcno], 0, sizeof(ICSIRQState)); } static void spapr_irq_print_info_xics(SpaprMachineState *spapr, Monitor *mon) @@ -628,6 +624,9 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp) int spapr_irq_claim(SpaprMachineState *spapr, int irq, bool lsi, Error **errp) { + assert(irq >= SPAPR_XIRQ_BASE); + assert(irq < (spapr->irq->nr_xirqs + SPAPR_XIRQ_BASE)); + return spapr->irq->claim(spapr, irq, lsi, errp); } @@ -635,6 +634,9 @@ void spapr_irq_free(SpaprMachineState *spapr, int irq, int num) { int i; + assert(irq >= SPAPR_XIRQ_BASE); + assert((irq+num) <= (spapr->irq->nr_xirqs + SPAPR_XIRQ_BASE)); + for (i = irq; i < (irq + num); i++) { spapr->irq->free(spapr, irq); } From patchwork Wed Sep 25 06:45:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 11160151 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 66EF2912 for ; Wed, 25 Sep 2019 07:21:16 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3D5BB222CC for ; Wed, 25 Sep 2019 07:21:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="fe0cKCE4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3D5BB222CC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:46316 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD1bu-0006pU-C6 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Sep 2019 03:21:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38868) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD13r-0008O6-3p for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:46:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iD13o-0003cD-QP for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:46:02 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:48221) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iD13n-0003WD-UU; Wed, 25 Sep 2019 02:46:00 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 46dT8r5YHWz9sRC; Wed, 25 Sep 2019 16:45:47 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1569393948; bh=oOHf3Ok6mT3niH+4eQHB15aHwOyP7EicV3r2obz9UAE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fe0cKCE427tphSrzrvlfi66K50YuZ3mMThWROQiTc2KSGDb9HQcwGzOwOYyCnCrvw P1oxYhzd8Cuo9Zb/A1sCkl0VDhYRSQnIHt4guXzbujr4BZc8E2TOUJzzAE//nMyEV/ B+NdfOped3nUwx/1DQp+/+rxscWhy7Ccde/+NKTI= From: David Gibson To: qemu-ppc@nongnu.org, clg@kaod.org, qemu-devel@nongnu.org Subject: [PATCH 17/20] spapr: Remove unused return value in claim path Date: Wed, 25 Sep 2019 16:45:31 +1000 Message-Id: <20190925064534.19155-18-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190925064534.19155-1-david@gibson.dropbear.id.au> References: <20190925064534.19155-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Riku Voipio , groug@kaod.org, Laurent Vivier , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , philmd@redhat.com, David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" spapr_irq_claim() and the hooks it is based on return an integer error code as well as taking an Error ** parameter. But none of the callers check the integer, so we can remove it and just use the richer Error **. Signed-off-by: David Gibson Reviewed-by: Cédric Le Goater Reviewed-by: Philippe Mathieu-Daudé --- hw/ppc/spapr_irq.c | 32 +++++++++++++------------------- include/hw/ppc/spapr_irq.h | 4 ++-- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c index 261d66ba17..2673a90604 100644 --- a/hw/ppc/spapr_irq.c +++ b/hw/ppc/spapr_irq.c @@ -112,8 +112,8 @@ static void spapr_irq_init_xics(SpaprMachineState *spapr, Error **errp) spapr->ics = ICS_SPAPR(obj); } -static int spapr_irq_claim_xics(SpaprMachineState *spapr, int irq, bool lsi, - Error **errp) +static void spapr_irq_claim_xics(SpaprMachineState *spapr, int irq, bool lsi, + Error **errp) { ICSState *ics = spapr->ics; @@ -122,11 +122,10 @@ static int spapr_irq_claim_xics(SpaprMachineState *spapr, int irq, bool lsi, if (!ics_irq_free(ics, irq - ics->offset)) { error_setg(errp, "IRQ %d is not free", irq); - return -1; + return; } ics_set_irq_type(ics, irq - ics->offset, lsi); - return 0; } static void spapr_irq_free_xics(SpaprMachineState *spapr, int irq) @@ -252,14 +251,12 @@ static void spapr_irq_init_xive(SpaprMachineState *spapr, Error **errp) spapr_xive_hcall_init(spapr); } -static int spapr_irq_claim_xive(SpaprMachineState *spapr, int irq, bool lsi, - Error **errp) +static void spapr_irq_claim_xive(SpaprMachineState *spapr, int irq, bool lsi, + Error **errp) { if (!spapr_xive_irq_claim(spapr->xive, irq, lsi)) { error_setg(errp, "IRQ %d is invalid", irq); - return -1; } - return 0; } static void spapr_irq_free_xive(SpaprMachineState *spapr, int irq) @@ -406,25 +403,22 @@ static void spapr_irq_init_dual(SpaprMachineState *spapr, Error **errp) } } -static int spapr_irq_claim_dual(SpaprMachineState *spapr, int irq, bool lsi, - Error **errp) +static void spapr_irq_claim_dual(SpaprMachineState *spapr, int irq, bool lsi, + Error **errp) { Error *local_err = NULL; - int ret; - ret = spapr_irq_xics.claim(spapr, irq, lsi, &local_err); + spapr_irq_xics.claim(spapr, irq, lsi, &local_err); if (local_err) { error_propagate(errp, local_err); - return ret; + return; } - ret = spapr_irq_xive.claim(spapr, irq, lsi, &local_err); + spapr_irq_xive.claim(spapr, irq, lsi, &local_err); if (local_err) { error_propagate(errp, local_err); - return ret; + return; } - - return ret; } static void spapr_irq_free_dual(SpaprMachineState *spapr, int irq) @@ -622,12 +616,12 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp) spapr->irq->nr_xirqs + SPAPR_XIRQ_BASE); } -int spapr_irq_claim(SpaprMachineState *spapr, int irq, bool lsi, Error **errp) +void spapr_irq_claim(SpaprMachineState *spapr, int irq, bool lsi, Error **errp) { assert(irq >= SPAPR_XIRQ_BASE); assert(irq < (spapr->irq->nr_xirqs + SPAPR_XIRQ_BASE)); - return spapr->irq->claim(spapr, irq, lsi, errp); + spapr->irq->claim(spapr, irq, lsi, errp); } void spapr_irq_free(SpaprMachineState *spapr, int irq, int num) diff --git a/include/hw/ppc/spapr_irq.h b/include/hw/ppc/spapr_irq.h index ed88b4599a..75279ca137 100644 --- a/include/hw/ppc/spapr_irq.h +++ b/include/hw/ppc/spapr_irq.h @@ -42,7 +42,7 @@ typedef struct SpaprIrq { uint8_t ov5; void (*init)(SpaprMachineState *spapr, Error **errp); - int (*claim)(SpaprMachineState *spapr, int irq, bool lsi, Error **errp); + void (*claim)(SpaprMachineState *spapr, int irq, bool lsi, Error **errp); void (*free)(SpaprMachineState *spapr, int irq); void (*print_info)(SpaprMachineState *spapr, Monitor *mon); void (*dt_populate)(SpaprMachineState *spapr, uint32_t nr_servers, @@ -61,7 +61,7 @@ extern SpaprIrq spapr_irq_xive; extern SpaprIrq spapr_irq_dual; void spapr_irq_init(SpaprMachineState *spapr, Error **errp); -int spapr_irq_claim(SpaprMachineState *spapr, int irq, bool lsi, Error **errp); +void spapr_irq_claim(SpaprMachineState *spapr, int irq, bool lsi, Error **errp); void spapr_irq_free(SpaprMachineState *spapr, int irq, int num); qemu_irq spapr_qirq(SpaprMachineState *spapr, int irq); int spapr_irq_post_load(SpaprMachineState *spapr, int version_id); From patchwork Wed Sep 25 06:45:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 11160105 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DBCB8924 for ; Wed, 25 Sep 2019 07:09:01 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B243721D7C for ; Wed, 25 Sep 2019 07:09:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="LHhiu2zd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B243721D7C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:46214 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD1Q4-00042L-8u for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Sep 2019 03:09:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38791) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD13p-0008MM-5T for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:46:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iD13n-0003a2-0d for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:46:00 -0400 Received: from ozlabs.org ([203.11.71.1]:52219) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iD13l-0003W9-IY; Wed, 25 Sep 2019 02:45:58 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 46dT8r4v3rz9sRD; Wed, 25 Sep 2019 16:45:47 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1569393948; bh=fPztQJ36JetKFM7FCxASK/DiMVhab/pW1QqMbxaeosc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LHhiu2zdn91IEZkW2HI1fl+xRzms2VOxirCPKtbbYOIWXSlMexD+yjceFY5SgWQjS pfUBL9SOiThpYFLoOnfiFHyzzd1pAkgGKsLJYT+yXl7ETyg+oN94zRNFLtW9CmKxrs odrzcyBwUwmE6jfetTknNTz9hIavmVoGzHhtocdg= From: David Gibson To: qemu-ppc@nongnu.org, clg@kaod.org, qemu-devel@nongnu.org Subject: [PATCH 18/20] xive: Improve irq claim/free path Date: Wed, 25 Sep 2019 16:45:32 +1000 Message-Id: <20190925064534.19155-19-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190925064534.19155-1-david@gibson.dropbear.id.au> References: <20190925064534.19155-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Riku Voipio , groug@kaod.org, Laurent Vivier , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , philmd@redhat.com, David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" spapr_xive_irq_claim() returns a bool to indicate if it succeeded. But most of the callers and one callee use a richer Error * instead. So use that instead of a bool return so we can actually pass more informative errors up the stack. In addition it didn't actually check if the irq was already claimed, which is one of the primary purposes of the claim path, so do that. spapr_xive_irq_free() also returned a bool... which no callers checked, so just drop it. Signed-off-by: David Gibson Reviewed-by: Cédric Le Goater --- hw/intc/spapr_xive.c | 17 ++++++++++------- hw/ppc/spapr_irq.c | 12 ++++++++---- include/hw/ppc/spapr_xive.h | 5 +++-- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c index 47b5ec0b56..5a56a58299 100644 --- a/hw/intc/spapr_xive.c +++ b/hw/intc/spapr_xive.c @@ -528,12 +528,18 @@ static void spapr_xive_register_types(void) type_init(spapr_xive_register_types) -bool spapr_xive_irq_claim(SpaprXive *xive, uint32_t lisn, bool lsi) +void spapr_xive_irq_claim(SpaprXive *xive, uint32_t lisn, bool lsi, + Error **errp) { XiveSource *xsrc = &xive->source; assert(lisn < xive->nr_irqs); + if (be64_to_cpu(xive->eat[lisn].w) & EAS_VALID) { + error_setg(errp, "IRQ %d is not free", lisn); + return; + } + /* * Set default values when allocating an IRQ number */ @@ -547,20 +553,17 @@ bool spapr_xive_irq_claim(SpaprXive *xive, uint32_t lisn, bool lsi) kvmppc_xive_source_reset_one(xsrc, lisn, &local_err); if (local_err) { - error_report_err(local_err); - return false; + error_propagate(errp, local_err); + return; } } - - return true; } -bool spapr_xive_irq_free(SpaprXive *xive, uint32_t lisn) +void spapr_xive_irq_free(SpaprXive *xive, uint32_t lisn) { assert(lisn < xive->nr_irqs); xive->eat[lisn].w &= cpu_to_be64(~EAS_VALID); - return true; } /* diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c index 2673a90604..f53544e45e 100644 --- a/hw/ppc/spapr_irq.c +++ b/hw/ppc/spapr_irq.c @@ -245,7 +245,13 @@ static void spapr_irq_init_xive(SpaprMachineState *spapr, Error **errp) /* Enable the CPU IPIs */ for (i = 0; i < nr_servers; ++i) { - spapr_xive_irq_claim(spapr->xive, SPAPR_IRQ_IPI + i, false); + Error *local_err = NULL; + + spapr_xive_irq_claim(spapr->xive, SPAPR_IRQ_IPI + i, false, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } } spapr_xive_hcall_init(spapr); @@ -254,9 +260,7 @@ static void spapr_irq_init_xive(SpaprMachineState *spapr, Error **errp) static void spapr_irq_claim_xive(SpaprMachineState *spapr, int irq, bool lsi, Error **errp) { - if (!spapr_xive_irq_claim(spapr->xive, irq, lsi)) { - error_setg(errp, "IRQ %d is invalid", irq); - } + spapr_xive_irq_claim(spapr->xive, irq, lsi, errp); } static void spapr_irq_free_xive(SpaprMachineState *spapr, int irq) diff --git a/include/hw/ppc/spapr_xive.h b/include/hw/ppc/spapr_xive.h index bfd40f01d8..69df3793e1 100644 --- a/include/hw/ppc/spapr_xive.h +++ b/include/hw/ppc/spapr_xive.h @@ -54,8 +54,9 @@ typedef struct SpaprXive { */ #define SPAPR_XIVE_BLOCK_ID 0x0 -bool spapr_xive_irq_claim(SpaprXive *xive, uint32_t lisn, bool lsi); -bool spapr_xive_irq_free(SpaprXive *xive, uint32_t lisn); +void spapr_xive_irq_claim(SpaprXive *xive, uint32_t lisn, bool lsi, + Error **errp); +void spapr_xive_irq_free(SpaprXive *xive, uint32_t lisn); void spapr_xive_pic_print_info(SpaprXive *xive, Monitor *mon); int spapr_xive_post_load(SpaprXive *xive, int version_id); From patchwork Wed Sep 25 06:45:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 11160111 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4FF28924 for ; Wed, 25 Sep 2019 07:12:20 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2071921D7C for ; Wed, 25 Sep 2019 07:12:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="G9E7jtvB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2071921D7C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:46244 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD1TG-0006sq-Em for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Sep 2019 03:12:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38817) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD13p-0008Ms-G9 for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:46:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iD13n-0003aF-2Z for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:46:01 -0400 Received: from ozlabs.org ([203.11.71.1]:32993) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iD13l-0003WB-Dw; Wed, 25 Sep 2019 02:45:58 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 46dT8r3ctwz9sRK; Wed, 25 Sep 2019 16:45:47 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1569393948; bh=Q2xV3V7Xdo55a+ODeRg9Q6DzdYaaaLtzSpMX8J75ERk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G9E7jtvBPbTbojyTxWKc6KUYTqFiEUKKiZcSR9czTmEkvDkzGQRJa1LrThWDt+gX6 /dFCDmPa4QTM0+sQnenPzczAbC9kulRNkC8C6xH00lJnK8NBVe0EBhOmfJrLsPXns9 fpQKSPItV3WyDra4l1fTAJiqu22GR4B/w81Fob9I= From: David Gibson To: qemu-ppc@nongnu.org, clg@kaod.org, qemu-devel@nongnu.org Subject: [PATCH 19/20] spapr: Use less cryptic representation of which irq backends are supported Date: Wed, 25 Sep 2019 16:45:33 +1000 Message-Id: <20190925064534.19155-20-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190925064534.19155-1-david@gibson.dropbear.id.au> References: <20190925064534.19155-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Riku Voipio , groug@kaod.org, Laurent Vivier , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , philmd@redhat.com, David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" SpaprIrq::ov5 stores the value for a particular byte in PAPR option vector 5 which indicates whether XICS, XIVE or both interrupt controllers are available. As usual for PAPR, the encoding is kind of overly complicated and confusing (though to be fair there are some backwards compat things it has to handle). But to make our internal code clearer, have SpaprIrq encode more directly which backends are available as two booleans, and derive the OV5 value from that at the point we need it. Signed-off-by: David Gibson Reviewed-by: Cédric Le Goater Reviewed-by: Greg Kurz --- hw/ppc/spapr.c | 15 ++++++++++++--- hw/ppc/spapr_hcall.c | 6 +++--- hw/ppc/spapr_irq.c | 12 ++++++++---- include/hw/ppc/spapr_irq.h | 3 ++- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 3742a8cf06..795f6ab505 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1136,19 +1136,28 @@ static void spapr_dt_ov5_platform_support(SpaprMachineState *spapr, void *fdt, PowerPCCPU *first_ppc_cpu = POWERPC_CPU(first_cpu); char val[2 * 4] = { - 23, spapr->irq->ov5, /* Xive mode. */ + 23, 0x00, /* XICS / XIVE mode */ 24, 0x00, /* Hash/Radix, filled in below. */ 25, 0x00, /* Hash options: Segment Tables == no, GTSE == no. */ 26, 0x40, /* Radix options: GTSE == yes. */ }; + if (spapr->irq->xics && spapr->irq->xive) { + val[1] = SPAPR_OV5_XIVE_BOTH; + } else if (spapr->irq->xive) { + val[1] = SPAPR_OV5_XIVE_EXPLOIT; + } else { + assert(spapr->irq->xics); + val[1] = SPAPR_OV5_XIVE_LEGACY; + } + if (!ppc_check_compat(first_ppc_cpu, CPU_POWERPC_LOGICAL_3_00, 0, first_ppc_cpu->compat_pvr)) { /* * If we're in a pre POWER9 compat mode then the guest should * do hash and use the legacy interrupt mode */ - val[1] = 0x00; /* XICS */ + val[1] = SPAPR_OV5_XIVE_LEGACY; /* XICS */ val[3] = 0x00; /* Hash */ } else if (kvm_enabled()) { if (kvmppc_has_cap_mmu_radix() && kvmppc_has_cap_mmu_hash_v3()) { @@ -2837,7 +2846,7 @@ static void spapr_machine_init(MachineState *machine) spapr_ovec_set(spapr->ov5, OV5_DRMEM_V2); /* advertise XIVE on POWER9 machines */ - if (spapr->irq->ov5 & (SPAPR_OV5_XIVE_EXPLOIT | SPAPR_OV5_XIVE_BOTH)) { + if (spapr->irq->xive) { spapr_ovec_set(spapr->ov5, OV5_XIVE_EXPLOIT); } diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index 3d3a67149a..140f05c1c6 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -1784,13 +1784,13 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu, * terminate the boot. */ if (guest_xive) { - if (spapr->irq->ov5 == SPAPR_OV5_XIVE_LEGACY) { + if (!spapr->irq->xive) { error_report( "Guest requested unavailable interrupt mode (XIVE), try the ic-mode=xive or ic-mode=dual machine property"); exit(EXIT_FAILURE); } } else { - if (spapr->irq->ov5 == SPAPR_OV5_XIVE_EXPLOIT) { + if (!spapr->irq->xics) { error_report( "Guest requested unavailable interrupt mode (XICS), either don't set the ic-mode machine property or try ic-mode=xics or ic-mode=dual"); exit(EXIT_FAILURE); @@ -1804,7 +1804,7 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu, */ if (!spapr->cas_reboot) { spapr->cas_reboot = spapr_ovec_test(ov5_updates, OV5_XIVE_EXPLOIT) - && spapr->irq->ov5 & SPAPR_OV5_XIVE_BOTH; + && spapr->irq->xics && spapr->irq->xive; } spapr_ovec_cleanup(ov5_updates); diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c index f53544e45e..073f375ba2 100644 --- a/hw/ppc/spapr_irq.c +++ b/hw/ppc/spapr_irq.c @@ -209,7 +209,8 @@ static void spapr_irq_init_kvm_xics(SpaprMachineState *spapr, Error **errp) SpaprIrq spapr_irq_xics = { .nr_xirqs = SPAPR_NR_XIRQS, .nr_msis = SPAPR_NR_MSIS, - .ov5 = SPAPR_OV5_XIVE_LEGACY, + .xics = true, + .xive = false, .init = spapr_irq_init_xics, .claim = spapr_irq_claim_xics, @@ -357,7 +358,8 @@ static void spapr_irq_init_kvm_xive(SpaprMachineState *spapr, Error **errp) SpaprIrq spapr_irq_xive = { .nr_xirqs = SPAPR_NR_XIRQS, .nr_msis = SPAPR_NR_MSIS, - .ov5 = SPAPR_OV5_XIVE_EXPLOIT, + .xics = false, + .xive = true, .init = spapr_irq_init_xive, .claim = spapr_irq_claim_xive, @@ -515,7 +517,8 @@ static void spapr_irq_set_irq_dual(void *opaque, int irq, int val) SpaprIrq spapr_irq_dual = { .nr_xirqs = SPAPR_NR_XIRQS, .nr_msis = SPAPR_NR_MSIS, - .ov5 = SPAPR_OV5_XIVE_BOTH, + .xics = true, + .xive = true, .init = spapr_irq_init_dual, .claim = spapr_irq_claim_dual, @@ -751,7 +754,8 @@ int spapr_irq_find(SpaprMachineState *spapr, int num, bool align, Error **errp) SpaprIrq spapr_irq_xics_legacy = { .nr_xirqs = SPAPR_IRQ_XICS_LEGACY_NR_XIRQS, .nr_msis = SPAPR_IRQ_XICS_LEGACY_NR_XIRQS, - .ov5 = SPAPR_OV5_XIVE_LEGACY, + .xics = true, + .xive = false, .init = spapr_irq_init_xics, .claim = spapr_irq_claim_xics, diff --git a/include/hw/ppc/spapr_irq.h b/include/hw/ppc/spapr_irq.h index 75279ca137..6816cb0500 100644 --- a/include/hw/ppc/spapr_irq.h +++ b/include/hw/ppc/spapr_irq.h @@ -39,7 +39,8 @@ void spapr_irq_msi_free(SpaprMachineState *spapr, int irq, uint32_t num); typedef struct SpaprIrq { uint32_t nr_xirqs; uint32_t nr_msis; - uint8_t ov5; + bool xics; + bool xive; void (*init)(SpaprMachineState *spapr, Error **errp); void (*claim)(SpaprMachineState *spapr, int irq, bool lsi, Error **errp); From patchwork Wed Sep 25 06:45:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 11160093 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6DFE91747 for ; Wed, 25 Sep 2019 07:04:32 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 442FC21D7C for ; Wed, 25 Sep 2019 07:04:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="T/I/5CtU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 442FC21D7C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:46132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD1Lh-0008Mi-SS for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Sep 2019 03:04:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38762) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iD13o-0008LZ-Ej for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:46:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iD13m-0003Yj-6e for qemu-devel@nongnu.org; Wed, 25 Sep 2019 02:46:00 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:34569) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iD13l-0003W5-GH; Wed, 25 Sep 2019 02:45:58 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 46dT8r29Pyz9sQw; Wed, 25 Sep 2019 16:45:47 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1569393948; bh=+CQCDXYh8ri/SJjKmt1CqAi9JDyF8I0zA1FgbTJMQ/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T/I/5CtUdsGk73Oy42eAVcv13BCFSR8iJpHTRJU767lwmPov+6pHFI1vQaDAGxh43 vZoqm2tPKavEYmntKpFxrFuna5ZBeIWkaeGLxrAZkmDeq2H0YmZAH+RJgUOobOUQiW LtFimhOH6SbGKt0OqCDLMsj4G9L3JUxgK4UialLQ= From: David Gibson To: qemu-ppc@nongnu.org, clg@kaod.org, qemu-devel@nongnu.org Subject: [PATCH 20/20] spapr: Eliminate SpaprIrq::init hook Date: Wed, 25 Sep 2019 16:45:34 +1000 Message-Id: <20190925064534.19155-21-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190925064534.19155-1-david@gibson.dropbear.id.au> References: <20190925064534.19155-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Riku Voipio , groug@kaod.org, Laurent Vivier , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini , philmd@redhat.com, David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This method is used to set up the interrupt backends for the current configuration. However, this means some confusing redirection between the "dual" mode init and the init hooks for xics only and xive only modes. Since we now have simple flags indicating whether XICS and/or XIVE are supported, it's easier to just open code each initialization directly in spapr_irq_init(). This will also make some future cleanups simpler. Signed-off-by: David Gibson Reviewed-by: Cédric Le Goater Reviewed-by: Greg Kurz --- hw/ppc/spapr_irq.c | 138 ++++++++++++++++-------------------- include/hw/ppc/spapr_irq.h | 1 - include/hw/ppc/xics_spapr.h | 1 + 3 files changed, 63 insertions(+), 77 deletions(-) diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c index 073f375ba2..62647dd5a3 100644 --- a/hw/ppc/spapr_irq.c +++ b/hw/ppc/spapr_irq.c @@ -91,27 +91,6 @@ static void spapr_irq_init_kvm(SpaprMachineState *spapr, /* * XICS IRQ backend. */ - -static void spapr_irq_init_xics(SpaprMachineState *spapr, Error **errp) -{ - Object *obj; - Error *local_err = NULL; - - obj = object_new(TYPE_ICS_SPAPR); - object_property_add_child(OBJECT(spapr), "ics", obj, &error_abort); - object_property_add_const_link(obj, ICS_PROP_XICS, OBJECT(spapr), - &error_fatal); - object_property_set_int(obj, spapr->irq->nr_xirqs, - "nr-irqs", &error_fatal); - object_property_set_bool(obj, true, "realized", &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } - - spapr->ics = ICS_SPAPR(obj); -} - static void spapr_irq_claim_xics(SpaprMachineState *spapr, int irq, bool lsi, Error **errp) { @@ -212,7 +191,6 @@ SpaprIrq spapr_irq_xics = { .xics = true, .xive = false, - .init = spapr_irq_init_xics, .claim = spapr_irq_claim_xics, .free = spapr_irq_free_xics, .print_info = spapr_irq_print_info_xics, @@ -227,37 +205,6 @@ SpaprIrq spapr_irq_xics = { /* * XIVE IRQ backend. */ -static void spapr_irq_init_xive(SpaprMachineState *spapr, Error **errp) -{ - uint32_t nr_servers = spapr_max_server_number(spapr); - DeviceState *dev; - int i; - - dev = qdev_create(NULL, TYPE_SPAPR_XIVE); - qdev_prop_set_uint32(dev, "nr-irqs", - spapr->irq->nr_xirqs + SPAPR_XIRQ_BASE); - /* - * 8 XIVE END structures per CPU. One for each available priority - */ - qdev_prop_set_uint32(dev, "nr-ends", nr_servers << 3); - qdev_init_nofail(dev); - - spapr->xive = SPAPR_XIVE(dev); - - /* Enable the CPU IPIs */ - for (i = 0; i < nr_servers; ++i) { - Error *local_err = NULL; - - spapr_xive_irq_claim(spapr->xive, SPAPR_IRQ_IPI + i, false, &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } - } - - spapr_xive_hcall_init(spapr); -} - static void spapr_irq_claim_xive(SpaprMachineState *spapr, int irq, bool lsi, Error **errp) { @@ -361,7 +308,6 @@ SpaprIrq spapr_irq_xive = { .xics = false, .xive = true, - .init = spapr_irq_init_xive, .claim = spapr_irq_claim_xive, .free = spapr_irq_free_xive, .print_info = spapr_irq_print_info_xive, @@ -392,23 +338,6 @@ static SpaprIrq *spapr_irq_current(SpaprMachineState *spapr) &spapr_irq_xive : &spapr_irq_xics; } -static void spapr_irq_init_dual(SpaprMachineState *spapr, Error **errp) -{ - Error *local_err = NULL; - - spapr_irq_xics.init(spapr, &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } - - spapr_irq_xive.init(spapr, &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } -} - static void spapr_irq_claim_dual(SpaprMachineState *spapr, int irq, bool lsi, Error **errp) { @@ -520,7 +449,6 @@ SpaprIrq spapr_irq_dual = { .xics = true, .xive = true, - .init = spapr_irq_init_dual, .claim = spapr_irq_claim_dual, .free = spapr_irq_free_dual, .print_info = spapr_irq_print_info_dual, @@ -608,8 +536,7 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp) spapr_irq_check(spapr, &local_err); if (local_err) { - error_propagate(errp, local_err); - return; + goto out; } /* Initialize the MSI IRQ allocator. */ @@ -617,10 +544,70 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp) spapr_irq_msi_init(spapr, spapr->irq->nr_msis); } - spapr->irq->init(spapr, errp); + if (spapr->irq->xics) { + Object *obj; + + obj = object_new(TYPE_ICS_SPAPR); + object_property_add_child(OBJECT(spapr), "ics", obj, &local_err); + if (local_err) { + goto out; + } + + object_property_add_const_link(obj, ICS_PROP_XICS, OBJECT(spapr), + &local_err); + if (local_err) { + goto out; + } + + object_property_set_int(obj, spapr->irq->nr_xirqs, "nr-irqs", + &local_err); + if (local_err) { + goto out; + } + + object_property_set_bool(obj, true, "realized", &local_err); + if (local_err) { + goto out; + } + + spapr->ics = ICS_SPAPR(obj); + } + + if (spapr->irq->xive) { + uint32_t nr_servers = spapr_max_server_number(spapr); + DeviceState *dev; + int i; + + dev = qdev_create(NULL, TYPE_SPAPR_XIVE); + qdev_prop_set_uint32(dev, "nr-irqs", + spapr->irq->nr_xirqs + SPAPR_XIRQ_BASE); + /* + * 8 XIVE END structures per CPU. One for each available + * priority + */ + qdev_prop_set_uint32(dev, "nr-ends", nr_servers << 3); + qdev_init_nofail(dev); + + spapr->xive = SPAPR_XIVE(dev); + + /* Enable the CPU IPIs */ + for (i = 0; i < nr_servers; ++i) { + Error *local_err = NULL; + + spapr_xive_irq_claim(spapr->xive, SPAPR_IRQ_IPI + i, false, &local_err); + if (local_err) { + goto out; + } + } + + spapr_xive_hcall_init(spapr); + } spapr->qirqs = qemu_allocate_irqs(spapr->irq->set_irq, spapr, spapr->irq->nr_xirqs + SPAPR_XIRQ_BASE); + +out: + error_propagate(errp, local_err); } void spapr_irq_claim(SpaprMachineState *spapr, int irq, bool lsi, Error **errp) @@ -757,7 +744,6 @@ SpaprIrq spapr_irq_xics_legacy = { .xics = true, .xive = false, - .init = spapr_irq_init_xics, .claim = spapr_irq_claim_xics, .free = spapr_irq_free_xics, .print_info = spapr_irq_print_info_xics, diff --git a/include/hw/ppc/spapr_irq.h b/include/hw/ppc/spapr_irq.h index 6816cb0500..fa862c665b 100644 --- a/include/hw/ppc/spapr_irq.h +++ b/include/hw/ppc/spapr_irq.h @@ -42,7 +42,6 @@ typedef struct SpaprIrq { bool xics; bool xive; - void (*init)(SpaprMachineState *spapr, Error **errp); void (*claim)(SpaprMachineState *spapr, int irq, bool lsi, Error **errp); void (*free)(SpaprMachineState *spapr, int irq); void (*print_info)(SpaprMachineState *spapr, Monitor *mon); diff --git a/include/hw/ppc/xics_spapr.h b/include/hw/ppc/xics_spapr.h index 691a6d00f7..267984a97b 100644 --- a/include/hw/ppc/xics_spapr.h +++ b/include/hw/ppc/xics_spapr.h @@ -34,6 +34,7 @@ #define TYPE_ICS_SPAPR "ics-spapr" #define ICS_SPAPR(obj) OBJECT_CHECK(ICSState, (obj), TYPE_ICS_SPAPR) +void ics_spapr_create(SpaprMachineState *spapr, int nr_xirqs, Error **errp); void spapr_dt_xics(SpaprMachineState *spapr, uint32_t nr_servers, void *fdt, uint32_t phandle); int xics_kvm_connect(SpaprMachineState *spapr, Error **errp);