From nobody Tue Feb 10 04:17:18 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1503376143687104.36504039670592; Mon, 21 Aug 2017 21:29:03 -0700 (PDT) Received: from localhost ([::1]:35618 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dk0oI-0004rF-IR for importer@patchew.org; Tue, 22 Aug 2017 00:29:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54645) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dk0jr-0000rw-0K for qemu-devel@nongnu.org; Tue, 22 Aug 2017 00:24:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dk0jp-00083P-NO for qemu-devel@nongnu.org; Tue, 22 Aug 2017 00:24:27 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:48145) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dk0jp-00080X-9u; Tue, 22 Aug 2017 00:24:25 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3xbyBD4kSXz9t34; Tue, 22 Aug 2017 14:24:20 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1503375860; bh=yF564823BRjrqZoLWBAbakiz3uJApCpgwg0cQWUl7NU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fqyM2d8RrVb7MU0CR6VSi+oUOC+TeoE2itc9lnD2tirgszTuzTcphNzb0J4riNetM 84Or2uFJSWGcwh073gDDdC+L38mXI+M5xn+mzPssLYqlEp4cP37/wF7tgPwuG6ZzPO n5n0uUHXcVQkcA/7Yo0wftBRIkJkrASrKcTN0lkM= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 22 Aug 2017 14:24:13 +1000 Message-Id: <20170822042416.26758-5-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170822042416.26758-1-david@gibson.dropbear.id.au> References: <20170822042416.26758-1-david@gibson.dropbear.id.au> 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] [PULL 4/7] spapr: Allow configure-connector to be called multiple times 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: lvivier@redhat.com, thuth@redhat.com, mdroth@linux.vnet.ibm.com, cohuck@redhat.com, qemu-devel@nongnu.org, agraf@suse.de, qemu-ppc@nongnu.org, Bharata B Rao , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Bharata B Rao In case of in-kernel memory hot unplug, when the guest is not able to remove all the LMBs that are requested for removal, it will add back any LMBs that have been successfully removed. The DR Connectors of these LMBs wouldn't have been unconfigured and hence the addition of these LMBs will result in configure-connector call being issued on LMB DR connectors that are already in configured state. Such configure-connector calls will fail resulting in a DIMM which is partially unplugged. This however worked till recently before we overhauled the DRC implementation in QEMU. Commit 9d4c0f4f0a71e: "spapr: Consolidate DRC state variables" is the first commit where this problem shows up as per git bisect. Ideally guest shouldn't be issuing configure-connector call on an already configured DR connector. However for now, work around this in QEMU by allowing configure-connector to be called multiple times for all types of DR connectors. Signed-off-by: Bharata B Rao [dwg: Corrected buglet that would have initialized fdt pointers ready for reading on a device not present at reset] Signed-off-by: David Gibson --- hw/ppc/spapr_drc.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index 5260b5d363..605697d8bd 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -442,12 +442,17 @@ void spapr_drc_reset(sPAPRDRConnector *drc) if (drc->dev) { /* A device present at reset is ready to go, same as coldplugged */ drc->state =3D drck->ready_state; + /* + * Ensure that we are able to send the FDT fragment again + * via configure-connector call if the guest requests. + */ + drc->ccs_offset =3D drc->fdt_start_offset; + drc->ccs_depth =3D 0; } else { drc->state =3D drck->empty_state; + drc->ccs_offset =3D -1; + drc->ccs_depth =3D -1; } - - drc->ccs_offset =3D -1; - drc->ccs_depth =3D -1; } =20 static void drc_reset(void *opaque) @@ -1071,8 +1076,14 @@ static void rtas_ibm_configure_connector(PowerPCCPU = *cpu, } =20 if ((drc->state !=3D SPAPR_DRC_STATE_LOGICAL_UNISOLATE) - && (drc->state !=3D SPAPR_DRC_STATE_PHYSICAL_UNISOLATE)) { - /* Need to unisolate the device before configuring */ + && (drc->state !=3D SPAPR_DRC_STATE_PHYSICAL_UNISOLATE) + && (drc->state !=3D SPAPR_DRC_STATE_LOGICAL_CONFIGURED) + && (drc->state !=3D SPAPR_DRC_STATE_PHYSICAL_CONFIGURED)) { + /* + * Need to unisolate the device before configuring + * or it should already be in configured state to + * allow configure-connector be called repeatedly. + */ rc =3D SPAPR_DR_CC_RESPONSE_NOT_CONFIGURABLE; goto out; } @@ -1108,8 +1119,13 @@ static void rtas_ibm_configure_connector(PowerPCCPU = *cpu, /* done sending the device tree, move to configured state = */ trace_spapr_drc_set_configured(drc_index); drc->state =3D drck->ready_state; - drc->ccs_offset =3D -1; - drc->ccs_depth =3D -1; + /* + * Ensure that we are able to send the FDT fragment + * again via configure-connector call if the guest request= s. + */ + drc->ccs_offset =3D drc->fdt_start_offset; + drc->ccs_depth =3D 0; + fdt_offset_next =3D drc->fdt_start_offset; resp =3D SPAPR_DR_CC_RESPONSE_SUCCESS; } else { resp =3D SPAPR_DR_CC_RESPONSE_PREV_PARENT; --=20 2.13.5