From nobody Sat Feb 7 04:47:22 2026 Received: from BN1PR04CU002.outbound.protection.outlook.com (mail-eastus2azon11010036.outbound.protection.outlook.com [52.101.56.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E32073191C4; Wed, 14 Jan 2026 16:49:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.56.36 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768409354; cv=fail; b=hcJ/w4Mah3hsswqDbZn3X+n6Y5zzlJIWL+zhN1ac1vFv14LUrKaLdSiG18Y4QRXajNW4/Y/1mY+pw1U/SH0rnzqOoGHQNE6Ohd2Hzel1GLBsamzvfHxad8k8oFTE7TSKxkuZxLY1mRAS3af8dcfbtBhEyx9/CMkWLsuppQKVeXg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768409354; c=relaxed/simple; bh=6jdHxc4rHQWqGcLuJelwLC2kPoIZnYzrMQGPkO/9LVo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NYqCIGA2o6kw3V2hF5FNcqbnYdVHNzhfe4qMAMvw1GUBs0Usx3zUp0BQDopi+RKIEqw8x8TohIfLBwUkEpWZeXTpvIlr0/DnRC/v5XZoTvmkj1UFjXRPnv747tvOPbG5P7CKOKFPOi5dcKHh18kUDoBA5dOdHcIV4Sj7eBVDbOU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=5tLFc/NT; arc=fail smtp.client-ip=52.101.56.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="5tLFc/NT" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RmVD+pmdJSFNreZGSZhWqBtYpPkeoAzvxMZa5GYtqFajQTAkim3IZU0lO1JphrthYIjk5vMxGFQhVu1K0GuwzqsQRmh+F+Bzqh043+lSZLtozv8ya1xxIHxzgkUgTRPfhoG71TJkMYTMKB7b8LQZZWFOyl9Dh572vg8egRxFaYXq2pB9MKv3u8mlx0/WvN078U/l9hL8tSA36AmAGIEQj+bJFQiDbStc0rFFLmVoU4iY2NyBnCPRk7etA9en6pnd6Iw/wyGS3LZ6vZ5rUKrLksip28Ibpk3mcmfQbh3FeVhcqA0r8jdBCJQRNDbZCYqm+xtveyqCXPeLGGNb1cdFkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6Tx2eWF8JbUnDyj5N18WVpH+gvpW9QnGcwP8EmhyHQM=; b=KAjILLzBX3+BiYSODxEtywXRm/44djHYdmAnYhwEjZad/+yIj76vfpusRzkTpuP4mpEcgf7xxo/E+2KxuczcHksQR5+SKwrJ9ADHBEHix3Yfu/P7zltWfriaXSywOFpnYAn/ReH8lOzDCFdpTAsG7I/NZLFepkMJxfejq3uokcsCfCKBjrFhJSDIUceTH4ZrasmLzDMybilx40Cjknh6k2zESTBDgnYEssZG12xzoUhpKBaI1eQYh8RjdB/LgGT/sw2FTXLX3gY7kE7e2Fpt99LOURkhDSU+e3Qtg7+gbEhyluoLbvvnW/a+sAp00BFns40BfVMjhtBvCUsvEVbdBQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6Tx2eWF8JbUnDyj5N18WVpH+gvpW9QnGcwP8EmhyHQM=; b=5tLFc/NTugbBPzTA+COd2PNA+ChEKjlsgGhw14Muf9lRNCEx37JJHklr/hwTknk9fu3Mgq66RVVJWr4AHoWr8PBFuXWK8axp1uIojN4s/dDMJgPlFDDo6EJG3096pstio0cVapRNq3yNRxZt7iZaa1T6MNU1G8+OYRsZuUchXkU= Received: from PH8P221CA0004.NAMP221.PROD.OUTLOOK.COM (2603:10b6:510:2d8::9) by SN7PR12MB7179.namprd12.prod.outlook.com (2603:10b6:806:2a7::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9499.7; Wed, 14 Jan 2026 16:49:08 +0000 Received: from CY4PEPF0000E9D6.namprd05.prod.outlook.com (2603:10b6:510:2d8:cafe::6e) by PH8P221CA0004.outlook.office365.com (2603:10b6:510:2d8::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9520.5 via Frontend Transport; Wed, 14 Jan 2026 16:49:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CY4PEPF0000E9D6.mail.protection.outlook.com (10.167.241.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.1 via Frontend Transport; Wed, 14 Jan 2026 16:49:07 +0000 Received: from rric.localdomain (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Wed, 14 Jan 2026 10:49:04 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Joshua Hahn , Robert Richter Subject: [PATCH v10 01/13] cxl/region: Rename misleading variable name @hpa to @hpa_range Date: Wed, 14 Jan 2026 17:48:17 +0100 Message-ID: <20260114164837.1076338-2-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260114164837.1076338-1-rrichter@amd.com> References: <20260114164837.1076338-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D6:EE_|SN7PR12MB7179:EE_ X-MS-Office365-Filtering-Correlation-Id: 01f1b3b1-680a-4caf-8114-08de538cd5a8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|82310400026|1800799024|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?audjNIBVYMJGKGcaxzqYqYVyGEzlQjYFKzo043tVCxJHWn4Yfv92YFhG1n2B?= =?us-ascii?Q?A3Fc0LrtgFyhEJ8hxx6VtUeDw5o9F7EDrLa2ilhQrnaMMqvD7OOus4lamc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QCds5dJgJ6XwsJ8w4lSndnYXI95fAbrZot8?= =?us-ascii?Q?63JjePeeU6csZN75kZZ4P9urJt9cq9P7srzUVMMQR76BNvc79xCEtaUSxdYW?= =?us-ascii?Q?9O+dyG/zHyEHEEFBKSFGcRqnfZ08gJ6vkK940VEIw7zj+ktcb5vDDcdAlbbY?= =?us-ascii?Q?46/k1YIyMLA2KUQaRNjmBJVlNt/AFqwsx+Bn70tMY9ZA1lnKRJR68rBqY2AR?= =?us-ascii?Q?gKUsaZ4mUTtJZvVr7F8v1/AVcqxnNqWufHg6CH6Cg3JfWAOHEDAaKxNPj7Xb?= =?us-ascii?Q?NWB3vRoov/o9D75FHWIU+A4QMiu8bGVPJbj1gTmtR3AKLu/wjZ95KHdptvAh?= =?us-ascii?Q?H7ac040s4X0PIT9RNNPYGuqavYNfsf1+AtfgPbMCivh300YsXq5mFO74jybI?= =?us-ascii?Q?p0lycp/03jD+gyqj+uPIcCOt/FpewVK7mCN2LiGU8O17FvYSjGZEKIjzxNMK?= =?us-ascii?Q?k/sVNbyUaf0lrnzsJPfm8mp7rRXvV5EJSgDzKiNqC7bM1V80iRef9rYqif/L?= =?us-ascii?Q?lRWTGlAA0SulW8ltYwE/v/kKX2gR86NXSCsCQo1p4SA4ZUGrKcc5I8j+tMmq?= =?us-ascii?Q?05ZXFWjWz/0B7fPnTRMenD0Gh1VbXXcq4BKs3QV2K0mPNMQjh5VWlnGdiJcX?= =?us-ascii?Q?6G2EWstBuWASgencTc+6Wb+FkGlHaqyNNMIp+HaAQxMeTUr5Ng+w5/lYqdYn?= =?us-ascii?Q?BgM/Cw=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(36860700013)(82310400026)(1800799024)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jan 2026 16:49:07.7439 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 01f1b3b1-680a-4caf-8114-08de538cd5a8 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D6.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7179 Content-Type: text/plain; charset="utf-8" @hpa is actually a @hpa_range, rename variables accordingly. Reviewed-by: Gregory Price Reviewed-by: Dave Jiang Reviewed-by: Jonathan Cameron Reviewed-by: Alison Schofield Signed-off-by: Robert Richter reviewed-by tags and the small update in the description of 13/13? --- drivers/cxl/core/region.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index ae899f68551f..51f1a5545324 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3474,9 +3474,9 @@ static int match_decoder_by_range(struct device *dev,= const void *data) } =20 static struct cxl_decoder * -cxl_port_find_switch_decoder(struct cxl_port *port, struct range *hpa) +cxl_port_find_switch_decoder(struct cxl_port *port, struct range *hpa_rang= e) { - struct device *cxld_dev =3D device_find_child(&port->dev, hpa, + struct device *cxld_dev =3D device_find_child(&port->dev, hpa_range, match_decoder_by_range); =20 return cxld_dev ? to_cxl_decoder(cxld_dev) : NULL; @@ -3489,14 +3489,14 @@ cxl_find_root_decoder(struct cxl_endpoint_decoder *= cxled) struct cxl_port *port =3D cxled_to_port(cxled); struct cxl_root *cxl_root __free(put_cxl_root) =3D find_cxl_root(port); struct cxl_decoder *root, *cxld =3D &cxled->cxld; - struct range *hpa =3D &cxld->hpa_range; + struct range *hpa_range =3D &cxld->hpa_range; =20 - root =3D cxl_port_find_switch_decoder(&cxl_root->port, hpa); + root =3D cxl_port_find_switch_decoder(&cxl_root->port, hpa_range); if (!root) { dev_err(cxlmd->dev.parent, "%s:%s no CXL window for range %#llx:%#llx\n", dev_name(&cxlmd->dev), dev_name(&cxld->dev), - cxld->hpa_range.start, cxld->hpa_range.end); + hpa_range->start, hpa_range->end); return NULL; } =20 @@ -3562,7 +3562,7 @@ static int __construct_region(struct cxl_region *cxlr, struct cxl_endpoint_decoder *cxled) { struct cxl_memdev *cxlmd =3D cxled_to_memdev(cxled); - struct range *hpa =3D &cxled->cxld.hpa_range; + struct range *hpa_range =3D &cxled->cxld.hpa_range; struct cxl_region_params *p; struct resource *res; int rc; @@ -3583,7 +3583,7 @@ static int __construct_region(struct cxl_region *cxlr, if (!res) return -ENOMEM; =20 - *res =3D DEFINE_RES_MEM_NAMED(hpa->start, range_len(hpa), + *res =3D DEFINE_RES_MEM_NAMED(hpa_range->start, range_len(hpa_range), dev_name(&cxlr->dev)); =20 rc =3D cxl_extended_linear_cache_resize(cxlr, res); @@ -3666,11 +3666,12 @@ static struct cxl_region *construct_region(struct c= xl_root_decoder *cxlrd, } =20 static struct cxl_region * -cxl_find_region_by_range(struct cxl_root_decoder *cxlrd, struct range *hpa) +cxl_find_region_by_range(struct cxl_root_decoder *cxlrd, + struct range *hpa_range) { struct device *region_dev; =20 - region_dev =3D device_find_child(&cxlrd->cxlsd.cxld.dev, hpa, + region_dev =3D device_find_child(&cxlrd->cxlsd.cxld.dev, hpa_range, match_region_by_range); if (!region_dev) return NULL; @@ -3680,7 +3681,7 @@ cxl_find_region_by_range(struct cxl_root_decoder *cxl= rd, struct range *hpa) =20 int cxl_add_to_region(struct cxl_endpoint_decoder *cxled) { - struct range *hpa =3D &cxled->cxld.hpa_range; + struct range *hpa_range =3D &cxled->cxld.hpa_range; struct cxl_region_params *p; bool attach =3D false; int rc; @@ -3691,12 +3692,13 @@ int cxl_add_to_region(struct cxl_endpoint_decoder *= cxled) return -ENXIO; =20 /* - * Ensure that if multiple threads race to construct_region() for @hpa - * one does the construction and the others add to that. + * Ensure that, if multiple threads race to construct_region() + * for the HPA range, one does the construction and the others + * add to that. */ mutex_lock(&cxlrd->range_lock); struct cxl_region *cxlr __free(put_cxl_region) =3D - cxl_find_region_by_range(cxlrd, hpa); + cxl_find_region_by_range(cxlrd, hpa_range); if (!cxlr) cxlr =3D construct_region(cxlrd, cxled); mutex_unlock(&cxlrd->range_lock); --=20 2.47.3 From nobody Sat Feb 7 04:47:22 2026 Received: from CH5PR02CU005.outbound.protection.outlook.com (mail-northcentralusazon11012037.outbound.protection.outlook.com [40.107.200.37]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A3134395260; Wed, 14 Jan 2026 16:49:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.200.37 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768409362; cv=fail; b=SIvhc5KJVAQ7KYoBUyV8erozrRB1RH2IScWzpT9WtzeYL3ugzS+3n2GDBxLBxtLYCaXw0EVZgIz0KGzbxgmNZdMG/LKrgjsi50r6dI0Rq6i9OUOgik+WC8c+P8S07pRUibFslksjtapV1KwQ6e0Gx7de1AEdmgh7NFDZmHqXu/M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768409362; c=relaxed/simple; bh=RBFov1bCg8LPrxfAYDWlACobATsqqb8BLKwUylf8+GI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=H7S+BkcokCg/kBu5TTFLQb1Lnee/WJdd/v81lZ1ESNmDUDvCmwBRbeu5W90vwd3UwJEezgXTkcJxr3BiAnYk5GASTc6c8EGowJ7qRIBTiB1jRMC9PGIqicwCfWJbouo/fdsO9uSEfmnxzGh2p1f+pLfxPDjYoowbeGyg7grhvmI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=PRojUQ4w; arc=fail smtp.client-ip=40.107.200.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="PRojUQ4w" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tKh0P0UtQegI73+HMfjm/vJX9U0IM9GfpqTyqJaXlYHUVu+0y46j9nzQfrid+/d7VXph62d9az21pKMvGq/Xj7OS3kQGPubLOtxu16DU4zqmlRqBh+zArLg7t7nAn9/LXW5cJpkgZas5z1Kibe4BFlBX3Vy4fAwRWUAach32dXQvxa3915AbcJmy6NGT3BBVb9ne5TSpCkXNdSP8ArMm4Ik818kK09ie5bNt7T35+7A1WXvZF7PHsY32joSGTG8iHgGIOqSc/Wy87UyGHF8CoKzOWIZBSCtqzF+cqjoHxE6Tdmx1KuSmy5XfsyLlLFqptPiGvr7mqW1LbKYomlNU8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YguNO3+jfhofxLbvJEo2fphc2r9LyuGu16WV3NJBQww=; b=ZtG9Bug9eUJMpubmzBzhuLi2H+IS/MpcqX5JBqkD1P8UALIE1OgIe12lWdcmpCzbcWDOHjj1d0sQVhntHBqBjjHTepJqRR+lr6n3C71u5Isy2VBip+weKZlAD9okgno9mQ6oMIlgv/EKsWmtQCNcUfRne6Vc9R4mifUvZN5Q2+ZAYf9uGnR2x4H/UmmLI+x1OYUWyB2a2FBLh5FeVMtj5oq0POhuerXlbzpWcqDhkCgBZ2/CzLGU0z1SCQvCIRD6Sg/jCdhsrMHeynsNx7dxocxnyMV//sjoZ255pUOWySzAHLDJYQxSVVnVrjR2UiA8Yj1sL8eKiVynBVAs991f3g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YguNO3+jfhofxLbvJEo2fphc2r9LyuGu16WV3NJBQww=; b=PRojUQ4wbWjWhq5E/Yf6e8Q5wQbPH1/jM/dTa+3TPKoDtr802r+C/p5S6spOTd2GVeKRiYmd25eKtIQsh8x62i9Zat7gHw3GmMB87+Acx8OEKi5o/1lf02fTBP+lRCJZV8l+vf/2jzxifFibz1jsayqjG8Eq2NDL5hFfCir4sOY= Received: from PH8P221CA0023.NAMP221.PROD.OUTLOOK.COM (2603:10b6:510:2d8::11) by CH2PR12MB4200.namprd12.prod.outlook.com (2603:10b6:610:ac::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9499.7; Wed, 14 Jan 2026 16:49:16 +0000 Received: from CY4PEPF0000E9D6.namprd05.prod.outlook.com (2603:10b6:510:2d8:cafe::5f) by PH8P221CA0023.outlook.office365.com (2603:10b6:510:2d8::11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9520.5 via Frontend Transport; Wed, 14 Jan 2026 16:49:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CY4PEPF0000E9D6.mail.protection.outlook.com (10.167.241.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.1 via Frontend Transport; Wed, 14 Jan 2026 16:49:15 +0000 Received: from rric.localdomain (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Wed, 14 Jan 2026 10:49:07 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Joshua Hahn , Robert Richter Subject: [PATCH v10 02/13] cxl/region: Store root decoder in struct cxl_region Date: Wed, 14 Jan 2026 17:48:18 +0100 Message-ID: <20260114164837.1076338-3-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260114164837.1076338-1-rrichter@amd.com> References: <20260114164837.1076338-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D6:EE_|CH2PR12MB4200:EE_ X-MS-Office365-Filtering-Correlation-Id: cee26524-0a38-4b84-00fa-08de538cda83 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|376014|7416014|1800799024|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?r4pG75juMvGIwHAFgLYGzai4mTbYarZF9GskUR/fWZBLuuxVADVu2fTaV8Jd?= =?us-ascii?Q?U/knOlwSJClPwrsJDVNyu7xDmnhGygpfTOKr1Z78hblhPL1zUQy8YL50IgGg?= =?us-ascii?Q?adweMUTxskJDiLSBfA3tjiEMAnNfaQAW4Mkv6An/Kz2zTbCpim3acT7uQrtr?= =?us-ascii?Q?rDCk1UVujtUqNpnPtROZtGIxjuLSIJEjB0/5uRZvHH3eoJN+c0w+I06BVOaI?= =?us-ascii?Q?9tox8dablM32rbN5kwzMT/+kkK4s9WznBybniuAkYqR4hee7ctdUUCpqZNZz?= =?us-ascii?Q?vDSWvycuiHD2+tmU0o9NSb/iviQ5Uazsiua43wEMWk++UQ/06kX7goSCqVmD?= =?us-ascii?Q?xuP4RnxVfuqBZGix29Eiobs65K36upPRkG+3VS4v2iahqxGfCk3waHDoK5rr?= =?us-ascii?Q?li13F6TbTEAg1XAkL2K71Ica2WQrKd0HF/D93clEEHzfRXBMcXkwZ/IMWQuT?= =?us-ascii?Q?Kn2DlUvxpJi5zfkNKfCh4CGOQkGCaxTJ/M1XeyiTSCp1+4UvdiDRMZJ3utj5?= =?us-ascii?Q?bxXSVPLOhu/hB8+6gWKuu18w8pRNYXsNiwVmcocFh1jYRon7v7sK6V0YepNZ?= =?us-ascii?Q?8JEoir1JYxR3tMoSIVF78J21y+bDf7Fh29PUO9zRyDYI3Y802ki9ytxSZjCm?= =?us-ascii?Q?ePFHs78qRFikx0LAfUC5sab7YAvOTT3qhQQNIqo3TtPDiyVoQJyjXfgywBV6?= =?us-ascii?Q?osItBPyDHibI2LfN+UlQn4wg8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-ascii?Q?8LNOu6SH1+qBkGUokUk70d+cJji6A8iehcFcN3NKICdmPnwA0Poae8PkylK/?= =?us-ascii?Q?F60OLA=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(376014)(7416014)(1800799024)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jan 2026 16:49:15.8869 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cee26524-0a38-4b84-00fa-08de538cda83 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D6.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4200 Content-Type: text/plain; charset="utf-8" A region is always bound to a root decoder. The region's associated root decoder is often needed. Add it to struct cxl_region. This simplifies the code by removing dynamic lookups and the root decoder argument from the function argument list where possible. Patch is a prerequisite to implement address translation which uses struct cxl_region to store all relevant region and interleaving parameters. It changes the argument list of __construct_region() in preparation of adding a context argument. Additionally the arg list of cxl_region_attach_position() is simplified and the use of to_cxl_root_decoder() removed, which always reconstructs and checks the pointer. The pointer never changes and is frequently used. Code becomes more readable as this amphazises the binding between both objects. Reviewed-by: Dave Jiang Reviewed-by: Jonathan Cameron Reviewed-by: Gregory Price Reviewed-by: Alison Schofield Signed-off-by: Robert Richter reviewed-by tags and the small update in the description of 13/13? --- drivers/cxl/core/region.c | 37 +++++++++++++++++++------------------ drivers/cxl/cxl.h | 2 ++ 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 51f1a5545324..22bd8ff37cef 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -489,9 +489,9 @@ static ssize_t interleave_ways_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { - struct cxl_root_decoder *cxlrd =3D to_cxl_root_decoder(dev->parent); - struct cxl_decoder *cxld =3D &cxlrd->cxlsd.cxld; struct cxl_region *cxlr =3D to_cxl_region(dev); + struct cxl_root_decoder *cxlrd =3D cxlr->cxlrd; + struct cxl_decoder *cxld =3D &cxlrd->cxlsd.cxld; struct cxl_region_params *p =3D &cxlr->params; unsigned int val, save; int rc; @@ -552,9 +552,9 @@ static ssize_t interleave_granularity_store(struct devi= ce *dev, struct device_attribute *attr, const char *buf, size_t len) { - struct cxl_root_decoder *cxlrd =3D to_cxl_root_decoder(dev->parent); - struct cxl_decoder *cxld =3D &cxlrd->cxlsd.cxld; struct cxl_region *cxlr =3D to_cxl_region(dev); + struct cxl_root_decoder *cxlrd =3D cxlr->cxlrd; + struct cxl_decoder *cxld =3D &cxlrd->cxlsd.cxld; struct cxl_region_params *p =3D &cxlr->params; int rc, val; u16 ig; @@ -628,7 +628,7 @@ static DEVICE_ATTR_RO(mode); =20 static int alloc_hpa(struct cxl_region *cxlr, resource_size_t size) { - struct cxl_root_decoder *cxlrd =3D to_cxl_root_decoder(cxlr->dev.parent); + struct cxl_root_decoder *cxlrd =3D cxlr->cxlrd; struct cxl_region_params *p =3D &cxlr->params; struct resource *res; u64 remainder =3D 0; @@ -1373,7 +1373,7 @@ static int cxl_port_setup_targets(struct cxl_port *po= rt, struct cxl_region *cxlr, struct cxl_endpoint_decoder *cxled) { - struct cxl_root_decoder *cxlrd =3D to_cxl_root_decoder(cxlr->dev.parent); + struct cxl_root_decoder *cxlrd =3D cxlr->cxlrd; int parent_iw, parent_ig, ig, iw, rc, pos =3D cxled->pos; struct cxl_port *parent_port =3D to_cxl_port(port->dev.parent); struct cxl_region_ref *cxl_rr =3D cxl_rr_load(port, cxlr); @@ -1731,10 +1731,10 @@ static int cxl_region_validate_position(struct cxl_= region *cxlr, } =20 static int cxl_region_attach_position(struct cxl_region *cxlr, - struct cxl_root_decoder *cxlrd, struct cxl_endpoint_decoder *cxled, const struct cxl_dport *dport, int pos) { + struct cxl_root_decoder *cxlrd =3D cxlr->cxlrd; struct cxl_memdev *cxlmd =3D cxled_to_memdev(cxled); struct cxl_switch_decoder *cxlsd =3D &cxlrd->cxlsd; struct cxl_decoder *cxld =3D &cxlsd->cxld; @@ -1971,7 +1971,7 @@ static int cxl_region_sort_targets(struct cxl_region = *cxlr) static int cxl_region_attach(struct cxl_region *cxlr, struct cxl_endpoint_decoder *cxled, int pos) { - struct cxl_root_decoder *cxlrd =3D to_cxl_root_decoder(cxlr->dev.parent); + struct cxl_root_decoder *cxlrd =3D cxlr->cxlrd; struct cxl_memdev *cxlmd =3D cxled_to_memdev(cxled); struct cxl_dev_state *cxlds =3D cxlmd->cxlds; struct cxl_region_params *p =3D &cxlr->params; @@ -2076,8 +2076,7 @@ static int cxl_region_attach(struct cxl_region *cxlr, ep_port =3D cxled_to_port(cxled); dport =3D cxl_find_dport_by_dev(root_port, ep_port->host_bridge); - rc =3D cxl_region_attach_position(cxlr, cxlrd, cxled, - dport, i); + rc =3D cxl_region_attach_position(cxlr, cxled, dport, i); if (rc) return rc; } @@ -2100,7 +2099,7 @@ static int cxl_region_attach(struct cxl_region *cxlr, if (rc) return rc; =20 - rc =3D cxl_region_attach_position(cxlr, cxlrd, cxled, dport, pos); + rc =3D cxl_region_attach_position(cxlr, cxled, dport, pos); if (rc) return rc; =20 @@ -2396,8 +2395,8 @@ static const struct attribute_group *region_groups[] = =3D { =20 static void cxl_region_release(struct device *dev) { - struct cxl_root_decoder *cxlrd =3D to_cxl_root_decoder(dev->parent); struct cxl_region *cxlr =3D to_cxl_region(dev); + struct cxl_root_decoder *cxlrd =3D cxlr->cxlrd; int id =3D atomic_read(&cxlrd->region_id); =20 /* @@ -2480,10 +2479,12 @@ static struct cxl_region *cxl_region_alloc(struct c= xl_root_decoder *cxlrd, int i * region id allocations */ get_device(dev->parent); + cxlr->cxlrd =3D cxlrd; + cxlr->id =3D id; + device_set_pm_not_required(dev); dev->bus =3D &cxl_bus_type; dev->type =3D &cxl_region_type; - cxlr->id =3D id; cxl_region_set_lock(cxlr, &cxlrd->cxlsd.cxld); =20 return cxlr; @@ -3115,7 +3116,7 @@ EXPORT_SYMBOL_FOR_MODULES(cxl_calculate_hpa_offset, "= cxl_translate"); u64 cxl_dpa_to_hpa(struct cxl_region *cxlr, const struct cxl_memdev *cxlmd, u64 dpa) { - struct cxl_root_decoder *cxlrd =3D to_cxl_root_decoder(cxlr->dev.parent); + struct cxl_root_decoder *cxlrd =3D cxlr->cxlrd; struct cxl_region_params *p =3D &cxlr->params; struct cxl_endpoint_decoder *cxled =3D NULL; u64 dpa_offset, hpa_offset, hpa; @@ -3168,7 +3169,7 @@ static int region_offset_to_dpa_result(struct cxl_reg= ion *cxlr, u64 offset, struct dpa_result *result) { struct cxl_region_params *p =3D &cxlr->params; - struct cxl_root_decoder *cxlrd =3D to_cxl_root_decoder(cxlr->dev.parent); + struct cxl_root_decoder *cxlrd =3D cxlr->cxlrd; struct cxl_endpoint_decoder *cxled; u64 hpa, hpa_offset, dpa_offset; u16 eig =3D 0; @@ -3522,7 +3523,7 @@ static int match_region_by_range(struct device *dev, = const void *data) static int cxl_extended_linear_cache_resize(struct cxl_region *cxlr, struct resource *res) { - struct cxl_root_decoder *cxlrd =3D to_cxl_root_decoder(cxlr->dev.parent); + struct cxl_root_decoder *cxlrd =3D cxlr->cxlrd; struct cxl_region_params *p =3D &cxlr->params; resource_size_t size =3D resource_size(res); resource_size_t cache_size, start; @@ -3558,9 +3559,9 @@ static int cxl_extended_linear_cache_resize(struct cx= l_region *cxlr, } =20 static int __construct_region(struct cxl_region *cxlr, - struct cxl_root_decoder *cxlrd, struct cxl_endpoint_decoder *cxled) { + struct cxl_root_decoder *cxlrd =3D cxlr->cxlrd; struct cxl_memdev *cxlmd =3D cxled_to_memdev(cxled); struct range *hpa_range =3D &cxled->cxld.hpa_range; struct cxl_region_params *p; @@ -3656,7 +3657,7 @@ static struct cxl_region *construct_region(struct cxl= _root_decoder *cxlrd, return cxlr; } =20 - rc =3D __construct_region(cxlr, cxlrd, cxled); + rc =3D __construct_region(cxlr, cxled); if (rc) { devm_release_action(port->uport_dev, unregister_region, cxlr); return ERR_PTR(rc); diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index ba17fa86d249..10ce9c3a8a55 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -529,6 +529,7 @@ enum cxl_partition_mode { * struct cxl_region - CXL region * @dev: This region's device * @id: This region's id. Id is globally unique across all regions + * @cxlrd: Region's root decoder * @mode: Operational mode of the mapped capacity * @type: Endpoint decoder target type * @cxl_nvb: nvdimm bridge for coordinating @cxlr_pmem setup / shutdown @@ -542,6 +543,7 @@ enum cxl_partition_mode { struct cxl_region { struct device dev; int id; + struct cxl_root_decoder *cxlrd; enum cxl_partition_mode mode; enum cxl_decoder_type type; struct cxl_nvdimm_bridge *cxl_nvb; --=20 2.47.3 From nobody Sat Feb 7 04:47:22 2026 Received: from PH8PR06CU001.outbound.protection.outlook.com (mail-westus3azon11012028.outbound.protection.outlook.com [40.107.209.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 70A6D3A4ADD; Wed, 14 Jan 2026 16:49:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.209.28 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768409366; cv=fail; b=EOceu9Ir7ni3SOOfyc+jYRGtimylPXth7EeElB0DwUkwwYisSGH67abQZVPTFWFY+ICWNWpWGPqEocySVcnAi8/RLMgjdzIiP5IR9l6Y/EbbJTV/w1af0vDcysy+kTCouyaq+C679FOhu3dYPRon+ZKSEiws98YnOdGRKYNlKa4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768409366; c=relaxed/simple; bh=+8WOrg6X4MAR1aJ1euaZ1yWKHUmjq22f8wkI1SuIR18=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pyALhDfyEioL6F4Sqe9NELaHi1UHBm1GP6/yfr8/ilLYrk6CPXzQMpQFEMbbYRm8QZVoAARvnaturR2/CCC39QzDEW1+GPOVdj/VAKM9fr5+97nnelQVuazmZynaUbtcE9rWhQoB6XiFFKv3xrhmDdqiZH9gb8X8PO948gmSosY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=sM5JPB20; arc=fail smtp.client-ip=40.107.209.28 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="sM5JPB20" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iHIzu5BgIl+tIPwmhwgi/2UmYbPBNVf9HEGfyPh+Jq1jv5D6Pb/AZ8MFAcPUe/SyGLRqPwHIH0hjSyXiR64Rr9lqcdx0GIjbxADLZlq56Y7qZlClsiwvZ38u6C8YOHtSRxBwFDIk5ZHaLJcL+W4XlcMi7hPIe3zNbnHEB5IU1swn4cHJC/+FhmNL2nVfNcqFgP9KL8OoWNxXIBN9Pg+1FNCThCpM8x5Bs1r8luIgNZ7EJua4hiT3JT7sX2tB/uqbSTO7VCJqkSP7hR47Tf4ycbdRLNgLT/yAMMA633V3AXj6wbDEX92iZ9iD/vtPDnLPe24vG8AqozibfUPKyhCj8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Mt8hgpmX3uUUpddMkt6UeK8qE8HBdFGhqQDjlReIWSQ=; b=qVxeHFYoKxEworS7rZAzDhXLC6talznebC+1gGa8AbEITzJSGIgqOEDWdALndmdiXhuuXPwL2Rp0QgM6qtMqTsyxo2FpdWqlWmASL6hlWFiRnf/yiY+tW48o91BMuSJy4nHVf2Z9JAVDo98qE5tWIQGvHmfD7Dl2kdIFG11dlEWZiEeo3RGjAZI9UB3KddbiwLvcGvZib4p2c9hzCq6jSWbxSL+YJeVGw7ZG9As+KfoPiNUb/+smDPHK8mXzPrh1IkvRZGB/KmAkv6Hdf7BEJYum0A/j3erjAynqo+0WDDQ3rxXqwwbPLybvTUR2UcC5vRX/TfEZGIt27cSfiIwOBw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Mt8hgpmX3uUUpddMkt6UeK8qE8HBdFGhqQDjlReIWSQ=; b=sM5JPB20rJWPFBJ07AGhUSS9OQf2gq0NJorEqLv3O+seAswd0JdeKYN7eN10x6pwuATt3aaWLtKUuGQ1xdHgoKXeuqGHpMwpkGwkKQ1ptzkCcjA5WQtJd7Sd3yuayXOinSVwF9VxWd/SnCuKtVQpcqxfX1X1cBq+GQzu4+UdjHs= Received: from PH8P221CA0008.NAMP221.PROD.OUTLOOK.COM (2603:10b6:510:2d8::35) by SA1PR12MB6917.namprd12.prod.outlook.com (2603:10b6:806:24c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.5; Wed, 14 Jan 2026 16:49:17 +0000 Received: from CY4PEPF0000E9D6.namprd05.prod.outlook.com (2603:10b6:510:2d8:cafe::f1) by PH8P221CA0008.outlook.office365.com (2603:10b6:510:2d8::35) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9520.6 via Frontend Transport; Wed, 14 Jan 2026 16:49:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CY4PEPF0000E9D6.mail.protection.outlook.com (10.167.241.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.1 via Frontend Transport; Wed, 14 Jan 2026 16:49:16 +0000 Received: from rric.localdomain (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Wed, 14 Jan 2026 10:49:11 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Joshua Hahn , Robert Richter Subject: [PATCH v10 03/13] cxl/region: Store HPA range in struct cxl_region Date: Wed, 14 Jan 2026 17:48:19 +0100 Message-ID: <20260114164837.1076338-4-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260114164837.1076338-1-rrichter@amd.com> References: <20260114164837.1076338-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D6:EE_|SA1PR12MB6917:EE_ X-MS-Office365-Filtering-Correlation-Id: e123d305-55c5-41e8-e65e-08de538cdafe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|7416014|376014|36860700013|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Pu2OzHpTPrmHHjit5NoqNYpX5ITN6eRlqsnbmsOlns1Aym8XG4EbcSzkw5Aq?= =?us-ascii?Q?YTCRQsi862HtJCh8Rlwv3miyXDPHeZDP3SIy3IviGwN6RpzU/NEmGlfWP5OR?= =?us-ascii?Q?YB2oZ3IQOUbK5oHeZmO4I1UgYAh+BXnI7CZgynrrTfZtfkJI7H7d1qm0ZETB?= =?us-ascii?Q?B9qFKOewEZKG7HjyQ14yok1lXPez2kw+FGN263kPWhTvLT3xvdKLxX1WC85D?= =?us-ascii?Q?e+qktR4gc2MOfYs1FjzcBXjyD1/WPfY21nPmigtTO43GosULPOdCtYCHUKO8?= =?us-ascii?Q?Wuglb04zPrAyDQJCUGhsQulzmEh86/i8Kr3/QTxnOwhmrv1tRa97vadlVzuo?= =?us-ascii?Q?5SA1CQ19zQEaXiIDFmvwUOJftep+9JPKN9i5T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Ycf9Ikiok1VzP786jIWkR+anRVqxbmLkXC3fPioAGs?= =?us-ascii?Q?zF2XxcmGYrzOJJtVRPMve8vUxIZAsF41QWZv0NxQf3PfiIcF84DTEvGTPbvm?= =?us-ascii?Q?CYoSjPUuiUBq9av9ugPGP5sV5P6Xvq/mZaSktRR8y22xZN6mCTkXTj37Pvsk?= =?us-ascii?Q?jEWhoV0LXJavxmOm0FCFCq3mtUfXcMS9ClB02d78j6hCzTjKOPo/DpgkrZgg?= =?us-ascii?Q?ibgtV5KVckV58luGj/emtj/FfGtmEw2R40cOYlsbjuQGrtYmCuvC2Fg1oslB?= =?us-ascii?Q?WNJ9/TOxzQ2ZmNCwq1B2YFVc/i0ZXQTdqvjtBU/hr8Ko8q62yvTbb8kXC7lp?= =?us-ascii?Q?lDUyjv1pTQoKrNFXVa3o+ZBncjr5o6Lcbbs9xo9AJsIzZR+pYUd9LZkqIDJV?= =?us-ascii?Q?CKkdGg=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(7416014)(376014)(36860700013)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jan 2026 16:49:16.6991 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e123d305-55c5-41e8-e65e-08de538cdafe X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D6.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6917 Content-Type: text/plain; charset="utf-8" Each region has a known host physical address (HPA) range it is assigned to. Endpoint decoders assigned to a region share the same HPA range. The region's address range is the system's physical address (SPA) range. Endpoint decoders in systems that need address translation use HPAs which are not SPAs. To make the SPA range accessible to the endpoint decoders, store and track the region's SPA range in struct cxl_region. Introduce the @hpa_range member to the struct. Now, the SPA range of an endpoint decoder can be determined based on its assigned region. Patch is a prerequisite to implement address translation which uses struct cxl_region to store all relevant region and interleaving parameters. Reviewed-by: Dave Jiang Reviewed-by: Jonathan Cameron Reviewed-by: Gregory Price Reviewed-by: Alison Schofield Signed-off-by: Robert Richter reviewed-by tags and the small update in the description of 13/13? --- drivers/cxl/core/region.c | 7 +++++++ drivers/cxl/cxl.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 22bd8ff37cef..04c3ff66ec81 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -664,6 +664,8 @@ static int alloc_hpa(struct cxl_region *cxlr, resource_= size_t size) return PTR_ERR(res); } =20 + cxlr->hpa_range =3D DEFINE_RANGE(res->start, res->end); + p->res =3D res; p->state =3D CXL_CONFIG_INTERLEAVE_ACTIVE; =20 @@ -700,6 +702,8 @@ static int free_hpa(struct cxl_region *cxlr) if (p->state >=3D CXL_CONFIG_ACTIVE) return -EBUSY; =20 + cxlr->hpa_range =3D DEFINE_RANGE(0, -1); + cxl_region_iomem_release(cxlr); p->state =3D CXL_CONFIG_IDLE; return 0; @@ -2453,6 +2457,8 @@ static void unregister_region(void *_cxlr) for (i =3D 0; i < p->interleave_ways; i++) detach_target(cxlr, i); =20 + cxlr->hpa_range =3D DEFINE_RANGE(0, -1); + cxl_region_iomem_release(cxlr); put_device(&cxlr->dev); } @@ -3579,6 +3585,7 @@ static int __construct_region(struct cxl_region *cxlr, } =20 set_bit(CXL_REGION_F_AUTO, &cxlr->flags); + cxlr->hpa_range =3D *hpa_range; =20 res =3D kmalloc(sizeof(*res), GFP_KERNEL); if (!res) diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index 10ce9c3a8a55..3a5ca1936ed1 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -530,6 +530,7 @@ enum cxl_partition_mode { * @dev: This region's device * @id: This region's id. Id is globally unique across all regions * @cxlrd: Region's root decoder + * @hpa_range: Address range occupied by the region * @mode: Operational mode of the mapped capacity * @type: Endpoint decoder target type * @cxl_nvb: nvdimm bridge for coordinating @cxlr_pmem setup / shutdown @@ -544,6 +545,7 @@ struct cxl_region { struct device dev; int id; struct cxl_root_decoder *cxlrd; + struct range hpa_range; enum cxl_partition_mode mode; enum cxl_decoder_type type; struct cxl_nvdimm_bridge *cxl_nvb; --=20 2.47.3 From nobody Sat Feb 7 04:47:22 2026 Received: from SA9PR02CU001.outbound.protection.outlook.com (mail-southcentralusazon11013035.outbound.protection.outlook.com [40.93.196.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B58302441A6; Wed, 14 Jan 2026 16:49:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.196.35 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768409375; cv=fail; b=u674IZ2VEUSXZarcZLztyUlVVcOxyW1XmlFDjjby1dixjyI0hNSNPu58M1kKCIa3KbFnodpvB0k6wt1qS2V2AdVKBMt1gNaf4z3hMUlAyT8zNMc8SSxauZyjL3KWfwE0Un8lUKvaKLhS2/gYDtrfr8MZRCl4wceJKyCXC3NjPK8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768409375; c=relaxed/simple; bh=mfZv6vJ3D2mucYXODwbmdwlBi9bDktACu8OdhQAIGVo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=llCYdeKqYtuzxuQY/OR0vkk4QlPdgXNWvfikb1C3z8eIUcLMLzOrfqsO2Stlg/muMILjqUTFaxB6b4319MQQU6+GCVjGzfFu9XDSjFgXpL4Jg2FdpSja8iHDAca6L7MFkl3eTjblATFY9Zo30NYi+kuPGVQBSHOpsssg+6OdjuU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=UwSoHqci; arc=fail smtp.client-ip=40.93.196.35 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="UwSoHqci" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AljDlz1hnYf3ijtu2qhw3vNtTV4F24rKPu+PtNrcdEnFeovoFFe4o4VqcFlHTlciopB8lK/W/kDnXWE/IMVX7IJHmsnUQ6SdUevoQfn5lzIuaR1n/czNrZoFjFOQTmUUkhOQ7aXY9K/8sEb+l2OG7ddTuZG/x3DUTtf80cmMMvV4NKej/dRdrtD4YpTWpNER7t6GEV2a4sbHqGLOMC24zSAx+6hvns1xGGjg0ATCnRIqun/XQcEbAFww+eKBlOhxLvROd/QOM/Scs23JRriy1cwerYTsY69HMactMtOF+egEgM8b5kEe12ZNtgMmp/qlO5hgDmNk5eKDfciks5zrYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VPBOs8/hvv9P/e2l3jqcyrSMf8SjzGONG2XAFTlMMyw=; b=L9cYkTegBQLvgqQmPeT2Gn8+uis2F2PD4SGJqiN8cyZpno0S2i58Otrb7KWJx3y7W/l2VhNF4xq3F6RfHRmOtRDp+26M8dmkowayOCcqID+rzWdg0fmVs4EY6Ea2EAUobmDvXzKrdu4AC0nd3bIrNXkvq4zmBTOTHh+LOppQ4HNNx8l9K1VSpXYKffm/hc7dMJdScbJM8XRHO0FR4nTRmxkfVmtB83/HffE11Qal+11T2ur+fPa11hQiiuTBPNXTasQaEcJPslC5IAClEZfJ181GeeKreul4MQBs5MEozJPNVtijaz+eMIAXQ6ZBHbfTOyiiaJy9RFirjcF90d5sDQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VPBOs8/hvv9P/e2l3jqcyrSMf8SjzGONG2XAFTlMMyw=; b=UwSoHqcieEClKUWOmxRoffH3mcdHvV6yMVtEH6+jTnoVPWhR1z8rfdHd8kblTe/E5NrM6znCbNGQq2yqbOgDilesfV83PlD03YEzvs3waDdQ2f+zg8t2htCDL6elTFjeeXvhl7Kc8d5Y2LjYoGP84fybJ7ksHYjEIFIi6hgC54g= Received: from PH8P221CA0003.NAMP221.PROD.OUTLOOK.COM (2603:10b6:510:2d8::31) by IA0PR12MB8695.namprd12.prod.outlook.com (2603:10b6:208:485::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9499.7; Wed, 14 Jan 2026 16:49:21 +0000 Received: from CY4PEPF0000E9D6.namprd05.prod.outlook.com (2603:10b6:510:2d8:cafe::54) by PH8P221CA0003.outlook.office365.com (2603:10b6:510:2d8::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9520.5 via Frontend Transport; Wed, 14 Jan 2026 16:49:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CY4PEPF0000E9D6.mail.protection.outlook.com (10.167.241.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.1 via Frontend Transport; Wed, 14 Jan 2026 16:49:20 +0000 Received: from rric.localdomain (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Wed, 14 Jan 2026 10:49:14 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Joshua Hahn , Robert Richter Subject: [PATCH v10 04/13] cxl: Simplify cxl_root_ops allocation and handling Date: Wed, 14 Jan 2026 17:48:20 +0100 Message-ID: <20260114164837.1076338-5-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260114164837.1076338-1-rrichter@amd.com> References: <20260114164837.1076338-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D6:EE_|IA0PR12MB8695:EE_ X-MS-Office365-Filtering-Correlation-Id: e7313d44-951c-4dad-fd98-08de538cdd6c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|36860700013|1800799024|82310400026|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?r42KqwiOgxI8QHr247EanBhC8r8lmmnJYjOXDMbsWsV+0CBJlmMvwWpbkqIi?= =?us-ascii?Q?cRKOVWXDI3SicYM8AnBcSCDG5M5nUDbD/O3cY/15oFi5vL+GmPGUNpSuHVoE?= =?us-ascii?Q?rmTUFVBfk29Fq88ykGAog28c90+ipm2/hzy43NVjwB712D2sETYGRvRFca/U?= =?us-ascii?Q?0f9AYltVM3foyeZLlHopZ37KeyY4tezoua0p4Y+Fk9BnvStwXdw0Is7Gl3LW?= =?us-ascii?Q?oGK1ofcCrbygz620Z4DHsHAQ2Mbo2ND4jakJkLhS3RO4Dcb48nv0peFCL1xa?= =?us-ascii?Q?Vaj5E8pWBcVFFsvIbdxPvdALBgekMHYp5yxHLgr+i4zmOH/z9kB8yojix9+H?= =?us-ascii?Q?kh/kTuDW4vkRiXXKJ+N86Rqbx5dCSMOO+aPfxaoisT5FcPrrvfc13X2Ivrdc?= =?us-ascii?Q?HnTwoX6jvtdx0eq5foUmYereWsz7UO3Qr5vYb/ergMSbNiSsGc4M+1bO2WlM?= =?us-ascii?Q?YTCyJSELrG8QBP2Yy+jy4BG4ZHyEQjA991bqPAIdHml4lQCV91Q+QKW0QBHr?= =?us-ascii?Q?n4Vklf5yt/Cu7YbOyk1V9qlrZ0dyECH4/SvR6k8BbNuB63IU54DxFGoodaTQ?= =?us-ascii?Q?/AS2HCwOkg1sjCqZC3+5uHXooUBJthFCy4aj7ORT8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G2m61qttIWGfJ4higtkZg5903XX1NFb/i/mjXBjN39u?= =?us-ascii?Q?cXcrDdO0SxNnW6mqgUW4ACpLN6tK9ZjfKzyEEZplwTn0vzMTWCEZvI+GzCAf?= =?us-ascii?Q?k6Fb0xmjYuv60AgfBqgKwikA39PGC2Y36nSaP/ZTAKPaLGmZC7LayHXFlQEZ?= =?us-ascii?Q?0JGQ3A=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(36860700013)(1800799024)(82310400026)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jan 2026 16:49:20.7993 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e7313d44-951c-4dad-fd98-08de538cdd6c X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D6.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8695 Content-Type: text/plain; charset="utf-8" A root port's callback handlers are collected in struct cxl_root_ops. The structure is dynamically allocated, though it contains only a single pointer in it. This also requires to check two pointers to check for the existance of a callback. Simplify the allocation, release and handler check by embedding the ops statically in struct cxl_root. Reviewed-by: Dave Jiang Reviewed-by: Jonathan Cameron Reviewed-by: Alison Schofield Signed-off-by: Robert Richter reviewed-by tags and the small update in the description of 13/13? --- drivers/cxl/acpi.c | 7 ++----- drivers/cxl/core/cdat.c | 8 ++++---- drivers/cxl/core/port.c | 8 ++------ drivers/cxl/cxl.h | 19 ++++++++++--------- 4 files changed, 18 insertions(+), 24 deletions(-) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index 77ac940e3013..b4bed40ef7c0 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -318,10 +318,6 @@ static int cxl_acpi_qos_class(struct cxl_root *cxl_roo= t, return cxl_acpi_evaluate_qtg_dsm(handle, coord, entries, qos_class); } =20 -static const struct cxl_root_ops acpi_root_ops =3D { - .qos_class =3D cxl_acpi_qos_class, -}; - static void del_cxl_resource(struct resource *res) { if (!res) @@ -923,9 +919,10 @@ static int cxl_acpi_probe(struct platform_device *pdev) cxl_res->end =3D -1; cxl_res->flags =3D IORESOURCE_MEM; =20 - cxl_root =3D devm_cxl_add_root(host, &acpi_root_ops); + cxl_root =3D devm_cxl_add_root(host); if (IS_ERR(cxl_root)) return PTR_ERR(cxl_root); + cxl_root->ops.qos_class =3D cxl_acpi_qos_class; root_port =3D &cxl_root->port; =20 rc =3D bus_for_each_dev(adev->dev.bus, NULL, root_port, diff --git a/drivers/cxl/core/cdat.c b/drivers/cxl/core/cdat.c index 7120b5f2e31f..18f0f2a25113 100644 --- a/drivers/cxl/core/cdat.c +++ b/drivers/cxl/core/cdat.c @@ -213,7 +213,7 @@ static int cxl_port_perf_data_calculate(struct cxl_port= *port, if (!cxl_root) return -ENODEV; =20 - if (!cxl_root->ops || !cxl_root->ops->qos_class) + if (!cxl_root->ops.qos_class) return -EOPNOTSUPP; =20 xa_for_each(dsmas_xa, index, dent) { @@ -221,9 +221,9 @@ static int cxl_port_perf_data_calculate(struct cxl_port= *port, =20 cxl_coordinates_combine(dent->coord, dent->cdat_coord, ep_c); dent->entries =3D 1; - rc =3D cxl_root->ops->qos_class(cxl_root, - &dent->coord[ACCESS_COORDINATE_CPU], - 1, &qos_class); + rc =3D cxl_root->ops.qos_class(cxl_root, + &dent->coord[ACCESS_COORDINATE_CPU], + 1, &qos_class); if (rc !=3D 1) continue; =20 diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index fef3aa0c6680..2338d146577c 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -954,19 +954,15 @@ struct cxl_port *devm_cxl_add_port(struct device *hos= t, } EXPORT_SYMBOL_NS_GPL(devm_cxl_add_port, "CXL"); =20 -struct cxl_root *devm_cxl_add_root(struct device *host, - const struct cxl_root_ops *ops) +struct cxl_root *devm_cxl_add_root(struct device *host) { - struct cxl_root *cxl_root; struct cxl_port *port; =20 port =3D devm_cxl_add_port(host, host, CXL_RESOURCE_NONE, NULL); if (IS_ERR(port)) return ERR_CAST(port); =20 - cxl_root =3D to_cxl_root(port); - cxl_root->ops =3D ops; - return cxl_root; + return to_cxl_root(port); } EXPORT_SYMBOL_NS_GPL(devm_cxl_add_root, "CXL"); =20 diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index 3a5ca1936ed1..0e15dc6e169f 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -646,6 +646,14 @@ struct cxl_port { resource_size_t component_reg_phys; }; =20 +struct cxl_root; + +struct cxl_root_ops { + int (*qos_class)(struct cxl_root *cxl_root, + struct access_coordinate *coord, int entries, + int *qos_class); +}; + /** * struct cxl_root - logical collection of root cxl_port items * @@ -654,7 +662,7 @@ struct cxl_port { */ struct cxl_root { struct cxl_port port; - const struct cxl_root_ops *ops; + struct cxl_root_ops ops; }; =20 static inline struct cxl_root * @@ -663,12 +671,6 @@ to_cxl_root(const struct cxl_port *port) return container_of(port, struct cxl_root, port); } =20 -struct cxl_root_ops { - int (*qos_class)(struct cxl_root *cxl_root, - struct access_coordinate *coord, int entries, - int *qos_class); -}; - static inline struct cxl_dport * cxl_find_dport_by_dev(struct cxl_port *port, const struct device *dport_de= v) { @@ -782,8 +784,7 @@ struct cxl_port *devm_cxl_add_port(struct device *host, struct device *uport_dev, resource_size_t component_reg_phys, struct cxl_dport *parent_dport); -struct cxl_root *devm_cxl_add_root(struct device *host, - const struct cxl_root_ops *ops); +struct cxl_root *devm_cxl_add_root(struct device *host); struct cxl_root *find_cxl_root(struct cxl_port *port); =20 DEFINE_FREE(put_cxl_root, struct cxl_root *, if (_T) put_device(&_T->port.= dev)) --=20 2.47.3 From nobody Sat Feb 7 04:47:22 2026 Received: from PH7PR06CU001.outbound.protection.outlook.com (mail-westus3azon11010021.outbound.protection.outlook.com [52.101.201.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 769A33191C4; Wed, 14 Jan 2026 16:49:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.201.21 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768409368; cv=fail; b=OmYdYvQkv+9Fio/Qjvn/HZhZCZg5IC/a0Dfibv4XtPLtM86B0yGeHW+ni6WhpyCorroRP2K1v3PFrHkCLjZhQ3YSUp9+cRZ7QUzOQ2QicrtKuxyt6clzUXEOQnL90v/KTVmJ2DaVN9ac6dnc47XT1LLyD0y2sopsC2bu8ireC3o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768409368; c=relaxed/simple; bh=aZczS4SSNZg5/Hu1dWEOcZmKrLE2wK9qQ8ly+H47qDw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=i5WBCbdtwe+f6RD6ZPrieOoWjiNwODVqI196Ajj6T7qvTY0/kwJrnIh3PlQRMM9khsnI9PZ7pPrCr+uQH6jxXtFVB/nlzvxB0GgcQAdDM3kZp4RDUGKBdaC2qBPUAsY7py5lrRg7VbOq/sr2WTHMwrWcidPfUVh4rwJj8ZBBH+U= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=VB/gjDX8; arc=fail smtp.client-ip=52.101.201.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="VB/gjDX8" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=acy9Qzm+o3/L1cvu/ln9C9tmy/31RxtME+CGHaMIjcWR6R2A2SLxKdeyRjjsjJ1boeLTTIFTF+UIDNGNzmWWT4nnsD+CmWYPW0vfKKW2TgJqx/DaC3S8icfZaHA+sb4QlfBnnf2kxE1/xcBDMQra+s2T12e7wMsbrB53sQhNsHMa+XNfVIYkteLp73XSIKtgxKwDHXCypW6/4ptBs+6n13OjR9EIjLddMymMns94AKOkm0ufS/UkKHul2Ai5TxfLJyegWLXk0XGeb+/FdC+w7KWiCRP5Jzqcg+kER/hnpBVDSfsZGmmAHM7UeksWhCFoPXzNRbdzfRkB6a5gUY6xnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=b6oR9AhquAkXNwE9hPP181BvC3Tkun2/4g9hZHsDceQ=; b=qrNUrUbOITe+iei2xLOHVU6EZ0Ta7ygIRMvQFiesnH4VvbABHzH1WPGxp+oKa3AtP6N5CkBu3Piyks0fQDOqTMHYp1AcMysYooVWFqR69Oz8viw2PaZ7muxXT5H11z9yYXGx8LNEP1dEI6XRw5LxhZxg6QCtQ/7a1YDwNVPinIeliQyE1rZlWIEUqKLHQbc2w8bU9Vv+i+OFnX021Z8/qDKIcVOtTZKAjAyghkBPwRlleU951DsExkBqCkcrZf1vdnu0L6Tp3pHArSQQNdS9qc63ylBy+ahCUCsoKZ12hmBOfdFqNHwgMjCX9cbX1UvnZHSwokY0zNuJROrvajD/oA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=b6oR9AhquAkXNwE9hPP181BvC3Tkun2/4g9hZHsDceQ=; b=VB/gjDX8eYHRM9KeyrIpYsFgCWKI9CsbzygVAC9o5CmGt5dkj3Ny4l/HqSRFOi+sZwEolR6hfBvS/BtTjiiKlg1Iz1LbYq/WDhETBfRRrPk3KWWfTFvSXpdNUjCGMQjlvjW6244RVEGgzA1vnBT71cOCKum0zjOJ0rhEO3r+Dm8= Received: from PH8P221CA0006.NAMP221.PROD.OUTLOOK.COM (2603:10b6:510:2d8::23) by CY8PR12MB7658.namprd12.prod.outlook.com (2603:10b6:930:9e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.5; Wed, 14 Jan 2026 16:49:22 +0000 Received: from CY4PEPF0000E9D6.namprd05.prod.outlook.com (2603:10b6:510:2d8:cafe::11) by PH8P221CA0006.outlook.office365.com (2603:10b6:510:2d8::23) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9520.5 via Frontend Transport; Wed, 14 Jan 2026 16:49:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CY4PEPF0000E9D6.mail.protection.outlook.com (10.167.241.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.1 via Frontend Transport; Wed, 14 Jan 2026 16:49:22 +0000 Received: from rric.localdomain (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Wed, 14 Jan 2026 10:49:17 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Joshua Hahn , Robert Richter Subject: [PATCH v10 05/13] cxl/region: Separate region parameter setup and region construction Date: Wed, 14 Jan 2026 17:48:21 +0100 Message-ID: <20260114164837.1076338-6-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260114164837.1076338-1-rrichter@amd.com> References: <20260114164837.1076338-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D6:EE_|CY8PR12MB7658:EE_ X-MS-Office365-Filtering-Correlation-Id: f1053b45-4674-406b-dc1a-08de538cde2c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|7416014|82310400026|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?CikRZ9TR3PHa148NsHIrEDfdSLudon9PjUmQhP35A2OporDDEhYh9bJpZ86i?= =?us-ascii?Q?Yp5+/EidfB45upM42r/RrBTQ4HwLptFbdIb/NKXvz4zjz/nsVCx/80Sd8BD9?= =?us-ascii?Q?stJtIrEkaYcew42BLdLvEZA9ZXzPQ4/ZM7ZLaYhh8LWVcj8Veovdcq4riwIT?= =?us-ascii?Q?vCkd520HBVdzHxIBL8y6uiHzN+D0VXp4Iy/ArfyarUzLUYNLvk+UaU6nXUBQ?= =?us-ascii?Q?CImkJisKixwBuM0aqU5/PO70Wi6maicv42Cf5LSEnIbqpfkHUWb62hmiz+G+?= =?us-ascii?Q?rXXPRPHLb5Hzucgb3sM2Av+F7iUvvSY9amhJiJ4Eat3vo+ILNjP7OgM6uzMk?= =?us-ascii?Q?AkK3jTAZ/2mJ1/QC24vAGxytAlnRA7I0KibnxBVMqOaW6FZ4/jrgHwLgyPPC?= =?us-ascii?Q?7t2YGpSzwco9U5NAjJeAqtQ3YjsdDLLEjFskgP2IO5nNIniDwXJK35iPXF3p?= =?us-ascii?Q?yI/PlNi1ZjB5FQtZGnnTngBS3iyawNJpBW3dATbApqbNKOJS8oYOtUU+0LCd?= =?us-ascii?Q?Cs++nt3807RdVWRSzB52wuHDJwzUta5quh/OR8+IGz+edLjkDfYaSdVc3SPI?= =?us-ascii?Q?xPXLtCANVhStwZnz/8hnPxpqgZsx8Ja0K1IBuw8b1JRB4EXvVSGitm0ZvgQu?= =?us-ascii?Q?2mMpHz+jYd9CZt4nMeZ2sUd4cV85aAM9L+cChVjVxEBrTEII9dKgCCqyPlp9?= =?us-ascii?Q?VesEfSJ/Ik9i7jqkxcvtjr239W+Ff9hGuvMvwHQrSY6LUM3WWtp/DHl8/66m?= =?us-ascii?Q?PGtldXwYh6NqiHjsaZNmkD6K5IpaiauyH0cwz8hQX2Gtu0SiVb16WpcaXGFg?= =?us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.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(376014)(7416014)(82310400026)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jan 2026 16:49:22.0333 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f1053b45-4674-406b-dc1a-08de538cde2c X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D6.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7658 Content-Type: text/plain; charset="utf-8" To construct a region, the region parameters such as address range and interleaving config need to be determined. This is done while constructing the region by inspecting the endpoint decoder configuration. The endpoint decoder is passed as a function argument. With address translation the endpoint decoder data is no longer sufficient to extract the region parameters as some of the information is obtained using other methods such as using firmware calls. In a first step, separate code to determine the region parameters from the region construction. Temporarily store all the data to create the region in the new struct cxl_region_context. Once the region data is determined and struct cxl_region_context is filled, construct the region. Patch is a prerequisite to implement address translation. The code separation helps to later extend it to determine region parameters using other methods as needed, esp. to support address translation. Reviewed-by: Gregory Price Reviewed-by: Dave Jiang Reviewed-by: Jonathan Cameron Reviewed-by: Alison Schofield Tested-by: Gregory Price Signed-off-by: Robert Richter reviewed-by tags and the small update in the description of 13/13? --- drivers/cxl/core/core.h | 8 ++++++++ drivers/cxl/core/region.c | 27 ++++++++++++++++++--------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/drivers/cxl/core/core.h b/drivers/cxl/core/core.h index 1fb66132b777..ae9e1bb51562 100644 --- a/drivers/cxl/core/core.h +++ b/drivers/cxl/core/core.h @@ -19,6 +19,14 @@ enum cxl_detach_mode { }; =20 #ifdef CONFIG_CXL_REGION + +struct cxl_region_context { + struct cxl_endpoint_decoder *cxled; + struct range hpa_range; + int interleave_ways; + int interleave_granularity; +}; + extern struct device_attribute dev_attr_create_pmem_region; extern struct device_attribute dev_attr_create_ram_region; extern struct device_attribute dev_attr_delete_region; diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 04c3ff66ec81..5ae77e9feb4d 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3565,11 +3565,12 @@ static int cxl_extended_linear_cache_resize(struct = cxl_region *cxlr, } =20 static int __construct_region(struct cxl_region *cxlr, - struct cxl_endpoint_decoder *cxled) + struct cxl_region_context *ctx) { + struct cxl_endpoint_decoder *cxled =3D ctx->cxled; struct cxl_root_decoder *cxlrd =3D cxlr->cxlrd; struct cxl_memdev *cxlmd =3D cxled_to_memdev(cxled); - struct range *hpa_range =3D &cxled->cxld.hpa_range; + struct range *hpa_range =3D &ctx->hpa_range; struct cxl_region_params *p; struct resource *res; int rc; @@ -3622,8 +3623,8 @@ static int __construct_region(struct cxl_region *cxlr, } =20 p->res =3D res; - p->interleave_ways =3D cxled->cxld.interleave_ways; - p->interleave_granularity =3D cxled->cxld.interleave_granularity; + p->interleave_ways =3D ctx->interleave_ways; + p->interleave_granularity =3D ctx->interleave_granularity; p->state =3D CXL_CONFIG_INTERLEAVE_ACTIVE; =20 rc =3D sysfs_update_group(&cxlr->dev.kobj, get_cxl_region_target_group()); @@ -3643,8 +3644,9 @@ static int __construct_region(struct cxl_region *cxlr, =20 /* Establish an empty region covering the given HPA range */ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd, - struct cxl_endpoint_decoder *cxled) + struct cxl_region_context *ctx) { + struct cxl_endpoint_decoder *cxled =3D ctx->cxled; struct cxl_memdev *cxlmd =3D cxled_to_memdev(cxled); struct cxl_port *port =3D cxlrd_to_port(cxlrd); struct cxl_dev_state *cxlds =3D cxlmd->cxlds; @@ -3664,7 +3666,7 @@ static struct cxl_region *construct_region(struct cxl= _root_decoder *cxlrd, return cxlr; } =20 - rc =3D __construct_region(cxlr, cxled); + rc =3D __construct_region(cxlr, ctx); if (rc) { devm_release_action(port->uport_dev, unregister_region, cxlr); return ERR_PTR(rc); @@ -3689,11 +3691,18 @@ cxl_find_region_by_range(struct cxl_root_decoder *c= xlrd, =20 int cxl_add_to_region(struct cxl_endpoint_decoder *cxled) { - struct range *hpa_range =3D &cxled->cxld.hpa_range; + struct cxl_region_context ctx; struct cxl_region_params *p; bool attach =3D false; int rc; =20 + ctx =3D (struct cxl_region_context) { + .cxled =3D cxled, + .hpa_range =3D cxled->cxld.hpa_range, + .interleave_ways =3D cxled->cxld.interleave_ways, + .interleave_granularity =3D cxled->cxld.interleave_granularity, + }; + struct cxl_root_decoder *cxlrd __free(put_cxl_root_decoder) =3D cxl_find_root_decoder(cxled); if (!cxlrd) @@ -3706,9 +3715,9 @@ int cxl_add_to_region(struct cxl_endpoint_decoder *cx= led) */ mutex_lock(&cxlrd->range_lock); struct cxl_region *cxlr __free(put_cxl_region) =3D - cxl_find_region_by_range(cxlrd, hpa_range); + cxl_find_region_by_range(cxlrd, &ctx.hpa_range); if (!cxlr) - cxlr =3D construct_region(cxlrd, cxled); + cxlr =3D construct_region(cxlrd, &ctx); mutex_unlock(&cxlrd->range_lock); =20 rc =3D PTR_ERR_OR_ZERO(cxlr); --=20 2.47.3 From nobody Sat Feb 7 04:47:22 2026 Received: from CH5PR02CU005.outbound.protection.outlook.com (mail-northcentralusazon11012010.outbound.protection.outlook.com [40.107.200.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 910AE3A4F31; Wed, 14 Jan 2026 16:49:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.200.10 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768409374; cv=fail; b=txYw5q1diarARX+MDxExHmrtIrTKERlbJsOziqXBheyMre7fobX5byFYXDNj/j/cwHyx9NxNNV+XmP+yohUhys1zWSRrQfAod8WRcYBXOPCg/22lAhaFlL0VB/jRJKqnr11eJSVcJ2BsK796TaofTqUwLvBraPFdK36IoarHPDI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768409374; c=relaxed/simple; bh=T2qZEc/Ds2t6IpxQFVAFGLA/D8M6yB3z4oAHURgNLNc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MLKWz6ikprov9QaS8WVJiQ0qEy5degBNZawgpVdehWr/1rJMNxBSZbL11X5rIXAY5y+YB+9uDLWeJAuKDP9AaphIhjbZnb0DMZvfewzWBWmxFU6IvoZIjI/z9AqpDof4/quTponxhzkYmLZBxjP39CLPR6N9KjoKrMyjD4Wj5jc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=vk9kJM/o; arc=fail smtp.client-ip=40.107.200.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="vk9kJM/o" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=j9SXBdBOJgOp6+yXBkWqLwyp85PbW/ICCTR7/6qJQPABmVRVnkqayEe7qaoiN37ypv978Oq9r8j0JwTJ5zqMbHsyFuR2PHPKo+cJF5LKO33P+Z6zNfSwCnNKYlcMbf58K3+HB2q4b8aY3HnjMTTLpkNyfnVqazAJI+pJZJ7ZqO5CQjks7UZFi5qC6jUf3GN2mpwW8CD9V2z9uEJkt3ewqUbXKSU8gBliAPWHRH5xAfsIOe4xjpoqCS+L1GD5IrSbzzJbAfyjrjfy5QkAlW5ozWZrwplYFkosPxSMOejTQcahbPKOM9HP8+qgfcwu/ae2oQZubrwtz2b1r9EZsFy0Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LX/LOzeTAkunfGV6Z5ekrVicZNBFsREdr+CYHlAh250=; b=nEHg77TtDWkFqJWKhfPcuh9DeVScvdlglDG+PQKe2BDR2lEfJEUQ6vv2scnqf5gETzPqg0DlGDGnu+7svNeFUtaUE/JVfI3oMuExe6zDBiRz9uQS1agmJo0FsjYvLcoj+avMaKYR1Ol0Fv22t350tCAsXERvfZt39jO4cVJyZjDbTwU86dGBv5RtFXHqMCl0feqIeaG6Zzy2Y9tynvNMj9Gvw3x5KAK6yBi02wPHuz2jH308i8Np/BmujEVq0x4T/HYpfCMVlaucXbc5TKQQJKzNjpCTfX2xBaEwJ22o4fBaYG6y3d3y9vwvawMkxOckRXbt7lXzN/AVugHviYHXtg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LX/LOzeTAkunfGV6Z5ekrVicZNBFsREdr+CYHlAh250=; b=vk9kJM/oOEIwo/9JMfb2fFIigH2RS7nDg6TTBMyM1tNxI81nu4JI8dcwAwixXKv6gk1BQxfXlHY9rdUxUOQYgCG27Ll62//sZqn+Rh3iL5r1cdwOwc4N3fYyd62FSs6iO7BdKoYUSK1jXmWduRMktTKGmH88/trP1n0TXX8R5Tk= Received: from PH8P221CA0007.NAMP221.PROD.OUTLOOK.COM (2603:10b6:510:2d8::25) by SA0PR12MB4350.namprd12.prod.outlook.com (2603:10b6:806:92::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.5; Wed, 14 Jan 2026 16:49:24 +0000 Received: from CY4PEPF0000E9D6.namprd05.prod.outlook.com (2603:10b6:510:2d8:cafe::31) by PH8P221CA0007.outlook.office365.com (2603:10b6:510:2d8::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9520.5 via Frontend Transport; Wed, 14 Jan 2026 16:49:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CY4PEPF0000E9D6.mail.protection.outlook.com (10.167.241.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.1 via Frontend Transport; Wed, 14 Jan 2026 16:49:24 +0000 Received: from rric.localdomain (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Wed, 14 Jan 2026 10:49:21 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Joshua Hahn , Robert Richter Subject: [PATCH v10 06/13] cxl/region: Add @hpa_range argument to function cxl_calc_interleave_pos() Date: Wed, 14 Jan 2026 17:48:22 +0100 Message-ID: <20260114164837.1076338-7-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260114164837.1076338-1-rrichter@amd.com> References: <20260114164837.1076338-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D6:EE_|SA0PR12MB4350:EE_ X-MS-Office365-Filtering-Correlation-Id: 54e64005-82e7-4906-9af9-08de538cdf98 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|7416014|1800799024|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?3vxVJ01mHqNjVRJMo8W00c2OjXKVJ0JYCh9Lz9AlNm+Ww37Bmw8rKnkYKdgT?= =?us-ascii?Q?teyPcbz7Ffw5YX/FahoO80AKz7hEg2RjXfu7sJryZ3FjDA6xIkHzG4+vgHmT?= =?us-ascii?Q?rDfKwiLSfCPTSo0jNWKYcz+yx/TFmwiyHWmQNXCuzV6XaF11x5AAK6rLR1Ed?= =?us-ascii?Q?5lI3CMveCkr4M2yXY3USvQTevgYkMYufNcciG6xOzHL1pHtqfcWkmbiJ0yUh?= =?us-ascii?Q?vNhiS3HTf/BPE9yveSQcMG5p8bh4uGEGFmYpGi5gce14HnG0ReQjqJdz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tM+IHd5vKmI+GbZPAlh5iZquLt3SY9KwdICb5K1KXzjeRvA5?= =?us-ascii?Q?HR+PB6W9kSd5U/e7lQVsaiuNRKR01t+1Ej0mkbpZIzKUNKx4k5irXxbWGnmN?= =?us-ascii?Q?FhFsCp3bjP7qqds/cW6sib25lDepKGFuEuK98r2qF3NxjFF6bpYm5YpwwXfb?= =?us-ascii?Q?MlvuR9cI1Se4xb0lMgVfwVoxAvspoGIKLWPzSGeM6RJoaJ79Af1EQudopXCe?= =?us-ascii?Q?G/0UsZ9m8Srp2H3GC6NMr3mvSsZW623Zr1xseoseJ5bI4RBaQQgkUVlDITv+?= =?us-ascii?Q?x4GlMW5rZ4Uc4743GsQ88ArzTZ3FhCCm9+poYQY2K7Tr5vbAMY7/11C8dpSe?= =?us-ascii?Q?WQ+KBE6F2PmdPIyPt229mM0aCj1rlVIpnMUGl8PKOvmuPun/cFbV9VAt6ee5?= =?us-ascii?Q?Y6WMk5V/7hnMcwd/hn3yVOr8kQ36+i9Afa/Uw+MWqGmLbEQzn7SWohRuls2p?= =?us-ascii?Q?X2P231HgLC+e3esfLaQDkouAtxNLlqm9MEMfBW4KxBUeosX+0D1TKuC/AIA9?= =?us-ascii?Q?Q2KQHw=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(376014)(7416014)(1800799024)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jan 2026 16:49:24.4167 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 54e64005-82e7-4906-9af9-08de538cdf98 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D6.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4350 Content-Type: text/plain; charset="utf-8" cxl_calc_interleave_pos() uses the endpoint decoder's HPA range to determine its interleaving position. This requires the endpoint decoders to be an SPA, which is not the case for systems that need address translation. Add a separate @hpa_range argument to function cxl_calc_interleave_pos() to specify the address range. Now it is possible to pass the SPA translated address range of an endpoint decoder to function cxl_calc_interleave_pos(). Refactor only, no functional changes. Patch is a prerequisite to implement address translation. Reviewed-by: Gregory Price Reviewed-by: Dave Jiang Reviewed-by: Jonathan Cameron Reviewed-by: Alison Schofield Tested-by: Gregory Price Signed-off-by: Robert Richter reviewed-by tags and the small update in the description of 13/13? --- drivers/cxl/core/region.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 5ae77e9feb4d..60d2d1dae2aa 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -1878,6 +1878,7 @@ static int find_pos_and_ways(struct cxl_port *port, s= truct range *range, /** * cxl_calc_interleave_pos() - calculate an endpoint position in a region * @cxled: endpoint decoder member of given region + * @hpa_range: translated HPA range of the endpoint * * The endpoint position is calculated by traversing the topology from * the endpoint to the root decoder and iteratively applying this @@ -1890,11 +1891,11 @@ static int find_pos_and_ways(struct cxl_port *port,= struct range *range, * Return: position >=3D 0 on success * -ENXIO on failure */ -static int cxl_calc_interleave_pos(struct cxl_endpoint_decoder *cxled) +static int cxl_calc_interleave_pos(struct cxl_endpoint_decoder *cxled, + struct range *hpa_range) { struct cxl_port *iter, *port =3D cxled_to_port(cxled); struct cxl_memdev *cxlmd =3D cxled_to_memdev(cxled); - struct range *range =3D &cxled->cxld.hpa_range; int parent_ways =3D 0, parent_pos =3D 0, pos =3D 0; int rc; =20 @@ -1932,7 +1933,8 @@ static int cxl_calc_interleave_pos(struct cxl_endpoin= t_decoder *cxled) if (is_cxl_root(iter)) break; =20 - rc =3D find_pos_and_ways(iter, range, &parent_pos, &parent_ways); + rc =3D find_pos_and_ways(iter, hpa_range, &parent_pos, + &parent_ways); if (rc) return rc; =20 @@ -1942,7 +1944,7 @@ static int cxl_calc_interleave_pos(struct cxl_endpoin= t_decoder *cxled) dev_dbg(&cxlmd->dev, "decoder:%s parent:%s port:%s range:%#llx-%#llx pos:%d\n", dev_name(&cxled->cxld.dev), dev_name(cxlmd->dev.parent), - dev_name(&port->dev), range->start, range->end, pos); + dev_name(&port->dev), hpa_range->start, hpa_range->end, pos); =20 return pos; } @@ -1955,7 +1957,7 @@ static int cxl_region_sort_targets(struct cxl_region = *cxlr) for (i =3D 0; i < p->nr_targets; i++) { struct cxl_endpoint_decoder *cxled =3D p->targets[i]; =20 - cxled->pos =3D cxl_calc_interleave_pos(cxled); + cxled->pos =3D cxl_calc_interleave_pos(cxled, &cxlr->hpa_range); /* * Record that sorting failed, but still continue to calc * cxled->pos so that follow-on code paths can reliably @@ -2139,7 +2141,7 @@ static int cxl_region_attach(struct cxl_region *cxlr, struct cxl_endpoint_decoder *cxled =3D p->targets[i]; int test_pos; =20 - test_pos =3D cxl_calc_interleave_pos(cxled); + test_pos =3D cxl_calc_interleave_pos(cxled, &cxlr->hpa_range); dev_dbg(&cxled->cxld.dev, "Test cxl_calc_interleave_pos(): %s test_pos:%d cxled->pos:%d\n", (test_pos =3D=3D cxled->pos) ? "success" : "fail", --=20 2.47.3 From nobody Sat Feb 7 04:47:22 2026 Received: from PH7PR06CU001.outbound.protection.outlook.com (mail-westus3azon11010032.outbound.protection.outlook.com [52.101.201.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0DEF63A4F29; Wed, 14 Jan 2026 16:49:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.201.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768409375; cv=fail; b=JmZjCWaVo+AfkVMkV0TaAz2K6K7uaz4xMSEsTz4tHQb1XUMNNqZpYyA8hCG5CV49aQQZtmeCnDVKX9gaj89jI1AX1Qh2I5DcdxKhyFdBIX48TfNd8UaBCSdE+txsJOz8E5B7VlJgXegc9AaGAjVgV9hXgA13d8Q2v1oLxshWCPE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768409375; c=relaxed/simple; bh=Rdzn5RG8r55Jz4OAE6FIcXYQ9R2LKeQCPJmEfgh/JuE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JEfOR9BF2xxvfD23XQjtZRRbuKLcJtX8iBw7TTsui+UiQpJaM4lmB6kFRv5m/Vuo1B7leZftTAvdkCE1osGtSrNVDGNSOTWw/xjjB3sqwdKWA0M8MRA0Aw07Wg1uqvbU/cPsM2ZWUAKCqFWyDNg3yPq7nPCZ45OWpUFczwXqPho= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=d1LdVVI5; arc=fail smtp.client-ip=52.101.201.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="d1LdVVI5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lWJT73qglpeAuT6Ka3kogJ9gbwyN0ITtidcAg41rvSGEJ0/TGrEW38HCIn3EdfMupM+urzgH6Uk9yCM+V28zT+dk4DR6ZnuZ8h6nd6c/TXayE4DThPAdalGBvXkZCKgyy5D0sSoJxFCo97mnskfVRzcsBfHQZpv01pg32qrssGHfa+88Y1nr0VinMc68wyU5w1LyyqhoZ4ESkYvGP0+9JGYKtmMAfS7bQNhX2mIhgEaUlojRW2/KCx5NgVz5tjDZvIJLDa2u2nga+eSjLaO0jT1YkGNrtCR40OFGIOB3byf3ecrn7VPzyyxFeMp6SKNmxPkoBFPX/GgGuEYcG6y+GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3ALj0oluNqm6lY7NXL6PkLUOkvq/nPzIV/Py/V2sR30=; b=rEDEHKAeEcqEuZ/QrKJmIkrYVKd13Xlp3kj59NuasNXgs6mAzmfsDI7NfkCMn4RA9NechwtEwG90COx1Nv1ag7aVGKSnvYsFKGd2ztsmh2MTvb8GjQIgEAYDVHCtsV8LkzXkpvoTsIFggU8LNfQotSrLw6CfVEbyuO/NO+cb4bOfaG1A8JYru4fSnv8m+gB5m9Bh+JLV8RLPyS4fLKnFq82R5+WgR72+GHj4ah0kYMRVqZFRIKoVJfNe5ZTD/Q7+J9VStLD5bCXBpv3SXcj0Kdk7L9eNwSyk0Lihb587hJ0foO5ZgzSIiRiBpojvCdYNmSygqsFl45Ncpii5FP58dg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3ALj0oluNqm6lY7NXL6PkLUOkvq/nPzIV/Py/V2sR30=; b=d1LdVVI57POjSqkht+zwDb5ruE8ZWYJS+Ru9ty4Q81U6+RAwvkbpcWpbkH46A4O1VwA9em9IihBNuRZZ7AoPXeh2NCo68HiHW5v64LvDB82nU0ETu4twLtHkdsTqGkPMSJSyL1ZcfE/QLY902HIfqzj9SSnVdmoCIb24/P3MIR4= Received: from PH8P221CA0001.NAMP221.PROD.OUTLOOK.COM (2603:10b6:510:2d8::16) by IA1PR12MB8077.namprd12.prod.outlook.com (2603:10b6:208:3f4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.5; Wed, 14 Jan 2026 16:49:30 +0000 Received: from CY4PEPF0000E9D6.namprd05.prod.outlook.com (2603:10b6:510:2d8:cafe::d3) by PH8P221CA0001.outlook.office365.com (2603:10b6:510:2d8::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9520.5 via Frontend Transport; Wed, 14 Jan 2026 16:49:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CY4PEPF0000E9D6.mail.protection.outlook.com (10.167.241.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.1 via Frontend Transport; Wed, 14 Jan 2026 16:49:29 +0000 Received: from rric.localdomain (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Wed, 14 Jan 2026 10:49:24 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Joshua Hahn , Robert Richter Subject: [PATCH v10 07/13] cxl/region: Use region data to get the root decoder Date: Wed, 14 Jan 2026 17:48:23 +0100 Message-ID: <20260114164837.1076338-8-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260114164837.1076338-1-rrichter@amd.com> References: <20260114164837.1076338-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D6:EE_|IA1PR12MB8077:EE_ X-MS-Office365-Filtering-Correlation-Id: 6a010890-1423-40a3-1f4f-08de538ce2bd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|7416014|82310400026|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?1OSSrHayjytNRGKmFUnaayBoMTke8hv+xcCrIJ69sQ0ablkjDjs60+W/Hibw?= =?us-ascii?Q?QFsV5jh9tp2e3JBMOV0vH5uFxE9y88kRq3tPEBpDPVo6TJu3Jgg0yL7R3Ezx?= =?us-ascii?Q?CzVg+kEF7UlakdI1Wod8P59rI0Pw9a/XmBfhWkkc4sodI0caHZliK+SPiCIY?= =?us-ascii?Q?FIhurdjlHn0z/5wZ8V3eC68dO6v4am5aNMawUu1/cZYQj79GmWOR+QY6wgpZ?= =?us-ascii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+TsUy4u+Z/yG88nfFnY?= =?us-ascii?Q?+HnFCjFcNu3UdWv6cBqGLMwloiEA9dEWm3/xTePVRsPwciXCVH1gdeLwe6XR?= =?us-ascii?Q?DeIxvdb7UdAeU14Jh2KOYV6UWO9NypSe3fSOh1zSoj9dDkXE++DvP5IekguC?= =?us-ascii?Q?Og12e1vJ85GGQcxo9Z32o862wTpDxNtA2g40IgcyBz4ndrxh1i4kiqNgKkfJ?= =?us-ascii?Q?izmH468zlDJe2XX/F0xXfLjPbY97LVSW/aPI871G8gw1R4kGcQN/05LPm4WU?= =?us-ascii?Q?/hIVhOuenxWAr465KWOCeGpGDrJH8WxMUcPL840r8m2oFI8fXoxyooroPNdp?= =?us-ascii?Q?9U9sV79NcmT2EweHLX546aW2kVcnPuyxrNsFepOtTpO4ii6fPeoYFB5Wfif2?= =?us-ascii?Q?2sVxECJIzI3xCvvwDkBPJ3nIyCIVcNZq1MR+BMAaW2IPu9PGDvirc8G701xB?= =?us-ascii?Q?Nyo9QWhaRzAGMhzkUnBJtSJ1rBxRPgnej6nBTekdfFuTRMXfNGV1sYYGBm65?= =?us-ascii?Q?XCD9MHwORYhYFpJpwSTGcDNdpeVClsFDzXq6SJ7toc9k/B5L6T64ZD4Btton?= =?us-ascii?Q?Fmug7w=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(376014)(7416014)(82310400026)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jan 2026 16:49:29.6824 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6a010890-1423-40a3-1f4f-08de538ce2bd X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D6.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8077 Content-Type: text/plain; charset="utf-8" To find a region's root decoder, the endpoint's HPA range is used to search the matching decoder by its range. With address translation the endpoint decoder's range is in a different address space and thus cannot be used to determine the root decoder. The region parameters are encapsulated within struct cxl_region_context and may include the translated Host Physical Address (HPA) range. Use this context to identify the root decoder rather than relying on the endpoint. Modify cxl_find_root_decoder() and add the region context as parameter. Rename this function to get_cxl_root_decoder() as a counterpart to put_cxl_root_decoder(). Simplify the implementation by removing function cxl_port_find_switch_decode(). The function is unnecessary because it is not referenced or utilized elsewhere in the code. Reviewed-by: Dave Jiang Reviewed-by: Jonathan Cameron Reviewed-by: Alison Schofield Tested-by: Gregory Price Signed-off-by: Robert Richter reviewed-by tags and the small update in the description of 13/13? --- drivers/cxl/core/region.c | 50 +++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 60d2d1dae2aa..912796fd708e 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3469,47 +3469,44 @@ static int devm_cxl_add_dax_region(struct cxl_regio= n *cxlr) return rc; } =20 -static int match_decoder_by_range(struct device *dev, const void *data) +static int match_root_decoder(struct device *dev, const void *data) { const struct range *r1, *r2 =3D data; - struct cxl_decoder *cxld; + struct cxl_root_decoder *cxlrd; =20 - if (!is_switch_decoder(dev)) + if (!is_root_decoder(dev)) return 0; =20 - cxld =3D to_cxl_decoder(dev); - r1 =3D &cxld->hpa_range; - return range_contains(r1, r2); -} - -static struct cxl_decoder * -cxl_port_find_switch_decoder(struct cxl_port *port, struct range *hpa_rang= e) -{ - struct device *cxld_dev =3D device_find_child(&port->dev, hpa_range, - match_decoder_by_range); + cxlrd =3D to_cxl_root_decoder(dev); + r1 =3D &cxlrd->cxlsd.cxld.hpa_range; =20 - return cxld_dev ? to_cxl_decoder(cxld_dev) : NULL; + return range_contains(r1, r2); } =20 +/* + * Note, when finished with the device, drop the reference with + * put_device() or use the put_cxl_root_decoder helper. + */ static struct cxl_root_decoder * -cxl_find_root_decoder(struct cxl_endpoint_decoder *cxled) +get_cxl_root_decoder(struct cxl_endpoint_decoder *cxled, + struct cxl_region_context *ctx) { struct cxl_memdev *cxlmd =3D cxled_to_memdev(cxled); struct cxl_port *port =3D cxled_to_port(cxled); struct cxl_root *cxl_root __free(put_cxl_root) =3D find_cxl_root(port); - struct cxl_decoder *root, *cxld =3D &cxled->cxld; - struct range *hpa_range =3D &cxld->hpa_range; + struct device *cxlrd_dev; =20 - root =3D cxl_port_find_switch_decoder(&cxl_root->port, hpa_range); - if (!root) { + cxlrd_dev =3D device_find_child(&cxl_root->port.dev, &ctx->hpa_range, + match_root_decoder); + if (!cxlrd_dev) { dev_err(cxlmd->dev.parent, "%s:%s no CXL window for range %#llx:%#llx\n", - dev_name(&cxlmd->dev), dev_name(&cxld->dev), - hpa_range->start, hpa_range->end); - return NULL; + dev_name(&cxlmd->dev), dev_name(&cxled->cxld.dev), + ctx->hpa_range.start, ctx->hpa_range.end); + return ERR_PTR(-ENXIO); } =20 - return to_cxl_root_decoder(&root->dev); + return to_cxl_root_decoder(cxlrd_dev); } =20 static int match_region_by_range(struct device *dev, const void *data) @@ -3706,9 +3703,10 @@ int cxl_add_to_region(struct cxl_endpoint_decoder *c= xled) }; =20 struct cxl_root_decoder *cxlrd __free(put_cxl_root_decoder) =3D - cxl_find_root_decoder(cxled); - if (!cxlrd) - return -ENXIO; + get_cxl_root_decoder(cxled, &ctx); + + if (IS_ERR(cxlrd)) + return PTR_ERR(cxlrd); =20 /* * Ensure that, if multiple threads race to construct_region() --=20 2.47.3 From nobody Sat Feb 7 04:47:22 2026 Received: from CO1PR03CU002.outbound.protection.outlook.com (mail-westus2azon11010008.outbound.protection.outlook.com [52.101.46.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2380B3A6412; Wed, 14 Jan 2026 16:49:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.46.8 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768409385; cv=fail; b=B8acNh+1uEX1RtObinHDhOQUog45N8wwdvZo4SWu8t+tSD6QaZ9OT9tX5xr2E8odnD5V+BScTg09n7cIDTITnMHaE7hNVBUxv+v3jIbIBkhsNh1etED6kfviIpn3YhnPqNujU9CMCFtcA5phxPEQqs/EdrPbCGP71ORBNU6bpIc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768409385; c=relaxed/simple; bh=OaYlsG0W9qiNW3r8wewMyj1q1ORAUzkzIEioR6a+yxU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=C6uKnKhy/FmpEVGvaX8Oa2wBSMKItxMUP3Tenoz6Cufp0UCaWPjLbT9JCvp4lMSMS4u5QnSEBZbT/ipr2mGAVDutq1lajpdeMdBWlJ4JHuHIr1fCPcnTGryygntEmhD+IyGayh6jROIp9ICxY0SK8BEc7nbVGrBfDgxdAjw+ZrY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=NHPF7uij; arc=fail smtp.client-ip=52.101.46.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="NHPF7uij" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dfeI+ciiYWP26dh6bdas/JyUeYp5PliJ5D1QP9wZlsAdsFpdKUsRR5IlaMNMwEYTE+IWBzOy53BtLLs5zUFmH2LGjPCp20nazdflfJ7RoJYfDc/rcZ9iOpv1qc9II0iPYFh8iqDyNzTpKm6sHdVzv3pXAT7wWmyJgSzSimsBTOS4xcNiLd2YpZhc2Yt6ayDagvXGdfLe3LH5TPeDQbe+N3Ay0p5r6fXWZpnOhhPIgapAqpXFHUz0DgG0RsSlw6UCF52EHw9mBlipodCFxOi0zzEPnX6Tvb2HP8bVKkwytiwHHvD6vQlauNGlixyYfdbgfPnFi4KX2e28vV+V1EeSow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=FzbBkRt07st8+BxfIZZdpJmdVxeK9lvPNgG21+xk+jI=; b=CSEMg0ZAYav5Ne1Vjwu9y/6r3OVx70cGvguMjz4eIPe7iyR75Qv7hnRNC58nB3KA1o8K1rJJblsPsyNXosWvyntqlWebXzk6zyZW/f5fUc4rpaWiZifAvqSTn+H112ptwbrnL8LATNMbUSxbhub/9zFFIjmH5F89/lDZy618JJ/lud/eBLlX7ka1Rs7GENy0aNX8jkl9Ffh8zg0PyP1OUbxSDVAQec7KJ+RkJy6Y2uu1R8O6DHob7VpF/AQh3MshekjGMYSb+AYmEzvbPwaLZk8NC+Z7HYnud4ELp+8MTMJl24EKYRHLfLB5umOj27zEK4ra3KCX6wKefb6Lh61+Ew== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FzbBkRt07st8+BxfIZZdpJmdVxeK9lvPNgG21+xk+jI=; b=NHPF7uijsUT4RLfiUor/BoUelU3roBsujLPzxPdb1HGYl1HhdbTbAQbHqsw7WxYDapHY/TykOLewxgSf2MRZZ2Hz9kjKZf9vmIBLRDshhjcqJ1LEkrHSTe3ffO58HUY9+yly/dQYpn4Vk/ZUdtxM9IY8b15hG3bCglpfkhaVf2I= Received: from PH8P221CA0027.NAMP221.PROD.OUTLOOK.COM (2603:10b6:510:2d8::6) by SN7PR12MB6864.namprd12.prod.outlook.com (2603:10b6:806:263::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9499.7; Wed, 14 Jan 2026 16:49:33 +0000 Received: from CY4PEPF0000E9D6.namprd05.prod.outlook.com (2603:10b6:510:2d8:cafe::ed) by PH8P221CA0027.outlook.office365.com (2603:10b6:510:2d8::6) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9520.4 via Frontend Transport; Wed, 14 Jan 2026 16:49:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CY4PEPF0000E9D6.mail.protection.outlook.com (10.167.241.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.1 via Frontend Transport; Wed, 14 Jan 2026 16:49:33 +0000 Received: from rric.localdomain (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Wed, 14 Jan 2026 10:49:27 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Joshua Hahn , Robert Richter Subject: [PATCH v10 08/13] cxl: Introduce callback for HPA address ranges translation Date: Wed, 14 Jan 2026 17:48:24 +0100 Message-ID: <20260114164837.1076338-9-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260114164837.1076338-1-rrichter@amd.com> References: <20260114164837.1076338-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D6:EE_|SN7PR12MB6864:EE_ X-MS-Office365-Filtering-Correlation-Id: 894ce909-9936-4ff5-3cf8-08de538ce4c3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|82310400026|1800799024|7053199007; X-Microsoft-Antispam-Message-Info: =?utf-8?B?OTIvczNleDVSa1Jyc3VxVXV2WnFIdlp6T0VKdXpramI1V0lZdHBVSTBLaXd3?= =?utf-8?B?V3hBMkhlejRjT25pWklJd3MyeG9mRDFwK0lBN01OTndzNWQ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VM4cEVJVnBiQTRZeC9RZm5pb2FsMmh2NXN4T3ZlM2xG?= =?utf-8?B?RGQ1VU4vcklHQlRSUW5mckptM3VSM09HcFV3cjQxSDZMcEFSbUdmR2tpQlVQ?= =?utf-8?B?d0U5YjM5ZWhrOFBWSzdTUjRDY0ZIdWVBL0JqdDRMbDdZNFlOSit3SXROM3p4?= =?utf-8?B?SWdBTUpTL3hnNlo3aHVWYkpMaDJ1WUhjK3RwV2VCUEhLOTc2Q2RvZms4ZUxu?= =?utf-8?B?OFFwNUhDZFRDakt1NnhuZEdLVEp6cW94bVFFbnhkcTZsNTZIUzVzRW5sOUxX?= =?utf-8?B?TnU3MUJyYXBpNTAxMTZrM2ZSZlYzR2drYjBQQmlYZXI2N0FQaUFmMzMySVVs?= =?utf-8?B?TFo3ZFhFM1NHVkZib3U4QUNidnZBPT0=?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(36860700013)(82310400026)(1800799024)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jan 2026 16:49:33.1079 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 894ce909-9936-4ff5-3cf8-08de538ce4c3 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D6.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6864 Introduce a callback to translate an endpoint's HPA range to the address range of the root port which is the System Physical Address (SPA) range used by a region. The callback can be set if a platform needs to handle address translation. The callback is attached to the root port. An endpoint's root port can easily be determined in the PCI hierarchy without any CXL specific knowledge. This allows the early use of address translation for CXL enumeration. Address translation is esp. needed for the detection of the root decoders. Thus, the callback is embedded in struct cxl_root_ops instead of struct cxl_rd_ops. Reviewed-by: Dave Jiang Reviewed-by: Jonathan Cameron Reviewed-by: Alison Schofield Tested-by: Gregory Price Signed-off-by: Robert Richter reviewed-by tags and the small update in the description of 13/13? --- drivers/cxl/core/region.c | 24 ++++++++++++++++++++++++ drivers/cxl/cxl.h | 1 + 2 files changed, 25 insertions(+) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 912796fd708e..ed8469fa55a9 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3483,6 +3483,15 @@ static int match_root_decoder(struct device *dev, co= nst void *data) return range_contains(r1, r2); } =20 +static int cxl_root_setup_translation(struct cxl_root *cxl_root, + struct cxl_region_context *ctx) +{ + if (!cxl_root->ops.translation_setup_root) + return 0; + + return cxl_root->ops.translation_setup_root(cxl_root, ctx); +} + /* * Note, when finished with the device, drop the reference with * put_device() or use the put_cxl_root_decoder helper. @@ -3495,6 +3504,21 @@ get_cxl_root_decoder(struct cxl_endpoint_decoder *cx= led, struct cxl_port *port =3D cxled_to_port(cxled); struct cxl_root *cxl_root __free(put_cxl_root) =3D find_cxl_root(port); struct device *cxlrd_dev; + int rc; + + /* + * Adjust the endpoint's HPA range and interleaving + * configuration to the root decoder=E2=80=99s memory space before + * setting up the root decoder. + */ + rc =3D cxl_root_setup_translation(cxl_root, ctx); + if (rc) { + dev_err(cxlmd->dev.parent, + "%s:%s Failed to setup translation for address range %#llx:%#llx\n", + dev_name(&cxlmd->dev), dev_name(&cxled->cxld.dev), + ctx->hpa_range.start, ctx->hpa_range.end); + return ERR_PTR(rc); + } =20 cxlrd_dev =3D device_find_child(&cxl_root->port.dev, &ctx->hpa_range, match_root_decoder); diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index 0e15dc6e169f..8ea334d81edf 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -652,6 +652,7 @@ struct cxl_root_ops { int (*qos_class)(struct cxl_root *cxl_root, struct access_coordinate *coord, int entries, int *qos_class); + int (*translation_setup_root)(struct cxl_root *cxl_root, void *data); }; =20 /** --=20 2.47.3 From nobody Sat Feb 7 04:47:22 2026 Received: from BYAPR05CU005.outbound.protection.outlook.com (mail-westusazon11010013.outbound.protection.outlook.com [52.101.85.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBE903A4F2E; Wed, 14 Jan 2026 16:49:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.85.13 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768409395; cv=fail; b=ss6/KtkLLlpOcOqDRQ2ySiZBmaVgzOZgu7IeIHF4bHRnpVCrUEnMjWK6wNMLNcVNNTgqaUTjH98wwOVa/UbX23bxyJIX+vKm5WOsTTUj6P+DYnyFr9wiubxuIfXormlDPhv763effFYRxjl/goPRlVrrucmxvlZVWn+TGlmeTWY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768409395; c=relaxed/simple; bh=qyyseSAGmUDBFvA5yNM8iK8z0TcjhT6VxbNBmEltT38=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ll2nUcgJ1+50eJrZ1nknIEF2DTqjA9CpeoeCwnWVBvnySbSl9dXvZXl6v3NrxIh/aoYVnd81+GAiDbFXt/0/LLmB3cmi6qDSRN8/B5xX5fkDwJGLqjG8l8e8cRsj/fQp1ioUkv7TV0s366rBTMzdNDfvvPY4JITqPj0j4I5V4IE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=LPJOaFku; arc=fail smtp.client-ip=52.101.85.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="LPJOaFku" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=feo6GcpTq+vHa83gMgK9e0Foqc/Kk8S8B7dGhMUWFP5XK5sEFFe96+rxaoLY3TtmFkZiCtd7obvyadA+EnPwSJS0WsT0qAlOE30C/nQPMdW4kaVkoy2wqxHGvRmz97UDoTSB1JJiezdfslm84ZAB1QQ23B67MkgXvaakX6aGVavs5d2ocS2nnXOOEjGMtEUeM2Noc5DyJZY8nbOZGnwGZ9w5JLlmF5flI0sBN/qFZZTdaTXDcXebcv9r7kJvSAtEAmMlmC6GMrCqEDSexmofYR0QgH70IOwS5NJreKOIi8O3sqENkRQ4hqEI/zZIsI8AwvTGJRMD/hlXGgZVIX2gbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CL8rqwNCbyR5hhSvyHdVG915YX46Qaro80cAShOyJLE=; b=mdxrl4fUa76EA2aC5nkE4gmjYkD1jtvqKRKJ9TUKe6M+arAZJdGSjKnArkmB4GHTJi7DqCQR5RA6UZpm5mBzhyOWHO+FRrazNsQhmnPaRO90rzWaEJ8q9u9C4VAVb3U81qmUAdzrEL+dLIjFzry6sSF7jHWO6JVzycdK25Db9TSL969gHkPOX2tGOioOxiduG4CLLJdUnPuEFBIM+keYgPs59I/7/kFo83QUUgsxATmsJbMswFfoKJU37VikdyNpbthxYyqt675nEoYgHwtLscPFOjauZEpuKc1NCGVPPCgXW8PEZmnJhUa2U4Koj7kLP2HI8cGu6FsynUC3sFGfjA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CL8rqwNCbyR5hhSvyHdVG915YX46Qaro80cAShOyJLE=; b=LPJOaFkuKlorm3thmDab4KoHaQqnNy4cZH0iowldkN745bvVfSD3/cnNNHWAfCdddPv0VHYPy/qNClzoUuVZrn/t0Ol/O5/C3ECPH43hJ69wmc5nyh3lhn+dNHpS1ykRA56iOjNgX3+0QtOxq7hY3JOc3brrHyIBKESg2V3tgWQ= Received: from PH8P221CA0017.NAMP221.PROD.OUTLOOK.COM (2603:10b6:510:2d8::13) by IA0PR12MB8352.namprd12.prod.outlook.com (2603:10b6:208:3dd::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.5; Wed, 14 Jan 2026 16:49:36 +0000 Received: from CY4PEPF0000E9D6.namprd05.prod.outlook.com (2603:10b6:510:2d8:cafe::82) by PH8P221CA0017.outlook.office365.com (2603:10b6:510:2d8::13) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9520.5 via Frontend Transport; Wed, 14 Jan 2026 16:49:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CY4PEPF0000E9D6.mail.protection.outlook.com (10.167.241.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.1 via Frontend Transport; Wed, 14 Jan 2026 16:49:36 +0000 Received: from rric.localdomain (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Wed, 14 Jan 2026 10:49:30 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Joshua Hahn , Robert Richter Subject: [PATCH v10 09/13] cxl/acpi: Prepare use of EFI runtime services Date: Wed, 14 Jan 2026 17:48:25 +0100 Message-ID: <20260114164837.1076338-10-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260114164837.1076338-1-rrichter@amd.com> References: <20260114164837.1076338-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D6:EE_|IA0PR12MB8352:EE_ X-MS-Office365-Filtering-Correlation-Id: 996c0576-01b3-43c3-50b0-08de538ce684 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700013|7416014|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?XEA7bI/RJndbvm5vgvKhBFKZEY18h//EMG3C9zzCDO0vycXfc/aLA1fvNhGv?= =?us-ascii?Q?uGLA5ryYZI1UfrHUMephwR9l0rdyBcEm0qebZq+WhigoZCZXnjoC1hoUkxqg?= =?us-ascii?Q?fe4w71mvLoPGhSnIauweTTAvqAma4AlUf5/F3yCZ7ytKWnODpq4yFJomOeK7?= =?us-ascii?Q?uaVosiBm+jakNGQKS7/h3jSOkaFJf+D1+h66pDsZ4L8kLGQHgQzIKwVPGPYm?= =?us-ascii?Q?a+azjK8YDNtlSQNC8aSFg8nsSTNUqMdlnTIaaFT8YNRcLhTdBtv3Xj//vRNC?= =?us-ascii?Q?PbNoS+y6ZYu8EKPe3nWojhKCFn4gtsmllqX5x0KIlIsnbpLEdWaqDnwmGM8V?= =?us-ascii?Q?f3hqxbaEYebg7TrJZJKCnnhflCzeSXXA01Kdvk0aOMpGOwXUay9wVQVRyWFI?= =?us-ascii?Q?gndx2YPxgrCApXuruO7JqUrYtVl2wCTfupAKl5VU9JVOk19m6CeKhJhmBHgp?= =?us-ascii?Q?puAZMr7NjgRF0QIpVJfOMyUHfs1bx4dTa6MKNlStF/yH3K18Cr7lAwygZTla?= =?us-ascii?Q?fSuIk14YKlXe7cBwzkxNtJdZ6AqRKHDAdtypvfdbav9K0//OWxSMBqhp1VxS?= =?us-ascii?Q?ZA1mmxQ2wOspNimMpWVItpvagSWEucQ31gBXQMl2SLEEBlMPEOcTP0gmHyFU?= =?us-ascii?Q?AhZxg+8msdLO2bKoKyUWJ19XEkNq7H0P2oJtyHCBWHqgequGegdi0z6hL21x?= =?us-ascii?Q?WiYu/Mjx9gB9w1HUo7hpLixrZpJgsOAibhuZbV+WyvKXln3Vj9LfBIfKvKUp?= =?us-ascii?Q?48NepucLrzTXMgF+FPtwz/SAAl/pW2/J740fv1RfuuNM+VQWRn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g=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(36860700013)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jan 2026 16:49:36.0558 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 996c0576-01b3-43c3-50b0-08de538ce684 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D6.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8352 Content-Type: text/plain; charset="utf-8" In order to use EFI runtime services, esp. ACPI PRM which uses the efi_rts_wq workqueue, initialize EFI before CXL ACPI. There is a subsys_initcall order dependency if driver is builtin: subsys_initcall(cxl_acpi_init); subsys_initcall(efisubsys_init); Prevent the efi_rts_wq workqueue being used by cxl_acpi_init() before its allocation. Use subsys_initcall_sync(cxl_acpi_init) to always run efisubsys_init() first. Reported-by: Gregory Price Tested-by: Joshua Hahn Reviewed-by: Joshua Hahn Reviewed-by: Gregory Price Reviewed-by: Dave Jiang Reviewed-by: Jonathan Cameron Tested-by: Gregory Price Signed-off-by: Robert Richter reviewed-by tags and the small update in the description of 13/13? --- drivers/cxl/acpi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index b4bed40ef7c0..a31d0f97f916 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -1005,8 +1005,12 @@ static void __exit cxl_acpi_exit(void) cxl_bus_drain(); } =20 -/* load before dax_hmem sees 'Soft Reserved' CXL ranges */ -subsys_initcall(cxl_acpi_init); +/* + * Load before dax_hmem sees 'Soft Reserved' CXL ranges. Use + * subsys_initcall_sync() since there is an order dependency with + * subsys_initcall(efisubsys_init), which must run first. + */ +subsys_initcall_sync(cxl_acpi_init); =20 /* * Arrange for host-bridge ports to be active synchronous with --=20 2.47.3 From nobody Sat Feb 7 04:47:22 2026 Received: from CY7PR03CU001.outbound.protection.outlook.com (mail-westcentralusazon11010006.outbound.protection.outlook.com [40.93.198.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C31AE3A641A; Wed, 14 Jan 2026 16:49:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.198.6 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768409394; cv=fail; b=VS368paiqkRVbaxeTrlHDMmSgF6ZCtKqcOeC+pOaxxzI/t6AFQYhEBbCgW1jTcXXIt/GpTStPWMwavEltia2oxMxx2DHW8nVfc1iJ40s/6lVwE4y7vFL+C6oyV7Y3utd6Jky1iKvxYrBOCXHRQDjQ36zDB5EAYFk87Q8fcugbZs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768409394; c=relaxed/simple; bh=NzCf99GYN03DBfAOAcmuubc6tBqWe9SLSB8N9200/z8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CpvfHCKWTBEOO2hvmH4nMB6umgmXlnutLUa+4J/Xsttwhd7n9TPI7Sa7M10t3dpbgqGuCRgyzPezAWemn6xgC1mHJK9V2obP5BG2TKCFIGUInEBteLZSWOcj/JiErWiNVMlDpx2ggXcAlcipe8AdeiCZkHCcU6hBAocBcl0YPXk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=rqpopEtn; arc=fail smtp.client-ip=40.93.198.6 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="rqpopEtn" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Z8S0/lUuyRvkarLyXX1a3bC0x2Z6xIP68LHFqnEnDQNycBm+e152CPYKB5XUHJ2lnmlGGpyMX2CX5hBmMdG2AUjrR78J435s2GTspb8R/JKL65/AS4vBZFL3bj8oUAhzA4NidYv+n7NxbFE0Ua7et3r+xIm7DrzyEFib8viTNZ5ovbn/3n1wHKpTXR+NLG7SNtJj+Rz5aB2+68rlsGylioEh4FV06Y6mFQlgUZ81/JMi92lhXIU5YNugfPmycOCWoQDCcJud1dWH9L6ko4Fp6Nf2ibkSeqR9zJs/KxX0hU7x12XmKL67pfKDdUI+OL12WaGjBoP/R0wbNxusO9UUzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=85r4L+xywSogYPdRiKqsvJWd9nfRBG7MiV7bEsM86WA=; b=aRW/nGWnHyPla6AOwzsFDlRf/c7oWPI7oEJk2LhZeyxwe+gyVFjJCTkpvR//R8zSQ+iwhswWWI2DzatuunAvMyqZ6sQgaz4lVmvALhvu/WZpA7ATTHMfCrUFusG79QrFbxNJ3W7vYnZL0NwxCyz5XrmYpIVqUBRUQw3Rd85iED1IwIUhQG41+EsmJkX8RXyxSOrX3oDlhsUah6LazoRnJJYlIAJLf8J6sSWoHKuYPJgBTzb6fYt5RXiEZqdDNnFKrO/zK15PiGbBLFVsNlI5Rq5fMbkZkqM30bEMrCX0jv4Kj3WIXiHGn9dnzLvq7pFQq8fvNHOEAjzhlP5uY9n8OQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=85r4L+xywSogYPdRiKqsvJWd9nfRBG7MiV7bEsM86WA=; b=rqpopEtnIdZFnDf4W/0+P5/On92UVvEOQRx2ZU75lfUD6QryiDV/2k2m3DOcy6m8/Wi43OHkaI06RBx7T+XbReiSkLOqW4a4HcabsixX3RyjQn2ioGCK10djd4mBSm/DTlL3VC3xWBV3Yuhnygh1WTAGSTgse781SUFb/pn2G8Y= Received: from PH8P221CA0028.NAMP221.PROD.OUTLOOK.COM (2603:10b6:510:2d8::28) by DS2PR12MB9686.namprd12.prod.outlook.com (2603:10b6:8:27a::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.5; Wed, 14 Jan 2026 16:49:38 +0000 Received: from CY4PEPF0000E9D6.namprd05.prod.outlook.com (2603:10b6:510:2d8:cafe::8e) by PH8P221CA0028.outlook.office365.com (2603:10b6:510:2d8::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9520.5 via Frontend Transport; Wed, 14 Jan 2026 16:49:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CY4PEPF0000E9D6.mail.protection.outlook.com (10.167.241.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.1 via Frontend Transport; Wed, 14 Jan 2026 16:49:37 +0000 Received: from rric.localdomain (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Wed, 14 Jan 2026 10:49:34 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Joshua Hahn , Robert Richter Subject: [PATCH v10 10/13] cxl: Enable AMD Zen5 address translation using ACPI PRMT Date: Wed, 14 Jan 2026 17:48:26 +0100 Message-ID: <20260114164837.1076338-11-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260114164837.1076338-1-rrichter@amd.com> References: <20260114164837.1076338-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D6:EE_|DS2PR12MB9686:EE_ X-MS-Office365-Filtering-Correlation-Id: 9d65e501-e166-4b4f-2415-08de538ce7a8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|7416014|82310400026|13003099007; X-Microsoft-Antispam-Message-Info: =?utf-8?B?dWVRYlJoRldDL0syd21XTE13WkF2cm1ldjRQUmduQzZHcEF3QjhzUC9HSTJ1?= =?utf-8?B?ajZpZVhaeklQYkhMOEtHTEF3ZlJ1THIrYkhJVnZXV25MTmpiSkxBQVA0S01j?= =?utf-8?B?YVVwZFF1SE4rZ0dZeGpqRytJbUtpNWt0bGtQUkx0MThxVVNZd0tQdm5iN3Fs?= =?utf-8?B?TUdaZ0xCeVRtR2Q4a2dHZmVweFpSRE4zc3hZR1MxMnFWejdab1pmRVlCMFBy?= =?utf-8?B?d3YyQ2xzK2JlRWMvaHAzRm9jRHVNRkVFMmNEclRKUmlwd3FicXZ0S2VDeU1n?= =?utf-8?B?amp5SGZLTDBnOWpreDJTOGE3RzI1Q2dtNHc0MEppR2FDTmphOUhtSGJTVDRw?= =?utf-8?B?ZUdkT3BtM0tMeTl3dkRaRUJPa1ZLRWF5SkFpKy9pT041R01qTWxlNWoyNUR4?= =?utf-8?B?ZklmOUxEMVRuNGI0VnprVWltU3VKYi9Vby9hb3ZFbWdWeVdVc0w4QzR0UUM1?= =?utf-8?B?Y3E5TW5kK1h3OUQ4R3ZUMXkrNHJoSWVRTzdKSmk3LytVcEgrVTVOVDlJQzIx?= =?utf-8?B?Qk5wV0NyUWVpa1RJblZuaFdLVjIzQU9ScE9JdlFiVXJGQkZGZ3l1TzhVMWRY?= =?utf-8?B?T3g1Nk1nS0p3VWZ6alJqZ2ZGZjkvSnBPbm12OXR4dGNiQldrY2dna0czUERr?= =?utf-8?B?dG5LS0lMZFNmYytiSVFwQS9BNnRGMkFVTWFQVVJ2MUpEN2c0K0pmbTg5em9I?= =?utf-8?B?MGtHWXFScjM0RDlpZlFoclpIWDA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dwaFNQd3pYdVZOdm9vRXgyNmE0U1k3OWZwT2ZvSjNrUy9idlVoT3Np?= =?utf-8?B?cXZjbWV1SW9aVWQyak5rbWxlZWhPNUMxUm1keXF1eUl3VE5OWCtFRlY0Z3Ey?= =?utf-8?B?cTJyRkplYjBRKzBDZ210TzB3RkJKSW9OV1VmOUJHQlhtRWlnUVN4Mm5qbWpP?= =?utf-8?B?OFNmbEVPVTRRMFBjZkpnbE1YbTB1bjF5ZHR1S1JQNEpLMVVVUGxuNG1hK1ht?= =?utf-8?B?bVVyTHQ3Wm9LTjNrbmp4cjQyMXJLRlR6NkVLdUpZMG9DVmthSHllb2ZqT1FI?= =?utf-8?B?TlA4dEU5Rmw0ZUdWMHJ5RUhEMTNGdVF2cDQ1RUJWUEZOeXJHeW9PQlB4QlBL?= =?utf-8?B?VTBWd0JaWWlmTXIrdmo2Zmoxd2pLOXcyN3JWUzVYaG5yZUh4Z2dKdExDSFFu?= =?utf-8?B?QVpQL0k1UVZ6MTVRMU9EZDBsUnRtMkFITlZ1dm5xY2JSdlZnbVphWjdXc0Qx?= =?utf-8?B?R0lDb2RVRFcvNGc2MzhtSVllVDQxQWdrKythMGdPNEFYTit5TTZoMlJlNUY0?= =?utf-8?B?TVNidFVYWmsvTEZMVUNrQS82cHFObTZ2WStOdE05ZnlXTmk2M0F4UEQvTmdy?= =?utf-8?B?cFNRSHhkZWdDOG9DR2xWcXlmcGRnPT0=?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(376014)(7416014)(82310400026)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jan 2026 16:49:37.9406 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9d65e501-e166-4b4f-2415-08de538ce7a8 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D6.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS2PR12MB9686 Add AMD Zen5 support for address translation. Zen5 systems may be configured to use 'Normalized addresses'. Then, host physical addresses (HPA) are different from their system physical addresses (SPA). The endpoint has its own physical address space and an incoming HPA is already converted to the device's physical address (DPA). Thus it has interleaving disabled and CXL endpoints are programmed passthrough (DPA =3D=3D HPA). Host Physical Addresses (HPAs) need to be translated from the endpoint to its CXL host bridge, esp. to identify the endpoint's root decoder and region's address range. ACPI Platform Runtime Mechanism (PRM) provides a handler to translate the DPA to its SPA. This is documented in: AMD Family 1Ah Models 00h=E2=80=930Fh and Models 10h=E2=80=931Fh ACPI v6.5 Porting Guide, Publication # 58088 https://www.amd.com/en/search/documentation/hub.html With Normalized Addressing this PRM handler must be used to translate an HPA of an endpoint to its SPA. Do the following to implement AMD Zen5 address translation: Introduce a new file core/atl.c to handle ACPI PRM specific address translation code. Naming is loosely related to the kernel's AMD Address Translation Library (CONFIG_AMD_ATL) but implementation does not depend on it, nor it is vendor specific. Use Kbuild and Kconfig options respectively to enable the code depending on architecture and platform options. AMD Zen5 systems support the ACPI PRM CXL Address Translation firmware call (see ACPI v6.5 Porting Guide, Address Translation - CXL DPA to System Physical Address). Firmware enables the PRM handler if the platform has address translation implemented. Check firmware and kernel support of ACPI PRM using the specific GUID. On success enable address translation by setting up the earlier introduced root port callback, see function cxl_prm_setup_translation(). Setup is done in cxl_setup_prm_address_translation(), it is the only function that needs to be exported. For low level PRM firmware calls, use the ACPI framework. Identify the region's interleaving ways by inspecting the address ranges. Also determine the interleaving granularity using the address translation callback. Note that the position of the chunk from one interleaving block to the next may vary and thus cannot be considered constant. Address offsets larger than the interleaving block size cannot be used to calculate the granularity. Thus, probe the granularity using address translation for various HPAs in the same interleaving block. Reviewed-by: Dave Jiang Reviewed-by: Jonathan Cameron Tested-by: Gregory Price Signed-off-by: Robert Richter reviewed-by tags and the small update in the description of 13/13? --- drivers/cxl/Kconfig | 5 + drivers/cxl/acpi.c | 2 + drivers/cxl/core/Makefile | 1 + drivers/cxl/core/atl.c | 190 ++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxl.h | 7 ++ 5 files changed, 205 insertions(+) create mode 100644 drivers/cxl/core/atl.c diff --git a/drivers/cxl/Kconfig b/drivers/cxl/Kconfig index 48b7314afdb8..103950a9b73e 100644 --- a/drivers/cxl/Kconfig +++ b/drivers/cxl/Kconfig @@ -233,4 +233,9 @@ config CXL_MCE def_bool y depends on X86_MCE && MEMORY_FAILURE =20 +config CXL_ATL + def_bool y + depends on CXL_REGION + depends on ACPI_PRMT && AMD_NB + endif diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index a31d0f97f916..50c2987e0459 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -925,6 +925,8 @@ static int cxl_acpi_probe(struct platform_device *pdev) cxl_root->ops.qos_class =3D cxl_acpi_qos_class; root_port =3D &cxl_root->port; =20 + cxl_setup_prm_address_translation(cxl_root); + rc =3D bus_for_each_dev(adev->dev.bus, NULL, root_port, add_host_bridge_dport); if (rc < 0) diff --git a/drivers/cxl/core/Makefile b/drivers/cxl/core/Makefile index 5ad8fef210b5..11fe272a6e29 100644 --- a/drivers/cxl/core/Makefile +++ b/drivers/cxl/core/Makefile @@ -20,3 +20,4 @@ cxl_core-$(CONFIG_CXL_REGION) +=3D region.o cxl_core-$(CONFIG_CXL_MCE) +=3D mce.o cxl_core-$(CONFIG_CXL_FEATURES) +=3D features.o cxl_core-$(CONFIG_CXL_EDAC_MEM_FEATURES) +=3D edac.o +cxl_core-$(CONFIG_CXL_ATL) +=3D atl.o diff --git a/drivers/cxl/core/atl.c b/drivers/cxl/core/atl.c new file mode 100644 index 000000000000..c36984686fb0 --- /dev/null +++ b/drivers/cxl/core/atl.c @@ -0,0 +1,190 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2025 Advanced Micro Devices, Inc. + */ + +#include +#include +#include + +#include +#include "core.h" + +/* + * PRM Address Translation - CXL DPA to System Physical Address + * + * Reference: + * + * AMD Family 1Ah Models 00h=E2=80=930Fh and Models 10h=E2=80=931Fh + * ACPI v6.5 Porting Guide, Publication # 58088 + */ + +static const guid_t prm_cxl_dpa_spa_guid =3D + GUID_INIT(0xee41b397, 0x25d4, 0x452c, 0xad, 0x54, 0x48, 0xc6, 0xe3, + 0x48, 0x0b, 0x94); + +struct prm_cxl_dpa_spa_data { + u64 dpa; + u8 reserved; + u8 devfn; + u8 bus; + u8 segment; + u64 *spa; +} __packed; + +static u64 prm_cxl_dpa_spa(struct pci_dev *pci_dev, u64 dpa) +{ + struct prm_cxl_dpa_spa_data data; + u64 spa; + int rc; + + data =3D (struct prm_cxl_dpa_spa_data) { + .dpa =3D dpa, + .devfn =3D pci_dev->devfn, + .bus =3D pci_dev->bus->number, + .segment =3D pci_domain_nr(pci_dev->bus), + .spa =3D &spa, + }; + + rc =3D acpi_call_prm_handler(prm_cxl_dpa_spa_guid, &data); + if (rc) { + pci_dbg(pci_dev, "failed to get SPA for %#llx: %d\n", dpa, rc); + return ULLONG_MAX; + } + + pci_dbg(pci_dev, "PRM address translation: DPA -> SPA: %#llx -> %#llx\n",= dpa, spa); + + return spa; +} + +static int cxl_prm_setup_root(struct cxl_root *cxl_root, void *data) +{ + struct cxl_region_context *ctx =3D data; + struct cxl_endpoint_decoder *cxled =3D ctx->cxled; + struct cxl_decoder *cxld =3D &cxled->cxld; + struct cxl_memdev *cxlmd =3D cxled_to_memdev(cxled); + struct range hpa_range =3D ctx->hpa_range; + struct pci_dev *pci_dev; + u64 spa_len, len; + u64 addr, base_spa, base; + int ways, gran; + + /* + * When Normalized Addressing is enabled, the endpoint maintains a 1:1 + * mapping between HPA and DPA. If disabled, skip address translation + * and perform only a range check. + */ + if (hpa_range.start !=3D cxled->dpa_res->start) + return 0; + + /* + * Endpoints are programmed passthrough in Normalized Addressing mode. + */ + if (ctx->interleave_ways !=3D 1) { + dev_dbg(&cxld->dev, "unexpected interleaving config: ways: %d granularit= y: %d\n", + ctx->interleave_ways, ctx->interleave_granularity); + return -ENXIO; + } + + if (!cxlmd || !dev_is_pci(cxlmd->dev.parent)) { + dev_dbg(&cxld->dev, "No endpoint found: %s, range %#llx-%#llx\n", + dev_name(cxld->dev.parent), hpa_range.start, + hpa_range.end); + return -ENXIO; + } + + pci_dev =3D to_pci_dev(cxlmd->dev.parent); + + /* Translate HPA range to SPA. */ + base =3D hpa_range.start; + hpa_range.start =3D prm_cxl_dpa_spa(pci_dev, hpa_range.start); + hpa_range.end =3D prm_cxl_dpa_spa(pci_dev, hpa_range.end); + base_spa =3D hpa_range.start; + + if (hpa_range.start =3D=3D ULLONG_MAX || hpa_range.end =3D=3D ULLONG_MAX)= { + dev_dbg(cxld->dev.parent, + "CXL address translation: Failed to translate HPA range: %#llx-%#llx:%#= llx-%#llx(%s)\n", + hpa_range.start, hpa_range.end, ctx->hpa_range.start, + ctx->hpa_range.end, dev_name(&cxld->dev)); + return -ENXIO; + } + + /* + * Since translated addresses include the interleaving offsets, align + * the range to 256 MB. + */ + hpa_range.start =3D ALIGN_DOWN(hpa_range.start, SZ_256M); + hpa_range.end =3D ALIGN(hpa_range.end, SZ_256M) - 1; + + len =3D range_len(&ctx->hpa_range); + spa_len =3D range_len(&hpa_range); + if (!len || !spa_len || spa_len % len) { + dev_dbg(cxld->dev.parent, + "CXL address translation: HPA range not contiguous: %#llx-%#llx:%#llx-%= #llx(%s)\n", + hpa_range.start, hpa_range.end, ctx->hpa_range.start, + ctx->hpa_range.end, dev_name(&cxld->dev)); + return -ENXIO; + } + + ways =3D spa_len / len; + gran =3D SZ_256; + + /* + * Determine interleave granularity + * + * Note: The position of the chunk from one interleaving block to the + * next may vary and thus cannot be considered constant. Address offsets + * larger than the interleaving block size cannot be used to calculate + * the granularity. + */ + if (ways > 1) { + while (gran <=3D SZ_16M) { + addr =3D prm_cxl_dpa_spa(pci_dev, base + gran); + if (addr !=3D base_spa + gran) + break; + gran <<=3D 1; + } + } + + if (gran > SZ_16M) { + dev_dbg(cxld->dev.parent, + "CXL address translation: Cannot determine granularity: %#llx-%#llx:%#l= lx-%#llx(%s)\n", + hpa_range.start, hpa_range.end, ctx->hpa_range.start, + ctx->hpa_range.end, dev_name(&cxld->dev)); + return -ENXIO; + } + + ctx->hpa_range =3D hpa_range; + ctx->interleave_ways =3D ways; + ctx->interleave_granularity =3D gran; + + dev_dbg(&cxld->dev, + "address mapping found for %s (hpa -> spa): %#llx+%#llx -> %#llx+%#llx w= ays:%d granularity:%d\n", + dev_name(cxlmd->dev.parent), base, len, hpa_range.start, + spa_len, ways, gran); + + return 0; +} + +void cxl_setup_prm_address_translation(struct cxl_root *cxl_root) +{ + struct device *host =3D cxl_root->port.uport_dev; + u64 spa; + struct prm_cxl_dpa_spa_data data =3D { .spa =3D &spa }; + int rc; + + /* + * Applies only to PCIe Host Bridges which are children of the CXL Root + * Device (HID=3D=E2=80=9CACPI0017=E2=80=9D). Check this and drop cxl_tes= t instances. + */ + if (!acpi_match_device(host->driver->acpi_match_table, host)) + return; + + /* Check kernel (-EOPNOTSUPP) and firmware support (-ENODEV) */ + rc =3D acpi_call_prm_handler(prm_cxl_dpa_spa_guid, &data); + if (rc =3D=3D -EOPNOTSUPP || rc =3D=3D -ENODEV) + return; + + cxl_root->ops.translation_setup_root =3D cxl_prm_setup_root; +} +EXPORT_SYMBOL_NS_GPL(cxl_setup_prm_address_translation, "CXL"); diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index 8ea334d81edf..20b0fd43fa7b 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -817,6 +817,13 @@ static inline void cxl_dport_init_ras_reporting(struct= cxl_dport *dport, struct device *host) { } #endif =20 +#ifdef CONFIG_CXL_ATL +void cxl_setup_prm_address_translation(struct cxl_root *cxl_root); +#else +static inline +void cxl_setup_prm_address_translation(struct cxl_root *cxl_root) {} +#endif + struct cxl_decoder *to_cxl_decoder(struct device *dev); struct cxl_root_decoder *to_cxl_root_decoder(struct device *dev); struct cxl_switch_decoder *to_cxl_switch_decoder(struct device *dev); --=20 2.47.3 From nobody Sat Feb 7 04:47:22 2026 Received: from CO1PR03CU002.outbound.protection.outlook.com (mail-westus2azon11010018.outbound.protection.outlook.com [52.101.46.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8826E3A4F2B; Wed, 14 Jan 2026 16:49:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.46.18 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768409385; cv=fail; b=QvT/plJIa1PQoPskUqFSxJD5u+BtmUaTcnVMfcReGuVI98TI8T6uuwSuZb+Y+A9fTKPQ7cLHlI02aYngk7FVGlWXDcN7Mgbi56JNv+PgTYlm7HVHGmKWyF6JWK7kQ7q9I1HSVGmnLaD1vXgJgUinrbcupOvP0/3Ee81oHh1JksE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768409385; c=relaxed/simple; bh=PpMzmYNriu+kPjIAZP8pB6tO9TzQKadRlUqAqHVTe8s=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Y2smgBUmFMYYv/592rKU3odR3tm0kqqw0BIFIQFBnFsS68rzt9FhWLZBfBRoRUHz9O8fnwFPgT37fj5aPy7SLBZWB74QM8RD/Q/+8Dr5i4v1cVV/efTZO7u5v9chji4rlikF3d9mDmW3LWVJGXHxuYgLu88hy0DPaIOxFzH+0Sk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=coxF0DUa; arc=fail smtp.client-ip=52.101.46.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="coxF0DUa" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=luu3a/vtzA9YQl1OsS8jyXMxLhNxxX9sYQ8Z8gPKFiCOFmNnoIaDLZ+OPeanaP04TxSzVuRRXD1dL+v82z0oQG5Juz0lLSFZuNBHvqtYwm8QdUTCRLbgt7s6529lMfBwkJYMwre1I6OHbTsw+AJfdelFxwnTFXs53ezrQqUTitsTJ1FgjaPH8w3nXZcsLHnphXprcNCKvknFjnXJ0xfPGkTO4iS9ntXOWnBQW37i1GXu1opfPzCKTJX4OKg+tBPU3ZrYGMz27zmmRKfal8So7BTqN7FvaDc4eAh7pw4MaDRkLaAbE8pQ350Ah82+jhnI4MsjabgRq31I1mMDnQiqWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=w36FrPzjTCg0lOfwMgs32wGutB/hVoOD3mMkBHCWHOw=; b=f5F70WwUad2kMmVrk5jGjNfx+GpZa7ZNPteLbTMvBTgXFEwPf9eoCxIuGJsVoZAvnHdD4+yAoDUupWXiOg1oY0e404eX1ps88xqpJD3Ir7p/SBID/6cxkxGC8K/lHEUKzH4hPzhiYIjkkOByG1+9pbNhzHt3oZVDoJwOl5byWOdYSqCNEhZuHzZwodsMva3Z9ucEtjt6EQVsIYMtQIG2C8iBM5q80q2fyftl1YiOA3B78OJowkbU9gxvn8j98IbMge4HWPue+xtVe/uN2OpogEEqHFR9octSrnuZWcAc3XUn6UFfyc+7aVWUKSOrHrSM0vmKOlkeseZZDqKd+vtQzw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=w36FrPzjTCg0lOfwMgs32wGutB/hVoOD3mMkBHCWHOw=; b=coxF0DUapsjWPPCWj4N7Y6qkrHt7d1CtVKqUdUgOfHbN2brLurpHPwHjNqQ8iI3dnt2+KggSIWnNN3NFqp1pxJh3QqhpdOqdjR487Zfahs4/RDdWuWeKRyTPujoy3DxGnGZ1rNc/R5porYBwpJT3BbG1dH4d+kREE+kGA4l4zkw= Received: from PH8P221CA0029.NAMP221.PROD.OUTLOOK.COM (2603:10b6:510:2d8::34) by SA5PPFC3F406448.namprd12.prod.outlook.com (2603:10b6:80f:fc04::8e0) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9499.7; Wed, 14 Jan 2026 16:49:41 +0000 Received: from CY4PEPF0000E9D6.namprd05.prod.outlook.com (2603:10b6:510:2d8:cafe::db) by PH8P221CA0029.outlook.office365.com (2603:10b6:510:2d8::34) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9520.5 via Frontend Transport; Wed, 14 Jan 2026 16:49:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CY4PEPF0000E9D6.mail.protection.outlook.com (10.167.241.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.1 via Frontend Transport; Wed, 14 Jan 2026 16:49:41 +0000 Received: from rric.localdomain (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Wed, 14 Jan 2026 10:49:37 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Joshua Hahn , Robert Richter Subject: [PATCH v10 11/13] cxl/atl: Lock decoders that need address translation Date: Wed, 14 Jan 2026 17:48:27 +0100 Message-ID: <20260114164837.1076338-12-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260114164837.1076338-1-rrichter@amd.com> References: <20260114164837.1076338-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D6:EE_|SA5PPFC3F406448:EE_ X-MS-Office365-Filtering-Correlation-Id: 0deec6ef-351d-43c5-8c05-08de538ce977 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?apLf/9qnJ2hIdarNiU85SY2ECCUl4QuMQ3zGgIdC7jweK7GfkcmSXqmRuQyL?= =?us-ascii?Q?GjJeDejhKFSMyyoJou8/+5Hp7hXCY/ieznYlKQF4LzhFngN3LlljGZSgZRV3?= =?us-ascii?Q?E5gR/foNtyPgM1B6GHOmYWTCVb/i6Ms+1isf8i15nzZNSz+oIhD1ircB2WJI?= =?us-ascii?Q?f1zWMQRHrN/88tYvyfCCjV05xzuMs+WB9PQ3d8Ptgorbdk80IcB847OgNsJf?= =?us-ascii?Q?rNOT8cAOy/elmgoz8lTnnLJyanrffeFx3pHIJiGJV5vgRzmt3x9SEqpZB1nA?= =?us-ascii?Q?7oi1905OVjXbg/apO5U+bMYGadGItlQDZvha59wpm1yF4C/jZn+m80lfKbSX?= =?us-ascii?Q?47iTq9YdZnRMe0y2ZwNZqJV+YFgfpxdL3aaSkisrgJnftccbU/7qBhRpeFqj?= =?us-ascii?Q?r2wccxlNtNsEXYtjmjMJLYhYULFs0MqMvrd6pTvjZ15AXI9OECS0LLNfDbNi?= =?us-ascii?Q?F+HNXXL0zc1qCKJxlbzBQNLTSwJmmgjnMBBCJ+Q/RtvAXyk0U1X0DcXjMZf7?= =?us-ascii?Q?AEbgEx3XrPv1mwN0QBZmSDGLko/WW5/h/TgSdG6Z49J6ZBHpBmuD/WCLJhcj?= =?us-ascii?Q?BwFnT50a3rqkOBTI3C8+0lAm5I0mPHrETYjDYFZ9QQVKY6a2y4JEmpZ7L0dF?= =?us-ascii?Q?UZ6pyQBM+QIkDjMLjV1LjpE94PyJX8qLP7SWapY8Ia+FepajNn35p2P8gH2G?= =?us-ascii?Q?hR2IRJ2fZT3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U?= =?us-ascii?Q?nY/CIWtR5eKaL3vNMhkLzayJW/SFqnxNAi9GCbujLfeOWvnvi3VA0hwsIMvG?= =?us-ascii?Q?BVU2XA=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jan 2026 16:49:41.0021 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0deec6ef-351d-43c5-8c05-08de538ce977 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D6.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA5PPFC3F406448 Content-Type: text/plain; charset="utf-8" The current kernel implementation does not support endpoint setup with Normalized Addressing. It only translates an endpoint's DPA to the SPA range of the host bridge. Therefore, the endpoint address range cannot be determined, making a non-auto setup impossible. If a decoder requires address translation, reprogramming should be disabled and the decoder locked. The BIOS, however, provides all the necessary address translation data, which the kernel can use to reconfigure endpoint decoders with normalized addresses. Locking the decoders in the BIOS would prevent a capable kernel (or other operating systems) from shutting down auto-generated regions and managing resources dynamically. Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang Tested-by: Gregory Price Signed-off-by: Robert Richter reviewed-by tags and the small update in the description of 13/13? --- drivers/cxl/core/atl.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/cxl/core/atl.c b/drivers/cxl/core/atl.c index c36984686fb0..09d0ea1792d9 100644 --- a/drivers/cxl/core/atl.c +++ b/drivers/cxl/core/atl.c @@ -154,6 +154,24 @@ static int cxl_prm_setup_root(struct cxl_root *cxl_roo= t, void *data) return -ENXIO; } =20 + /* + * The current kernel implementation does not support endpoint + * setup with Normalized Addressing. It only translates an + * endpoint's DPA to the SPA range of the host bridge. + * Therefore, the endpoint address range cannot be determined, + * making a non-auto setup impossible. If a decoder requires + * address translation, reprogramming should be disabled and + * the decoder locked. + * + * The BIOS, however, provides all the necessary address + * translation data, which the kernel can use to reconfigure + * endpoint decoders with normalized addresses. Locking the + * decoders in the BIOS would prevent a capable kernel (or + * other operating systems) from shutting down auto-generated + * regions and managing resources dynamically. + */ + cxld->flags |=3D CXL_DECODER_F_LOCK; + ctx->hpa_range =3D hpa_range; ctx->interleave_ways =3D ways; ctx->interleave_granularity =3D gran; --=20 2.47.3 From nobody Sat Feb 7 04:47:22 2026 Received: from SJ2PR03CU001.outbound.protection.outlook.com (mail-westusazon11012041.outbound.protection.outlook.com [52.101.43.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E27BA3191C4; Wed, 14 Jan 2026 16:49:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.43.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768409395; cv=fail; b=q5tWuod5JwMDaCreuGbNotZV2b6uQhmRcl7HackvBxHldndbkEQ818vN9T9dV7P5QPDCb3zLfaXPHS9eysHYJOBmqpYgE4FDVa/RnYLL8vYQraKxwaSXDY/C1wF6SqJrOxEgrDQrkog8JFq3/nMnSKF/E+cd45wMj5o2fxVYSSg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768409395; c=relaxed/simple; bh=xiwJAIUuh9AVDho+Gih/u77kTjCpeApAR4lYGw6KEmA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IaDuHQHnnD2jc75bag4ySs9/6k0LBMugPXgsTbxk+FYrtcci/R0VAbHXWYbUBFuFIbGztSdSz3hlcw7VoViKSwJif61CDVMOdNlKknS3otN32Pnm2a6taBZSck0H+IMEmNmIcwBuzjiJgy1LWnM6iWD8k5HoPg53ZO/ySmhaehY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=5BvKpnzV; arc=fail smtp.client-ip=52.101.43.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="5BvKpnzV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mJgKXSSnp4PPjWJvNwGM4YXWdJ2CAJrOFS4L+4vcR3UcyyruXJn4C6zExlfhIAkHuhHmerS3yzPBdwk/aiYA+Xcjkh6Yi7RQRtAQ7wzmsOs8+VOFlrm7nCSziVMAKY2zgOhkgd4p0IVcTsJWR0yODpi8PZaeJENPDAtWpl7CAhh8DwKIc9kTpm9Ks513A8KwkFmTofrB/1hstM8ETvJth9ZKctgLkffJYIQ7q5xIAYHnu5dJOAfgOyIdu7S/FlPA3OJ1L6swLi8DZouQi9LZj/q2H2fQQgWtafmrOwbtGFDOUHbVRCmNqxCk+Xi9bSF4zhoZAhsVrEV6LsaCb00pfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=trp5Yw8f165Rl/oFd2YnsS4tfmH9XWPzMgehjItzdeY=; b=w+3bdWuvbgebaiCg13CP+RtouJ5sX3mhI765JrHth9rGKsrb5rH3mnJVmJkeB3Etk5nGbrySHnC7RQtfqV5Z7bFCzfHp5epdpyMptbya6Vrs+4/ldLmTQ5SPPqs3lFZhQiJr/v0YAjYRm8Js5nkoAKKI036d3fKM1aOqQOp9w9rnbX6ZlCu8C1Tc+7KGaMwvHG5Bpforqd72cGuGMM7K3rgiIVNqSVWXQ44O9NvroqvPkrrnwfh1AkHW43sDio46RuXBSVC4VEPFv+WVmhcsb6b4iiTBH9UPZl4sVAj5WhHSfEBZZFY1w6kRRnYIc4o+IqZOzUS6YH2XL+4tSIABAA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=trp5Yw8f165Rl/oFd2YnsS4tfmH9XWPzMgehjItzdeY=; b=5BvKpnzV2fQBP10/uSkUr0whAYEtTy2dunilFsDusRKiAl5Cqk9xilyhLfAeBrb8J44zmuFKGdzzSEciw3yRUwGxdjicr9WPnGYeE7VnDvVHuYpBxshPkRlxbJHw263Wcme6UnDJpXc4warAUiQH65xQjoDNAWOhmPnBoZPQLsA= Received: from DS7PR03CA0039.namprd03.prod.outlook.com (2603:10b6:5:3b5::14) by PH7PR12MB7967.namprd12.prod.outlook.com (2603:10b6:510:273::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9499.7; Wed, 14 Jan 2026 16:49:47 +0000 Received: from CY4PEPF0000E9D5.namprd05.prod.outlook.com (2603:10b6:5:3b5:cafe::68) by DS7PR03CA0039.outlook.office365.com (2603:10b6:5:3b5::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9520.5 via Frontend Transport; Wed, 14 Jan 2026 16:49:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CY4PEPF0000E9D5.mail.protection.outlook.com (10.167.241.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.1 via Frontend Transport; Wed, 14 Jan 2026 16:49:46 +0000 Received: from rric.localdomain (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Wed, 14 Jan 2026 10:49:41 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Joshua Hahn , Robert Richter Subject: [PATCH v10 12/13] cxl/region: Factor out code into cxl_region_setup_poison() Date: Wed, 14 Jan 2026 17:48:28 +0100 Message-ID: <20260114164837.1076338-13-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260114164837.1076338-1-rrichter@amd.com> References: <20260114164837.1076338-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D5:EE_|PH7PR12MB7967:EE_ X-MS-Office365-Filtering-Correlation-Id: 27a79dbd-7e24-44a7-805c-08de538ced05 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|1800799024|7416014|82310400026|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?cJCEeYfar3nzyEYQJxjC+Q+IflT8ClLK3zQVgBHW69ta0odboh2ZiBUoAyPg?= =?us-ascii?Q?QqSjCijWjS6QJsaDCYOojyXQqx8MShw6XwEZ90F6VG/+r6A+pRDcP52YDnQx?= =?us-ascii?Q?5VpqCvMkBmc3pQm81VFOpe8ExJuLzpjKgL6GWoqsChDVbZz1uQfn5zVmDK5p?= =?us-ascii?Q?0Z8V+CsuTU2ZabPomxqFAeO0zgC3q+bADRpBVkKaJiSRfVT4uJ8/aScutwy/?= =?us-ascii?Q?QTQhOKIHWDm4vo9ez+et4CgWMFv1cX09dOvVizB1QHCbDC8TxSYLRW8vq/pV?= =?us-ascii?Q?KM+UxlE3YJxcp6BYqQC2wbE+Indj19PqzYnFVG8FvL9VTVSMPgdfUj0lqE9+?= =?us-ascii?Q?pLBof1feEqUXBUAT91lWI/GbDhIrzClKRMKrAckgHrAKYlujaAU0TuvurUVx?= =?us-ascii?Q?FPJfdG+lUzkxEONmbqLrIJclcQg+gqM3WyL/m6zMuUZtlWmFmPPhYfjzYuib?= =?us-ascii?Q?lVGps9SyJozlodKJKdMzvZbybn7V5XGihLI3vMJD2KmAg+jRk+iEDJZClBwr?= =?us-ascii?Q?zSrv3fX8NM/YnSe6xzrsVv/Vl6MmZ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?Q?vLM/gtSbbHvFNRR4dmc49e/Cpt0/PZyrjKTppggXa4Va3D7XiX7n3pLF8Lfw?= =?us-ascii?Q?71bt11XdVjlwdMozEFyK+T4t336kXGdMN7WPTOl837fgwy20vLvfWu3FZVxy?= =?us-ascii?Q?hi1bobzRwyj/3xztYx+S7UvNY3AI+NQisuy9fBpUf/60PUDy/Nagy39mHaQJ?= =?us-ascii?Q?LHGm46fI/A1Cu1gr2XEdwkovvy4EmD9arw06Vxv4MzxvjnvZQXTc+DKuVgV3?= =?us-ascii?Q?SCFuqQ=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(36860700013)(1800799024)(7416014)(82310400026)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jan 2026 16:49:46.9375 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 27a79dbd-7e24-44a7-805c-08de538ced05 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D5.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7967 Content-Type: text/plain; charset="utf-8" Poison injection setup code is embedded in cxl_region_probe(). For improved encapsulation, readability, and maintainability, factor out code into function cxl_region_setup_poison(). This patch is a prerequisite to disable poison by region offset for Normalized Addressing. No functional changes. Reviewed-by: Dave Jiang Reviewed-by: Alison Schofield Signed-off-by: Robert Richter reviewed-by tags and the small update in the description of 13/13? --- drivers/cxl/core/region.c | 53 +++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index ed8469fa55a9..80cd77f0842e 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3916,6 +3916,31 @@ static int cxl_region_debugfs_poison_clear(void *dat= a, u64 offset) DEFINE_DEBUGFS_ATTRIBUTE(cxl_poison_clear_fops, NULL, cxl_region_debugfs_poison_clear, "%llx\n"); =20 +static int cxl_region_setup_poison(struct cxl_region *cxlr) +{ + struct device *dev =3D &cxlr->dev; + struct cxl_region_params *p =3D &cxlr->params; + struct dentry *dentry; + + /* Create poison attributes if all memdevs support the capabilities */ + for (int i =3D 0; i < p->nr_targets; i++) { + struct cxl_endpoint_decoder *cxled =3D p->targets[i]; + struct cxl_memdev *cxlmd =3D cxled_to_memdev(cxled); + + if (!cxl_memdev_has_poison_cmd(cxlmd, CXL_POISON_ENABLED_INJECT) || + !cxl_memdev_has_poison_cmd(cxlmd, CXL_POISON_ENABLED_CLEAR)) + return 0; + } + + dentry =3D cxl_debugfs_create_dir(dev_name(dev)); + debugfs_create_file("inject_poison", 0200, dentry, cxlr, + &cxl_poison_inject_fops); + debugfs_create_file("clear_poison", 0200, dentry, cxlr, + &cxl_poison_clear_fops); + + return devm_add_action_or_reset(dev, remove_debugfs, dentry); +} + static int cxl_region_can_probe(struct cxl_region *cxlr) { struct cxl_region_params *p =3D &cxlr->params; @@ -3945,7 +3970,6 @@ static int cxl_region_probe(struct device *dev) { struct cxl_region *cxlr =3D to_cxl_region(dev); struct cxl_region_params *p =3D &cxlr->params; - bool poison_supported =3D true; int rc; =20 rc =3D cxl_region_can_probe(cxlr); @@ -3969,30 +3993,9 @@ static int cxl_region_probe(struct device *dev) if (rc) return rc; =20 - /* Create poison attributes if all memdevs support the capabilities */ - for (int i =3D 0; i < p->nr_targets; i++) { - struct cxl_endpoint_decoder *cxled =3D p->targets[i]; - struct cxl_memdev *cxlmd =3D cxled_to_memdev(cxled); - - if (!cxl_memdev_has_poison_cmd(cxlmd, CXL_POISON_ENABLED_INJECT) || - !cxl_memdev_has_poison_cmd(cxlmd, CXL_POISON_ENABLED_CLEAR)) { - poison_supported =3D false; - break; - } - } - - if (poison_supported) { - struct dentry *dentry; - - dentry =3D cxl_debugfs_create_dir(dev_name(dev)); - debugfs_create_file("inject_poison", 0200, dentry, cxlr, - &cxl_poison_inject_fops); - debugfs_create_file("clear_poison", 0200, dentry, cxlr, - &cxl_poison_clear_fops); - rc =3D devm_add_action_or_reset(dev, remove_debugfs, dentry); - if (rc) - return rc; - } + rc =3D cxl_region_setup_poison(cxlr); + if (rc) + return rc; =20 switch (cxlr->mode) { case CXL_PARTMODE_PMEM: --=20 2.47.3 From nobody Sat Feb 7 04:47:22 2026 Received: from MW6PR02CU001.outbound.protection.outlook.com (mail-westus2azon11012024.outbound.protection.outlook.com [52.101.48.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97E973A4F3E; Wed, 14 Jan 2026 16:49:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.48.24 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768409395; cv=fail; b=NGUBY4MHzvrFHkIN12aSnWLS5qzbHSYOxDg4x4c46EfKjZpjHh5jAWa2Gngk/eDzYZi27NH+GSqdSNyxS6wpJIUBUACwnaFlLNBN6qpSiNBV0+VWpR2d8HNfQ4ngJPN2Qm9ZWLPe6FLOBEUZsTSHVeZDH5RZ+29S6Q4kJK1qKH8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768409395; c=relaxed/simple; bh=rVm1FkgiqRxjxALgWdbQdDvlDRSLYmLzkrgDb0JJhX4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=M+3bryoZGJx867WzYesWBI7rirQVC+YNj22gYjg25XqtyrYucijB7CqlKZXP8anFgis6ApZOP28mHWESlvXaom8GeP+ufNP0NX4HWYOdxhgly94lw7d0I/8ZGedFW6SqhqnKDh9gSw0LR+fp4K3VEUQ8fa1fNr53zOLwQfphenc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=0YrXnZ6o; arc=fail smtp.client-ip=52.101.48.24 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="0YrXnZ6o" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NAPaGe9LDrt/J/aMEW+xQ3h86xoMhpNw/aI8hPLdQVe9ej3mKihXI6EmAT6JtF7oKBbm49sMMid/K8oWORsYxZz2bQNyhkTofESG9L0WYcSqBu+8N73X8g+R49qpl7p8vY3XbzBtZj6GmIZDzKoseyk4CjXjxMYsrSLEaB7rf8Exm4ANKnKoRazlTxyq7JAYF4Wojx2pkA3Jjx8g6AsvBug0SmfijUhcFDh0hYKPyXRFUBTuC3Kc8X/+ad4UwuTM2V3Rb+c+6O4pVnMYiGGoeZsj0G5dUm/TiU9gWe3s+Fw68/OXe/vlXcKHep9WdHsBr8b0HJRlalPEnSZZ0YkGtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=whm/9TVz57nKr7U2yw4m8ZqDHTFTheoMGwd01tPe3qo=; b=e1JrXJUJRjx5QA7Y3TB0J7isKsw6hvxndEmbm1ufcjHOsDAQXjwkWFgHgoh59eHk3I2oOwPvobGX6l5F/G0f6kZNc9ecnkbSkuKsL97E7Ge031cQw0kTmYBcjRV+80bjiSulEEhdGNHS3hugTiI5QQDRgd8jAaf8DRGAWcyYYBC2unPajT1TiriSGzVxZOwPEUqAI4Rs6DZe9mBz4kEXG2ayGIKdzw1rCtdirwCkNFuGsW4QUYSLFx7a0XASTddmibdi067sUC/AECshSeBLprsHvSfN0nFxTwHsmf4leDNhSeKoLMn1X2LzJXrVm7leiOc6V4mi6nje0c8dRO+G/w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=whm/9TVz57nKr7U2yw4m8ZqDHTFTheoMGwd01tPe3qo=; b=0YrXnZ6oTETtFO1LokhlRNN/Sg5gK/QWJp19f8iVY1t2lWyqpyJeMnkumb55k6sv2Jhty0sm9geDaoU/Q3WaeYXO1EYBdqNR2xJp/dGTWzKgvobmrAz9tlb7f/fyZPlzgdESwPJic21acKW5yChdgJpc5K/QM0iOmEhwZmBVaz0= Received: from DS7PR03CA0052.namprd03.prod.outlook.com (2603:10b6:5:3b5::27) by LV9PR12MB9806.namprd12.prod.outlook.com (2603:10b6:408:2ea::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.5; Wed, 14 Jan 2026 16:49:48 +0000 Received: from CY4PEPF0000E9D5.namprd05.prod.outlook.com (2603:10b6:5:3b5:cafe::df) by DS7PR03CA0052.outlook.office365.com (2603:10b6:5:3b5::27) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9520.4 via Frontend Transport; Wed, 14 Jan 2026 16:49:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CY4PEPF0000E9D5.mail.protection.outlook.com (10.167.241.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.1 via Frontend Transport; Wed, 14 Jan 2026 16:49:48 +0000 Received: from rric.localdomain (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Wed, 14 Jan 2026 10:49:44 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Joshua Hahn , Robert Richter Subject: [PATCH v10 13/13] cxl: Disable HPA/SPA translation handlers for Normalized Addressing Date: Wed, 14 Jan 2026 17:48:29 +0100 Message-ID: <20260114164837.1076338-14-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260114164837.1076338-1-rrichter@amd.com> References: <20260114164837.1076338-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D5:EE_|LV9PR12MB9806:EE_ X-MS-Office365-Filtering-Correlation-Id: 4aedc4a3-65f3-42dc-02d8-08de538cedba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|376014|82310400026|1800799024|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?L8H/ZHIrgVZqaj7TlqieDbaBvTxf4E5hEcN5m+4uaBSLB2qR0LqhddmXgdBF?= =?us-ascii?Q?uJ1SWOWOcHijOr3s4MEcoHbOfJsDhthd3aS9wj1vxv082uDo26IXYCVib6VQ?= =?us-ascii?Q?0x+iCGG0baGychl5RNodaFbLGnQUIEPj1X+cDYZmk89w7RvF/hr7Rs04ZUC8?= =?us-ascii?Q?r4tGf9sVOJjNYxhxFdGDeghOrG0FLDi3UkwazpjU3V6lgm4lqYmpUlbPfD8t?= =?us-ascii?Q?C4xOBPVxo+UQuGJDnO19yQwaWB7Rgvdc08evkB0GNsHT8PluyUsQ/rERZeYY?= =?us-ascii?Q?O7u1hBnsDQuulhHrvR1KEKP5SDfLHEvBPh6tHm4EWN3eHknBUFPTiU8IeVSw?= =?us-ascii?Q?YHupFvf333CuSP84cImP2rS9oJNCMENWoSUiifC3qfQzBOa67BcsJkY1Yxph?= =?us-ascii?Q?kYH2fHWo4hBf4QxKTAkU+D8ZGo/KeVzYzjZaV86+EXajU2Leyju0bJSvUaho?= =?us-ascii?Q?B0kQ3bMim8+YakWKgmcYs1ggjsgiFRn+EB2HD+GyJyC36fCCAc3Cp1CeXqzW?= =?us-ascii?Q?tgkLxnxCsFm3iOxDKFNQJ/1VbLpO7LqWAMC9om8qJiRRrR0ayjGjS8nKWCfT?= =?us-ascii?Q?86VDtx8kMKYsXayHw5bAx/3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dcFWkzIWmBCTCCr4TOWQUcOOaDAGNZcbx7i8Z16fMBWAPbn67sBK2juzJ?= =?us-ascii?Q?16dK77f0VoC2FVrN8Jzg8VmfKYfv8hLlIAVuSMUh7jOiKaKJ7A+cCMA6/MOU?= =?us-ascii?Q?ZhwXlrp3boFjVt4uFmI3rrZscCEDDAC1AZ+lRiRHvgd7?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(7416014)(376014)(82310400026)(1800799024)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jan 2026 16:49:48.1215 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4aedc4a3-65f3-42dc-02d8-08de538cedba X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D5.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV9PR12MB9806 Content-Type: text/plain; charset="utf-8" The root decoder provides the callbacks hpa_to_spa and spa_to_hpa to perform Host Physical Address (HPA) and System Physical Address translations, respectively. The callbacks are required to convert addresses when HPA !=3D SPA. XOR interleaving depends on this mechanism, and the necessary handlers are implemented. The translation handlers are used for poison injection (trace_cxl_poison, cxl_poison_inject_fops) and error handling (cxl_event_trace_record). In AMD Zen5 systems with Normalized Addressing, endpoint addresses are not SPAs, and translation handlers are required for these features to function correctly. Now, as ACPI PRM translation could be expensive in tracing or error handling code paths, do not yet enable translations to avoid its intensive use. Instead, disable those features which are used only for debugging and enhanced logging. Introduce the flag CXL_REGION_F_NORM_ADDR that indicates Normalized Addressing for a region and use it to disable poison injection and DPA to HPA conversion. Note: Dropped unused CXL_DECODER_F_MASK macro. Reviewed-by: Alison Schofield Signed-off-by: Robert Richter reviewed-by tags and the small update in the description of 13/13? --- drivers/cxl/core/atl.c | 3 +++ drivers/cxl/core/region.c | 33 +++++++++++++++++++++++++-------- drivers/cxl/cxl.h | 9 ++++++++- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/drivers/cxl/core/atl.c b/drivers/cxl/core/atl.c index 09d0ea1792d9..310668786189 100644 --- a/drivers/cxl/core/atl.c +++ b/drivers/cxl/core/atl.c @@ -169,8 +169,11 @@ static int cxl_prm_setup_root(struct cxl_root *cxl_roo= t, void *data) * decoders in the BIOS would prevent a capable kernel (or * other operating systems) from shutting down auto-generated * regions and managing resources dynamically. + * + * Indicate that Normalized Addressing is enabled. */ cxld->flags |=3D CXL_DECODER_F_LOCK; + cxld->flags |=3D CXL_DECODER_F_NORMALIZED_ADDRESSING; =20 ctx->hpa_range =3D hpa_range; ctx->interleave_ways =3D ways; diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 80cd77f0842e..8e92b491d686 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -1097,14 +1097,16 @@ static int cxl_rr_assign_decoder(struct cxl_port *p= ort, struct cxl_region *cxlr, return 0; } =20 -static void cxl_region_set_lock(struct cxl_region *cxlr, - struct cxl_decoder *cxld) +static void cxl_region_setup_flags(struct cxl_region *cxlr, + struct cxl_decoder *cxld) { - if (!test_bit(CXL_DECODER_F_LOCK, &cxld->flags)) - return; + if (test_bit(CXL_DECODER_F_LOCK, &cxld->flags)) { + set_bit(CXL_REGION_F_LOCK, &cxlr->flags); + clear_bit(CXL_REGION_F_NEEDS_RESET, &cxlr->flags); + } =20 - set_bit(CXL_REGION_F_LOCK, &cxlr->flags); - clear_bit(CXL_REGION_F_NEEDS_RESET, &cxlr->flags); + if (test_bit(CXL_DECODER_F_NORMALIZED_ADDRESSING, &cxld->flags)) + set_bit(CXL_REGION_F_NORMALIZED_ADDRESSING, &cxlr->flags); } =20 /** @@ -1218,7 +1220,7 @@ static int cxl_port_attach_region(struct cxl_port *po= rt, } } =20 - cxl_region_set_lock(cxlr, cxld); + cxl_region_setup_flags(cxlr, cxld); =20 rc =3D cxl_rr_ep_add(cxl_rr, cxled); if (rc) { @@ -2493,7 +2495,7 @@ static struct cxl_region *cxl_region_alloc(struct cxl= _root_decoder *cxlrd, int i device_set_pm_not_required(dev); dev->bus =3D &cxl_bus_type; dev->type =3D &cxl_region_type; - cxl_region_set_lock(cxlr, &cxlrd->cxlsd.cxld); + cxl_region_setup_flags(cxlr, &cxlrd->cxlsd.cxld); =20 return cxlr; } @@ -3132,6 +3134,13 @@ u64 cxl_dpa_to_hpa(struct cxl_region *cxlr, const st= ruct cxl_memdev *cxlmd, u8 eiw =3D 0; int pos; =20 + /* + * Conversion between SPA and DPA is not supported in + * Normalized Address mode. + */ + if (test_bit(CXL_REGION_F_NORMALIZED_ADDRESSING, &cxlr->flags)) + return ULLONG_MAX; + for (int i =3D 0; i < p->nr_targets; i++) { if (cxlmd =3D=3D cxled_to_memdev(p->targets[i])) { cxled =3D p->targets[i]; @@ -3922,6 +3931,14 @@ static int cxl_region_setup_poison(struct cxl_region= *cxlr) struct cxl_region_params *p =3D &cxlr->params; struct dentry *dentry; =20 + /* + * Do not enable poison injection in Normalized Address mode. + * Conversion between SPA and DPA is required for this, but it is + * not supported in this mode. + */ + if (test_bit(CXL_REGION_F_NORMALIZED_ADDRESSING, &cxlr->flags)) + return 0; + /* Create poison attributes if all memdevs support the capabilities */ for (int i =3D 0; i < p->nr_targets; i++) { struct cxl_endpoint_decoder *cxled =3D p->targets[i]; diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index 20b0fd43fa7b..de30a87600be 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -332,7 +332,7 @@ int cxl_dport_map_rcd_linkcap(struct pci_dev *pdev, str= uct cxl_dport *dport); #define CXL_DECODER_F_TYPE3 BIT(3) #define CXL_DECODER_F_LOCK BIT(4) #define CXL_DECODER_F_ENABLE BIT(5) -#define CXL_DECODER_F_MASK GENMASK(5, 0) +#define CXL_DECODER_F_NORMALIZED_ADDRESSING BIT(6) =20 enum cxl_decoder_type { CXL_DECODER_DEVMEM =3D 2, @@ -525,6 +525,13 @@ enum cxl_partition_mode { */ #define CXL_REGION_F_LOCK 2 =20 +/* + * Indicate Normalized Addressing. Use it to disable SPA conversion if + * HPA !=3D SPA and an address translation callback handler does not + * exist. Flag is needed by AMD Zen5 platforms. + */ +#define CXL_REGION_F_NORMALIZED_ADDRESSING 3 + /** * struct cxl_region - CXL region * @dev: This region's device --=20 2.47.3