diff mbox

[2/7] target-arm: add powered off cpu state

Message ID 1399305623-22016-3-git-send-email-robherring2@gmail.com
State New
Headers show

Commit Message

Rob Herring May 5, 2014, 4 p.m. UTC
From: Rob Herring <rob.herring@linaro.org>

Add tracking of cpu power state in order to support powering off of
cores in system emuluation. The initial state is determined by the
start-powered-off QOM property.

Signed-off-by: Rob Herring <rob.herring@linaro.org>
---
 target-arm/cpu-qom.h | 1 +
 target-arm/cpu.c     | 7 ++++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

Comments

Peter Maydell May 5, 2014, 4:27 p.m. UTC | #1
On 5 May 2014 17:00, Rob Herring <robherring2@gmail.com> wrote:
> From: Rob Herring <rob.herring@linaro.org>
>
> Add tracking of cpu power state in order to support powering off of
> cores in system emuluation. The initial state is determined by the
> start-powered-off QOM property.
>
> Signed-off-by: Rob Herring <rob.herring@linaro.org>
> ---
>  target-arm/cpu-qom.h | 1 +
>  target-arm/cpu.c     | 7 ++++++-
>  2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/target-arm/cpu-qom.h b/target-arm/cpu-qom.h
> index edc7f26..8ccb227 100644
> --- a/target-arm/cpu-qom.h
> +++ b/target-arm/cpu-qom.h
> @@ -96,6 +96,7 @@ typedef struct ARMCPU {
>
>      /* Should CPU start in PSCI powered-off state? */
>      bool start_powered_off;

This could use a comment:
      /* CPU currently in PSCI powered-off state */

Also this is variable CPU state, so it will need to
be migrated, which means you need to add a
VMSTATE_BOOL(powered_off, ARMCPU),
to vmstate_arm_cpu in machine.c and bump the
version numbers.

> +    bool powered_off;
>
>      /* [QEMU_]KVM_ARM_TARGET_* constant for this CPU, or
>       * QEMU_KVM_ARM_TARGET_NONE if the kernel doesn't support this CPU type.
> diff --git a/target-arm/cpu.c b/target-arm/cpu.c
> index c0ddc3e..03c025b 100644
> --- a/target-arm/cpu.c
> +++ b/target-arm/cpu.c
> @@ -39,7 +39,9 @@ static void arm_cpu_set_pc(CPUState *cs, vaddr value)
>
>  static bool arm_cpu_has_work(CPUState *cs)
>  {
> -    return cs->interrupt_request &
> +    ARMCPU *cpu = ARM_CPU(cs);
> +
> +    return !cpu->powered_off && cs->interrupt_request &
>          (CPU_INTERRUPT_FIQ | CPU_INTERRUPT_HARD | CPU_INTERRUPT_EXITTB);
>  }
>
> @@ -90,6 +92,9 @@ static void arm_cpu_reset(CPUState *s)
>      env->vfp.xregs[ARM_VFP_MVFR1] = cpu->mvfr1;
>      env->vfp.xregs[ARM_VFP_MVFR2] = cpu->mvfr2;
>
> +    cpu->powered_off = cpu->start_powered_off;
> +    s->halted = cpu->start_powered_off;
> +
>      if (arm_feature(env, ARM_FEATURE_IWMMXT)) {
>          env->iwmmxt.cregs[ARM_IWMMXT_wCID] = 0x69051000 | 'Q';
>      }
> --
> 1.9.1

The rest of this looks correct.

thanks
-- PMM
Peter Crosthwaite May 15, 2014, 1:12 p.m. UTC | #2
On Mon, May 5, 2014 at 4:00 PM, Rob Herring <robherring2@gmail.com> wrote:
> From: Rob Herring <rob.herring@linaro.org>
>
> Add tracking of cpu power state in order to support powering off of
> cores in system emuluation. The initial state is determined by the

"emulation"

Regards,
Peter
diff mbox

Patch

diff --git a/target-arm/cpu-qom.h b/target-arm/cpu-qom.h
index edc7f26..8ccb227 100644
--- a/target-arm/cpu-qom.h
+++ b/target-arm/cpu-qom.h
@@ -96,6 +96,7 @@  typedef struct ARMCPU {
 
     /* Should CPU start in PSCI powered-off state? */
     bool start_powered_off;
+    bool powered_off;
 
     /* [QEMU_]KVM_ARM_TARGET_* constant for this CPU, or
      * QEMU_KVM_ARM_TARGET_NONE if the kernel doesn't support this CPU type.
diff --git a/target-arm/cpu.c b/target-arm/cpu.c
index c0ddc3e..03c025b 100644
--- a/target-arm/cpu.c
+++ b/target-arm/cpu.c
@@ -39,7 +39,9 @@  static void arm_cpu_set_pc(CPUState *cs, vaddr value)
 
 static bool arm_cpu_has_work(CPUState *cs)
 {
-    return cs->interrupt_request &
+    ARMCPU *cpu = ARM_CPU(cs);
+
+    return !cpu->powered_off && cs->interrupt_request &
         (CPU_INTERRUPT_FIQ | CPU_INTERRUPT_HARD | CPU_INTERRUPT_EXITTB);
 }
 
@@ -90,6 +92,9 @@  static void arm_cpu_reset(CPUState *s)
     env->vfp.xregs[ARM_VFP_MVFR1] = cpu->mvfr1;
     env->vfp.xregs[ARM_VFP_MVFR2] = cpu->mvfr2;
 
+    cpu->powered_off = cpu->start_powered_off;
+    s->halted = cpu->start_powered_off;
+
     if (arm_feature(env, ARM_FEATURE_IWMMXT)) {
         env->iwmmxt.cregs[ARM_IWMMXT_wCID] = 0x69051000 | 'Q';
     }