Skip to contentSkip to conversation

pseries and Power updates

PATCH Applied David Gibson 3 participants 13 messages Feb 28, 2012 – Mar 7, 2012

lore
Share & tools
lore
#0 lore raw

cover pseries and Power updates

This series contains a number of bugfixes and enhancements for the pseries machine, including a significant cleanup of the pseries PCI code.

#1 lore raw

PATCH 1/7 pseries: Don't try to munmap() a malloc()ed TCE table

For the pseries machine, TCE (IOMMU) tables can either be directly malloc()ed in qemu or, when running on a KVM which supports it, mmap()ed from a KVM ioctl. The latter option is used when available, because it allows the (frequent bottlenext) H_PUT_TCE hypercall to be KVM accelerated. However, even when KVM is persent, TCE acceleration is not always possible. Only KVM HV supports this ioctl(), not KVM PR, or the kernel could run out of contiguous memory to allocate the new table. In this case we need to fall back on the malloc()ed table.

When a device is removed, and we need to remove the TCE table, we need to either munmap() or free() the table as appropriate for how it was allocated. The code is supposed to do that, but we buggily fail to initialize the tcet->fd variable in the malloc() case, which is used as a flag to determine which is the right choice.

This patch fixes the bug, and cleans up error messages relating to this path while we're at it.

---
 target-ppc/kvm.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
target-ppc/kvm.c +10 -2
index 50cfa02..90c6941 100644
@@ -843,12 +843,18 @@ void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t window_size, int *pfd)
     int fd;
     void *table;
 
+    /* Must set fd to -1 so we don't try to munmap when called for
+     * destroying the table, which the upper layers -will- do
+     */
+    *pfd = -1;
     if (!cap_spapr_tce) {
         return NULL;
     }
 
     fd = kvm_vm_ioctl(kvm_state, KVM_CREATE_SPAPR_TCE, &args);
     if (fd < 0) {
+        fprintf(stderr, "KVM: Failed to create TCE table for liobn 0x%x\n",
+                liobn);
         return NULL;
     }
 
@@ -857,6 +863,8 @@ void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t window_size, int *pfd)
 
     table = mmap(NULL, len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
     if (table == MAP_FAILED) {
+        fprintf(stderr, "KVM: Failed to map TCE table for liobn 0x%x\n",
+                liobn);
         close(fd);
         return NULL;
     }
@@ -876,8 +884,8 @@ int kvmppc_remove_spapr_tce(void *table, int fd, uint32_t window_size)
     len = (window_size / SPAPR_VIO_TCE_PAGE_SIZE)*sizeof(VIOsPAPR_RTCE);
     if ((munmap(table, len) < 0) ||
         (close(fd) < 0)) {
-        fprintf(stderr, "KVM: Unexpected error removing KVM SPAPR TCE "
-                "table: %s", strerror(errno));
+        fprintf(stderr, "KVM: Unexpected error removing TCE table: %s",
+                strerror(errno));
         /* Leak the table */
     }
 
Signature · 1 line
1.7.9
#2 lore raw

PATCH 2/7 PPC64: Add support for ldbrx and stdbrx instructions

In reply to David Gibson

From: Thomas Huth <[email protected]>

These instructions for loading and storing byte-swapped 64-bit values have been introduced in PowerISA 2.06.

---
 target-ppc/cpu.h            |    4 ++-
 target-ppc/translate.c      |   52 +++++++++++++++++++++++++++++++++++-------
 target-ppc/translate_init.c |    2 +-
 3 files changed, 47 insertions(+), 11 deletions(-)
target-ppc/cpu.h +3 -1
index fbcf488..036b3b6 100644
@@ -1918,8 +1918,10 @@ enum {
     PPC2_DFP           = 0x0000000000000004ULL,
     /* Embedded.Processor Control                                            */
     PPC2_PRCNTL        = 0x0000000000000008ULL,
+    /* Byte-reversed, indexed, double-word load and store                    */
+    PPC2_DBRX          = 0x0000000000000010ULL,
 
-#define PPC_TCG_INSNS2 (PPC2_BOOKE206 | PPC2_PRCNTL)
+#define PPC_TCG_INSNS2 (PPC2_BOOKE206 | PPC2_PRCNTL | PPC2_DBRX)
 };
 
 /*****************************************************************************/
target-ppc/translate.c +43 -9

124 lines not on this page · raw message

target-ppc/translate_init.c +1 -1
index 6253076..087f2f0 100644
@@ -6571,7 +6571,7 @@ static void init_proc_970MP (CPUPPCState *env)
                               PPC_64B | PPC_ALTIVEC |                         \
                               PPC_SEGMENT_64B | PPC_SLBI |                    \
                               PPC_POPCNTB | PPC_POPCNTWD)
