qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/2] ppc/pnc: fix XSCOM MMIO base address for P9 machines with multiple chips
@ 2019-06-12 17:43 Cédric Le Goater
  2019-06-12 17:43 ` [Qemu-devel] [PATCH 1/2] " Cédric Le Goater
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Cédric Le Goater @ 2019-06-12 17:43 UTC (permalink / raw)
  To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater

Hello,

The base address of the MMIO window of the XSCOM bus is incorrect on
P9 machines with multiple chips. Provide a fix for that to prepare
ground for future PowerNV chips.

Thanks,

C.


Cédric Le Goater (2):
  ppc/pnc: fix XSCOM MMIO base address for P9 machines with multiple
    chips
  ppc/pnc: remove xscom_base field from PnvChip

 include/hw/ppc/pnv.h       |  8 ++++----
 include/hw/ppc/pnv_xscom.h |  2 +-
 hw/ppc/pnv.c               | 34 ++++++++++++++++------------------
 hw/ppc/pnv_xscom.c         | 17 ++++++++++++-----
 4 files changed, 33 insertions(+), 28 deletions(-)

-- 
2.21.0



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH 1/2] ppc/pnc: fix XSCOM MMIO base address for P9 machines with multiple chips
  2019-06-12 17:43 [Qemu-devel] [PATCH 0/2] ppc/pnc: fix XSCOM MMIO base address for P9 machines with multiple chips Cédric Le Goater
@ 2019-06-12 17:43 ` Cédric Le Goater
  2019-06-12 17:43 ` [Qemu-devel] [PATCH 2/2] ppc/pnc: remove xscom_base field from PnvChip Cédric Le Goater
  2019-06-12 17:47 ` [Qemu-devel] [PATCH 0/2] ppc/pnc: fix XSCOM MMIO base address for P9 machines with multiple chips Cédric Le Goater
  2 siblings, 0 replies; 5+ messages in thread
From: Cédric Le Goater @ 2019-06-12 17:43 UTC (permalink / raw)
  To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater

The PNV_XSCOM_BASE and PNV_XSCOM_SIZE macros are specific to POWER8
and they are used when the device tree is populated and the MMIO
region created, even for POWER9 chips. This is not too much of a
problem today because we don't have important devices on the second
chip, but we might have oneday (PHBs).

Fix by using the appropriate macros in case of P9.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 include/hw/ppc/pnv.h       |  3 +++
 include/hw/ppc/pnv_xscom.h |  2 +-
 hw/ppc/pnv.c               | 24 ++++++++++++++++--------
 hw/ppc/pnv_xscom.c         | 17 ++++++++++++-----
 4 files changed, 32 insertions(+), 14 deletions(-)

diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h
index 703e5ef222de..aa926d120771 100644
--- a/include/hw/ppc/pnv.h
+++ b/include/hw/ppc/pnv.h
@@ -283,4 +283,7 @@ int pnv_bmc_hiomap(IPMIBmc *bmc);
 #define PNV9_PSIHB_ESB_SIZE          0x0000000000010000ull
 #define PNV9_PSIHB_ESB_BASE(chip)    PNV9_CHIP_BASE(chip, 0x00060302031c0000ull)
 
+#define PNV9_XSCOM_SIZE              0x0000000400000000ull
+#define PNV9_XSCOM_BASE(chip)        PNV9_CHIP_BASE(chip, 0x00603fc00000000ull)
+
 #endif /* PPC_PNV_H */
