From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony PERARD Subject: [PATCH 3/4] Update vcpu hotplug logic Date: Fri, 31 May 2013 17:33:12 +0100 Message-ID: <1370017993-13437-4-git-send-email-anthony.perard@citrix.com> References: <1370017993-13437-1-git-send-email-anthony.perard@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1370017993-13437-1-git-send-email-anthony.perard@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen Devel Cc: "Liu, Jinsong" , Ian Jackson , Stefano Stabellini , Anthony PERARD List-Id: xen-devel@lists.xenproject.org From: Ian Jackson Add vcpu online/offline check to avoid redundant SCI interrupt. Signed-off-by: Liu, Jinsong Port from qemu-xen-traditionnal to qemu-xen. Signed-off-by: Anthony PERARD --- hw/acpi_piix4.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c index bc7b454..49c38d3 100644 --- a/hw/acpi_piix4.c +++ b/hw/acpi_piix4.c @@ -706,16 +706,24 @@ static int piix4_device_hotplug(DeviceState *qdev, PCIDevice *dev, return 0; } -static void enable_processor(PIIX4PMState *g, int cpu) +static int enable_processor(PIIX4PMState *g, int cpu) { + if (g->cpus_sts[cpu/8] & (1 << (cpu%8))) + return 0; + g->ar.gpe.sts[0] |= 4; g->cpus_sts[cpu/8] |= (1 << (cpu%8)); + return 1; } -static void disable_processor(PIIX4PMState *g, int cpu) +static int disable_processor(PIIX4PMState *g, int cpu) { + if (!(g->cpus_sts[cpu/8] & (1 << (cpu%8)))) + return 0; + g->ar.gpe.sts[0] |= 4; g->cpus_sts[cpu/8] &= ~(1 << (cpu%8)); + return 1; } void qemu_cpu_add_remove(int cpu, int state) @@ -725,10 +733,15 @@ void qemu_cpu_add_remove(int cpu, int state) return; } - if (state) - enable_processor(acpi_state, cpu); - else - disable_processor(acpi_state, cpu); + if (state) { + if (!enable_processor(acpi_state, cpu)) { + return; + } + } else { + if (!disable_processor(acpi_state, cpu)) { + return; + } + } pm_update_sci(acpi_state); } -- Anthony PERARD