Skip to contentSkip to conversation

PPC NewWorld fixery v3

PATCH In review Alexander Graf 3 participants 24 messages Jan 12, 2010 – Jan 13, 2010

lore
Share & tools
lore
#10 lore raw

PATCH 6/9 PPC: tell the guest about the time base frequency

In reply to Alexander Graf

Our guest systems need to know by how much the timebase increases every second, so there usually is a "timebase-frequency" property in the cpu leaf of the device tree.

This property is missing in OpenBIOS.

With qemu, Linux's fallback timebase speed and qemu's internal timebase speed match up. With KVM, that is no longer true. The guest is running at the same timebase speed as the host.

This leads to massive timing problems. On my test machine, a "sleep 2" takes about 14 seconds with KVM enabled.

This patch exports the timebase frequency to OpenBIOS, so it can then put them into the device tree.

---
 hw/ppc.h             |    1 +
 hw/ppc_newworld.c    |    9 +++++++++
 hw/ppc_oldworld.c    |    9 +++++++++
 target-ppc/kvm.c     |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 target-ppc/kvm_ppc.h |    2 ++
 5 files changed, 67 insertions(+), 0 deletions(-)
hw/ppc.h +1 -0
index b9a12a1..de13092 100644
@@ -46,5 +46,6 @@ enum {
 #define FW_CFG_PPC_WIDTH	(FW_CFG_ARCH_LOCAL + 0x00)
 #define FW_CFG_PPC_HEIGHT	(FW_CFG_ARCH_LOCAL + 0x01)
 #define FW_CFG_PPC_DEPTH	(FW_CFG_ARCH_LOCAL + 0x02)
+#define FW_CFG_PPC_TBFREQ	(FW_CFG_ARCH_LOCAL + 0x03)
 
 #define PPC_SERIAL_MM_BAUDBASE 399193
hw/ppc_newworld.c +9 -0
index 308e102..6c7a537 100644
@@ -40,6 +40,7 @@
 #include "loader.h"
 #include "elf.h"
 #include "kvm.h"
+#include "kvm_ppc.h"
 
 #define MAX_IDE_BUS 2
 #define VGA_BIOS_SIZE 65536
@@ -389,6 +390,14 @@ static void ppc_core99_init (ram_addr_t ram_size,
     fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height);
     fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth);
 
+    if (kvm_enabled()) {
+#ifdef CONFIG_KVM
+        fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, kvmppc_get_tbfreq());
+#endif
+    } else {
+        fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, get_ticks_per_sec());
+    }
+
     qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
 }
 
hw/ppc_oldworld.c +9 -0
index 7ccc6a1..04a7835 100644
@@ -40,6 +40,7 @@
 #include "loader.h"
 #include "elf.h"
 #include "kvm.h"
+#include "kvm_ppc.h"
 
 #define MAX_IDE_BUS 2
 #define VGA_BIOS_SIZE 65536
@@ -401,6 +402,14 @@ static void ppc_heathrow_init (ram_addr_t ram_size,
     fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height);
     fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth);
 
+    if (kvm_enabled()) {
+#ifdef CONFIG_KVM
+        fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, kvmppc_get_tbfreq());
+#endif
+    } else {
+        fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, get_ticks_per_sec());
+    }
+
     qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
 }
 
target-ppc/kvm.c +46 -0

49 lines not on this page · raw message

target-ppc/kvm_ppc.h +2 -0
index 3792ef7..e8d66e8 100644
@@ -14,4 +14,6 @@ void kvmppc_fdt_update(void *fdt);
 int kvmppc_read_host_property(const char *node_path, const char *prop,
                                      void *val, size_t len);
 
+uint32_t kvmppc_get_tbfreq(void);
+
 #endif /* __KVM_PPC_H__ */
Signature · 1 line
1.6.0.2
#0 lore raw

cover PPC NewWorld fixery v3

I'm trying to get the PPC64 system emulation target working finally. While doing so, I ran into several issues, all related to PCI this time.

This patchset fixes all the PCI config space access and PCI interrupt mapping issues I've found on PPC64. Using this and a patched OpenBIOS version, I can successfully access IDE devices and was booting a guest into the shell from IDE using serial console.

To leverage this patch, you also need a few patches to OpenBIOS. I'll present them to the OpenBIOS list, but in general getting patches into Qemu is harder than getting them into OpenBIOS. So I want to wait for the review process here first.

Find the OpenBIOS patch at: http://alex.csgraf.de/openbios-ppc-u3.patch

v1 -> v2:

- use decoding function for config space bits
- merge config space data access functions
- introduce encoding function for x86 style encodings
- convert Uninorth to use config space decoder

v2 -> v3:

- call pci_addr_to_devfn pci_addr_to_config_reg
- split out debug fix
- call convert functions config_addr instead of config_reg
- no spaces between braces
- dropped: Enable secondary cmd64x
- new: Tell the guest about the time base frequency
- new: Use macio IDE controller for Newworld
- new: Get rid of segfaults in DBDMA emulation
- new: Add USB per default on U3

Alexander Graf (9):
PCI: PCI config space access overhaul
PPC: Add config space conversion function for uni_north
PPC: Use Mac99_U3 type on ppc64
PPC: Include dump of lspci -nn on real G5
PPC: Make interrupts work
PPC: tell the guest about the time base frequency
PPC: Use macio IDE controller for Newworld
PPC: Get rid of segfaults in DBDMA emulation
PPC: Add USB per default on U3

 hw/apb_pci.c               |    1 +
 hw/grackle_pci.c           |    1 +
 hw/gt64xxx.c               |    1 +
 hw/mac_dbdma.c             |   10 ++-
 hw/pci.h                   |   13 ++++
 hw/pci_host.c              |   46 ++++++++++++---
 hw/pci_host.h              |   16 +++++
 hw/pci_host_template.h     |   92 +++++++++--------------------
 hw/pci_host_template_all.h |   23 +++++++
 hw/pci_ids.h               |    1 +
 hw/piix_pci.c              |    1 +
 hw/ppc.h                   |    2 +
 hw/ppc4xx_pci.c            |    1 +
 hw/ppc_mac.h               |    1 +
 hw/ppc_newworld.c          |   49 +++++++++++++---
 hw/ppc_oldworld.c          |    9 +++
 hw/ppce500_pci.c           |    1 +
 hw/unin_pci.c              |  141 +++++++++++++++++++++++++++++++++++++++++++-
 target-ppc/kvm.c           |   46 ++++++++++++++
 target-ppc/kvm_ppc.h       |    2 +
 20 files changed, 370 insertions(+), 87 deletions(-)
 create mode 100644 hw/pci_host_template_all.h
#1 lore raw

PATCH 1/9 PCI: PCI config space access overhaul

Different host buses may have different layouts for config space accessors.

The Mac U3 for example uses the following define to access Type 0 (directly attached) devices:

  #define MACRISC_CFA0(devfn, off)        \
        ((1 << (unsigned int)PCI_SLOT(dev_fn)) \
        | (((unsigned int)PCI_FUNC(dev_fn)) << 8) \
        | (((unsigned int)(off)) & 0xFCUL))

Obviously, this is different from the encoding we interpret in qemu. In order to let host controllers take some influence there, we can just introduce a decoding function that takes whatever accessor we have and decodes it into understandable fields.

To not touch all different code paths in qemu, I added this on top of the existing config_reg element. In the future, we should work on gradually moving references to config_reg to config_reg_dec and then phase out config_reg.

This patch is the groundwork for Uninorth PCI config space fixes.

CC Michael S. Tsirkin <[email protected]>
CC Isaku Yamahata <[email protected]>

---