-#define POWERPC_INSNS2_POWER7 (PPC2_VSX | PPC2_DFP)
+#define POWERPC_INSNS2_POWER7 (PPC2_VSX | PPC2_DFP | PPC2_DBRX)
 #define POWERPC_MSRM_POWER7   (0x800000000204FF36ULL)
 #define POWERPC_MMU_POWER7    (POWERPC_MMU_2_06)
 #define POWERPC_EXCP_POWER7   (POWERPC_EXCP_POWER7)
Signature · 1 line
1.7.9
#3 lore raw

PATCH 3/7 pseries: Add support for level interrupts to XICS

In reply to David Gibson

The pseries "xics" interrupt controller, like most interrupt controllers can support both message (i.e. edge sensitive) interrupts and level sensitive interrupts, but it needs to know which are which.

When I implemented the xics emulation for qemu, the only devices we supported were the PAPR virtual IO devices. These devices only use message interrupts, so they were the only ones I implemented in xics.

Since then, however, we have added support for PCI devices, which use level sensitive interrupts. It turns out the message interrupt logic still actually works most of the time for these, but there are circumstances where we can lost interrupts due to the incorrect interrupt logic.

This patch, therefore, implements the correct xics level-sensitive interrupt logic. The type of the interrupt is set when a device allocates a new xics interrupt.

---
 hw/spapr.c     |    4 +-
 hw/spapr.h     |   12 +++++-
 hw/spapr_pci.c |    2 +-
 hw/spapr_vio.c |    2 +-
 hw/xics.c      |  122 +++++++++++++++++++++++++++++++++++++++++---------------
 hw/xics.h      |    2 +-
 6 files changed, 106 insertions(+), 38 deletions(-)
hw/spapr.c +2 -2
index dffb6a2..828bc53 100644
@@ -83,7 +83,7 @@
 
 sPAPREnvironment *spapr;
 
-qemu_irq spapr_allocate_irq(uint32_t hint, uint32_t *irq_num)
+qemu_irq spapr_allocate_irq(uint32_t hint, uint32_t *irq_num, int lsi)
 {
     uint32_t irq;
     qemu_irq qirq;
@@ -95,7 +95,7 @@ qemu_irq spapr_allocate_irq(uint32_t hint, uint32_t *irq_num)
         irq = spapr->next_irq++;
     }
 
-    qirq = xics_find_qirq(spapr->icp, irq);
+    qirq = xics_assign_irq(spapr->icp, irq, lsi);
     if (!qirq) {
         return NULL;
     }
hw/spapr.h +11 -1
index e946a34..4aae1a0 100644
@@ -286,7 +286,17 @@ void spapr_register_hypercall(target_ulong opcode, spapr_hcall_fn fn);
 target_ulong spapr_hypercall(CPUState *env, target_ulong opcode,
                              target_ulong *args);
 
-qemu_irq spapr_allocate_irq(uint32_t hint, uint32_t *irq_num);
+qemu_irq spapr_allocate_irq(uint32_t hint, uint32_t *irq_num, int lsi);
+
+static inline qemu_irq spapr_allocate_msi(uint32_t hint, uint32_t *irq_num)
+{
+    return spapr_allocate_irq(hint, irq_num, 0);
+}
+
+static inline qemu_irq spapr_allocate_lsi(uint32_t hint, uint32_t *irq_num)
+{
+    return spapr_allocate_irq(hint, irq_num, 1);
+}
 
 static inline uint32_t rtas_ld(target_ulong phys, int n)
 {
hw/spapr_pci.c +1 -1
index 1e8d03e..28a46bd 100644
@@ -178,7 +178,7 @@ static int spapr_phb_init(SysBusDevice *s)
         qemu_irq qirq;
         uint32_t num;
 
-        qirq = spapr_allocate_irq(0, &num);
+        qirq = spapr_allocate_lsi(0, &num);
         if (!qirq) {
             return -1;
         }
hw/spapr_vio.c +1 -1
index ea317ef..ca0c8e7 100644
@@ -670,7 +670,7 @@ static int spapr_vio_busdev_init(DeviceState *qdev)
         dev->qdev.id = id;
     }
 
