From nobody Sat Nov 1 22:15:49 2025 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 1509300908694317.3356669188357; Sun, 29 Oct 2017 11:15:08 -0700 (PDT) Received: from localhost ([::1]:37295 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8s6n-0005re-UN for importer@patchew.org; Sun, 29 Oct 2017 14:14:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35525) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8s4l-0004dM-FC for qemu-devel@nongnu.org; Sun, 29 Oct 2017 14:12:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e8s4i-0005oJ-6s for qemu-devel@nongnu.org; Sun, 29 Oct 2017 14:12:47 -0400 Received: from 3.mo178.mail-out.ovh.net ([46.105.44.197]:39448) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e8s4h-0005l7-TJ for qemu-devel@nongnu.org; Sun, 29 Oct 2017 14:12:44 -0400 Received: from player793.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo178.mail-out.ovh.net (Postfix) with ESMTP id 3955F5A27D for ; Sun, 29 Oct 2017 19:12:36 +0100 (CET) Received: from zorba.kaod.org (ken64-2-78-199-76-109.fbx.proxad.net [78.199.76.109]) (Authenticated sender: clg@kaod.org) by player793.ha.ovh.net (Postfix) with ESMTPSA id 39A7D4007C; Sun, 29 Oct 2017 19:12: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: Sun, 29 Oct 2017 19:12:10 +0100 Message-Id: <20171029181217.9927-2-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171029181217.9927-1-clg@kaod.org> References: <20171029181217.9927-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1879126947114617683 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddrfeekgddutdelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm 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.44.197 Subject: [Qemu-devel] [PATCH 1/8] spapr: introduce an IRQ allocator at the machine level 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 proposal adding 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 named 'srcno'. On the sPAPR platform, these IRQ operations are simply backed by a bitmap 'irq_map' in the machine. 'irq_base' is a base number in sync with the ICSState 'offset'. It lets us allocate only the subset of the IRQ numbers used on the sPAPR platform but we could also choose to waste some extra bytes (512) and allocate the whole number space. 'nr_irqs' is the total number of IRQs, required to manipulate the bitmap. Signed-off-by: C=C3=A9dric Le Goater --- hw/intc/xics.c | 3 ++- hw/intc/xics_spapr.c | 57 ++++++++++++---------------------------------- hw/ppc/spapr.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++= +++- include/hw/ppc/spapr.h | 4 ++++ include/hw/ppc/xics.h | 4 ++++ 5 files changed, 85 insertions(+), 45 deletions(-) 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 d98ea8b13068..f2e20bca5b2e 100644 --- a/hw/intc/xics_spapr.c +++ b/hw/intc/xics_spapr.c @@ -245,50 +245,23 @@ 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, 0); 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,10 +278,8 @@ 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; - } =20 /* * MSIMesage::data is used for storing VIRQ so @@ -320,9 +291,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, 0); } if (first < 0) { error_setg(errp, "can't find a free %d-IRQ block", num); @@ -331,25 +302,25 @@ int spapr_ics_alloc_block(ICSState *ics, int num, boo= l lsi, =20 if (first >=3D 0) { 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) +static void ics_free(ICSState *ics, int irq, int num) { int i; + XICSFabricClass *xic =3D XICS_FABRIC_GET_CLASS(ics->xics); =20 - for (i =3D srcno; i < srcno + num; ++i) { - if (ICS_IRQ_FREE(ics, i)) { - trace_xics_ics_free_warn(0, i + ics->offset); + for (i =3D irq; i < irq + num; ++i) { + if (xic->irq_test(ics->xics, i)) { + trace_xics_ics_free_warn(0, i); } - memset(&ics->irqs[i], 0, sizeof(ICSIRQState)); + xic->irq_free_block(ics->xics, i, 1); } } =20 @@ -357,7 +328,7 @@ 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); + ics_free(ics, irq, num); } } =20 diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index d682f013d422..88da4bad2328 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1681,6 +1681,24 @@ static const VMStateDescription vmstate_spapr_patb_e= ntry =3D { }, }; =20 +static bool spapr_irq_map_needed(void *opaque) +{ + sPAPRMachineState *spapr =3D opaque; + + return find_first_bit(spapr->irq_map, spapr->nr_irqs) < spapr->nr_irqs; +} + +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 +1718,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 +2356,13 @@ 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); + spapr->irq_base =3D XICS_IRQ_BASE; + /* 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,6 +3560,38 @@ 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) +{ + sPAPRMachineState *spapr =3D SPAPR_MACHINE(xi); + int srcno =3D irq - spapr->irq_base; + + 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; + + 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->irq_base; +} + +static void spapr_irq_free_block(XICSFabric *xi, int irq, int num) +{ + sPAPRMachineState *spapr =3D SPAPR_MACHINE(xi); + int srcno =3D irq - spapr->irq_base; + + bitmap_clear(spapr->irq_map, srcno, num); +} + static void spapr_pic_print_info(InterruptStatsProvider *obj, Monitor *mon) { @@ -3630,6 +3686,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/spapr.h b/include/hw/ppc/spapr.h index 9d21ca9bde3a..b962bfe09bb5 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,9 @@ struct sPAPRMachineState { struct VIOsPAPRBus *vio_bus; QLIST_HEAD(, sPAPRPHBState) phbs; struct sPAPRNVRAM *nvram; + int32_t nr_irqs; + unsigned long *irq_map; + uint32_t irq_base; ICSState *ics; sPAPRRTCState rtc; =20 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 Sat Nov 1 22:15:49 2025 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 1509300912419969.5678646701349; Sun, 29 Oct 2017 11:15:12 -0700 (PDT) Received: from localhost ([::1]:37294 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8s6l-0005qg-Tm for importer@patchew.org; Sun, 29 Oct 2017 14:14:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35532) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8s4m-0004dr-6n for qemu-devel@nongnu.org; Sun, 29 Oct 2017 14:12:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e8s4j-0005ob-15 for qemu-devel@nongnu.org; Sun, 29 Oct 2017 14:12:48 -0400 Received: from 6.mo178.mail-out.ovh.net ([46.105.53.132]:59051) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e8s4i-0005oD-RC for qemu-devel@nongnu.org; Sun, 29 Oct 2017 14:12:44 -0400 Received: from player793.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo178.mail-out.ovh.net (Postfix) with ESMTP id 6F4BA63798 for ; Sun, 29 Oct 2017 19:12:43 +0100 (CET) Received: from zorba.kaod.org (ken64-2-78-199-76-109.fbx.proxad.net [78.199.76.109]) (Authenticated sender: clg@kaod.org) by player793.ha.ovh.net (Postfix) with ESMTPSA id 445A74007B; Sun, 29 Oct 2017 19:12: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: Sun, 29 Oct 2017 19:12:11 +0100 Message-Id: <20171029181217.9927-3-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171029181217.9927-1-clg@kaod.org> References: <20171029181217.9927-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1881097271350889299 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddrfeekgddutdelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm 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.53.132 Subject: [Qemu-devel] [PATCH 2/8] spapr: introduce a machine class flag to handle migration compatibility 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" Older pseries machines, before 2.11, 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 'pre_2_11_has_no_bitmap' identifying an older version. Signed-off-by: C=C3=A9dric Le Goater --- hw/ppc/spapr.c | 19 +++++++++++++++++++ include/hw/ppc/spapr.h | 1 + 2 files changed, 20 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 88da4bad2328..b33eebe44906 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 pre-2.11 pseries machine + */ + if (smc->pre_2_11_has_no_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 @@ -3772,8 +3787,12 @@ static void spapr_machine_2_10_instance_options(Mach= ineState *machine) =20 static void spapr_machine_2_10_class_options(MachineClass *mc) { + sPAPRMachineClass *smc =3D SPAPR_MACHINE_CLASS(mc); + spapr_machine_2_11_class_options(mc); SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_10); + + smc->pre_2_11_has_no_bitmap =3D true; } =20 DEFINE_SPAPR_MACHINE(2_10, "2.10", false); diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index b962bfe09bb5..1525d1518c47 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -62,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 pre_2_11_has_no_bitmap; void (*phb_placement)(sPAPRMachineState *spapr, uint32_t index, uint64_t *buid, hwaddr *pio,=20 hwaddr *mmio32, hwaddr *mmio64, --=20 2.13.6 From nobody Sat Nov 1 22:15:49 2025 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 1509301090343983.4126892534819; Sun, 29 Oct 2017 11:18:10 -0700 (PDT) Received: from localhost ([::1]:37311 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8s9s-0008W3-Fp for importer@patchew.org; Sun, 29 Oct 2017 14:18:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35578) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8s4t-0004i6-89 for qemu-devel@nongnu.org; Sun, 29 Oct 2017 14:12:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e8s4q-0005qJ-3X for qemu-devel@nongnu.org; Sun, 29 Oct 2017 14:12:55 -0400 Received: from 4.mo178.mail-out.ovh.net ([46.105.49.171]:55981) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e8s4p-0005q8-TR for qemu-devel@nongnu.org; Sun, 29 Oct 2017 14:12:52 -0400 Received: from player793.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo178.mail-out.ovh.net (Postfix) with ESMTP id E33596379A for ; Sun, 29 Oct 2017 19:12:50 +0100 (CET) Received: from zorba.kaod.org (ken64-2-78-199-76-109.fbx.proxad.net [78.199.76.109]) (Authenticated sender: clg@kaod.org) by player793.ha.ovh.net (Postfix) with ESMTPSA id 792304007C; Sun, 29 Oct 2017 19:12:43 +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: Sun, 29 Oct 2017 19:12:12 +0100 Message-Id: <20171029181217.9927-4-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171029181217.9927-1-clg@kaod.org> References: <20171029181217.9927-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1883067598106364755 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddrfeekgddutdelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm 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.49.171 Subject: [Qemu-devel] [PATCH 3/8] pnv: introduce an irq_test() 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" On PowerNV, there is no need for a bitmap for the moment. The only interrupts handled are the ones from the PSI controller. Signed-off-by: C=C3=A9dric Le Goater --- hw/ppc/pnv.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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); --=20 2.13.6 From nobody Sat Nov 1 22:15:49 2025 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 1509301090105687.6390246072513; Sun, 29 Oct 2017 11:18:10 -0700 (PDT) Received: from localhost ([::1]:37310 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8s9s-0008Vs-8H for importer@patchew.org; Sun, 29 Oct 2017 14:18:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35623) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8s50-0004pS-Sx for qemu-devel@nongnu.org; Sun, 29 Oct 2017 14:13:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e8s4x-0005uv-NT for qemu-devel@nongnu.org; Sun, 29 Oct 2017 14:13:02 -0400 Received: from 7.mo178.mail-out.ovh.net ([46.105.58.91]:56716) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e8s4x-0005uU-HM for qemu-devel@nongnu.org; Sun, 29 Oct 2017 14:12:59 -0400 Received: from player793.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo178.mail-out.ovh.net (Postfix) with ESMTP id 476BD6379A for ; Sun, 29 Oct 2017 19:12:58 +0100 (CET) Received: from zorba.kaod.org (ken64-2-78-199-76-109.fbx.proxad.net [78.199.76.109]) (Authenticated sender: clg@kaod.org) by player793.ha.ovh.net (Postfix) with ESMTPSA id ECEF74007C; Sun, 29 Oct 2017 19:12:50 +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: Sun, 29 Oct 2017 19:12:13 +0100 Message-Id: <20171029181217.9927-5-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171029181217.9927-1-clg@kaod.org> References: <20171029181217.9927-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1885319398066785107 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddrfeekgddutdelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm 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.91 Subject: [Qemu-devel] [PATCH 4/8] 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 'pre_2_11_has_no_bitmap'. Signed-off-by: C=C3=A9dric Le Goater --- hw/intc/xics_spapr.c | 6 +++--- hw/ppc/spapr.c | 25 ++++++++++++++++++++++--- include/hw/ppc/xics.h | 2 +- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c index f2e20bca5b2e..e1f158302a6a 100644 --- a/hw/intc/xics_spapr.c +++ b/hw/intc/xics_spapr.c @@ -257,7 +257,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, 0); + irq =3D xic->irq_alloc_block(ics->xics, 1, 0, lsi); if (irq < 0) { error_setg(errp, "can't allocate IRQ: no IRQ left"); return -1; @@ -291,9 +291,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, 0); + first =3D xic->irq_alloc_block(ics->xics, num, 0, 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 b33eebe44906..5e42e3329ef4 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1696,6 +1696,13 @@ static const VMStateDescription vmstate_spapr_patb_e= ntry =3D { }, }; =20 +/* + * Let's provision 4 LSIs per PHBs + */ +#define SPAPR_MAX_PHBS ((SPAPR_PCI_LIMIT - SPAPR_PCI_BASE) / \ + SPAPR_PCI_MEM64_WIN_SIZE - 1) +#define SPAPR_MAX_LSI (SPAPR_MAX_PHBS * 4) + static bool spapr_irq_map_needed(void *opaque) { sPAPRMachineState *spapr =3D opaque; @@ -3523,8 +3530,6 @@ static void spapr_phb_placement(sPAPRMachineState *sp= apr, uint32_t index, * 1TiB 64-bit MMIO windows for each PHB. */ const uint64_t base_buid =3D 0x800000020000000ULL; -#define SPAPR_MAX_PHBS ((SPAPR_PCI_LIMIT - SPAPR_PCI_BASE) / \ - SPAPR_PCI_MEM64_WIN_SIZE - 1) int i; =20 /* Sanity check natural alignments */ @@ -3583,18 +3588,32 @@ 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) +/* + * 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 + if (!lsi && !smc->pre_2_11_has_no_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->pre_2_11_has_no_bitmap && srcno >=3D SPAPR_MAX_LSI) { + return -1; + } + 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 30e7f2e0a7dd..c8e6637d16e4 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); } XICSFabricClass; =20 --=20 2.13.6 From nobody Sat Nov 1 22:15:49 2025 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 1509301199658275.91818679727066; Sun, 29 Oct 2017 11:19:59 -0700 (PDT) Received: from localhost ([::1]:37319 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8sBe-0001Ns-PT for importer@patchew.org; Sun, 29 Oct 2017 14:19:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35692) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8s59-0004zB-Od for qemu-devel@nongnu.org; Sun, 29 Oct 2017 14:13:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e8s55-0005xF-AT for qemu-devel@nongnu.org; Sun, 29 Oct 2017 14:13:11 -0400 Received: from 3.mo178.mail-out.ovh.net ([46.105.44.197]:39622) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e8s55-0005wx-1J for qemu-devel@nongnu.org; Sun, 29 Oct 2017 14:13:07 -0400 Received: from player793.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo178.mail-out.ovh.net (Postfix) with ESMTP id 0606B637C2 for ; Sun, 29 Oct 2017 19:13:06 +0100 (CET) Received: from zorba.kaod.org (ken64-2-78-199-76-109.fbx.proxad.net [78.199.76.109]) (Authenticated sender: clg@kaod.org) by player793.ha.ovh.net (Postfix) with ESMTPSA id 56CDB4007B; Sun, 29 Oct 2017 19:12:58 +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: Sun, 29 Oct 2017 19:12:14 +0100 Message-Id: <20171029181217.9927-6-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171029181217.9927-1-clg@kaod.org> References: <20171029181217.9927-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1887289723133463379 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddrfeekgddutdelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm 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.44.197 Subject: [Qemu-devel] [PATCH 5/8] spapr: introduce an 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" Now that we can distinguish an LSI interrupt from an MSI using the IRQ number, let's introduce a new XICSFabric operation for this purpose and remove the use of XICS_FLAGS_IRQ_LSI flag. The 'irq' parameter continues to refer to the global IRQ number space. For compatibility with older machines, we use the machine class flag 'pre_2_11_has_no_bitmap'. 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 | 14 ++++++++++++++ include/hw/ppc/xics.h | 2 ++ 5 files changed, 51 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 5e42e3329ef4..d97f287118f0 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3626,6 +3626,19 @@ 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); + sPAPRMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(spapr); + int srcno =3D irq - spapr->irq_base; + + if (smc->pre_2_11_has_no_bitmap) { + return spapr->ics->irqs[srcno].flags & XICS_FLAGS_IRQ_LSI; + } else { + return (srcno >=3D 0) && (srcno < SPAPR_MAX_LSI); + } +} + static void spapr_pic_print_info(InterruptStatsProvider *obj, Monitor *mon) { @@ -3723,6 +3736,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 c8e6637d16e4..292b929e88eb 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, bool lsi); 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 Sat Nov 1 22:15:49 2025 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 1509301109624355.08257686414186; Sun, 29 Oct 2017 11:18:29 -0700 (PDT) Received: from localhost ([::1]:37313 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8sA9-0000HW-Pc for importer@patchew.org; Sun, 29 Oct 2017 14:18:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35719) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8s5G-00052R-75 for qemu-devel@nongnu.org; Sun, 29 Oct 2017 14:13:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e8s5D-0005ye-1j for qemu-devel@nongnu.org; Sun, 29 Oct 2017 14:13:18 -0400 Received: from 1.mo178.mail-out.ovh.net ([178.33.251.53]:41791) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e8s5C-0005yQ-Rm for qemu-devel@nongnu.org; Sun, 29 Oct 2017 14:13:14 -0400 Received: from player793.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo178.mail-out.ovh.net (Postfix) with ESMTP id 89A0E637BF for ; Sun, 29 Oct 2017 19:13:13 +0100 (CET) Received: from zorba.kaod.org (ken64-2-78-199-76-109.fbx.proxad.net [78.199.76.109]) (Authenticated sender: clg@kaod.org) by player793.ha.ovh.net (Postfix) with ESMTPSA id 0EE514007C; Sun, 29 Oct 2017 19:13: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: Sun, 29 Oct 2017 19:12:15 +0100 Message-Id: <20171029181217.9927-7-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171029181217.9927-1-clg@kaod.org> References: <20171029181217.9927-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1889541518792297299 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddrfeekgddutdelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm 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: 178.33.251.53 Subject: [Qemu-devel] [PATCH 6/8] 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 pre-2.11 pseries machines can now be done directly under the irq_alloc_block() operation. let's remove ics_set_irq_type() which becomes useless. The PowerNV machine is a bit special because it does not manage its own IRQ number allocator yet. But, as it only handles the PSI interrupts which are LSIs, this is not a problem. For compatibility with older machines, we use the machine class flag 'pre_2_11_has_no_bitmap'. Signed-off-by: C=C3=A9dric Le Goater --- hw/intc/xics.c | 8 -------- hw/intc/xics_spapr.c | 9 +-------- hw/ppc/pnv_psi.c | 4 ---- hw/ppc/spapr.c | 9 ++++++++- 4 files changed, 9 insertions(+), 21 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 e1f158302a6a..23d81ff83182 100644 --- a/hw/intc/xics_spapr.c +++ b/hw/intc/xics_spapr.c @@ -264,7 +264,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; @@ -277,7 +276,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 =20 @@ -300,12 +299,6 @@ 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 - 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 d97f287118f0..557d89d9ecb5 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3598,7 +3598,7 @@ static int spapr_irq_alloc_block(XICSFabric *xi, int = count, int align, bool lsi) sPAPRMachineState *spapr =3D SPAPR_MACHINE(xi); sPAPRMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(spapr); int start =3D 0; - int srcno; + int srcno, i; =20 if (!lsi && !smc->pre_2_11_has_no_bitmap) { start =3D SPAPR_MAX_LSI; @@ -3614,6 +3614,13 @@ static int spapr_irq_alloc_block(XICSFabric *xi, int= count, int align, bool lsi) return -1; } =20 + if (lsi && smc->pre_2_11_has_no_bitmap) { + for (i =3D srcno; i < srcno + count; ++i) { + assert(!(spapr->ics->irqs[srcno].flags & XICS_FLAGS_IRQ_MASK)); + spapr->ics->irqs[srcno].flags =3D XICS_FLAGS_IRQ_LSI; + } + } + bitmap_set(spapr->irq_map, srcno, count); return srcno + spapr->irq_base; } --=20 2.13.6 From nobody Sat Nov 1 22:15:49 2025 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 150930095394662.75186369745347; Sun, 29 Oct 2017 11:15:53 -0700 (PDT) Received: from localhost ([::1]:37298 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8s7Z-0006Sh-0f for importer@patchew.org; Sun, 29 Oct 2017 14:15:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8s5N-000599-J5 for qemu-devel@nongnu.org; Sun, 29 Oct 2017 14:13:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e8s5K-00065Y-Cd for qemu-devel@nongnu.org; Sun, 29 Oct 2017 14:13:25 -0400 Received: from 10.mo178.mail-out.ovh.net ([46.105.76.150]:54277) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e8s5K-000649-6w for qemu-devel@nongnu.org; Sun, 29 Oct 2017 14:13:22 -0400 Received: from player793.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo178.mail-out.ovh.net (Postfix) with ESMTP id D9DB4637BF for ; Sun, 29 Oct 2017 19:13:20 +0100 (CET) Received: from zorba.kaod.org (ken64-2-78-199-76-109.fbx.proxad.net [78.199.76.109]) (Authenticated sender: clg@kaod.org) by player793.ha.ovh.net (Postfix) with ESMTPSA id 9798B40078; Sun, 29 Oct 2017 19:13:13 +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: Sun, 29 Oct 2017 19:12:16 +0100 Message-Id: <20171029181217.9927-8-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171029181217.9927-1-clg@kaod.org> References: <20171029181217.9927-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1891511843512224595 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddrfeekgddutdelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm 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.76.150 Subject: [Qemu-devel] [PATCH 7/8] spapr: move spapr_ics_free() under irq_free_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" So we can now use bitmap_clear() which is slightly more efficent but more important, it removes the usage of ics_valid_irq() which has a reference to the 'ics' object of the machine. Signed-off-by: C=C3=A9dric Le Goater --- hw/intc/trace-events | 2 -- hw/intc/xics_spapr.c | 19 ++----------------- hw/ppc/spapr.c | 11 ++++++++++- hw/ppc/trace-events | 2 ++ 4 files changed, 14 insertions(+), 20 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_spapr.c b/hw/intc/xics_spapr.c index 23d81ff83182..4ba23fe5125b 100644 --- a/hw/intc/xics_spapr.c +++ b/hw/intc/xics_spapr.c @@ -304,25 +304,10 @@ int spapr_ics_alloc_block(ICSState *ics, int num, boo= l lsi, return first; } =20 -static void ics_free(ICSState *ics, int irq, int num) -{ - int i; - XICSFabricClass *xic =3D XICS_FABRIC_GET_CLASS(ics->xics); - - for (i =3D irq; i < irq + num; ++i) { - if (xic->irq_test(ics->xics, i)) { - trace_xics_ics_free_warn(0, i); - } - xic->irq_free_block(ics->xics, i, 1); - } -} - 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, 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/spapr.c b/hw/ppc/spapr.c index 557d89d9ecb5..f8224ea3e894 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3629,8 +3629,17 @@ static void spapr_irq_free_block(XICSFabric *xi, int= irq, int num) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(xi); int srcno =3D irq - spapr->irq_base; + int i; =20 - bitmap_clear(spapr->irq_map, srcno, num); + 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)) { + trace_spapr_irq_free_warn(0, i); + } + } + bitmap_clear(spapr->irq_map, srcno, num); + } } =20 static bool spapr_irq_is_lsi(XICSFabric *xi, int irq) 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 Sat Nov 1 22:15:49 2025 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 1509301294081561.268424617571; Sun, 29 Oct 2017 11:21:34 -0700 (PDT) Received: from localhost ([::1]:37326 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8sD0-00021V-3w for importer@patchew.org; Sun, 29 Oct 2017 14:21:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35779) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e8s5V-0005Dr-2h for qemu-devel@nongnu.org; Sun, 29 Oct 2017 14:13:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e8s5R-0006EI-TM for qemu-devel@nongnu.org; Sun, 29 Oct 2017 14:13:33 -0400 Received: from 6.mo178.mail-out.ovh.net ([46.105.53.132]:34756) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e8s5R-0006D4-Jl for qemu-devel@nongnu.org; Sun, 29 Oct 2017 14:13:29 -0400 Received: from player793.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo178.mail-out.ovh.net (Postfix) with ESMTP id 4ECF2637D9 for ; Sun, 29 Oct 2017 19:13:28 +0100 (CET) Received: from zorba.kaod.org (ken64-2-78-199-76-109.fbx.proxad.net [78.199.76.109]) (Authenticated sender: clg@kaod.org) by player793.ha.ovh.net (Postfix) with ESMTPSA id E5BC140078; Sun, 29 Oct 2017 19:13:20 +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: Sun, 29 Oct 2017 19:12:17 +0100 Message-Id: <20171029181217.9927-9-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171029181217.9927-1-clg@kaod.org> References: <20171029181217.9927-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1893763643383581523 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddrfeekgddutdelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm 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.53.132 Subject: [Qemu-devel] [PATCH 8/8] 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 | 23 ++++++++++++----------- 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(+), 26 deletions(-) diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c index 4ba23fe5125b..3f8c937c4fa1 100644 --- a/hw/intc/xics_spapr.c +++ b/hw/intc/xics_spapr.c @@ -245,19 +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 (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, 0, lsi); + irq =3D xic->irq_alloc_block(XICS_FABRIC(spapr), 1, 0, lsi); if (irq < 0) { error_setg(errp, "can't allocate IRQ: no IRQ left"); return -1; @@ -273,11 +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); + XICSFabricClass *xic =3D XICS_FABRIC_GET_CLASS(spapr); =20 =20 /* @@ -290,9 +291,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, 0, lsi); + first =3D xic->irq_alloc_block(XICS_FABRIC(spapr), num, 0, lsi); } if (first < 0) { error_setg(errp, "can't find a free %d-IRQ block", num); @@ -304,10 +305,10 @@ 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); - xic->irq_free_block(ics->xics, irq, num); + XICSFabricClass *xic =3D XICS_FABRIC_GET_CLASS(spapr); + 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 f8224ea3e894..a5b087eb5c56 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3593,7 +3593,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); sPAPRMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(spapr); @@ -3750,7 +3751,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 292b929e88eb..943f6f235be1 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); @@ -211,8 +214,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