From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796384877; b=3/uV4uhmpikM8JLEb/MVrkTRzxgbtEmYH+pQdN80KOUdzyjL6iMMrPTtTXzI7uoPjDQ8 GkYd2H+YacVpjh5r/rtPikUPN1LVGvnC/iWbqMElU2XawKaJm13+JNWGhmC1tdDBQu+JJ C0Lq5RdZGJ1UYkzRLCsRh0kUvOVob0GL9nFFsdIYNen4PRdXKQ2IoCHD8pdNJBFKYW1Ji lqWfPrNh9J5i0VgO4pEpR68Rhxzy2ysfC9O2c+HfPXI7MR4cleoxADPyDQ4piCYvpvGAY /NhxoUTQ20cH9hNLulNQt+wokQK7i9UFEDSqXEnrgiQ/By5WdzZCxXWOuI3y9byQqaA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384877; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=7mpy8F690GiYtzQExjAyD7h7cFpXe3RWS74f6WPr0rE=; b=A9oHdczzHKNqqTl032Mz0heqSOoG3gfSwaEacYMflqEQ+T+YrmRp3yo9RRhXfqhHywVk k3tbDvktr20ghlGw1tCMLzTDbX5aokKZmjcNfrEO/TgR4Vxv9xViO9Fb0hBI76EqgNdLM 3dsDW9uAZ9a6eKRve5gx2q2jE4aRGxH8BcLsEriIEc6AeV1gNXVoFqR6S4CTA4YO4RFaN 129MA6gl+63smtocsVZfEFdylEg276GHjY6zjJjp7NsR+Z2Det46nD0GhtpoCcEHnKDT4 114p2s6L2AdXSNiSByD3/BlAW/1w3JF49K+8fnU6Dh0fiLr3P49Y22I3oFkHHg7wVog== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=w4Pw8lhc; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E37F606A322; Fri, 4 Dec 2026 11:47:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=w4Pw8lhc Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA31F1F000C2; Fri, 4 Dec 2026 11:47:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384877; bh=7mpy8F690GiYtzQExjAyD7h7cFpXe3RWS74f6WPr0rE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=w4Pw8lhcuX2piMzmjVumNw8nxZ/3yhYYjSOmB6392f07HfrnaAuQm0hSd3LVGNWsM wMwO1ivpvBarj4XAZTmbWk34A3pdTdNdLy2ysFNmv4G2gCAYW8IQ4GO3mFSrvyhUj5 xXexPWxq7GUxg0EjlwLsTr6ak3zAv9CJkm3JPYDE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jonathan Cameron , Dave Jiang , Li Ming , Richard Cheng , Alison Schofield , Sasha Levin Subject: [PATCH 6.6 0324/1167] cxl/hdm: Restore commit_end when decoder enumeration fails Date: Fri, 4 Dec 2026 18:55:51 +0900 Message-ID: <20261204100710.445666947@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alison Schofield [ Upstream commit 7dae18c39e99813461db6ef3fc13f077452109ce ] commit_end tracks the highest committed decoder on a port. It gets advanced before decoder enumeration is complete, so a later failure leaves it pointing at a decoder that was never added. The next probe then rejects decoder0 as out of order and enumeration fails. Reset commit_end to the uncommitted baseline once the decoders are torn down, so a subsequent probe rebuilds it from scratch. Register the reset before the decoders are added so that on unwind it runs after every decoder has been unregistered. This prevents commit_end from dropping below the highest committed decoder still registered and exposing an inconsistent value to a concurrent reader. Protect the commit_end advance in the DVSEC emulation path against concurrent readers, matching the register-programmed path. Fixes: 176baefb2eb5 ("cxl/hdm: Commit decoder state to hardware") Fixes: b777e9bec960 ("cxl/hdm: Emulate HDM decoder from DVSEC range registers") Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang Reviewed-by: Li Ming Reviewed-by: Richard Cheng Signed-off-by: Alison Schofield Link: https://patch.msgid.link/4802c5abc906b858a4754bfc4fa3e4c2c455d0c3.1786143520.git.alison.schofield@intel.com Signed-off-by: Dave Jiang [ sashal: Replaced upstream's cxl_rwsem.region lock with this tree's global cxl_region_rwsem, and kept the local target_map context line while dropping the inner rc. ] Signed-off-by: Sasha Levin --- drivers/cxl/core/hdm.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c index f46e206724642..18b4542657f22 100644 --- a/drivers/cxl/core/hdm.c +++ b/drivers/cxl/core/hdm.c @@ -821,7 +821,8 @@ static int cxl_setup_hdm_decoder_from_dvsec( * change the range registers at run time. */ cxld->flags |= CXL_DECODER_F_ENABLE | CXL_DECODER_F_LOCK; - port->commit_end = cxld->id; + scoped_guard(rwsem_write, &cxl_region_rwsem) + port->commit_end = cxld->id; rc = devm_cxl_dpa_reserve(cxled, *dpa_base, len, 0); if (rc) { @@ -1020,6 +1021,14 @@ static void cxl_settle_decoders(struct cxl_hdm *cxlhdm) msleep(20); } +static void cxl_reset_commit_end(void *data) +{ + struct cxl_port *port = data; + + guard(rwsem_write)(&cxl_region_rwsem); + port->commit_end = -1; +} + /** * devm_cxl_enumerate_decoders - add decoder objects per HDM register set * @cxlhdm: Structure to populate with HDM capabilities @@ -1030,8 +1039,8 @@ int devm_cxl_enumerate_decoders(struct cxl_hdm *cxlhdm, { void __iomem *hdm = cxlhdm->regs.hdm_decoder; struct cxl_port *port = cxlhdm->port; - int i; u64 dpa_base = 0; + int i, rc; /* * Per CXL 4.0 8.2.4.20.1 Target Count is the number of target ports @@ -1047,9 +1056,17 @@ int devm_cxl_enumerate_decoders(struct cxl_hdm *cxlhdm, cxl_settle_decoders(cxlhdm); + /* + * Reset commit_end after all decoders have been torn down so a + * subsequent probe rebuilds it from scratch. + */ + rc = devm_add_action(&port->dev, cxl_reset_commit_end, port); + if (rc) + return rc; + for (i = 0; i < cxlhdm->decoder_count; i++) { int target_map[CXL_DECODER_MAX_INTERLEAVE] = { 0 }; - int rc, target_count = cxlhdm->target_count; + int target_count = cxlhdm->target_count; struct cxl_decoder *cxld; if (is_cxl_endpoint(port)) { -- 2.53.0