From patchwork Fri Jan 13 15:45:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 642026 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp318132pvb; Fri, 13 Jan 2023 09:08:05 -0800 (PST) X-Google-Smtp-Source: AMrXdXs4q4A+3NXm8mb2f8475tnWkR0eLi2fybFOFoS1ZOZ/7r8/nMnpYXi7Mj5bkfJOC4v36d/0 X-Received: by 2002:a05:6102:9d4:b0:3bb:c520:70cb with SMTP id g20-20020a05610209d400b003bbc52070cbmr40317917vsi.4.1673629685463; Fri, 13 Jan 2023 09:08:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673629685; cv=none; d=google.com; s=arc-20160816; b=LHtC+Dk7AblRP6D6HiQL4rEjtia50ZTKcfh5ojS2l2i2CwBgdsDW2ECM6RO/5G9HMT ZliAOwtT3XYuThaGIq8DmVx0wOybmzOYK0os6BXMi6xhxgZ1f45VSlQqx5H2qU17JLVD aH/W3WcvoGCWK5jReH9HTeMk15JB96hSCXMn1ydOdemyO4w6Vo2YVU2MHdlUyAmu4aPr AF9tkL734RZh4bYIyS7K/5LgV97JxbVbYNx/wj56vzljGgOYqXN7r+pEHUWF6yuvbx4a 8gTiLeInselyQgzb1zMxyqz72P+gE3WEdEL8ZX7mb5TB27UQt891HwLKcQyxC7Rbr+tL 6yQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oZv1aBP22CJYNPpwWsHYyzzFVllV/sO8yGsxaU0io8I=; b=LwwghRpp+osbV/XHoi03ZvVW1VaAnKnHBHMuQNCPKy8RkRS0yomDg1ep2ZJmvHqQ/N 4oBSMY7GoNBboD5dLqX9m58jZaHZXULJYbJCeMvIm467rjZ8kkIzadvzzjpAtHLdW5Og xqfOmXESOvTBmlhZ9Rhi19pmfPCfgj53CckuCaTgu1ijVj6rR4N6MsYTXwOyUwUGVctU lKCptuPo3m7UWvaUzWDf6kynfGPeCc3e186eCgrI/TpSc1xPPHHkfAwH7PO5qKcnov54 5Nx0MixX4kJ+lszpKuskbaBgrnUEnU5VqBofhCK+16jjsaN4kul5zVuMWoNmV81dIPoD mwCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bm+dGUdh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q124-20020a675c82000000b003d0d44fe1f1si2900648vsb.157.2023.01.13.09.08.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Jan 2023 09:08:05 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bm+dGUdh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pGMHu-0002hg-PS; Fri, 13 Jan 2023 10:48:14 -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 1pGMHs-0002fO-HY for qemu-devel@nongnu.org; Fri, 13 Jan 2023 10:48:12 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pGMHq-0006Xt-RY for qemu-devel@nongnu.org; Fri, 13 Jan 2023 10:48:12 -0500 Received: by mail-wm1-x329.google.com with SMTP id m8-20020a05600c3b0800b003d96f801c48so19056035wms.0 for ; Fri, 13 Jan 2023 07:48:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=oZv1aBP22CJYNPpwWsHYyzzFVllV/sO8yGsxaU0io8I=; b=bm+dGUdhHEfD75vWbztUhfTJ0PxzE8gf4WERZKG3a6E7v+qJebAQpVuCDK9mikJwJd j1ji8NDg/oBqdMrTwq+cUU/ZSq9l1gVY8gq8y4O6+UeTY/EGwGIrBamCe25hyqhI02sh Yhfrl48DMvouFonhdx6k1QdQ1b70z8u5eYOikNrr+pnKoYZcDCt04f8CkYaLD3gEocId TjjXVy2GTr2Iu1DV1BgKOrV8YVzSAhIwPAfPGjowZpuIANAJDT8bOMeyvm5y7DRGqbU3 ax/ulOy3fIlFDGmccgnIjTimmvQLr3enFTSiZ8DE3uz7BQSsgP9TCdNa6pDmRSOQ8Dxz +sAA== 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=oZv1aBP22CJYNPpwWsHYyzzFVllV/sO8yGsxaU0io8I=; b=KotCjj8QK/b4IHgDWHMEJB8pkTQINLGL5irCtIPAhqtiPjznVUsaE36jDQQPsHfnnj w/Y3oT+hLuguLnMQ2DahY3oNLARcmo+wiJJAFnzJGBbOe8BwD8BBzr4Z8PYH3ZCm5lyu DYN7CJ4wmnYMK7woFJFmdPiRPDvXxn98sjRmJPrzjXshsMxuVDaiqTx64NWeaM8y4Zi/ QmtkZ5G3+uc1dJ/fdwJaviHzo5ZleDk6B6oPeN0KLvM5Ljtd2cnjT4hzznsqMYcO6iG4 QvQGdvr1gBEpO6vRIB5eNVwZm1bqq11+qik2siQtPNOt3SKlXdxmuadl/6Khl3/7dX7I 7eFQ== X-Gm-Message-State: AFqh2kpCacXf9KD97nGlMOFGG+lNSCfc98eSBKYH7nbUiYgfiA/ASl8d oAQ+CMz012gBN3RDezJIxIzLZsnLJVplGwYF X-Received: by 2002:a05:600c:4fcf:b0:3d1:d396:1ade with SMTP id o15-20020a05600c4fcf00b003d1d3961ademr58308745wmq.9.1673624889098; Fri, 13 Jan 2023 07:48:09 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id p9-20020a05600c358900b003cffd3c3d6csm27758505wmq.12.2023.01.13.07.48.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 13 Jan 2023 07:48:08 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Bernhard Beschow , "Michael S . Tsirkin" , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PULL 32/46] hw/isa/piix4: Decouple INTx-to-LNKx routing which is board-specific Date: Fri, 13 Jan 2023 16:45:18 +0100 Message-Id: <20230113154532.49979-33-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230113154532.49979-1-philmd@linaro.org> References: <20230113154532.49979-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Bernhard Beschow 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 Reviewed-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20230109172347.1830-7-shentey@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- hw/isa/piix4.c | 26 -------------------------- hw/mips/malta.c | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c index 9c79c9677b..6e9434129d 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) } } -static int pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num) -{ - int slot; - - slot = 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 = 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]); pci_bus_irqs(pci_bus, piix4_set_irq, s, PIIX_NUM_PIRQS); - pci_bus_map_irqs(pci_bus, pci_slot_get_pirq); } static void piix4_init(Object *obj) diff --git a/hw/mips/malta.c b/hw/mips/malta.c index 8bf2e2ff5f..ec172b111a 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" @@ -993,6 +994,31 @@ static void malta_mips_config(MIPSCPU *cpu) } } +static int malta_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num) +{ + int slot; + + slot = 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 = opaque; @@ -1225,6 +1251,7 @@ void mips_malta_init(MachineState *machine) qdev_prop_set_bit(dev, "cpu-little-endian", !be); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); pci_bus = PCI_BUS(qdev_get_child_bus(dev, "pci")); + pci_bus_map_irqs(pci_bus, malta_pci_slot_get_pirq); /* Southbridge */ piix4 = pci_create_simple_multifunction(pci_bus, PIIX4_PCI_DEVFN, true,