From patchwork Fri Feb 21 03:36:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 11395485 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9CFF8159A for ; Fri, 21 Feb 2020 03:47:16 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 733502071E for ; Fri, 21 Feb 2020 03:47:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="p1NFPDHn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 733502071E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:51860 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4zHX-0002Gy-L4 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 20 Feb 2020 22:47:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49688) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4z87-0002Tj-Qw for qemu-devel@nongnu.org; Thu, 20 Feb 2020 22:37:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j4z86-0000I2-HO for qemu-devel@nongnu.org; Thu, 20 Feb 2020 22:37:31 -0500 Received: from ozlabs.org ([203.11.71.1]:57011) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j4z86-0008N7-2C; Thu, 20 Feb 2020 22:37:30 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 48NxwK247Vz9sSm; Fri, 21 Feb 2020 14:37:04 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1582256225; bh=ZWlfxuDNu4capZMYHkoGfmpDSiGt/RmLDnFclqC5olk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p1NFPDHnN2QOmvecf4CqeVgYsx5OnN8iuHDCL7se/EhbLoPV0S+GWcdMdExBl9KkN CWpSIK+5FWksutB4UzZC5RiSjOFOXBNuyyPGZ7bpUO0oV3TRDXIw4s0zzGtXmrDhUH I+7LIB1ioZmhZplo8OhVwgYbhfPd9dsIfk4jmtTM= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 18/20] spapr: Don't use spapr_drc_needed() in CAS code Date: Fri, 21 Feb 2020 14:36:48 +1100 Message-Id: <20200221033650.444386-19-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200221033650.444386-1-david@gibson.dropbear.id.au> References: <20200221033650.444386-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 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, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Greg Kurz We currently don't support hotplug of devices between boot and CAS. If this happens a CAS reboot is triggered. We detect this during CAS using the spapr_drc_needed() function which is essentially a VMStateDescription .needed callback. Even if the condition for CAS reboot happens to be the same as for DRC migration, it looks wrong to piggyback a migration helper for this. Introduce a helper with slightly more explicit name and use it in both CAS and DRC migration code. Since a subsequent patch will enhance this helper to cover the case of hot unplug, let's go for spapr_drc_transient(). While here convert spapr_hotplugged_dev_before_cas() to the "transient" wording as well. This doesn't change any behaviour. Signed-off-by: Greg Kurz Message-Id: <158169248180.3465937.9531405453362718771.stgit@bahia.lan> Signed-off-by: David Gibson --- hw/ppc/spapr_drc.c | 20 ++++++++++++++------ hw/ppc/spapr_hcall.c | 14 +++++++++----- include/hw/ppc/spapr_drc.h | 4 +++- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index fc62e04901..4c35ce7c5c 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -456,23 +456,31 @@ void spapr_drc_reset(SpaprDrc *drc) } } -bool spapr_drc_needed(void *opaque) +bool spapr_drc_transient(SpaprDrc *drc) { - SpaprDrc *drc = (SpaprDrc *)opaque; SpaprDrcClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); - /* If no dev is plugged in there is no need to migrate the DRC state */ + /* + * If no dev is plugged in there is no need to migrate the DRC state + * nor to reset the DRC at CAS. + */ if (!drc->dev) { return false; } /* - * We need to migrate the state if it's not equal to the expected - * long-term state, which is the same as the coldplugged initial - * state */ + * We need to reset the DRC at CAS or to migrate the DRC state if it's + * not equal to the expected long-term state, which is the same as the + * coldplugged initial state. + */ return (drc->state != drck->ready_state); } +static bool spapr_drc_needed(void *opaque) +{ + return spapr_drc_transient(opaque); +} + static const VMStateDescription vmstate_spapr_drc = { .name = "spapr_drc", .version_id = 1, diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index b8bb66b5c0..6db3dbde9c 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -1640,20 +1640,24 @@ static uint32_t cas_check_pvr(SpaprMachineState *spapr, PowerPCCPU *cpu, return best_compat; } -static bool spapr_hotplugged_dev_before_cas(void) +static bool spapr_transient_dev_before_cas(void) { - Object *drc_container, *obj; + Object *drc_container; ObjectProperty *prop; ObjectPropertyIterator iter; drc_container = container_get(object_get_root(), "/dr-connector"); object_property_iter_init(&iter, drc_container); while ((prop = object_property_iter_next(&iter))) { + SpaprDrc *drc; + if (!strstart(prop->type, "link<", NULL)) { continue; } - obj = object_property_get_link(drc_container, prop->name, NULL); - if (spapr_drc_needed(obj)) { + drc = SPAPR_DR_CONNECTOR(object_property_get_link(drc_container, + prop->name, NULL)); + + if (spapr_drc_transient(drc)) { return true; } } @@ -1830,7 +1834,7 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu, spapr_irq_update_active_intc(spapr); - if (spapr_hotplugged_dev_before_cas()) { + if (spapr_transient_dev_before_cas()) { spapr->cas_reboot = true; } diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h index df3d958a66..21af8deac1 100644 --- a/include/hw/ppc/spapr_drc.h +++ b/include/hw/ppc/spapr_drc.h @@ -278,7 +278,9 @@ int spapr_dt_drc(void *fdt, int offset, Object *owner, uint32_t drc_type_mask); void spapr_drc_attach(SpaprDrc *drc, DeviceState *d, Error **errp); void spapr_drc_detach(SpaprDrc *drc); -bool spapr_drc_needed(void *opaque); + +/* Returns true if a hot plug/unplug request is pending */ +bool spapr_drc_transient(SpaprDrc *drc); static inline bool spapr_drc_unplug_requested(SpaprDrc *drc) {