From nobody Mon Feb 9 01:05:06 2026 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=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1608938427; cv=none; d=zohomail.com; s=zohoarc; b=ZI71QTp2t73vFwG1DHp3Crkxdu/cjM8ryc/bJ9FaXO0UZKGZghpN6xquG0PSKJBj2KY04d2ZLqMr16j2E18GL2ODdFPYDwRQzRRvW8efr46Cqm7aMlHg3fGwkp+97X/66ha3QmsuIFr+IY6PKL0ek93KqLQ9FzPCOICi5IkJebk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608938427; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=ap7CRb5SEejDLe06323nvnjjH7eqyHtj/1mtqjyI4zI=; b=BMFmfCM7YCXef+TISVo3kXFqxwm/LjRWpGcgPaKQfUJqArhxiq/5nVZNMZ+BWFaoMwpoMFpsgDpqARjz+iO1S2xVCSmgZ/Uh1R+rhnE8Wcn3grwjQJJ33za8UDZD6ZHsyF6GUhl6P6oVo0w8gnEDohM3J8lLNSjXar9SyekDFC0= ARC-Authentication-Results: i=1; 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=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1608938427266457.5940638406055; Fri, 25 Dec 2020 15:20:27 -0800 (PST) Received: from localhost ([::1]:40034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kswNk-0004ax-9a for importer@patchew.org; Fri, 25 Dec 2020 18:20:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33902) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kswKO-000146-TY; Fri, 25 Dec 2020 18:16:56 -0500 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:48598) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kswKK-0006ae-TK; Fri, 25 Dec 2020 18:16:56 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 704507470EC; Sat, 26 Dec 2020 00:16:49 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id D30AD7470DF; Sat, 26 Dec 2020 00:16:48 +0100 (CET) Message-Id: <7df2e39f5229780c2ebf05b2efe0d8ce12d0766a.1608937677.git.balaton@eik.bme.hu> In-Reply-To: References: Subject: [PATCH 3/3] sam460ex: Clean up irq mapping Date: Sat, 26 Dec 2020 00:07:57 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org X-Spam-Probability: 8% 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=2001:738:2001:2001::2001; 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, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Mark Cave-Ayland , Guenter Roeck , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Reply-to: BALATON Zoltan From: BALATON Zoltan via Content-Type: text/plain; charset="utf-8" Avoid mapping multiple interrupts to the same irq. Instead map them to the 4 PCI interrupts and use an or-gate in the board to connect them to the interrupt controller. This does not fix any known problem but does not seem to cause a new problem either and may be cleaner at least. Signed-off-by: BALATON Zoltan Tested-by: Guenter Roeck --- hw/ppc/Kconfig | 1 + hw/ppc/ppc440_pcix.c | 28 ++++++++++++++-------------- hw/ppc/sam460ex.c | 16 +++++++++++++--- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/hw/ppc/Kconfig b/hw/ppc/Kconfig index 5893f80909..fabdb1a96f 100644 --- a/hw/ppc/Kconfig +++ b/hw/ppc/Kconfig @@ -58,6 +58,7 @@ config SAM460EX select PFLASH_CFI01 select IDE_SII3112 select M41T80 + select OR_IRQ select PPC440 select SM501 select SMBUS_EEPROM diff --git a/hw/ppc/ppc440_pcix.c b/hw/ppc/ppc440_pcix.c index ee952314c8..504decbbc2 100644 --- a/hw/ppc/ppc440_pcix.c +++ b/hw/ppc/ppc440_pcix.c @@ -57,8 +57,8 @@ struct PPC440PCIXState { PCIDevice *dev; struct PLBOutMap pom[PPC440_PCIX_NR_POMS]; struct PLBInMap pim[PPC440_PCIX_NR_PIMS]; + qemu_irq irq[PCI_NUM_PINS]; uint32_t sts; - qemu_irq irq; AddressSpace bm_as; MemoryRegion bm; =20 @@ -415,24 +415,20 @@ static void ppc440_pcix_reset(DeviceState *dev) s->sts =3D 0; } =20 -/* All pins from each slot are tied to a single board IRQ. - * This may need further refactoring for other boards. */ static int ppc440_pcix_map_irq(PCIDevice *pci_dev, int irq_num) { - trace_ppc440_pcix_map_irq(pci_dev->devfn, irq_num, 0); - return 0; + int n =3D (irq_num + PCI_SLOT(pci_dev->devfn)) % PCI_NUM_PINS; + + trace_ppc440_pcix_map_irq(pci_dev->devfn, irq_num, n); + return n; } =20 static void ppc440_pcix_set_irq(void *opaque, int irq_num, int level) { - qemu_irq *pci_irq =3D opaque; + qemu_irq *pci_irqs =3D opaque; =20 trace_ppc440_pcix_set_irq(irq_num); - if (irq_num < 0) { - error_report("%s: PCI irq %d", __func__, irq_num); - return; - } - qemu_set_irq(*pci_irq, level); + qemu_set_irq(pci_irqs[irq_num], level); } =20 static AddressSpace *ppc440_pcix_set_iommu(PCIBus *b, void *opaque, int de= vfn) @@ -472,15 +468,19 @@ static void ppc440_pcix_realize(DeviceState *dev, Err= or **errp) SysBusDevice *sbd =3D SYS_BUS_DEVICE(dev); PPC440PCIXState *s; PCIHostState *h; + int i; =20 h =3D PCI_HOST_BRIDGE(dev); s =3D PPC440_PCIX_HOST_BRIDGE(dev); =20 - sysbus_init_irq(sbd, &s->irq); + for (i =3D 0; i < ARRAY_SIZE(s->irq); i++) { + sysbus_init_irq(sbd, &s->irq[i]); + } memory_region_init(&s->busmem, OBJECT(dev), "pci bus memory", UINT64_M= AX); h->bus =3D pci_register_root_bus(dev, NULL, ppc440_pcix_set_irq, - ppc440_pcix_map_irq, &s->irq, &s->busmem, - get_system_io(), PCI_DEVFN(0, 0), 1, TYPE_PCI_BUS= ); + ppc440_pcix_map_irq, s->irq, &s->busmem, + get_system_io(), PCI_DEVFN(0, 0), ARRAY_SIZE(s->i= rq), + TYPE_PCI_BUS); =20 s->dev =3D pci_create_simple(h->bus, PCI_DEVFN(0, 0), "ppc4xx-host-bri= dge"); =20 diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c index 14e6583eb0..59b19fbca1 100644 --- a/hw/ppc/sam460ex.c +++ b/hw/ppc/sam460ex.c @@ -33,6 +33,7 @@ #include "sysemu/qtest.h" #include "sysemu/reset.h" #include "hw/sysbus.h" +#include "hw/or-irq.h" #include "hw/char/serial.h" #include "hw/i2c/ppc4xx_i2c.h" #include "hw/i2c/smbus_eeprom.h" @@ -292,7 +293,7 @@ static void sam460ex_init(MachineState *machine) SysBusDevice *sbdev; struct boot_info *boot_info; uint8_t *spd_data; - int success; + int i, success; =20 cpu =3D POWERPC_CPU(cpu_create(machine->cpu_type)); env =3D &cpu->env; @@ -382,13 +383,22 @@ static void sam460ex_init(MachineState *machine) =20 /* PCI bus */ ppc460ex_pcie_init(env); - /* All PCI irqs are connected to the same UIC pin (cf. UBoot source) */ - dev =3D sysbus_create_simple("ppc440-pcix-host", 0xc0ec00000, uic[1][0= ]); + dev =3D sysbus_create_simple("ppc440-pcix-host", 0xc0ec00000, NULL); pci_bus =3D (PCIBus *)qdev_get_child_bus(dev, "pci.0"); if (!pci_bus) { error_report("couldn't create PCI controller!"); exit(1); } + /* All PCI irqs are connected to the same UIC pin (cf. UBoot source) */ + sbdev =3D SYS_BUS_DEVICE(dev); + dev =3D qdev_new(TYPE_OR_IRQ); + object_property_set_int(OBJECT(dev), "num-lines", PCI_NUM_PINS, + &error_fatal); + qdev_realize_and_unref(dev, NULL, &error_fatal); + for (i =3D 0; i < PCI_NUM_PINS; i++) { + sysbus_connect_irq(sbdev, i, qdev_get_gpio_in(dev, i)); + } + qdev_connect_gpio_out(dev, 0, uic[1][0]); memory_region_init_alias(isa, NULL, "isa_mmio", get_system_io(), 0, 0x10000); memory_region_add_subregion(get_system_memory(), 0xc08000000, isa); --=20 2.21.3