ppc/pnc: fix XSCOM MMIO base address for P9 machines with multiple chips
cover ppc/pnc: fix XSCOM MMIO base address for P9 machines with multiple chips
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(-)
Signature · 1 line
2.21.0
PATCH 1/2 ppc/pnc: fix XSCOM MMIO base address for P9 machines with multiple chips
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.
--- 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(-)
include/hw/ppc/pnv.h +3 -0
@@ -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 */
include/hw/ppc/pnv_xscom.h +1 -1
@@ -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,
hw/ppc/pnv.c +16 -8
@@ -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) {
hw/ppc/pnv_xscom.c +12 -5
@@ -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);
Signature · 1 line
2.21.0
PATCH 2/2 ppc/pnc: remove xscom_base field from PnvChip
In reply to Cédric Le GoaterIt has now became useless with the previous patch.
--- include/hw/ppc/pnv.h | 5 +---- hw/ppc/pnv.c | 10 ---------- 2 files changed, 1 insertion(+), 14 deletions(-)
include/hw/ppc/pnv.h +1 -4
@@ -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:
hw/ppc/pnv.c +0 -10
@@ -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,
Signature · 1 line
2.21.0
Quoted 5 lines · 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.
David,
I just noticed the 'pnc' in the title. If you were to merge, can you fix it ?
Thanks,
C.
Quoted 11 lines · Cédric Le Goater
Quoted 5 lines · 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.
David,
I just noticed the 'pnc' in the title. If you were to merge, can you fix it ?
Done.
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