From patchwork Wed Sep 11 04:04:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 1160639 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=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="hSPkDmka"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46SpLY0nw4z9sCJ for ; Wed, 11 Sep 2019 14:09:09 +1000 (AEST) Received: from localhost ([::1]:46388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i7twI-00048I-5D for incoming@patchwork.ozlabs.org; Wed, 11 Sep 2019 00:09:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46487) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i7tsU-0000TR-1n for qemu-devel@nongnu.org; Wed, 11 Sep 2019 00:05:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i7tsP-0002pJ-JH for qemu-devel@nongnu.org; Wed, 11 Sep 2019 00:05:08 -0400 Received: from bilbo.ozlabs.org ([2401:3900:2:1::2]:55205 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i7tsM-0002gc-AJ; Wed, 11 Sep 2019 00:05:04 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 46SpFh1r6jz9sNk; Wed, 11 Sep 2019 14:04:56 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1568174696; bh=raU0a+JnIcBoqXKDb0A97AqcM6JTh7CnyZizdQL7HOI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hSPkDmkaJpS5sopLCZALIxirddQxijU+6iAXbPC424i7KX52BR7SKEGqbXWAzgxhB 7ydajdWwBYUsROz78QM1tAKFbnQjo8xnniNmu9fzL5XlJUAfNtfOF6Z+XCFh0AZiDl NUAxEYNIjI694Bb3gQhLZGyhNv8g86o2yjDb6KPU= From: David Gibson To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Date: Wed, 11 Sep 2019 14:04:52 +1000 Message-Id: <20190911040452.8341-8-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190911040452.8341-1-david@gibson.dropbear.id.au> References: <20190911040452.8341-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PATCH 7/7] spapr: Perform machine reset in a more sensible order X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, aik@ozlabs.ru, groug@kaod.org, clg@kaod.org, philmd@redhat.com, David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" We've made several changes in the past to the machine reset order to fix specific problems. However, we've ended up with an order that doesn't make a lot of logical sense. This is an attempt to rectify this. First we reset global CAS options, since that should depend on nothing else. Then we reset the CPUs, which shouldn't depend on external devices. Then the irq subsystem, then the bulk of devices (which might rely on irqs). Finally we set up the entry state ready for boot, which could potentially rely on a bunch of other things. Signed-off-by: David Gibson --- hw/ppc/spapr.c | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 5a919a6cc1..1560a11738 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1724,6 +1724,28 @@ static void spapr_machine_reset(MachineState *machine) void *fdt; int rc; + /* + * If this reset wasn't generated by CAS, we should reset our + * negotiated options and start from scratch + */ + if (!spapr->cas_reboot) { + spapr_ovec_cleanup(spapr->ov5_cas); + spapr->ov5_cas = spapr_ovec_new(); + + ppc_set_compat_all(spapr->max_compat_pvr, &error_fatal); + } + + /* + * There is no CAS under qtest. Simulate one to please the code that + * depends on spapr->ov5_cas. This is especially needed to test device + * unplug, so we do that before resetting the DRCs. + */ + if (qtest_enabled()) { + spapr_ovec_cleanup(spapr->ov5_cas); + spapr->ov5_cas = spapr_ovec_clone(spapr->ov5); + } + + /* Reset the CPUs */ spapr_caps_apply(spapr); first_ppc_cpu = POWERPC_CPU(first_cpu); @@ -1741,34 +1763,15 @@ static void spapr_machine_reset(MachineState *machine) spapr_setup_hpt_and_vrma(spapr); } - qemu_devices_reset(); - - /* - * If this reset wasn't generated by CAS, we should reset our - * negotiated options and start from scratch - */ - if (!spapr->cas_reboot) { - spapr_ovec_cleanup(spapr->ov5_cas); - spapr->ov5_cas = spapr_ovec_new(); - - ppc_set_compat_all(spapr->max_compat_pvr, &error_fatal); - } - + /* Reset IRQ subsystem */ /* * This is fixing some of the default configuration of the XIVE * devices. To be called after the reset of the machine devices. */ spapr_irq_reset(spapr, &error_fatal); - /* - * There is no CAS under qtest. Simulate one to please the code that - * depends on spapr->ov5_cas. This is especially needed to test device - * unplug, so we do that before resetting the DRCs. - */ - if (qtest_enabled()) { - spapr_ovec_cleanup(spapr->ov5_cas); - spapr->ov5_cas = spapr_ovec_clone(spapr->ov5); - } + /* Reset other devices */ + qemu_devices_reset(); /* DRC reset may cause a device to be unplugged. This will cause troubles * if this device is used by another device (eg, a running vhost backend