From nobody Wed May 8 08:41:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1510327530739865.2260836050349; Fri, 10 Nov 2017 07:25:30 -0800 (PST) Received: from localhost ([::1]:42234 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDBBF-0002ay-Sg for importer@patchew.org; Fri, 10 Nov 2017 10:25:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47463) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDB6o-0007Rk-1X for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:20:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eDB6j-00057R-Ut for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:20:42 -0500 Received: from 7.mo68.mail-out.ovh.net ([46.105.63.230]:57917) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eDB6j-00055i-Pa for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:20:37 -0500 Received: from player737.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id 791879C349 for ; Fri, 10 Nov 2017 16:20:36 +0100 (CET) Received: from zorba.kaod.org.com (deibp9eh1--blueice1n7.emea.ibm.com [195.212.29.161]) (Authenticated sender: clg@kaod.org) by player737.ha.ovh.net (Postfix) with ESMTPSA id 03C86E00A4; Fri, 10 Nov 2017 16:20:28 +0100 (CET) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson , Greg Kurz , Benjamin Herrenschmidt Date: Fri, 10 Nov 2017 15:20:07 +0000 Message-Id: <20171110152017.24324-2-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171110152017.24324-1-clg@kaod.org> References: <20171110152017.24324-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 14106399933422799699 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddrieefgdejgecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.63.230 Subject: [Qemu-devel] [PATCH for-2.12 v3 01/11] spapr: add pseries 2.12 machine type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Greg Kurz --- hw/ppc/spapr.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index d682f013d422..a2dcbee07214 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3687,6 +3687,20 @@ static const TypeInfo spapr_machine_info =3D { type_init(spapr_machine_register_##suffix) =20 /* + * pseries-2.12 + */ +static void spapr_machine_2_12_instance_options(MachineState *machine) +{ +} + +static void spapr_machine_2_12_class_options(MachineClass *mc) +{ + /* Defaults for the latest behaviour inherited from the base class */ +} + +DEFINE_SPAPR_MACHINE(2_12, "2.12", true); + +/* * pseries-2.11 */ static void spapr_machine_2_11_instance_options(MachineState *machine) @@ -3698,7 +3712,7 @@ static void spapr_machine_2_11_class_options(MachineC= lass *mc) /* Defaults for the latest behaviour inherited from the base class */ } =20 -DEFINE_SPAPR_MACHINE(2_11, "2.11", true); +DEFINE_SPAPR_MACHINE(2_11, "2.11", false); =20 /* * pseries-2.10 --=20 2.13.6 From nobody Wed May 8 08:41:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1510327362773712.2056730022368; Fri, 10 Nov 2017 07:22:42 -0800 (PST) Received: from localhost ([::1]:42218 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDB8d-0000CQ-Pv for importer@patchew.org; Fri, 10 Nov 2017 10:22:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47524) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDB6v-0007WZ-LP for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:20:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eDB6r-0005K7-In for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:20:49 -0500 Received: from 1.mo68.mail-out.ovh.net ([46.105.41.146]:36909) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eDB6r-0005HJ-D0 for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:20:45 -0500 Received: from player737.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id 18A289A3D6 for ; Fri, 10 Nov 2017 16:20:44 +0100 (CET) Received: from zorba.kaod.org.com (deibp9eh1--blueice1n7.emea.ibm.com [195.212.29.161]) (Authenticated sender: clg@kaod.org) by player737.ha.ovh.net (Postfix) with ESMTPSA id B1C26E008C; Fri, 10 Nov 2017 16:20:36 +0100 (CET) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson , Greg Kurz , Benjamin Herrenschmidt Date: Fri, 10 Nov 2017 15:20:08 +0000 Message-Id: <20171110152017.24324-3-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171110152017.24324-1-clg@kaod.org> References: <20171110152017.24324-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 14108651733340687187 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddrieefgdejgecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.41.146 Subject: [Qemu-devel] [PATCH for-2.12 v3 02/11] ppc/xics: remove useless if condition X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The previous code section uses a 'first < 0' test and returns. Therefore, there is no need to test the 'first' variable against '>=3D 0' afterwards. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Greg Kurz --- hw/intc/xics_spapr.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c index d98ea8b13068..e8c0a1b3e903 100644 --- a/hw/intc/xics_spapr.c +++ b/hw/intc/xics_spapr.c @@ -329,10 +329,8 @@ int spapr_ics_alloc_block(ICSState *ics, int num, bool= lsi, return -1; } =20 - if (first >=3D 0) { - for (i =3D first; i < first + num; ++i) { - ics_set_irq_type(ics, i, lsi); - } + for (i =3D first; i < first + num; ++i) { + ics_set_irq_type(ics, i, lsi); } first +=3D ics->offset; =20 --=20 2.13.6 From nobody Wed May 8 08:41:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1510327546612421.04902573748257; Fri, 10 Nov 2017 07:25:46 -0800 (PST) Received: from localhost ([::1]:42239 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDBBT-0002pf-Ni for importer@patchew.org; Fri, 10 Nov 2017 10:25:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47612) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDB72-0007cp-S1 for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:20:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eDB6y-0005de-Pi for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:20:56 -0500 Received: from 4.mo68.mail-out.ovh.net ([46.105.59.63]:51355) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eDB6y-0005aq-Iu for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:20:52 -0500 Received: from player737.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id 8F1C59C179 for ; Fri, 10 Nov 2017 16:20:51 +0100 (CET) Received: from zorba.kaod.org.com (deibp9eh1--blueice1n7.emea.ibm.com [195.212.29.161]) (Authenticated sender: clg@kaod.org) by player737.ha.ovh.net (Postfix) with ESMTPSA id 50966E00A1; Fri, 10 Nov 2017 16:20:44 +0100 (CET) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson , Greg Kurz , Benjamin Herrenschmidt Date: Fri, 10 Nov 2017 15:20:09 +0000 Message-Id: <20171110152017.24324-4-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171110152017.24324-1-clg@kaod.org> References: <20171110152017.24324-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 14110622059604249427 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddrieefgdejgecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.59.63 Subject: [Qemu-devel] [PATCH for-2.12 v3 03/11] spapr: introduce new XICSFabric operations for an IRQ allocator X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Currently, the ICSState 'ics' object of the sPAPR machine acts as the global interrupt source handler and also as the IRQ number allocator for the machine. Some IRQ numbers are allocated very early in the machine initialization sequence to populate the device tree, and this is a problem to introduce the new POWER XIVE interrupt model, as it needs to share the IRQ numbers with the older model. To prepare ground for XIVE, here is a set of new XICSFabric operations to let the machine handle directly the IRQ number allocation and to decorrelate the allocation from the interrupt source object : bool (*irq_test)(XICSFabric *xi, int irq); int (*irq_alloc_block)(XICSFabric *xi, int count, int align); void (*irq_free_block)(XICSFabric *xi, int irq, int num); In these prototypes, the 'irq' parameter refers to a number in the global IRQ number space. Indexes for arrays storing different state informations on the interrupts, like the ICSIRQState, are usually named 'srcno'. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Greg Kurz --- hw/ppc/spapr.c | 19 +++++++++++++++++++ include/hw/ppc/xics.h | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index a2dcbee07214..84d68f2fdbae 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3536,6 +3536,21 @@ static ICPState *spapr_icp_get(XICSFabric *xi, int v= cpu_id) return cpu ? ICP(cpu->intc) : NULL; } =20 +static bool spapr_irq_test(XICSFabric *xi, int irq) +{ + return false; +} + +static int spapr_irq_alloc_block(XICSFabric *xi, int count, int align) +{ + return -1; +} + +static void spapr_irq_free_block(XICSFabric *xi, int irq, int num) +{ + ; +} + static void spapr_pic_print_info(InterruptStatsProvider *obj, Monitor *mon) { @@ -3630,6 +3645,10 @@ static void spapr_machine_class_init(ObjectClass *oc= , void *data) xic->ics_get =3D spapr_ics_get; xic->ics_resend =3D spapr_ics_resend; xic->icp_get =3D spapr_icp_get; + xic->irq_test =3D spapr_irq_test; + xic->irq_alloc_block =3D spapr_irq_alloc_block; + xic->irq_free_block =3D spapr_irq_free_block; + ispc->print_info =3D spapr_pic_print_info; /* Force NUMA node memory size to be a multiple of * SPAPR_MEMORY_BLOCK_SIZE (256M) since that's the granularity diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index 28d248abad61..30e7f2e0a7dd 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -175,6 +175,10 @@ typedef struct XICSFabricClass { ICSState *(*ics_get)(XICSFabric *xi, int irq); void (*ics_resend)(XICSFabric *xi); ICPState *(*icp_get)(XICSFabric *xi, int server); + /* IRQ allocator helpers */ + bool (*irq_test)(XICSFabric *xi, int irq); + int (*irq_alloc_block)(XICSFabric *xi, int count, int align); + void (*irq_free_block)(XICSFabric *xi, int irq, int num); } XICSFabricClass; =20 #define XICS_IRQS_SPAPR 1024 --=20 2.13.6 From nobody Wed May 8 08:41:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1510327685330831.6634728577034; Fri, 10 Nov 2017 07:28:05 -0800 (PST) Received: from localhost ([::1]:42252 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDBDm-0004wp-BZ for importer@patchew.org; Fri, 10 Nov 2017 10:27:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47669) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDB78-0007gh-4C for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:21:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eDB76-0005rj-FF for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:21:02 -0500 Received: from 9.mo68.mail-out.ovh.net ([46.105.78.111]:59345) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eDB76-0005p6-5q for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:21:00 -0500 Received: from player737.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id 1DF379C36A for ; Fri, 10 Nov 2017 16:20:59 +0100 (CET) Received: from zorba.kaod.org.com (deibp9eh1--blueice1n7.emea.ibm.com [195.212.29.161]) (Authenticated sender: clg@kaod.org) by player737.ha.ovh.net (Postfix) with ESMTPSA id C6910E008E; Fri, 10 Nov 2017 16:20:51 +0100 (CET) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson , Greg Kurz , Benjamin Herrenschmidt Date: Fri, 10 Nov 2017 15:20:10 +0000 Message-Id: <20171110152017.24324-5-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171110152017.24324-1-clg@kaod.org> References: <20171110152017.24324-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 14112873860922575699 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddrieefgdejgecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.78.111 Subject: [Qemu-devel] [PATCH for-2.12 v3 04/11] spapr: move current IRQ allocation under the machine X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Use the new XICSFabric operations to handle the IRQ number allocation directly under the machine. These changes only move code and adapt it to take into account the new API which uses IRQ numbers. On PowerNV, only provide a basic irq_test() operation. For the moment, there is no need for more. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Greg Kurz --- hw/intc/trace-events | 2 -- hw/intc/xics.c | 3 ++- hw/intc/xics_spapr.c | 57 +++++++++---------------------------------------= ---- hw/ppc/pnv.c | 18 +++++++++++++++++ hw/ppc/spapr.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++= --- hw/ppc/trace-events | 2 ++ 6 files changed, 85 insertions(+), 53 deletions(-) diff --git a/hw/intc/trace-events b/hw/intc/trace-events index b86f242b0fcf..e34ecf7a16e5 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -65,8 +65,6 @@ 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_alloc(int irq) "irq %d" xics_alloc_block(int first, int num, bool lsi, int align) "first irq %d, %= d irqs, lsi=3D%d, alignnum %d" -xics_ics_free(int src, int irq, int num) "Source#%d, first irq %d, %d irqs" -xics_ics_free_warn(int src, int irq) "Source#%d, irq %d is already free" =20 # hw/intc/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 cc9816e7f204..2c4899f278e2 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -53,6 +53,7 @@ void icp_pic_print_info(ICPState *icp, Monitor *mon) void ics_pic_print_info(ICSState *ics, Monitor *mon) { uint32_t i; + XICSFabricClass *xic =3D XICS_FABRIC_GET_CLASS(ics->xics); =20 monitor_printf(mon, "ICS %4x..%4x %p\n", ics->offset, ics->offset + ics->nr_irqs - 1, ics); @@ -64,7 +65,7 @@ void ics_pic_print_info(ICSState *ics, Monitor *mon) for (i =3D 0; i < ics->nr_irqs; i++) { ICSIRQState *irq =3D ics->irqs + i; =20 - if (!(irq->flags & XICS_FLAGS_IRQ_MASK)) { + if (!xic->irq_test(ics->xics, i + ics->offset)) { continue; } monitor_printf(mon, " %4x %s %02x %02x\n", diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c index e8c0a1b3e903..de9e65d35247 100644 --- a/hw/intc/xics_spapr.c +++ b/hw/intc/xics_spapr.c @@ -245,50 +245,26 @@ void xics_spapr_init(sPAPRMachineState *spapr) spapr_register_hypercall(H_IPOLL, h_ipoll); } =20 -#define ICS_IRQ_FREE(ics, srcno) \ - (!((ics)->irqs[(srcno)].flags & (XICS_FLAGS_IRQ_MASK))) - -static int ics_find_free_block(ICSState *ics, int num, int alignnum) -{ - int first, i; - - for (first =3D 0; first < ics->nr_irqs; first +=3D alignnum) { - if (num > (ics->nr_irqs - first)) { - return -1; - } - for (i =3D first; i < first + num; ++i) { - if (!ICS_IRQ_FREE(ics, i)) { - break; - } - } - if (i =3D=3D (first + num)) { - return first; - } - } - - return -1; -} - int spapr_ics_alloc(ICSState *ics, int irq_hint, bool lsi, Error **errp) { int irq; + XICSFabricClass *xic =3D XICS_FABRIC_GET_CLASS(ics->xics); =20 if (!ics) { return -1; } if (irq_hint) { - if (!ICS_IRQ_FREE(ics, irq_hint - ics->offset)) { + if (xic->irq_test(ics->xics, irq_hint)) { error_setg(errp, "can't allocate IRQ %d: already in use", irq_= hint); return -1; } irq =3D irq_hint; } else { - irq =3D ics_find_free_block(ics, 1, 1); + irq =3D xic->irq_alloc_block(ics->xics, 1, 1); if (irq < 0) { error_setg(errp, "can't allocate IRQ: no IRQ left"); return -1; } - irq +=3D ics->offset; } =20 ics_set_irq_type(ics, irq - ics->offset, lsi); @@ -305,6 +281,7 @@ int spapr_ics_alloc_block(ICSState *ics, int num, bool = lsi, bool align, Error **errp) { int i, first =3D -1; + XICSFabricClass *xic =3D XICS_FABRIC_GET_CLASS(ics->xics); =20 if (!ics) { return -1; @@ -320,9 +297,9 @@ int spapr_ics_alloc_block(ICSState *ics, int num, bool = lsi, if (align) { assert((num =3D=3D 1) || (num =3D=3D 2) || (num =3D=3D 4) || (num =3D=3D 8) || (num =3D=3D 16) || (num =3D=3D 32)); - first =3D ics_find_free_block(ics, num, num); + first =3D xic->irq_alloc_block(ics->xics, num, num); } else { - first =3D ics_find_free_block(ics, num, 1); + first =3D xic->irq_alloc_block(ics->xics, num, 1); } if (first < 0) { error_setg(errp, "can't find a free %d-IRQ block", num); @@ -330,33 +307,19 @@ int spapr_ics_alloc_block(ICSState *ics, int num, boo= l lsi, } =20 for (i =3D first; i < first + num; ++i) { - ics_set_irq_type(ics, i, lsi); + ics_set_irq_type(ics, i - ics->offset, lsi); } - first +=3D ics->offset; =20 trace_xics_alloc_block(first, num, lsi, align); =20 return first; } =20 -static void ics_free(ICSState *ics, int srcno, int num) -{ - int i; - - for (i =3D srcno; i < srcno + num; ++i) { - if (ICS_IRQ_FREE(ics, i)) { - trace_xics_ics_free_warn(0, i + ics->offset); - } - memset(&ics->irqs[i], 0, sizeof(ICSIRQState)); - } -} - void spapr_ics_free(ICSState *ics, int irq, int num) { - if (ics_valid_irq(ics, irq)) { - trace_xics_ics_free(0, irq, num); - ics_free(ics, irq - ics->offset, num); - } + XICSFabricClass *xic =3D XICS_FABRIC_GET_CLASS(ics->xics); + + xic->irq_free_block(ics->xics, irq, num); } =20 void spapr_dt_xics(int nr_servers, void *fdt, uint32_t phandle) diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index c35c439d816b..8288940ef9d7 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -1018,6 +1018,23 @@ static ICPState *pnv_icp_get(XICSFabric *xi, int pir) return cpu ? ICP(cpu->intc) : NULL; } =20 +static bool pnv_irq_test(XICSFabric *xi, int irq) +{ + PnvMachineState *pnv =3D POWERNV_MACHINE(xi); + int i; + + /* We don't have a IRQ allocator for the PowerNV machine yet, so + * just check that the IRQ number is valid for the PSI source + */ + for (i =3D 0; i < pnv->num_chips; i++) { + ICSState *ics =3D &pnv->chips[i]->psi.ics; + if (ics_valid_irq(ics, irq)) { + return true; + } + } + return false; +} + static void pnv_pic_print_info(InterruptStatsProvider *obj, Monitor *mon) { @@ -1102,6 +1119,7 @@ static void powernv_machine_class_init(ObjectClass *o= c, void *data) xic->icp_get =3D pnv_icp_get; xic->ics_get =3D pnv_ics_get; xic->ics_resend =3D pnv_ics_resend; + xic->irq_test =3D pnv_irq_test; ispc->print_info =3D pnv_pic_print_info; =20 powernv_machine_class_props_init(oc); diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 84d68f2fdbae..4bdceb45a14f 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3536,19 +3536,69 @@ static ICPState *spapr_icp_get(XICSFabric *xi, int = vcpu_id) return cpu ? ICP(cpu->intc) : NULL; } =20 +#define ICS_IRQ_FREE(ics, srcno) \ + (!((ics)->irqs[(srcno)].flags & (XICS_FLAGS_IRQ_MASK))) + +static int ics_find_free_block(ICSState *ics, int num, int alignnum) +{ + int first, i; + + for (first =3D 0; first < ics->nr_irqs; first +=3D alignnum) { + if (num > (ics->nr_irqs - first)) { + return -1; + } + for (i =3D first; i < first + num; ++i) { + if (!ICS_IRQ_FREE(ics, i)) { + break; + } + } + if (i =3D=3D (first + num)) { + return first; + } + } + + return -1; +} + static bool spapr_irq_test(XICSFabric *xi, int irq) { - return false; + sPAPRMachineState *spapr =3D SPAPR_MACHINE(xi); + ICSState *ics =3D spapr->ics; + int srcno =3D irq - ics->offset; + + return !ICS_IRQ_FREE(ics, srcno); } =20 static int spapr_irq_alloc_block(XICSFabric *xi, int count, int align) { - return -1; + sPAPRMachineState *spapr =3D SPAPR_MACHINE(xi); + ICSState *ics =3D spapr->ics; + int srcno; + + srcno =3D ics_find_free_block(ics, count, align); + if (srcno =3D=3D -1) { + return -1; + } + + return srcno + ics->offset; } =20 static void spapr_irq_free_block(XICSFabric *xi, int irq, int num) { - ; + sPAPRMachineState *spapr =3D SPAPR_MACHINE(xi); + ICSState *ics =3D spapr->ics; + int srcno =3D irq - ics->offset; + int i; + + if (ics_valid_irq(ics, irq)) { + trace_spapr_irq_free(0, irq, num); + for (i =3D srcno; i < srcno + num; ++i) { + if (ICS_IRQ_FREE(ics, i)) { + trace_spapr_irq_free_warn(0, i + ics->offset); + } + memset(&ics->irqs[i], 0, sizeof(ICSIRQState)); + } + } } =20 static void spapr_pic_print_info(InterruptStatsProvider *obj, diff --git a/hw/ppc/trace-events b/hw/ppc/trace-events index 4a6a6490fa78..dc9ab4c4deb3 100644 --- a/hw/ppc/trace-events +++ b/hw/ppc/trace-events @@ -12,6 +12,8 @@ spapr_pci_msi_retry(unsigned config_addr, unsigned req_nu= m, unsigned max_irqs) " # hw/ppc/spapr.c 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_free(int src, int irq, int num) "Source#%d, first irq %d, %d irq= s" +spapr_irq_free_warn(int src, int irq) "Source#%d, irq %d is already free" =20 # hw/ppc/spapr_hcall.c spapr_cas_pvr_try(uint32_t pvr) "0x%x" --=20 2.13.6 From nobody Wed May 8 08:41:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1510327589844253.459745893422; Fri, 10 Nov 2017 07:26:29 -0800 (PST) Received: from localhost ([::1]:42244 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDBCI-0003ZA-VR for importer@patchew.org; Fri, 10 Nov 2017 10:26:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47716) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDB7F-0007ms-El for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:21:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eDB7E-00064y-29 for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:21:09 -0500 Received: from 2.mo68.mail-out.ovh.net ([46.105.52.162]:33896) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eDB7D-00063O-PE for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:21:07 -0500 Received: from player737.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id 9849D9C36A for ; Fri, 10 Nov 2017 16:21:06 +0100 (CET) Received: from zorba.kaod.org.com (deibp9eh1--blueice1n7.emea.ibm.com [195.212.29.161]) (Authenticated sender: clg@kaod.org) by player737.ha.ovh.net (Postfix) with ESMTPSA id 5A332E0077; Fri, 10 Nov 2017 16:20:59 +0100 (CET) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson , Greg Kurz , Benjamin Herrenschmidt Date: Fri, 10 Nov 2017 15:20:11 +0000 Message-Id: <20171110152017.24324-6-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171110152017.24324-1-clg@kaod.org> References: <20171110152017.24324-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 14114844183152528211 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddrieefgdejgecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.52.162 Subject: [Qemu-devel] [PATCH for-2.12 v3 05/11] spapr: introduce an IRQ allocator using a bitmap X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Let's define a new set of XICSFabric IRQ operations for the latest pseries machine. These simply use a a bitmap 'irq_map' as a IRQ number allocator. The previous pseries machines keep the old set of IRQ operations using the ICSIRQState array. Signed-off-by: C=C3=A9dric Le Goater --- Changes since v2 : - introduced a second set of XICSFabric IRQ operations for older pseries machines hw/ppc/spapr.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++= ---- include/hw/ppc/spapr.h | 3 ++ 2 files changed, 74 insertions(+), 5 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 4bdceb45a14f..4ef0b73559ca 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1681,6 +1681,22 @@ static const VMStateDescription vmstate_spapr_patb_e= ntry =3D { }, }; =20 +static bool spapr_irq_map_needed(void *opaque) +{ + return true; +} + +static const VMStateDescription vmstate_spapr_irq_map =3D { + .name =3D "spapr_irq_map", + .version_id =3D 0, + .minimum_version_id =3D 0, + .needed =3D spapr_irq_map_needed, + .fields =3D (VMStateField[]) { + VMSTATE_BITMAP(irq_map, sPAPRMachineState, 0, nr_irqs), + VMSTATE_END_OF_LIST() + }, +}; + static const VMStateDescription vmstate_spapr =3D { .name =3D "spapr", .version_id =3D 3, @@ -1700,6 +1716,7 @@ static const VMStateDescription vmstate_spapr =3D { &vmstate_spapr_ov5_cas, &vmstate_spapr_patb_entry, &vmstate_spapr_pending_events, + &vmstate_spapr_irq_map, NULL } }; @@ -2337,8 +2354,12 @@ static void ppc_spapr_init(MachineState *machine) /* Setup a load limit for the ramdisk leaving room for SLOF and FDT */ load_limit =3D MIN(spapr->rma_size, RTAS_MAX_ADDR) - FW_OVERHEAD; =20 + /* Initialize the IRQ allocator */ + spapr->nr_irqs =3D XICS_IRQS_SPAPR; + spapr->irq_map =3D bitmap_new(spapr->nr_irqs); + /* Set up Interrupt Controller before we create the VCPUs */ - xics_system_init(machine, XICS_IRQS_SPAPR, &error_fatal); + xics_system_init(machine, spapr->nr_irqs, &error_fatal); =20 /* Set up containers for ibm,client-architecture-support negotiated op= tions */ @@ -3560,7 +3581,7 @@ static int ics_find_free_block(ICSState *ics, int num= , int alignnum) return -1; } =20 -static bool spapr_irq_test(XICSFabric *xi, int irq) +static bool spapr_irq_test_2_11(XICSFabric *xi, int irq) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(xi); ICSState *ics =3D spapr->ics; @@ -3569,7 +3590,7 @@ static bool spapr_irq_test(XICSFabric *xi, int irq) return !ICS_IRQ_FREE(ics, srcno); } =20 -static int spapr_irq_alloc_block(XICSFabric *xi, int count, int align) +static int spapr_irq_alloc_block_2_11(XICSFabric *xi, int count, int align) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(xi); ICSState *ics =3D spapr->ics; @@ -3583,7 +3604,7 @@ static int spapr_irq_alloc_block(XICSFabric *xi, int = count, int align) return srcno + ics->offset; } =20 -static void spapr_irq_free_block(XICSFabric *xi, int irq, int num) +static void spapr_irq_free_block_2_11(XICSFabric *xi, int irq, int num) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(xi); ICSState *ics =3D spapr->ics; @@ -3601,6 +3622,46 @@ static void spapr_irq_free_block(XICSFabric *xi, int= irq, int num) } } =20 +static bool spapr_irq_test(XICSFabric *xi, int irq) +{ + sPAPRMachineState *spapr =3D SPAPR_MACHINE(xi); + int srcno =3D irq - spapr->ics->offset; + + return test_bit(srcno, spapr->irq_map); +} + +static int spapr_irq_alloc_block(XICSFabric *xi, int count, int align) +{ + sPAPRMachineState *spapr =3D SPAPR_MACHINE(xi); + int start =3D 0; + int srcno; + + /* + * The 'align_mask' parameter of bitmap_find_next_zero_area() + * should be one less than a power of 2; 0 means no + * alignment. Adapt the 'align' value of the former allocator to + * fit the requirements of bitmap_find_next_zero_area() + */ + align -=3D 1; + + srcno =3D bitmap_find_next_zero_area(spapr->irq_map, spapr->nr_irqs, s= tart, + count, align); + if (srcno =3D=3D spapr->nr_irqs) { + return -1; + } + + bitmap_set(spapr->irq_map, srcno, count); + return srcno + spapr->ics->offset; +} + +static void spapr_irq_free_block(XICSFabric *xi, int irq, int num) +{ + sPAPRMachineState *spapr =3D SPAPR_MACHINE(xi); + int srcno =3D irq - spapr->ics->offset; + + bitmap_clear(spapr->irq_map, srcno, num); +} + static void spapr_pic_print_info(InterruptStatsProvider *obj, Monitor *mon) { @@ -3778,7 +3839,12 @@ static void spapr_machine_2_11_instance_options(Mach= ineState *machine) =20 static void spapr_machine_2_11_class_options(MachineClass *mc) { - /* Defaults for the latest behaviour inherited from the base class */ + XICSFabricClass *xic =3D XICS_FABRIC_CLASS(mc); + + spapr_machine_2_12_class_options(mc); + xic->irq_test =3D spapr_irq_test_2_11; + xic->irq_alloc_block =3D spapr_irq_alloc_block_2_11; + xic->irq_free_block =3D spapr_irq_free_block_2_11; } =20 DEFINE_SPAPR_MACHINE(2_11, "2.11", false); diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 9d21ca9bde3a..5835c694caff 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -7,6 +7,7 @@ #include "hw/ppc/spapr_drc.h" #include "hw/mem/pc-dimm.h" #include "hw/ppc/spapr_ovec.h" +#include "qemu/bitmap.h" =20 struct VIOsPAPRBus; struct sPAPRPHBState; @@ -78,6 +79,8 @@ struct sPAPRMachineState { struct VIOsPAPRBus *vio_bus; QLIST_HEAD(, sPAPRPHBState) phbs; struct sPAPRNVRAM *nvram; + int32_t nr_irqs; + unsigned long *irq_map; ICSState *ics; sPAPRRTCState rtc; =20 --=20 2.13.6 From nobody Wed May 8 08:41:12 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1510327832564888.2657681968224; Fri, 10 Nov 2017 07:30:32 -0800 (PST) Received: from localhost ([::1]:42260 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDBG3-0006o5-J9 for importer@patchew.org; Fri, 10 Nov 2017 10:30:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDB7M-0007sj-Fu for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:21:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eDB7L-0006Ka-HT for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:21:16 -0500 Received: from 1.mo68.mail-out.ovh.net ([46.105.41.146]:59851) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eDB7L-0006J3-AY for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:21:15 -0500 Received: from player737.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id 4D1659C282 for ; Fri, 10 Nov 2017 16:21:14 +0100 (CET) Received: from zorba.kaod.org.com (deibp9eh1--blueice1n7.emea.ibm.com [195.212.29.161]) (Authenticated sender: clg@kaod.org) by player737.ha.ovh.net (Postfix) with ESMTPSA id E1E33E009E; Fri, 10 Nov 2017 16:21:06 +0100 (CET) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson , Greg Kurz , Benjamin Herrenschmidt Date: Fri, 10 Nov 2017 15:20:12 +0000 Message-Id: <20171110152017.24324-7-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171110152017.24324-1-clg@kaod.org> References: <20171110152017.24324-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 14117095982310329171 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddrieefgdejgecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.41.146 Subject: [Qemu-devel] [PATCH for-2.12 v3 06/11] spapr: store a reference IRQ bitmap X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" To save some state when the guest is migrated, we capture the IRQ bitmap after all devices have been reseted and store it as a reference for the machine. Signed-off-by: C=C3=A9dric Le Goater --- We should probably merge this patch with the previous in the next versions of the patchset. For the moment, I thought it would be interesting to isolate the topic for discussion. hw/ppc/spapr.c | 7 ++++++- include/hw/ppc/spapr.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 4ef0b73559ca..bf0e5b4f815b 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1437,6 +1437,9 @@ static void ppc_spapr_reset(void) qemu_devices_reset(); spapr_clear_pending_events(spapr); =20 + spapr->irq_map_ref =3D bitmap_new(spapr->nr_irqs); + bitmap_copy(spapr->irq_map_ref, spapr->irq_map, spapr->nr_irqs); + /* * We place the device tree and RTAS just below either the top of the = RMA, * or just below 2GB, whichever is lowere, so that it can be @@ -1683,7 +1686,9 @@ static const VMStateDescription vmstate_spapr_patb_en= try =3D { =20 static bool spapr_irq_map_needed(void *opaque) { - return true; + sPAPRMachineState *spapr =3D opaque; + + return !bitmap_equal(spapr->irq_map, spapr->irq_map_ref, spapr->nr_irq= s); } =20 static const VMStateDescription vmstate_spapr_irq_map =3D { diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 5835c694caff..023436c32b2a 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -81,6 +81,7 @@ struct sPAPRMachineState { struct sPAPRNVRAM *nvram; int32_t nr_irqs; unsigned long *irq_map; + unsigned long *irq_map_ref; ICSState *ics; sPAPRRTCState rtc; =20 --=20 2.13.6 From nobody Wed May 8 08:41:13 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1510327405580478.3955294792871; Fri, 10 Nov 2017 07:23:25 -0800 (PST) Received: from localhost ([::1]:42221 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDB9K-0000u7-Sj for importer@patchew.org; Fri, 10 Nov 2017 10:23:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47804) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDB7X-00081D-6W for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:21:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eDB7T-0006ag-3c for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:21:27 -0500 Received: from 1.mo68.mail-out.ovh.net ([46.105.41.146]:59875) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eDB7S-0006ZQ-TI for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:21:23 -0500 Received: from player737.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id D59459C350 for ; Fri, 10 Nov 2017 16:21:21 +0100 (CET) Received: from zorba.kaod.org.com (deibp9eh1--blueice1n7.emea.ibm.com [195.212.29.161]) (Authenticated sender: clg@kaod.org) by player737.ha.ovh.net (Postfix) with ESMTPSA id 819C8E009C; Fri, 10 Nov 2017 16:21:14 +0100 (CET) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson , Greg Kurz , Benjamin Herrenschmidt Date: Fri, 10 Nov 2017 15:20:13 +0000 Message-Id: <20171110152017.24324-8-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171110152017.24324-1-clg@kaod.org> References: <20171110152017.24324-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 14119066309961157459 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddrieefgdejgecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.41.146 Subject: [Qemu-devel] [PATCH for-2.12 v3 07/11] spapr: introduce an 'irq_base' number X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 'irq_base' is a base IRQ number which lets us allocate only the subset of the IRQ numbers used on the sPAPR platform. It is sync with the ICSState 'offset' attribute and this is slightly redundant. We could also choose to waste some extra bytes (512) and allocate the whole number space. To be discussed. But more important, it removes a dependency on the ICSState object of the sPAPR machine which is required for XIVE. Signed-off-by: C=C3=A9dric Le Goater --- hw/ppc/spapr.c | 7 ++++--- include/hw/ppc/spapr.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index bf0e5b4f815b..1cbbd7715a85 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2362,6 +2362,7 @@ static void ppc_spapr_init(MachineState *machine) /* Initialize the IRQ allocator */ spapr->nr_irqs =3D XICS_IRQS_SPAPR; spapr->irq_map =3D bitmap_new(spapr->nr_irqs); + spapr->irq_base =3D XICS_IRQ_BASE; =20 /* Set up Interrupt Controller before we create the VCPUs */ xics_system_init(machine, spapr->nr_irqs, &error_fatal); @@ -3630,7 +3631,7 @@ static void spapr_irq_free_block_2_11(XICSFabric *xi,= int irq, int num) static bool spapr_irq_test(XICSFabric *xi, int irq) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(xi); - int srcno =3D irq - spapr->ics->offset; + int srcno =3D irq - spapr->irq_base; =20 return test_bit(srcno, spapr->irq_map); } @@ -3656,13 +3657,13 @@ static int spapr_irq_alloc_block(XICSFabric *xi, in= t count, int align) } =20 bitmap_set(spapr->irq_map, srcno, count); - return srcno + spapr->ics->offset; + return srcno + spapr->irq_base; } =20 static void spapr_irq_free_block(XICSFabric *xi, int irq, int num) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(xi); - int srcno =3D irq - spapr->ics->offset; + int srcno =3D irq - spapr->irq_base; =20 bitmap_clear(spapr->irq_map, srcno, num); } diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 023436c32b2a..200667dcff9d 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -82,6 +82,7 @@ struct sPAPRMachineState { int32_t nr_irqs; unsigned long *irq_map; unsigned long *irq_map_ref; + uint32_t irq_base; ICSState *ics; sPAPRRTCState rtc; =20 --=20 2.13.6 From nobody Wed May 8 08:41:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1510327667553826.3375026341723; Fri, 10 Nov 2017 07:27:47 -0800 (PST) Received: from localhost ([::1]:42251 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDBDa-0004ni-K5 for importer@patchew.org; Fri, 10 Nov 2017 10:27:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47840) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDB7f-00087X-7L for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:21:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eDB7b-0006sT-3O for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:21:35 -0500 Received: from 10.mo68.mail-out.ovh.net ([46.105.79.203]:41869) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eDB7a-0006p3-Qz for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:21:31 -0500 Received: from player737.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id 73EA09C33C for ; Fri, 10 Nov 2017 16:21:29 +0100 (CET) Received: from zorba.kaod.org.com (deibp9eh1--blueice1n7.emea.ibm.com [195.212.29.161]) (Authenticated sender: clg@kaod.org) by player737.ha.ovh.net (Postfix) with ESMTPSA id 1DF8FE008C; Fri, 10 Nov 2017 16:21:21 +0100 (CET) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson , Greg Kurz , Benjamin Herrenschmidt Date: Fri, 10 Nov 2017 15:20:14 +0000 Message-Id: <20171110152017.24324-9-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171110152017.24324-1-clg@kaod.org> References: <20171110152017.24324-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 14121318110194535251 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddrieefgdejgecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.79.203 Subject: [Qemu-devel] [PATCH for-2.12 v3 08/11] spapr: introduce a XICSFabric irq_is_lsi() operation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" It will be used later on to distinguish the allocation of an LSI interrupt from an MSI and also to reduce the use of the ICSIRQState array of the ICSState object, which is on our way to introduce XIVE. The 'irq' parameter continues to refer to the global IRQ number space. On PowerNV, only the PSI controller interrupts are handled and they are all LSIs. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Greg Kurz --- hw/intc/xics.c | 26 +++++++++++++++++--------- hw/intc/xics_kvm.c | 4 ++-- hw/ppc/pnv.c | 16 ++++++++++++++++ hw/ppc/spapr.c | 9 +++++++++ include/hw/ppc/xics.h | 2 ++ 5 files changed, 46 insertions(+), 11 deletions(-) diff --git a/hw/intc/xics.c b/hw/intc/xics.c index 2c4899f278e2..42880e736697 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -33,6 +33,7 @@ #include "trace.h" #include "qemu/timer.h" #include "hw/ppc/xics.h" +#include "hw/ppc/spapr.h" #include "qemu/error-report.h" #include "qapi/visitor.h" #include "monitor/monitor.h" @@ -70,8 +71,7 @@ void ics_pic_print_info(ICSState *ics, Monitor *mon) } monitor_printf(mon, " %4x %s %02x %02x\n", ics->offset + i, - (irq->flags & XICS_FLAGS_IRQ_LSI) ? - "LSI" : "MSI", + ics_is_lsi(ics, i) ? "LSI" : "MSI", irq->priority, irq->status); } } @@ -377,6 +377,14 @@ static const TypeInfo icp_info =3D { /* * ICS: Source layer */ +bool ics_is_lsi(ICSState *ics, int srcno) +{ + XICSFabric *xi =3D ics->xics; + XICSFabricClass *xic =3D XICS_FABRIC_GET_CLASS(xi); + + return xic->irq_is_lsi(xi, srcno + ics->offset); +} + static void ics_simple_resend_msi(ICSState *ics, int srcno) { ICSIRQState *irq =3D ics->irqs + srcno; @@ -435,7 +443,7 @@ static void ics_simple_set_irq(void *opaque, int srcno,= int val) { ICSState *ics =3D (ICSState *)opaque; =20 - if (ics->irqs[srcno].flags & XICS_FLAGS_IRQ_LSI) { + if (ics_is_lsi(ics, srcno)) { ics_simple_set_irq_lsi(ics, srcno, val); } else { ics_simple_set_irq_msi(ics, srcno, val); @@ -472,7 +480,7 @@ void ics_simple_write_xive(ICSState *ics, int srcno, in= t server, trace_xics_ics_simple_write_xive(ics->offset + srcno, srcno, server, priority); =20 - if (ics->irqs[srcno].flags & XICS_FLAGS_IRQ_LSI) { + if (ics_is_lsi(ics, srcno)) { ics_simple_write_xive_lsi(ics, srcno); } else { ics_simple_write_xive_msi(ics, srcno); @@ -484,10 +492,10 @@ static void ics_simple_reject(ICSState *ics, uint32_t= nr) ICSIRQState *irq =3D ics->irqs + nr - ics->offset; =20 trace_xics_ics_simple_reject(nr, nr - ics->offset); - if (irq->flags & XICS_FLAGS_IRQ_MSI) { - irq->status |=3D XICS_STATUS_REJECTED; - } else if (irq->flags & XICS_FLAGS_IRQ_LSI) { + if (ics_is_lsi(ics, nr - ics->offset)) { irq->status &=3D ~XICS_STATUS_SENT; + } else { + irq->status |=3D XICS_STATUS_REJECTED; } } =20 @@ -497,7 +505,7 @@ static void ics_simple_resend(ICSState *ics) =20 for (i =3D 0; i < ics->nr_irqs; i++) { /* FIXME: filter by server#? */ - if (ics->irqs[i].flags & XICS_FLAGS_IRQ_LSI) { + if (ics_is_lsi(ics, i)) { ics_simple_resend_lsi(ics, i); } else { ics_simple_resend_msi(ics, i); @@ -512,7 +520,7 @@ static void ics_simple_eoi(ICSState *ics, uint32_t nr) =20 trace_xics_ics_simple_eoi(nr); =20 - if (ics->irqs[srcno].flags & XICS_FLAGS_IRQ_LSI) { + if (ics_is_lsi(ics, srcno)) { irq->status &=3D ~XICS_STATUS_SENT; } } diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c index 3091ad3ac2c8..2f10637c9f7c 100644 --- a/hw/intc/xics_kvm.c +++ b/hw/intc/xics_kvm.c @@ -258,7 +258,7 @@ static int ics_set_kvm_state(ICSState *ics, int version= _id) state |=3D KVM_XICS_MASKED; } =20 - if (ics->irqs[i].flags & XICS_FLAGS_IRQ_LSI) { + if (ics_is_lsi(ics, i)) { state |=3D KVM_XICS_LEVEL_SENSITIVE; if (irq->status & XICS_STATUS_ASSERTED) { state |=3D KVM_XICS_PENDING; @@ -293,7 +293,7 @@ static void ics_kvm_set_irq(void *opaque, int srcno, in= t val) int rc; =20 args.irq =3D srcno + ics->offset; - if (ics->irqs[srcno].flags & XICS_FLAGS_IRQ_MSI) { + if (!ics_is_lsi(ics, srcno)) { if (!val) { return; } diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 8288940ef9d7..958223376b4c 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -1035,6 +1035,21 @@ static bool pnv_irq_test(XICSFabric *xi, int irq) return false; } =20 +static bool pnv_irq_is_lsi(XICSFabric *xi, int irq) +{ + PnvMachineState *pnv =3D POWERNV_MACHINE(xi); + int i; + + /* PowerNV machine only has PSI interrupts which are all LSIs */ + for (i =3D 0; i < pnv->num_chips; i++) { + ICSState *ics =3D &pnv->chips[i]->psi.ics; + if (ics_valid_irq(ics, irq)) { + return true; + } + } + return false; +} + static void pnv_pic_print_info(InterruptStatsProvider *obj, Monitor *mon) { @@ -1120,6 +1135,7 @@ static void powernv_machine_class_init(ObjectClass *o= c, void *data) xic->ics_get =3D pnv_ics_get; xic->ics_resend =3D pnv_ics_resend; xic->irq_test =3D pnv_irq_test; + xic->irq_is_lsi =3D pnv_irq_is_lsi; ispc->print_info =3D pnv_pic_print_info; =20 powernv_machine_class_props_init(oc); diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 1cbbd7715a85..ce314fcf38db 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3628,6 +3628,14 @@ static void spapr_irq_free_block_2_11(XICSFabric *xi= , int irq, int num) } } =20 +static bool spapr_irq_is_lsi(XICSFabric *xi, int irq) +{ + sPAPRMachineState *spapr =3D SPAPR_MACHINE(xi); + int srcno =3D irq - spapr->ics->offset; + + return spapr->ics->irqs[srcno].flags & XICS_FLAGS_IRQ_LSI; +} + static bool spapr_irq_test(XICSFabric *xi, int irq) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(xi); @@ -3765,6 +3773,7 @@ static void spapr_machine_class_init(ObjectClass *oc,= void *data) xic->irq_test =3D spapr_irq_test; xic->irq_alloc_block =3D spapr_irq_alloc_block; xic->irq_free_block =3D spapr_irq_free_block; + xic->irq_is_lsi =3D spapr_irq_is_lsi; =20 ispc->print_info =3D spapr_pic_print_info; /* Force NUMA node memory size to be a multiple of diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index 30e7f2e0a7dd..478f8e510179 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -179,6 +179,7 @@ typedef struct XICSFabricClass { bool (*irq_test)(XICSFabric *xi, int irq); int (*irq_alloc_block)(XICSFabric *xi, int count, int align); void (*irq_free_block)(XICSFabric *xi, int irq, int num); + bool (*irq_is_lsi)(XICSFabric *xi, int irq); } XICSFabricClass; =20 #define XICS_IRQS_SPAPR 1024 @@ -205,6 +206,7 @@ void ics_simple_write_xive(ICSState *ics, int nr, int s= erver, void ics_set_irq_type(ICSState *ics, int srcno, bool lsi); void icp_pic_print_info(ICPState *icp, Monitor *mon); void ics_pic_print_info(ICSState *ics, Monitor *mon); +bool ics_is_lsi(ICSState *ics, int srno); =20 void ics_resend(ICSState *ics); void icp_resend(ICPState *ss); --=20 2.13.6 From nobody Wed May 8 08:41:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1510327792671702.8771452053118; Fri, 10 Nov 2017 07:29:52 -0800 (PST) Received: from localhost ([::1]:42258 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDBFa-0006Qt-Qa for importer@patchew.org; Fri, 10 Nov 2017 10:29:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47913) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDB7m-0008GK-CQ for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:21:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eDB7i-00073p-9N for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:21:42 -0500 Received: from 4.mo68.mail-out.ovh.net ([46.105.59.63]:53669) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eDB7i-000724-0D for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:21:38 -0500 Received: from player737.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id C6D679C0CA for ; Fri, 10 Nov 2017 16:21:36 +0100 (CET) Received: from zorba.kaod.org.com (deibp9eh1--blueice1n7.emea.ibm.com [195.212.29.161]) (Authenticated sender: clg@kaod.org) by player737.ha.ovh.net (Postfix) with ESMTPSA id 9BA92E008C; Fri, 10 Nov 2017 16:21:29 +0100 (CET) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson , Greg Kurz , Benjamin Herrenschmidt Date: Fri, 10 Nov 2017 15:20:15 +0000 Message-Id: <20171110152017.24324-10-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171110152017.24324-1-clg@kaod.org> References: <20171110152017.24324-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 14123288431717288787 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddrieefgdejgecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.59.63 Subject: [Qemu-devel] [PATCH for-2.12 v3 09/11] spapr: split the IRQ number space for LSI interrupts X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The type of an interrupt, MSI or LSI, is stored under the flag attribute of the ICSIRQState array. To reduce the use of this array and consequently of the ICSState object (This is needed to introduce the new XIVE model), we choose to split the IRQ number space of the machine in two: first the LSIs and then the MSIs. This also has the benefit to keep the LSI IRQ numbers in a well known range which will be useful for PHB hotplug. This change only applies to the latest pseries machines. Older machines still use the ICSIRQState array to define the IRQ type. Signed-off-by: C=C3=A9dric Le Goater --- Changes since v2 : - introduced a second set of XICSFabric IRQ operations for older pseries machines hw/intc/xics_spapr.c | 6 +++--- hw/ppc/spapr.c | 33 +++++++++++++++++++++++++++++---- include/hw/ppc/xics.h | 2 +- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c index de9e65d35247..b8e91aaf52bd 100644 --- a/hw/intc/xics_spapr.c +++ b/hw/intc/xics_spapr.c @@ -260,7 +260,7 @@ int spapr_ics_alloc(ICSState *ics, int irq_hint, bool l= si, Error **errp) } irq =3D irq_hint; } else { - irq =3D xic->irq_alloc_block(ics->xics, 1, 1); + irq =3D xic->irq_alloc_block(ics->xics, 1, 1, lsi); if (irq < 0) { error_setg(errp, "can't allocate IRQ: no IRQ left"); return -1; @@ -297,9 +297,9 @@ int spapr_ics_alloc_block(ICSState *ics, int num, bool = lsi, if (align) { assert((num =3D=3D 1) || (num =3D=3D 2) || (num =3D=3D 4) || (num =3D=3D 8) || (num =3D=3D 16) || (num =3D=3D 32)); - first =3D xic->irq_alloc_block(ics->xics, num, num); + first =3D xic->irq_alloc_block(ics->xics, num, num, lsi); } else { - first =3D xic->irq_alloc_block(ics->xics, num, 1); + first =3D xic->irq_alloc_block(ics->xics, num, 1, lsi); } if (first < 0) { error_setg(errp, "can't find a free %d-IRQ block", num); diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index ce314fcf38db..f14eae6196cd 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3596,7 +3596,8 @@ static bool spapr_irq_test_2_11(XICSFabric *xi, int i= rq) return !ICS_IRQ_FREE(ics, srcno); } =20 -static int spapr_irq_alloc_block_2_11(XICSFabric *xi, int count, int align) +static int spapr_irq_alloc_block_2_11(XICSFabric *xi, int count, int align, + bool lsi) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(xi); ICSState *ics =3D spapr->ics; @@ -3628,7 +3629,7 @@ static void spapr_irq_free_block_2_11(XICSFabric *xi,= int irq, int num) } } =20 -static bool spapr_irq_is_lsi(XICSFabric *xi, int irq) +static bool spapr_irq_is_lsi_2_11(XICSFabric *xi, int irq) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(xi); int srcno =3D irq - spapr->ics->offset; @@ -3644,10 +3645,21 @@ static bool spapr_irq_test(XICSFabric *xi, int irq) return test_bit(srcno, spapr->irq_map); } =20 -static int spapr_irq_alloc_block(XICSFabric *xi, int count, int align) + +/* + * Let's provision 4 LSIs per PHBs + */ +#define SPAPR_MAX_LSI (SPAPR_MAX_PHBS * 4) + +/* + * Split the IRQ number space of the machine in two: first the LSIs + * and then the MSIs. This allows us to keep the LSI IRQ numbers in a + * well known range which is useful for PHB hotplug. + */ +static int spapr_irq_alloc_block(XICSFabric *xi, int count, int align, boo= l lsi) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(xi); - int start =3D 0; + int start =3D lsi ? 0 : SPAPR_MAX_LSI; int srcno; =20 /* @@ -3664,6 +3676,10 @@ static int spapr_irq_alloc_block(XICSFabric *xi, int= count, int align) return -1; } =20 + if (lsi && srcno >=3D SPAPR_MAX_LSI) { + return -1; + } + bitmap_set(spapr->irq_map, srcno, count); return srcno + spapr->irq_base; } @@ -3676,6 +3692,14 @@ static void spapr_irq_free_block(XICSFabric *xi, int= irq, int num) bitmap_clear(spapr->irq_map, srcno, num); } =20 +static bool spapr_irq_is_lsi(XICSFabric *xi, int irq) +{ + sPAPRMachineState *spapr =3D SPAPR_MACHINE(xi); + int srcno =3D irq - spapr->irq_base; + + return (srcno >=3D 0) && (srcno < SPAPR_MAX_LSI); +} + static void spapr_pic_print_info(InterruptStatsProvider *obj, Monitor *mon) { @@ -3860,6 +3884,7 @@ static void spapr_machine_2_11_class_options(MachineC= lass *mc) xic->irq_test =3D spapr_irq_test_2_11; xic->irq_alloc_block =3D spapr_irq_alloc_block_2_11; xic->irq_free_block =3D spapr_irq_free_block_2_11; + xic->irq_is_lsi =3D spapr_irq_is_lsi_2_11; } =20 DEFINE_SPAPR_MACHINE(2_11, "2.11", false); diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index 478f8e510179..292b929e88eb 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -177,7 +177,7 @@ typedef struct XICSFabricClass { ICPState *(*icp_get)(XICSFabric *xi, int server); /* IRQ allocator helpers */ bool (*irq_test)(XICSFabric *xi, int irq); - int (*irq_alloc_block)(XICSFabric *xi, int count, int align); + int (*irq_alloc_block)(XICSFabric *xi, int count, int align, bool lsi); void (*irq_free_block)(XICSFabric *xi, int irq, int num); bool (*irq_is_lsi)(XICSFabric *xi, int irq); } XICSFabricClass; --=20 2.13.6 From nobody Wed May 8 08:41:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1510327744297452.67092292609016; Fri, 10 Nov 2017 07:29:04 -0800 (PST) Received: from localhost ([::1]:42256 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDBEo-0005o4-BG for importer@patchew.org; Fri, 10 Nov 2017 10:28:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47963) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDB7t-0008Nb-GG for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:21:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eDB7p-0007CW-E6 for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:21:49 -0500 Received: from 3.mo68.mail-out.ovh.net ([46.105.58.60]:45236) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eDB7p-0007BK-6V for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:21:45 -0500 Received: from player737.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id 30CBC9C30E for ; Fri, 10 Nov 2017 16:21:44 +0100 (CET) Received: from zorba.kaod.org.com (deibp9eh1--blueice1n7.emea.ibm.com [195.212.29.161]) (Authenticated sender: clg@kaod.org) by player737.ha.ovh.net (Postfix) with ESMTPSA id EC5F7E0090; Fri, 10 Nov 2017 16:21:36 +0100 (CET) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson , Greg Kurz , Benjamin Herrenschmidt Date: Fri, 10 Nov 2017 15:20:16 +0000 Message-Id: <20171110152017.24324-11-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171110152017.24324-1-clg@kaod.org> References: <20171110152017.24324-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 14125540234246654803 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddrieefgdejgecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.58.60 Subject: [Qemu-devel] [PATCH for-2.12 v3 10/11] sparp: merge ics_set_irq_type() in irq_alloc_block() operation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Setting the XICS_FLAGS_IRQ_LSI (or XICS_FLAGS_IRQ_MSI) for older pseries machines can now be done directly under the irq_alloc_block() operation. Signed-off-by: C=C3=A9dric Le Goater --- hw/intc/xics.c | 8 -------- hw/intc/xics_spapr.c | 7 +------ hw/ppc/pnv_psi.c | 4 ---- hw/ppc/spapr.c | 13 +++++++++++++ include/hw/ppc/xics.h | 1 - 5 files changed, 14 insertions(+), 19 deletions(-) diff --git a/hw/intc/xics.c b/hw/intc/xics.c index 42880e736697..237eed3c11f8 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -710,14 +710,6 @@ ICPState *xics_icp_get(XICSFabric *xi, int server) return xic->icp_get(xi, server); } =20 -void ics_set_irq_type(ICSState *ics, int srcno, bool lsi) -{ - assert(!(ics->irqs[srcno].flags & XICS_FLAGS_IRQ_MASK)); - - ics->irqs[srcno].flags |=3D - lsi ? XICS_FLAGS_IRQ_LSI : XICS_FLAGS_IRQ_MSI; -} - static void xics_register_types(void) { type_register_static(&ics_simple_info); diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c index b8e91aaf52bd..f28e9136f2f6 100644 --- a/hw/intc/xics_spapr.c +++ b/hw/intc/xics_spapr.c @@ -267,7 +267,6 @@ int spapr_ics_alloc(ICSState *ics, int irq_hint, bool l= si, Error **errp) } } =20 - ics_set_irq_type(ics, irq - ics->offset, lsi); trace_xics_alloc(irq); =20 return irq; @@ -280,7 +279,7 @@ int spapr_ics_alloc(ICSState *ics, int irq_hint, bool l= si, Error **errp) int spapr_ics_alloc_block(ICSState *ics, int num, bool lsi, bool align, Error **errp) { - int i, first =3D -1; + int first =3D -1; XICSFabricClass *xic =3D XICS_FABRIC_GET_CLASS(ics->xics); =20 if (!ics) { @@ -306,10 +305,6 @@ int spapr_ics_alloc_block(ICSState *ics, int num, bool= lsi, return -1; } =20 - for (i =3D first; i < first + num; ++i) { - ics_set_irq_type(ics, i - ics->offset, lsi); - } - trace_xics_alloc_block(first, num, lsi, align); =20 return first; diff --git a/hw/ppc/pnv_psi.c b/hw/ppc/pnv_psi.c index 9876c266223d..ee7fca311cbf 100644 --- a/hw/ppc/pnv_psi.c +++ b/hw/ppc/pnv_psi.c @@ -487,10 +487,6 @@ static void pnv_psi_realize(DeviceState *dev, Error **= errp) return; } =20 - for (i =3D 0; i < ics->nr_irqs; i++) { - ics_set_irq_type(ics, i, true); - } - /* XSCOM region for PSI registers */ pnv_xscom_region_init(&psi->xscom_regs, OBJECT(dev), &pnv_psi_xscom_op= s, psi, "xscom-psi", PNV_XSCOM_PSIHB_SIZE); diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index f14eae6196cd..8c2cff93f933 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3596,18 +3596,31 @@ static bool spapr_irq_test_2_11(XICSFabric *xi, int= irq) return !ICS_IRQ_FREE(ics, srcno); } =20 +static void ics_set_irq_type(ICSState *ics, int srcno, bool lsi) +{ + assert(!(ics->irqs[srcno].flags & XICS_FLAGS_IRQ_MASK)); + + ics->irqs[srcno].flags |=3D + lsi ? XICS_FLAGS_IRQ_LSI : XICS_FLAGS_IRQ_MSI; +} + static int spapr_irq_alloc_block_2_11(XICSFabric *xi, int count, int align, bool lsi) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(xi); ICSState *ics =3D spapr->ics; int srcno; + int i; =20 srcno =3D ics_find_free_block(ics, count, align); if (srcno =3D=3D -1) { return -1; } =20 + for (i =3D srcno; i < srcno + count; ++i) { + ics_set_irq_type(ics, i, lsi); + } + return srcno + ics->offset; } =20 diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index 292b929e88eb..056cf37bc68f 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -203,7 +203,6 @@ 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); =20 -void ics_set_irq_type(ICSState *ics, int srcno, bool lsi); void icp_pic_print_info(ICPState *icp, Monitor *mon); void ics_pic_print_info(ICSState *ics, Monitor *mon); bool ics_is_lsi(ICSState *ics, int srno); --=20 2.13.6 From nobody Wed May 8 08:41:13 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1510327945122657.1342846925339; Fri, 10 Nov 2017 07:32:25 -0800 (PST) Received: from localhost ([::1]:42275 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDBHn-0008E8-V6 for importer@patchew.org; Fri, 10 Nov 2017 10:32:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48083) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDB81-0008V7-DQ for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:21:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eDB7x-0007OA-5X for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:21:57 -0500 Received: from 1.mo68.mail-out.ovh.net ([46.105.41.146]:48707) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eDB7w-0007MP-T5 for qemu-devel@nongnu.org; Fri, 10 Nov 2017 10:21:53 -0500 Received: from player737.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id C79689C30E for ; Fri, 10 Nov 2017 16:21:51 +0100 (CET) Received: from zorba.kaod.org.com (deibp9eh1--blueice1n7.emea.ibm.com [195.212.29.161]) (Authenticated sender: clg@kaod.org) by player737.ha.ovh.net (Postfix) with ESMTPSA id 68063E007C; Fri, 10 Nov 2017 16:21:44 +0100 (CET) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson , Greg Kurz , Benjamin Herrenschmidt Date: Fri, 10 Nov 2017 15:20:17 +0000 Message-Id: <20171110152017.24324-12-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171110152017.24324-1-clg@kaod.org> References: <20171110152017.24324-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 14127510557279423315 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddrieefgdejgecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.41.146 Subject: [Qemu-devel] [PATCH for-2.12 v3 11/11] spapr: use sPAPRMachineState in spapr_ics_ prototypes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The routines manipulating the IRQ numbers for the sPAPR machine do not have any relation with the ICSState anymore. So use a sPAPRMachineState parameter in their prototype and prefix them with spapr_irq_. Signed-off-by: C=C3=A9dric Le Goater --- hw/intc/xics_spapr.c | 30 ++++++++++++------------------ hw/ppc/spapr.c | 5 +++-- hw/ppc/spapr_events.c | 4 ++-- hw/ppc/spapr_pci.c | 8 ++++---- hw/ppc/spapr_vio.c | 2 +- include/hw/ppc/xics.h | 13 +++++++------ 6 files changed, 29 insertions(+), 33 deletions(-) diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c index f28e9136f2f6..b5c8b8fa0e89 100644 --- a/hw/intc/xics_spapr.c +++ b/hw/intc/xics_spapr.c @@ -245,22 +245,20 @@ void xics_spapr_init(sPAPRMachineState *spapr) spapr_register_hypercall(H_IPOLL, h_ipoll); } =20 -int spapr_ics_alloc(ICSState *ics, int irq_hint, bool lsi, Error **errp) +int spapr_irq_alloc(sPAPRMachineState *spapr, int irq_hint, bool lsi, + Error **errp) { int irq; - XICSFabricClass *xic =3D XICS_FABRIC_GET_CLASS(ics->xics); + XICSFabricClass *xic =3D XICS_FABRIC_GET_CLASS(spapr); =20 - if (!ics) { - return -1; - } if (irq_hint) { - if (xic->irq_test(ics->xics, irq_hint)) { + if (xic->irq_test(XICS_FABRIC(spapr), irq_hint)) { error_setg(errp, "can't allocate IRQ %d: already in use", irq_= hint); return -1; } irq =3D irq_hint; } else { - irq =3D xic->irq_alloc_block(ics->xics, 1, 1, lsi); + irq =3D xic->irq_alloc_block(XICS_FABRIC(spapr), 1, 1, lsi); if (irq < 0) { error_setg(errp, "can't allocate IRQ: no IRQ left"); return -1; @@ -276,15 +274,11 @@ int spapr_ics_alloc(ICSState *ics, int irq_hint, bool= lsi, Error **errp) * Allocate block of consecutive IRQs, and return the number of the first = IRQ in * the block. If align=3D=3Dtrue, aligns the first IRQ number to num. */ -int spapr_ics_alloc_block(ICSState *ics, int num, bool lsi, +int spapr_irq_alloc_block(sPAPRMachineState *spapr, int num, bool lsi, bool align, Error **errp) { int first =3D -1; - XICSFabricClass *xic =3D XICS_FABRIC_GET_CLASS(ics->xics); - - if (!ics) { - return -1; - } + XICSFabricClass *xic =3D XICS_FABRIC_GET_CLASS(spapr); =20 /* * MSIMesage::data is used for storing VIRQ so @@ -296,9 +290,9 @@ int spapr_ics_alloc_block(ICSState *ics, int num, bool = lsi, if (align) { assert((num =3D=3D 1) || (num =3D=3D 2) || (num =3D=3D 4) || (num =3D=3D 8) || (num =3D=3D 16) || (num =3D=3D 32)); - first =3D xic->irq_alloc_block(ics->xics, num, num, lsi); + first =3D xic->irq_alloc_block(XICS_FABRIC(spapr), num, num, lsi); } else { - first =3D xic->irq_alloc_block(ics->xics, num, 1, lsi); + first =3D xic->irq_alloc_block(XICS_FABRIC(spapr), num, 1, lsi); } if (first < 0) { error_setg(errp, "can't find a free %d-IRQ block", num); @@ -310,11 +304,11 @@ int spapr_ics_alloc_block(ICSState *ics, int num, boo= l lsi, return first; } =20 -void spapr_ics_free(ICSState *ics, int irq, int num) +void spapr_irq_free(sPAPRMachineState *spapr, int irq, int num) { - XICSFabricClass *xic =3D XICS_FABRIC_GET_CLASS(ics->xics); + XICSFabricClass *xic =3D XICS_FABRIC_GET_CLASS(spapr); =20 - xic->irq_free_block(ics->xics, irq, num); + xic->irq_free_block(XICS_FABRIC(spapr), irq, num); } =20 void spapr_dt_xics(int nr_servers, void *fdt, uint32_t phandle) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 8c2cff93f933..1ef09963519f 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3669,7 +3669,8 @@ static bool spapr_irq_test(XICSFabric *xi, int irq) * and then the MSIs. This allows us to keep the LSI IRQ numbers in a * well known range which is useful for PHB hotplug. */ -static int spapr_irq_alloc_block(XICSFabric *xi, int count, int align, boo= l lsi) +static int spapr_irq_alloc_block_xi(XICSFabric *xi, int count, int align, + bool lsi) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(xi); int start =3D lsi ? 0 : SPAPR_MAX_LSI; @@ -3808,7 +3809,7 @@ static void spapr_machine_class_init(ObjectClass *oc,= void *data) xic->ics_resend =3D spapr_ics_resend; xic->icp_get =3D spapr_icp_get; xic->irq_test =3D spapr_irq_test; - xic->irq_alloc_block =3D spapr_irq_alloc_block; + xic->irq_alloc_block =3D spapr_irq_alloc_block_xi; xic->irq_free_block =3D spapr_irq_free_block; xic->irq_is_lsi =3D spapr_irq_is_lsi; =20 diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c index e377fc7ddea2..cead596f3e7a 100644 --- a/hw/ppc/spapr_events.c +++ b/hw/ppc/spapr_events.c @@ -718,7 +718,7 @@ void spapr_events_init(sPAPRMachineState *spapr) spapr->event_sources =3D spapr_event_sources_new(); =20 spapr_event_sources_register(spapr->event_sources, EVENT_CLASS_EPOW, - spapr_ics_alloc(spapr->ics, 0, false, + spapr_irq_alloc(spapr, 0, false, &error_fatal)); =20 /* NOTE: if machine supports modern/dedicated hotplug event source, @@ -731,7 +731,7 @@ void spapr_events_init(sPAPRMachineState *spapr) */ if (spapr->use_hotplug_event_source) { spapr_event_sources_register(spapr->event_sources, EVENT_CLASS_HOT= _PLUG, - spapr_ics_alloc(spapr->ics, 0, false, + spapr_irq_alloc(spapr, 0, false, &error_fatal)); } =20 diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 5a3122a9f9f9..e0ef77a480e5 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -314,7 +314,7 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPRM= achineState *spapr, return; } =20 - spapr_ics_free(spapr->ics, msi->first_irq, msi->num); + spapr_irq_free(spapr, msi->first_irq, msi->num); if (msi_present(pdev)) { spapr_msi_setmsg(pdev, 0, false, 0, 0); } @@ -352,7 +352,7 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPRM= achineState *spapr, } =20 /* Allocate MSIs */ - irq =3D spapr_ics_alloc_block(spapr->ics, req_num, false, + irq =3D spapr_irq_alloc_block(spapr, req_num, false, ret_intr_type =3D=3D RTAS_TYPE_MSI, &err); if (err) { error_reportf_err(err, "Can't allocate MSIs for device %x: ", @@ -363,7 +363,7 @@ static void rtas_ibm_change_msi(PowerPCCPU *cpu, sPAPRM= achineState *spapr, =20 /* Release previous MSIs */ if (msi) { - spapr_ics_free(spapr->ics, msi->first_irq, msi->num); + spapr_irq_free(spapr, msi->first_irq, msi->num); g_hash_table_remove(phb->msi, &config_addr); } =20 @@ -1675,7 +1675,7 @@ static void spapr_phb_realize(DeviceState *dev, Error= **errp) uint32_t irq; Error *local_err =3D NULL; =20 - irq =3D spapr_ics_alloc_block(spapr->ics, 1, true, false, &local_e= rr); + irq =3D spapr_irq_alloc_block(spapr, 1, true, false, &local_err); if (local_err) { error_propagate(errp, local_err); error_prepend(errp, "can't allocate LSIs: "); diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c index ea3bc8bd9e21..bb7ed2c537b0 100644 --- a/hw/ppc/spapr_vio.c +++ b/hw/ppc/spapr_vio.c @@ -454,7 +454,7 @@ static void spapr_vio_busdev_realize(DeviceState *qdev,= Error **errp) dev->qdev.id =3D id; } =20 - dev->irq =3D spapr_ics_alloc(spapr->ics, dev->irq, false, &local_err); + dev->irq =3D spapr_irq_alloc(spapr, dev->irq, false, &local_err); if (local_err) { error_propagate(errp, local_err); return; diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index 056cf37bc68f..dd3e2eacedb2 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -184,10 +184,13 @@ typedef struct XICSFabricClass { =20 #define XICS_IRQS_SPAPR 1024 =20 -int spapr_ics_alloc(ICSState *ics, int irq_hint, bool lsi, Error **errp); -int spapr_ics_alloc_block(ICSState *ics, int num, bool lsi, bool align, - Error **errp); -void spapr_ics_free(ICSState *ics, int irq, int num); +typedef struct sPAPRMachineState sPAPRMachineState; + +int spapr_irq_alloc(sPAPRMachineState *spapr, int irq_hint, bool lsi, + Error **errp); +int spapr_irq_alloc_block(sPAPRMachineState *spapr, int num, bool lsi, + bool align, Error **errp); +void spapr_irq_free(sPAPRMachineState *spapr, int irq, int num); void spapr_dt_xics(int nr_servers, void *fdt, uint32_t phandle); =20 qemu_irq xics_get_qirq(XICSFabric *xi, int irq); @@ -210,8 +213,6 @@ bool ics_is_lsi(ICSState *ics, int srno); void ics_resend(ICSState *ics); void icp_resend(ICPState *ss); =20 -typedef struct sPAPRMachineState sPAPRMachineState; - int xics_kvm_init(sPAPRMachineState *spapr, Error **errp); void xics_spapr_init(sPAPRMachineState *spapr); =20 --=20 2.13.6