ppc/pnv: misc fixes and cleanups for POWER9
cover ppc/pnv: misc fixes and cleanups for POWER9
Hello,
Here are some preliminary and straight forward fixes before adding POWER9 support to the PowerNV machine.
The full tree can be found here :
https://github.com/legoater/qemu powernv-2.12
Thanks,
C.
Cédric Le Goater (6):
ppc/pnv: use POWER9 DD2 processor
ppc/pnv: change core mask for POWER9
ppc/pnv: introduce pnv*_is_power9() helpers
ppc/pnv: fix XSCOM core addressing on POWER9
ppc/pnv: change initrd address
target/ppc: add support for POWER9 HILE
hw/ppc/pnv.c | 23 ++++++++++++----------- hw/ppc/pnv_core.c | 2 +- hw/ppc/pnv_xscom.c | 8 +++----- include/hw/ppc/pnv.h | 11 ++++++++++- include/hw/ppc/pnv_xscom.h | 13 +++++++++++-- target/ppc/cpu.h | 1 + target/ppc/excp_helper.c | 2 +- tests/pnv-xscom-test.c | 31 +++++++++++++++++++------------ 8 files changed, 58 insertions(+), 33 deletions(-)
Signature · 1 line
2.13.6
PATCH 1/6 ppc/pnv: use POWER9 DD2 processor
commit 1ed9c8af501f ("target/ppc: Add POWER9 DD2.0 model information") deprecated the POWER9 model v1.0.
--- hw/ppc/pnv.c | 2 +- tests/pnv-xscom-test.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
hw/ppc/pnv.c +1 -1
@@ -759,7 +759,7 @@ static void pnv_chip_power9_class_init(ObjectClass *klass, void *data)PnvChipClass *k =PNV_CHIP_CLASS (klass); k->chip_type =PNV_CHIP_POWER9 ; - k->chip_cfam_id =0x100d104980000000ull ;/* P9 Nimbus DD1.0 */ + k->chip_cfam_id =0x220d104900008000ull ;/* P9 Nimbus DD2.0 */ k->cores_mask =POWER9_CORE_MASK ; k->core_pir = pnv_chip_core_pir_p9; k->xscom_base =0x00603fc00000000ull ;
tests/pnv-xscom-test.c +1 -1
@@ -48,7 +48,7 @@ static const PnvChip pnv_chips[] = { .cpu_model = "POWER9", .xscom_base = 0x000603fc00000000ull, .xscom_core_base = 0x0ull, - .cfam_id = 0x100d104980000000ull, + .cfam_id = 0x220d104900008000ull, .first_core = 0x20, },#endif
Signature · 1 line
2.13.6
PATCH 2/6 ppc/pnv: change core mask for POWER9
In reply to Cédric Le GoaterWhen addressed by XSCOM, the first core has the 0x20 chiplet ID but the CPU PIR can start at 0x0.
--- hw/ppc/pnv.c | 4 ++-- tests/pnv-xscom-test.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
hw/ppc/pnv.c +2 -2
@@ -707,9 +707,9 @@ static uint32_t pnv_chip_core_pir_p9(PnvChip *chip, uint32_t core_id)#define POWER8_CORE_MASK (0x7e7eull)/* -* POWER9 has 24 cores, ids starting at 0x20 +* POWER9 has 24 cores, ids starting at 0x0 */ -#define POWER9_CORE_MASK (0xffffff00000000ull) +#define POWER9_CORE_MASK (0xffffffffffffffull)static void pnv_chip_power8e_class_init (ObjectClass *klass,void *data) {
tests/pnv-xscom-test.c +1 -1
@@ -49,7 +49,7 @@ static const PnvChip pnv_chips[] = { .xscom_base = 0x000603fc00000000ull, .xscom_core_base = 0x0ull, .cfam_id = 0x220d104900008000ull, - .first_core = 0x20, + .first_core = 0x0, },#endif };
Signature · 1 line
2.13.6
PATCH 3/6 ppc/pnv: introduce pnv*_is_power9() helpers
In reply to Cédric Le GoaterThese are useful when instantiating device models which are shared between the POWER8 and the POWER9 processor families.
--- hw/ppc/pnv_xscom.c | 8 +++----- include/hw/ppc/pnv.h | 10 ++++++++++ 2 files changed, 13 insertions(+), 5 deletions(-)
hw/ppc/pnv_xscom.c +3 -5
@@ -51,10 +51,9 @@ static void xscom_complete(CPUState *cs, uint64_t hmer_bits)static uint32_t pnv_xscom_pcba (PnvChip *chip,uint64_t addr) { -PnvChipClass *pcc =PNV_CHIP_GET_CLASS (chip); - addr &= (PNV_XSCOM_SIZE -1 ); -if (pcc->chip_type ==PNV_CHIP_POWER9 ) { + +if (pnv_chip_is_power9 (chip)) {return addr >>3 ; }else {return ((addr >>4 ) & ~0xfull ) | ((addr >>3 ) &0xf );
@@ -231,7 +230,6 @@ int pnv_dt_xscom(PnvChip *chip, void *fdt, int root_offset)int xscom_offset;ForeachPopulateArgs args;char *name; -PnvChipClass *pcc =PNV_CHIP_GET_CLASS (chip); name =g_strdup_printf ("xscom@%" PRIx64,be64_to_cpu (reg[0 ])); xscom_offset =fdt_add_subnode (fdt, root_offset, name);
@@ -242,7 +240,7 @@ int pnv_dt_xscom(PnvChip *chip, void *fdt, int root_offset)_FDT ((fdt_setprop_cell (fdt, xscom_offset,"#size-cells" ,1 )));_FDT ((fdt_setprop (fdt, xscom_offset,"reg" , reg,sizeof (reg)))); -if (pcc->chip_type ==PNV_CHIP_POWER9 ) { +if (pnv_chip_is_power9 (chip)) {_FDT ((fdt_setprop (fdt, xscom_offset,"compatible" , compat_p9,sizeof (compat_p9)))); }else {
include/hw/ppc/pnv.h +10 -0
@@ -138,6 +138,16 @@ typedef struct PnvMachineState {Notifier powerdown_notifier; } PnvMachineState; +static inline bool pnv_chip_is_power9 (const PnvChip *chip) +{ +return PNV_CHIP_GET_CLASS (chip)->chip_type ==PNV_CHIP_POWER9 ; +} + +static inline bool pnv_is_power9 (PnvMachineState *pnv) +{ +return pnv_chip_is_power9 (pnv->chips[0 ]); +} +#define PNV_FDT_ADDR 0x01000000#define PNV_TIMEBASE_FREQ 512000000ULL
Signature · 1 line
2.13.6
PATCH 4/6 ppc/pnv: fix XSCOM core addressing on POWER9
In reply to Cédric Le GoaterThe XSCOM base address of the core chiplet was wrongly calculated. Use the OPAL macros to fix that and do a couple of renames.
--- hw/ppc/pnv.c | 15 ++++++++------- hw/ppc/pnv_core.c | 2 +- include/hw/ppc/pnv.h | 1 - include/hw/ppc/pnv_xscom.h | 13 +++++++++++-- tests/pnv-xscom-test.c | 27 +++++++++++++++++---------- 5 files changed, 37 insertions(+), 21 deletions(-)
hw/ppc/pnv.c +8 -7
@@ -721,7 +721,6 @@ static void pnv_chip_power8e_class_init(ObjectClass *klass, void *data) k->cores_mask =POWER8E_CORE_MASK ; k->core_pir = pnv_chip_core_pir_p8; k->xscom_base =0x003fc0000000000ull ; - k->xscom_core_base =0x10000000ull ; dc->desc ="PowerNV Chip POWER8E" ; }
@@ -735,7 +734,6 @@ static void pnv_chip_power8_class_init(ObjectClass *klass, void *data) k->cores_mask =POWER8_CORE_MASK ; k->core_pir = pnv_chip_core_pir_p8; k->xscom_base =0x003fc0000000000ull ; - k->xscom_core_base =0x10000000ull ; dc->desc ="PowerNV Chip POWER8" ; }
@@ -749,7 +747,6 @@ static void pnv_chip_power8nvl_class_init(ObjectClass *klass, void *data) k->cores_mask =POWER8_CORE_MASK ; k->core_pir = pnv_chip_core_pir_p8; k->xscom_base =0x003fc0000000000ull ; - k->xscom_core_base =0x10000000ull ; dc->desc ="PowerNV Chip POWER8NVL" ; }
@@ -763,7 +760,6 @@ static void pnv_chip_power9_class_init(ObjectClass *klass, void *data) k->cores_mask =POWER9_CORE_MASK ; k->core_pir = pnv_chip_core_pir_p9; k->xscom_base =0x00603fc00000000ull ; - k->xscom_core_base =0x0ull ; dc->desc ="PowerNV Chip POWER9" ; }
@@ -887,6 +883,7 @@ static void pnv_chip_realize(DeviceState *dev, Error **errp) && (i < chip->nr_cores); core_hwid++) {char core_name[32 ];void *pnv_core = chip->cores + i * typesize; +uint64_t xscom_core_base;if (!(chip->cores_mask & (1ull << core_hwid))) {continue ;
@@ -910,9 +907,13 @@ static void pnv_chip_realize(DeviceState *dev, Error **errp)object_unref (OBJECT (pnv_core));/* Each core has an XSCOM MMIO region */ -pnv_xscom_add_subregion (chip, -PNV_XSCOM_EX_CORE_BASE (pcc->xscom_core_base, - core_hwid), +if (!pnv_chip_is_power9 (chip)) { + xscom_core_base =PNV_XSCOM_EX_BASE (core_hwid); + }else { + xscom_core_base =PNV_XSCOM_P9_EC_BASE (core_hwid); + } + +pnv_xscom_add_subregion (chip, xscom_core_base, &PNV_CORE (pnv_core)->xscom_regs); i++; }
hw/ppc/pnv_core.c +1 -1
@@ -192,7 +192,7 @@ static void pnv_core_realize(DeviceState *dev, Error **errp)snprintf (name,sizeof (name),"xscom-core.%d" , cc->core_id);pnv_xscom_region_init (&pc->xscom_regs,OBJECT (dev), &pnv_core_xscom_ops, - pc, name,PNV_XSCOM_EX_CORE_SIZE ); + pc, name,PNV_XSCOM_EX_SIZE );return ; err:
include/hw/ppc/pnv.h +0 -1
@@ -74,7 +74,6 @@ typedef struct PnvChipClass {uint64_t cores_mask;hwaddr xscom_base; -hwaddr xscom_core_base;uint32_t (*core_pir)(PnvChip *chip,uint32_t core_id); } PnvChipClass;
include/hw/ppc/pnv_xscom.h +11 -2
@@ -21,6 +21,8 @@#include "qom/object.h" +typedef struct PnvChip PnvChip ; +typedef struct PnvXScomInterface {Object parent; }PnvXScomInterface ;
@@ -54,8 +56,15 @@ typedef struct PnvXScomInterfaceClass {* PCB SLAVE 0x110Fxxxx */ -#define PNV_XSCOM_EX_CORE_BASE (base, i) ((base) | ((uint64_t)(i) << 24)) -#define PNV_XSCOM_EX_CORE_SIZE 0x100000 +#define PNV_XSCOM_EX_CORE_BASE 0x10000000ull + +#define PNV_XSCOM_EX_BASE (core) \ + (PNV_XSCOM_EX_CORE_BASE | ((uint64_t)(core) << 24)) +#define PNV_XSCOM_EX_SIZE 0x100000 + +#define PNV_XSCOM_P9_EC_BASE (core) \ + ((uint64_t)(((core) & 0x1F) + 0x20) << 24) +#define PNV_XSCOM_P9_EC_SIZE 0x100000#define PNV_XSCOM_LPC_BASE 0xb0020#define PNV_XSCOM_LPC_SIZE 0x4
tests/pnv-xscom-test.c +17 -10
@@ -21,7 +21,6 @@ typedef struct PnvChip {PnvChipType chip_type;const char *cpu_model;uint64_t xscom_base; -uint64_t xscom_core_base;uint64_t cfam_id;uint32_t first_core; } PnvChip;
@@ -31,14 +30,12 @@ static const PnvChip pnv_chips[] = { .chip_type = PNV_CHIP_POWER8, .cpu_model = "POWER8", .xscom_base = 0x0003fc0000000000ull, - .xscom_core_base = 0x10000000ull, .cfam_id = 0x220ea04980000000ull, .first_core = 0x1, }, { .chip_type = PNV_CHIP_POWER8NVL, .cpu_model = "POWER8NVL", .xscom_base = 0x0003fc0000000000ull, - .xscom_core_base = 0x10000000ull, .cfam_id = 0x120d304980000000ull, .first_core = 0x1, },
@@ -47,7 +44,6 @@ static const PnvChip pnv_chips[] = { .chip_type = PNV_CHIP_POWER9, .cpu_model = "POWER9", .xscom_base = 0x000603fc00000000ull, - .xscom_core_base = 0x0ull, .cfam_id = 0x220d104900008000ull, .first_core = 0x0, },
@@ -89,16 +85,27 @@ static void test_cfam_id(const void *data)qtest_quit (global_qtest); } -#define PNV_XSCOM_EX_CORE_BASE (chip, i) \ - ((chip)->xscom_core_base | (((uint64_t)i) << 24)) + +#define PNV_XSCOM_EX_CORE_BASE 0x10000000ull +#define PNV_XSCOM_EX_BASE (core) \ + (PNV_XSCOM_EX_CORE_BASE | ((uint64_t)(core) << 24)) +#define PNV_XSCOM_P9_EC_BASE (core) \ + ((uint64_t)(((core) & 0x1F) + 0x20) << 24) +#define PNV_XSCOM_EX_DTS_RESULT0 0x50000static void test_xscom_core (const PnvChip *chip) { -uint32_t first_core_dts0 = -PNV_XSCOM_EX_CORE_BASE (chip, chip->first_core) | -PNV_XSCOM_EX_DTS_RESULT0 ; -uint64_t dts0 =pnv_xscom_read (chip, first_core_dts0); +uint32_t first_core_dts0 =PNV_XSCOM_EX_DTS_RESULT0 ; +uint64_t dts0; + +if (chip->chip_type !=PNV_CHIP_POWER9 ) { + first_core_dts0 |=PNV_XSCOM_EX_BASE (chip->first_core); + }else { + first_core_dts0 |=PNV_XSCOM_P9_EC_BASE (chip->first_core); + } + + dts0 =pnv_xscom_read (chip, first_core_dts0); g_assert_cmphex(dts0, ==, 0x26f024f023f0000ull); }
Signature · 1 line
2.13.6
PATCH 5/6 ppc/pnv: change initrd address
In reply to Cédric Le GoaterWhen skiboot starts, it first clears the CPU structs for all possible CPUs on a system :
for (i = 0; i <= cpu_max_pir; i++) memset(&cpu_stacks[i].cpu, 0, sizeof(struct cpu_thread));
On POWER9, cpu_max_pir is quite big, 0x7fff, and the skiboot cpu_stacks array overlaps with the memory region in which QEMU maps the initramfs file. Move it upwards in memory to keep it safe.
--- hw/ppc/pnv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/pnv.c +1 -1
@@ -53,7 +53,7 @@#define FW_MAX_SIZE 0x00400000#define KERNEL_LOAD_ADDR 0x20000000 -#define INITRD_LOAD_ADDR 0x40000000 +#define INITRD_LOAD_ADDR 0x60000000static const char *pnv_chip_core_typename (const PnvChip *o) {
Signature · 1 line
2.13.6
PATCH 6/6 target/ppc: add support for POWER9 HILE
In reply to Cédric Le Goater--- target/ppc/cpu.h | 1 + target/ppc/excp_helper.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
target/ppc/cpu.h +1 -0
@@ -2012,6 +2012,7 @@ void ppc_compat_add_property(Object *obj, const char *name,#define HID0_DOZE (1 << 23)/* pre-2.06 */ #define HID0_NAP (1 << 22)/* pre-2.06 */ #define HID0_HILE PPC_BIT(19)/* POWER8 */ +#define HID0_POWER9_HILE PPC_BIT(4)/*****************************************************************************/ /* PowerPC Instructions types definitions */
target/ppc/excp_helper.c +1 -1
@@ -654,7 +654,7 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp) } }else if (excp_model ==POWERPC_EXCP_POWER8 ) {if (new_msr &MSR_HVB ) { -if (env->spr[SPR_HID0 ] &HID0_HILE ) { +if (env->spr[SPR_HID0 ] & (HID0_HILE |HID0_POWER9_HILE )) { new_msr |= (target_ulong )1 <<MSR_LE ; } }else if (env->spr[SPR_LPCR ] &LPCR_ILE ) {
Signature · 1 line
2.13.6
David Gibson
AppliedQuoted 10 lines · Cédric Le Goater
Hello,
Here are some preliminary and straight forward fixes before adding POWER9 support to the PowerNV machine.
The full tree can be found here :
https://github.com/legoater/qemu powernv-2.12
Thanks,
Applied to ppc-for-2.12.
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