From patchwork Tue Sep 19 14:56:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 9959373 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5B537601E9 for ; Tue, 19 Sep 2017 15:21:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 597BF2236A for ; Tue, 19 Sep 2017 15:21:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E54F2897E; Tue, 19 Sep 2017 15:21:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EADD32236A for ; Tue, 19 Sep 2017 15:21:12 +0000 (UTC) Received: from localhost ([::1]:43497 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duKKm-0005i3-5F for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Sep 2017 11:21:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duK0D-0004pv-8E for qemu-devel@nongnu.org; Tue, 19 Sep 2017 10:59:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1duK09-00018Q-Ug for qemu-devel@nongnu.org; Tue, 19 Sep 2017 10:59:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58165) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1duK09-000184-NE for qemu-devel@nongnu.org; Tue, 19 Sep 2017 10:59:53 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B0EAC7F7AB; Tue, 19 Sep 2017 14:59:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B0EAC7F7AB Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=cohuck@redhat.com Received: from localhost (unknown [10.36.117.0]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 16FC7171AA; Tue, 19 Sep 2017 14:59:45 +0000 (UTC) From: Cornelia Huck To: peter.maydell@linaro.org Date: Tue, 19 Sep 2017 16:56:27 +0200 Message-Id: <20170919145636.9389-30-cohuck@redhat.com> In-Reply-To: <20170919145636.9389-1-cohuck@redhat.com> References: <20170919145636.9389-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 19 Sep 2017 14:59:52 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 29/38] s390x: get rid of cpu_states and use possible_cpus instead X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, david@redhat.com, Cornelia Huck , agraf@suse.de, qemu-devel@nongnu.org, borntraeger@de.ibm.com, rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: David Hildenbrand Now that we have possible_cpus, we can get rid of the global variable and rewrite s390_cpu_addr2state() to use it. Signed-off-by: David Hildenbrand Message-Id: <20170913132417.24384-20-david@redhat.com> Reviewed-by: Igor Mammedov Signed-off-by: Cornelia Huck --- hw/s390x/s390-virtio-ccw.c | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index cc64a81321..720f145054 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -36,23 +36,26 @@ #include "qapi/qmp/qerror.h" #include "hw/nmi.h" -static S390CPU **cpu_states; - S390CPU *s390_cpu_addr2state(uint16_t cpu_addr) { - if (cpu_addr >= max_cpus) { - return NULL; + static MachineState *ms; + + if (!ms) { + ms = MACHINE(qdev_get_machine()); + g_assert(ms->possible_cpus); } - /* Fast lookup via CPU ID */ - return cpu_states[cpu_addr]; + /* CPU address corresponds to the core_id and the index */ + if (cpu_addr >= ms->possible_cpus->len) { + return NULL; + } + return S390_CPU(ms->possible_cpus->cpus[cpu_addr].cpu); } static void s390_init_cpus(MachineState *machine) { MachineClass *mc = MACHINE_GET_CLASS(machine); int i; - gchar *name; if (machine->cpu_model == NULL) { machine->cpu_model = s390_default_cpu_model_name(); @@ -63,18 +66,6 @@ static void s390_init_cpus(MachineState *machine) exit(1); } - cpu_states = g_new0(S390CPU *, max_cpus); - - for (i = 0; i < max_cpus; i++) { - name = g_strdup_printf("cpu[%i]", i); - object_property_add_link(OBJECT(machine), name, TYPE_S390_CPU, - (Object **) &cpu_states[i], - object_property_allow_set_link, - OBJ_PROP_LINK_UNREF_ON_RELEASE, - &error_abort); - g_free(name); - } - /* initialize possible_cpus */ mc->possible_cpu_arch_ids(machine); @@ -310,15 +301,8 @@ static void ccw_init(MachineState *machine) static void s390_cpu_plug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { - gchar *name; MachineState *ms = MACHINE(hotplug_dev); S390CPU *cpu = S390_CPU(dev); - CPUState *cs = CPU(dev); - - name = g_strdup_printf("cpu[%i]", cpu->env.core_id); - object_property_set_link(OBJECT(hotplug_dev), OBJECT(cs), name, - errp); - g_free(name); g_assert(!ms->possible_cpus->cpus[cpu->env.core_id].cpu); ms->possible_cpus->cpus[cpu->env.core_id].cpu = OBJECT(dev);