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=1796387616; b=NMuT9wO9UgLXymKXyjoInvovzm8JJAZvh8v7RG7/QnxoXZdqSD0NhMxiyO0SOrnFVroh 2/3OHZjBmkXja+k3v/ip0IcJuwTHO+eL6giMvzv+SLUZ9H57z46nEGr/jpDu/28pH4ALE tmHj9t4ov5pijVjHLv0XJj2FNmm8WkM87a+hfErngeLO2dxcbEALkK5DkN0TWnZkFcHdx MD/Dl3qaQ4BV5RdWnnZek+b5E8EOftF5UEF0ttTYJ2ifRHYaMmZD9SyNnjcvsW2G+w5Fj NyXAltyQAitjrJYd5SPVOW19K4IDSrTA0RHkfFfbTB0o7/jjF+sAEbNQRLNO5G1kOkw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387616; 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=1f5JOwIER/DI9R2JIWanPIxvLh+Oq/D56B10WhpqtLo=; b=abqL3Fcc/vVLmUE4KoVCA0ubtN/wX+woHER+uwExjNOXjDVMcgqsWtBhAfjsc0TY/+TO auMjmVD6WnjdNNrm/EbuYzyX8U+kIbKIaB2GMK2dc7QptlnMXnwi+h7FJ0WrH1TGQcydY /9uxSlE8JWY34xDwMpQg/zsYDnL6yI1L9TMh+5AKtpDditvYM6icvooxVLZ/kuBHE2R30 yF07N2cQ1+tZydP9pPG81YK5s0HrOq4ZhvDvX+xug9Mirs+iDIllZDLlvcF1sSYzEPfYq dlOO4G9MMboZqTDE0nPrQjrj+h5e+IKDqfDXdPW8eWMeK7/2Z6rVIv3sMrSV08r6wsA== 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=t5daE+rK; 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 1DA90606A32C; Fri, 4 Dec 2026 12:33:36 +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=t5daE+rK Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88AEB1F00933; Fri, 4 Dec 2026 12:33:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387616; bh=1f5JOwIER/DI9R2JIWanPIxvLh+Oq/D56B10WhpqtLo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=t5daE+rKm6bNcRMK2QU1e5VABf0kZHmzQaBUI5Bl41pfnMdIVhMVffwLFAz8azZgd eVEQd4R/QFHeDP83nH+6/OFiUVP13eBLa/bTlitmKKtfhJjYnpu8ffmcRR4YlgTxeO L0npxNQW3jELTF6CWq01Qfms8k13OdfLZJYj98K8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alison Schofield , Li Ming , Dave Jiang , Sasha Levin Subject: [PATCH 6.1 0279/1059] cxl/hdm: Make switch decoder target parsing endian-safe Date: Fri, 4 Dec 2026 18:56:50 +0900 Message-ID: <20261204100651.500226682@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@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.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alison Schofield [ Upstream commit 3f846646b3d3b5699139e686e1107d231a725860 ] Switch decoder target IDs are stored one per byte, starting with target 0 in the least significant byte. The current code accesses those bytes in memory order, which only matches register order on little-endian hosts. On big-endian hosts, the target IDs are reversed and the decoder is associated with the wrong downstream ports. Place the register values in a byte array in little-endian order and index the target IDs from there, so the target mapping is independent of host endianness. Fixes: d17d0540a0db ("cxl/core/hdm: Add CXL standard decoder enumeration to the core") Signed-off-by: Alison Schofield Reviewed-by: Li Ming Link: https://patch.msgid.link/b0526825b3c3ffdb78837563e178d9aa27b6bbb8.1786143520.git.alison.schofield@intel.com Signed-off-by: Dave Jiang Signed-off-by: Sasha Levin --- drivers/cxl/core/hdm.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c index 689df3b86b026..c70a438d200e1 100644 --- a/drivers/cxl/core/hdm.c +++ b/drivers/cxl/core/hdm.c @@ -2,6 +2,7 @@ /* Copyright(c) 2022 Intel Corporation. All rights reserved. */ #include #include +#include #include #include @@ -715,15 +716,12 @@ static int init_hdm_decoder(struct cxl_port *port, struct cxl_decoder *cxld, u64 *dpa_base) { struct cxl_endpoint_decoder *cxled = NULL; + u8 target_id[CXL_HDM_DECODER0_TL_TARGETS]; u64 size, base, skip, dpa_size; bool committed; u32 remainder; int i, rc; u32 ctrl; - union { - u64 value; - unsigned char target_id[8]; - } target_list; if (is_endpoint_decoder(&cxld->dev)) cxled = to_cxl_endpoint_decoder(&cxld->dev); @@ -803,10 +801,12 @@ static int init_hdm_decoder(struct cxl_port *port, struct cxl_decoder *cxld, return -ENXIO; } - target_list.value = - ioread64_hi_lo(hdm + CXL_HDM_DECODER0_TL_LOW(which)); + put_unaligned_le32(readl(hdm + CXL_HDM_DECODER0_TL_LOW(which)), + &target_id[0]); + put_unaligned_le32(readl(hdm + CXL_HDM_DECODER0_TL_HIGH(which)), + &target_id[4]); for (i = 0; i < cxld->interleave_ways; i++) - target_map[i] = target_list.target_id[i]; + target_map[i] = target_id[i]; return 0; } -- 2.53.0