On 19/8/26 16:56, Philippe Mathieu-Daudé wrote:
Every target setting the cpu_exec_halt callback alias it to
their cpu_has_work() function, making the callback redundant.
Call cpu_has_work() directly in accel/tcg/cpu-exec.c
cpu_has_work_after_processing_async_events() and remove the
boilerplate cpu_exec_halt hook registration. No functional
impact expected.
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
---
include/accel/tcg/cpu-ops.h | 17 -----------------
accel/tcg/cpu-exec.c | 23 ++++++++---------------
target/alpha/cpu.c | 1 -
target/avr/cpu.c | 1 -
target/hexagon/cpu.c | 1 -
target/hppa/cpu.c | 1 -
target/loongarch/tcg/tcg_cpu.c | 1 -
target/m68k/cpu.c | 1 -
target/microblaze/cpu.c | 1 -
target/mips/cpu.c | 1 -
target/or1k/cpu.c | 1 -
target/ppc/cpu_init.c | 1 -
target/riscv/tcg/tcg-cpu.c | 1 -
target/rx/cpu.c | 1 -
target/s390x/cpu.c | 1 -
target/sh4/cpu.c | 1 -
target/sparc/cpu.c | 1 -
target/tricore/cpu.c | 1 -
target/xtensa/cpu.c | 1 -
19 files changed, 8 insertions(+), 49 deletions(-)
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 54561ed31c1..bfdc42ab6a0 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -48,7 +48,6 @@
#include "internal-common.h"
#if !defined(CONFIG_USER_ONLY)
#include "accel/tcg/iommu.h"
-#include "hw/core/sysemu-cpu-ops.h"
#endif
/* -icount align implementation. */
@@ -659,21 +658,16 @@ static bool
cpu_has_work_after_processing_async_events(CPUState *cpu)
{
const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops;
+ if (tcg_ops->process_async_events) {
+ tcg_ops->process_async_events(cpu);
+ }
+
+ if (!cpu_has_work(cpu)) {
+ return false;
+ }
+
if (tcg_ops->transition_halt_to_exec) {
- assert(!tcg_ops->cpu_exec_halt);
- if (tcg_ops->process_async_events) {
- tcg_ops->process_async_events(cpu);
- }
- if (!cpu_has_work(cpu)) {
- return false;
- }
tcg_ops->transition_halt_to_exec(cpu);
- } else {
- assert(!tcg_ops->process_async_events);
- assert(cpu->cc->sysemu_ops->has_work == tcg_ops->cpu_exec_halt);
- if (!tcg_ops->cpu_exec_halt(cpu)) {
- return false;
- }
}
Hmm maybe I should squash:
-- >8 --
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index 22fae41125f..9761bb173c1 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -874,8 +874,6 @@ static void arm_cpu_transition_halt_to_exec(CPUState
*cs)
{
ARMCPU *cpu = ARM_CPU(cs);
- assert(cpu_has_work(cs));
-
/* We're about to come out of WFI/WFE: disable the WFxT timer */
if (cpu->wfxt_timer) {
timer_del(cpu->wfxt_timer);
diff --git a/target/i386/tcg/system/seg_helper.c
b/target/i386/tcg/system/seg_helper.c
index 7a3f14a255e..cbea6bebeb5 100644
--- a/target/i386/tcg/system/seg_helper.c
+++ b/target/i386/tcg/system/seg_helper.c
@@ -145,8 +145,6 @@ void x86_cpu_transition_halt_to_exec(CPUState *cpu)
X86CPU *x86_cpu = X86_CPU(cpu);
CPUX86State *env = cpu_env(cpu);
- assert(cpu_has_work(cpu));
-
/* Complete HLT instruction. */
if (env->eflags & TF_MASK) {
env->dr[6] |= DR6_BS;
---