* [PATCH 2/3] sam460ex: Drop unneeded dependencies
2020-12-25 23:07 [PATCH 0/3] Clean up sam460ex irq mapping BALATON Zoltan via
2020-12-25 23:07 ` [PATCH 3/3] sam460ex: Clean up " BALATON Zoltan via
@ 2020-12-25 23:07 ` BALATON Zoltan via
2020-12-27 15:33 ` Philippe Mathieu-Daudé
2020-12-25 23:07 ` [PATCH 1/3] ppc4xx: Move common dependency on serial to common option BALATON Zoltan via
2 siblings, 1 reply; 6+ messages in thread
From: BALATON Zoltan via @ 2020-12-25 23:07 UTC (permalink / raw)
To: qemu-devel, qemu-ppc
Cc: Peter Maydell, Mark Cave-Ayland, Guenter Roeck, David Gibson
Remove dependencies from KConfig that are not actually needed.
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
hw/ppc/Kconfig | 2 --
1 file changed, 2 deletions(-)
diff --git a/hw/ppc/Kconfig b/hw/ppc/Kconfig
index 8548f42b0d..5893f80909 100644
--- a/hw/ppc/Kconfig
+++ b/hw/ppc/Kconfig
@@ -55,7 +55,6 @@ config PPC4XX
config SAM460EX
bool
- select PPC405
select PFLASH_CFI01
select IDE_SII3112
select M41T80
@@ -64,7 +63,6 @@ config SAM460EX
select SMBUS_EEPROM
select USB_EHCI_SYSBUS
select USB_OHCI
- select FDT_PPC
config PREP
bool
--
2.21.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 1/3] ppc4xx: Move common dependency on serial to common option
2020-12-25 23:07 [PATCH 0/3] Clean up sam460ex irq mapping BALATON Zoltan via
2020-12-25 23:07 ` [PATCH 3/3] sam460ex: Clean up " BALATON Zoltan via
2020-12-25 23:07 ` [PATCH 2/3] sam460ex: Drop unneeded dependencies BALATON Zoltan via
@ 2020-12-25 23:07 ` BALATON Zoltan via
2 siblings, 0 replies; 6+ messages in thread
From: BALATON Zoltan via @ 2020-12-25 23:07 UTC (permalink / raw)
To: qemu-devel, qemu-ppc
Cc: Peter Maydell, Mark Cave-Ayland, Guenter Roeck, David Gibson
All machines that select SERIAL also select PPC4XX so we can just add
this common dependency there once.
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
hw/ppc/Kconfig | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/hw/ppc/Kconfig b/hw/ppc/Kconfig
index dd86e664d2..8548f42b0d 100644
--- a/hw/ppc/Kconfig
+++ b/hw/ppc/Kconfig
@@ -37,7 +37,6 @@ config PPC405
select M48T59
select PFLASH_CFI02
select PPC4XX
- select SERIAL
config PPC440
bool
@@ -46,13 +45,13 @@ config PPC440
imply E1000_PCI
select PCI_EXPRESS
select PPC4XX
- select SERIAL
select FDT_PPC
config PPC4XX
bool
select BITBANG_I2C
select PCI
+ select SERIAL
config SAM460EX
bool
@@ -61,7 +60,6 @@ config SAM460EX
select IDE_SII3112
select M41T80
select PPC440
- select SERIAL
select SM501
select SMBUS_EEPROM
select USB_EHCI_SYSBUS
@@ -123,7 +121,6 @@ config VIRTEX
bool
select PPC4XX
select PFLASH_CFI01
- select SERIAL
select XILINX
select XILINX_ETHLITE
select FDT_PPC
--
2.21.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 0/3] Clean up sam460ex irq mapping
@ 2020-12-25 23:07 BALATON Zoltan via
2020-12-25 23:07 ` [PATCH 3/3] sam460ex: Clean up " BALATON Zoltan via
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: BALATON Zoltan via @ 2020-12-25 23:07 UTC (permalink / raw)
To: qemu-devel, qemu-ppc
Cc: Peter Maydell, Mark Cave-Ayland, Guenter Roeck, David Gibson
This cleans up irq mapping in sam460ex inspired by similar changes to
other machines recently although there's no known or noticable problem
that this fixes. The first two patches are just simplifying
dependencies in Kconfig that I've noticed during writing the patch.
Regards,
BALATON Zoltan
BALATON Zoltan (3):
ppc4xx: Move common dependency on serial to common option
sam460ex: Drop unneeded dependencies
sam460ex: Clean up irq mapping
hw/ppc/Kconfig | 8 ++------
hw/ppc/ppc440_pcix.c | 28 ++++++++++++++--------------
hw/ppc/sam460ex.c | 16 +++++++++++++---
3 files changed, 29 insertions(+), 23 deletions(-)
--
2.21.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/3] sam460ex: Clean up irq mapping
2020-12-25 23:07 [PATCH 0/3] Clean up sam460ex irq mapping BALATON Zoltan via
@ 2020-12-25 23:07 ` BALATON Zoltan via
2020-12-27 18:00 ` Guenter Roeck
2020-12-25 23:07 ` [PATCH 2/3] sam460ex: Drop unneeded dependencies BALATON Zoltan via
2020-12-25 23:07 ` [PATCH 1/3] ppc4xx: Move common dependency on serial to common option BALATON Zoltan via
2 siblings, 1 reply; 6+ messages in thread
From: BALATON Zoltan via @ 2020-12-25 23:07 UTC (permalink / raw)
To: qemu-devel, qemu-ppc
Cc: Peter Maydell, Mark Cave-Ayland, Guenter Roeck, David Gibson
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 <balaton@eik.bme.hu>
---
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;
@@ -415,24 +415,20 @@ static void ppc440_pcix_reset(DeviceState *dev)
s->sts = 0;
}
-/* 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 = (irq_num + PCI_SLOT(pci_dev->devfn)) % PCI_NUM_PINS;
+
+ trace_ppc440_pcix_map_irq(pci_dev->devfn, irq_num, n);
+ return n;
}
static void ppc440_pcix_set_irq(void *opaque, int irq_num, int level)
{
- qemu_irq *pci_irq = opaque;
+ qemu_irq *pci_irqs = opaque;
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);
}
static AddressSpace *ppc440_pcix_set_iommu(PCIBus *b, void *opaque, int devfn)
@@ -472,15 +468,19 @@ static void ppc440_pcix_realize(DeviceState *dev, Error **errp)
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
PPC440PCIXState *s;
PCIHostState *h;
+ int i;
h = PCI_HOST_BRIDGE(dev);
s = PPC440_PCIX_HOST_BRIDGE(dev);
- sysbus_init_irq(sbd, &s->irq);
+ for (i = 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_MAX);
h->bus = 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->irq),
+ TYPE_PCI_BUS);
s->dev = pci_create_simple(h->bus, PCI_DEVFN(0, 0), "ppc4xx-host-bridge");
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;
cpu = POWERPC_CPU(cpu_create(machine->cpu_type));
env = &cpu->env;
@@ -382,13 +383,22 @@ static void sam460ex_init(MachineState *machine)
/* PCI bus */
ppc460ex_pcie_init(env);
- /* All PCI irqs are connected to the same UIC pin (cf. UBoot source) */
- dev = sysbus_create_simple("ppc440-pcix-host", 0xc0ec00000, uic[1][0]);
+ dev = sysbus_create_simple("ppc440-pcix-host", 0xc0ec00000, NULL);
pci_bus = (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 = SYS_BUS_DEVICE(dev);
+ dev = 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 = 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);
--
2.21.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/3] sam460ex: Drop unneeded dependencies
2020-12-25 23:07 ` [PATCH 2/3] sam460ex: Drop unneeded dependencies BALATON Zoltan via
@ 2020-12-27 15:33 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-12-27 15:33 UTC (permalink / raw)
To: BALATON Zoltan, qemu-devel, qemu-ppc
Cc: Peter Maydell, Mark Cave-Ayland, Guenter Roeck, David Gibson
On 12/26/20 12:07 AM, BALATON Zoltan via wrote:
> Remove dependencies from KConfig that are not actually needed.
>
> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
> ---
> hw/ppc/Kconfig | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/hw/ppc/Kconfig b/hw/ppc/Kconfig
> index 8548f42b0d..5893f80909 100644
> --- a/hw/ppc/Kconfig
> +++ b/hw/ppc/Kconfig
> @@ -55,7 +55,6 @@ config PPC4XX
>
> config SAM460EX
> bool
> - select PPC405
You reviewed commit def9119efe2 ("hw/ppc/Kconfig: Let the Sam460ex
board use the PowerPC 405 devices").
> select PFLASH_CFI01
> select IDE_SII3112
> select M41T80
> @@ -64,7 +63,6 @@ config SAM460EX
> select SMBUS_EEPROM
> select USB_EHCI_SYSBUS
> select USB_OHCI
> - select FDT_PPC
Correct, I guess I got confused by the _FDT() macro used in
sam460ex_load_device_tree(). So:
Fixes: b0048f76095 ("hw/ppc/Kconfig: Only select FDT helper for machines
using it")
>
> config PREP
> bool
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] sam460ex: Clean up irq mapping
2020-12-25 23:07 ` [PATCH 3/3] sam460ex: Clean up " BALATON Zoltan via
@ 2020-12-27 18:00 ` Guenter Roeck
0 siblings, 0 replies; 6+ messages in thread
From: Guenter Roeck @ 2020-12-27 18:00 UTC (permalink / raw)
To: BALATON Zoltan, qemu-devel, qemu-ppc
Cc: Peter Maydell, Mark Cave-Ayland, David Gibson
On 12/25/20 3:07 PM, BALATON Zoltan wrote:
> 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 <balaton@eik.bme.hu>
Tested-by: Guenter Roeck <linux@roeck-us.net>
> ---
> 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;
>
> @@ -415,24 +415,20 @@ static void ppc440_pcix_reset(DeviceState *dev)
> s->sts = 0;
> }
>
> -/* 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 = (irq_num + PCI_SLOT(pci_dev->devfn)) % PCI_NUM_PINS;
> +
> + trace_ppc440_pcix_map_irq(pci_dev->devfn, irq_num, n);
> + return n;
> }
>
> static void ppc440_pcix_set_irq(void *opaque, int irq_num, int level)
> {
> - qemu_irq *pci_irq = opaque;
> + qemu_irq *pci_irqs = opaque;
>
> 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);
> }
>
> static AddressSpace *ppc440_pcix_set_iommu(PCIBus *b, void *opaque, int devfn)
> @@ -472,15 +468,19 @@ static void ppc440_pcix_realize(DeviceState *dev, Error **errp)
> SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
> PPC440PCIXState *s;
> PCIHostState *h;
> + int i;
>
> h = PCI_HOST_BRIDGE(dev);
> s = PPC440_PCIX_HOST_BRIDGE(dev);
>
> - sysbus_init_irq(sbd, &s->irq);
> + for (i = 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_MAX);
> h->bus = 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->irq),
> + TYPE_PCI_BUS);
>
> s->dev = pci_create_simple(h->bus, PCI_DEVFN(0, 0), "ppc4xx-host-bridge");
>
> 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;
>
> cpu = POWERPC_CPU(cpu_create(machine->cpu_type));
> env = &cpu->env;
> @@ -382,13 +383,22 @@ static void sam460ex_init(MachineState *machine)
>
> /* PCI bus */
> ppc460ex_pcie_init(env);
> - /* All PCI irqs are connected to the same UIC pin (cf. UBoot source) */
> - dev = sysbus_create_simple("ppc440-pcix-host", 0xc0ec00000, uic[1][0]);
> + dev = sysbus_create_simple("ppc440-pcix-host", 0xc0ec00000, NULL);
> pci_bus = (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 = SYS_BUS_DEVICE(dev);
> + dev = 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 = 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);
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-12-27 18:03 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-25 23:07 [PATCH 0/3] Clean up sam460ex irq mapping BALATON Zoltan via
2020-12-25 23:07 ` [PATCH 3/3] sam460ex: Clean up " BALATON Zoltan via
2020-12-27 18:00 ` Guenter Roeck
2020-12-25 23:07 ` [PATCH 2/3] sam460ex: Drop unneeded dependencies BALATON Zoltan via
2020-12-27 15:33 ` Philippe Mathieu-Daudé
2020-12-25 23:07 ` [PATCH 1/3] ppc4xx: Move common dependency on serial to common option BALATON Zoltan via
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.