[PATCH v2 44/58] accel/hvf: Have WFI returns if !cpu_has_work

Philippe Mathieu-Daudé posted 58 patches 3 weeks, 1 day ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Cameron Esfahani <dirty@apple.com>, Roman Bolshakov <rbolshakov@ddn.com>, Phil Dennis-Jordan <phil@philjordan.eu>, Mads Ynddal <mads@ynddal.dk>, Peter Maydell <peter.maydell@linaro.org>, Alexander Graf <agraf@csgraf.de>, Stefan Hajnoczi <stefanha@redhat.com>
There is a newer version of this series
[PATCH v2 44/58] accel/hvf: Have WFI returns if !cpu_has_work
Posted by Philippe Mathieu-Daudé 3 weeks, 1 day ago
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/arm/hvf/hvf.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index cf4746c344a..8c2eac6738f 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -1749,6 +1749,13 @@ static void hvf_wfi(CPUState *cpu)
     uint64_t nanos;
     uint32_t cntfrq;
 
+    if (cpu_has_work(cpu)) {
+        /* Don't bother to go into our "low power state" if
+         * we would just wake up immediately.
+         */
+        return;
+    }
+
     if (cpu_test_interrupt(cpu, CPU_INTERRUPT_HARD | CPU_INTERRUPT_FIQ)) {
         /* Interrupt pending, no need to wait */
         return;
-- 
2.51.0


Re: [PATCH v2 44/58] accel/hvf: Have WFI returns if !cpu_has_work
Posted by Richard Henderson 2 weeks, 5 days ago
On 10/23/25 15:06, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/arm/hvf/hvf.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
> index cf4746c344a..8c2eac6738f 100644
> --- a/target/arm/hvf/hvf.c
> +++ b/target/arm/hvf/hvf.c
> @@ -1749,6 +1749,13 @@ static void hvf_wfi(CPUState *cpu)
>       uint64_t nanos;
>       uint32_t cntfrq;
>   
> +    if (cpu_has_work(cpu)) {
> +        /* Don't bother to go into our "low power state" if
> +         * we would just wake up immediately.
> +         */
> +        return;
> +    }
> +
>       if (cpu_test_interrupt(cpu, CPU_INTERRUPT_HARD | CPU_INTERRUPT_FIQ)) {
>           /* Interrupt pending, no need to wait */
>           return;

cpu_has_work is a superset of the interrupt test.
The interrupt test should be removed.

r~