From: Bernhard Beschow <shentey@gmail.com>
To: qemu-devel@nongnu.org
Cc: "John G Johnson" <john.g.johnson@oracle.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Huacai Chen" <chenhuacai@kernel.org>,
"Jiaxun Yang" <jiaxun.yang@flygoat.com>,
"Aurelien Jarno" <aurelien@aurel32.net>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Hervé Poussineau" <hpoussin@reactos.org>,
"Elena Ufimtseva" <elena.ufimtseva@oracle.com>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Jagannathan Raman" <jag.raman@oracle.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
qemu-ppc@nongnu.org, qemu-arm@nongnu.org,
"Bernhard Beschow" <shentey@gmail.com>
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 [thread overview]
Message-ID: <20221120150550.63059-4-shentey@gmail.com> (raw)
In-Reply-To: <20221120150550.63059-1-shentey@gmail.com>
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 <shentey@gmail.com>
---
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)
}
}
-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 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)
}
}
+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 main_cpu_reset(void *opaque)
{
MIPSCPU *cpu = opaque;
@@ -1411,6 +1437,8 @@ void mips_malta_init(MachineState *machine)
/* Interrupt controller */
qdev_connect_gpio_out_named(DEVICE(piix4), "intr", 0, i8259_irq);
+ pci_bus_map_irqs(pci_bus, pci_slot_get_pirq);
+
/* generate SPD EEPROM data */
dev = DEVICE(object_resolve_path_component(OBJECT(piix4), "pm"));
smbus = I2C_BUS(qdev_get_child_bus(dev, "i2c"));
--
2.38.1
next prev parent reply other threads:[~2022-11-20 15:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-20 15:05 [PATCH v2 0/3] Decouple INTx-to-LNKx routing from south bridges Bernhard Beschow
2022-11-20 15:05 ` [PATCH v2 1/3] hw/pci/pci: Factor out pci_bus_map_irqs() from pci_bus_irqs() Bernhard Beschow
2022-11-20 15:05 ` [PATCH v2 2/3] hw/isa/piix3: Decouple INTx-to-LNKx routing which is board-specific Bernhard Beschow
2022-11-20 15:05 ` Bernhard Beschow [this message]
2022-12-09 15:23 ` [PATCH v2 0/3] Decouple INTx-to-LNKx routing from south bridges Philippe Mathieu-Daudé
2022-12-18 10:21 ` Bernhard Beschow
2022-12-18 13:05 ` Michael S. Tsirkin
2022-12-20 23:10 ` Michael S. Tsirkin
2022-12-20 23:26 ` Bernhard Beschow
2022-12-21 6:33 ` Michael S. Tsirkin
2022-12-21 6:32 ` Michael S. Tsirkin
2022-12-21 7:24 ` Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221120150550.63059-4-shentey@gmail.com \
--to=shentey@gmail.com \
--cc=aurelien@aurel32.net \
--cc=chenhuacai@kernel.org \
--cc=eduardo@habkost.net \
--cc=elena.ufimtseva@oracle.com \
--cc=hpoussin@reactos.org \
--cc=jag.raman@oracle.com \
--cc=jiaxun.yang@flygoat.com \
--cc=john.g.johnson@oracle.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).