From patchwork Mon Nov 3 12:45:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 406151 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C06EB140081 for ; Mon, 3 Nov 2014 23:52:50 +1100 (AEDT) Received: from localhost ([::1]:34338 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlH7p-0003Yj-0h for incoming@patchwork.ozlabs.org; Mon, 03 Nov 2014 07:52:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51455) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlH17-0008KP-5V for qemu-devel@nongnu.org; Mon, 03 Nov 2014 07:45:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XlH12-0008UW-9U for qemu-devel@nongnu.org; Mon, 03 Nov 2014 07:45:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53357) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlH12-0008UE-1K for qemu-devel@nongnu.org; Mon, 03 Nov 2014 07:45:48 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sA3Cjh3g030265 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 3 Nov 2014 07:45:43 -0500 Received: from redhat.com (ovpn-116-73.ams2.redhat.com [10.36.116.73]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id sA3Cjfo2028210; Mon, 3 Nov 2014 07:45:42 -0500 Date: Mon, 3 Nov 2014 14:45:40 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1415018633-16041-19-git-send-email-mst@redhat.com> References: <1415018633-16041-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1415018633-16041-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Gu Zheng , Peter Maydell , Anthony Liguori , Igor Mammedov Subject: [Qemu-devel] [PULL 18/29] acpi/cpu-hotplug: introduce helper function to keep bit setting in one place X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Gu Zheng Introduce helper function acpi_set_cpu_present_bit() to simplify acpi_cpu_plug_cb and acpi_cpu_hotplug_init, so that we can keep bit setting in one place. Signed-off-by: Gu Zheng Acked-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Igor Mammedov --- hw/acpi/cpu_hotplug.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/hw/acpi/cpu_hotplug.c b/hw/acpi/cpu_hotplug.c index ae48b63..b8ebfad 100644 --- a/hw/acpi/cpu_hotplug.c +++ b/hw/acpi/cpu_hotplug.c @@ -36,10 +36,9 @@ static const MemoryRegionOps AcpiCpuHotplug_ops = { }, }; -void acpi_cpu_plug_cb(ACPIREGS *ar, qemu_irq irq, - AcpiCpuHotplug *g, DeviceState *dev, Error **errp) +static void acpi_set_cpu_present_bit(AcpiCpuHotplug *g, CPUState *cpu, + Error **errp) { - CPUState *cpu = CPU(dev); CPUClass *k = CPU_GET_CLASS(cpu); int64_t cpu_id; @@ -49,9 +48,18 @@ void acpi_cpu_plug_cb(ACPIREGS *ar, qemu_irq irq, return; } - ar->gpe.sts[0] |= ACPI_CPU_HOTPLUG_STATUS; g->sts[cpu_id / 8] |= (1 << (cpu_id % 8)); +} + +void acpi_cpu_plug_cb(ACPIREGS *ar, qemu_irq irq, + AcpiCpuHotplug *g, DeviceState *dev, Error **errp) +{ + acpi_set_cpu_present_bit(g, CPU(dev), errp); + if (*errp != NULL) { + return; + } + ar->gpe.sts[0] |= ACPI_CPU_HOTPLUG_STATUS; acpi_update_sci(ar, irq); } @@ -61,11 +69,7 @@ void acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner, CPUState *cpu; CPU_FOREACH(cpu) { - CPUClass *cc = CPU_GET_CLASS(cpu); - int64_t id = cc->get_arch_id(cpu); - - g_assert((id / 8) < ACPI_GPE_PROC_LEN); - gpe_cpu->sts[id / 8] |= (1 << (id % 8)); + acpi_set_cpu_present_bit(gpe_cpu, cpu, &error_abort); } memory_region_init_io(&gpe_cpu->io, owner, &AcpiCpuHotplug_ops, gpe_cpu, "acpi-cpu-hotplug", ACPI_GPE_PROC_LEN);