Skip to contentSkip to conversation

hw/pci-host/prep: Fix PCI swizzling in map_irq()

PATCH In review Philippe Mathieu-Daudé 4 participants 14 messages Oct 12, 2020 – Nov 2, 2020

lore
Share & tools
lore
#0 lore raw

cover hw/pci-host/prep: Fix PCI swizzling in map_irq()

Fix a bug in the Raven PCI host, plus few cleanups while here.

Philippe Mathieu-Daudé (4):
hw/pci-host/prep: Update coding style to make checkpatch.pl happy hw/pci-host/prep: Remove legacy PReP machine temporary workaround hw/pci-host/prep: Fix PCI swizzling in map_irq() docs/system/target-ppc.rst: Update PReP historical information

 docs/system/target-ppc.rst |  8 ++++----
 hw/pci-host/prep.c         | 32 ++++++++++++--------------------
 2 files changed, 16 insertions(+), 24 deletions(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/4 hw/pci-host/prep: Update coding style to make checkpatch.pl happy

To make the next commit easier to review, clean this code first.

---
 hw/pci-host/prep.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
hw/pci-host/prep.c +4 -2
index d0323fefb10..80dfb67da43 100644
@@ -234,8 +234,10 @@ static void raven_pcihost_realizefn(DeviceState *d, Error **errp)
             sysbus_init_irq(dev, &s->pci_irqs[i]);
         }
     } else {
-        /* According to PReP specification section 6.1.6 "System Interrupt
-         * Assignments", all PCI interrupts are routed via IRQ 15 */
+        /*
+         * According to PReP specification section 6.1.6 "System Interrupt
+         * Assignments", all PCI interrupts are routed via IRQ 15
+         */
         s->or_irq = OR_IRQ(object_new(TYPE_OR_IRQ));
         object_property_set_int(OBJECT(s->or_irq), "num-lines", PCI_NUM_PINS,
                                 &error_fatal);
Signature · 1 line
2.26.2
Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] hw/pci-host/prep: Update coding style to make checkpatch.pl happy

Quoted 14 lines · Philippe Mathieu-Daudé

To make the next commit easier to review, clean this code first.

---
 hw/pci-host/prep.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
hw/pci-host/prep.c +0 -0
index d0323fefb10..80dfb67da43 100644
@@ -234,8 +234,10 @@ static void raven_pcihost_realizefn(DeviceState *d, Error **errp)
             sysbus_init_irq(dev, &s->pci_irqs[i]);
         }

hw/pci-host/prep.c static void raven_pcihost_realizefn(DeviceState *d, Error **errp) · line 243