v1 -> v2:

- merge data access functions
- use decoding function for config space bits
- introduce encoding function for x86 style encodings

v2 -> v3:

- call pci_addr_to_devfn pci_addr_to_config_reg
- revert debug fix
- call convert functions config_addr instead of config_reg
- no spaces between braces

---
 hw/apb_pci.c               |    1 +
 hw/grackle_pci.c           |    1 +
 hw/gt64xxx.c               |    1 +
 hw/pci.h                   |   13 ++++++
 hw/pci_host.c              |   46 ++++++++++++++++++----
 hw/pci_host.h              |   16 ++++++++
 hw/pci_host_template.h     |   92 +++++++++++++------------------------------
 hw/pci_host_template_all.h |   23 +++++++++++
 hw/piix_pci.c              |    1 +
 hw/ppc4xx_pci.c            |    1 +
 hw/ppce500_pci.c           |    1 +
 hw/unin_pci.c              |    1 +
 12 files changed, 124 insertions(+), 73 deletions(-)
 create mode 100644 hw/pci_host_template_all.h
hw/apb_pci.c +1 -0
index c14e1c0..05e7f38 100644
@@ -300,6 +300,7 @@ PCIBus *pci_apb_init(target_phys_addr_t special_base,
     /* mem_data */
     sysbus_mmio_map(s, 4, mem_base);
     d = FROM_SYSBUS(APBState, s);
+    pci_host_init(&d->host_state);
     d->host_state.bus = pci_register_bus(&d->busdev.qdev, "pci",
                                          pci_apb_set_irq, pci_pbm_map_irq, pic,
                                          0, 32);
hw/grackle_pci.c +1 -0
index ee4fed5..7feba63 100644
@@ -88,6 +88,7 @@ PCIBus *pci_grackle_init(uint32_t base, qemu_irq *pic)
     qdev_init_nofail(dev);
     s = sysbus_from_qdev(dev);
     d = FROM_SYSBUS(GrackleState, s);
+    pci_host_init(&d->host_state);
     d->host_state.bus = pci_register_bus(&d->busdev.qdev, "pci",
                                          pci_grackle_set_irq,
                                          pci_grackle_map_irq,
hw/gt64xxx.c +1 -0
index c8034e2..b3a951b 100644
@@ -1109,6 +1109,7 @@ PCIBus *pci_gt64120_init(qemu_irq *pic)
     s = qemu_mallocz(sizeof(GT64120State));
     s->pci = qemu_mallocz(sizeof(GT64120PCIState));
 
+    pci_host_init(s->pci);
     s->pci->bus = pci_register_bus(NULL, "pci",
                                    pci_gt64120_set_irq, pci_gt64120_map_irq,
                                    pic, 144, 4);
hw/pci.h +13 -0
index ed048f5..0106d3e 100644
@@ -10,10 +10,23 @@
 
 /* PCI bus */
 
+typedef struct PCIAddress {
+    PCIBus *domain;
+    uint8_t bus;
+    uint8_t slot;
+    uint8_t fn;
+} PCIAddress;
+
 #define PCI_DEVFN(slot, func)   ((((slot) & 0x1f) << 3) | ((func) & 0x07))
 #define PCI_SLOT(devfn)         (((devfn) >> 3) & 0x1f)
 #define PCI_FUNC(devfn)         ((devfn) & 0x07)
 
+static inline uint32_t pci_addr_to_config_reg(PCIAddress *addr, uint32_t offset)
+{
+    return ((addr->bus & 0xff) << 16) | (PCI_DEVFN(addr->slot, addr->fn) << 8) |
+           offset;
+}
+
 /* Class, Vendor and Device IDs from Linux's pci_ids.h */
 #include "pci_ids.h"
 
hw/pci_host.c +37 -9

88 lines not on this page · raw message

hw/pci_host.h +16 -0
index a006687..064ad96 100644
@@ -30,14 +30,30 @@
 
 #include "sysbus.h"
 
+/* for config space access */
+typedef struct PCIConfigAddress {
+    PCIAddress addr;
+    uint32_t addr_mask;
+    uint16_t offset;
+    bool valid;
+} PCIConfigAddress;
+
+typedef void (*pci_config_addr_fn)(PCIHostState *s, uint32_t config_reg,
+                                   PCIConfigAddress *conf);
+
 struct PCIHostState {
     SysBusDevice busdev;
+    pci_config_addr_fn decode_config_addr;
+    PCIConfigAddress config_addr;
     uint32_t config_reg;
     PCIBus *bus;
 };
 
 void pci_data_write(PCIBus *s, uint32_t addr, uint32_t val, int len);
 uint32_t pci_data_read(PCIBus *s, uint32_t addr, int len);
+void pci_host_init(PCIHostState *s);
+void pci_host_decode_config_addr(PCIHostState *s, uint32_t config_reg,
+                                PCIConfigAddress *decoded);
 
 /* for mmio */
 int pci_host_conf_register_mmio(PCIHostState *s);
hw/pci_host_template.h +28 -64

113 lines not on this page · raw message

hw/pci_host_template_all.h new file +23 -0
new file mode 100644
index 0000000..74b3e84
@@ -0,0 +1,23 @@
+#define PCI_HOST_BWL    b
+#define PCI_HOST_BITS   8
+
+#include "pci_host_template.h"
+
+#undef PCI_HOST_BWL
+#undef PCI_HOST_BITS
+
+#define PCI_HOST_BWL    w
+#define PCI_HOST_BITS   16
+
+#include "pci_host_template.h"
+
+#undef PCI_HOST_BWL
+#undef PCI_HOST_BITS
+
+#define PCI_HOST_BWL    l
+#define PCI_HOST_BITS   32
+
+#include "pci_host_template.h"
+
+#undef PCI_HOST_BWL
+#undef PCI_HOST_BITS
hw/piix_pci.c +1 -0
index cd12212..2bdf03b 100644
@@ -223,6 +223,7 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, qemu_irq *
 
     dev = qdev_create(NULL, "i440FX-pcihost");
     s = FROM_SYSBUS(I440FXState, sysbus_from_qdev(dev));
+    pci_host_init(s);
     b = pci_bus_new(&s->busdev.qdev, NULL, 0);
     s->bus = b;
     qdev_init_nofail(dev);
hw/ppc4xx_pci.c +1 -0
index 2d00b61..dd8e290 100644
@@ -357,6 +357,7 @@ PCIBus *ppc4xx_pci_init(CPUState *env, qemu_irq pci_irqs[4],
 
     controller = qemu_mallocz(sizeof(PPC4xxPCIState));
 
+    pci_host_init(&controller->pci_state);
     controller->pci_state.bus = pci_register_bus(NULL, "pci",
                                                  ppc4xx_pci_set_irq,
                                                  ppc4xx_pci_map_irq,
hw/ppce500_pci.c +1 -0
index a72fb86..5914183 100644
@@ -278,6 +278,7 @@ PCIBus *ppce500_pci_init(qemu_irq pci_irqs[4], target_phys_addr_t registers)
 
     controller = qemu_mallocz(sizeof(PPCE500PCIState));
 
+    pci_host_init(&controller->pci_state);
     controller->pci_state.bus = pci_register_bus(NULL, "pci",
                                                  mpc85xx_pci_set_irq,
                                                  mpc85xx_pci_map_irq,
hw/unin_pci.c +1 -0
index 3ae4e7a..fdb9401 100644
@@ -84,6 +84,7 @@ static int pci_unin_main_init_device(SysBusDevice *dev)
     /* Uninorth main bus */
     s = FROM_SYSBUS(UNINState, dev);
 
+    pci_host_init(&s->host_state);
     pci_mem_config = pci_host_conf_register_mmio(&s->host_state);
     pci_mem_data = pci_host_data_register_mmio(&s->host_state);
     sysbus_init_mmio(dev, 0x1000, pci_mem_config);
Signature · 1 line
1.6.0.2
#12 lore raw

PATCH 8/9 PPC: Get rid of segfaults in DBDMA emulation

In reply to Alexander Graf

While trying to find the right channel number for the DBDMA emulation I stumbled across segmentation faults that were purely triggered by the guest.

The guest should never have the possiblity to segfault us, so let's check all indirect function calls on a channel, so the code even works for channels that have not been reserved.

---
 hw/mac_dbdma.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
hw/mac_dbdma.c +7 -3
index 8ec3d99..8f94c35 100644
@@ -402,7 +402,9 @@ static void start_output(DBDMA_channel *ch, int key, uint32_t addr,
     ch->io.dma_end = dbdma_end;
     ch->io.is_dma_out = 1;
     ch->processing = 1;
-    ch->rw(&ch->io);
+    if (ch->rw) {
+        ch->rw(&ch->io);
+    }
 }
 
 static void start_input(DBDMA_channel *ch, int key, uint32_t addr,
@@ -425,7 +427,9 @@ static void start_input(DBDMA_channel *ch, int key, uint32_t addr,
     ch->io.dma_end = dbdma_end;
     ch->io.is_dma_out = 0;
     ch->processing = 1;
-    ch->rw(&ch->io);
+    if (ch->rw) {
+        ch->rw(&ch->io);
+    }
 }
 
 static void load_word(DBDMA_channel *ch, int key, uint32_t addr,
@@ -688,7 +692,7 @@ dbdma_control_write(DBDMA_channel *ch)
 
     if (status & ACTIVE)
         qemu_bh_schedule(dbdma_bh);
-    if (status & FLUSH)
+    if ((status & FLUSH) && ch->flush)
         ch->flush(&ch->io);
 }
 
Signature · 1 line
1.6.0.2
#9 lore raw

PATCH 5/9 PPC: Make interrupts work

In reply to Alexander Graf

The interrupt code as is didn't really work for me. I couldn't even convince Linux to take interrupt 9 in an interrupt-map.

So let's do this right. Let's map all PCI interrupts to 0x1b - 0x1e. That way we're at least a small step closer to what real hardware does.

I also took the interrupt pin to line conversion from OpenBIOS, which at least assures us we're compatible with our firmware :-).

A dump of the PCI interrupt-map from a U2 (iBook):

00009000 00000000 00000000 00000000 ff97c528 00000034 00000001 0000d800 00000000 00000000 00000000 ff97c528 0000003f 00000001 0000c000 00000000 00000000 00000000 ff97c528 0000001b 00000001 0000c800 00000000 00000000 00000000 ff97c528 0000001c 00000001 0000d000 00000000 00000000 00000000 ff97c528 0000001d 00000001

---
 hw/unin_pci.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)
hw/unin_pci.c +11 -3
index 1e32d63..ca980ec 100644
@@ -36,22 +36,30 @@
 #define UNIN_DPRINTF(fmt, ...)
 #endif
 
+static const int unin_irq_line[] = { 0x1b, 0x1c, 0x1d, 0x1e };
+
 typedef struct UNINState {
     SysBusDevice busdev;
     PCIHostState host_state;
 } UNINState;
 
-/* Don't know if this matches real hardware, but it agrees with OHW.  */
 static int pci_unin_map_irq(PCIDevice *pci_dev, int irq_num)
 {
-    return (irq_num + (pci_dev->devfn >> 3)) & 3;
+    int retval;
+    int devfn = pci_dev->devfn & 0x00FFFFFF;
+ 
+    retval = (((devfn >> 11) & 0x1F) + irq_num) & 3;
+ 
+    return retval;
 }
 
 static void pci_unin_set_irq(void *opaque, int irq_num, int level)
 {
     qemu_irq *pic = opaque;
 
-    qemu_set_irq(pic[irq_num + 8], level);
+    UNIN_DPRINTF("%s: setting INT %d = %d\n", __func__,
+                 unin_irq_line[irq_num], level);
+    qemu_set_irq(pic[unin_irq_line[irq_num]], level);
 }
 
 static void pci_unin_save(QEMUFile* f, void *opaque)
Signature · 1 line
1.6.0.2
#2 lore raw

PATCH 2/9 PPC: Add config space conversion function for uni_north

In reply to Alexander Graf

As stated in the previous patch, the Uninorth PCI bridge requires different layouts in its PCI config space accessors.

This patch introduces a conversion function that makes it compatible with the way Linux accesses it.

I also kept an OpenBIOS compatibility hack in. I think it'd be better to take small steps here and do the config space access rework in OpenBIOS later on. When that's done we can remove that hack.

CC Michael S. Tsirkin <[email protected]>
CC Isaku Yamahata <[email protected]>

---

v1 -> v2:

- convert Uninorth to use config space decoder

v2 -> v3:

- stick to new naming scheme

---
 hw/unin_pci.c |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)
hw/unin_pci.c +31 -0
index fdb9401..64ad23e 100644
@@ -75,6 +75,36 @@ static void pci_unin_reset(void *opaque)
 {
 }
 
+static void unin_decode_config_addr(PCIHostState *s, uint32_t config_reg,
+                                    PCIConfigAddress *decoded)
+{
+    decoded->addr.domain = s->bus;
+    decoded->addr_mask = 7;
+    decoded->offset = config_reg & 0xfc;
+    decoded->addr.fn = (config_reg >> 8) & 0x7;
+
+    if (config_reg & (1u << 31)) {
+        /* XXX OpenBIOS compatibility hack */
+        pci_host_decode_config_addr(s, config_reg, decoded);
+    } else if (config_reg & 1) {
+        /* CFA1 style values */
+
+        decoded->valid = (config_reg & 1) ? true : false;
+        decoded->addr.bus = (config_reg >> 16) & 0xff;
+        decoded->addr.slot = (config_reg >> 11) & 0x1f;
+    } else {
+        /* CFA0 style values */
+
+        decoded->valid = true;
+        decoded->addr.bus = 0;
+        decoded->addr.slot = ffs(config_reg & 0xfffff800) - 1;
+    }
+
+    UNIN_DPRINTF("Converted config space accessor %08x -> %02x %02x %x\n",
+                 config_reg, decoded->addr.bus, decoded->addr.slot,
+                 decoded->addr.fn);
+}
+
 static int pci_unin_main_init_device(SysBusDevice *dev)
 {
     UNINState *s;
@@ -85,6 +115,7 @@ static int pci_unin_main_init_device(SysBusDevice *dev)
     s = FROM_SYSBUS(UNINState, dev);
 
     pci_host_init(&s->host_state);
+    s->host_state.decode_config_addr = unin_decode_config_addr;
     pci_mem_config = pci_host_conf_register_mmio(&s->host_state);
     pci_mem_data = pci_host_data_register_mmio(&s->host_state);
     sysbus_init_mmio(dev, 0x1000, pci_mem_config);
Signature · 1 line
1.6.0.2
#3 lore raw

PATCH 3/9 PPC: Use Mac99_U3 type on ppc64

In reply to Alexander Graf

The "Mac99" type so far defines a "U2" based configuration. Unfortunately, there have never been any U2 based PPC64 machines. That's what the U3 was developed for.

So let's split the Mac99 machine in a PPC64 and a PPC32 machine. The PPC32 machine stays "Mac99", while the PPC64 one becomes "Mac99_U3". All peripherals stay the same.

---

v1 -> v2:

- s/get_config/decode_config/

v2 -> v3:

- stick to new naming scheme

---
 hw/pci_ids.h      |    1 +
 hw/ppc.h          |    1 +
 hw/ppc_mac.h      |    1 +
 hw/ppc_newworld.c |   12 +++++++-
 hw/unin_pci.c     |   70 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 83 insertions(+), 2 deletions(-)
hw/pci_ids.h +1 -0
index 63379c2..fe7a121 100644
@@ -63,6 +63,7 @@
 
 #define PCI_VENDOR_ID_APPLE              0x106b
 #define PCI_DEVICE_ID_APPLE_UNI_N_AGP    0x0020
+#define PCI_DEVICE_ID_APPLE_U3_AGP       0x004b
 
 #define PCI_VENDOR_ID_SUN                0x108e
 #define PCI_DEVICE_ID_SUN_EBUS           0x1000
hw/ppc.h +1 -0
index bbf3a98..b9a12a1 100644
@@ -40,6 +40,7 @@ enum {
     ARCH_PREP = 0,
     ARCH_MAC99,
     ARCH_HEATHROW,
+    ARCH_MAC99_U3,
 };
 
 #define FW_CFG_PPC_WIDTH	(FW_CFG_ARCH_LOCAL + 0x00)
hw/ppc_mac.h +1 -0
index a04dffe..89f96bb 100644
@@ -58,6 +58,7 @@ PCIBus *pci_grackle_init(uint32_t base, qemu_irq *pic);
 
 /* UniNorth PCI */
 PCIBus *pci_pmac_init(qemu_irq *pic);
+PCIBus *pci_pmac_u3_init(qemu_irq *pic);
 
 /* Mac NVRAM */
 typedef struct MacIONVRAMState MacIONVRAMState;
hw/ppc_newworld.c +10 -2
index a4c714a..308e102 100644
@@ -114,6 +114,7 @@ static void ppc_core99_init (ram_addr_t ram_size,
     void *fw_cfg;
     void *dbdma;
     uint8_t *vga_bios_ptr;
+    int machine_arch;
 
     linux_boot = (kernel_filename != NULL);
 
@@ -317,7 +318,14 @@ static void ppc_core99_init (ram_addr_t ram_size,
         }
     }
     pic = openpic_init(NULL, &pic_mem_index, smp_cpus, openpic_irqs, NULL);
-    pci_bus = pci_pmac_init(pic);
+    if (PPC_INPUT(env) == PPC_FLAGS_INPUT_970) {
+        /* 970 gets a U3 bus */
+        pci_bus = pci_pmac_u3_init(pic);
+        machine_arch = ARCH_MAC99_U3;
+    } else {
+        pci_bus = pci_pmac_init(pic);
+        machine_arch = ARCH_MAC99;
+    }
     /* init basic PC hardware */
     pci_vga_init(pci_bus, vga_bios_offset, vga_bios_size);
 
@@ -364,7 +372,7 @@ static void ppc_core99_init (ram_addr_t ram_size,
     fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2);
     fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
     fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
-    fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, ARCH_MAC99);
+    fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, machine_arch);
     fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_base);
     fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
     if (kernel_cmdline) {
hw/unin_pci.c +70 -0

100 lines not on this page · raw message

Signature · 1 line
1.6.0.2
#4 lore raw

PATCH 4/9 PPC: Include dump of lspci -nn on real G5

In reply to Alexander Graf

To ease debugging and to know what we're lacking, I found it really useful to have an lspci dump of a real U3 based G5 around. So I added a comment for it.

If people don't think it's important enough to include this information in the sources, just don't apply this patch.

---
 hw/unin_pci.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
hw/unin_pci.c +25 -0
index 8e1a471..1e32d63 100644
@@ -244,6 +244,31 @@ PCIBus *pci_pmac_init(qemu_irq *pic)
     return d->host_state.bus;
 }
 
+/*
+ * PCI bus layout on a real G5 (U3 based):
+ *
+ * 0000:f0:0b.0 Host bridge [0600]: Apple Computer Inc. U3 AGP [106b:004b]
+ * 0000:f0:10.0 VGA compatible controller [0300]: ATI Technologies Inc RV350 AP [Radeon 9600] [1002:4150]
+ * 0001:00:00.0 Host bridge [0600]: Apple Computer Inc. CPC945 HT Bridge [106b:004a]
+ * 0001:00:01.0 PCI bridge [0604]: Advanced Micro Devices [AMD] AMD-8131 PCI-X Bridge [1022:7450] (rev 12)
+ * 0001:00:02.0 PCI bridge [0604]: Advanced Micro Devices [AMD] AMD-8131 PCI-X Bridge [1022:7450] (rev 12)
+ * 0001:00:03.0 PCI bridge [0604]: Apple Computer Inc. K2 HT-PCI Bridge [106b:0045]
+ * 0001:00:04.0 PCI bridge [0604]: Apple Computer Inc. K2 HT-PCI Bridge [106b:0046]
+ * 0001:00:05.0 PCI bridge [0604]: Apple Computer Inc. K2 HT-PCI Bridge [106b:0047]
+ * 0001:00:06.0 PCI bridge [0604]: Apple Computer Inc. K2 HT-PCI Bridge [106b:0048]
+ * 0001:00:07.0 PCI bridge [0604]: Apple Computer Inc. K2 HT-PCI Bridge [106b:0049]
+ * 0001:01:07.0 Class [ff00]: Apple Computer Inc. K2 KeyLargo Mac/IO [106b:0041] (rev 20)
+ * 0001:01:08.0 USB Controller [0c03]: Apple Computer Inc. K2 KeyLargo USB [106b:0040]
+ * 0001:01:09.0 USB Controller [0c03]: Apple Computer Inc. K2 KeyLargo USB [106b:0040]
+ * 0001:02:0b.0 USB Controller [0c03]: NEC Corporation USB [1033:0035] (rev 43)
+ * 0001:02:0b.1 USB Controller [0c03]: NEC Corporation USB [1033:0035] (rev 43)
+ * 0001:02:0b.2 USB Controller [0c03]: NEC Corporation USB 2.0 [1033:00e0] (rev 04)
+ * 0001:03:0d.0 Class [ff00]: Apple Computer Inc. K2 ATA/100 [106b:0043]
+ * 0001:03:0e.0 FireWire (IEEE 1394) [0c00]: Apple Computer Inc. K2 FireWire [106b:0042]
+ * 0001:04:0f.0 Ethernet controller [0200]: Apple Computer Inc. K2 GMAC (Sun GEM) [106b:004c]
+ * 0001:05:0c.0 IDE interface [0101]: Broadcom K2 SATA [1166:0240]
+ *
+ */
 PCIBus *pci_pmac_u3_init(qemu_irq *pic)
 {
     DeviceState *dev;
Signature · 1 line
1.6.0.2
#11 lore raw

PATCH 7/9 PPC: Use macio IDE controller for Newworld

In reply to Alexander Graf

Per default Linux doesn't come with a lot of storage adapters enabled on Mac configurations. The one that's pretty much always present is the pmac-ide, while the cmd64x is almost never included in any distribution.

So let's switch to use the MacIO based IDE controller. There is corresponding OpenBIOS code to get interrupts working properly.

---
 hw/ppc_newworld.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)
hw/ppc_newworld.c +11 -5
index 6c7a537..c08211e 100644
@@ -110,6 +110,7 @@ static void ppc_core99_init (ram_addr_t ram_size,
     int nvram_mem_index;
     int vga_bios_size, bios_size;
     int pic_mem_index, dbdma_mem_index, cuda_mem_index, escc_mem_index;
+    int ide_mem_index[3];
     int ppc_boot_device;
     DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
     void *fw_cfg;
@@ -340,11 +341,16 @@ static void ppc_core99_init (ram_addr_t ram_size,
         fprintf(stderr, "qemu: too many IDE bus\n");
         exit(1);
     }
-    for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) {
-        hd[i] = drive_get(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS);
-    }
     dbdma = DBDMA_init(&dbdma_mem_index);
-    pci_cmd646_ide_init(pci_bus, hd, 0);
+
+    /* We only emulate 2 out of 3 IDE controllers for now */
+    ide_mem_index[0] = -1;
+    hd[0] = drive_get(IF_IDE, 0, 0);
+    hd[1] = drive_get(IF_IDE, 0, 1);
+    ide_mem_index[1] = pmac_ide_init(hd, pic[0x0d], dbdma, 0x16, pic[0x02]);
+    hd[0] = drive_get(IF_IDE, 1, 0);
+    hd[1] = drive_get(IF_IDE, 1, 1);
+    ide_mem_index[2] = pmac_ide_init(hd, pic[0x0e], dbdma, 0x1a, pic[0x02]);
 
     /* cuda also initialize ADB */
     cuda_init(&cuda_mem_index, pic[0x19]);
@@ -354,7 +360,7 @@ static void ppc_core99_init (ram_addr_t ram_size,
 
 
     macio_init(pci_bus, PCI_DEVICE_ID_APPLE_UNI_N_KEYL, 0, pic_mem_index,
-               dbdma_mem_index, cuda_mem_index, NULL, 0, NULL,
+               dbdma_mem_index, cuda_mem_index, NULL, 3, ide_mem_index,
                escc_mem_index);
 
     if (usb_enabled) {
Signature · 1 line
1.6.0.2
#13 lore raw

PATCH 9/9 PPC: Add USB per default on U3

In reply to Alexander Graf

Linux with CONFIG_PPC64 doesn't support ADB devices anymore, so we have to use USB for keyboard and mouse.

This patch enables USB per default on U3 and adds a virtual keyboard and mouse there.

---
 hw/ppc_newworld.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
hw/ppc_newworld.c +11 -1
index c08211e..52a56e4 100644
@@ -41,6 +41,7 @@
 #include "elf.h"
 #include "kvm.h"
 #include "kvm_ppc.h"
+#include "hw/usb.h"
 
 #define MAX_IDE_BUS 2
 #define VGA_BIOS_SIZE 65536
@@ -353,12 +354,14 @@ static void ppc_core99_init (ram_addr_t ram_size,
     ide_mem_index[2] = pmac_ide_init(hd, pic[0x0e], dbdma, 0x1a, pic[0x02]);
 
     /* cuda also initialize ADB */
+    if (machine_arch == ARCH_MAC99_U3) {
+        usb_enabled = 1;
+    }
     cuda_init(&cuda_mem_index, pic[0x19]);
 
     adb_kbd_init(&adb_bus);
     adb_mouse_init(&adb_bus);
 
-
     macio_init(pci_bus, PCI_DEVICE_ID_APPLE_UNI_N_KEYL, 0, pic_mem_index,
                dbdma_mem_index, cuda_mem_index, NULL, 3, ide_mem_index,
                escc_mem_index);
@@ -367,6 +370,13 @@ static void ppc_core99_init (ram_addr_t ram_size,
         usb_ohci_init_pci(pci_bus, -1);
     }
 
+    /* U3 needs to use USB for input because Linux doesn't support via-cuda
+       on PPC64 */
+    if (machine_arch == ARCH_MAC99_U3) {
+        usbdevice_create("keyboard");
+        usbdevice_create("mouse");
+    }
+
     if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
         graphic_depth = 15;
 
Signature · 1 line
1.6.0.2
#16 lore raw
In reply to Alexander Graf
Quoted 8 lines · Alexander Graf

I'm trying to get the PPC64 system emulation target working finally. While doing so, I ran into several issues, all related to PCI this time.

This patchset fixes all the PCI config space access and PCI interrupt mapping issues I've found on PPC64. Using this and a patched OpenBIOS version, I can successfully access IDE devices and was booting a guest into the shell from IDE using serial console.

Quoted 6 lines

To leverage this patch, you also need a few patches to OpenBIOS. I'll present them to the OpenBIOS list, but in general getting patches into Qemu is harder than getting them into OpenBIOS. So I want to wait for the review process here first.

Find the OpenBIOS patch at: http://alex.csgraf.de/openbios-ppc-u3.patch

About the OpenBIOS patch, could you move the PCI_INT_MAP defines to a PPC-specific header and make pci_host_set_interrupt_map() contents surrounded by #ifdef CONFIG_PPC (to make it empty function for other arches)?

#5 lore raw

Re: [Qemu-devel] [PATCH 4/9] PPC: Include dump of lspci -nn on real G5

In reply to Alexander Graf
Quoted 5 lines · Alexander Graf

To ease debugging and to know what we're lacking, I found it really useful to have an lspci dump of a real U3 based G5 around. So I added a comment for it.

If people don't think it's important enough to include this information in the sources, just don't apply this patch.

I think it would be useful, but the right place would be in ppc_newworld.c, because that is where the PCI bus is populated.

For unin_pci.c, an interesting reference would be a link to the data sheet.

#17 lore raw
In reply to Blue Swirl
Quoted 14 lines · Blue Swirl
Quoted 13 lines · Alexander Graf

I'm trying to get the PPC64 system emulation target working finally. While doing so, I ran into several issues, all related to PCI this time.

This patchset fixes all the PCI config space access and PCI interrupt mapping issues I've found on PPC64. Using this and a patched OpenBIOS version, I can successfully access IDE devices and was booting a guest into the shell from IDE using serial console.

To leverage this patch, you also need a few patches to OpenBIOS. I'll present them to the OpenBIOS list, but in general getting patches into Qemu is harder than getting them into OpenBIOS. So I want to wait for the review process here first.

Quoted 6 lines
Quoted 1 line

Find the OpenBIOS patch at: http://alex.csgraf.de/openbios-ppc-u3.patch

About the OpenBIOS patch, could you move the PCI_INT_MAP defines to a PPC-specific header and make pci_host_set_interrupt_map() contents surrounded by #ifdef CONFIG_PPC (to make it empty function for other arches)?

Well, other archs should be able to use the same code. If OpenBIOS knows how interrupts work for a particular device, it really should tell the OS about it too IMHO.

Alex

#6 lore raw

Re: [Qemu-devel] [PATCH 4/9] PPC: Include dump of lspci -nn on real G5

In reply to Blue Swirl
Quoted 9 lines · Blue Swirl
Quoted 5 lines · Alexander Graf

To ease debugging and to know what we're lacking, I found it really useful to have an lspci dump of a real U3 based G5 around. So I added a comment for it.

If people don't think it's important enough to include this information in the sources, just don't apply this patch.

I think it would be useful, but the right place would be in ppc_newworld.c, because that is where the PCI bus is populated.

Hum, that file is pretty cluttered already. How about we create a Documentation subdir in qemu that contains information about various devices?

Quoted 1 line

For unin_pci.c, an interesting reference would be a link to the data sheet.

I'm not aware of any. The only real specification I know of is for the U4.

Alex

#7 lore raw

Re: [Qemu-devel] [PATCH 4/9] PPC: Include dump of lspci -nn on real G5

Quoted 7 lines · Alexander Graf
Quoted 4 lines · Blue Swirl
Quoted 3 lines · Alexander Graf

To ease debugging and to know what we're lacking, I found it really useful to have an lspci dump of a real U3 based G5 around. So I added a comment for it.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

If people don't think it's important enough to include this information in the sources, just don't apply this patch.

I think it would be useful, but the right place would be in ppc_newworld.c, because that is where the PCI bus is populated.

Hum, that file is pretty cluttered already. How about we create a Documentation subdir in qemu that contains information about various devices?

Nobody reads documentation :) There's plenty of room near line 50, that's where I have put references in other files.

Quoted 3 lines
Quoted 1 line

For unin_pci.c, an interesting reference would be a link to the data sheet.

I'm not aware of any. The only real specification I know of is for the U4.

Then U4 may be a more interesting machine to be implemented than U3, at least if there are more documented devices or fewer critical undocumented devices.

#8 lore raw

Re: [Qemu-devel] [PATCH 4/9] PPC: Include dump of lspci -nn on real G5

Quoted 19 lines · Blue Swirl
Quoted 7 lines · Alexander Graf
Quoted 4 lines · Blue Swirl
Quoted 3 lines · Alexander Graf

To ease debugging and to know what we're lacking, I found it really useful to have an lspci dump of a real U3 based G5 around. So I added a comment for it.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

If people don't think it's important enough to include this information in the sources, just don't apply this patch.

I think it would be useful, but the right place would be in ppc_newworld.c, because that is where the PCI bus is populated.

Hum, that file is pretty cluttered already. How about we create a Documentation subdir in qemu that contains information about various devices?

Nobody reads documentation :) There's plenty of room near line 50, that's where I have put references in other files.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

For unin_pci.c, an interesting reference would be a link to the data sheet.

I'm not aware of any. The only real specification I know of is for the U4.

Then U4 may be a more interesting machine to be implemented than U3, at least if there are more documented devices or fewer critical undocumented devices.

The easy part about U3 is that it's accessed the same way as U2, so the PPC32 code can be reused.
Eventually we need a U4 target though, especially since that also implements PCIe. For now it's one thing at a time - first a proof of concept for KVM and then a U4 :).

Alex

#18 lore raw
In reply to Alexander Graf
Quoted 17 lines · Alexander Graf
Quoted 14 lines · Blue Swirl
Quoted 13 lines · Alexander Graf

I'm trying to get the PPC64 system emulation target working finally. While doing so, I ran into several issues, all related to PCI this time.

This patchset fixes all the PCI config space access and PCI interrupt mapping issues I've found on PPC64. Using this and a patched OpenBIOS version, I can successfully access IDE devices and was booting a guest into the shell from IDE using serial console.

To leverage this patch, you also need a few patches to OpenBIOS. I'll present them to the OpenBIOS list, but in general getting patches into Qemu is harder than getting them into OpenBIOS. So I want to wait for the review process here first.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Find the OpenBIOS patch at: http://alex.csgraf.de/openbios-ppc-u3.patch

About the OpenBIOS patch, could you move the PCI_INT_MAP defines to a PPC-specific header and make pci_host_set_interrupt_map() contents surrounded by #ifdef CONFIG_PPC (to make it empty function for other arches)?

Well, other archs should be able to use the same code. If OpenBIOS knows how interrupts work for a particular device, it really should tell the OS about it too IMHO.

I'm not so sure. Here's an example of a Sparc64 interrupt-map:

        Node 0xf005f9d4
            bus-range:  00000001.00000001
            scsi-initiator-id:  00000007
            compatible:  70636931.3038652c.35303030.00706369
            66mhz-capable:
            fast-back-to-back:
            devsel-speed:  00000001
            class-code:  00060400
            revision-id:  00000011
            device-id:  00005000
            vendor-id:  0000108e
            interrupt-map:
00010800.00000000.00000000.00000001.f005f1e0.00000021.00011000.00000000.00000000.00000001.f005f1e0.0000000f.00011800.00000000.00000000.00000001.f005f1e0.00000020
            interrupt-map-mask:  00fff800.00000000.00000000.00000007
            #interrupt-cells:  00000001
            slot-names:  00000000
            no-probe-list:  '0'
            clock-frequency:  01f78a40
            model:  'SUNW,simba'
            #address-cells:  00000003
            #size-cells:  00000002
            reg:  00000900.00000000.00000000.00000000.00000000
            device_type:  'pci'
            name:  'pci'
#14 lore raw

Re: [Qemu-devel] [PATCH 9/9] PPC: Add USB per default on U3

In reply to Alexander Graf

Am 12.01.2010 um 12:58 schrieb Alexander Graf:

Quoted 5 lines

Linux with CONFIG_PPC64 doesn't support ADB devices anymore, so we have to use USB for keyboard and mouse.

This patch enables USB per default on U3 and adds a virtual keyboard and mouse there.

Wasn't the PowerMac G3 blue&white (Yosemite) the first New World Mac? It had a USB keyboard and mouse and ADB for backwards compatibility.

Quoted 6 lines
hw/ppc_newworld.c +0 -0
index c08211e..52a56e4 100644

hw/ppc_newworld.c static void ppc_core99_init (ram_addr_t · line 361

Quoted 8 lines
hw/ppc_newworld.c +3 -0
@@ -353,12 +354,14 @@ static void ppc_core99_init (ram_addr_t  
 ram_size,
    ide_mem_index[2] = pmac_ide_init(hd, pic[0x0e], dbdma, 0x1a,  
 pic[0x02]);
 
    /* cuda also initialize ADB */
+    if (machine_arch == ARCH_MAC99_U3) {
+        usb_enabled = 1;
+    }

I'd therefore propose to enable USB independently of U3 for the New World machine.

Andreas

#15 lore raw

Re: [Qemu-devel] [PATCH 9/9] PPC: Add USB per default on U3

Quoted 19 lines · Andreas Färber

Am 12.01.2010 um 12:58 schrieb Alexander Graf:

Quoted 5 lines

Linux with CONFIG_PPC64 doesn't support ADB devices anymore, so we have to use USB for keyboard and mouse.

This patch enables USB per default on U3 and adds a virtual keyboard and mouse there.

Wasn't the PowerMac G3 blue&white (Yosemite) the first New World Mac? It had a USB keyboard and mouse and ADB for backwards compatibility.

Quoted 8 lines
hw/ppc_newworld.c +0 -0
index c08211e..52a56e4 100644
@@ -353,12 +354,14 @@ static void ppc_core99_init (ram_addr_t ram_size,
   ide_mem_index[2] = pmac_ide_init(hd, pic[0x0e], dbdma, 0x1a, pic[0x02]);
 
Quoted 6 lines

hw/ppc_newworld.c static void ppc_core99_init (ram_addr_t ram_size, · line 359

Quoted 4 lines
hw/ppc_newworld.c +3 -0
   /* cuda also initialize ADB */
+    if (machine_arch == ARCH_MAC99_U3) {
+        usb_enabled = 1;
+    }

I'd therefore propose to enable USB independently of U3 for the New World machine.

Well USB comes with quite some overhead, so I'd like to only enable it only when necessary. On the U3 it is necessary, because we don't get a keyboard otherwise. On PPC32 Macs we can just not have USB and be happy.

Alex

#19 lore raw
In reply to Blue Swirl
Quoted 29 lines · Blue Swirl
Quoted 17 lines · Alexander Graf
Quoted 14 lines · Blue Swirl
Quoted 13 lines · Alexander Graf

I'm trying to get the PPC64 system emulation target working finally. While doing so, I ran into several issues, all related to PCI this time.

This patchset fixes all the PCI config space access and PCI interrupt mapping issues I've found on PPC64. Using this and a patched OpenBIOS version, I can successfully access IDE devices and was booting a guest into the shell from IDE using serial console.

To leverage this patch, you also need a few patches to OpenBIOS. I'll present them to the OpenBIOS list, but in general getting patches into Qemu is harder than getting them into OpenBIOS. So I want to wait for the review process here first.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Find the OpenBIOS patch at: http://alex.csgraf.de/openbios-ppc-u3.patch

About the OpenBIOS patch, could you move the PCI_INT_MAP defines to a PPC-specific header and make pci_host_set_interrupt_map() contents surrounded by #ifdef CONFIG_PPC (to make it empty function for other arches)?

Well, other archs should be able to use the same code. If OpenBIOS knows how interrupts work for a particular device, it really should tell the OS about it too IMHO.

I'm not so sure. Here's an example of a Sparc64 interrupt-map:

Quoted 14 lines
       Node 0xf005f9d4
           bus-range:  00000001.00000001
           scsi-initiator-id:  00000007
           compatible:  70636931.3038652c.35303030.00706369
           66mhz-capable:
           fast-back-to-back:
           devsel-speed:  00000001
           class-code:  00060400
           revision-id:  00000011
           device-id:  00005000
           vendor-id:  0000108e
           interrupt-map:
00010800.00000000.00000000.00000001.f005f1e0.00000021.00011000.00000000.00000000.00000001.f005f1e0.0000000f.00011800.00000000.00000000.00000001.f005f1e0.00000020
           interrupt-map-mask:  00fff800.00000000.00000000.00000007

This translates to:

Interrupt PIN A on dev 00010800 -> INT 0x21
Interrupt PIN A on dev 00011000 -> INT 0x0f
Interrupt PIN A on dev 00011800 -> INT 0x20

What does the corresponding code in OpenBIOS do to figure out which IRQ is routed where?

The UniNorth case is really simple, because it doesn't take any mangling into account. Usually PCI bridges also assign pins differently depending on the port the card is plugged into, so an "all devices on PIN A" configuration still ends up being distributed over all 4 interrupts.

I'm certainly open to more clever ideas. We could of course forget about all the interrupt mapping and simply put PIC targeted interrupt properties into each device's node. But I somehow like the map approach better, especially because the "normal" (defined in the interrupt map draft) way of doing PCI interrupts is to have an interrupt property of size=1 which defines the pin.

Alex

#20 lore raw
Quoted 48 lines · Alexander Graf
Quoted 29 lines · Blue Swirl
Quoted 17 lines · Alexander Graf
Quoted 14 lines · Blue Swirl
Quoted 13 lines · Alexander Graf

I'm trying to get the PPC64 system emulation target working finally. While doing so, I ran into several issues, all related to PCI this time.

This patchset fixes all the PCI config space access and PCI interrupt mapping issues I've found on PPC64. Using this and a patched OpenBIOS version, I can successfully access IDE devices and was booting a guest into the shell from IDE using serial console.

To leverage this patch, you also need a few patches to OpenBIOS. I'll present them to the OpenBIOS list, but in general getting patches into Qemu is harder than getting them into OpenBIOS. So I want to wait for the review process here first.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Find the OpenBIOS patch at: http://alex.csgraf.de/openbios-ppc-u3.patch

About the OpenBIOS patch, could you move the PCI_INT_MAP defines to a PPC-specific header and make pci_host_set_interrupt_map() contents surrounded by #ifdef CONFIG_PPC (to make it empty function for other arches)?

Well, other archs should be able to use the same code. If OpenBIOS knows how interrupts work for a particular device, it really should tell the OS about it too IMHO.

I'm not so sure. Here's an example of a Sparc64 interrupt-map:

Quoted 14 lines

       Node 0xf005f9d4
           bus-range:  00000001.00000001
           scsi-initiator-id:  00000007
           compatible:  70636931.3038652c.35303030.00706369
           66mhz-capable:
           fast-back-to-back:
           devsel-speed:  00000001
           class-code:  00060400
           revision-id:  00000011
           device-id:  00005000
           vendor-id:  0000108e
           interrupt-map:
00010800.00000000.00000000.00000001.f005f1e0.00000021.00011000.00000000.00000000.00000001.f005f1e0.0000000f.00011800.00000000.00000000.00000001.f005f1e0.00000020
           interrupt-map-mask:  00fff800.00000000.00000000.00000007

Quoted 7 lines

This translates to:

Interrupt PIN A on dev 00010800 -> INT 0x21
Interrupt PIN A on dev 00011000 -> INT 0x0f
Interrupt PIN A on dev 00011800 -> INT 0x20

What does the corresponding code in OpenBIOS do to figure out which IRQ is routed where?

Currently there isn't anything, so something may be better than nothing. Would your code produce correct interrupt-map then also for Sparc64?

Quoted 3 lines

The UniNorth case is really simple, because it doesn't take any mangling into account. Usually PCI bridges also assign pins differently depending on the port the card is plugged into, so an "all devices on PIN A" configuration still ends up being distributed over all 4 interrupts.

I'm certainly open to more clever ideas. We could of course forget about all the interrupt mapping and simply put PIC targeted interrupt properties into each device's node. But I somehow like the map approach better, especially because the "normal" (defined in the interrupt map draft) way of doing PCI interrupts is to have an interrupt property of size=1 which defines the pin.

I should probably read the draft before trying to comment further.

#21 lore raw
Quoted 55 lines · Blue Swirl
Quoted 54 lines · Alexander Graf
Quoted 29 lines · Blue Swirl
Quoted 17 lines · Alexander Graf
Quoted 14 lines · Blue Swirl
Quoted 13 lines · Alexander Graf

I'm trying to get the PPC64 system emulation target working finally. While doing so, I ran into several issues, all related to PCI this time.

This patchset fixes all the PCI config space access and PCI interrupt mapping issues I've found on PPC64. Using this and a patched OpenBIOS version, I can successfully access IDE devices and was booting a guest into the shell from IDE using serial console.

To leverage this patch, you also need a few patches to OpenBIOS. I'll present them to the OpenBIOS list, but in general getting patches into Qemu is harder than getting them into OpenBIOS. So I want to wait for the review process here first.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Find the OpenBIOS patch at: http://alex.csgraf.de/openbios-ppc-u3.patch

About the OpenBIOS patch, could you move the PCI_INT_MAP defines to a PPC-specific header and make pci_host_set_interrupt_map() contents surrounded by #ifdef CONFIG_PPC (to make it empty function for other arches)?

Well, other archs should be able to use the same code. If OpenBIOS knows how interrupts work for a particular device, it really should tell the OS about it too IMHO.

I'm not so sure. Here's an example of a Sparc64 interrupt-map:

Quoted 14 lines
       Node 0xf005f9d4
           bus-range:  00000001.00000001
           scsi-initiator-id:  00000007
           compatible:  70636931.3038652c.35303030.00706369
           66mhz-capable:
           fast-back-to-back:
           devsel-speed:  00000001
           class-code:  00060400
           revision-id:  00000011
           device-id:  00005000
           vendor-id:  0000108e
           interrupt-map:
00010800.00000000.00000000.00000001.f005f1e0.00000021.00011000.00000000.00000000.00000001.f005f1e0.0000000f.00011800.00000000.00000000.00000001.f005f1e0.00000020
           interrupt-map-mask:  00fff800.00000000.00000000.00000007

This translates to:

Interrupt PIN A on dev 00010800 -> INT 0x21
Interrupt PIN A on dev 00011000 -> INT 0x0f
Interrupt PIN A on dev 00011800 -> INT 0x20

Quoted 5 lines
Quoted 1 line

What does the corresponding code in OpenBIOS do to figure out which IRQ is routed where?

Currently there isn't anything, so something may be better than nothing. Would your code produce correct interrupt-map then also for Sparc64?

Depends on how your PCI bridge maps interrupts. What does qemu's pci interrupt map function for your pci bridge look like?

Quoted 6 lines
Quoted 4 lines

The UniNorth case is really simple, because it doesn't take any mangling into account. Usually PCI bridges also assign pins differently depending on the port the card is plugged into, so an "all devices on PIN A" configuration still ends up being distributed over all 4 interrupts.

I'm certainly open to more clever ideas. We could of course forget about all the interrupt mapping and simply put PIC targeted interrupt properties into each device's node. But I somehow like the map approach better, especially because the "normal" (defined in the interrupt map draft) way of doing PCI interrupts is to have an interrupt property of size=1 which defines the pin.

I should probably read the draft before trying to comment further.

http://playground.sun.com/1275/practice/imap/imap0_9d.pdf

Alex

#22 lore raw
Quoted 58 lines · Alexander Graf
Quoted 55 lines · Blue Swirl
Quoted 54 lines · Alexander Graf
Quoted 29 lines · Blue Swirl
Quoted 17 lines · Alexander Graf
Quoted 14 lines · Blue Swirl
Quoted 13 lines · Alexander Graf

I'm trying to get the PPC64 system emulation target working finally. While doing so, I ran into several issues, all related to PCI this time.

This patchset fixes all the PCI config space access and PCI interrupt mapping issues I've found on PPC64. Using this and a patched OpenBIOS version, I can successfully access IDE devices and was booting a guest into the shell from IDE using serial console.

To leverage this patch, you also need a few patches to OpenBIOS. I'll present them to the OpenBIOS list, but in general getting patches into Qemu is harder than getting them into OpenBIOS. So I want to wait for the review process here first.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Find the OpenBIOS patch at: http://alex.csgraf.de/openbios-ppc-u3.patch

About the OpenBIOS patch, could you move the PCI_INT_MAP defines to a PPC-specific header and make pci_host_set_interrupt_map() contents surrounded by #ifdef CONFIG_PPC (to make it empty function for other arches)?

Well, other archs should be able to use the same code. If OpenBIOS knows how interrupts work for a particular device, it really should tell the OS about it too IMHO.

I'm not so sure. Here's an example of a Sparc64 interrupt-map:

Quoted 14 lines

       Node 0xf005f9d4
           bus-range:  00000001.00000001
           scsi-initiator-id:  00000007
           compatible:  70636931.3038652c.35303030.00706369
           66mhz-capable:
           fast-back-to-back:
           devsel-speed:  00000001
           class-code:  00060400
           revision-id:  00000011
           device-id:  00005000
           vendor-id:  0000108e
           interrupt-map:
00010800.00000000.00000000.00000001.f005f1e0.00000021.00011000.00000000.00000000.00000001.f005f1e0.0000000f.00011800.00000000.00000000.00000001.f005f1e0.00000020
           interrupt-map-mask:  00fff800.00000000.00000000.00000007

This translates to:

Interrupt PIN A on dev 00010800 -> INT 0x21
Interrupt PIN A on dev 00011000 -> INT 0x0f
Interrupt PIN A on dev 00011800 -> INT 0x20

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

What does the corresponding code in OpenBIOS do to figure out which IRQ is routed where?

Currently there isn't anything, so something may be better than nothing. Would your code produce correct interrupt-map then also for Sparc64?

Depends on how your PCI bridge maps interrupts. What does qemu's pci interrupt map function for your pci bridge look like?

/* The APB host has an IRQ line for each IRQ line of each slot. */ static int pci_apb_map_irq(PCIDevice *pci_dev, int irq_num)

{
    return ((pci_dev->devfn & 0x18) >> 1) + irq_num;
}

This may be bogus though.

Quoted 9 lines
Quoted 7 lines
Quoted 5 lines

The UniNorth case is really simple, because it doesn't take any mangling into account. Usually PCI bridges also assign pins differently depending on the port the card is plugged into, so an "all devices on PIN A" configuration still ends up being distributed over all 4 interrupts.

I'm certainly open to more clever ideas. We could of course forget about all the interrupt mapping and simply put PIC targeted interrupt properties into each device's node. But I somehow like the map approach better, especially because the "normal" (defined in the interrupt map draft) way of doing PCI interrupts is to have an interrupt property of size=1 which defines the pin.

I should probably read the draft before trying to comment further.

http://playground.sun.com/1275/practice/imap/imap0_9d.pdf

Thanks.

#23 lore raw
Quoted 67 lines · Blue Swirl
Quoted 58 lines · Alexander Graf
Quoted 55 lines · Blue Swirl
Quoted 54 lines · Alexander Graf
Quoted 29 lines · Blue Swirl
Quoted 17 lines · Alexander Graf
Quoted 14 lines · Blue Swirl
Quoted 13 lines · Alexander Graf

I'm trying to get the PPC64 system emulation target working finally. While doing so, I ran into several issues, all related to PCI this time.

This patchset fixes all the PCI config space access and PCI interrupt mapping issues I've found on PPC64. Using this and a patched OpenBIOS version, I can successfully access IDE devices and was booting a guest into the shell from IDE using serial console.

To leverage this patch, you also need a few patches to OpenBIOS. I'll present them to the OpenBIOS list, but in general getting patches into Qemu is harder than getting them into OpenBIOS. So I want to wait for the review process here first.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Find the OpenBIOS patch at: http://alex.csgraf.de/openbios-ppc-u3.patch

About the OpenBIOS patch, could you move the PCI_INT_MAP defines to a PPC-specific header and make pci_host_set_interrupt_map() contents surrounded by #ifdef CONFIG_PPC (to make it empty function for other arches)?

Well, other archs should be able to use the same code. If OpenBIOS knows how interrupts work for a particular device, it really should tell the OS about it too IMHO.

I'm not so sure. Here's an example of a Sparc64 interrupt-map:

Quoted 14 lines
       Node 0xf005f9d4
           bus-range:  00000001.00000001
           scsi-initiator-id:  00000007
           compatible:  70636931.3038652c.35303030.00706369
           66mhz-capable:
           fast-back-to-back:
           devsel-speed:  00000001
           class-code:  00060400
           revision-id:  00000011
           device-id:  00005000
           vendor-id:  0000108e
           interrupt-map:
00010800.00000000.00000000.00000001.f005f1e0.00000021.00011000.00000000.00000000.00000001.f005f1e0.0000000f.00011800.00000000.00000000.00000001.f005f1e0.00000020
           interrupt-map-mask:  00fff800.00000000.00000000.00000007

This translates to:

Interrupt PIN A on dev 00010800 -> INT 0x21
Interrupt PIN A on dev 00011000 -> INT 0x0f
Interrupt PIN A on dev 00011800 -> INT 0x20

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

What does the corresponding code in OpenBIOS do to figure out which IRQ is routed where?

Currently there isn't anything, so something may be better than nothing. Would your code produce correct interrupt-map then also for Sparc64?

Depends on how your PCI bridge maps interrupts. What does qemu's pci interrupt map function for your pci bridge look like?

Quoted 7 lines

/* The APB host has an IRQ line for each IRQ line of each slot. */ static int pci_apb_map_irq(PCIDevice *pci_dev, int irq_num)

{
   return ((pci_dev->devfn & 0x18) >> 1) + irq_num;
}

This may be bogus though.

Don't know, it might be correct :-). Either way, you'd have to do a map similar to the one in the dump you gave above. That should be fairly easy to generate programatically.

If you need help to understand interrupt-map properties, feel free to ask. I only finally managed to understand them recently myself.

Alex