From nobody Fri May 3 04:10:15 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 1510234274933265.8265744522736; Thu, 9 Nov 2017 05:31:14 -0800 (PST) Received: from localhost ([::1]:36911 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCmv6-0000rU-UK for importer@patchew.org; Thu, 09 Nov 2017 08:31:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40340) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCmtL-000889-9t for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:29:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eCmtH-00056A-CX for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:29:11 -0500 Received: from 5.mo68.mail-out.ovh.net ([46.105.62.179]:51001) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eCmtH-00055s-6F for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:29:07 -0500 Received: from player750.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id 649CD9B59B for ; Thu, 9 Nov 2017 14:29:04 +0100 (CET) Received: from zorba.kaod.org.com (LFbn-1-2231-173.w90-76.abo.wanadoo.fr [90.76.52.173]) (Authenticated sender: clg@kaod.org) by player750.ha.ovh.net (Postfix) with ESMTPSA id 38803180C6C; Thu, 9 Nov 2017 11:14:57 +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: Thu, 9 Nov 2017 11:14:28 +0100 Message-Id: <20171109101439.390-2-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171109101439.390-1-clg@kaod.org> References: <20171109101439.390-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 3073425271620275027 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddriedugdegiecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd 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.62.179 Subject: [Qemu-devel] [PATCH for-2.12 v2 01/12] 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 --- 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 Fri May 3 04:10:15 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 1510234302426800.3373756916963; Thu, 9 Nov 2017 05:31:42 -0800 (PST) Received: from localhost ([::1]:36913 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCmvi-0001K0-JJ for importer@patchew.org; Thu, 09 Nov 2017 08:31:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40403) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCmtQ-0008Bu-KN for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:29:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eCmtM-00058G-KU for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:29:16 -0500 Received: from 1.mo68.mail-out.ovh.net ([46.105.41.146]:37085) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eCmtM-00057u-E8 for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:29:12 -0500 Received: from player750.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id 3C4B09BCAA for ; Thu, 9 Nov 2017 14:29:11 +0100 (CET) Received: from zorba.kaod.org.com (LFbn-1-2231-173.w90-76.abo.wanadoo.fr [90.76.52.173]) (Authenticated sender: clg@kaod.org) by player750.ha.ovh.net (Postfix) with ESMTPSA id 6666D181AF8; Thu, 9 Nov 2017 11:15:03 +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: Thu, 9 Nov 2017 11:14:29 +0100 Message-Id: <20171109101439.390-3-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171109101439.390-1-clg@kaod.org> References: <20171109101439.390-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 3075114123513006931 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddriedugdegiecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd 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 v2 02/12] 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 --- 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 Fri May 3 04:10:15 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 1510234298341508.65388461543876; Thu, 9 Nov 2017 05:31:38 -0800 (PST) Received: from localhost ([::1]:36912 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCmvR-000170-9w for importer@patchew.org; Thu, 09 Nov 2017 08:31:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40452) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCmtX-0008Gf-7k for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:29:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eCmtT-0005B2-8K for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:29:23 -0500 Received: from 8.mo68.mail-out.ovh.net ([46.105.74.219]:34714) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eCmtT-0005Ao-1o for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:29:19 -0500 Received: from player750.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id EA0709B8F0 for ; Thu, 9 Nov 2017 14:29:17 +0100 (CET) Received: from zorba.kaod.org.com (LFbn-1-2231-173.w90-76.abo.wanadoo.fr [90.76.52.173]) (Authenticated sender: clg@kaod.org) by player750.ha.ovh.net (Postfix) with ESMTPSA id 92455181AFD; Thu, 9 Nov 2017 11:15:09 +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: Thu, 9 Nov 2017 11:14:30 +0100 Message-Id: <20171109101439.390-4-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171109101439.390-1-clg@kaod.org> References: <20171109101439.390-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 3076802973432253267 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddriedugdegiecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd 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.74.219 Subject: [Qemu-devel] [PATCH for-2.12 v2 03/12] 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_6 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 --- 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 Fri May 3 04:10:15 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 1510234474023365.8991728770195; Thu, 9 Nov 2017 05:34:34 -0800 (PST) Received: from localhost ([::1]:36924 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCmyU-0003YH-2S for importer@patchew.org; Thu, 09 Nov 2017 08:34:30 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40496) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCmtc-0008Kf-Dt for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:29:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eCmtY-0005Cw-Dm for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:29:28 -0500 Received: from 1.mo68.mail-out.ovh.net ([46.105.41.146]:40213) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eCmtY-0005CS-57 for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:29:24 -0500 Received: from player750.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id 9979B9BDDF for ; Thu, 9 Nov 2017 14:29:22 +0100 (CET) Received: from zorba.kaod.org.com (LFbn-1-2231-173.w90-76.abo.wanadoo.fr [90.76.52.173]) (Authenticated sender: clg@kaod.org) by player750.ha.ovh.net (Postfix) with ESMTPSA id BFCDE181B07; Thu, 9 Nov 2017 11:15:15 +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: Thu, 9 Nov 2017 11:14:31 +0100 Message-Id: <20171109101439.390-5-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171109101439.390-1-clg@kaod.org> References: <20171109101439.390-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 3078491822706953043 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddriedugdegiecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd 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 v2 04/12] 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 --- 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..481bfb0277df 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 Fri May 3 04:10:15 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 1510234491446313.8449096945059; Thu, 9 Nov 2017 05:34:51 -0800 (PST) Received: from localhost ([::1]:36927 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCmym-0003sB-JD for importer@patchew.org; Thu, 09 Nov 2017 08:34:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40544) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCmtg-0008PS-7V for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:29:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eCmtc-0005EE-4o for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:29:32 -0500 Received: from 9.mo68.mail-out.ovh.net ([46.105.78.111]:45162) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eCmtb-0005Dv-RL for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:29:28 -0500 Received: from player750.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id 937859BD4A for ; Thu, 9 Nov 2017 14:29:26 +0100 (CET) Received: from zorba.kaod.org.com (LFbn-1-2231-173.w90-76.abo.wanadoo.fr [90.76.52.173]) (Authenticated sender: clg@kaod.org) by player750.ha.ovh.net (Postfix) with ESMTPSA id EC169181B0F; Thu, 9 Nov 2017 11:15: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: Thu, 9 Nov 2017 11:14:32 +0100 Message-Id: <20171109101439.390-6-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171109101439.390-1-clg@kaod.org> References: <20171109101439.390-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 3080462147117157203 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddriedugdegiecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd 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 v2 05/12] 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" On the sPAPR platform, these IRQ operations are simply backed by a bitmap 'irq_map' in the machine. Older pseries machines do not have a bitmap acting as a IRQ number allocator but use the ICSIRQState array for this purpose. This difference between machine versions needs to be taken into account when loading the state. To keep in sync the bitmap with the ICSIRQState array flags, we introduce a machine class flag 'has_irq_bitmap' set to false for older versions only. Signed-off-by: C=C3=A9dric Le Goater --- hw/ppc/spapr.c | 97 ++++++++++++++++++++++++++++++++++------------= ---- include/hw/ppc/spapr.h | 4 +++ 2 files changed, 70 insertions(+), 31 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 481bfb0277df..70f6a96ec909 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1532,6 +1532,7 @@ static bool spapr_vga_init(PCIBus *pci_bus, Error **e= rrp) static int spapr_post_load(void *opaque, int version_id) { sPAPRMachineState *spapr =3D (sPAPRMachineState *)opaque; + sPAPRMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(spapr); int err =3D 0; =20 if (!object_dynamic_cast(OBJECT(spapr->ics), TYPE_ICS_KVM)) { @@ -1562,6 +1563,20 @@ static int spapr_post_load(void *opaque, int version= _id) } } =20 + /* + * Synchronize the IRQ number bitmap with the ICSIRQState array + * coming from an older pseries machine + */ + if (!smc->has_irq_bitmap) { + int srcno; + + for (srcno =3D 0; srcno < spapr->ics->nr_irqs; srcno++) { + if (spapr->ics->irqs[srcno].flags & XICS_FLAGS_IRQ_MASK && + !test_bit(srcno, spapr->irq_map)) { + bitmap_set(spapr->irq_map, srcno, 1); + } + } + } return err; } =20 @@ -1681,6 +1696,30 @@ static const VMStateDescription vmstate_spapr_patb_e= ntry =3D { }, }; =20 +static bool spapr_irq_map_needed(void *opaque) +{ + sPAPRMachineState *spapr =3D opaque; + sPAPRMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(spapr); + + /* Never transfer the bitmap on older machines, it doesn't exist */ + if (!smc->has_irq_bitmap) { + return false; + } + + 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 +1739,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 +2377,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 */ @@ -3536,50 +3580,37 @@ 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) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(xi); ICSState *ics =3D spapr->ics; int srcno =3D irq - ics->offset; =20 - return ICS_IRQ_FREE(ics, srcno); + return test_bit(srcno, spapr->irq_map); } =20 static int spapr_irq_alloc_block(XICSFabric *xi, int count, int align) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(xi); ICSState *ics =3D spapr->ics; + int start =3D 0; int srcno; =20 - srcno =3D ics_find_free_block(ics, count, align); - if (srcno =3D=3D -1) { + /* + * 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; } =20 + bitmap_set(spapr->irq_map, srcno, count); return srcno + ics->offset; } =20 @@ -3593,11 +3624,11 @@ static void spapr_irq_free_block(XICSFabric *xi, in= t irq, int num) 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)) { + if (!test_bit(i, spapr->irq_map)) { trace_spapr_irq_free_warn(0, i + ics->offset); } - memset(&ics->irqs[i], 0, sizeof(ICSIRQState)); } + bitmap_clear(spapr->irq_map, srcno, num); } } =20 @@ -3679,6 +3710,7 @@ static void spapr_machine_class_init(ObjectClass *oc,= void *data) hc->unplug_request =3D spapr_machine_device_unplug_request; =20 smc->dr_lmb_enabled =3D true; + smc->has_irq_bitmap =3D true; mc->default_cpu_type =3D POWERPC_CPU_TYPE_NAME("power8_v2.0"); mc->has_hotpluggable_cpus =3D true; smc->resize_hpt_default =3D SPAPR_RESIZE_HPT_ENABLED; @@ -3778,7 +3810,10 @@ 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 */ + sPAPRMachineClass *smc =3D SPAPR_MACHINE_CLASS(mc); + + spapr_machine_2_12_class_options(mc); + smc->has_irq_bitmap =3D false; } =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..71faeff17a40 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; @@ -61,6 +62,7 @@ struct sPAPRMachineClass { bool dr_lmb_enabled; /* enable dynamic-reconfig/hotplug of LMBs = */ bool use_ohci_by_default; /* use USB-OHCI instead of XHCI */ bool pre_2_10_has_unused_icps; + bool has_irq_bitmap; void (*phb_placement)(sPAPRMachineState *spapr, uint32_t index, uint64_t *buid, hwaddr *pio,=20 hwaddr *mmio32, hwaddr *mmio64, @@ -78,6 +80,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 Fri May 3 04:10:15 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 1510234573518426.809321673254; Thu, 9 Nov 2017 05:36:13 -0800 (PST) Received: from localhost ([::1]:36935 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCn01-00055w-44 for importer@patchew.org; Thu, 09 Nov 2017 08:36:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40725) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCmtu-0000BJ-8C for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:29:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eCmtq-0005MS-4F for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:29:46 -0500 Received: from 3.mo68.mail-out.ovh.net ([46.105.58.60]:48615) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eCmtp-0005Lw-TY for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:29:42 -0500 Received: from player750.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id 4DBE699C7C for ; Thu, 9 Nov 2017 14:29:40 +0100 (CET) Received: from zorba.kaod.org.com (LFbn-1-2231-173.w90-76.abo.wanadoo.fr [90.76.52.173]) (Authenticated sender: clg@kaod.org) by player750.ha.ovh.net (Postfix) with ESMTPSA id 246B1181B2C; Thu, 9 Nov 2017 11:15: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: Thu, 9 Nov 2017 11:14:33 +0100 Message-Id: <20171109101439.390-7-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171109101439.390-1-clg@kaod.org> References: <20171109101439.390-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 3082150996274350931 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddriedugdegiecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd 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 v2 06/12] 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_0 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 --- hw/ppc/spapr.c | 5 ++++- include/hw/ppc/spapr.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 70f6a96ec909..d4d0a36cc5bf 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 @@ -1706,7 +1709,7 @@ static bool spapr_irq_map_needed(void *opaque) return false; } =20 - return true; + 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 71faeff17a40..090eda962ccb 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -82,6 +82,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 Fri May 3 04:10:15 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 1510234486001189.49583928977688; Thu, 9 Nov 2017 05:34:46 -0800 (PST) Received: from localhost ([::1]:36926 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCmyj-0003oc-58 for importer@patchew.org; Thu, 09 Nov 2017 08:34:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40794) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCmu7-0000Kw-3h for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:30:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eCmu3-0005QS-3B for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:29:59 -0500 Received: from 5.mo68.mail-out.ovh.net ([46.105.62.179]:51828) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eCmu2-0005QC-TR for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:29:55 -0500 Received: from player750.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id B194E9B877 for ; Thu, 9 Nov 2017 14:29:53 +0100 (CET) Received: from zorba.kaod.org.com (LFbn-1-2231-173.w90-76.abo.wanadoo.fr [90.76.52.173]) (Authenticated sender: clg@kaod.org) by player750.ha.ovh.net (Postfix) with ESMTPSA id 50E64181B40; Thu, 9 Nov 2017 11:15:34 +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: Thu, 9 Nov 2017 11:14:34 +0100 Message-Id: <20171109101439.390-8-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171109101439.390-1-clg@kaod.org> References: <20171109101439.390-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 3083839847709707091 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddriedugdegiecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd 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.62.179 Subject: [Qemu-devel] [PATCH for-2.12 v2 07/12] 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_0 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 | 11 +++++------ include/hw/ppc/spapr.h | 1 + 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index d4d0a36cc5bf..6c3fc12ed8e1 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2383,6 +2383,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); @@ -3586,8 +3587,7 @@ static ICPState *spapr_icp_get(XICSFabric *xi, int vc= pu_id) static bool spapr_irq_test(XICSFabric *xi, int irq) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(xi); - ICSState *ics =3D spapr->ics; - int srcno =3D irq - ics->offset; + int srcno =3D irq - spapr->irq_base; =20 return test_bit(srcno, spapr->irq_map); } @@ -3595,7 +3595,6 @@ static bool spapr_irq_test(XICSFabric *xi, int irq) static int spapr_irq_alloc_block(XICSFabric *xi, int count, int align) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(xi); - ICSState *ics =3D spapr->ics; int start =3D 0; int srcno; =20 @@ -3614,21 +3613,21 @@ static int spapr_irq_alloc_block(XICSFabric *xi, in= t count, int align) } =20 bitmap_set(spapr->irq_map, srcno, count); - return srcno + 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); ICSState *ics =3D spapr->ics; - int srcno =3D irq - ics->offset; + int srcno =3D irq - spapr->irq_base; int i; =20 if (ics_valid_irq(ics, irq)) { trace_spapr_irq_free(0, irq, num); for (i =3D srcno; i < srcno + num; ++i) { if (!test_bit(i, spapr->irq_map)) { - trace_spapr_irq_free_warn(0, i + ics->offset); + trace_spapr_irq_free_warn(0, i + spapr->irq_base); } } bitmap_clear(spapr->irq_map, srcno, num); diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 090eda962ccb..8d227fe6f56c 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -83,6 +83,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 Fri May 3 04:10:15 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 1510234664071444.78793410194226; Thu, 9 Nov 2017 05:37:44 -0800 (PST) Received: from localhost ([::1]:36947 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCn1W-0006bn-90 for importer@patchew.org; Thu, 09 Nov 2017 08:37:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCmuO-0000ZC-75 for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:30:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eCmuN-0005YX-4t for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:30:16 -0500 Received: from 1.mo68.mail-out.ovh.net ([46.105.41.146]:46444) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eCmuM-0005Y3-Ua for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:30:15 -0500 Received: from player750.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id CF0F79BDF1 for ; Thu, 9 Nov 2017 14:30:13 +0100 (CET) Received: from zorba.kaod.org.com (LFbn-1-2231-173.w90-76.abo.wanadoo.fr [90.76.52.173]) (Authenticated sender: clg@kaod.org) by player750.ha.ovh.net (Postfix) with ESMTPSA id 7D5F1181B69; Thu, 9 Nov 2017 11:15:40 +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: Thu, 9 Nov 2017 11:14:35 +0100 Message-Id: <20171109101439.390-9-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171109101439.390-1-clg@kaod.org> References: <20171109101439.390-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 3085528697659886419 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddriedugdegiecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd 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 v2 08/12] spapr: remove the use of ics_valid_irq() 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" ics_valid_irq() can be replaced by a simple check on the 'srcno' number. It also removes a dependency on the ICSState object of the sPAPR machine. Signed-off-by: C=C3=A9dric Le Goater --- hw/ppc/spapr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 6c3fc12ed8e1..0c6a4c8bffc0 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3619,11 +3619,10 @@ static int spapr_irq_alloc_block(XICSFabric *xi, in= t count, int align) 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 - spapr->irq_base; int i; =20 - if (ics_valid_irq(ics, irq)) { + if (srcno >=3D 0 && srcno < spapr->nr_irqs) { trace_spapr_irq_free(0, irq, num); for (i =3D srcno; i < srcno + num; ++i) { if (!test_bit(i, spapr->irq_map)) { --=20 2.13.6 From nobody Fri May 3 04:10:15 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 15102347056641001.7991154464802; Thu, 9 Nov 2017 05:38:25 -0800 (PST) Received: from localhost ([::1]:36949 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCn26-000748-JD for importer@patchew.org; Thu, 09 Nov 2017 08:38:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41098) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCmum-0000yr-0O for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:30:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eCmuh-0005kx-On for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:30:40 -0500 Received: from 6.mo68.mail-out.ovh.net ([46.105.63.100]:41052) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eCmuh-0005kZ-F9 for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:30:35 -0500 Received: from player750.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id 38CCC9B916 for ; Thu, 9 Nov 2017 14:30:34 +0100 (CET) Received: from zorba.kaod.org.com (LFbn-1-2231-173.w90-76.abo.wanadoo.fr [90.76.52.173]) (Authenticated sender: clg@kaod.org) by player750.ha.ovh.net (Postfix) with ESMTPSA id AA797181B8C; Thu, 9 Nov 2017 11:15:46 +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: Thu, 9 Nov 2017 11:14:36 +0100 Message-Id: <20171109101439.390-10-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171109101439.390-1-clg@kaod.org> References: <20171109101439.390-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 3087217546870688595 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddriedugdegiecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd 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.100 Subject: [Qemu-devel] [PATCH for-2.12 v2 09/12] 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 --- 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 0c6a4c8bffc0..86d5e310e85f 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3633,6 +3633,14 @@ static void spapr_irq_free_block(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->irq_base; + + return spapr->ics->irqs[srcno].flags & XICS_FLAGS_IRQ_LSI; +} + static void spapr_pic_print_info(InterruptStatsProvider *obj, Monitor *mon) { @@ -3731,6 +3739,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 Fri May 3 04:10:15 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 1510234729755802.3276345496114; Thu, 9 Nov 2017 05:38:49 -0800 (PST) Received: from localhost ([::1]:36950 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCn2U-0007MX-TI for importer@patchew.org; Thu, 09 Nov 2017 08:38:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41308) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCmvA-0001JH-Gc for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:31:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eCmv6-0005y0-Bm for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:31:04 -0500 Received: from 2.mo68.mail-out.ovh.net ([46.105.52.162]:52980) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eCmv6-0005xK-53 for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:31:00 -0500 Received: from player750.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id 6D2E49BE01 for ; Thu, 9 Nov 2017 14:30:58 +0100 (CET) Received: from zorba.kaod.org.com (LFbn-1-2231-173.w90-76.abo.wanadoo.fr [90.76.52.173]) (Authenticated sender: clg@kaod.org) by player750.ha.ovh.net (Postfix) with ESMTPSA id D75AA181B98; Thu, 9 Nov 2017 11:15:52 +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: Thu, 9 Nov 2017 11:14:37 +0100 Message-Id: <20171109101439.390-11-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171109101439.390-1-clg@kaod.org> References: <20171109101439.390-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 3089187871669062483 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddriedugdegiecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd 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 v2 10/12] 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 nature 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 (needed to introduce for 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. For compatibility with older machines, we use the machine class flag 'has_irq_bitmap'. Signed-off-by: C=C3=A9dric Le Goater --- hw/intc/xics_spapr.c | 6 +++--- hw/ppc/spapr.c | 27 ++++++++++++++++++++++++++- include/hw/ppc/xics.h | 2 +- 3 files changed, 30 insertions(+), 5 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 86d5e310e85f..d576e235d226 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3592,9 +3592,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); + sPAPRMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(spapr); int start =3D 0; int srcno; =20 @@ -3606,12 +3618,20 @@ static int spapr_irq_alloc_block(XICSFabric *xi, in= t count, int align) */ align -=3D 1; =20 + if (!lsi && smc->has_irq_bitmap) { + start =3D SPAPR_MAX_LSI; + } + 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; } =20 + if (lsi && smc->has_irq_bitmap && srcno >=3D SPAPR_MAX_LSI) { + return -1; + } + bitmap_set(spapr->irq_map, srcno, count); return srcno + spapr->irq_base; } @@ -3636,8 +3656,13 @@ static void spapr_irq_free_block(XICSFabric *xi, int= irq, int num) static bool spapr_irq_is_lsi(XICSFabric *xi, int irq) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(xi); + sPAPRMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(spapr); int srcno =3D irq - spapr->irq_base; =20 + if (smc->has_irq_bitmap) { + return (srcno >=3D 0) && (srcno < SPAPR_MAX_LSI); + } + return spapr->ics->irqs[srcno].flags & XICS_FLAGS_IRQ_LSI; } =20 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 Fri May 3 04:10:15 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 1510234863773822.3986353071317; Thu, 9 Nov 2017 05:41:03 -0800 (PST) Received: from localhost ([::1]:36963 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCn4d-0000dV-Tg for importer@patchew.org; Thu, 09 Nov 2017 08:40:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41479) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCmvc-0001fH-1T for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:31:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eCmvY-0006Ec-2E for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:31:32 -0500 Received: from 10.mo68.mail-out.ovh.net ([46.105.79.203]:54504) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eCmvX-0006DM-SM for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:31:28 -0500 Received: from player750.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id 7F38D9BDFE for ; Thu, 9 Nov 2017 14:31:26 +0100 (CET) Received: from zorba.kaod.org.com (LFbn-1-2231-173.w90-76.abo.wanadoo.fr [90.76.52.173]) (Authenticated sender: clg@kaod.org) by player750.ha.ovh.net (Postfix) with ESMTPSA id 1024E181C38; Thu, 9 Nov 2017 11:15: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: Thu, 9 Nov 2017 11:14:38 +0100 Message-Id: <20171109101439.390-12-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171109101439.390-1-clg@kaod.org> References: <20171109101439.390-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 3090876720091663187 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddriedugdegiecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd 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 v2 11/12] 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. For compatibility with older machines, we use the machine class flag 'has_irq_bitmap'. 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 | 14 ++++++++++++++ include/hw/ppc/xics.h | 1 - 5 files changed, 15 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 d576e235d226..0cf1e02fa2b7 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3592,6 +3592,13 @@ static bool spapr_irq_test(XICSFabric *xi, int irq) return test_bit(srcno, spapr->irq_map); } =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; +} =20 /* * Let's provision 4 LSIs per PHBs @@ -3632,6 +3639,13 @@ static int spapr_irq_alloc_block(XICSFabric *xi, int= count, int align, bool lsi) return -1; } =20 + if (!smc->has_irq_bitmap) { + int i; + for (i =3D srcno; i < srcno + count; ++i) { + ics_set_irq_type(spapr->ics, i, lsi); + } + } + bitmap_set(spapr->irq_map, srcno, count); return srcno + spapr->irq_base; } 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 Fri May 3 04:10:15 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 1510234853312366.038597877745; Thu, 9 Nov 2017 05:40:53 -0800 (PST) Received: from localhost ([::1]:36962 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCn4Z-0000a6-Fs for importer@patchew.org; Thu, 09 Nov 2017 08:40:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41566) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCmvm-0001p3-Mo for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:31:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eCmvg-0006LW-8x for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:31:42 -0500 Received: from 6.mo68.mail-out.ovh.net ([46.105.63.100]:51990) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eCmvf-0006Ky-WF for qemu-devel@nongnu.org; Thu, 09 Nov 2017 08:31:36 -0500 Received: from player750.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id 8F1B19BC35 for ; Thu, 9 Nov 2017 14:31:34 +0100 (CET) Received: from zorba.kaod.org.com (LFbn-1-2231-173.w90-76.abo.wanadoo.fr [90.76.52.173]) (Authenticated sender: clg@kaod.org) by player750.ha.ovh.net (Postfix) with ESMTPSA id 3D118181C71; Thu, 9 Nov 2017 11:16:05 +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: Thu, 9 Nov 2017 11:14:39 +0100 Message-Id: <20171109101439.390-13-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171109101439.390-1-clg@kaod.org> References: <20171109101439.390-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 3092565572508814163 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddriedugdegiecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd 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.100 Subject: [Qemu-devel] [PATCH for-2.12 v2 12/12] 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_0 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 0cf1e02fa2b7..dcde3f4da659 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3610,7 +3610,8 @@ static void ics_set_irq_type(ICSState *ics, int srcno= , bool lsi) * 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); sPAPRMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(spapr); @@ -3776,7 +3777,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