From nobody Thu Nov 13 15:17:52 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1580769590384428.50882447424135; Mon, 3 Feb 2020 14:39:50 -0800 (PST) Received: from localhost ([::1]:48006 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iykNh-0004hn-BB for importer@patchew.org; Mon, 03 Feb 2020 17:39:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36676) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iykMf-0003t6-4b for qemu-devel@nongnu.org; Mon, 03 Feb 2020 17:38:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iykMc-0007hI-Qh for qemu-devel@nongnu.org; Mon, 03 Feb 2020 17:38:44 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:26572 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iykMc-0007br-Ju for qemu-devel@nongnu.org; Mon, 03 Feb 2020 17:38:42 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 013MccUS003249 for ; Mon, 3 Feb 2020 17:38:41 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 2xxfrvanvd-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 03 Feb 2020 17:38:40 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 3 Feb 2020 22:36:14 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 3 Feb 2020 22:36:12 -0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 013MaB6D37421288 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 3 Feb 2020 22:36:11 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3D8A44205C; Mon, 3 Feb 2020 22:36:11 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 01EA442068; Mon, 3 Feb 2020 22:36:11 +0000 (GMT) Received: from bahia.lan (unknown [9.145.55.193]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 3 Feb 2020 22:36:10 +0000 (GMT) Subject: [PATCH 1/3] spapr: Don't use spapr_drc_needed() in CAS code From: Greg Kurz To: David Gibson Date: Mon, 03 Feb 2020 23:36:10 +0100 In-Reply-To: <158076936422.2118610.5626450767672103134.stgit@bahia.lan> References: <158076936422.2118610.5626450767672103134.stgit@bahia.lan> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 20020322-0008-0000-0000-0000034F696A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20020322-0009-0000-0000-00004A6FF450 Message-Id: <158076937025.2118610.529669524688469462.stgit@bahia.lan> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.572 definitions=2020-02-03_08:2020-02-02, 2020-02-03 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 spamscore=0 bulkscore=0 suspectscore=0 clxscore=1034 priorityscore=1501 lowpriorityscore=0 impostorscore=0 malwarescore=0 phishscore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1911200001 definitions=main-2002030163 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.158.5 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: Laurent Vivier , Alexey Kardashevskiy , qemu-ppc@nongnu.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" 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 use a migration related helper for this. Introduce a helper with more explicit semantics (ie. the device attached to this DRC is ready or not) and use it in both CAS and DRC migration code. This doesn't change any behaviour. Signed-off-by: Greg Kurz --- hw/ppc/spapr_drc.c | 5 ++--- hw/ppc/spapr_hcall.c | 12 +++++++++--- include/hw/ppc/spapr_drc.h | 8 +++++++- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index 17aeac38016d..d512ac6e1e7f 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -455,10 +455,9 @@ void spapr_drc_reset(SpaprDrc *drc) } } =20 -bool spapr_drc_needed(void *opaque) +static bool spapr_drc_needed(void *opaque) { SpaprDrc *drc =3D (SpaprDrc *)opaque; - SpaprDrcClass *drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); =20 /* If no dev is plugged in there is no need to migrate the DRC state */ if (!drc->dev) { @@ -469,7 +468,7 @@ bool spapr_drc_needed(void *opaque) * 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 */ - return (drc->state !=3D drck->ready_state); + return !spapr_drc_device_ready(drc); } =20 static const VMStateDescription vmstate_spapr_drc =3D { diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index b8bb66b5c0d4..7a33d79bbae9 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -1642,18 +1642,24 @@ static uint32_t cas_check_pvr(SpaprMachineState *sp= apr, PowerPCCPU *cpu, =20 static bool spapr_hotplugged_dev_before_cas(void) { - Object *drc_container, *obj; + Object *drc_container; ObjectProperty *prop; ObjectPropertyIterator iter; =20 drc_container =3D container_get(object_get_root(), "/dr-connector"); object_property_iter_init(&iter, drc_container); while ((prop =3D object_property_iter_next(&iter))) { + SpaprDrc *drc; + if (!strstart(prop->type, "link<", NULL)) { continue; } - obj =3D object_property_get_link(drc_container, prop->name, NULL); - if (spapr_drc_needed(obj)) { + drc =3D SPAPR_DR_CONNECTOR(object_property_get_link(drc_container, + prop->name, NULL= )); + if (!drc->dev) { + continue; + } + if (!spapr_drc_device_ready(drc)) { return true; } } diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h index 83f03cc5773c..8e8bbedb21b7 100644 --- a/include/hw/ppc/spapr_drc.h +++ b/include/hw/ppc/spapr_drc.h @@ -269,7 +269,13 @@ int spapr_dt_drc(void *fdt, int offset, Object *owner,= uint32_t drc_type_mask); =20 void spapr_drc_attach(SpaprDrc *drc, DeviceState *d, Error **errp); void spapr_drc_detach(SpaprDrc *drc); -bool spapr_drc_needed(void *opaque); + +static inline bool spapr_drc_device_ready(SpaprDrc *drc) +{ + SpaprDrcClass *drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); + + return drc->state =3D=3D drck->ready_state; +} =20 static inline bool spapr_drc_unplug_requested(SpaprDrc *drc) {