-    dev->qirq = spapr_allocate_irq(dev->vio_irq_num, &dev->vio_irq_num);
+    dev->qirq = spapr_allocate_msi(dev->vio_irq_num, &dev->vio_irq_num);
     if (!dev->qirq) {
         return -1;
     }
hw/xics.c +90 -32

201 lines not on this page · raw message

hw/xics.h +1 -1
index 83c1182..7cb2b64 100644
@@ -31,7 +31,7 @@
 
 struct icp_state;
 
-qemu_irq xics_find_qirq(struct icp_state *icp, int irq);
+qemu_irq xics_assign_irq(struct icp_state *icp, int irq, int lsi);
 
 struct icp_state *xics_system_init(int nr_irqs);
 
Signature · 1 line
1.7.9
#4 lore raw

Re: [Qemu-devel] [PATCH 3/7] pseries: Add support for level interrupts to XICS

Quoted 14 lines · David Gibson

The pseries "xics" interrupt controller, like most interrupt controllers can support both message (i.e. edge sensitive) interrupts and level sensitive interrupts, but it needs to know which are which.

When I implemented the xics emulation for qemu, the only devices we supported were the PAPR virtual IO devices. These devices only use message interrupts, so they were the only ones I implemented in xics.

Since then, however, we have added support for PCI devices, which use level sensitive interrupts. It turns out the message interrupt logic still actually works most of the time for these, but there are circumstances where we can lost interrupts due to the incorrect interrupt logic.

Quoted 5 lines

This patch, therefore, implements the correct xics level-sensitive interrupt logic. The type of the interrupt is set when a device allocates a new xics interrupt.

This looks wrong

Quoted 23 lines

---

hw/spapr.c     |    4 +-
hw/spapr.h     |   12 +++++-
hw/spapr_pci.c |    2 +-
hw/spapr_vio.c |    2 +-
hw/xics.c      |  122 +++++++++++++++++++++++++++++++++++++++++---------------
hw/xics.h      |    2 +-
6 files changed, 106 insertions(+), 38 deletions(-)
hw/spapr.c +1 -1
index dffb6a2..828bc53 100644
@@ -83,7 +83,7 @@
 
 sPAPREnvironment *spapr;
 
-qemu_irq spapr_allocate_irq(uint32_t hint, uint32_t *irq_num)
+qemu_irq spapr_allocate_irq(uint32_t hint, uint32_t *irq_num, int lsi)
 {
    uint32_t irq;
    qemu_irq qirq;

hw/spapr.c qemu_irq spapr_allocate_irq(uint32_t hint, uint32_t *irq_num) · line 98

Quoted 5 lines
hw/spapr.c +1 -1
@@ -95,7 +95,7 @@ qemu_irq spapr_allocate_irq(uint32_t hint, uint32_t *irq_num)
        irq = spapr->next_irq++;
    }
 
-    qirq = xics_find_qirq(spapr->icp, irq);
+    qirq = xics_assign_irq(spapr->icp, irq, lsi);

Find becomes assign? Is this on purpose?

While at it, could you make the "lsi" thing an enum? That'd make things easier to track :).

Alex

#5 lore raw

Re: [Qemu-devel] [Qemu-ppc] [PATCH 3/7] pseries: Add support for level interrupts to XICS

Quoted 17 lines · Alexander Graf
Quoted 14 lines · David Gibson

The pseries "xics" interrupt controller, like most interrupt controllers can support both message (i.e. edge sensitive) interrupts and level sensitive interrupts, but it needs to know which are which.

