From patchwork Mon Sep 11 21:10:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 812618 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 3xrgbl2PD9z9s8J for ; Tue, 12 Sep 2017 07:12:03 +1000 (AEST) Received: from localhost ([::1]:60594 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drVzt-0007o8-Dt for incoming@patchwork.ozlabs.org; Mon, 11 Sep 2017 17:12:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36809) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drVz0-0007SL-NC for qemu-devel@nongnu.org; Mon, 11 Sep 2017 17:11:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1drVyw-00014t-Ky for qemu-devel@nongnu.org; Mon, 11 Sep 2017 17:11:06 -0400 Received: from 16.mo1.mail-out.ovh.net ([178.33.104.224]:34636) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1drVyw-000145-Dc for qemu-devel@nongnu.org; Mon, 11 Sep 2017 17:11:02 -0400 Received: from player169.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo1.mail-out.ovh.net (Postfix) with ESMTP id 090A7931F4 for ; Mon, 11 Sep 2017 23:11:01 +0200 (CEST) Received: from bahia.lan (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player169.ha.ovh.net (Postfix) with ESMTPA id B91C2580075; Mon, 11 Sep 2017 23:10:57 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Mon, 11 Sep 2017 23:10:57 +0200 Message-ID: <150516425752.1593.1536226898929735667.stgit@bahia.lan> User-Agent: StGit/0.17.1-46-g6855-dirty MIME-Version: 1.0 X-Ovh-Tracer-Id: 18150632398564792805 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelledrgedtgdduieegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.33.104.224 Subject: [Qemu-devel] [PATCH v2] spapr_cpu_core: cleaning up qdev_get_machine() calls 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: Daniel Henrique Barboza , qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This patch removes the qdev_get_machine() calls that are made in spapr_cpu_core.c in situations where we can get an existing pointer for the MachineState by either passing it as an argument to the function or by using other already available pointers. Credits to Daniel Henrique Barboza for the idea and the changelog text. Signed-off-by: Greg Kurz --- v2: - fixed typo in spapr_cpu_reset() --- hw/ppc/spapr_cpu_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index dc9df0d393d1..0f32532abe99 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -73,8 +73,8 @@ void spapr_cpu_parse_features(sPAPRMachineState *spapr) static void spapr_cpu_reset(void *opaque) { - sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine()); PowerPCCPU *cpu = opaque; + sPAPRMachineState *spapr = SPAPR_MACHINE(cpu->vhyp); CPUState *cs = CPU(cpu); CPUPPCState *env = &cpu->env; @@ -162,10 +162,10 @@ static void spapr_cpu_core_unrealizefn(DeviceState *dev, Error **errp) g_free(sc->threads); } -static void spapr_cpu_core_realize_child(Object *child, Error **errp) +static void spapr_cpu_core_realize_child(Object *child, + sPAPRMachineState *spapr, Error **errp) { Error *local_err = NULL; - sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine()); CPUState *cs = CPU(child); PowerPCCPU *cpu = POWERPC_CPU(cs); Object *obj; @@ -254,7 +254,7 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) for (j = 0; j < cc->nr_threads; j++) { obj = sc->threads + j * size; - spapr_cpu_core_realize_child(obj, &local_err); + spapr_cpu_core_realize_child(obj, spapr, &local_err); if (local_err) { goto err; }