ppc/pnv: new Pnv8Chip and Pnv9Chip models
v3 cover ppc/pnv: new Pnv8Chip and Pnv9Chip models
Hello,
Here comes new chip models for the different processor the PowerNV machine supports and some more cleanups around the device tree of the ISA bus of the machine.
Thanks,
C.
Changes since v2:
- introduced a parent_realize
- removed the machines
Changes since v1:
- reworked the ISABus creation interface with the chip, the machine is not aware anymore of the chip controllers.
- removed the bizarre controllers under the PnvChip base class.
- kept back some changes on the ISA device tree name. They will come in time with the LPC controller for P9
Cédric Le Goater (2):
ppc/pnv: introduce Pnv8Chip and Pnv9Chip models ppc/pnv: consolidate the creation of the ISA bus device tree
include/hw/ppc/pnv.h | 24 +++- hw/ppc/pnv.c | 332 +++++++++++++++++++++++++++++++-------------------- 2 files changed, 225 insertions(+), 131 deletions(-)
Signature · 1 line
2.13.6
PATCH v3 1/2 ppc/pnv: introduce Pnv8Chip and Pnv9Chip models
It introduces a base PnvChip class from which the specific processor chip classes, Pnv8Chip and Pnv9Chip, inherit. Each of them needs to define an init and a realize routine which will create the controllers of the target processor. For the moment, the base PnvChip class handles the XSCOM bus and the cores.
--- include/hw/ppc/pnv.h | 24 ++++- hw/ppc/pnv.c | 281 ++++++++++++++++++++++++++++++++------------------- 2 files changed, 202 insertions(+), 103 deletions(-)
include/hw/ppc/pnv.h +23 -1
@@ -57,12 +57,32 @@ typedef struct PnvChip {MemoryRegion xscom_mmio;MemoryRegion xscom;AddressSpace xscom_as; +} PnvChip; + +#define TYPE_PNV8_CHIP "pnv8-chip" +#define PNV8_CHIP (obj) OBJECT_CHECK(Pnv8Chip, (obj), TYPE_PNV8_CHIP) + +typedef struct Pnv8Chip { +/*< private >*/ +PnvChip parent_obj; + +/*< public >*/ MemoryRegion icp_mmio;PnvLpcController lpc;PnvPsi psi;PnvOCC occ; -} PnvChip; +}Pnv8Chip ; + +#define TYPE_PNV9_CHIP "pnv9-chip" +#define PNV9_CHIP (obj) OBJECT_CHECK(Pnv9Chip, (obj), TYPE_PNV9_CHIP) + +typedef struct Pnv9Chip { +/*< private >*/ +PnvChip parent_obj; + +/*< public >*/ +}Pnv9Chip ; typedef struct PnvChipClass { /*< private >*/
@@ -75,6 +95,8 @@ typedef struct PnvChipClass {hwaddr xscom_base; +DeviceRealize parent_realize; +uint32_t (*core_pir)(PnvChip *chip,uint32_t core_id); Object *(*intc_create)(PnvChip *chip, Object *child, Error **errp); ISABus *(*isa_create)(PnvChip *chip, Error **errp);
hw/ppc/pnv.c +179 -102
380 lines not on this page · raw message
Signature · 1 line
2.13.6
PATCH v3 2/2 ppc/pnv: consolidate the creation of the ISA bus device tree
In reply to Cédric Le GoaterThe device tree node of the ISA bus was being partially done in different places. Move all the nodes creation under the same routine.
--- hw/ppc/pnv.c | 51 +++++++++++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 28 deletions(-)
hw/ppc/pnv.c +23 -28
@@ -265,18 +265,6 @@ static void pnv_dt_icp(PnvChip *chip, void *fdt, uint32_t pir,g_free (reg); } -static int pnv_chip_lpc_offset (PnvChip *chip,void *fdt) -{ -char *name; -int offset; - - name =g_strdup_printf ("/xscom@%" PRIx64"/isa@%x" , - (uint64_t )PNV_XSCOM_BASE (chip),PNV_XSCOM_LPC_BASE ); - offset =fdt_path_offset (fdt, name); -g_free (name); -return offset; -} -static void pnv_dt_chip (PnvChip *chip,void *fdt) {const char *typename =pnv_chip_core_typename (chip);
@@ -285,16 +273,6 @@ static void pnv_dt_chip(PnvChip *chip, void *fdt)pnv_dt_xscom (chip, fdt,0 ); -/* The default LPC bus of a multichip system is on chip 0. It's -* recognized by the firmware (skiboot) using a "primary" -* property. -*/ -if (chip->chip_id ==0x0 ) { -int lpc_offset =pnv_chip_lpc_offset (chip, fdt); - -_FDT ((fdt_setprop (fdt, lpc_offset,"primary" ,NULL ,0 ))); - } -for (i =0 ; i < chip->nr_cores; i++) {PnvCore *pnv_core =PNV_CORE (chip->cores + i * typesize);
@@ -418,16 +396,35 @@ static int pnv_dt_isa_device(DeviceState *dev, void *opaque)return 0 ; } -static void pnv_dt_isa (ISABus *bus,void *fdt,int lpc_offset) +static int pnv_chip_isa_offset (PnvChip *chip,void *fdt) +{ +char *name; +int offset; + + name =g_strdup_printf ("/xscom@%" PRIx64"/isa@%x" , + (uint64_t )PNV_XSCOM_BASE (chip),PNV_XSCOM_LPC_BASE ); + offset =fdt_path_offset (fdt, name); +g_free (name); +return offset; +} + +/* The default LPC bus of a multichip system is on chip 0. It's +* recognized by the firmware (skiboot) using a "primary" property. +*/ +static void pnv_dt_isa (PnvMachineState *pnv,void *fdt) { +int isa_offset =pnv_chip_isa_offset (pnv->chips[0 ], fdt);ForeachPopulateArgs args = { .fdt = fdt, - .offset = lpc_offset, + .offset = isa_offset, }; +_FDT ((fdt_setprop (fdt, isa_offset,"primary" ,NULL ,0 ))); +/* ISA devices are not necessarily parented to the ISA bus so we * can not use object_child_foreach() */ -qbus_walk_children (BUS (bus), pnv_dt_isa_device,NULL ,NULL ,NULL , &args); +qbus_walk_children (BUS (pnv->isa_bus), pnv_dt_isa_device,NULL ,NULL ,NULL , + &args); }static void *pnv_dt_create (MachineState *machine)
@@ -438,7 +435,6 @@ static void *pnv_dt_create(MachineState *machine)char *buf;int off;int i; -int lpc_offset; fdt =g_malloc0 (FDT_MAX_SIZE );_FDT ((fdt_create_empty_tree (fdt,FDT_MAX_SIZE )));
@@ -480,8 +476,7 @@ static void *pnv_dt_create(MachineState *machine) }/* Populate ISA devices on chip 0 */ - lpc_offset =pnv_chip_lpc_offset (pnv->chips[0 ], fdt); -pnv_dt_isa (pnv->isa_bus, fdt, lpc_offset); +pnv_dt_isa (pnv, fdt);if (pnv->bmc) {pnv_dt_bmc_sensors (pnv->bmc, fdt);
Signature · 1 line
2.13.6
David Gibson
AppliedQuoted 5 lines · Cédric Le Goater
Hello,
Here comes new chip models for the different processor the PowerNV machine supports and some more cleanups around the device tree of the ISA bus of the machine.
Applied to ppc-for-3.0, thanks.
Quoted 26 lines
Thanks,
C.
Changes since v2:
- introduced a
parent_realize
- removed the machinesChanges since v1:
- reworked the ISABus creation interface with the chip, the machine is not aware anymore of the chip controllers.
- removed the bizarre controllers under the PnvChip base class.
- kept back some changes on the ISA device tree name. They will come in time with the LPC controller for P9Cédric Le Goater (2):
ppc/pnv: introduce Pnv8Chip and Pnv9Chip models ppc/pnv: consolidate the creation of the ISA bus device treeinclude/hw/ppc/pnv.h | 24 +++- hw/ppc/pnv.c | 332 +++++++++++++++++++++++++++++++-------------------- 2 files changed, 225 insertions(+), 131 deletions(-)
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
Re: [Qemu-devel] [PATCH v3 2/2] ppc/pnv: consolidate the creation of the ISA bus device tree
In reply to Cédric Le GoaterQuoted 49 lines · Cédric Le Goater
The device tree node of the ISA bus was being partially done in different places. Move all the nodes creation under the same routine.
Signed-off-by Cédric Le Goater <[email protected]>--- hw/ppc/pnv.c | 51 +++++++++++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 28 deletions(-)hw/ppc/pnv.c +0
-22@@ -265,18 +265,6 @@ static void pnv_dt_icp(PnvChip *chip, void *fdt, uint32_t pir,g_free (reg); } -static int pnv_chip_lpc_offset (PnvChip *chip,void *fdt) -{ -char *name; -int offset; - - name =g_strdup_printf ("/xscom@%" PRIx64"/isa@%x" , - (uint64_t )PNV_XSCOM_BASE (chip),PNV_XSCOM_LPC_BASE ); - offset =fdt_path_offset (fdt, name); -g_free (name); -return offset; -} -static void pnv_dt_chip (PnvChip *chip,void *fdt) {const char *typename =pnv_chip_core_typename (chip);@@ -285,16 +273,6 @@ static void pnv_dt_chip(PnvChip *chip, void *fdt)pnv_dt_xscom (chip, fdt,0 ); -/* The default LPC bus of a multichip system is on chip 0. It's -* recognized by the firmware (skiboot) using a "primary" -* property. -*/ -if (chip->chip_id ==0x0 ) { -int lpc_offset =pnv_chip_lpc_offset (chip, fdt); - -_FDT ((fdt_setprop (fdt, lpc_offset,"primary" ,NULL ,0 ))); - } -for (i =0 ; i < chip->nr_cores; i++) {PnvCore *pnv_core =PNV_CORE (chip->cores + i * typesize);
hw/ppc/pnv.c static int pnv_dt_isa_device(DeviceState *dev, void *opaque) · line 399
Quoted 5 lines
hw/ppc/pnv.c +1
-1@@ -418,16 +396,35 @@ static int pnv_dt_isa_device(DeviceState *dev, void *opaque)return 0 ; } -static void pnv_dt_isa (ISABus *bus,void *fdt,int lpc_offset) +static int pnv_chip_isa_offset (PnvChip *chip,void *fdt)
AFAICT, this only has one caller, so you could probably fold it in there. Not a big deal, though.
Quoted 51 lines
hw/ppc/pnv.c +22
-5+{ +char *name; +int offset; + + name =g_strdup_printf ("/xscom@%" PRIx64"/isa@%x" , + (uint64_t )PNV_XSCOM_BASE (chip),PNV_XSCOM_LPC_BASE ); + offset =fdt_path_offset (fdt, name); +g_free (name); +return offset; +} + +/* The default LPC bus of a multichip system is on chip 0. It's +* recognized by the firmware (skiboot) using a "primary" property. +*/ +static void pnv_dt_isa (PnvMachineState *pnv,void *fdt) { +int isa_offset =pnv_chip_isa_offset (pnv->chips[0 ], fdt);ForeachPopulateArgs args = { .fdt = fdt, - .offset = lpc_offset, + .offset = isa_offset, }; +_FDT ((fdt_setprop (fdt, isa_offset,"primary" ,NULL ,0 ))); +/* ISA devices are not necessarily parented to the ISA bus so we * can not use object_child_foreach() */ -qbus_walk_children (BUS (bus), pnv_dt_isa_device,NULL ,NULL ,NULL , &args); +qbus_walk_children (BUS (pnv->isa_bus), pnv_dt_isa_device,NULL ,NULL ,NULL , + &args); }static void *pnv_dt_create (MachineState *machine)@@ -438,7 +435,6 @@ static void *pnv_dt_create(MachineState *machine)char *buf;int off;int i; -int lpc_offset; fdt =g_malloc0 (FDT_MAX_SIZE );_FDT ((fdt_create_empty_tree (fdt,FDT_MAX_SIZE )));@@ -480,8 +476,7 @@ static void *pnv_dt_create(MachineState *machine) }/* Populate ISA devices on chip 0 */ - lpc_offset =pnv_chip_lpc_offset (pnv->chips[0 ], fdt); -pnv_dt_isa (pnv->isa_bus, fdt, lpc_offset); +pnv_dt_isa (pnv, fdt);if (pnv->bmc) {pnv_dt_bmc_sensors (pnv->bmc, fdt);
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
Re: [Qemu-devel] [PATCH v3 2/2] ppc/pnv: consolidate the creation of the ISA bus device tree
Quoted 53 lines · David Gibson
Quoted 52 lines · Cédric Le Goater
The device tree node of the ISA bus was being partially done in different places. Move all the nodes creation under the same routine.
Signed-off-by Cédric Le Goater <[email protected]>--- hw/ppc/pnv.c | 51 +++++++++++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 28 deletions(-)hw/ppc/pnv.c +0
-22@@ -265,18 +265,6 @@ static void pnv_dt_icp(PnvChip *chip, void *fdt, uint32_t pir,g_free (reg); } -static int pnv_chip_lpc_offset (PnvChip *chip,void *fdt) -{ -char *name; -int offset; - - name =g_strdup_printf ("/xscom@%" PRIx64"/isa@%x" , - (uint64_t )PNV_XSCOM_BASE (chip),PNV_XSCOM_LPC_BASE ); - offset =fdt_path_offset (fdt, name); -g_free (name); -return offset; -} -static void pnv_dt_chip (PnvChip *chip,void *fdt) {const char *typename =pnv_chip_core_typename (chip);@@ -285,16 +273,6 @@ static void pnv_dt_chip(PnvChip *chip, void *fdt)pnv_dt_xscom (chip, fdt,0 ); -/* The default LPC bus of a multichip system is on chip 0. It's -* recognized by the firmware (skiboot) using a "primary" -* property. -*/ -if (chip->chip_id ==0x0 ) { -int lpc_offset =pnv_chip_lpc_offset (chip, fdt); - -_FDT ((fdt_setprop (fdt, lpc_offset,"primary" ,NULL ,0 ))); - } -for (i =0 ; i < chip->nr_cores; i++) {PnvCore *pnv_core =PNV_CORE (chip->cores + i * typesize);@@ -418,16 +396,35 @@ static int pnv_dt_isa_device(DeviceState *dev, void *opaque)return 0 ; }
Quoted 5 lines
hw/ppc/pnv.c static int pnv_dt_isa_device(DeviceState *dev, void *opaque) · line 399
Quoted 2 lines
hw/ppc/pnv.c +1
-1-static void pnv_dt_isa (ISABus *bus,void *fdt,int lpc_offset) +static int pnv_chip_isa_offset (PnvChip *chip,void *fdt)AFAICT, this only has one caller, so you could probably fold it in there. Not a big deal, though.
yes. Next round I think. With P9, it becomes :
static int pnv_chip_isa_offset(PnvChip *chip, void *fdt)
{
char *name;
int offset;
if (pnv_chip_is_power9(chip)) {
name = g_strdup_printf("/lpcm-opb@%" PRIx64 "/lpc@0",
(uint64_t) PNV9_LPCM_BASE(chip));
} else {
name = g_strdup_printf("/xscom@%" PRIx64 "/isa@%x",
(uint64_t) PNV_XSCOM_BASE(chip),
PNV_XSCOM_LPC_BASE);
}
offset = fdt_path_offset(fdt, name);
g_free(name);
return offset;
}I need to simplify that. Probably with the patch I already sent moving the name under the LPC model.
Thanks,
C.
Quoted 53 lines
Quoted 52 lines
hw/ppc/pnv.c +22
-5+{ +char *name; +int offset; + + name =g_strdup_printf ("/xscom@%" PRIx64"/isa@%x" , + (uint64_t )PNV_XSCOM_BASE (chip),PNV_XSCOM_LPC_BASE ); + offset =fdt_path_offset (fdt, name); +g_free (name); +return offset; +} + +/* The default LPC bus of a multichip system is on chip 0. It's +* recognized by the firmware (skiboot) using a "primary" property. +*/ +static void pnv_dt_isa (PnvMachineState *pnv,void *fdt) { +int isa_offset =pnv_chip_isa_offset (pnv->chips[0 ], fdt);ForeachPopulateArgs args = { .fdt = fdt, - .offset = lpc_offset, + .offset = isa_offset, }; +_FDT ((fdt_setprop (fdt, isa_offset,"primary" ,NULL ,0 ))); +/* ISA devices are not necessarily parented to the ISA bus so we * can not use object_child_foreach() */ -qbus_walk_children (BUS (bus), pnv_dt_isa_device,NULL ,NULL ,NULL , &args); +qbus_walk_children (BUS (pnv->isa_bus), pnv_dt_isa_device,NULL ,NULL ,NULL , + &args); }static void *pnv_dt_create (MachineState *machine)@@ -438,7 +435,6 @@ static void *pnv_dt_create(MachineState *machine)char *buf;int off;int i; -int lpc_offset; fdt =g_malloc0 (FDT_MAX_SIZE );_FDT ((fdt_create_empty_tree (fdt,FDT_MAX_SIZE )));@@ -480,8 +476,7 @@ static void *pnv_dt_create(MachineState *machine) }/* Populate ISA devices on chip 0 */ - lpc_offset =pnv_chip_lpc_offset (pnv->chips[0 ], fdt); -pnv_dt_isa (pnv->isa_bus, fdt, lpc_offset); +pnv_dt_isa (pnv, fdt);if (pnv->bmc) {pnv_dt_bmc_sensors (pnv->bmc, fdt);