When I implemented the xics emulation for qemu, the only devices we supported were the PAPR virtual IO devices. These devices only use message interrupts, so they were the only ones I implemented in xics.

Since then, however, we have added support for PCI devices, which use level sensitive interrupts. It turns out the message interrupt logic still actually works most of the time for these, but there are circumstances where we can lost interrupts due to the incorrect interrupt logic.

Quoted 7 lines
Quoted 5 lines

This patch, therefore, implements the correct xics level-sensitive interrupt logic. The type of the interrupt is set when a device allocates a new xics interrupt.

This looks wrong

Oops, I'll fix that up.

Quoted 27 lines
Quoted 27 lines

---

hw/spapr.c     |    4 +-
hw/spapr.h     |   12 +++++-
hw/spapr_pci.c |    2 +-
hw/spapr_vio.c |    2 +-
hw/xics.c      |  122 +++++++++++++++++++++++++++++++++++++++++---------------
hw/xics.h      |    2 +-
6 files changed, 106 insertions(+), 38 deletions(-)
hw/spapr.c +1 -1
index dffb6a2..828bc53 100644
@@ -83,7 +83,7 @@
 
 sPAPREnvironment *spapr;
 
-qemu_irq spapr_allocate_irq(uint32_t hint, uint32_t *irq_num)
+qemu_irq spapr_allocate_irq(uint32_t hint, uint32_t *irq_num, int lsi)
 {
    uint32_t irq;
    qemu_irq qirq;
@@ -95,7 +95,7 @@ qemu_irq spapr_allocate_irq(uint32_t hint, uint32_t *irq_num)
        irq = spapr->next_irq++;
    }
 
Quoted 4 lines

hw/spapr.c qemu_irq spapr_allocate_irq(uint32_t hint, uint32_t *irq_num) · line 98

Quoted 2 lines
hw/spapr.c +1 -1
-    qirq = xics_find_qirq(spapr->icp, irq);
+    qirq = xics_assign_irq(spapr->icp, irq, lsi);

Find becomes assign? Is this on purpose?

Yes. Previously xics_find_qirq() just returned the qmeu_irq associated with a given xics irq number, without changing any state. Now it also flags whether the irq is an lsi or msi, so the old name didn't seem right any more.

Quoted 2 lines

While at it, could you make the "lsi" thing an enum? That'd make things easier to track :).

Ok, will do.

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
#6 lore raw

PATCH 4/7 pseries: Update SLOF firmware image

In reply to David Gibson

This patch updates the SLOF firmware image used on the pseries machine. The new version adds support for Cirrus VGA and virtfs, as well as including a number of bugfixes.

---
 pc-bios/README   |    2 +-
 pc-bios/slof.bin |  Bin 869584 -> 880496 bytes
 roms/SLOF        |    2 +-
 3 files changed, 2 insertions(+), 2 deletions(-)
pc-bios/README +1 -1
index 5dce355..71f4871 100644
@@ -17,7 +17,7 @@
 - SLOF (Slimline Open Firmware) is a free IEEE 1275 Open Firmware
   implementation for certain IBM POWER hardware.  The sources are at
   https://github.com/dgibson/SLOF, and the image currently in qemu is
-  built from git tag qemu-slof-20120111.1.
+  built from git tag qemu-slof-20120217.
 
 - sgabios (the Serial Graphics Adapter option ROM) provides a means for
   legacy x86 software to communicate with an attached serial console as
pc-bios/slof.bin binary +0 -0
index 8554f54b5773f0771eec28f6c3bc0dc17e063a47..449a7bb2afaf604f6c089612e99086df0800d7dc 100644
GIT binary patch
roms/SLOF +1 -1
index ab062ff..d153364 160000
@@ -1 +1 @@
-Subproject commit ab062ff3b37c39649f2b0d94ed607adc6f6b3c7d
+Subproject commit d153364253548d6cd91403711f84996e6a7dab31
Signature · 1 line
1.7.9
#7 lore raw

PATCH 5/7 pseries: Remove unused constant from PCI code

In reply to David Gibson

The 'bars' constant array was used in experimental device allocation code which is no longer necessary now that we always run the SLOF firmware. This patch removes the now redundant variable.