Quoted 10 lines
hw/pci-host/prep.c +4 -2
     } else {
-        /* According to PReP specification section 6.1.6 "System Interrupt
-         * Assignments", all PCI interrupts are routed via IRQ 15 */
+        /*
+         * According to PReP specification section 6.1.6 "System Interrupt
+         * Assignments", all PCI interrupts are routed via IRQ 15
+         */
         s->or_irq = OR_IRQ(object_new(TYPE_OR_IRQ));
         object_property_set_int(OBJECT(s->or_irq), "num-lines", PCI_NUM_PINS,
                                 &error_fatal);

ATB,

Mark.

Reviewed-by on v1 1/4
#3 lore raw

Re: [PATCH 1/4] hw/pci-host/prep: Update coding style to make checkpatch.pl happy

In reply to Philippe Mathieu-Daudé
Quoted 3 lines · Philippe Mathieu-Daudé

To make the next commit easier to review, clean this code first.

Quoted 21 lines
---
 hw/pci-host/prep.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
hw/pci-host/prep.c +4 -2
index d0323fefb10..80dfb67da43 100644
@@ -234,8 +234,10 @@ static void raven_pcihost_realizefn(DeviceState *d, Error **errp)
             sysbus_init_irq(dev, &s->pci_irqs[i]);
         }
     } else {
-        /* According to PReP specification section 6.1.6 "System Interrupt
-         * Assignments", all PCI interrupts are routed via IRQ 15 */
+        /*
+         * According to PReP specification section 6.1.6 "System Interrupt
+         * Assignments", all PCI interrupts are routed via IRQ 15
+         */
         s->or_irq = OR_IRQ(object_new(TYPE_OR_IRQ));
         object_property_set_int(OBJECT(s->or_irq), "num-lines", PCI_NUM_PINS,
                                 &error_fatal);
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#4 lore raw

PATCH 2/4 hw/pci-host/prep: Remove legacy PReP machine temporary workaround

In reply to Philippe Mathieu-Daudé

The legacy PReP machine has been removed in commit b2ce76a0730 ("hw/ppc/prep: Remove the deprecated "prep" machine and the OpenHackware BIOS"). This temporary workaround is no more required, remove it.

---
 hw/pci-host/prep.c | 32 +++++++++++---------------------
 1 file changed, 11 insertions(+), 21 deletions(-)
hw/pci-host/prep.c +11 -21
index 80dfb67da43..064593d1e52 100644
@@ -75,7 +75,6 @@ struct PRePPCIState {
     RavenPCIState pci_dev;
 
     int contiguous_map;
-    bool is_legacy_prep;
 };
 
 #define BIOS_SIZE (1 * MiB)
@@ -229,24 +228,18 @@ static void raven_pcihost_realizefn(DeviceState *d, Error **errp)
     MemoryRegion *address_space_mem = get_system_memory();
     int i;
 
-    if (s->is_legacy_prep) {
-        for (i = 0; i < PCI_NUM_PINS; i++) {
-            sysbus_init_irq(dev, &s->pci_irqs[i]);
-        }
-    } else {
-        /*
-         * According to PReP specification section 6.1.6 "System Interrupt
-         * Assignments", all PCI interrupts are routed via IRQ 15
-         */
-        s->or_irq = OR_IRQ(object_new(TYPE_OR_IRQ));
-        object_property_set_int(OBJECT(s->or_irq), "num-lines", PCI_NUM_PINS,
-                                &error_fatal);
-        qdev_realize(DEVICE(s->or_irq), NULL, &error_fatal);
-        sysbus_init_irq(dev, &s->or_irq->out_irq);
+    /*
+     * According to PReP specification section 6.1.6 "System Interrupt
+     * Assignments", all PCI interrupts are routed via IRQ 15.
+     */
+    s->or_irq = OR_IRQ(object_new(TYPE_OR_IRQ));
+    object_property_set_int(OBJECT(s->or_irq), "num-lines", PCI_NUM_PINS,
+                            &error_fatal);
+    qdev_realize(DEVICE(s->or_irq), NULL, &error_fatal);
+    sysbus_init_irq(dev, &s->or_irq->out_irq);
 
-        for (i = 0; i < PCI_NUM_PINS; i++) {
-            s->pci_irqs[i] = qdev_get_gpio_in(DEVICE(s->or_irq), i);
-        }
+    for (i = 0; i < PCI_NUM_PINS; i++) {
+        s->pci_irqs[i] = qdev_get_gpio_in(DEVICE(s->or_irq), i);
     }
 
     qdev_init_gpio_in(d, raven_change_gpio, 1);
@@ -403,9 +396,6 @@ static Property raven_pcihost_properties[] = {
     DEFINE_PROP_UINT32("elf-machine", PREPPCIState, pci_dev.elf_machine,
                        EM_NONE),
     DEFINE_PROP_STRING("bios-name", PREPPCIState, pci_dev.bios_name),
-    /* Temporary workaround until legacy prep machine is removed */
-    DEFINE_PROP_BOOL("is-legacy-prep", PREPPCIState, is_legacy_prep,
-                     false),
     DEFINE_PROP_END_OF_LIST()
 };
 
Signature · 1 line
2.26.2
Reviewed-by on v1 2/4
#5 lore raw

Re: [PATCH 2/4] hw/pci-host/prep: Remove legacy PReP machine temporary workaround

Quoted 34 lines · Philippe Mathieu-Daudé

The legacy PReP machine has been removed in commit b2ce76a0730 ("hw/ppc/prep: Remove the deprecated "prep" machine and the OpenHackware BIOS"). This temporary workaround is no more required, remove it.

---
 hw/pci-host/prep.c | 32 +++++++++++---------------------
 1 file changed, 11 insertions(+), 21 deletions(-)
hw/pci-host/prep.c +0 -9
index 80dfb67da43..064593d1e52 100644
@@ -75,7 +75,6 @@ struct PRePPCIState {
     RavenPCIState pci_dev;
 
     int contiguous_map;
-    bool is_legacy_prep;
 };
 
 #define BIOS_SIZE (1 * MiB)
@@ -229,24 +228,18 @@ static void raven_pcihost_realizefn(DeviceState *d, Error **errp)
     MemoryRegion *address_space_mem = get_system_memory();
     int i;
 
-    if (s->is_legacy_prep) {
-        for (i = 0; i < PCI_NUM_PINS; i++) {
-            sysbus_init_irq(dev, &s->pci_irqs[i]);
-        }
-    } else {
-        /*
-         * According to PReP specification section 6.1.6 "System Interrupt
-         * Assignments", all PCI interrupts are routed via IRQ 15

hw/pci-host/prep.c static void raven_pcihost_realizefn(DeviceState *d, Error **errp) · line 234

Quoted 10 lines
hw/pci-host/prep.c +4 -6
-         */
-        s->or_irq = OR_IRQ(object_new(TYPE_OR_IRQ));
-        object_property_set_int(OBJECT(s->or_irq), "num-lines", PCI_NUM_PINS,
-                                &error_fatal);
-        qdev_realize(DEVICE(s->or_irq), NULL, &error_fatal);
-        sysbus_init_irq(dev, &s->or_irq->out_irq);
+    /*
+     * According to PReP specification section 6.1.6 "System Interrupt
+     * Assignments", all PCI interrupts are routed via IRQ 15.
+     */

Since you're changing the indentation of these lines anyway, I think you could also simply squash patch 1 into this one here (just a matter of taste, though).

Quoted 16 lines
hw/pci-host/prep.c +7 -3
+    s->or_irq = OR_IRQ(object_new(TYPE_OR_IRQ));
+    object_property_set_int(OBJECT(s->or_irq), "num-lines", PCI_NUM_PINS,
+                            &error_fatal);
+    qdev_realize(DEVICE(s->or_irq), NULL, &error_fatal);
+    sysbus_init_irq(dev, &s->or_irq->out_irq);
 
-        for (i = 0; i < PCI_NUM_PINS; i++) {
-            s->pci_irqs[i] = qdev_get_gpio_in(DEVICE(s->or_irq), i);
-        }
+    for (i = 0; i < PCI_NUM_PINS; i++) {
+        s->pci_irqs[i] = qdev_get_gpio_in(DEVICE(s->or_irq), i);
     }
 
     qdev_init_gpio_in(d, raven_change_gpio, 1);

hw/pci-host/prep.c static Property raven_pcihost_properties[] = { · line 401

Quoted 9 lines
hw/pci-host/prep.c +0 -3
@@ -403,9 +396,6 @@ static Property raven_pcihost_properties[] = {
     DEFINE_PROP_UINT32("elf-machine", PREPPCIState, pci_dev.elf_machine,
                        EM_NONE),
     DEFINE_PROP_STRING("bios-name", PREPPCIState, pci_dev.bios_name),
-    /* Temporary workaround until legacy prep machine is removed */
-    DEFINE_PROP_BOOL("is-legacy-prep", PREPPCIState, is_legacy_prep,
-                     false),
     DEFINE_PROP_END_OF_LIST()
 };
 
#6 lore raw

Re: [PATCH 2/4] hw/pci-host/prep: Remove legacy PReP machine temporary workaround

Quoted 41 lines · Thomas Huth
Quoted 40 lines · Philippe Mathieu-Daudé

The legacy PReP machine has been removed in commit b2ce76a0730 ("hw/ppc/prep: Remove the deprecated "prep" machine and the OpenHackware BIOS"). This temporary workaround is no more required, remove it.

---
  hw/pci-host/prep.c | 32 +++++++++++---------------------
  1 file changed, 11 insertions(+), 21 deletions(-)
hw/pci-host/prep.c +0 -15
index 80dfb67da43..064593d1e52 100644
@@ -75,7 +75,6 @@ struct PRePPCIState {
      RavenPCIState pci_dev;
 
      int contiguous_map;
-    bool is_legacy_prep;
  };
 
  #define BIOS_SIZE (1 * MiB)
@@ -229,24 +228,18 @@ static void raven_pcihost_realizefn(DeviceState *d, Error **errp)
      MemoryRegion *address_space_mem = get_system_memory();
      int i;
 
-    if (s->is_legacy_prep) {
-        for (i = 0; i < PCI_NUM_PINS; i++) {
-            sysbus_init_irq(dev, &s->pci_irqs[i]);
-        }
-    } else {
-        /*
-         * According to PReP specification section 6.1.6 "System Interrupt
-         * Assignments", all PCI interrupts are routed via IRQ 15
-         */
-        s->or_irq = OR_IRQ(object_new(TYPE_OR_IRQ));
-        object_property_set_int(OBJECT(s->or_irq), "num-lines", PCI_NUM_PINS,
-                                &error_fatal);
-        qdev_realize(DEVICE(s->or_irq), NULL, &error_fatal);
-        sysbus_init_irq(dev, &s->or_irq->out_irq);
Quoted 8 lines

hw/pci-host/prep.c static void raven_pcihost_realizefn(DeviceState *d, Error **errp) · line 234

Quoted 4 lines
hw/pci-host/prep.c +4 -0
+    /*
+     * According to PReP specification section 6.1.6 "System Interrupt
+     * Assignments", all PCI interrupts are routed via IRQ 15.
+     */

Since you're changing the indentation of these lines anyway, I think you could also simply squash patch 1 into this one here (just a matter of taste, though).

Then the diff is not trivial to review :/

Quoted 14 lines
Quoted 14 lines
hw/pci-host/prep.c +7 -3
+    s->or_irq = OR_IRQ(object_new(TYPE_OR_IRQ));
+    object_property_set_int(OBJECT(s->or_irq), "num-lines", PCI_NUM_PINS,
+                            &error_fatal);
+    qdev_realize(DEVICE(s->or_irq), NULL, &error_fatal);
+    sysbus_init_irq(dev, &s->or_irq->out_irq);
 
-        for (i = 0; i < PCI_NUM_PINS; i++) {
-            s->pci_irqs[i] = qdev_get_gpio_in(DEVICE(s->or_irq), i);
-        }
+    for (i = 0; i < PCI_NUM_PINS; i++) {
+        s->pci_irqs[i] = qdev_get_gpio_in(DEVICE(s->or_irq), i);
      }
 
Quoted 14 lines

hw/pci-host/prep.c static Property raven_pcihost_properties[] = { · line 401

Quoted 12 lines
hw/pci-host/prep.c +0 -3
      qdev_init_gpio_in(d, raven_change_gpio, 1);
@@ -403,9 +396,6 @@ static Property raven_pcihost_properties[] = {
      DEFINE_PROP_UINT32("elf-machine", PREPPCIState, pci_dev.elf_machine,
                         EM_NONE),
      DEFINE_PROP_STRING("bios-name", PREPPCIState, pci_dev.bios_name),
-    /* Temporary workaround until legacy prep machine is removed */
-    DEFINE_PROP_BOOL("is-legacy-prep", PREPPCIState, is_legacy_prep,
-                     false),
      DEFINE_PROP_END_OF_LIST()
  };
 

Thanks!

Reviewed-by on v1 2/4
#7 lore raw

Re: [PATCH 2/4] hw/pci-host/prep: Remove legacy PReP machine temporary workaround

In reply to Philippe Mathieu-Daudé
Quoted 59 lines · Philippe Mathieu-Daudé

The legacy PReP machine has been removed in commit b2ce76a0730 ("hw/ppc/prep: Remove the deprecated "prep" machine and the OpenHackware BIOS"). This temporary workaround is no more required, remove it.

---
 hw/pci-host/prep.c | 32 +++++++++++---------------------
 1 file changed, 11 insertions(+), 21 deletions(-)
hw/pci-host/prep.c +11 -18
index 80dfb67da43..064593d1e52 100644
@@ -75,7 +75,6 @@ struct PRePPCIState {
     RavenPCIState pci_dev;
 
     int contiguous_map;
-    bool is_legacy_prep;
 };
 
 #define BIOS_SIZE (1 * MiB)
@@ -229,24 +228,18 @@ static void raven_pcihost_realizefn(DeviceState *d, Error **errp)
     MemoryRegion *address_space_mem = get_system_memory();
     int i;
 
-    if (s->is_legacy_prep) {
-        for (i = 0; i < PCI_NUM_PINS; i++) {
-            sysbus_init_irq(dev, &s->pci_irqs[i]);
-        }
-    } else {
-        /*
-         * According to PReP specification section 6.1.6 "System Interrupt
-         * Assignments", all PCI interrupts are routed via IRQ 15
-         */
-        s->or_irq = OR_IRQ(object_new(TYPE_OR_IRQ));
-        object_property_set_int(OBJECT(s->or_irq), "num-lines", PCI_NUM_PINS,
-                                &error_fatal);
-        qdev_realize(DEVICE(s->or_irq), NULL, &error_fatal);
-        sysbus_init_irq(dev, &s->or_irq->out_irq);
+    /*
+     * According to PReP specification section 6.1.6 "System Interrupt
+     * Assignments", all PCI interrupts are routed via IRQ 15.
+     */
+    s->or_irq = OR_IRQ(object_new(TYPE_OR_IRQ));
+    object_property_set_int(OBJECT(s->or_irq), "num-lines", PCI_NUM_PINS,
+                            &error_fatal);
+    qdev_realize(DEVICE(s->or_irq), NULL, &error_fatal);
+    sysbus_init_irq(dev, &s->or_irq->out_irq);
 
-        for (i = 0; i < PCI_NUM_PINS; i++) {
-            s->pci_irqs[i] = qdev_get_gpio_in(DEVICE(s->or_irq), i);
-        }
+    for (i = 0; i < PCI_NUM_PINS; i++) {
+        s->pci_irqs[i] = qdev_get_gpio_in(DEVICE(s->or_irq), i);
     }
 
     qdev_init_gpio_in(d, raven_change_gpio, 1);

hw/pci-host/prep.c static Property raven_pcihost_properties[] = { · line 400

Quoted 8 lines
hw/pci-host/prep.c +0 -3
@@ -403,9 +396,6 @@ static Property raven_pcihost_properties[] = {
     DEFINE_PROP_UINT32("elf-machine", PREPPCIState, pci_dev.elf_machine,
                        EM_NONE),
     DEFINE_PROP_STRING("bios-name", PREPPCIState, pci_dev.bios_name),
-    /* Temporary workaround until legacy prep machine is removed */
-    DEFINE_PROP_BOOL("is-legacy-prep", PREPPCIState, is_legacy_prep,
-                     false),
     DEFINE_PROP_END_OF_LIST()
 };

Yes indeed, this workaround is certainly no longer needed.

ATB,

Mark.

Reviewed-by on v1 2/4
#8 lore raw

Re: [PATCH 2/4] hw/pci-host/prep: Remove legacy PReP machine temporary workaround

In reply to Philippe Mathieu-Daudé
Quoted 6 lines · Philippe Mathieu-Daudé

The legacy PReP machine has been removed in commit b2ce76a0730 ("hw/ppc/prep: Remove the deprecated "prep" machine and the OpenHackware BIOS"). This temporary workaround is no more required, remove it.

Quoted 62 lines
---
 hw/pci-host/prep.c | 32 +++++++++++---------------------
 1 file changed, 11 insertions(+), 21 deletions(-)
hw/pci-host/prep.c +11 -21
index 80dfb67da43..064593d1e52 100644
@@ -75,7 +75,6 @@ struct PRePPCIState {
     RavenPCIState pci_dev;
 
     int contiguous_map;
-    bool is_legacy_prep;
 };
 
 #define BIOS_SIZE (1 * MiB)
@@ -229,24 +228,18 @@ static void raven_pcihost_realizefn(DeviceState *d, Error **errp)
     MemoryRegion *address_space_mem = get_system_memory();
     int i;
 
-    if (s->is_legacy_prep) {
-        for (i = 0; i < PCI_NUM_PINS; i++) {
-            sysbus_init_irq(dev, &s->pci_irqs[i]);
-        }
-    } else {
-        /*
-         * According to PReP specification section 6.1.6 "System Interrupt
-         * Assignments", all PCI interrupts are routed via IRQ 15
-         */
-        s->or_irq = OR_IRQ(object_new(TYPE_OR_IRQ));
-        object_property_set_int(OBJECT(s->or_irq), "num-lines", PCI_NUM_PINS,
-                                &error_fatal);
-        qdev_realize(DEVICE(s->or_irq), NULL, &error_fatal);
-        sysbus_init_irq(dev, &s->or_irq->out_irq);
+    /*
+     * According to PReP specification section 6.1.6 "System Interrupt
+     * Assignments", all PCI interrupts are routed via IRQ 15.
+     */
+    s->or_irq = OR_IRQ(object_new(TYPE_OR_IRQ));
+    object_property_set_int(OBJECT(s->or_irq), "num-lines", PCI_NUM_PINS,
+                            &error_fatal);
+    qdev_realize(DEVICE(s->or_irq), NULL, &error_fatal);
+    sysbus_init_irq(dev, &s->or_irq->out_irq);
 
-        for (i = 0; i < PCI_NUM_PINS; i++) {
-            s->pci_irqs[i] = qdev_get_gpio_in(DEVICE(s->or_irq), i);
-        }
+    for (i = 0; i < PCI_NUM_PINS; i++) {
+        s->pci_irqs[i] = qdev_get_gpio_in(DEVICE(s->or_irq), i);
     }
 
     qdev_init_gpio_in(d, raven_change_gpio, 1);
@@ -403,9 +396,6 @@ static Property raven_pcihost_properties[] = {
     DEFINE_PROP_UINT32("elf-machine", PREPPCIState, pci_dev.elf_machine,
                        EM_NONE),
     DEFINE_PROP_STRING("bios-name", PREPPCIState, pci_dev.bios_name),
-    /* Temporary workaround until legacy prep machine is removed */
-    DEFINE_PROP_BOOL("is-legacy-prep", PREPPCIState, is_legacy_prep,
-                     false),
     DEFINE_PROP_END_OF_LIST()
 };
 
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#9 lore raw

PATCH 3/4 hw/pci-host/prep: Fix PCI swizzling in map_irq()

In reply to Philippe Mathieu-Daudé

In commit a01d8cadadf we changed the number of IRQs to 4 but forgot to update the map_irq() function. Do it now.

Fixes a01d8cadadf ("Fix memory corruption ... in PreP emulation")

---

---
 hw/pci-host/prep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/pci-host/prep.c +1 -1
index 064593d1e52..2224135fedb 100644
@@ -195,7 +195,7 @@ static const MemoryRegionOps raven_io_ops = {
 
 static int raven_map_irq(PCIDevice *pci_dev, int irq_num)
 {
-    return (irq_num + (pci_dev->devfn >> 3)) & 1;
+    return (irq_num + (pci_dev->devfn >> 3)) & 3;
 }
 
 static void raven_set_irq(void *opaque, int irq_num, int level)
Signature · 1 line
2.26.2
#10 lore raw
Quoted 18 lines · Philippe Mathieu-Daudé

In commit a01d8cadadf we changed the number of IRQs to 4 but forgot to update the map_irq() function. Do it now.

Fixes a01d8cadadf ("Fix memory corruption ... in PreP emulation")

---

---
 hw/pci-host/prep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/pci-host/prep.c +0 -0
index 064593d1e52..2224135fedb 100644

hw/pci-host/prep.c static const MemoryRegionOps raven_io_ops = { · line 201

Quoted 8 lines
hw/pci-host/prep.c +1 -1
@@ -195,7 +195,7 @@ static const MemoryRegionOps raven_io_ops = {
 
 static int raven_map_irq(PCIDevice *pci_dev, int irq_num)
 {
-    return (irq_num + (pci_dev->devfn >> 3)) & 1;
+    return (irq_num + (pci_dev->devfn >> 3)) & 3;
 }
 
 static void raven_set_irq(void *opaque, int irq_num, int level)

It feels like this should also have a corresponding change in OpenBIOS for consistency, even though technically because of the OR on IRQ 15 it doesn't really matter. The relevant part in OpenBIOS can be found here:
https://git.qemu.org/?p=openbios.git;a=blob;f=drivers/pci.c;h=34ae69a907b6312a3a7ab218afe8ba9efded1df7;hb=7f28286f5cb1ca682e3ba0a8706d8884f12bc49e#l2001
and in particular this section:

/* Use the same "physical" routing as QEMU's raven_map_irq() although
ultimately all 4 PCI interrupts are ORd to IRQ 15 as indicated by the PReP specification */
props[(*ncells)++] = arch->irqs[((intno - 1) + (addr >> 11)) & 1];

ATB,

Mark.

#11 lore raw
Quoted 35 lines · Mark Cave-Ayland
Quoted 18 lines · Philippe Mathieu-Daudé

In commit a01d8cadadf we changed the number of IRQs to 4 but forgot to update the map_irq() function. Do it now.

Fixes a01d8cadadf ("Fix memory corruption ... in PreP emulation")

---

---
  hw/pci-host/prep.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/pci-host/prep.c +0 -0
index 064593d1e52..2224135fedb 100644

hw/pci-host/prep.c static const MemoryRegionOps raven_io_ops = { · line 201

Quoted 8 lines
hw/pci-host/prep.c +1 -1
@@ -195,7 +195,7 @@ static const MemoryRegionOps raven_io_ops = {
 
  static int raven_map_irq(PCIDevice *pci_dev, int irq_num)
  {
-    return (irq_num + (pci_dev->devfn >> 3)) & 1;
+    return (irq_num + (pci_dev->devfn >> 3)) & 3;
  }
 
  static void raven_set_irq(void *opaque, int irq_num, int level)

It feels like this should also have a corresponding change in OpenBIOS for consistency, even though technically because of the OR on IRQ 15 it doesn't really matter. The relevant part in OpenBIOS can be found here:
https://git.qemu.org/?p=openbios.git;a=blob;f=drivers/pci.c;h=34ae69a907b6312a3a7ab218afe8ba9efded1df7;hb=7f28286f5cb1ca682e3ba0a8706d8884f12bc49e#l2001
and in particular this section:

Quoted 4 lines

/* Use the same "physical" routing as QEMU's raven_map_irq() although
ultimately all 4 PCI interrupts are ORd to IRQ 15 as indicated by the PReP specification */
props[(*ncells)++] = arch->irqs[((intno - 1) + (addr >> 11)) & 1];

Done:
https://github.com/openbios/openbios/pull/7

Quoted 6 lines

ATB,

Mark.

#12 lore raw

PATCH 4/4 docs/system/target-ppc.rst: Update PReP historical information

In reply to Philippe Mathieu-Daudé

Link Jocelyn Mayer's web page from the Wayback Machine, and correct the PReP acronym.

---
Cc: Jocelyn Mayer <[email protected]>

---
 docs/system/target-ppc.rst | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
docs/system/target-ppc.rst +4 -4
index a2f04c533c2..1f57966771d 100644
@@ -3,7 +3,7 @@
 PowerPC System emulator
 -----------------------
 
-Use the executable ``qemu-system-ppc`` to simulate a complete 40P (PREP)
+Use the executable ``qemu-system-ppc`` to simulate a complete 40P (PReP)
 or PowerMac PowerPC system.
 
 QEMU emulates the following PowerMac peripherals:
@@ -20,7 +20,7 @@ QEMU emulates the following PowerMac peripherals:
 
 -  VIA-CUDA with ADB keyboard and mouse.
 
-QEMU emulates the following 40P (PREP) peripherals:
+QEMU emulates the following 40P (PReP) peripherals:
 
 -  PCI Bridge
 
@@ -43,5 +43,5 @@ the g3beige and mac99 PowerMac and the 40p machines. OpenBIOS is a free
 (GPL v2) portable firmware implementation. The goal is to implement a
 100% IEEE 1275-1994 (referred to as Open Firmware) compliant firmware.
 
-More information is available at
-http://perso.magic.fr/l_indien/qemu-ppc/.
+Archived historical information is available at
+https://web.archive.org/web/20051212135300/http://perso.magic.fr/l_indien/qemu-ppc/.
Signature · 1 line
2.26.2
Reviewed-by on v1 4/4
#13 lore raw

Re: [PATCH 4/4] docs/system/target-ppc.rst: Update PReP historical information

Quoted 33 lines · Philippe Mathieu-Daudé

Link Jocelyn Mayer's web page from the Wayback Machine, and correct the PReP acronym.

---
Cc: Jocelyn Mayer <[email protected]>

---
 docs/system/target-ppc.rst | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
docs/system/target-ppc.rst +2 -2
index a2f04c533c2..1f57966771d 100644
@@ -3,7 +3,7 @@
 PowerPC System emulator
 -----------------------
 
-Use the executable ``qemu-system-ppc`` to simulate a complete 40P (PREP)
+Use the executable ``qemu-system-ppc`` to simulate a complete 40P (PReP)
 or PowerMac PowerPC system.
 
 QEMU emulates the following PowerMac peripherals:
@@ -20,7 +20,7 @@ QEMU emulates the following PowerMac peripherals:
 
 -  VIA-CUDA with ADB keyboard and mouse.
 
-QEMU emulates the following 40P (PREP) peripherals:
+QEMU emulates the following 40P (PReP) peripherals:
 
 -  PCI Bridge
 

docs/system/target-ppc.rst the g3beige and mac99 PowerMac and the 40p machines. OpenBIOS is a free · line 47

Quoted 7 lines
docs/system/target-ppc.rst +2 -2
@@ -43,5 +43,5 @@ the g3beige and mac99 PowerMac and the 40p machines. OpenBIOS is a free
 (GPL v2) portable firmware implementation. The goal is to implement a
 100% IEEE 1275-1994 (referred to as Open Firmware) compliant firmware.
 
-More information is available at
-http://perso.magic.fr/l_indien/qemu-ppc/.
+Archived historical information is available at
+https://web.archive.org/web/20051212135300/http://perso.magic.fr/l_indien/qemu-ppc/.

There seems to be a later version available in the archive, too:

https://web.archive.org/web/20080212093125/http://perso.magic.fr/l_indien/qemu-ppc/

... but I think the contents did not change anymore. So: