Message ID | 20200723025657.644724-8-bauerman@linux.ibm.com |
---|---|
State | New |
Headers | show |
Series | Generalize start-powered-off property from ARM | expand |
On Wed, Jul 22, 2020 at 11:56:56PM -0300, Thiago Jung Bauermann wrote: > Instead of setting CPUState::halted to 1 in secondary_cpu_reset(), use the > start-powered-off property which makes cpu_common_reset() initialize it > to 1 in common code. > > This makes secondary_cpu_reset() unnecessary, so remove it. > > Also remove setting of cs->halted from cpu_devinit(), which seems out of > place when compared to similar code in other architectures (e.g., > ppce500_init() in hw/ppc/e500.c). > > Suggested-by: Philippe Mathieu-Daudé <philmd@redhat.com> > Signed-off-by: Thiago Jung Bauermann <bauerman@linux.ibm.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> > --- > hw/sparc/sun4m.c | 17 ++--------------- > 1 file changed, 2 insertions(+), 15 deletions(-) > > NB: I was only able to test that this patch builds. I wasn't able to > run it. > > diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c > index f1d92df781..fd74e516bb 100644 > --- a/hw/sparc/sun4m.c > +++ b/hw/sparc/sun4m.c > @@ -218,15 +218,6 @@ static void dummy_cpu_set_irq(void *opaque, int irq, int level) > { > } > > -static void secondary_cpu_reset(void *opaque) > -{ > - SPARCCPU *cpu = opaque; > - CPUState *cs = CPU(cpu); > - > - cpu_reset(cs); > - cs->halted = 1; > -} > - > static void cpu_halt_signal(void *opaque, int irq, int level) > { > if (level && current_cpu) { > @@ -810,7 +801,6 @@ static const TypeInfo ram_info = { > static void cpu_devinit(const char *cpu_type, unsigned int id, > uint64_t prom_addr, qemu_irq **cpu_irqs) > { > - CPUState *cs; > SPARCCPU *cpu; > CPUSPARCState *env; > > @@ -818,11 +808,8 @@ static void cpu_devinit(const char *cpu_type, unsigned int id, > env = &cpu->env; > > cpu_sparc_set_id(env, id); > - if (id != 0) { > - qemu_register_reset(secondary_cpu_reset, cpu); > - cs = CPU(cpu); > - cs->halted = 1; > - } > + object_property_set_bool(OBJECT(cpu), "start-powered-off", id != 0, > + &error_abort); > *cpu_irqs = qemu_allocate_irqs(cpu_set_irq, cpu, MAX_PILS); > env->prom_addr = prom_addr; > } >
On 7/23/20 4:56 AM, Thiago Jung Bauermann wrote: > Instead of setting CPUState::halted to 1 in secondary_cpu_reset(), use the > start-powered-off property which makes cpu_common_reset() initialize it > to 1 in common code. > > This makes secondary_cpu_reset() unnecessary, so remove it. > > Also remove setting of cs->halted from cpu_devinit(), which seems out of > place when compared to similar code in other architectures (e.g., > ppce500_init() in hw/ppc/e500.c). > > Suggested-by: Philippe Mathieu-Daudé <philmd@redhat.com> > Signed-off-by: Thiago Jung Bauermann <bauerman@linux.ibm.com> > --- > hw/sparc/sun4m.c | 17 ++--------------- > 1 file changed, 2 insertions(+), 15 deletions(-) > > NB: I was only able to test that this patch builds. I wasn't able to > run it. > > diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c > index f1d92df781..fd74e516bb 100644 > --- a/hw/sparc/sun4m.c > +++ b/hw/sparc/sun4m.c > @@ -218,15 +218,6 @@ static void dummy_cpu_set_irq(void *opaque, int irq, int level) > { > } > > -static void secondary_cpu_reset(void *opaque) > -{ > - SPARCCPU *cpu = opaque; > - CPUState *cs = CPU(cpu); > - > - cpu_reset(cs); > - cs->halted = 1; > -} > - > static void cpu_halt_signal(void *opaque, int irq, int level) > { > if (level && current_cpu) { > @@ -810,7 +801,6 @@ static const TypeInfo ram_info = { > static void cpu_devinit(const char *cpu_type, unsigned int id, > uint64_t prom_addr, qemu_irq **cpu_irqs) > { > - CPUState *cs; > SPARCCPU *cpu; > CPUSPARCState *env; > > @@ -818,11 +808,8 @@ static void cpu_devinit(const char *cpu_type, unsigned int id, > env = &cpu->env; > > cpu_sparc_set_id(env, id); > - if (id != 0) { > - qemu_register_reset(secondary_cpu_reset, cpu); > - cs = CPU(cpu); > - cs->halted = 1; > - } > + object_property_set_bool(OBJECT(cpu), "start-powered-off", id != 0, > + &error_abort); > *cpu_irqs = qemu_allocate_irqs(cpu_set_irq, cpu, MAX_PILS); > env->prom_addr = prom_addr; > } > Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c index f1d92df781..fd74e516bb 100644 --- a/hw/sparc/sun4m.c +++ b/hw/sparc/sun4m.c @@ -218,15 +218,6 @@ static void dummy_cpu_set_irq(void *opaque, int irq, int level) { } -static void secondary_cpu_reset(void *opaque) -{ - SPARCCPU *cpu = opaque; - CPUState *cs = CPU(cpu); - - cpu_reset(cs); - cs->halted = 1; -} - static void cpu_halt_signal(void *opaque, int irq, int level) { if (level && current_cpu) { @@ -810,7 +801,6 @@ static const TypeInfo ram_info = { static void cpu_devinit(const char *cpu_type, unsigned int id, uint64_t prom_addr, qemu_irq **cpu_irqs) { - CPUState *cs; SPARCCPU *cpu; CPUSPARCState *env; @@ -818,11 +808,8 @@ static void cpu_devinit(const char *cpu_type, unsigned int id, env = &cpu->env; cpu_sparc_set_id(env, id); - if (id != 0) { - qemu_register_reset(secondary_cpu_reset, cpu); - cs = CPU(cpu); - cs->halted = 1; - } + object_property_set_bool(OBJECT(cpu), "start-powered-off", id != 0, + &error_abort); *cpu_irqs = qemu_allocate_irqs(cpu_set_irq, cpu, MAX_PILS); env->prom_addr = prom_addr; }
Instead of setting CPUState::halted to 1 in secondary_cpu_reset(), use the start-powered-off property which makes cpu_common_reset() initialize it to 1 in common code. This makes secondary_cpu_reset() unnecessary, so remove it. Also remove setting of cs->halted from cpu_devinit(), which seems out of place when compared to similar code in other architectures (e.g., ppce500_init() in hw/ppc/e500.c). Suggested-by: Philippe Mathieu-Daudé <philmd@redhat.com> Signed-off-by: Thiago Jung Bauermann <bauerman@linux.ibm.com> --- hw/sparc/sun4m.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) NB: I was only able to test that this patch builds. I wasn't able to run it.