---
 hw/spapr_pci.c |    7 -------
 1 files changed, 0 insertions(+), 7 deletions(-)
hw/spapr_pci.c +0 -7
index 28a46bd..dafcd0e 100644
@@ -32,13 +32,6 @@
 
 #include "hw/pci_internals.h"
 
-static const uint32_t bars[] = {
-    PCI_BASE_ADDRESS_0, PCI_BASE_ADDRESS_1,
-    PCI_BASE_ADDRESS_2, PCI_BASE_ADDRESS_3,
-    PCI_BASE_ADDRESS_4, PCI_BASE_ADDRESS_5
-    /*, PCI_ROM_ADDRESS*/
-};
-
 static PCIDevice *find_dev(sPAPREnvironment *spapr,
                            uint64_t buid, uint32_t config_addr)
 {
Signature · 1 line
1.7.9
#8 lore raw

PATCH 6/7 pseries: Remove PCI device from PCI host bridge code

In reply to David Gibson

From: Alexey Kardashevskiy <[email protected]>

The sPAPR PCI code defines a PCI device "spapr-pci-host-bridge-pci" which is never used. This came over from the earlier bridge driver we used as a template. Some other bridges appear on their own PCI bus as a device, but that is not true of pSeries bridges, which are pure host to PCI with no visible presence on the PCI side.

---
 hw/spapr_pci.c |   20 --------------------
 1 files changed, 0 insertions(+), 20 deletions(-)
hw/spapr_pci.c +0 -20
index dafcd0e..b0254ee 100644
@@ -183,25 +183,6 @@ static int spapr_phb_init(SysBusDevice *s)
     return 0;
 }
 
