From nobody Tue May 14 02:27:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1668956859; cv=none; d=zohomail.com; s=zohoarc; b=gMHCJQ5ZFLKPlTdici4evcnEljuGE8BflJWR0GFGeuC+FNii2ULqRadJpntjMQppZCNnV8I7IxWtw70DSAB3wjX9J59zYPdF+PLdPWRDAQLXPMO1JFZ+3FY/aLTxgZNlvjZWkoVe/z8ERQqRrj8SQKndIKv4jM2lgILLj/23s+A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668956859; h=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:References:Sender:Subject:To; bh=RupXXG9LxqizCm25x5DZfegVWd8XQCxByXgEiCGa2SA=; b=eDlno2TQp/3TUISQunqFiTUfc4kkl/85kkwu0iJExAprhaEiUwqayKa0V0zSlJugBOMLXBKsuYFMqtngGjjpW2US8qQFRVjt82B1RdrgG/YnwUPfepv/aWxYaauZHINctOdPhGrVWj9xtNObS8s5FTWS5S5U8xEt6wz1tXEZmbw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1668956859506595.8273049678987; Sun, 20 Nov 2022 07:07:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1owlu3-0002Hh-9T; Sun, 20 Nov 2022 10:06:39 -0500 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 1owlu1-0002HH-OS; Sun, 20 Nov 2022 10:06:37 -0500 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1owltz-0001xH-OG; Sun, 20 Nov 2022 10:06:37 -0500 Received: by mail-ej1-x62d.google.com with SMTP id n12so23389552eja.11; Sun, 20 Nov 2022 07:06:34 -0800 (PST) Received: from localhost.localdomain (dynamic-077-013-067-205.77.13.pool.telefonica.de. [77.13.67.205]) by smtp.gmail.com with ESMTPSA id u10-20020a1709061daa00b007b2a3cad2cfsm4026785ejh.132.2022.11.20.07.06.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Nov 2022 07:06:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RupXXG9LxqizCm25x5DZfegVWd8XQCxByXgEiCGa2SA=; b=EecpGOO+oX4jGiep077zUttl5GqnN/LTL4zbMWKdzqfOxF2kEEfjXa984wcVWbLU9Z CbtmGovwCUvvWxUwGo0QZWQHCBk8v07PeM4ZCw+Zu7RJjzcsZmR5K2ioqYjDFArYhRLE pjKZSkKzqpCkg3mmqx1Rei80eUj6czdIkE6y2wo611+51b2M3ho2F37nPRuKTXVWuNzW GKDM1h85GjVnB9mLWcNnsWD2Wu1twKouPQ4OhcgHE24fbul9W5DkRgikPmI3CkxtqzUb VikMToTtJxes7tEFfg4vxy8ivQv+Fm6LmA2q6TxLfNygjP0dbwB8dYnoJL5z46n5yVEy gnuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RupXXG9LxqizCm25x5DZfegVWd8XQCxByXgEiCGa2SA=; b=dUxnTkRS/Y5J9mUBLTaGzS37I61981MTmAm/BGTc+jomP0PB9XHObqOEzSUB32BiWB FRkCybyXrQ3STy5XKgDOqKweEyJJbHcgWe6VB1FuG0t5vcO+BYxet7aY2IC2kCcpQ9te qRRVAIQkQksjdeDf/uEr7mXv9RXNk3xo18e6a4ToGNtMfQiPZqMl+idi4pXCkNGXOHCm 0aw/vvPp8VkzEv+dd3xTIfWx2jRED6EXRruUaMhmBv68U4ND/S+RZWQxN/id7micfOiB USSlpk7DnTFDLAXihvSnWgjoGJ5FeMK0CXUm/c/AdJhbHaAjWJTCPXSNz4+ZOhLmC9eE oCQw== X-Gm-Message-State: ANoB5pmLbeyxjc/UBsf87csh2ukNFCUrekCyPAVOLhy83WETuUcyGluB cYilAQBUr57C+xkcQ30/KLiNeKBy8rc= X-Google-Smtp-Source: AA0mqf6MYpKXFgkxCJ/ncrXsp9tZqca5Xouf4ywcs9vFL0RUbWcggUjFDxifj5FG3j9O6zdq3CSAMQ== X-Received: by 2002:a17:906:fcd0:b0:7ad:b8c0:3057 with SMTP id qx16-20020a170906fcd000b007adb8c03057mr12455927ejb.440.1668956793445; Sun, 20 Nov 2022 07:06:33 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: John G Johnson , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Huacai Chen , Jiaxun Yang , Aurelien Jarno , Paolo Bonzini , Marcel Apfelbaum , "Michael S. Tsirkin" , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Elena Ufimtseva , Eduardo Habkost , Jagannathan Raman , Richard Henderson , qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Bernhard Beschow Subject: [PATCH v2 1/3] hw/pci/pci: Factor out pci_bus_map_irqs() from pci_bus_irqs() Date: Sun, 20 Nov 2022 16:05:48 +0100 Message-Id: <20221120150550.63059-2-shentey@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221120150550.63059-1-shentey@gmail.com> References: <20221120150550.63059-1-shentey@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::62d; envelope-from=shentey@gmail.com; helo=mail-ej1-x62d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1668956860528100003 Content-Type: text/plain; charset="utf-8" pci_bus_irqs() coupled together the assignment of pci_set_irq_fn and pci_map_irq_fn to a PCI bus. This coupling gets in the way when the pci_map_irq_fn is board-specific while the pci_set_irq_fn is device- specific. For example, both of QEMU's PIIX south bridge models have different pci_map_irq_fn implementations which are board-specific rather than device-specific. These implementations should therefore reside in board code. The pci_set_irq_fn's, however, should stay in the device models because they access memory internal to the model. Factoring out pci_bus_map_irqs() from pci_bus_irqs() allows the assignments to be decoupled, resolving the problem described above. Note also how pci_vpb_realize() which gets touched in this commit assigns different pci_map_irq_fn's depending on the board. Signed-off-by: Bernhard Beschow Acked-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/i386/pc_q35.c | 4 ++-- hw/isa/piix3.c | 8 ++++---- hw/isa/piix4.c | 3 ++- hw/pci-host/raven.c | 3 ++- hw/pci-host/versatile.c | 3 ++- hw/pci/pci.c | 12 +++++++++--- hw/remote/machine.c | 3 ++- include/hw/pci/pci.h | 3 ++- 8 files changed, 25 insertions(+), 14 deletions(-) diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index a496bd6e74..39f035903c 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -268,8 +268,8 @@ static void pc_q35_init(MachineState *machine) for (i =3D 0; i < GSI_NUM_PINS; i++) { qdev_connect_gpio_out_named(lpc_dev, ICH9_GPIO_GSI, i, x86ms->gsi[= i]); } - pci_bus_irqs(host_bus, ich9_lpc_set_irq, ich9_lpc_map_irq, ich9_lpc, - ICH9_LPC_NB_PIRQS); + pci_bus_irqs(host_bus, ich9_lpc_set_irq, ich9_lpc, ICH9_LPC_NB_PIRQS); + pci_bus_map_irqs(host_bus, ich9_lpc_map_irq); pci_bus_set_route_irq_fn(host_bus, ich9_route_intx_pin_to_irq); isa_bus =3D ich9_lpc->isa_bus; =20 diff --git a/hw/isa/piix3.c b/hw/isa/piix3.c index f9b4af5c05..7ad26b82e8 100644 --- a/hw/isa/piix3.c +++ b/hw/isa/piix3.c @@ -388,8 +388,8 @@ static void piix3_realize(PCIDevice *dev, Error **errp) return; } =20 - pci_bus_irqs(pci_bus, piix3_set_irq, pci_slot_get_pirq, - piix3, PIIX_NUM_PIRQS); + pci_bus_irqs(pci_bus, piix3_set_irq, piix3, PIIX_NUM_PIRQS); + pci_bus_map_irqs(pci_bus, pci_slot_get_pirq); pci_bus_set_route_irq_fn(pci_bus, piix3_route_intx_pin_to_irq); } =20 @@ -424,8 +424,8 @@ static void piix3_xen_realize(PCIDevice *dev, Error **e= rrp) * connected to the IOAPIC directly. * These additional routes can be discovered through ACPI. */ - pci_bus_irqs(pci_bus, xen_piix3_set_irq, xen_pci_slot_get_pirq, - piix3, XEN_PIIX_NUM_PIRQS); + pci_bus_irqs(pci_bus, xen_piix3_set_irq, piix3, XEN_PIIX_NUM_PIRQS); + pci_bus_map_irqs(pci_bus, xen_pci_slot_get_pirq); } =20 static void piix3_xen_class_init(ObjectClass *klass, void *data) diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c index 8fc1db6dc9..f9211d085f 100644 --- a/hw/isa/piix4.c +++ b/hw/isa/piix4.c @@ -271,7 +271,8 @@ static void piix4_realize(PCIDevice *dev, Error **errp) } qdev_connect_gpio_out(DEVICE(&s->pm), 0, s->isa[9]); =20 - pci_bus_irqs(pci_bus, piix4_set_irq, pci_slot_get_pirq, s, PIIX_NUM_PI= RQS); + pci_bus_irqs(pci_bus, piix4_set_irq, s, PIIX_NUM_PIRQS); + pci_bus_map_irqs(pci_bus, pci_slot_get_pirq); } =20 static void piix4_init(Object *obj) diff --git a/hw/pci-host/raven.c b/hw/pci-host/raven.c index 7a105e4a63..2db577df4f 100644 --- a/hw/pci-host/raven.c +++ b/hw/pci-host/raven.c @@ -258,7 +258,8 @@ static void raven_pcihost_realizefn(DeviceState *d, Err= or **errp) =20 qdev_init_gpio_in(d, raven_change_gpio, 1); =20 - pci_bus_irqs(&s->pci_bus, raven_set_irq, raven_map_irq, s, PCI_NUM_PIN= S); + pci_bus_irqs(&s->pci_bus, raven_set_irq, s, PCI_NUM_PINS); + pci_bus_map_irqs(&s->pci_bus, raven_map_irq); =20 memory_region_init_io(&h->conf_mem, OBJECT(h), &pci_host_conf_le_ops, = s, "pci-conf-idx", 4); diff --git a/hw/pci-host/versatile.c b/hw/pci-host/versatile.c index f66384fa02..c77a999955 100644 --- a/hw/pci-host/versatile.c +++ b/hw/pci-host/versatile.c @@ -422,7 +422,8 @@ static void pci_vpb_realize(DeviceState *dev, Error **e= rrp) mapfn =3D pci_vpb_map_irq; } =20 - pci_bus_irqs(&s->pci_bus, pci_vpb_set_irq, mapfn, s->irq, 4); + pci_bus_irqs(&s->pci_bus, pci_vpb_set_irq, s->irq, 4); + pci_bus_map_irqs(&s->pci_bus, mapfn); =20 /* Our memory regions are: * 0 : our control registers diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 2f450f6a72..6396cde004 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -283,6 +283,7 @@ static void pci_change_irq_level(PCIDevice *pci_dev, in= t irq_num, int change) PCIBus *bus; for (;;) { bus =3D pci_get_bus(pci_dev); + assert(bus->map_irq); irq_num =3D bus->map_irq(pci_dev, irq_num); if (bus->set_irq) break; @@ -521,16 +522,20 @@ void pci_root_bus_cleanup(PCIBus *bus) qbus_unrealize(BUS(bus)); } =20 -void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq, pci_map_irq_fn map_= irq, +void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq, void *irq_opaque, int nirq) { bus->set_irq =3D set_irq; - bus->map_irq =3D map_irq; bus->irq_opaque =3D irq_opaque; bus->nirq =3D nirq; bus->irq_count =3D g_malloc0(nirq * sizeof(bus->irq_count[0])); } =20 +void pci_bus_map_irqs(PCIBus *bus, pci_map_irq_fn map_irq) +{ + bus->map_irq =3D map_irq; +} + void pci_bus_irqs_cleanup(PCIBus *bus) { bus->set_irq =3D NULL; @@ -552,7 +557,8 @@ PCIBus *pci_register_root_bus(DeviceState *parent, cons= t char *name, =20 bus =3D pci_root_bus_new(parent, name, address_space_mem, address_space_io, devfn_min, typename); - pci_bus_irqs(bus, set_irq, map_irq, irq_opaque, nirq); + pci_bus_irqs(bus, set_irq, irq_opaque, nirq); + pci_bus_map_irqs(bus, map_irq); return bus; } =20 diff --git a/hw/remote/machine.c b/hw/remote/machine.c index 75d550daae..519f855ec1 100644 --- a/hw/remote/machine.c +++ b/hw/remote/machine.c @@ -63,8 +63,9 @@ static void remote_machine_init(MachineState *machine) } else { remote_iohub_init(&s->iohub); =20 - pci_bus_irqs(pci_host->bus, remote_iohub_set_irq, remote_iohub_map= _irq, + pci_bus_irqs(pci_host->bus, remote_iohub_set_irq, &s->iohub, REMOTE_IOHUB_NB_PIRQS); + pci_bus_map_irqs(pci_host->bus, remote_iohub_map_irq); } =20 qbus_set_hotplug_handler(BUS(pci_host->bus), OBJECT(s)); diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 6ccaaf5154..01ea267253 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -446,8 +446,9 @@ PCIBus *pci_root_bus_new(DeviceState *parent, const cha= r *name, MemoryRegion *address_space_io, uint8_t devfn_min, const char *typename); void pci_root_bus_cleanup(PCIBus *bus); -void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq, pci_map_irq_fn map_= irq, +void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq, void *irq_opaque, int nirq); +void pci_bus_map_irqs(PCIBus *bus, pci_map_irq_fn map_irq); void pci_bus_irqs_cleanup(PCIBus *bus); int pci_bus_get_irq_level(PCIBus *bus, int irq_num); /* 0 <=3D pin <=3D 3 0 =3D INTA, 1 =3D INTB, 2 =3D INTC, 3 =3D INTD */ --=20 2.38.1 From nobody Tue May 14 02:27:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1668956837; cv=none; d=zohomail.com; s=zohoarc; b=cm0U3z6C2vDg44wMBaakg7b0fFYFcrNS0b9pzmX1oTilhvG8ksDzf86Ui9CFFDciKVrpia8SaENWxQ8PiG29ZUgc7idGVCPFfQ44aw+izLr3wosAVgAZ2ZC5QT3AfB5typw5G17vDhqAv0EMEf+VWRZRhtYZgp76wjhCEHZ4wrE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668956837; h=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:References:Sender:Subject:To; bh=dkQTfg08VbNig6GdBRLWj6lsjB4ZP5VrJ/GDbk7xlCk=; b=NXMaqK2OMaI3oOMQICX2ByjGbgTcTiRaIhnzZf2wO0vUEYNJ1tSpUozpBQ86F9qyaI2g/58gkPNvYPKW4fcKuHNYomXVj9m2Lj3HxTWSG+gWGG/jmwfeTpriFqnLFQVTNuj3HRrP02Zr+mGJhrUSojStSv3KAHoyKfwAYhjho3k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1668956837915926.7369521972649; Sun, 20 Nov 2022 07:07:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1owlu4-0002Iy-NA; Sun, 20 Nov 2022 10:06:40 -0500 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 1owlu3-0002IJ-QS; Sun, 20 Nov 2022 10:06:39 -0500 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1owlu2-0001xV-6F; Sun, 20 Nov 2022 10:06:39 -0500 Received: by mail-ed1-x536.google.com with SMTP id b8so2314981edf.11; Sun, 20 Nov 2022 07:06:36 -0800 (PST) Received: from localhost.localdomain (dynamic-077-013-067-205.77.13.pool.telefonica.de. [77.13.67.205]) by smtp.gmail.com with ESMTPSA id u10-20020a1709061daa00b007b2a3cad2cfsm4026785ejh.132.2022.11.20.07.06.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Nov 2022 07:06:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dkQTfg08VbNig6GdBRLWj6lsjB4ZP5VrJ/GDbk7xlCk=; b=mApgodRuAqIWbyxGLeZzrhTnup4TWlSMWDrzaBIDWNRo7LttKtfn8CxuvbLKFAlXOg n7QwWTzy1GmWC/EHJxVP/xHUVFp2czqq2+uV4aonnLCTJ0SRPuIAFzZsy5CYrK1gr7k2 IN1heOxj3+PuZGoaQsANgeDX4paCbER6j96GoFXvukXd2ag+ZNW5xWWIrwj638+bMcvX U9QNSP/4B7ufUqwMXEycZXKxFkOMLCTQDj+Fw6zOJnGzqNSPX1wjvG6+XtkoirMgk5Cv lBH31vQyMdLSziZz9yo7bAcb55ffuaFL4mQnqhOCihArv5vHs+3yD5SvvLsL8ISF8Iyr fM2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dkQTfg08VbNig6GdBRLWj6lsjB4ZP5VrJ/GDbk7xlCk=; b=pcFW2kwo1w87Ld1cLBHPf4N0RuEZiX1Uc8DW3S8yBSB2AiVbXAhJ87/9LK5A/+XRg0 fVUEs7kkNaXqGy19qrgLP7b8G6FTn8Ab33aDEYGkn8oPso0cOdGKGFe9bYxjuwafgu1+ zpfZ53b70kRlkQYoNm/kmkzPIMTvI1TKoOMEk5E9+jBz9z7BpA3/Zx47EmdLp9BAC8l6 TJT5fuYDwwKQaugW1WGLIebWjyw2XrG/rkveD74Cg3fmlZg6vMgs+vQdH8Wnp2WNRuQP xmhpwp3sCdexuUdgNAnOfdHX55m5x4trA38sTsjivIOYICUcri72tVV0jqOEWocZj+Ix dfNg== X-Gm-Message-State: ANoB5pnhQMo7tW4tWNr297Wfj/7Yv/SYlAAuV5eSsPp/fFPSO7kFjyO8 3miD3LEJ5lPg/ROTMjlJIoq3Q0T7rZ8= X-Google-Smtp-Source: AA0mqf5pmbIBol28hejVecmX2zVuk/a2DNlufyPZowVsm736L3WJRweJuabEhEghD+mX7VMKjrGGQg== X-Received: by 2002:aa7:dc0c:0:b0:461:6f87:20bb with SMTP id b12-20020aa7dc0c000000b004616f8720bbmr12726589edu.300.1668956795148; Sun, 20 Nov 2022 07:06:35 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: John G Johnson , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Huacai Chen , Jiaxun Yang , Aurelien Jarno , Paolo Bonzini , Marcel Apfelbaum , "Michael S. Tsirkin" , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Elena Ufimtseva , Eduardo Habkost , Jagannathan Raman , Richard Henderson , qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Bernhard Beschow Subject: [PATCH v2 2/3] hw/isa/piix3: Decouple INTx-to-LNKx routing which is board-specific Date: Sun, 20 Nov 2022 16:05:49 +0100 Message-Id: <20221120150550.63059-3-shentey@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221120150550.63059-1-shentey@gmail.com> References: <20221120150550.63059-1-shentey@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::536; envelope-from=shentey@gmail.com; helo=mail-ed1-x536.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1668956838872100001 Content-Type: text/plain; charset="utf-8" pci_map_irq_fn's in general seem to be board-specific. So move PIIX3's pci_slot_get_pirq() to board code to not have PIIX3 make assuptions about its board. Signed-off-by: Bernhard Beschow Acked-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/i386/pc_piix.c | 16 ++++++++++++++++ hw/isa/piix3.c | 13 ------------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 0ad0ed1603..ecae85a31e 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -47,6 +47,7 @@ #include "hw/sysbus.h" #include "hw/i2c/smbus_eeprom.h" #include "hw/xen/xen-x86.h" +#include "hw/xen/xen.h" #include "exec/memory.h" #include "hw/acpi/acpi.h" #include "hw/acpi/piix4.h" @@ -73,6 +74,17 @@ static const int ide_iobase2[MAX_IDE_BUS] =3D { 0x3f6, 0= x376 }; static const int ide_irq[MAX_IDE_BUS] =3D { 14, 15 }; #endif =20 +/* + * Return the global irq number corresponding to a given device irq + * pin. We could also use the bus number to have a more precise mapping. + */ +static int pci_slot_get_pirq(PCIDevice *pci_dev, int pci_intx) +{ + int slot_addend; + slot_addend =3D PCI_SLOT(pci_dev->devfn) - 1; + return (pci_intx + slot_addend) & 3; +} + /* PC hardware initialisation */ static void pc_init1(MachineState *machine, const char *host_type, const char *pci_type) @@ -223,6 +235,10 @@ static void pc_init1(MachineState *machine, piix3->pic =3D x86ms->gsi; piix3_devfn =3D piix3->dev.devfn; isa_bus =3D ISA_BUS(qdev_get_child_bus(DEVICE(piix3), "isa.0")); + + pci_bus_map_irqs(pci_bus, + xen_enabled() ? xen_pci_slot_get_pirq + : pci_slot_get_pirq); } else { pci_bus =3D NULL; isa_bus =3D isa_bus_new(NULL, get_system_memory(), system_io, diff --git a/hw/isa/piix3.c b/hw/isa/piix3.c index 7ad26b82e8..30509f39e5 100644 --- a/hw/isa/piix3.c +++ b/hw/isa/piix3.c @@ -79,17 +79,6 @@ static void piix3_set_irq(void *opaque, int pirq, int le= vel) piix3_set_irq_level(piix3, pirq, level); } =20 -/* - * Return the global irq number corresponding to a given device irq - * pin. We could also use the bus number to have a more precise mapping. - */ -static int pci_slot_get_pirq(PCIDevice *pci_dev, int pci_intx) -{ - int slot_addend; - slot_addend =3D PCI_SLOT(pci_dev->devfn) - 1; - return (pci_intx + slot_addend) & 3; -} - static PCIINTxRoute piix3_route_intx_pin_to_irq(void *opaque, int pin) { PIIX3State *piix3 =3D opaque; @@ -389,7 +378,6 @@ static void piix3_realize(PCIDevice *dev, Error **errp) } =20 pci_bus_irqs(pci_bus, piix3_set_irq, piix3, PIIX_NUM_PIRQS); - pci_bus_map_irqs(pci_bus, pci_slot_get_pirq); pci_bus_set_route_irq_fn(pci_bus, piix3_route_intx_pin_to_irq); } =20 @@ -425,7 +413,6 @@ static void piix3_xen_realize(PCIDevice *dev, Error **e= rrp) * These additional routes can be discovered through ACPI. */ pci_bus_irqs(pci_bus, xen_piix3_set_irq, piix3, XEN_PIIX_NUM_PIRQS); - pci_bus_map_irqs(pci_bus, xen_pci_slot_get_pirq); } =20 static void piix3_xen_class_init(ObjectClass *klass, void *data) --=20 2.38.1 From nobody Tue May 14 02:27:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1668956854; cv=none; d=zohomail.com; s=zohoarc; b=BsFY6u7LSvREGGuHm2aaNdUJ1duGm6Wu5HQOnfHU5AWdJ3gWlFVuyT16MrybaAALr8q/j3V4Rl6KgLY9kA/ML6NkOsFyN5qYUKoh9dF3j6JPptK11+elGSkwXtWMKsD4cN+Y/XflVIKd9b301E8ZJjR8ZtWp+jytt6EOP9RAI3o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668956854; h=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:References:Sender:Subject:To; bh=0Zh5kljSKyLV2en7a07D0RyTRcfllpFZEVpu0lha4HU=; b=SjfNXRuHmXLBu+BWDtO4KdpxrioVxphy2Z/myQoE/GslRC5y7LQ/wBD0f8pk9wy8UROh0CqeNQ8UnxZsYmXoL6SnGUoLuqAjQTfUll6c2/aYPWHBFmQ3u+eE0a7VjbjJH2s80cgIIyleqTl/AyBl/b2lczYumwja/Jzxc8HJDvA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1668956854868379.08302109138253; Sun, 20 Nov 2022 07:07:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1owlu6-0002KL-A6; Sun, 20 Nov 2022 10:06:42 -0500 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 1owlu5-0002JR-7D; Sun, 20 Nov 2022 10:06:41 -0500 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1owlu3-0001xl-Cz; Sun, 20 Nov 2022 10:06:40 -0500 Received: by mail-ej1-x633.google.com with SMTP id m22so23387426eji.10; Sun, 20 Nov 2022 07:06:38 -0800 (PST) Received: from localhost.localdomain (dynamic-077-013-067-205.77.13.pool.telefonica.de. [77.13.67.205]) by smtp.gmail.com with ESMTPSA id u10-20020a1709061daa00b007b2a3cad2cfsm4026785ejh.132.2022.11.20.07.06.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Nov 2022 07:06:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0Zh5kljSKyLV2en7a07D0RyTRcfllpFZEVpu0lha4HU=; b=fJk2e5FTLNeAu8w5XXddGM0l9T0K8W37jumtAcoQ1pasLTAsRkB8HnwP1D7uzXYf5k DJ1DbWoHnjS8pUlRS9Sr9Ng0efjldfYp1cEqmGJ7FaD9vM+hf9vF+HqDsg+/ju2qkx6U AfK9FcSCBBbLdrJv1qifZpAccsr9WED5xwePAKNKIxMtYoQbxh4d3emGsMpwsGIn24Em G1L8nvLhHH0ZHhz2ljwjf9fifNrQXy76o11PmileFXCt4jjbalCCXDyLP1T7qlg4jba8 M25PY+zoPZAbkg6c0QcK6fmau+l1aKZd/aPGE27IHhRevrggSUl1Sw8BAGNNDruWK8Ea xsUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0Zh5kljSKyLV2en7a07D0RyTRcfllpFZEVpu0lha4HU=; b=FW5nzy8lCDdwqq081FdfcwWMDwC4QwZbix1RRCDZksqGwLJWAZPPtnzBnmWSZHL2/d wl27xQ1xFgXEHA343LiMV06pOyBJqGhKpNN71Q7t2nuNmt15GZ2lkYtru0krIr+3HhLf mTrWerDwRr4Tco9bO9yJriMtlYPYvoTCcTtRt15pmJc/sCj1PAaNoEKlPvWxOxxNI69q xNTr0VT1B2RRcAQet2CByc6XkGWb0VCEymi9Jm0mfZ3G6jbhDJBcXnZO/41BByySIHfO 8NZArgN+AvKvGAbD+4bQBI8Wk88E+pydnM9/MipBL8oNcRGy/hBqqprjKoalvCjxFzL4 XHIQ== X-Gm-Message-State: ANoB5pl0HY1aBRc8cuXXVmQqF2suK90EKZMWFUGTr2x17NBnQ9TyWP0U iFgWi5PExPBkfeX8FsaHg5IHu2goLKI= X-Google-Smtp-Source: AA0mqf5cKphuOh8pzn7WzNY+JoeS33iZ4JlPEN2FvPREDFodMamcjjhsJ1fHmd0OF1GUWg8pwbMnqA== X-Received: by 2002:a17:906:706:b0:7ac:2e16:eb05 with SMTP id y6-20020a170906070600b007ac2e16eb05mr12937504ejb.26.1668956796802; Sun, 20 Nov 2022 07:06:36 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: John G Johnson , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Huacai Chen , Jiaxun Yang , Aurelien Jarno , Paolo Bonzini , Marcel Apfelbaum , "Michael S. Tsirkin" , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Elena Ufimtseva , Eduardo Habkost , Jagannathan Raman , Richard Henderson , qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Bernhard Beschow Subject: [PATCH v2 3/3] hw/isa/piix4: Decouple INTx-to-LNKx routing which is board-specific Date: Sun, 20 Nov 2022 16:05:50 +0100 Message-Id: <20221120150550.63059-4-shentey@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221120150550.63059-1-shentey@gmail.com> References: <20221120150550.63059-1-shentey@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::633; envelope-from=shentey@gmail.com; helo=mail-ej1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1668956856482100003 Content-Type: text/plain; charset="utf-8" pci_map_irq_fn's in general seem to be board-specific, and PIIX4's pci_slot_get_pirq() in particular seems very Malta-specific. So move the latter to malta.c to 1/ keep the board logic in one place and 2/ avoid PIIX4 to make assumptions about its board. Signed-off-by: Bernhard Beschow Acked-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/isa/piix4.c | 26 -------------------------- hw/mips/malta.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c index f9211d085f..eca96fb8f0 100644 --- a/hw/isa/piix4.c +++ b/hw/isa/piix4.c @@ -79,31 +79,6 @@ static void piix4_set_irq(void *opaque, int irq_num, int= level) } } =20 -static int pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num) -{ - int slot; - - slot =3D PCI_SLOT(pci_dev->devfn); - - switch (slot) { - /* PIIX4 USB */ - case 10: - return 3; - /* AMD 79C973 Ethernet */ - case 11: - return 1; - /* Crystal 4281 Sound */ - case 12: - return 2; - /* PCI slot 1 to 4 */ - case 18 ... 21: - return ((slot - 18) + irq_num) & 0x03; - /* Unknown device, don't do any translation */ - default: - return irq_num; - } -} - static void piix4_isa_reset(DeviceState *dev) { PIIX4State *d =3D PIIX4_PCI_DEVICE(dev); @@ -272,7 +247,6 @@ static void piix4_realize(PCIDevice *dev, Error **errp) qdev_connect_gpio_out(DEVICE(&s->pm), 0, s->isa[9]); =20 pci_bus_irqs(pci_bus, piix4_set_irq, s, PIIX_NUM_PIRQS); - pci_bus_map_irqs(pci_bus, pci_slot_get_pirq); } =20 static void piix4_init(Object *obj) diff --git a/hw/mips/malta.c b/hw/mips/malta.c index c0a2e0ab04..e435f80973 100644 --- a/hw/mips/malta.c +++ b/hw/mips/malta.c @@ -39,6 +39,7 @@ #include "hw/mips/bootloader.h" #include "hw/mips/cpudevs.h" #include "hw/pci/pci.h" +#include "hw/pci/pci_bus.h" #include "qemu/log.h" #include "hw/mips/bios.h" #include "hw/ide/pci.h" @@ -1140,6 +1141,31 @@ static void malta_mips_config(MIPSCPU *cpu) } } =20 +static int pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num) +{ + int slot; + + slot =3D PCI_SLOT(pci_dev->devfn); + + switch (slot) { + /* PIIX4 USB */ + case 10: + return 3; + /* AMD 79C973 Ethernet */ + case 11: + return 1; + /* Crystal 4281 Sound */ + case 12: + return 2; + /* PCI slot 1 to 4 */ + case 18 ... 21: + return ((slot - 18) + irq_num) & 0x03; + /* Unknown device, don't do any translation */ + default: + return irq_num; + } +} + static void main_cpu_reset(void *opaque) { MIPSCPU *cpu =3D opaque; @@ -1411,6 +1437,8 @@ void mips_malta_init(MachineState *machine) /* Interrupt controller */ qdev_connect_gpio_out_named(DEVICE(piix4), "intr", 0, i8259_irq); =20 + pci_bus_map_irqs(pci_bus, pci_slot_get_pirq); + /* generate SPD EEPROM data */ dev =3D DEVICE(object_resolve_path_component(OBJECT(piix4), "pm")); smbus =3D I2C_BUS(qdev_get_child_bus(dev, "i2c")); --=20 2.38.1