Patchwork x86: Clean up CPU reset

login
register
mail settings
Submitter Jan Kiszka
Date June 23, 2010, 6:20 a.m.
Message ID <4C21A7C6.1090504@web.de>
Download mbox | patch
Permalink /patch/56591/
State New
Headers show

Comments

Jan Kiszka - June 23, 2010, 6:20 a.m.
From: Jan Kiszka <jan.kiszka@siemens.com>

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 hw/pc.c |   22 ++++------------------
 1 files changed, 4 insertions(+), 18 deletions(-)
Blue Swirl - June 27, 2010, 8:23 p.m.
Thanks, applied.

On Wed, Jun 23, 2010 at 6:20 AM, Jan Kiszka <jan.kiszka@web.de> wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>  hw/pc.c |   22 ++++------------------
>  1 files changed, 4 insertions(+), 18 deletions(-)
>
> diff --git a/hw/pc.c b/hw/pc.c
> index 1848151..8b9e70a 100644
> --- a/hw/pc.c
> +++ b/hw/pc.c
> @@ -812,20 +812,12 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int level)
>     }
>  }
>
> -static void bsp_cpu_reset(void *opaque)
> +static void pc_cpu_reset(void *opaque)
>  {
>     CPUState *env = opaque;
>
>     cpu_reset(env);
> -    env->halted = 0;
> -}
> -
> -static void ap_cpu_reset(void *opaque)
> -{
> -    CPUState *env = opaque;
> -
> -    cpu_reset(env);
> -    env->halted = 1;
> +    env->halted = !cpu_is_bsp(env);
>  }
>
>  static CPUState *pc_new_cpu(const char *cpu_model)
> @@ -839,16 +831,10 @@ static CPUState *pc_new_cpu(const char *cpu_model)
>     }
>     if ((env->cpuid_features & CPUID_APIC) || smp_cpus > 1) {
>         env->cpuid_apic_id = env->cpu_index;
> -        /* APIC reset callback resets cpu */
>         env->apic_state = apic_init(env, env->cpuid_apic_id);
>     }
> -    if (cpu_is_bsp(env)) {
> -        qemu_register_reset(bsp_cpu_reset, env);
> -        env->halted = 0;
> -    } else {
> -        qemu_register_reset(ap_cpu_reset, env);
> -        env->halted = 1;
> -    }
> +    qemu_register_reset(pc_cpu_reset, env);
> +    pc_cpu_reset(env);
>     return env;
>  }
>
> --
> 1.6.0.2
>

Patch

diff --git a/hw/pc.c b/hw/pc.c
index 1848151..8b9e70a 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -812,20 +812,12 @@  void pc_acpi_smi_interrupt(void *opaque, int irq, int level)
     }
 }
 
-static void bsp_cpu_reset(void *opaque)
+static void pc_cpu_reset(void *opaque)
 {
     CPUState *env = opaque;
 
     cpu_reset(env);
-    env->halted = 0;
-}
-
-static void ap_cpu_reset(void *opaque)
-{
-    CPUState *env = opaque;
-
-    cpu_reset(env);
-    env->halted = 1;
+    env->halted = !cpu_is_bsp(env);
 }
 
 static CPUState *pc_new_cpu(const char *cpu_model)
@@ -839,16 +831,10 @@  static CPUState *pc_new_cpu(const char *cpu_model)
     }
     if ((env->cpuid_features & CPUID_APIC) || smp_cpus > 1) {
         env->cpuid_apic_id = env->cpu_index;
-        /* APIC reset callback resets cpu */
         env->apic_state = apic_init(env, env->cpuid_apic_id);
     }
-    if (cpu_is_bsp(env)) {
-        qemu_register_reset(bsp_cpu_reset, env);
-        env->halted = 0;
-    } else {
-        qemu_register_reset(ap_cpu_reset, env);
-        env->halted = 1;
-    }
+    qemu_register_reset(pc_cpu_reset, env);
+    pc_cpu_reset(env);
     return env;
 }