-static int spapr_main_pci_host_init(PCIDevice *d)
-{
-    return 0;
-}
-
-static void spapr_main_pci_host_class_init(ObjectClass *klass, void *data)
-{
-    PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
-
-    k->init = spapr_main_pci_host_init;
-}
-
-static TypeInfo spapr_main_pci_host_info = {
-    .name          = "spapr-pci-host-bridge-pci",
-    .parent        = TYPE_PCI_DEVICE,
-    .instance_size = sizeof(PCIDevice),
-    .class_init    = spapr_main_pci_host_class_init,
-};
-
 static void spapr_phb_class_init(ObjectClass *klass, void *data)
 {
     SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
@@ -219,7 +200,6 @@ static TypeInfo spapr_phb_info = {
 static void spapr_register_types(void)
 {
     type_register_static(&spapr_phb_info);
-    type_register_static(&spapr_main_pci_host_info);
 }
 
 type_init(spapr_register_types)
Signature · 1 line
1.7.9
#9 lore raw

PATCH 7/7 pseries: Configure PCI bridge using properties

In reply to David Gibson

From: Alexey Kardashevskiy <[email protected]>

Currently, the function spapr_create_phb() uses its parameters to initialize the correct memory windows for the new PCI Host Bridge (PHB). This is not the way things are supposed to be done with qdevs, and means you can't create extra PHBs easily using -device.

Since pSeries machines can and do have many PHBs with various configurations, this is a real limitation, not just a theoretical. This patch, therefore, alters the PHB initialization code to use qdev properties to set these parameters of the new bridge, moving most of the code from spapr_create_phb() to spapr_phb_init().

While we're at it, we change the naming of each PCI bus and its associated memory regions to be less arbitrary and make it easier to relate the guest and qemu views of memory to each other.

---
 hw/spapr.c     |    2 +-
 hw/spapr_pci.c |  149 ++++++++++++++++++++++++++++++-------------------------
 hw/spapr_pci.h |    5 +-
 3 files changed, 84 insertions(+), 72 deletions(-)
hw/spapr.c +1 -1
index 828bc53..d1cb6cd 100644
@@ -629,7 +629,7 @@ static void ppc_spapr_init(ram_addr_t ram_size,
     }
 
     /* Set up PCI */
-    spapr_create_phb(spapr, "pci", SPAPR_PCI_BUID,
+    spapr_create_phb(spapr, SPAPR_PCI_BUID,
                      SPAPR_PCI_MEM_WIN_ADDR,
                      SPAPR_PCI_MEM_WIN_SIZE,
                      SPAPR_PCI_IO_WIN_ADDR);
hw/spapr_pci.c +81 -68

194 lines not on this page · raw message

hw/spapr_pci.h +2 -3
index 213340c..b4b8a73 100644
@@ -35,7 +35,7 @@ typedef struct sPAPRPHBState {
     uint64_t buid;
 
     MemoryRegion memspace, iospace;
-    target_phys_addr_t mem_win_addr, io_win_addr;
+    target_phys_addr_t mem_win_addr, mem_win_size, io_win_addr, io_win_size;
     MemoryRegion memwindow, iowindow;
 
     struct {
@@ -49,8 +49,7 @@ typedef struct sPAPRPHBState {
 #define SPAPR_PCI_MEM_WIN_BUS_OFFSET 0x80000000ULL
 #define SPAPR_PCI_IO_WIN_SIZE        0x10000
 
-void spapr_create_phb(sPAPREnvironment *spapr,
-                      const char *busname, uint64_t buid,
+void spapr_create_phb(sPAPREnvironment *spapr, uint64_t buid,
                       uint64_t mem_win_addr, uint64_t mem_win_size,
                       uint64_t io_win_addr);
 
Signature · 1 line
1.7.9
#10 lore raw

Re: [Qemu-devel] [PATCH 7/7] pseries: Configure PCI bridge using properties

Am 28.02.2012 04:18, schrieb David Gibson:

Quoted 130 lines

From: Alexey Kardashevskiy <[email protected]>

Currently, the function spapr_create_phb() uses its parameters to initialize the correct memory windows for the new PCI Host Bridge (PHB). This is not the way things are supposed to be done with qdevs, and means you can't create extra PHBs easily using -device.

Since pSeries machines can and do have many PHBs with various configurations, this is a real limitation, not just a theoretical. This patch, therefore, alters the PHB initialization code to use qdev properties to set these parameters of the new bridge, moving most of the code from spapr_create_phb() to spapr_phb_init().

While we're at it, we change the naming of each PCI bus and its associated memory regions to be less arbitrary and make it easier to relate the guest and qemu views of memory to each other.

---
 hw/spapr.c     |    2 +-
 hw/spapr_pci.c |  149 ++++++++++++++++++++++++++++++-------------------------
 hw/spapr_pci.h |    5 +-
 3 files changed, 84 insertions(+), 72 deletions(-)
hw/spapr_pci.c +46 -43
index b0254ee..654cb56 100644
@@ -161,49 +161,6 @@ static void pci_spapr_set_irq(void *opaque, int irq_num, int level)
     qemu_set_irq(phb->lsi_table[irq_num].qirq, level);
 }
 
-static int spapr_phb_init(SysBusDevice *s)
-{
-    sPAPRPHBState *phb = FROM_SYSBUS(sPAPRPHBState, s);
-    int i;
-
-    /* Initialize the LSI table */
-    for (i = 0; i < SPAPR_PCI_NUM_LSI; i++) {
-        qemu_irq qirq;
-        uint32_t num;
-
-        qirq = spapr_allocate_lsi(0, &num);
-        if (!qirq) {
-            return -1;
-        }
-
-        phb->lsi_table[i].dt_irq = num;
-        phb->lsi_table[i].qirq = qirq;
-    }
-
-    return 0;
-}
-
-static void spapr_phb_class_init(ObjectClass *klass, void *data)
-{
-    SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
-
-    sdc->init = spapr_phb_init;
-}
-
-static TypeInfo spapr_phb_info = {
-    .name          = "spapr-pci-host-bridge",
-    .parent        = TYPE_SYS_BUS_DEVICE,
-    .instance_size = sizeof(sPAPRPHBState),
-    .class_init    = spapr_phb_class_init,
-};
-
-static void spapr_register_types(void)
-{
-    type_register_static(&spapr_phb_info);
-}
-
-type_init(spapr_register_types)
-
 static uint64_t spapr_io_read(void *opaque, target_phys_addr_t addr,
                               unsigned size)
 {
@@ -297,14 +248,76 @@ void spapr_create_phb(sPAPREnvironment *spapr,
                                                  PCI_DEVFN(0, 0),
                                                  SPAPR_PCI_NUM_LSI);
 
+    QLIST_INSERT_HEAD(&spapr->phbs, phb, list);
+
+    /* Initialize the LSI table */
+    for (i = 0; i < SPAPR_PCI_NUM_LSI; i++) {
+        qemu_irq qirq;
+        uint32_t num;
+
+        qirq = spapr_allocate_lsi(0, &num);
+        if (!qirq) {
+            return -1;
+        }
+
+        phb->lsi_table[i].dt_irq = num;
+        phb->lsi_table[i].qirq = qirq;
+    }
+
+    return 0;
+}
+
+static Property spapr_phb_properties[] = {
+    DEFINE_PROP_HEX64("buid", sPAPRPHBState, buid, 0),
+    DEFINE_PROP_HEX64("mem_win_addr", sPAPRPHBState, mem_win_addr, 0),
+    DEFINE_PROP_HEX64("mem_win_size", sPAPRPHBState, mem_win_size, 0x20000000),
+    DEFINE_PROP_HEX64("io_win_addr", sPAPRPHBState, io_win_addr, 0),
+    DEFINE_PROP_HEX64("io_win_size", sPAPRPHBState, io_win_size, 0x10000),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
+static void spapr_phb_class_init(ObjectClass *klass, void *data)
+{
+    SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
+    DeviceClass *dc = DEVICE_CLASS(klass);
+
+    sdc->init = spapr_phb_init;
+    dc->props = spapr_phb_properties;
+}
+
+static TypeInfo spapr_phb_info = {
+    .name          = "spapr-pci-host-bridge",
+    .parent        = TYPE_SYS_BUS_DEVICE,
+    .instance_size = sizeof(sPAPRPHBState),
+    .class_init    = spapr_phb_class_init,
+};
+
+static void spapr_register_pci_type(void)
+{

hw/spapr_pci.c void spapr_create_phb(sPAPREnvironment *spapr, · line 305

Quoted 10 lines
hw/spapr_pci.c +4 -1
+    type_register_static(&spapr_phb_info);
+
     spapr_rtas_register("read-pci-config", rtas_read_pci_config);
     spapr_rtas_register("write-pci-config", rtas_write_pci_config);
     spapr_rtas_register("ibm,read-pci-config", rtas_ibm_read_pci_config);
     spapr_rtas_register("ibm,write-pci-config", rtas_ibm_write_pci_config);
+}
 
-    QLIST_INSERT_HEAD(&spapr->phbs, phb, list);
+type_init(spapr_register_pci_type)

Please respect the recently enforced convention of naming the function ..._register_types as before and best putting it and type_init() in the bottom so that we don't end up with multiple ones per file.

And registering types is all such a function can safely do since the call of these constructors is about to be moved (spapr_rtas_register looks fishy in that aspect).

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#11 lore raw

Re: [Qemu-devel] [Qemu-ppc] [PATCH 7/7] pseries: Configure PCI bridge using properties

Quoted 2 lines · Andreas Färber

Am 28.02.2012 04:18, schrieb David Gibson:

Quoted 1 line

From: Alexey Kardashevskiy <[email protected]>

[snip]

Quoted 6 lines

hw/spapr_pci.c void spapr_create_phb(sPAPREnvironment *spapr, · line 305

Quoted 2 lines
hw/spapr_pci.c +1 -1
-    QLIST_INSERT_HEAD(&spapr->phbs, phb, list);
+type_init(spapr_register_pci_type)

Please respect the recently enforced convention of naming the function ..._register_types as before and best putting it and type_init() in the bottom so that we don't end up with multiple ones per file.

Now that I'm aware of the convention, sure.

Quoted 3 lines

And registering types is all such a function can safely do since the call of these constructors is about to be moved (spapr_rtas_register looks fishy in that aspect).

Ok, I'll do the rename and move the rtas register calls into the class_init function and respin.

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
#12 lore raw
In reply to David Gibson
Quoted 4 lines · David Gibson

This series contains a number of bugfixes and enhancements for the pseries machine, including a significant cleanup of the pseries PCI code.

Thanks, applied 1-2, 4-6 to ppc-next.

Alex