Message ID | 20221221182300.307900-4-dbarboza@ventanamicro.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | riscv: opensbi boot test and cleanups | expand |
On 21/12/22 19:22, Daniel Henrique Barboza wrote: > The MachineState object provides a 'fdt' pointer that is already being > used by other RISC-V machines, and it's also used by the 'dumpdtb' QMP > command. > > Remove the 'fdt' pointer from SiFiveUState and use MachineState::fdt > instead. > > Cc: Palmer Dabbelt <palmer@dabbelt.com> > Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> > --- > hw/riscv/sifive_u.c | 15 ++++++--------- > include/hw/riscv/sifive_u.h | 3 --- > 2 files changed, 6 insertions(+), 12 deletions(-) Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
On Thu, Dec 22, 2022 at 4:29 AM Daniel Henrique Barboza <dbarboza@ventanamicro.com> wrote: > > The MachineState object provides a 'fdt' pointer that is already being > used by other RISC-V machines, and it's also used by the 'dumpdtb' QMP > command. > > Remove the 'fdt' pointer from SiFiveUState and use MachineState::fdt > instead. > > Cc: Palmer Dabbelt <palmer@dabbelt.com> > Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Alistair > --- > hw/riscv/sifive_u.c | 15 ++++++--------- > include/hw/riscv/sifive_u.h | 3 --- > 2 files changed, 6 insertions(+), 12 deletions(-) > > diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c > index b40a4767e2..9cf66957ab 100644 > --- a/hw/riscv/sifive_u.c > +++ b/hw/riscv/sifive_u.c > @@ -98,7 +98,7 @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap, > { > MachineState *ms = MACHINE(qdev_get_machine()); > void *fdt; > - int cpu; > + int cpu, fdt_size; > uint32_t *cells; > char *nodename; > uint32_t plic_phandle, prci_phandle, gpio_phandle, phandle = 1; > @@ -112,14 +112,14 @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap, > }; > > if (ms->dtb) { > - fdt = s->fdt = load_device_tree(ms->dtb, &s->fdt_size); > + fdt = ms->fdt = load_device_tree(ms->dtb, &fdt_size); > if (!fdt) { > error_report("load_device_tree() failed"); > exit(1); > } > goto update_bootargs; > } else { > - fdt = s->fdt = create_device_tree(&s->fdt_size); > + fdt = ms->fdt = create_device_tree(&fdt_size); > if (!fdt) { > error_report("create_device_tree() failed"); > exit(1); > @@ -615,9 +615,9 @@ static void sifive_u_machine_init(MachineState *machine) > hwaddr end = riscv_load_initrd(machine->initrd_filename, > machine->ram_size, kernel_entry, > &start); > - qemu_fdt_setprop_cell(s->fdt, "/chosen", > + qemu_fdt_setprop_cell(machine->fdt, "/chosen", > "linux,initrd-start", start); > - qemu_fdt_setprop_cell(s->fdt, "/chosen", "linux,initrd-end", > + qemu_fdt_setprop_cell(machine->fdt, "/chosen", "linux,initrd-end", > end); > } > } else { > @@ -630,14 +630,11 @@ static void sifive_u_machine_init(MachineState *machine) > > /* Compute the fdt load address in dram */ > fdt_load_addr = riscv_load_fdt(memmap[SIFIVE_U_DEV_DRAM].base, > - machine->ram_size, s->fdt); > + machine->ram_size, machine->fdt); > if (!riscv_is_32bit(&s->soc.u_cpus)) { > start_addr_hi32 = (uint64_t)start_addr >> 32; > } > > - /* Set machine->fdt for 'dumpdtb' QMP/HMP command */ > - machine->fdt = s->fdt; > - > /* reset vector */ > uint32_t reset_vec[12] = { > s->msel, /* MSEL pin state */ > diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h > index e680d61ece..4a8828a30e 100644 > --- a/include/hw/riscv/sifive_u.h > +++ b/include/hw/riscv/sifive_u.h > @@ -67,9 +67,6 @@ typedef struct SiFiveUState { > /*< public >*/ > SiFiveUSoCState soc; > > - void *fdt; > - int fdt_size; > - > bool start_in_flash; > uint32_t msel; > uint32_t serial; > -- > 2.38.1 > >
On Thu, Dec 22, 2022 at 2:29 AM Daniel Henrique Barboza <dbarboza@ventanamicro.com> wrote: > > The MachineState object provides a 'fdt' pointer that is already being > used by other RISC-V machines, and it's also used by the 'dumpdtb' QMP > command. > > Remove the 'fdt' pointer from SiFiveUState and use MachineState::fdt > instead. > > Cc: Palmer Dabbelt <palmer@dabbelt.com> > Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> > --- > hw/riscv/sifive_u.c | 15 ++++++--------- > include/hw/riscv/sifive_u.h | 3 --- > 2 files changed, 6 insertions(+), 12 deletions(-) > Reviewed-by: Bin Meng <bmeng@tinylab.org>
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index b40a4767e2..9cf66957ab 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -98,7 +98,7 @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap, { MachineState *ms = MACHINE(qdev_get_machine()); void *fdt; - int cpu; + int cpu, fdt_size; uint32_t *cells; char *nodename; uint32_t plic_phandle, prci_phandle, gpio_phandle, phandle = 1; @@ -112,14 +112,14 @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap, }; if (ms->dtb) { - fdt = s->fdt = load_device_tree(ms->dtb, &s->fdt_size); + fdt = ms->fdt = load_device_tree(ms->dtb, &fdt_size); if (!fdt) { error_report("load_device_tree() failed"); exit(1); } goto update_bootargs; } else { - fdt = s->fdt = create_device_tree(&s->fdt_size); + fdt = ms->fdt = create_device_tree(&fdt_size); if (!fdt) { error_report("create_device_tree() failed"); exit(1); @@ -615,9 +615,9 @@ static void sifive_u_machine_init(MachineState *machine) hwaddr end = riscv_load_initrd(machine->initrd_filename, machine->ram_size, kernel_entry, &start); - qemu_fdt_setprop_cell(s->fdt, "/chosen", + qemu_fdt_setprop_cell(machine->fdt, "/chosen", "linux,initrd-start", start); - qemu_fdt_setprop_cell(s->fdt, "/chosen", "linux,initrd-end", + qemu_fdt_setprop_cell(machine->fdt, "/chosen", "linux,initrd-end", end); } } else { @@ -630,14 +630,11 @@ static void sifive_u_machine_init(MachineState *machine) /* Compute the fdt load address in dram */ fdt_load_addr = riscv_load_fdt(memmap[SIFIVE_U_DEV_DRAM].base, - machine->ram_size, s->fdt); + machine->ram_size, machine->fdt); if (!riscv_is_32bit(&s->soc.u_cpus)) { start_addr_hi32 = (uint64_t)start_addr >> 32; } - /* Set machine->fdt for 'dumpdtb' QMP/HMP command */ - machine->fdt = s->fdt; - /* reset vector */ uint32_t reset_vec[12] = { s->msel, /* MSEL pin state */ diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h index e680d61ece..4a8828a30e 100644 --- a/include/hw/riscv/sifive_u.h +++ b/include/hw/riscv/sifive_u.h @@ -67,9 +67,6 @@ typedef struct SiFiveUState { /*< public >*/ SiFiveUSoCState soc; - void *fdt; - int fdt_size; - bool start_in_flash; uint32_t msel; uint32_t serial;
The MachineState object provides a 'fdt' pointer that is already being used by other RISC-V machines, and it's also used by the 'dumpdtb' QMP command. Remove the 'fdt' pointer from SiFiveUState and use MachineState::fdt instead. Cc: Palmer Dabbelt <palmer@dabbelt.com> Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> --- hw/riscv/sifive_u.c | 15 ++++++--------- include/hw/riscv/sifive_u.h | 3 --- 2 files changed, 6 insertions(+), 12 deletions(-)