target/xtensa: Replace CPUXtensa:runstall by CPUState:start_powered_off
cover target/xtensa: Replace CPUXtensa:runstall by CPUState:start_powered_off
CPUXtensa::runstall and CPUState::start_powered_off are semantically equivalent. Replace the target specific field by the generic one.
Philippe Mathieu-Daudé (2):
hw/core/cpu: Expose CPUState::start_powered_off docstring target/xtensa: Replace CPUXtensa:runstall by
CPUState:start_powered_off
include/hw/core/cpu.h | 2 +- target/xtensa/cpu.h | 1 - target/xtensa/cpu.c | 8 ++++++-- target/xtensa/helper.c | 6 ++++-- 4 files changed, 11 insertions(+), 6 deletions(-)
Signature · 1 line
2.51.0
PATCH 1/2 hw/core/cpu: Expose CPUState::start_powered_off docstring
The comment about @start_powered_off is buried within the CPUState structure. Hoist it to the structure docstring comment.
--- include/hw/core/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/core/cpu.h +1 -1
@@ -412,6 +412,7 @@ struct qemu_work_item;* QOM parent. * Under TCG this value is propagated to @tcg_cflags. * See TranslationBlock::TCG CF_CLUSTER_MASK. +* @start_powered_off: Indicates whether the CPU starts in powered-off state. * @tcg_cflags: Pre-computed cflags for this cpu. * @nr_threads: Number of threads within this CPU core. * @thread: Host thread details, only live once @created is #true
@@ -496,7 +497,6 @@ struct CPUState {bool stop;bool stopped; -/* Should CPU start in powered-off state? */ bool start_powered_off;bool unplug;
Signature · 1 line
2.51.0
Re: [PATCH 1/2] hw/core/cpu: Expose CPUState::start_powered_off docstring
Quoted 8 lines · Philippe Mathieu-Daudé
The comment about @start_powered_off is buried within the CPUState structure. Hoist it to the structure docstring comment.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/hw/core/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
r~
Quoted 21 lines
include/hw/core/cpu.h +1
-1@@ -412,6 +412,7 @@ struct qemu_work_item;* QOM parent. * Under TCG this value is propagated to @tcg_cflags. * See TranslationBlock::TCG CF_CLUSTER_MASK. +* @start_powered_off: Indicates whether the CPU starts in powered-off state. * @tcg_cflags: Pre-computed cflags for this cpu. * @nr_threads: Number of threads within this CPU core. * @thread: Host thread details, only live once @created is #true @@ -496,7 +497,6 @@ struct CPUState {bool stop;bool stopped; -/* Should CPU start in powered-off state? */ bool start_powered_off;bool unplug;
PATCH 2/2 target/xtensa: Replace CPUXtensa:runstall by CPUState:start_powered_off
In reply to Philippe Mathieu-DaudéCPUXtensa::runstall and CPUState::start_powered_off are semantically equivalent. Replace the target specific field by the generic one.
--- target/xtensa/cpu.h | 1 - target/xtensa/cpu.c | 8 ++++++-- target/xtensa/helper.c | 6 ++++-- 3 files changed, 10 insertions(+), 5 deletions(-)
target/xtensa/cpu.h +0 -1
@@ -529,7 +529,6 @@ struct CPUArchState {xtensa_tlb_entry dtlb[10 ][MAX_TLB_WAY_SIZE ];xtensa_mpu_entry mpu_fg[MAX_MPU_FOREGROUND_SEGMENTS ];unsigned autorefill_idx; -bool runstall;AddressSpace *address_space_er;MemoryRegion *system_er;int pending_irq_level;/* level of last raised IRQ */
target/xtensa/cpu.c +6 -2
@@ -143,7 +143,7 @@ static bool xtensa_cpu_has_work(CPUState *cs) {CPUXtensaState *env =cpu_env (cs); -return !env->runstall && env->pending_irq_level; +return !cs->start_powered_off && env->pending_irq_level; }#endif /* !CONFIG_USER_ONLY */
@@ -204,7 +204,11 @@ static void xtensa_cpu_reset_hold(Object *obj, ResetType type)#ifndef CONFIG_USER_ONLY reset_mmu (env); - cs->halted = env->runstall; +if (cs->start_powered_off) { + cs->halted =1 ; + }else { + cs->halted =0 ; + }#endif /* For inf * 0 + NaN, return the input NaN */ set_float_infzeronan_rule (float_infzeronan_dnan_never, &env->fp_status);
target/xtensa/helper.c +4 -2
@@ -311,11 +311,13 @@ void xtensa_runstall(CPUXtensaState *env, bool runstall) {CPUState *cpu =env_cpu (env); - env->runstall = runstall; - cpu->halted = runstall;if (runstall) { + cpu->start_powered_off = true; + cpu->halted =1 ;cpu_interrupt (cpu,CPU_INTERRUPT_HALT ); }else { + cpu->start_powered_off = false; + cpu->halted =0 ;qemu_cpu_kick (cpu); } }
Signature · 1 line
2.51.0
Quoted 37 lines · Philippe Mathieu-Daudé
CPUXtensa::runstallandCPUState::start_powered_offare semantically equivalent. Replace the target specific field by the generic one.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/xtensa/cpu.h | 1 - target/xtensa/cpu.c | 8 ++++++-- target/xtensa/helper.c | 6 ++++-- 3 files changed, 10 insertions(+), 5 deletions(-)target/xtensa/cpu.h +0
-1@@ -529,7 +529,6 @@ struct CPUArchState {xtensa_tlb_entry dtlb[10 ][MAX_TLB_WAY_SIZE ];xtensa_mpu_entry mpu_fg[MAX_MPU_FOREGROUND_SEGMENTS ];unsigned autorefill_idx; -bool runstall;AddressSpace *address_space_er;MemoryRegion *system_er;int pending_irq_level;/* level of last raised IRQ */ target/xtensa/cpu.c +1
-1@@ -143,7 +143,7 @@ static bool xtensa_cpu_has_work(CPUState *cs) {CPUXtensaState *env =cpu_env (cs); -return !env->runstall && env->pending_irq_level; +return !cs->start_powered_off && env->pending_irq_level; }#endif /* !CONFIG_USER_ONLY */
target/xtensa/cpu.c static void xtensa_cpu_reset_hold(Object *obj, ResetType type) · line 211
Quoted 9 lines
target/xtensa/cpu.c +5
-1@@ -204,7 +204,11 @@ static void xtensa_cpu_reset_hold(Object *obj, ResetType type)#ifndef CONFIG_USER_ONLY reset_mmu (env); - cs->halted = env->runstall; +if (cs->start_powered_off) { + cs->halted =1 ; + }else { + cs->halted =0 ; + }
This would of course be
cs->halted = cs->start_powered_off;
though I'm a bit surprised that such generic fields must be handled in target-specific code.
Quoted 13 lines
target/xtensa/cpu.c +0
-0#endif /* For inf * 0 + NaN, return the input NaN */ set_float_infzeronan_rule (float_infzeronan_dnan_never, &env->fp_status);target/xtensa/helper.c +0
-2@@ -311,11 +311,13 @@ void xtensa_runstall(CPUXtensaState *env, bool runstall) {CPUState *cpu =env_cpu (env); - env->runstall = runstall; - cpu->halted = runstall;
target/xtensa/helper.c void xtensa_runstall(CPUXtensaState *env, bool runstall) · line 323
Quoted 10 lines
target/xtensa/helper.c +4
-0if (runstall) { + cpu->start_powered_off = true; + cpu->halted =1 ;cpu_interrupt (cpu,CPU_INTERRUPT_HALT ); }else { + cpu->start_powered_off = false; + cpu->halted =0 ;qemu_cpu_kick (cpu); } }
Why this change?
r~
Quoted 7 lines · Richard Henderson
Quoted 6 lines
-
cs->halted=env->runstall;
+ if (cs->start_powered_off) {
+cs->halted= 1;
+ } else {
+cs->halted= 0;
+ }
Quoted 6 lines
This would of course be
cs->halted=cs->start_powered_off;though I'm a bit surprised that such generic fields must be handled in target-specific code.
Indeed, this is done by cpu_common_reset_hold.
r~
Quoted 3 lines · Philippe Mathieu-Daudé
CPUXtensa::runstallandCPUState::start_powered_offare semantically equivalent. Replace the target specific field by the generic one.
xtensa runstall is not about powering on the CPU, it's about stalling its pipeline. Also it can be applied at any time to a running CPU to hold it, deasserting it will let the CPU continue running.
Signature · 2 lines
Thanks. -- Max