From nobody Mon Feb 9 19:54:05 2026 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; dkim=fail; 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 1545371925824970.8530606043826; Thu, 20 Dec 2018 21:58:45 -0800 (PST) Received: from localhost ([::1]:42435 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gaDpc-0001HC-CL for importer@patchew.org; Fri, 21 Dec 2018 00:58:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60194) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gaDdn-0000ZQ-Qj for qemu-devel@nongnu.org; Fri, 21 Dec 2018 00:46:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gaDdl-0007FS-LC for qemu-devel@nongnu.org; Fri, 21 Dec 2018 00:46:31 -0500 Received: from ozlabs.org ([203.11.71.1]:38593) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gaDdk-00072F-U9; Fri, 21 Dec 2018 00:46:29 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 43Ld0P1cGBz9sNf; Fri, 21 Dec 2018 16:46:11 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1545371173; bh=e0VF+YAPSMZV2aFaOnpiSG2n4YYtIf5JD9qBgaV3xys=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TWQu8C05UJyHaKlZUNdjS8vMVxrvEeDzvdoeC/xNbPgDPczzI7979CD7AU3/e+Q0X YLPMm+wrxRdCUe51xc8ZtSgOG/UBq22gfhH127GUnyjulN5DZdYltzR6NF2RMZTub1 yxbDi/zKJCJ9O0mDaxrGUhzIiMwlNYCPA7OuzOyY= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 21 Dec 2018 16:45:39 +1100 Message-Id: <20181221054606.22007-14-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181221054606.22007-1-david@gibson.dropbear.id.au> References: <20181221054606.22007-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 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: 203.11.71.1 Subject: [Qemu-devel] [PULL 13/40] mac_newworld: simplify IRQ wiring 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: gkurz@redhat.com, lvivier@redhat.com, Greg Kurz , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Greg Kurz The OpenPIC have 5 outputs per connected CPU. The machine init code hence needs a bi-dimensional array (smp_cpu lines, 5 columns) to wire up the irqs between the PIC and the CPUs. The current code first allocates an array of smp_cpus pointers to qemu_irq type, then it allocates another array of smp_cpus * 5 qemu_irq and fills the first array with pointers to each line of the second array. This is rather convoluted. Simplify the logic by introducing a structured type that describes all the OpenPIC outputs for a single CPU, ie, fixed size of 5 qemu_irq, and only allocate a smp_cpu sized array of those. This also allows to use g_new(T, n) instead of g_malloc(sizeof(T) * n) as recommended in HACKING. Signed-off-by: Greg Kurz Signed-off-by: David Gibson --- hw/ppc/mac_newworld.c | 30 +++++++++++++----------------- include/hw/ppc/openpic.h | 2 ++ 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index 7e45afae7c..bb19eaba36 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -115,7 +115,7 @@ static void ppc_core99_init(MachineState *machine) PowerPCCPU *cpu =3D NULL; CPUPPCState *env =3D NULL; char *filename; - qemu_irq **openpic_irqs; + IrqLines *openpic_irqs; int linux_boot, i, j, k; MemoryRegion *ram =3D g_new(MemoryRegion, 1), *bios =3D g_new(MemoryRe= gion, 1); hwaddr kernel_base, initrd_base, cmdline_base =3D 0; @@ -248,41 +248,37 @@ static void ppc_core99_init(MachineState *machine) memory_region_add_subregion(get_system_memory(), 0xf8000000, sysbus_mmio_get_region(s, 0)); =20 - openpic_irqs =3D g_malloc0(smp_cpus * sizeof(qemu_irq *)); - openpic_irqs[0] =3D - g_malloc0(smp_cpus * sizeof(qemu_irq) * OPENPIC_OUTPUT_NB); + openpic_irqs =3D g_new0(IrqLines, smp_cpus); for (i =3D 0; i < smp_cpus; i++) { /* Mac99 IRQ connection between OpenPIC outputs pins * and PowerPC input pins */ switch (PPC_INPUT(env)) { case PPC_FLAGS_INPUT_6xx: - openpic_irqs[i] =3D openpic_irqs[0] + (i * OPENPIC_OUTPUT_NB); - openpic_irqs[i][OPENPIC_OUTPUT_INT] =3D + openpic_irqs[i].irq[OPENPIC_OUTPUT_INT] =3D ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT]; - openpic_irqs[i][OPENPIC_OUTPUT_CINT] =3D + openpic_irqs[i].irq[OPENPIC_OUTPUT_CINT] =3D ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT]; - openpic_irqs[i][OPENPIC_OUTPUT_MCK] =3D + openpic_irqs[i].irq[OPENPIC_OUTPUT_MCK] =3D ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_MCP]; /* Not connected ? */ - openpic_irqs[i][OPENPIC_OUTPUT_DEBUG] =3D NULL; + openpic_irqs[i].irq[OPENPIC_OUTPUT_DEBUG] =3D NULL; /* Check this */ - openpic_irqs[i][OPENPIC_OUTPUT_RESET] =3D + openpic_irqs[i].irq[OPENPIC_OUTPUT_RESET] =3D ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_HRESET]; break; #if defined(TARGET_PPC64) case PPC_FLAGS_INPUT_970: - openpic_irqs[i] =3D openpic_irqs[0] + (i * OPENPIC_OUTPUT_NB); - openpic_irqs[i][OPENPIC_OUTPUT_INT] =3D + openpic_irqs[i].irq[OPENPIC_OUTPUT_INT] =3D ((qemu_irq *)env->irq_inputs)[PPC970_INPUT_INT]; - openpic_irqs[i][OPENPIC_OUTPUT_CINT] =3D + openpic_irqs[i].irq[OPENPIC_OUTPUT_CINT] =3D ((qemu_irq *)env->irq_inputs)[PPC970_INPUT_INT]; - openpic_irqs[i][OPENPIC_OUTPUT_MCK] =3D + openpic_irqs[i].irq[OPENPIC_OUTPUT_MCK] =3D ((qemu_irq *)env->irq_inputs)[PPC970_INPUT_MCP]; /* Not connected ? */ - openpic_irqs[i][OPENPIC_OUTPUT_DEBUG] =3D NULL; + openpic_irqs[i].irq[OPENPIC_OUTPUT_DEBUG] =3D NULL; /* Check this */ - openpic_irqs[i][OPENPIC_OUTPUT_RESET] =3D + openpic_irqs[i].irq[OPENPIC_OUTPUT_RESET] =3D ((qemu_irq *)env->irq_inputs)[PPC970_INPUT_HRESET]; break; #endif /* defined(TARGET_PPC64) */ @@ -299,7 +295,7 @@ static void ppc_core99_init(MachineState *machine) k =3D 0; for (i =3D 0; i < smp_cpus; i++) { for (j =3D 0; j < OPENPIC_OUTPUT_NB; j++) { - sysbus_connect_irq(s, k++, openpic_irqs[i][j]); + sysbus_connect_irq(s, k++, openpic_irqs[i].irq[j]); } } g_free(openpic_irqs); diff --git a/include/hw/ppc/openpic.h b/include/hw/ppc/openpic.h index 5eb982197d..dad08fe9be 100644 --- a/include/hw/ppc/openpic.h +++ b/include/hw/ppc/openpic.h @@ -20,6 +20,8 @@ enum { OPENPIC_OUTPUT_NB, }; =20 +typedef struct IrqLines { qemu_irq irq[OPENPIC_OUTPUT_NB]; } IrqLines; + #define OPENPIC_MODEL_RAVEN 0 #define OPENPIC_MODEL_FSL_MPIC_20 1 #define OPENPIC_MODEL_FSL_MPIC_42 2 --=20 2.19.2