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 <clg@kaod.org>
---
hw/ppc/pnv.c | 51 +++++++++++++++++++++++----------------------------
1 file changed, 23 insertions(+), 28 deletions(-)
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index a29ea996b45d..7401ffe5b01c 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -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);
--
2.13.6
On Mon, Jun 18, 2018 at 07:05:40PM +0200, Cédric Le Goater wrote:
> 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 <clg@kaod.org>
> ---
> hw/ppc/pnv.c | 51 +++++++++++++++++++++++----------------------------
> 1 file changed, 23 insertions(+), 28 deletions(-)
>
> diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
> index a29ea996b45d..7401ffe5b01c 100644
> --- a/hw/ppc/pnv.c
> +++ b/hw/ppc/pnv.c
> @@ -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)
AFAICT, this only has one caller, so you could probably fold it in
there. Not a big deal, though.
> +{
> + 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);
--
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
On 06/19/2018 02:28 AM, David Gibson wrote:
> On Mon, Jun 18, 2018 at 07:05:40PM +0200, Cédric Le Goater wrote:
>> 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 <clg@kaod.org>
>> ---
>> hw/ppc/pnv.c | 51 +++++++++++++++++++++++----------------------------
>> 1 file changed, 23 insertions(+), 28 deletions(-)
>>
>> diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
>> index a29ea996b45d..7401ffe5b01c 100644
>> --- a/hw/ppc/pnv.c
>> +++ b/hw/ppc/pnv.c
>> @@ -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)
>
> 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.
>
>> +{
>> + 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);
>
© 2016 - 2026 Red Hat, Inc.