diff --git a/include/hw/ppc/pnv_xscom.h b/include/hw/ppc/pnv_xscom.h
index 7ddc82c3a288..78fcf88a495b 100644
--- a/include/hw/ppc/pnv_xscom.h
+++ b/include/hw/ppc/pnv_xscom.h
@@ -102,7 +102,7 @@ typedef struct PnvXScomInterfaceClass {
 #define PNV9_XSCOM_PEC_PCI_BASE   0xd010800
 #define PNV9_XSCOM_PEC_PCI_SIZE   0x200
 
-extern void pnv_xscom_realize(PnvChip *chip, Error **errp);
+extern void pnv_xscom_realize(PnvChip *chip, uint64_t size, Error **errp);
 extern int pnv_dt_xscom(PnvChip *chip, void *fdt, int offset);
 
 extern void pnv_xscom_add_subregion(PnvChip *chip, hwaddr offset,
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index 7b60c97339dd..92c01dfc09ef 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -902,6 +902,14 @@ static void pnv_chip_power8_realize(DeviceState *dev, Error **errp)
     Error *local_err = NULL;
     int i;
 
+    /* XSCOM bridge is first */
+    pnv_xscom_realize(chip, PNV_XSCOM_SIZE, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        return;
+    }
+    sysbus_mmio_map(SYS_BUS_DEVICE(chip), 0, PNV_XSCOM_BASE(chip));
+
     pcc->parent_realize(dev, &local_err);
     if (local_err) {
         error_propagate(errp, local_err);
@@ -1092,6 +1100,14 @@ static void pnv_chip_power9_realize(DeviceState *dev, Error **errp)
     Error *local_err = NULL;
     uint32_t i;
 
+    /* XSCOM bridge is first */
+    pnv_xscom_realize(chip, PNV9_XSCOM_SIZE, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        return;
+    }
+    sysbus_mmio_map(SYS_BUS_DEVICE(chip), 0, PNV9_XSCOM_BASE(chip));
+
     pcc->parent_realize(dev, &local_err);
     if (local_err) {
         error_propagate(errp, local_err);
@@ -1301,14 +1317,6 @@ static void pnv_chip_realize(DeviceState *dev, Error **errp)
     PnvChip *chip = PNV_CHIP(dev);
     Error *error = NULL;
 
-    /* XSCOM bridge */
-    pnv_xscom_realize(chip, &error);
-    if (error) {
-        error_propagate(errp, error);
-        return;
-    }
-    sysbus_mmio_map(SYS_BUS_DEVICE(chip), 0, PNV_XSCOM_BASE(chip));
-
     /* Cores */
     pnv_chip_core_realize(chip, &error);
     if (error) {
diff --git a/hw/ppc/pnv_xscom.c b/hw/ppc/pnv_xscom.c
index cc7c66320f23..770176326526 100644
--- a/hw/ppc/pnv_xscom.c
+++ b/hw/ppc/pnv_xscom.c
@@ -211,17 +211,17 @@ const MemoryRegionOps pnv_xscom_ops = {
     .endianness = DEVICE_BIG_ENDIAN,
 };
 
-void pnv_xscom_realize(PnvChip *chip, Error **errp)
+void pnv_xscom_realize(PnvChip *chip, uint64_t size, Error **errp)
 {
     SysBusDevice *sbd = SYS_BUS_DEVICE(chip);
     char *name;
 
     name = g_strdup_printf("xscom-%x", chip->chip_id);
     memory_region_init_io(&chip->xscom_mmio, OBJECT(chip), &pnv_xscom_ops,
-                          chip, name, PNV_XSCOM_SIZE);
+                          chip, name, size);
     sysbus_init_mmio(sbd, &chip->xscom_mmio);
 
-    memory_region_init(&chip->xscom, OBJECT(chip), name, PNV_XSCOM_SIZE);
+    memory_region_init(&chip->xscom, OBJECT(chip), name, size);
     address_space_init(&chip->xscom_as, &chip->xscom, name);
     g_free(name);
 }
@@ -263,12 +263,19 @@ static const char compat_p9[] = "ibm,power9-xscom\0ibm,xscom";
 
 int pnv_dt_xscom(PnvChip *chip, void *fdt, int root_offset)
 {
-    uint64_t reg[] = { cpu_to_be64(PNV_XSCOM_BASE(chip)),
-                       cpu_to_be64(PNV_XSCOM_SIZE) };
+    uint64_t reg[2];
     int xscom_offset;
     ForeachPopulateArgs args;
     char *name;
 
+    if (pnv_chip_is_power9(chip)) {
+        reg[0] = cpu_to_be64(PNV9_XSCOM_BASE(chip));
+        reg[1] = cpu_to_be64(PNV9_XSCOM_SIZE);
+    } else {
+        reg[0] = cpu_to_be64(PNV_XSCOM_BASE(chip));
+        reg[1] = cpu_to_be64(PNV_XSCOM_SIZE);
+    }
+
     name = g_strdup_printf("xscom@%" PRIx64, be64_to_cpu(reg[0]));
     xscom_offset = fdt_add_subnode(fdt, root_offset, name);
     _FDT(xscom_offset);
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH 2/2] ppc/pnc: remove xscom_base field from PnvChip
  2019-06-12 17:43 [Qemu-devel] [PATCH 0/2] ppc/pnc: fix XSCOM MMIO base address for P9 machines with multiple chips Cédric Le Goater
  2019-06-12 17:43 ` [Qemu-devel] [PATCH 1/2] " Cédric Le Goater
@ 2019-06-12 17:43 ` Cédric Le Goater
  2019-06-12 17:47 ` [Qemu-devel] [PATCH 0/2] ppc/pnc: fix XSCOM MMIO base address for P9 machines with multiple chips Cédric Le Goater
  2 siblings, 0 replies; 5+ messages in thread
From: Cédric Le Goater @ 2019-06-12 17:43 UTC (permalink / raw)
  To: David Gibson; +Cc: qemu-ppc, qemu-devel, Cédric Le Goater

It has now became useless with the previous patch.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 include/hw/ppc/pnv.h |  5 +----
 hw/ppc/pnv.c         | 10 ----------
 2 files changed, 1 insertion(+), 14 deletions(-)

diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h
index aa926d120771..de0c1d285fa7 100644
--- a/include/hw/ppc/pnv.h
+++ b/include/hw/ppc/pnv.h
@@ -58,7 +58,6 @@ typedef struct PnvChip {
     uint64_t     cores_mask;
     void         *cores;
 
-    hwaddr       xscom_base;
     MemoryRegion xscom_mmio;
     MemoryRegion xscom;
     AddressSpace xscom_as;
@@ -114,8 +113,6 @@ typedef struct PnvChipClass {
     uint64_t     cores_mask;
     uint32_t     num_phbs;
 
-    hwaddr       xscom_base;
-
     DeviceRealize parent_realize;
 
     uint32_t (*core_pir)(PnvChip *chip, uint32_t core_id);
@@ -226,7 +223,7 @@ int pnv_bmc_hiomap(IPMIBmc *bmc);
  */
 #define PNV_XSCOM_SIZE        0x800000000ull
 #define PNV_XSCOM_BASE(chip)                                            \
-    (chip->xscom_base + ((uint64_t)(chip)->chip_id) * PNV_XSCOM_SIZE)
+    (0x0003fc0000000000ull + ((uint64_t)(chip)->chip_id) * PNV_XSCOM_SIZE)
 
 /*
  * XSCOM 0x20109CA defines the ICP BAR:
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index 92c01dfc09ef..4352066ec1f2 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -982,7 +982,6 @@ static void pnv_chip_power8e_class_init(ObjectClass *klass, void *data)
     k->isa_create = pnv_chip_power8_isa_create;
     k->dt_populate = pnv_chip_power8_dt_populate;
     k->pic_print_info = pnv_chip_power8_pic_print_info;
-    k->xscom_base = 0x003fc0000000000ull;
     dc->desc = "PowerNV Chip POWER8E";
 
     device_class_set_parent_realize(dc, pnv_chip_power8_realize,
@@ -1003,7 +1002,6 @@ static void pnv_chip_power8_class_init(ObjectClass *klass, void *data)
     k->isa_create = pnv_chip_power8_isa_create;
     k->dt_populate = pnv_chip_power8_dt_populate;
     k->pic_print_info = pnv_chip_power8_pic_print_info;
-    k->xscom_base = 0x003fc0000000000ull;
     dc->desc = "PowerNV Chip POWER8";
 
     device_class_set_parent_realize(dc, pnv_chip_power8_realize,
@@ -1024,7 +1022,6 @@ static void pnv_chip_power8nvl_class_init(ObjectClass *klass, void *data)
     k->isa_create = pnv_chip_power8nvl_isa_create;
     k->dt_populate = pnv_chip_power8_dt_populate;
     k->pic_print_info = pnv_chip_power8_pic_print_info;
-    k->xscom_base = 0x003fc0000000000ull;
     dc->desc = "PowerNV Chip POWER8NVL";
 
     device_class_set_parent_realize(dc, pnv_chip_power8_realize,
@@ -1210,7 +1207,6 @@ static void pnv_chip_power9_class_init(ObjectClass *klass, void *data)
     k->isa_create = pnv_chip_power9_isa_create;
     k->dt_populate = pnv_chip_power9_dt_populate;
     k->pic_print_info = pnv_chip_power9_pic_print_info;
-    k->xscom_base = 0x00603fc00000000ull;
     dc->desc = "PowerNV Chip POWER9";
 
     device_class_set_parent_realize(dc, pnv_chip_power9_realize,
@@ -1247,11 +1243,6 @@ static void pnv_chip_core_sanitize(PnvChip *chip, Error **errp)
     }
 }
 
-static void pnv_chip_instance_init(Object *obj)
-{
-    PNV_CHIP(obj)->xscom_base = PNV_CHIP_GET_CLASS(obj)->xscom_base;
-}
-
 static void pnv_chip_core_realize(PnvChip *chip, Error **errp)
 {
     Error *error = NULL;
@@ -1519,7 +1510,6 @@ static const TypeInfo types[] = {
         .name          = TYPE_PNV_CHIP,
         .parent        = TYPE_SYS_BUS_DEVICE,
         .class_init    = pnv_chip_class_init,
-        .instance_init = pnv_chip_instance_init,
         .instance_size = sizeof(PnvChip),
         .class_size    = sizeof(PnvChipClass),
         .abstract      = true,
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] ppc/pnc: fix XSCOM MMIO base address for P9 machines with multiple chips
  2019-06-12 17:43 [Qemu-devel] [PATCH 0/2] ppc/pnc: fix XSCOM MMIO base address for P9 machines with multiple chips Cédric Le Goater
  2019-06-12 17:43 ` [Qemu-devel] [PATCH 1/2] " Cédric Le Goater
  2019-06-12 17:43 ` [Qemu-devel] [PATCH 2/2] ppc/pnc: remove xscom_base field from PnvChip Cédric Le Goater
@ 2019-06-12 17:47 ` Cédric Le Goater
  2019-06-13  0:04   ` David Gibson
  2 siblings, 1 reply; 5+ messages in thread
From: Cédric Le Goater @ 2019-06-12 17:47 UTC (permalink / raw)
  To: David Gibson; +Cc: qemu-ppc, qemu-devel

On 12/06/2019 19:43, Cédric Le Goater wrote:
> Hello,
> 
> The base address of the MMIO window of the XSCOM bus is incorrect on
> P9 machines with multiple chips. Provide a fix for that to prepare
> ground for future PowerNV chips.

David,

I just noticed the 'pnc' in the title. If you were to merge, can you 
fix it ? 

Thanks,

C. 



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] ppc/pnc: fix XSCOM MMIO base address for P9 machines with multiple chips
  2019-06-12 17:47 ` [Qemu-devel] [PATCH 0/2] ppc/pnc: fix XSCOM MMIO base address for P9 machines with multiple chips Cédric Le Goater
@ 2019-06-13  0:04   ` David Gibson
  0 siblings, 0 replies; 5+ messages in thread
From: David Gibson @ 2019-06-13  0:04 UTC (permalink / raw)
  To: Cédric Le Goater; +Cc: qemu-ppc, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 625 bytes --]

On Wed, Jun 12, 2019 at 07:47:20PM +0200, Cédric Le Goater wrote:
> On 12/06/2019 19:43, Cédric Le Goater wrote:
> > Hello,
> > 
> > The base address of the MMIO window of the XSCOM bus is incorrect on
> > P9 machines with multiple chips. Provide a fix for that to prepare
> > ground for future PowerNV chips.
> 
> David,
> 
> I just noticed the 'pnc' in the title. If you were to merge, can you 
> fix it ?

Done.

-- 
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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-06-13  3:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-12 17:43 [Qemu-devel] [PATCH 0/2] ppc/pnc: fix XSCOM MMIO base address for P9 machines with multiple chips Cédric Le Goater
2019-06-12 17:43 ` [Qemu-devel] [PATCH 1/2] " Cédric Le Goater
2019-06-12 17:43 ` [Qemu-devel] [PATCH 2/2] ppc/pnc: remove xscom_base field from PnvChip Cédric Le Goater
2019-06-12 17:47 ` [Qemu-devel] [PATCH 0/2] ppc/pnc: fix XSCOM MMIO base address for P9 machines with multiple chips Cédric Le Goater
2019-06-13  0:04   ` David Gibson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).