From nobody Fri Sep 5 22:29:15 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1746141847601639.7931487965476; Thu, 1 May 2025 16:24:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uAdDI-00051m-RO; Thu, 01 May 2025 19:21:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uAdCw-0004kt-8L; Thu, 01 May 2025 19:20:47 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uAdCu-0007Gb-7m; Thu, 01 May 2025 19:20:45 -0400 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id A1ACE55D266; Fri, 02 May 2025 01:20:42 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by zero.eik.bme.hu (zero.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10028) with ESMTP id tR4n3kZLU_Vp; Fri, 2 May 2025 01:20:40 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 9C1B055D25A; Fri, 02 May 2025 01:20:40 +0200 (CEST) X-Virus-Scanned: amavisd-new at eik.bme.hu Message-ID: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 08/13] hw/ppc/pegasos2: Move PCI IRQ routing setup to a function To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin Date: Fri, 02 May 2025 01:20:40 +0200 (CEST) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1746141849260019100 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Collect steps of setting up PCI IRQ routing in one function. Signed-off-by: BALATON Zoltan --- hw/ppc/pegasos2.c | 66 +++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c index 66bceec5ef..26a571f82e 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -107,6 +107,38 @@ static void pegasos2_pci_irq(void *opaque, int n, int = level) qemu_set_irq(pm->via_pirq[n], level); } =20 +/* Set up PCI interrupt routing: lines from pci.0 and pci.1 are ORed */ +static void pegasos2_setup_pci_irq(Pegasos2MachineState *pm) +{ + for (int h =3D 0; h < 2; h++) { + DeviceState *pd; + g_autofree const char *pn =3D g_strdup_printf("pcihost%d", h); + + pd =3D DEVICE(object_resolve_path_component(OBJECT(pm->nb), pn)); + assert(pd); + for (int i =3D 0; i < PCI_NUM_PINS; i++) { + OrIRQState *ori =3D &pm->orirq[i]; + + if (h =3D=3D 0) { + g_autofree const char *n =3D g_strdup_printf("pci-orirq[%d= ]", i); + + object_initialize_child_with_props(OBJECT(pm), n, + ori, sizeof(*ori), + TYPE_OR_IRQ, &error_fat= al, + "num-lines", "2", NULL); + qdev_realize(DEVICE(ori), NULL, &error_fatal); + qemu_init_irq(&pm->pci_irqs[i], pegasos2_pci_irq, pm, i); + qdev_connect_gpio_out(DEVICE(ori), 0, &pm->pci_irqs[i]); + pm->mv_pirq[i] =3D qdev_get_gpio_in_named(pm->nb, "gpp", 1= 2 + i); + pm->via_pirq[i] =3D qdev_get_gpio_in_named(pm->sb, "pirq",= i); + } + qdev_connect_gpio_out(pd, i, qdev_get_gpio_in(DEVICE(ori), h)); + } + } + qdev_connect_gpio_out_named(pm->sb, "intr", 0, + qdev_get_gpio_in_named(pm->nb, "gpp", 31)); +} + static void pegasos2_init(MachineState *machine) { Pegasos2MachineState *pm =3D PEGASOS2_MACHINE(machine); @@ -118,7 +150,6 @@ static void pegasos2_init(MachineState *machine) I2CBus *i2c_bus; const char *fwname =3D machine->firmware ?: PROM_FILENAME; char *filename; - int i; ssize_t sz; uint8_t *spd_data; =20 @@ -169,9 +200,6 @@ static void pegasos2_init(MachineState *machine) /* Marvell Discovery II system controller */ pm->nb =3D DEVICE(sysbus_create_simple(TYPE_MV64361, -1, qdev_get_gpio_in(DEVICE(pm->cpu), PPC6xx_INPUT_I= NT))); - for (i =3D 0; i < PCI_NUM_PINS; i++) { - pm->mv_pirq[i] =3D qdev_get_gpio_in_named(pm->nb, "gpp", 12 + i); - } pci_bus =3D mv64361_get_pci_bus(pm->nb, 1); =20 /* VIA VT8231 South Bridge (multifunction PCI device) */ @@ -185,14 +213,9 @@ static void pegasos2_init(MachineState *machine) } =20 pci_realize_and_unref(PCI_DEVICE(via), pci_bus, &error_abort); - for (i =3D 0; i < PCI_NUM_PINS; i++) { - pm->via_pirq[i] =3D qdev_get_gpio_in_named(DEVICE(via), "pirq", i); - } object_property_add_alias(OBJECT(machine), "rtc-time", object_resolve_path_component(via, "rtc"), "date"); - qdev_connect_gpio_out_named(DEVICE(via), "intr", 0, - qdev_get_gpio_in_named(pm->nb, "gpp", 31)); =20 dev =3D PCI_DEVICE(object_resolve_path_component(via, "ide")); pci_ide_create_devs(dev); @@ -205,30 +228,7 @@ static void pegasos2_init(MachineState *machine) /* other PC hardware */ pci_vga_init(pci_bus); =20 - /* PCI interrupt routing: lines from pci.0 and pci.1 are ORed */ - for (int h =3D 0; h < 2; h++) { - DeviceState *pd; - g_autofree const char *pn =3D g_strdup_printf("pcihost%d", h); - - pd =3D DEVICE(object_resolve_path_component(OBJECT(pm->nb), pn)); - assert(pd); - for (i =3D 0; i < PCI_NUM_PINS; i++) { - OrIRQState *ori =3D &pm->orirq[i]; - - if (h =3D=3D 0) { - g_autofree const char *n =3D g_strdup_printf("pci-orirq[%d= ]", i); - - object_initialize_child_with_props(OBJECT(pm), n, - ori, sizeof(*ori), - TYPE_OR_IRQ, &error_fat= al, - "num-lines", "2", NULL); - qdev_realize(DEVICE(ori), NULL, &error_fatal); - qemu_init_irq(&pm->pci_irqs[i], pegasos2_pci_irq, pm, i); - qdev_connect_gpio_out(DEVICE(ori), 0, &pm->pci_irqs[i]); - } - qdev_connect_gpio_out(pd, i, qdev_get_gpio_in(DEVICE(ori), h)); - } - } + pegasos2_setup_pci_irq(pm); =20 if (machine->kernel_filename) { sz =3D load_elf(machine->kernel_filename, NULL, NULL, NULL, --=20 2.41.3