From nobody Sun Feb 8 03:27:29 2026 Received: from BN1PR04CU002.outbound.protection.outlook.com (mail-eastus2azon11010031.outbound.protection.outlook.com [52.101.56.31]) (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 3937925A320; Fri, 14 Nov 2025 00:40:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.56.31 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763080862; cv=fail; b=UgP3EID1Pr8AAP9QOk/2wi/hW5cyMbtZdLm8D4iYycZBoj6Hauz0ydmePFBHoVkA2zYbPkJmg8ZhF3H8PWMvo+Z0HagfAStv9h38mZ2c64lqaNlSkbSggwOWeC0HSnD1k11JJw7PllwWsHyJC2kV3yvGF2tyeXjlDyjsYSUE31U= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763080862; c=relaxed/simple; bh=JLS8R12RZ5/HQZ4HENy0nQbnkZZ+1UT5vPEOczjcX5E=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Z3fzic/hKkailShB672N75WZ0+c+7MTEaqOKZ4Hir5NMshqpEUYk4fNE3qvwKP2IQI/L5qklASt3FBsM1wNGBzGIGwDfAba7/VIoOWG2EmOiJyZQe/yNTjO1ExXXL8Ce5nQx1I9Lvxf1rdI8vbgFCJXhJrRPpRPwA69Ooiw7mgA= 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=IolQyLh/; arc=fail smtp.client-ip=52.101.56.31 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="IolQyLh/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Fceg0fKyq622jAuXlA7qNTjh4CWQNyMqA3xB8cenDqBeD8FZ7hHUt/ULo2QeJSI8tdNnbZPqyfG2V2oCDgVbfAHkuSuPftlnrCRzpzH3uJyPr4Pzgky5JjfAszkapCajYxX4eFD6ULVbQXbWClkOgRpOJ65N181lNB/0NNn+igJRs9SiytLkuiKebdFKfrRrlELF3758cMtFnrJ96ZccpNwEjm+r5MoTbuQzcAmvK7aIzkA7BaZM4T8o+WxPUNPpYEhF0/RVgMqHr06Pe84Yz/OYgj5wFTdyZMf+xMUR6H9QUew2kyjuUi8ho6donICiB2vBHaOogdgwhxq5kw+HOQ== 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=tgol9ma4L0ejYAP2rul9IaSjIxNyP2viFpL+ErVHRpc=; b=Jrs14/CfNeGOkkTdtMqaCJS/5N5Nd3Q0DN9FofM0UzPeOeoAV2IuSaUb0CYezKMKcX8OZOMz52YADn7TxUOl+3WhyrNISiecVsGPMySV979BGk3Fl9bHtYRkimV8neHxAJ+cN0JRpmubicoOPVJhr40P8CX38ozi68IPpMjIN7s3kYBw23VIKen7D2wOGyGoFVwfXtCg9ceJivmj25QqPJHqHEyTkhw0MQvBaZtmYyLFvNQXOu7mvapNBsVMQVPpJtGFwWIwdGTgyatHUC6inZlPHGHal1cGByKGrFGEcOjq0PmxcmxacSxUWjRjKbGloV4PFbn7f3kJ1wGkZsIM+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=tgol9ma4L0ejYAP2rul9IaSjIxNyP2viFpL+ErVHRpc=; b=IolQyLh/GX9fS0gjVIimtmm5G9vTt+EgciwASylZzNpu9Of8IVxMC+VYSExVz2Zq4sfz59BAPpYuL31ojzb/QOZ2RQcMZhiMMYhQpXtuLeWT12BEZRHhngHOWbzoODZQPifOTctwas3H9gWu+jBuxNwsqKLtJST2Z5lhNEAang4= Received: from MW4PR04CA0379.namprd04.prod.outlook.com (2603:10b6:303:81::24) by CH1PR12MB9622.namprd12.prod.outlook.com (2603:10b6:610:2b2::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9320.17; Fri, 14 Nov 2025 00:40:56 +0000 Received: from SJ1PEPF000023D2.namprd02.prod.outlook.com (2603:10b6:303:81:cafe::6c) by MW4PR04CA0379.outlook.office365.com (2603:10b6:303:81::24) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9320.16 via Frontend Transport; Fri, 14 Nov 2025 00:40:34 +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 SJ1PEPF000023D2.mail.protection.outlook.com (10.167.244.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9320.13 via Frontend Transport; Fri, 14 Nov 2025 00:40:55 +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; Thu, 13 Nov 2025 16:40:49 -0800 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 v6 01/11] cxl/region: Rename misleading variable name @hpa to @hpa_range Date: Fri, 14 Nov 2025 01:40:06 +0100 Message-ID: <20251114004021.1310661-2-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251114004021.1310661-1-rrichter@amd.com> References: <20251114004021.1310661-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: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D2:EE_|CH1PR12MB9622:EE_ X-MS-Office365-Filtering-Correlation-Id: e9cf1470-8ead-4182-db14-08de231678b3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700013|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?OwEU/K80oMqUP1hkVVpSwS+AsNUNvA7V3/7vG0Mt3D86kIQEhtF711ucQAMO?= =?us-ascii?Q?IIJf+mYxzm9QhIgYiTeF7opI1j4kU/8ROSvvyCkZ5Bgf8yQDOPVBtAr2SRUU?= =?us-ascii?Q?+BUUq80Tbm1IWar71umZWyem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-ascii?Q?ZU5j7CAIBzsHwb0zjKV0D9iOp0yrXuIOSKJlpB6vwkcM+lpB2d+/fTQdk8yJ?= =?us-ascii?Q?bbHZ+zjLJRAUJz1CjfHBcHy5Yrm3QVZZ+xoHNKhaUQj46k9ZN64KPVbR0mdn?= =?us-ascii?Q?PtgWPhlk8r2Q1A1aAyCTqhyjD9s4iIN/Ak65WG/00LC5ot7P18UDlgGiS96X?= =?us-ascii?Q?0rRQQrlprnApSGUQ8sQ5IfgMfnev5yU5vXiFK3Mvra/S1s9JmAWGVuSHB9co?= =?us-ascii?Q?qHlLBmJCrzxlHqOs7tKPnjjhB5krL1sajSNGwWbo9sIV6OdnEmW1RlKw6pAR?= =?us-ascii?Q?CyTyFjhEr6sC7OyPZYgP6+X9p1Ho5fiJuw/uR8OvBDME6DuaGL48+LXh6i6Q?= =?us-ascii?Q?1pRuJyEfs5otU7u0mIOuphZ6lPQXvy7KMiBd7qrZ7F31Jj98YbB1i98uUJ7r?= =?us-ascii?Q?XWUzTTNxonrHTGjaEflPouVqSkuajVDP2KKRJdgS7CW6u6jyXUvEzxTsVr48?= =?us-ascii?Q?yVkbLPT1Hz+QA9PDFExOX7HSykp/eVBKVt7eb3OB0F2t2Mt+/379kp193o27?= =?us-ascii?Q?WtZCPYLiRbIN5c/e5zM=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(36860700013)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2025 00:40:55.3157 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e9cf1470-8ead-4182-db14-08de231678b3 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: SJ1PEPF000023D2.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH1PR12MB9622 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 Signed-off-by: Robert Richter --- 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 8cdb6a935289..e108819593e9 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3345,9 +3345,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; @@ -3360,14 +3360,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 @@ -3433,7 +3433,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; @@ -3454,7 +3454,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); @@ -3533,11 +3533,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; @@ -3547,7 +3548,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; @@ -3558,12 +3559,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 Sun Feb 8 03:27:29 2026 Received: from CO1PR03CU002.outbound.protection.outlook.com (mail-westus2azon11010059.outbound.protection.outlook.com [52.101.46.59]) (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 CDD6526059D; Fri, 14 Nov 2025 00:41:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.46.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763080865; cv=fail; b=Allbh26SJaL6Oe/OECicZsLR6TTgP87swnwxLYUxaJ9JIEs1NDu41HR/AD8zqZRpjYsnfhsAc+Sqj+2pmJOzlRZp6WN+BzqAndyc8aYKdPJ1nyG6R7SkTbkdu0sS46lAN+V5apAZnPNFIqS/yjWbf4x2mjPpXHTTi/+jZ7AAmHE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763080865; c=relaxed/simple; bh=rFeByDsxyBOl4GvAKL+jHGD/ANn3GVYNmoAXQhkpfUM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EUVudKe3V5D9U6so5VCZ7qCbQ9gLlclBgWB/0s7qWTxUnryNdAA0o2coPLLpthFbwq+s2RsI+aGCsbkePwVnCK8Zk0sa0KQid0eFMfCq4uNRqE5F0ZbXEoDfS+CVbWCHEAqYhz/ROqPfnbJHnxVr4+DPsFj64iRkGue89DpQE/Y= 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=TaTwtt20; arc=fail smtp.client-ip=52.101.46.59 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="TaTwtt20" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZdqPkqbsPMajXO2TeuqP3pjuujEx/smp7zjVkrTq5h/FijSsrRDhlivuQ0bYfa42ViwRbPC8msihZElBgYoJ2ns291HKu51/wG9nWP14fMbgkNPLggS4Vm40+4bQnDS2OBAszkJkmZHwgrh6ndSRUOvXewTFlzTj3f8ZCd1lDC8dxRexyvKP74LKGQP3UKUZGVZlWJsq0LhWnUjhsf8uKD3afdT96Vr1Ls92Ysx8SOF109ZRTZLHU3+KEdVywWHL0zJwzbNxQqgiTHebHJ+qnmiV7jsrn/1p2hmqaoN90Iy2EUDONIRZHPnNloxaD1a0LLfg8uunLcF0OYG+lnR76Q== 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=JQ7wsX7LA3oR9Oe2ZJQT6W6FeRhidUPF9O7J8GDBD28=; b=pEU5Y83ENbEKm32k7mVt2v4vO/V0BMycBR+xk315WUgQizDsa9aHCeclkn9oAFr0IBKP7sOldQObXsB1LibHqwJ9lJYpsIKFBVr58StTc3J8CfZz3/Yj/JCziYWtJ2hpitg8xeTJOlZU/EuRRB4qoZ2tg3jj9INZ3AccY/qy4dcvY8NCNmUKsiZq+K1YCx4GK7ukp1PyNLVfQIRLpGYvObtpWaZBHrAv1646youNftVCddrU9bpcelttDUilQihVIMuyLUTXEOieTiAjA9948WCyCo3P8+q8XoUL3Q8wMNP/rZMs7Ip+BmNBiOacNq63+QDmEV5zmUFuYGmL4Dcoqg== 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=JQ7wsX7LA3oR9Oe2ZJQT6W6FeRhidUPF9O7J8GDBD28=; b=TaTwtt20vvtvfQTclrxN5dp3/HCFD+o+J8N8EaYZEpMnbZhhC0CGk4Bqj+Jtnuny+4GFPk2f7s774Ir1dH3UaEaAoo/OyhFolkNGA8QyUZbhH2QjutB1/IPDlr33WQh2c2jLzKNb2/8UGgjqsxPKyHVhVAmSRy8MGomM+CWb2hE= Received: from MW4PR04CA0369.namprd04.prod.outlook.com (2603:10b6:303:81::14) by DS7PR12MB9501.namprd12.prod.outlook.com (2603:10b6:8:250::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9320.16; Fri, 14 Nov 2025 00:41:00 +0000 Received: from SJ1PEPF000023D2.namprd02.prod.outlook.com (2603:10b6:303:81:cafe::ba) by MW4PR04CA0369.outlook.office365.com (2603:10b6:303:81::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9320.15 via Frontend Transport; Fri, 14 Nov 2025 00:40:43 +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 SJ1PEPF000023D2.mail.protection.outlook.com (10.167.244.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9320.13 via Frontend Transport; Fri, 14 Nov 2025 00:40:59 +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; Thu, 13 Nov 2025 16:40:54 -0800 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 v6 02/11] cxl/region: Store root decoder in struct cxl_region Date: Fri, 14 Nov 2025 01:40:07 +0100 Message-ID: <20251114004021.1310661-3-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251114004021.1310661-1-rrichter@amd.com> References: <20251114004021.1310661-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: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D2:EE_|DS7PR12MB9501:EE_ X-MS-Office365-Filtering-Correlation-Id: e03c4259-40f3-4378-e8c8-08de23167b32 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|7416014|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?qLLxlzlk1Spi0atx4uQ8+M2mG7Y//dDm78lPML19KL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hsP002RgozoovcrIRFeLXQ/oiYNzY1SZ87NTl3oOjugNl01W1uB7?= =?us-ascii?Q?M94DMY2rdN1IobT6Ql5xBqIg3WuGcC7Uk6wXbxZmH6z/QfSegBgFEPl8cNxH?= =?us-ascii?Q?oHzGev2e8R3DQZsU0wEeD+YOFmThunEMOA5hUmntADYQcWNdzbfNEEU1H6dQ?= =?us-ascii?Q?LkSdc9+PHF6avwIcYtYhJlKGni7R7nY6o4GJhQtswHzJsHuQ6pZkTdYEYg4c?= =?us-ascii?Q?ekOuJZTcw3DisynVwheRynf+fRGU+wvemX6vPpvct0am+Owo537GoE+a3pOA?= =?us-ascii?Q?7jv/1u78rdd0fvG6um+NLYsoNP9vtBcx9Ztc6qPDfUHQKtr5PmcXXXCDgbGR?= =?us-ascii?Q?bci/JDQVEyg3ERqXvihesX9J4q5PHsN+PkR00cFWJGhyaHAi/2DEWETWYCz3?= =?us-ascii?Q?Zot9/UULVgLNWsaG4IClXgp3EJknZ4QPV0d1GQf4ooVUhM/z/Gyxt1KWWxpF?= =?us-ascii?Q?B/sm3+BpOq2hzEFmXZkVbhwpZiwTcgJMfwqk/sFR2SxxA/0cOwi9MEkLsoDP?= =?us-ascii?Q?4p60PMNnbh7iy8/LW3m4ELQEyiLL2J+Ye+Oz2SC4JICtY+Fdy/Xt6fYePPSI?= =?us-ascii?Q?o1du/mepLHQuVwo9j9W6OpVlSitmYXY8grLOM1BoilGXBYHnPmZzxl83qYA/?= =?us-ascii?Q?K6+c/M3CdRgo5FH6E4E=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(7416014)(376014)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2025 00:40:59.5017 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e03c4259-40f3-4378-e8c8-08de23167b32 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: SJ1PEPF000023D2.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB9501 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 Signed-off-by: Robert Richter --- 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 e108819593e9..d3bd8d074033 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -495,9 +495,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; @@ -558,9 +558,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; @@ -634,7 +634,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; @@ -1327,7 +1327,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); @@ -1685,10 +1685,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; @@ -1925,7 +1925,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; @@ -2030,8 +2030,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; } @@ -2054,7 +2053,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 @@ -2350,8 +2349,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 /* @@ -2434,10 +2433,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; =20 return cxlr; } @@ -2926,7 +2927,7 @@ static bool cxl_is_hpa_in_chunk(u64 hpa, struct cxl_r= egion *cxlr, int pos) 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; u64 dpa_offset, hpa_offset, bits_upper, mask_upper, hpa; struct cxl_region_params *p =3D &cxlr->params; struct cxl_endpoint_decoder *cxled =3D NULL; @@ -3002,7 +3003,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; u64 bits_upper, bits_lower; @@ -3393,7 +3394,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; @@ -3429,9 +3430,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; @@ -3523,7 +3524,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 6524b242e8c4..e61e274cdab2 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -521,6 +521,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 @@ -534,6 +535,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 Sun Feb 8 03:27:29 2026 Received: from CH1PR05CU001.outbound.protection.outlook.com (mail-northcentralusazon11010055.outbound.protection.outlook.com [52.101.193.55]) (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 051102192EA; Fri, 14 Nov 2025 00:41:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.193.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763080882; cv=fail; b=aOYkrY89YNjllxf9wq5P9H5qPlffvt0zzVSETBYxgObyvoMqb63WeECd+d/Qt2vzC5zHZ78Wnp/AwNzFLxZgxDU+XYYCRCW1t6posBJ0DROgSn0QjNcZQdVVlMw+8/5VXCQH3MRzYWcluSbbyYAImI/AntZkh0CODl39uaZyn9U= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763080882; c=relaxed/simple; bh=/m4K2MszO4PSIp4MRyq1YJ6RQplFH23mK8hnk27UTb0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dTaO30XU3RTGt4OAcTJb5vGMA//paiHYa92w/Wim6dXiG1uytK9SMTXZ5nqcfc6odM8dCs8r3+EOzifJ99jkcFjiYwHa8O6NJslKAFIzmhfi3c8hTAULuwyL+228hVJAF6eADeIWz0Q7chWvORoCDxZUdXH9/72IpAZS4GX3j38= 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=a2lHTj9A; arc=fail smtp.client-ip=52.101.193.55 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="a2lHTj9A" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hYaPY+m1xupy6XUgEz5+wxAP1QZ5mizEiaJ+s8TXOkG9Dpp9u8sAc2Kp41En+QzOWPr5iqFoinj9/Yr6osLs3hWUYRGK/nWT6cONh+WKWYU01acoa3fbpD+WcIzHVWOQh/t0JlLCizv3do83Zxs9SqEhSnalqiQc9Q3Gq+1WlhSOSnv9k/uBojfXmWFgb7/ERPUseRwM77wEbhErUNLgSyHYPsGm8KeD0IjUQDcwWNm+thaZE1aksQxpJ+EHfOognw4wIc6bf3lTe7ojTxOdjuQ/2mlOHE/0GEaDAqDynufd46AkIjUvqKoihwWFtEBOIGZ4csIHzKtsG3ZnECLGGw== 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=tSbQ34c5JJeZVTwwFMFBOxctCj0izz6Nby7BAoJn3Lg=; b=VTuVnjNEwDZeQ6f4unb7Z10CLN+IpX4yb+N4aSL1NfRMPrj+F9bUmFmkEiIaksWZe2P0S46DSOkNQUpse8A8gXT2dLA90lBUYlBtp51Vka1dTfMNyIxGIJ4fwaCxcn2SEsuzR+EbPpDHyXFJIH11YtZdn1oQe0DCYJ2wcMEM/OgHcVyIk68hwv24lXq6z/yVjYTlE9TuxiKiOxMTZK6zM3FFbVDJYTqA5ySKRCPrq22X++xe64xJ5Smohp5wr7DU7bOv+rxy/S1TwoQOJQULaah8qjrzupEH/1aKO1U0dwWRMLbS6A5/bDz+yAvqXQCOIU3TpqFnCuqDRS19RvYfLw== 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=tSbQ34c5JJeZVTwwFMFBOxctCj0izz6Nby7BAoJn3Lg=; b=a2lHTj9A2XjwuMzs/IkbAGwg05mRBaSEHPedvH8290vTmES/Qa86NJzjkWZd3yOAzS8HiCJRT0quIo0HeNBn8ySdFAiVAfaOBpDYNEDIUy0QeP/Bd7M10myw27d0K7jRDBsAR8AGopE1gk3UEtOZzlQF89oKOU2HhuNSVAXUWdc= Received: from SJ0PR03CA0264.namprd03.prod.outlook.com (2603:10b6:a03:3a0::29) by SJ0PR12MB5634.namprd12.prod.outlook.com (2603:10b6:a03:429::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9320.17; Fri, 14 Nov 2025 00:41:16 +0000 Received: from SJ1PEPF000023D1.namprd02.prod.outlook.com (2603:10b6:a03:3a0:cafe::dc) by SJ0PR03CA0264.outlook.office365.com (2603:10b6:a03:3a0::29) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9320.17 via Frontend Transport; Fri, 14 Nov 2025 00:41: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 SJ1PEPF000023D1.mail.protection.outlook.com (10.167.244.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9320.13 via Frontend Transport; Fri, 14 Nov 2025 00:41:14 +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; Thu, 13 Nov 2025 16:40:59 -0800 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 v6 03/11] cxl/region: Store HPA range in struct cxl_region Date: Fri, 14 Nov 2025 01:40:08 +0100 Message-ID: <20251114004021.1310661-4-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251114004021.1310661-1-rrichter@amd.com> References: <20251114004021.1310661-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: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D1:EE_|SJ0PR12MB5634:EE_ X-MS-Office365-Filtering-Correlation-Id: fcd2c869-b437-4f33-5455-08de23168414 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|7416014|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?9hUbZKnfkDzDU9VY2bVy4V5ReyeNa/b9pe/Z6MqOt2+o4vKc7CxuJjwYrdfu?= =?us-ascii?Q?J/jZXFlBiupt/W/CftIhACBiNAxss++P50/xjJIqXQbesr/LdzY4aInXs5JY?= =?us-ascii?Q?26R7nZrHWRWwkRx4RJxkuWNv9/gy09YMn4tWzcYSfGuTRe0iKVO/CWpnSJvS?= =?us-ascii?Q?nC+3L2jxml8hMvd9mtPpE17lRSMacoFFmLt8/O/taUIpiJk0ZTP0ehwQmKff?= =?us-ascii?Q?K0+o7kQHdMjbGQPHp1Dd7dL9cyLyO92tvwIFeMebuvPOR8YerVfB1GMR2uP+?= =?us-ascii?Q?lnOVp57UtfunFStMptcoGr1P1V/m/vxwP9BXXmEWoMeDOVJnZWaSpadZOU7L?= =?us-ascii?Q?A3mEWDI3dyMwmLLZBpU/y/OVMXp0foRny4+NAbqWFeOuTMxpLzIgDYDg25Y0?= =?us-ascii?Q?3Y0n8oCHSqNRhLKYiM5jxULNZWJgBuVpWoHs/ZPJ05lhTDuGsNGURBrVrrC9?= =?us-ascii?Q?puUvE8b+pb9LTVjjZ0UFcR0WOMGmFV8Ch+FyJztkUCRt3OgulusyxaP3Q79i?= =?us-ascii?Q?7Pp2sPXwVSFdlw9FbLAcaTZ7/3PxjCbRK0u/KbJ1keCUJlzd5tJxqcn8U8XM?= =?us-ascii?Q?oMKEPVuorFZ7um6rGyWW4zeXwC6O9BPpmuShnDmaEWUAMVIJv3XHmrcD7D3Y?= =?us-ascii?Q?civu/nTZ2sskSRnTR1eEZzYSmNQRL3eErnwao+me4Rr9WwaL9vZfZ7gTDq5c?= =?us-ascii?Q?vFLJqsfmPpYHfi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RY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(7416014)(376014)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2025 00:41:14.4018 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fcd2c869-b437-4f33-5455-08de23168414 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: SJ1PEPF000023D1.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB5634 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 Signed-off-by: Robert Richter --- 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 d3bd8d074033..13b4e27248cf 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -670,6 +670,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 @@ -706,6 +708,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; @@ -2407,6 +2411,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); } @@ -3450,6 +3456,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 e61e274cdab2..4633004fb770 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -522,6 +522,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 @@ -536,6 +537,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 Sun Feb 8 03:27:29 2026 Received: from CO1PR03CU002.outbound.protection.outlook.com (mail-westus2azon11010006.outbound.protection.outlook.com [52.101.46.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 5EA2122B8CB; Fri, 14 Nov 2025 00:41:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.46.6 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763080888; cv=fail; b=ULhV4BZ+hixreAK7g128xpECFjcYyqP+t4SfuDgoygaBKS92kx3uy3AGGS0Z1FYM6YAqKiGCOwU6E+yXc66uJ88mUcA7KpVPt1QWXOJerOpIV3ODFsSR0Ucdbt2TFW/HwnBB2WVqUUp6sPhIXl3MxphFy35WPsaA9/PUoGU1E8k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763080888; c=relaxed/simple; bh=Ruw6cex6Mkl3tOYxwXtIS9uSljMfdsGuorzsuHZfGmI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=p2WvqajHNezjGwxUi1mA4GkLwdlirIlx8EdgmIoJW9KEoIMUpnDcU8SgzaJS4d2HHI3j1FRKVGKCJnMGRdSwyqwaKxchxclh3Fo+aeKNydYpBz45ChOdismPibsbvgOw2ez8kVixtfsgB3Gkakz3vcTe+VVxFhJeiDOpb0cr7tM= 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=3OAmDN57; arc=fail smtp.client-ip=52.101.46.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="3OAmDN57" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=d4IqTJjS2/RqPr57wC7LrJxFB2VNFeuAUbyeEG8YQdFsYkpLpvOo/Qu4lETuIKunI2iqnfL3I7qFHT+65lm+2okGl87VEoobkDmhcjuwp1z8hVxlkB41ThdoylzyIrXVmpdAu9TRz2FqDQ7SpFY4gXiaKPHaEl2Jk+uQ/Urr1K+9pPRy641B340Ma9QNH4yzrEItjwz/voyLQTE1u80T1HUXm/wvbxbMfD7q5iTEGP0vMqiPlc2st3HL4qqJaBXAYGn5P8+AOoQR/oBWH90z6gzFdzq86sb2+CS7TO9KTlGHfgg2Dir9XgRsO2AF+LsNZmSidL5kfzUxolFjwpCKwg== 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=bI1Hlz+H7En0RaN1e5KhWTcYb8eOSnWXpCGMI4CjbDI=; b=BOW5h4Cj9NCiPRCT7v/SGqgeg4akxTaP30TUc6LXc/tlgWiuVe8GOZgofPfj1qrEFHXgEpbQthDmOO8bvoCOjTorIIBsbTcEKhdxpnjfxO7fV7WSY4PyhTIV0KtrOAM59lA95d0Kzko2FehtgxeBkj3ima0CZ4W8KcwP44UZVIHfEg+gQFyORENQvtP0k7p+EVsZzR+ibWCo7B5dTMQe/a7vHJjtqcZvPwruL/iNspq10OnTyfb5mAWMbxG2kUx073iItBQhB2/puGc84e5QEwkX1kOKE+yhICDeIBQ8IkzOOee5AHUWvGyNS5QBsyjazJj4GKJQzFeHOSrH5IKgkw== 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=bI1Hlz+H7En0RaN1e5KhWTcYb8eOSnWXpCGMI4CjbDI=; b=3OAmDN57PQ72POFv1hBhrlAxVtgbPe61a7ifNJcyauuHl7VHVSqfa1Rfwp6nWaM5q3VS2i0nrshEjk+9tNkqUDIsUHirPEVoEjvM+QGbsb+ahb17P7gpE261JEI36qy80FLsW0VdYE/JjDiRDTwwybGKVnS/ZxAxgYdKIc01/2k= Received: from SJ0PR03CA0266.namprd03.prod.outlook.com (2603:10b6:a03:3a0::31) by DM4PR12MB5721.namprd12.prod.outlook.com (2603:10b6:8:5c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9298.12; Fri, 14 Nov 2025 00:41:18 +0000 Received: from SJ1PEPF000023D1.namprd02.prod.outlook.com (2603:10b6:a03:3a0:cafe::d8) by SJ0PR03CA0266.outlook.office365.com (2603:10b6:a03:3a0::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9320.17 via Frontend Transport; Fri, 14 Nov 2025 00:41: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 SJ1PEPF000023D1.mail.protection.outlook.com (10.167.244.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9320.13 via Frontend Transport; Fri, 14 Nov 2025 00:41:18 +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; Thu, 13 Nov 2025 16:41:04 -0800 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 v6 04/11] cxl: Simplify cxl_root_ops allocation and handling Date: Fri, 14 Nov 2025 01:40:09 +0100 Message-ID: <20251114004021.1310661-5-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251114004021.1310661-1-rrichter@amd.com> References: <20251114004021.1310661-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: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D1:EE_|DM4PR12MB5721:EE_ X-MS-Office365-Filtering-Correlation-Id: fc0a4bb5-3a1d-4a2e-7202-08de2316864f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|36860700013|82310400026|1800799024|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?OvaZqWZzjf9ogXwXgKxq9lXhVZn3VEm4EQX7ZBcPRE9AbAS14ihnJ8dqgs5I?= =?us-ascii?Q?mScbHcL24KFPC5PuBNJFhuFMeohdEYJ4jcOd2gsDjrSmd7UmaIkkKIoWSVYA?= =?us-ascii?Q?s2qy0U7f34XvD4EWpgzF/gsJour9RT9UWjTJ78QntlkPbpWQQbaKwiT7eQFd?= =?us-ascii?Q?ffEVpGoTgus36kr3p33rExsWNE/PCr0vWZWPIbauJ5aYXrefgmKKqyuOnSBV?= =?us-ascii?Q?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/y8wLKKqDAwfIIJGgKEGq1RGUdAP4?= =?us-ascii?Q?BZYdg+Zf1V/A1umHEjfQ6vW3OE3QcSCQIE5KnpVRrk6wYxyxDHU+5M4g8cdF?= =?us-ascii?Q?949aKRQz/zeosDG55fjyIwOhRj9ev/s+FKiYLJkjcFHoRFptEwfGgmVe5QMo?= =?us-ascii?Q?7trz6QzhKIUzPOvtuKxgauhf5AlJMCIYIcRNKifZRj6Dex2rmOaPRVaXVmLd?= =?us-ascii?Q?UA6wSY6KEsB7e8viUvm9WKY8qWYz5pP4kybnNyp1i/y/jh3EGAGUwcG+vyPW?= =?us-ascii?Q?/sD+9XxtI5V7JpOtCnGZXs8pTJXTe2B/c3kG7E+ZYsxvRD5wqeKzi6RytFlp?= =?us-ascii?Q?R8CtJzGaOGaG2mwNVWCeSw6pvv6JX6bowqwWYidR1JPgPo/qKqkftF6Ap76B?= =?us-ascii?Q?XBfCgEK8bRSduDkeRfQkQe5+aDx5v7R93HtnNxBFGguE7OFDpjDb6A5C1bUC?= =?us-ascii?Q?lZEXT7r+N01fBweasPM=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(36860700013)(82310400026)(1800799024)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2025 00:41:18.1446 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fc0a4bb5-3a1d-4a2e-7202-08de2316864f 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: SJ1PEPF000023D1.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5721 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 Signed-off-by: Robert Richter --- 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 0a1bad3cafa7..866813e1b729 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -299,10 +299,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) @@ -907,9 +903,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 c4bd6e8a0cf0..b84a9b52942c 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 4633004fb770..8945dc1532a7 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -638,6 +638,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 * @@ -646,7 +654,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 * @@ -655,12 +663,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) { @@ -755,8 +757,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 Sun Feb 8 03:27:29 2026 Received: from DM1PR04CU001.outbound.protection.outlook.com (mail-centralusazon11010057.outbound.protection.outlook.com [52.101.61.57]) (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 6044826F28D; Fri, 14 Nov 2025 00:41:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.61.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763080890; cv=fail; b=RSck3q5r4Co3iDXihVPbhFOhT3Fc9NvMTr109rSPaX9/RY0SBcICn0enomWlHpZc8T96nCJpOT9ihORKr0xYMXTXvDN4NyuW0XOlwix0KsCWLBP1p8HNC84tyvKqI7EW9e7qRmTe2fmNLoHY3N1gZCFdTwdT4+PnKLouhTEJBLY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763080890; c=relaxed/simple; bh=NndT+k3MCNINVWqo3EPl3NPWWiToLoamysBBp6eJQKw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QQu0yIVnzHRU7q2QwMUEI4Z4GWK3Rzka5Ia26GioAzB7Xqxb/SZS13gSCaprdDh6EItHDjfNHqmf0P+bFJVLyWrAgWZPnyQJSqHkkZ2V+GITyDTIS9YLNG1q1D4JsuupsMSDSdtn4Tsw/rtyFjNUVTTtL85BEhhIV0IUulifSGI= 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=Po5BTiGP; arc=fail smtp.client-ip=52.101.61.57 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="Po5BTiGP" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TPipCeqX3CtWTr09HhnpBWBNh+YE+B3Na79prXqZiHB/Qo8VD/jhKLmpD6Pn+XpOfS4tpXb7/UoTJrXMhWXYgmjs7yC/1iWdtx9FS2AfQm+T7tRhnB81oto9Kq7oXUuPZT55wKgtiCwK9kA59HY9o4kpIjla4xFrj9awkKtOtDhrXMAYJUGjSKUABg3al1svhk7LzXrycq015a+SAjAh3Is0eYQdJYSGoPFl81AjZK+Mbc8/kGMd3H+ITWhwD7u9o4UD+TMiGndFUK5rHqG0FuepnDlzRAtxd1DUguvbxo/xwmOntwjqmgI9WHGt15wz9/fqkjmmT2T+sAPKFq4UVw== 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=UM1vnZU7MoOj5AeEB3TDs69T1a55Gy2TFxe8IBC6cLA=; b=j7pWcaT+73GsS6fS5YVSGGRFunjbIwj2/JSeuOLYp1I+qJEAnNiU7q+ygespD/5g1CPkyrX+sUyU4qqBf+DIPuHy54JzI2prjXcPgLXxA6GqkX8MmIP86ni4KR8B9jiV1gwqqhzTpIuJJK2VsKcRqmCGjZA24Nl0pvdH79Yx+JkTY4syKJomLzaD30GMLSpAHzfudJMB9BTppmEWSX0ORKusismjy/1mXBMAmWEVQ4/EvVSF50NJUi3y3YoodzV7p79N3vVG2VStSMDff7n7aA1jCJ5ZsX6/PubuWGVte9Wt2zBAWurzef4HOvAoIDVo5KhALE72Wivk0nmRvwRmyQ== 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=UM1vnZU7MoOj5AeEB3TDs69T1a55Gy2TFxe8IBC6cLA=; b=Po5BTiGP3CJO+nsgpnjaYJjv29w3K6Y5RnyG+PK3agmz7yKlDS+9EbKKbZJLALS7x3FIU1XYKLonJ2ooULB6IZepH8pMxFEWlQtx8r3NvK7TLpxnev/DwRJ5ycG1IW4cVxsyIuCUjLzeTyX9dezE4fmJ4Y2GIQie6sSlS3s3JBw= Received: from SJ0PR03CA0266.namprd03.prod.outlook.com (2603:10b6:a03:3a0::31) by DS0PR12MB6608.namprd12.prod.outlook.com (2603:10b6:8:d0::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9320.17; Fri, 14 Nov 2025 00:41:22 +0000 Received: from SJ1PEPF000023D1.namprd02.prod.outlook.com (2603:10b6:a03:3a0:cafe::9b) by SJ0PR03CA0266.outlook.office365.com (2603:10b6:a03:3a0::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9320.17 via Frontend Transport; Fri, 14 Nov 2025 00:41:10 +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 SJ1PEPF000023D1.mail.protection.outlook.com (10.167.244.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9320.13 via Frontend Transport; Fri, 14 Nov 2025 00:41: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; Thu, 13 Nov 2025 16:41:10 -0800 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 v6 05/11] cxl/region: Separate region parameter setup and region construction Date: Fri, 14 Nov 2025 01:40:10 +0100 Message-ID: <20251114004021.1310661-6-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251114004021.1310661-1-rrichter@amd.com> References: <20251114004021.1310661-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: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D1:EE_|DS0PR12MB6608:EE_ X-MS-Office365-Filtering-Correlation-Id: 18f615c9-03b0-4130-3025-08de231687ea X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?z5buLhjl6/v0F5w4GbNcJvJHfeWuc/zziN/tyE4rL7W9Aof+Wc7kpTWQvPDt?= =?us-ascii?Q?o4whNGsShC5NNoKjl8sMxvlks2lYGThcVpjjKRlYH+ZfCeTfVIkM3tTZqPGA?= =?us-ascii?Q?HECrtCS5hfkIqs04Rs0fXfMeyyvd2Ezn3Zy7XKn5iP3siz5LD7iRaIdBnCar?= =?us-ascii?Q?7sGVbMXxQjZgABZqf7jNYbvc8bBr+UcBfyBTPz3wFPb3cj6+kfLH/V0rlMmP?= =?us-ascii?Q?rNxXsW8iNVm8i1zdnF2jVEXriB6U0WNpTcodqv7f2nIdLeStuiACInaxC3Gr?= =?us-ascii?Q?pnx9PMLq//w576pwYMSLDbokBHIN+1h36kK9UuskO+C7X7sEeZ8zk46L4iiA?= =?us-ascii?Q?YG8gddOzKB9r8zB4ZKo0k9N/bbPW1ACvoXU/YxskSr4z9rkpymcUP9w+uXvn?= =?us-ascii?Q?ylBfsTzRZEZ5ealqUSDjsVIFmO2MwcH32YBk6qW6BIsDWRJD2Zffo+URYzfZ?= =?us-ascii?Q?ELhYJ5KJM5m7hG0UfwkrWKdBX8vE3jDnSAbl7qrdVwDckmt9R7Zxpp8DwNFA?= =?us-ascii?Q?+j6WqHA1Von9n9fC8po54AzTr7lpZF61vRi/Xw9NSEiAmrVrI2brvNN+Wvdz?=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Jiehb9uYz5ZZmBZTm31c2CgNjANuwJ3E8m?= =?us-ascii?Q?lREd4y4MVBLljehUaiI9ozignT9DG/EB1YZgyBwPug6q3yBqi2rTf7IocwTZ?= =?us-ascii?Q?uw2ube/s6TsT45bIdZA=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2025 00:41:20.8382 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 18f615c9-03b0-4130-3025-08de231687ea 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: SJ1PEPF000023D1.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6608 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 Tested-by: Gregory Price Signed-off-by: Robert Richter --- 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 13b4e27248cf..52924006a10f 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3436,11 +3436,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; @@ -3489,8 +3490,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()); @@ -3510,8 +3511,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; @@ -3531,7 +3533,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); @@ -3556,11 +3558,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) @@ -3573,9 +3582,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 Sun Feb 8 03:27:29 2026 Received: from CO1PR03CU002.outbound.protection.outlook.com (mail-westus2azon11010045.outbound.protection.outlook.com [52.101.46.45]) (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 7721A26F293; Fri, 14 Nov 2025 00:41:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.46.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763080891; cv=fail; b=iuKoUqoKbjVqdTHMkTh1cRtWntZ1Iq3dHla4xgZJdy2SpuM5xEfzc70b+O4OXxCX9TtGSnEaWxS+yrhSedb+EWZ4rRUmrydfRfaXMnKbix6aRS86gDtbmK/quqVvvtpzNyapl72um7q9oAAh0mmXsmBFxIrQ0tBojWYkjho6ba0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763080891; c=relaxed/simple; bh=D2nn/7d43b6StB+50Mrc5CzHNcdxGpoqaludcZ4hH/Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KyXptDrLQio24BGnuYhjLJnceiWEgIi44Q0Se8mWrTblHTyVezNRAuxd3ZB4Ikc5h2dPOht7sWbcow/tYgsD/4zcQwHCw/SoWy3Dva4tSIKbxddgtH4GJX1i6ysle+/6XD/VVHXMxkTnsJgCfo2mBflExTlEaIaKYeH6t1bKVtA= 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=rZc70tdy; arc=fail smtp.client-ip=52.101.46.45 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="rZc70tdy" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cwSj4vUcRKD0h9xRYia3GVZawplUrO1VpcI47FkZCB5XEuVBVsLatUxpl42lD58jR7hS67qO2nOOF9EeJ2LbG4u0iUlTgWcbRpn+eatqt5EG9GhLJ1K7AaZsCcoWAOVei6NONs6SZ1IrLppejlkin0gX3DFsXxl7OmWdpXoLOjEGoqexcs7n226FyXRvRIF3rA/F3mo7qSMMtkJ0DJEbulWPgrxFUO9vaCNaet+2Il+0v2VcqbnHOHx9qXOuReoCB8ugRDi0Jq0t2dTXQR4Zokjf/yjOTn9ZY14dY4YFwGrqBKsot/fuY4DLv1Yh1g/EMLIuPBhy2+Ug8yDq7Yi3Gw== 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=AXMZtfPyDB48KKByRPJ/uPczC4YfeaiH/bOpk5DLcQw=; b=jz58ETC6AF89VHPffmJuwc4JxTNhA/e9vUrmmBLKcoPeeOYvgKMi4oDuNJaROXIUgpJMXx9d1FE2eOAI2WGmHFoeOyxGkBsSDb/8zqFOpn8bcDR3weZzwA9saCi6nr8qKifWYu9gmWQ7k/j94nS6cCvdimsVTGMsSUHVGaZwOHJn2mSZM0Iq2yH7prXATOXFZ1S6yZZGbkrwB/zQ9x2FA1BS5fNjGRJrkykRxtZkL1m/R1vBWOEsEsrpZuH5HVii6HZA/sxdO/6mvEezPODNS5y1gjmOzFTiK6ZYAQPGVzuYJkpbZAXkPSgfzXtix+JVXctFVattJZY8ZQEFwQjjdg== 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=AXMZtfPyDB48KKByRPJ/uPczC4YfeaiH/bOpk5DLcQw=; b=rZc70tdyd9RfN5P2u1P2oPBhKhnUhJJovrdQ09oFyWPiYFuIrCbRIcLlYgPzWftbFYndxUOI9kVROUqlp/48VrkCMzHKs6vMXX0ykA70VLKJR0Wd4RN4fkCbZCNMgLUIoN8n6a1PH21GCG3Ih/Z8UhsYC6DFIVG/s/Np1QRwAx4= Received: from SJ0PR03CA0249.namprd03.prod.outlook.com (2603:10b6:a03:3a0::14) by DS5PPFD22966BE3.namprd12.prod.outlook.com (2603:10b6:f:fc00::662) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9298.16; Fri, 14 Nov 2025 00:41:25 +0000 Received: from SJ1PEPF000023D1.namprd02.prod.outlook.com (2603:10b6:a03:3a0:cafe::5c) by SJ0PR03CA0249.outlook.office365.com (2603:10b6:a03:3a0::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9320.17 via Frontend Transport; Fri, 14 Nov 2025 00:41:19 +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 SJ1PEPF000023D1.mail.protection.outlook.com (10.167.244.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9320.13 via Frontend Transport; Fri, 14 Nov 2025 00:41: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; Thu, 13 Nov 2025 16:41:15 -0800 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 v6 06/11] cxl/region: Add @hpa_range argument to function cxl_calc_interleave_pos() Date: Fri, 14 Nov 2025 01:40:11 +0100 Message-ID: <20251114004021.1310661-7-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251114004021.1310661-1-rrichter@amd.com> References: <20251114004021.1310661-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: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D1:EE_|DS5PPFD22966BE3:EE_ X-MS-Office365-Filtering-Correlation-Id: 73876381-6c5c-46fe-ef24-08de23168a17 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|376014|7416014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?PDkdqMpYap6sqem61jx173oIi2wDsLY/TiXcumKwoF1fSoq0k78s5VvQBxwY?= =?us-ascii?Q?2qjUu4R/RgiDwK7Zllul6Q1S8OydEEpD1nfDHldO9t32F0Am6YI5cIDC3iSD?= =?us-ascii?Q?bdjpQ1K2iJBhnuo0ulP3aC5UpmHxC4flJhovgbcezKCghNcQW7MuYqXbq4cM?= =?us-ascii?Q?dbl1YBRlKAK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IQThKrYEEoQJK?= =?us-ascii?Q?A5GIRsUt8nPKrndatS/V2K3EvqqAGbvwYuIxTIoFzUsyrV/8aZlMS5dFUfkY?= =?us-ascii?Q?WlRtXamY2YGcEtK/JQuvTAa+im1eSo+wUSKhvR2tnlB8CmK78NjmQtrRI4mS?= =?us-ascii?Q?9rqQiZGBZy3tuVUYOExlq7Kn49xnoRPS82e1JW/149W/uL1bKc8kOzgcz41f?= =?us-ascii?Q?ZzBLqn687YUC43ehEFvb4i7tBVxLrU683PMX3nA58c/leMW2zGfIx+v1WyJM?= =?us-ascii?Q?jLUNj1bbkyyobk+ZRKKDQa2UvQlsm9DYdk2PJ/g6r+pKl0NDLrMZZDsPeVNe?= =?us-ascii?Q?Y71tYRTdFz21nsK6O6j1O2ZwEn3TiE0/R/Ovbu0kijq+ueYGSj3oShPgR6IC?= =?us-ascii?Q?veqVBzBXudH/ZJJctSfY15s4+qLmsy2a+/w/HgW5ilaPBBwWKAywdxNwY9lZ?= =?us-ascii?Q?fckED1jEaQDi8WG07HXHMvwMpLnRxQITynBZ374sxoFZcYWhc5N6JRBiPUZ3?= =?us-ascii?Q?nA1z7D5nWwMHKDOuvPo=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(376014)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2025 00:41:24.4925 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 73876381-6c5c-46fe-ef24-08de23168a17 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: SJ1PEPF000023D1.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS5PPFD22966BE3 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 Tested-by: Gregory Price Signed-off-by: Robert Richter --- 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 52924006a10f..01d23a42a6de 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -1832,6 +1832,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 @@ -1844,11 +1845,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 @@ -1886,7 +1887,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 @@ -1896,7 +1898,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; } @@ -1909,7 +1911,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 @@ -2093,7 +2095,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 Sun Feb 8 03:27:29 2026 Received: from MW6PR02CU001.outbound.protection.outlook.com (mail-westus2azon11012039.outbound.protection.outlook.com [52.101.48.39]) (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 DF3BF26F471; Fri, 14 Nov 2025 00:41:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.48.39 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763080891; cv=fail; b=ZoFpsEPdTXGFE8D9hwy1gu+jkdLXEw7khKgfNKwz10rpxrKk7SHH2Bim7DPnlDAz8hlrSaGLMS8I1ZixKviu767MLcOPaAAiGhlvabOdzb0/7TfHFD7hty+m41R1jwEdiJ90pUPZAwqbEvGUQIcGuGDNWOefpVO0d3N3cAQlPXE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763080891; c=relaxed/simple; bh=d06gooiMiKPsC5Bx+E7CE5qgN7rQevYOEQx6OxWdwIA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VBgrctGXWuRMv87fWxm+TnLuzwtMud8bhf3bsQPxaSFyQZNJUmEFoZUUB0W6Tsuw2BsWklV6/ThBMXLfr9sR4ZU6a6mF+2/w/26uVN8luGSpAp0J3xGm1IA0sYOZfYLZeVFzD8AfoY+IJhoeTPEohSsBo/VHzrF0x8TaakrAS/A= 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=qcg+cfZx; arc=fail smtp.client-ip=52.101.48.39 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="qcg+cfZx" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pDaXxqfe26KzA65Oe4aa7jAc+AC3FV+/V/Fi+Zn4ePRepm+cKvMpboB3/oVsm1gTuaAVM8zobagz60w+2JY2Zeg3F3EGwkzqJhnWCD+GefDL4BWNve9A1tMAX3+0oDJgvDiTXhmt5bN+8UoeTYZz8kAiPUCLy3B2Z87N7ThfYPffWInCZk5PuDv+gaDUx+R0BAYRRUaRy0s4N8sL5SvoX4RjK1QeC4aMtVm+Sg7RkQwTLXA+ptP33Zx5FcTKmJiUks594IIKFwfOUIkChQyrs/ld/MgmrT57KaHawvp6AJcffI+ZsxaiYqXMjoJ/Kk7a/rywPQFwYLhgLYi4ywJAfg== 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=7bvyi1cOSEXnDetmw5p6jhn1TIZexq6antxJQLAL7S4=; b=VBje+McmFZ4rNZIjyifuUTWHZjYmiZrlxbYbBgyhLkSNp3TIxmMuVJvgEAuk+BFownp4zFwrtx1df3SG+KZCeBDoU9fifI/6c26szUsueIfmIwmUFt3YfRTzrTl7SkhXX8IaJitg3+HfurZNqJyBSpYBa4KI0pdZISsw9Xjq3DK+RLC3vjdjhlGpGuY4/gJAhQYYE86xfI2IZFHbzQOBDJ0UaUTKlf+WkgfcS5Qu5K3kzAJGvbWsp/3U3m8gt9VoSQCb8RzVarTcPHdFdMYmWcAqSdN4Tv1p2GDk8/Ue/L734/GZHTBmRfw3ItixjqvVgxc2HfmBH1OOMlDvCb4bcA== 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=7bvyi1cOSEXnDetmw5p6jhn1TIZexq6antxJQLAL7S4=; b=qcg+cfZxbcRhsKf5FX3hupTGk0EoILg7lG7/IqEUrCfrVSDLLa8cJmKgzRAbRWqJtZ+i22x8tggwT5b8oib6H7SlT2+fTq12o71JbpwbNOOZjwm9aPJ533Nand1h+5u9rKekwnaCxK7CHzdni1XLHH1ZBB6T5hK9VTHCmhDuSWw= Received: from SJ0PR03CA0260.namprd03.prod.outlook.com (2603:10b6:a03:3a0::25) by SA3PR12MB7806.namprd12.prod.outlook.com (2603:10b6:806:31d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9320.17; Fri, 14 Nov 2025 00:41:25 +0000 Received: from SJ1PEPF000023D1.namprd02.prod.outlook.com (2603:10b6:a03:3a0:cafe::7a) by SJ0PR03CA0260.outlook.office365.com (2603:10b6:a03:3a0::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9320.17 via Frontend Transport; Fri, 14 Nov 2025 00:41:21 +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 SJ1PEPF000023D1.mail.protection.outlook.com (10.167.244.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9320.13 via Frontend Transport; Fri, 14 Nov 2025 00:41:25 +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; Thu, 13 Nov 2025 16:41:19 -0800 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 v6 07/11] cxl/region: Use region data to get the root decoder Date: Fri, 14 Nov 2025 01:40:12 +0100 Message-ID: <20251114004021.1310661-8-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251114004021.1310661-1-rrichter@amd.com> References: <20251114004021.1310661-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: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D1:EE_|SA3PR12MB7806:EE_ X-MS-Office365-Filtering-Correlation-Id: 0c3631df-5a62-459c-d546-08de23168a9e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|7416014|36860700013|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?jB4cwi0TL9iUUPON6uDGji2jVAiaXqVu2XhBZTuNC+n+ELnczpiIVTcjYNGz?= =?us-ascii?Q?f9G2WjcHZfmWmVJsLWSSYDNbSCz9EqE/smhMMCnvUjklJjpwCUArPuMl9vw/?= =?us-ascii?Q?1ddxnvTUS9yho3z0B4WFx+xfWEHhV7mgtbR/55PqkIs0CZ9OTH2UXQ9PoqMm?= =?us-ascii?Q?OumetDzemJujfRsOFk1DKgStoNJ7+EX78s20185wbBKL2VsQ1gzceYqBbKhq?= =?us-ascii?Q?9UCAIiFb8CdPUCU+SUI5kyyrqHuT9AQ94lGThde/Vd5eAv0B4SBNOVn8+ooV?= =?us-ascii?Q?Wtd9VAEzWX2Nq12mv3T+9MbbNxs4EwQs/WZd+FTZyGM9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yzgOSbF5rGVESTmKTzeADFVWH8RsLwKALtKNDSAXpoVik+bux7Os?= =?us-ascii?Q?rr53gSDH7WlXGIWBhYh9XJ9OX1ODmEQg8z1F36OOuFrSgtQFaNqG5NrPmiVc?= =?us-ascii?Q?VAlbNHb1lFbWdjmQCDaxcywJqzTd9sqhuy+wwqtmFAIlze05YBt7+5iLsP1f?= =?us-ascii?Q?+44/QP240xUqO2puiwb2/btys2nn8ygepB3X6mCLce9DCsQd/sxjWK7CuGUB?= =?us-ascii?Q?hzUrYyZYm3VCemM4mpFbzaFKWPrhwpHvqcRuUIdst+WL/wmSykRs0/4scVCR?= =?us-ascii?Q?AlUOJX0iUSQkhUvs8g38KecR1Dj9XAuXFPewDiScbk+Phz8eGdSmqqqHrcV6?= =?us-ascii?Q?+YIgQ3lj+tcY/Pw/0Gg=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(7416014)(36860700013)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2025 00:41:25.3767 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0c3631df-5a62-459c-d546-08de23168a9e 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: SJ1PEPF000023D1.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7806 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 struc 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 Tested-by: Gregory Price Signed-off-by: Robert Richter --- 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 01d23a42a6de..c028b772cfab 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3340,47 +3340,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) @@ -3573,9 +3570,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 Sun Feb 8 03:27:29 2026 Received: from CH5PR02CU005.outbound.protection.outlook.com (mail-northcentralusazon11012039.outbound.protection.outlook.com [40.107.200.39]) (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 3AC7626F28D; Fri, 14 Nov 2025 00:41:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.200.39 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763080897; cv=fail; b=NzEkkiu88MXHX9FkysIgYc6C2EbxHhgj6dqTZnf1Y9D5axS/W9+lItCzxWGCAvH/vVRGV0n1BW6xBWblWX2W2dB0jPQ6TaaKA5K9hvCnUcUZD0nbNxjjPfOM8wRvayF5XUB8rRm5WWExB6Wp9SbuxRcdGdUChpEHxfXXLQAouLY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763080897; c=relaxed/simple; bh=GS0tkR1bxoAWbCbJFlmi6dlSShLTzJvNkXsbjHidgek=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Zs2lTntFjcB4hMZ2u+UeXuZsMQWoQck+s2aCohe8e9x0ovxvvEDEFQfaigO36Ni1ZOQwX/eZzN51ltvHR6AX7T6TbKU27p0n/6XexSonGGWt42WAzleU9Px2PjW8qiXk37hYZuD2MTkxRU745Xya6UmdPBV9UFexBYwZh6AfbYA= 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=378NJz3k; arc=fail smtp.client-ip=40.107.200.39 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="378NJz3k" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=e+w2nDzGP7Boh6HnroTXwbg7tPso1+g8GErDRfLNjCWS7iuDYbhKyL2CmozpROW6phNGhcWmv5ixvJ+PrFwk4Il93fiq1WSJ6+0Gs3gVgAy+bP2TMpAPFrdi3e0aJzwciWp9Iue1f/1n93hzFtNL8fmNdRnkDoI/lzcSGF/2Tz4lHII5nphVEc+n8QWkAfq+8LvfSRhq6hmcrZd2zqqZkhcwD7Sdd93dOWMkYIYdI40OG3iJ5L84MzUPH1O52aT5JX53Y3D2YfiRIJ4ira2oGTzAp5OIPEqlhW26VIxD/lsCWaFLGOnPJQOJWYb1aQBmu5Z5aQC9YcCiXYgKLx7q4w== 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=+1Kuu5LfrtWDVLGCFKooEngQQXUA4xBf60Mc9IOwj+w=; b=k5sTP6FKQWMRyKFMUUB7ryQzF7vLC2EzaYw90+okWtsU3m99Q3Bq3syQbn28YND6LmbP1bJAEGRO5qm6du9B2+JCRx3YOhCNj1T/80BycAq1SY7IZ6rgxRIkd71kr8E71qSfrTxG4zFBYQm8dTR82n0nS870x6dQRewhYRdXgN7Re4Jn6aO8dA9xiCtZ7wdccbj/6Yz5ZWmEXGv1TbMCyFHaWuUwu1JuO0hBGIxUmDKSZ9176kL+1bhvOs7ExJGyYwphBOyXFPDSjybaDY7VIp/ezIW7ziOGxdO19yNuaEvURogYBQv0IaRAD1W291taAKNoF8mAGNRi04CIiihWdA== 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=+1Kuu5LfrtWDVLGCFKooEngQQXUA4xBf60Mc9IOwj+w=; b=378NJz3kSpPx2/TpHLylPAUdHUL0s3MeJxisZl27w+dZj3umtkdmYxy5lWGGcYSSYnujONKNpWQ+401DtJhWSqyheslbWrPzorAqrP77VYsPUfFY6bBAY/q79DdEjZf4Rfs2sEYrTIINi/iYaB/ZnSGxHBm8Gnrn/80hq1jsCV4= Received: from SJ0PR03CA0255.namprd03.prod.outlook.com (2603:10b6:a03:3a0::20) by CH0PR12MB8485.namprd12.prod.outlook.com (2603:10b6:610:193::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9320.17; Fri, 14 Nov 2025 00:41:30 +0000 Received: from SJ1PEPF000023D1.namprd02.prod.outlook.com (2603:10b6:a03:3a0:cafe::3f) by SJ0PR03CA0255.outlook.office365.com (2603:10b6:a03:3a0::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9320.17 via Frontend Transport; Fri, 14 Nov 2025 00:41: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 SJ1PEPF000023D1.mail.protection.outlook.com (10.167.244.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9320.13 via Frontend Transport; Fri, 14 Nov 2025 00:41: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; Thu, 13 Nov 2025 16:41:24 -0800 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 v6 08/11] cxl: Introduce callback for HPA address ranges translation Date: Fri, 14 Nov 2025 01:40:13 +0100 Message-ID: <20251114004021.1310661-9-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251114004021.1310661-1-rrichter@amd.com> References: <20251114004021.1310661-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: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D1:EE_|CH0PR12MB8485:EE_ X-MS-Office365-Filtering-Correlation-Id: 2a8f4169-2caa-474a-d31f-08de23168d34 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|36860700013|1800799024|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?4Y66SBFz+lPK+EdhmumuY10WkmnhjtWeJ0kSpuK9OTgw7M+Rskh3zBjG+RQO?= =?us-ascii?Q?upo/1y6pSoVHZEGLOhvpRf0csdzW7z0uU33OzF9G0WoroI/XjrIg5lEE1JPp?= =?us-ascii?Q?UoX2lJctFiEThE7/UXb4lorjAh8OvQPzRycpxDBedJe8EysOPbeBt4h83yjk?= =?us-ascii?Q?FJsowuUg4CO9wl2MkHlTpNF0L2HXtkt5VNReLdXYosNzDNk1edwPN4Qf98d4?= =?us-ascii?Q?DVKeEVy55Lsu8kExQabco99Jm3g1N6glR4BuL0zazmxiLhpQPmTS+SUKpErE?= =?us-ascii?Q?zWwQtjsq0XyzfqTYIENeJPLE6Uc077oqfmDMFfnxd0OhtHcTFJwuUSQ7K+lL?= =?us-ascii?Q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Tw8i0472wq3KiW?= =?us-ascii?Q?aVjOPeFwm66LIsKiAjs3qnMTIU3xOXA9pyJWGJoH/u11MuidiRbU9RXSGVM9?= =?us-ascii?Q?xZnGfeJeEo4r4lqfgm9UCzGwS9QeZLtI8SxoKtyaknGhoPSl6OplSm/ilb+V?= =?us-ascii?Q?6CMw1YJajHzOvxF27cpvhGj9S31FOOARV9w1Z+5gKarcWbhORMZeQiT4ZLrh?= =?us-ascii?Q?VZpUXdIz9CNuTDddFjo/PesG9EcjufsQxqD4a4eSfbiAWm0srj4ZrsIrLtKk?= =?us-ascii?Q?iJemVuwqHr6ampF8AUyL5KH2/86OqoLW7lNkpUJdathqfNTJ6arMefo1ObjR?= =?us-ascii?Q?wqMeAUstN+7uVEEpev4=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(36860700013)(1800799024)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2025 00:41:29.7146 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2a8f4169-2caa-474a-d31f-08de23168d34 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: SJ1PEPF000023D1.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB8485 Content-Type: text/plain; charset="utf-8" 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 Tested-by: Gregory Price Signed-off-by: Robert Richter --- drivers/cxl/core/region.c | 19 +++++++++++++++++++ drivers/cxl/cxl.h | 1 + 2 files changed, 20 insertions(+) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index c028b772cfab..42ba0210c779 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3354,6 +3354,15 @@ static int match_root_decoder(struct device *dev, co= nst void *data) return range_contains(r1, r2); } =20 +static int translate_hpa_range(struct cxl_root *cxl_root, + struct cxl_region_context *ctx) +{ + if (!cxl_root->ops.translate_hpa_range) + return 0; + + return cxl_root->ops.translate_hpa_range(cxl_root, ctx); +} + /* * Note, when finished with the device, drop the reference with * put_device() or use the put_cxl_root_decoder helper. @@ -3366,6 +3375,16 @@ 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; + + rc =3D translate_hpa_range(cxl_root, ctx); + if (rc) { + dev_err(cxlmd->dev.parent, + "%s:%s Failed to translate 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 8945dc1532a7..e67e37322ee9 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -644,6 +644,7 @@ struct cxl_root_ops { int (*qos_class)(struct cxl_root *cxl_root, struct access_coordinate *coord, int entries, int *qos_class); + int (*translate_hpa_range)(struct cxl_root *cxl_root, void *data); }; =20 /** --=20 2.47.3 From nobody Sun Feb 8 03:27:29 2026 Received: from CH5PR02CU005.outbound.protection.outlook.com (mail-northcentralusazon11012004.outbound.protection.outlook.com [40.107.200.4]) (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 B2EF126F28D; Fri, 14 Nov 2025 00:41:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.200.4 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763080905; cv=fail; b=pTeQGRtZvxqpq4QMBqW3zB6IRt90YnUmznsHL0lZHORnkeM0eoo1W4YxODnl9y4eXGWB9dl+f3IVwirY0rkKLoT8u9E0r06c0PHD54PvOYt5B69w4jB1qZJwlnR6Ce90uQhWG8Cs0lrqvDn+6bim+SBVkNH9apA96FtnuYsazJ8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763080905; c=relaxed/simple; bh=ZwEUSBt3BzCW4o1QzK5TYxo+6JhVfVXjnKYALU7/JtQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UuPsDvqnELZQ8U/qJxs5eWTvWziWIKLrv37/fRtXenaNHf3GlAJmB9BKdfQqGkdF5cmqeFU3jR5tYFdd52Tfre5mKpUDYSUsvh//ozLk5w8ydss4lcrAmyu0/heybWO00p9606S1qqsew6MCMt3gE1fy2s0DNRn8u5cETubcKgA= 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=pYT1F0JS; arc=fail smtp.client-ip=40.107.200.4 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="pYT1F0JS" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nVxY5C3WPh4BVRKc51PNlYk9iT2wPZHUo3vDAQT1yotN1ZlJDXi/JV304zaQZ4idsX0dYVsHl2Lzb8bE8N+ZjZ/0qBRg0NKRoKrN6om2VuVru86ktBmSmQzeqx8JQNlU0eghiJOO4bhKv7m9nXgpl/vfSOmF8Bdr2kt+WxiVWAWRADd0TEnKd39emjItNA/S2Eu1BAsljieX+0zowlN6bnl1eKvEE2ol8G2K+JrFmIMfYrgmqj+9hcmH65xcQaWUfRWKnrol8sqVgF9fJ4Ng52QJucDuPmr+SEdfWvCt91oA70qVVJ1IrVCkVTysgZ38aRlLF33TtNnV0RNqK1AFwg== 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=D1SRYRj549j2XPnJd0ES06nTnLWMXYj7DmwV5/M5kgQ=; b=RDKO7Pg4GBVXRoYdaWRFDTJ/kUBvQfFRoGJLYLzrJldUs5gQi4157D+EEV2RP10X8ZtPgz9QK57J9pbcOeOX/MdsDlrTwWZiswuk2CU1x0+WYet8OefZDcyPFJQzKv/jv+oyLmr9kk4WMId6ulxykdmLsp2G2bRRotjT9VT8Wer4Tf5p8Ys9L0R2TZ6XNORxDiAd2DZ1TCSga8w98XMmjejXPiRePVLLXKSmYdJC+y1ABpTZbudH5JHOz5zEfktUxfU2t+CM7Vfdv609cgHRL56KzhA7/djasGHrFTV72wKNAbPTfhAxK6/uvrxCT+Val/58kh/+ryynpLA4Y3LwOw== 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=D1SRYRj549j2XPnJd0ES06nTnLWMXYj7DmwV5/M5kgQ=; b=pYT1F0JSs5s4wwNDYpFOyKk38dM+71sJmprmB9TrB9njGfguQF+NShPN0z8rthG+Xt5vLYF7Obmd2gvf/dgQs0aT+YrxNmHtQVQuaRVsev5qehEOfl8pBtswL9+wT+tYo4/VXZiDJJeDt/9sNysFc/8zzv40ZaA2ZLCCgCyj16k= Received: from MW4PR04CA0386.namprd04.prod.outlook.com (2603:10b6:303:81::31) by BL3PR12MB6522.namprd12.prod.outlook.com (2603:10b6:208:3be::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9320.16; Fri, 14 Nov 2025 00:41:34 +0000 Received: from SJ1PEPF000023D2.namprd02.prod.outlook.com (2603:10b6:303:81:cafe::5e) by MW4PR04CA0386.outlook.office365.com (2603:10b6:303:81::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9320.17 via Frontend Transport; Fri, 14 Nov 2025 00:41:34 +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 SJ1PEPF000023D2.mail.protection.outlook.com (10.167.244.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9320.13 via Frontend Transport; Fri, 14 Nov 2025 00:41:34 +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; Thu, 13 Nov 2025 16:41:29 -0800 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 v6 09/11] cxl/acpi: Prepare use of EFI runtime services Date: Fri, 14 Nov 2025 01:40:14 +0100 Message-ID: <20251114004021.1310661-10-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251114004021.1310661-1-rrichter@amd.com> References: <20251114004021.1310661-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: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D2:EE_|BL3PR12MB6522:EE_ X-MS-Office365-Filtering-Correlation-Id: b10718e4-5649-4343-59c7-08de23168ff2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|7416014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?oo2SQYQLnaSvGxJjCqn8YRe6y+2hv1Y4zge1QUDJWzbnh4ySXNLKzd6pebFv?= =?us-ascii?Q?cM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w2FIxG9gh6s6CuKfEVyA9KEGji2LRbVp?= =?us-ascii?Q?OMuZUeG856bHwkmILFzko+euycZTJiO747BXZrnBUvqRD9iTJPAZf98EAxis?= =?us-ascii?Q?HpgRsTVXszrbsTynahgcwhSehxsJZTbU0mcAVMMCVkLcxbgoLgMwyrRE6MvC?= =?us-ascii?Q?x2BxvZJY7LBoEb8+WYrqUasxKZHVWlj/XsgnYIKtWLjw6ubaR/r2hENQiOtM?= =?us-ascii?Q?xBS4XADVs1RP0ayOF6Fqo4hGtCP5VnaDqjq5L+B1l6hhzKCU8GaKWWu4/jqO?= =?us-ascii?Q?urA0Oc2Jgbe1U+/HBpdpyFOPZdG8+JWGKhw43kjH7dTzjKRZR+MIANp+FQV9?= =?us-ascii?Q?V5sip4wCYqMf4R+y38x72A2MrDjBMI0707QD8SdWVhTkzd44KWwvviGqBDjv?= =?us-ascii?Q?m79jO21IbhqvRSwsGX7kRpVmfXy8C7Dgl7Pv3nPI0B4mwPlo6STHpdyPdnkj?= =?us-ascii?Q?ms9d4NOpphOtMiFcWnl+Adqr5MMSZgauhdllalgzWKFUjl7jcy/yxr4y4twI?= =?us-ascii?Q?wf3RSOb6V7CgcVbJj4SNX26AwRiyGxGUVoCsOzzwrchr7dlmCRnKJH+c0y7P?= =?us-ascii?Q?uv9+bqczJSQzyU5CuLgBiwRsfO8mFXfa+5oDZr0WonBBGI3v8IecIMQ6TnB0?= =?us-ascii?Q?oZ7UgaZcvqPG6bykj/0=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(376014)(7416014)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2025 00:41:34.3121 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b10718e4-5649-4343-59c7-08de23168ff2 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: SJ1PEPF000023D2.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB6522 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 --- 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 866813e1b729..604cf995d0e4 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -989,8 +989,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 Sun Feb 8 03:27:29 2026 Received: from SN4PR0501CU005.outbound.protection.outlook.com (mail-southcentralusazon11011066.outbound.protection.outlook.com [40.93.194.66]) (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 0E70E258CF0; Fri, 14 Nov 2025 00:41:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.194.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763080911; cv=fail; b=AgijaANiBfjFD1wNrm8sFfEPnZZIZyoTUW1aIeXpJGp3wI8SUgNNHFRf0YAEr8+Kcmngp8RTDU2eBOsvzuDbDPQmj2JNxB37SCHDdGZlEgQKXOxpuLwFOaiv5u4jMx3LLCYp741WvhHaV8VO7FuLTns+mx4rhbJd3naOaXKPo+E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763080911; c=relaxed/simple; bh=miiZW+wiLtdC3ubhN4wSwOXpWqfScEy+lsDAJI3zjnY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kLsVfufZZPVpchbG8AzUBW7andzUiMQpL1wt9Es9yJ2Le1+GgmgTdGRsra057+xtHBM6o/c8XMix/wFt/JUe+VXDEeEOIjBY+nod2feVvQmSZBtshgvvTTu40ePpZb2D7a3r2mdOhTslWqB8j9in6UC0/beaS0zFMhSeC/t+Wew= 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=VdHz0tJ0; arc=fail smtp.client-ip=40.93.194.66 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="VdHz0tJ0" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HaAbG9rmiXqra0fSrPLwJjUD3WxQBw+87XCNyszRBzhlEZrIgN3mH0XeCF2Z5COsV0EX/e2yiji8NLdmIuwool2NjVa+dIyB5tPEYkniSkXdXulJzIRE4rPrC5DkIaO848qabIdBhdO9wdK1UhyacXMfwCOLdDwLy3lkFkC8lyk7wgXkDXdySO2uaf++eH+o4B+MJybI+WtA6GA15+XLHvsiBsUzdoAdfjQanAfNi1dQbR/gd++gM1g9WD+b/SI7PAscp4varN3V8Lx7lr7WvadWh59H32j0YUqIuRbyzQDuBr/W7UQILoyVfnGyTbn4mjlOnU/c8h7dzMb0ETi40A== 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=hHv/K83xOVk8rRklnTr6zF0kOzT8Mv9gvRnocBImKJw=; b=Ysn+r3Iynr22HTvG/H4ynXMrUdX60Vlb2xyQLKD3sd70FmzTd1MI/5usyE+ySf2vTjX+hJhZv8t90antvrvZnUiF0qkfmJyXshZVAlZhMCOvIJg8SARd0aIQ3ozfvw7Kl8OcfIYnBjc0wGCHGqehFO7J1/ly0Qd9DbMK/C8zsvmZQOanvM5RG27KqMqvc6aSTlKDT7g9fXlLELUdUhaVKcj15LJ6d4wjAG+r9btAVJ8awLQu0vClRx/FB0gFqgpOxzkg/d0twM1UZfXlLDEH6iWpSgTK1TgXSVHeYmTo4w170Zt2DSA6dbS4hUUspMxqiYnh1JBYPH24KXnAoj28JA== 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=hHv/K83xOVk8rRklnTr6zF0kOzT8Mv9gvRnocBImKJw=; b=VdHz0tJ0ZayX4y8X2fmr72dME3/P0kKDrizZ0npc0UxdKWKMV1VClGlP8NTZwvLF0bvkie2A0F4P1cVOwtLnW0QY+ZJB3Boh/Ca1ylXZTE3kQfYGAynO15t/LxUOJ/FtiLJb71BexM37FwK7R+gdV4/QawL521K9AN1g5Zt+QKI= Received: from MW4PR04CA0370.namprd04.prod.outlook.com (2603:10b6:303:81::15) by CH3PR12MB9282.namprd12.prod.outlook.com (2603:10b6:610:1cb::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9320.15; Fri, 14 Nov 2025 00:41:43 +0000 Received: from SJ1PEPF000023D2.namprd02.prod.outlook.com (2603:10b6:303:81:cafe::7) by MW4PR04CA0370.outlook.office365.com (2603:10b6:303:81::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9320.17 via Frontend Transport; Fri, 14 Nov 2025 00:41:43 +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 SJ1PEPF000023D2.mail.protection.outlook.com (10.167.244.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9320.13 via Frontend Transport; Fri, 14 Nov 2025 00:41:43 +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; Thu, 13 Nov 2025 16:41:35 -0800 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 v6 10/11] cxl: Enable AMD Zen5 address translation using ACPI PRMT Date: Fri, 14 Nov 2025 01:40:15 +0100 Message-ID: <20251114004021.1310661-11-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251114004021.1310661-1-rrichter@amd.com> References: <20251114004021.1310661-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: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D2:EE_|CH3PR12MB9282:EE_ X-MS-Office365-Filtering-Correlation-Id: f0d5c03e-21be-4bd1-7ed6-08de23169529 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|7416014|1800799024|36860700013|13003099007; X-Microsoft-Antispam-Message-Info: =?utf-8?B?VDYyMFVpMk5OZEJVQUxCWWhDOTRWK1RhVzIzajNUeEdIQm5ySkJMdEtkTGdV?= =?utf-8?B?OUZhUzVobWVkSi9iaUR6UUV2ZEcwUWw4UlRRMHZLdTQ1dXhaSmk1NXc3OVNX?= =?utf-8?B?V0packJqOEhuK0svcG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12WEJYVnZtV0Z1?= =?utf-8?B?YVpSTGhaZG5PSEZYOGRtczN3Q1pSZXByT3ovWGRUWjhOSUt0Ymc4STVXYklZ?= =?utf-8?B?UitGNW9XNU9XZlRmUHp2SHZEajJ3ZUlaYlJ2R0FDek9SL1BOVEdtOWdHQjJr?= =?utf-8?B?VnFDTmJrL3YvUTlUMWk0cTA5OG1KRmYrTnMzSnlPV2dZT1ZFRThPSDN6Njdm?= =?utf-8?Q?c46A=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(82310400026)(7416014)(1800799024)(36860700013)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2025 00:41:43.0629 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f0d5c03e-21be-4bd1-7ed6-08de23169529 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: SJ1PEPF000023D2.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9282 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_translate_hpa_range(). 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 --- drivers/cxl/Kconfig | 5 + drivers/cxl/acpi.c | 2 + drivers/cxl/core/Makefile | 1 + drivers/cxl/core/atl.c | 197 ++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxl.h | 7 ++ 5 files changed, 212 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 604cf995d0e4..40894e2156ce 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -909,6 +909,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..3b02999d3c59 --- /dev/null +++ b/drivers/cxl/core/atl.c @@ -0,0 +1,197 @@ +// 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_translate_hpa_range(struct cxl_root *cxl_root, void *da= ta) +{ + 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 =3D range_len(&hpa_range); + 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; + + if (!IS_ALIGNED(hpa_range.start, SZ_256M) || + !IS_ALIGNED(hpa_range.end + 1, SZ_256M)) { + dev_dbg(cxld->dev.parent, + "CXL address translation: Unaligned decoder HPA range: %#llx-%#llx(%s)\= n", + hpa_range.start, hpa_range.end, dev_name(&cxld->dev)); + return -ENXIO; + } + + /* + * 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; + + 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.translate_hpa_range =3D cxl_prm_translate_hpa_range; +} +EXPORT_SYMBOL_NS_GPL(cxl_setup_prm_address_translation, "CXL"); diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index e67e37322ee9..75fd45ddca38 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -790,6 +790,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 Sun Feb 8 03:27:29 2026 Received: from CY7PR03CU001.outbound.protection.outlook.com (mail-westcentralusazon11010012.outbound.protection.outlook.com [40.93.198.12]) (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 8F3982BE02B; Fri, 14 Nov 2025 00:41:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.198.12 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763080918; cv=fail; b=iSAaeuqtrMEJnkQX53nC3kUei4/8vOUY5rqnRpkuqh5fvDlix/arB5WOQySKoDuZnOCJ+VASHqizGP5AgeWYAo26pNunNunh+icJtOgVxv0sJPyNHT7jIyMtY4qFCEwm/XJAbXsIAC9eQIzFktOYukudc+ZHeV5tEYNZSYAC4HY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763080918; c=relaxed/simple; bh=fmPkrHHmJHz+BjwGzTLIHNx69R5QxyCJDSJYO7tOfaA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OM0fY2xTPdnFvfCXAg/hCYYRQm/UEP5hH8bZ/vGIEljIo68zEb+0GenGhLpNtXAgZlS88z6lmgEdRFJ+ddkvXsj7alSf6cbkotasZvpy7wnj6K04ly9iO+lNPixofQxEjKVyUhKX60oQAXT9FJVIX5nXQWqFJCohmISgFCfX0zM= 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=3UXfLvD6; arc=fail smtp.client-ip=40.93.198.12 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="3UXfLvD6" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Bv0hBufkX/nfaN1PsScg+WRNj6DBdmi62dvEGyCv5aURMa39YHXXQD0bBvintz3uyNRZVpD5EU3oeG5kDdWgbzP3GKo47W8Ixex1ERKx2Byp9P4cUNZ0ORi+ZcA2f5w19Mj7sAk8LdNS3rn/ERIIhFVG45p+BYN5kFz/YoTFiOEgLMV4WbNuP8SfOCrhFRarkAANUBORSuQP94KmuniJqQ63B6buSi7mFgyWJ1cuzS1Yqx8TjumP/xCfbyAzZbWb0mlxto9nEs//wTWA0ekOuE8wy8up7lJnFLQDLfYm+7lRDbaHOhBpZld1+4ZoRnaBIU6uCv7pEZUzvbYQTk1iEw== 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=4f138otZxepqQcsYuXrlA+i4xSPSAgzNPKcGE+Dir3M=; b=m89O+jz7FFhjjfsV0zsM0BBGfy+/lM6dDpehtGIijqSnrEbBoapNTC9AvJc/QcUNvZpZxjcVjE6nkIuWn5lwLJVBNDvEPyVMKBAWZzNwo1WNnWhNh9OlIiw1btguossmjaiel1eViS9VV2OiDeh3xZ/gLe1c/BFu7/UYax/jIxyFi6ffu+PNlIO3gwdHydNHL1tGikVkWuzmLbwDKLcA+O0m4/2uHucNyW+AM58sIfFoYYPP7466MXBnFKvgPd4zCVyju3fSuXydRnZ53JRCFs/uWTS/WEFYZGeP8TL9KnBdDC4O3mgGzHPQLCtibMKbra8Ydw8nT1XqAEfqIrkW+A== 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=4f138otZxepqQcsYuXrlA+i4xSPSAgzNPKcGE+Dir3M=; b=3UXfLvD6uhKe143Yzq78v3A+DrIs8CaLFhT9CxXXm/0Rjd/RAyPYPwGb/fDYXd+bbtxPbcmJJfOdNnfF7Y7VM1+reteK8g5wg3KH5Gq2tkSa1Zr1xnisdymB/44lPbbukV6aXg6VApdNavZ0NIiAnN6hh4jZd8bTBz4R1iDF/I0= Received: from MW4PR04CA0385.namprd04.prod.outlook.com (2603:10b6:303:81::30) by DM4PR12MB5820.namprd12.prod.outlook.com (2603:10b6:8:64::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9298.16; Fri, 14 Nov 2025 00:41:47 +0000 Received: from SJ1PEPF000023D2.namprd02.prod.outlook.com (2603:10b6:303:81:cafe::88) by MW4PR04CA0385.outlook.office365.com (2603:10b6:303:81::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9320.16 via Frontend Transport; Fri, 14 Nov 2025 00:41:42 +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 SJ1PEPF000023D2.mail.protection.outlook.com (10.167.244.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9320.13 via Frontend Transport; Fri, 14 Nov 2025 00:41: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; Thu, 13 Nov 2025 16:41:41 -0800 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 v6 11/11] cxl/atl: Lock decoders that need address translation Date: Fri, 14 Nov 2025 01:40:16 +0100 Message-ID: <20251114004021.1310661-12-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251114004021.1310661-1-rrichter@amd.com> References: <20251114004021.1310661-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: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D2:EE_|DM4PR12MB5820:EE_ X-MS-Office365-Filtering-Correlation-Id: 2bef3d45-48f2-404a-3426-08de23169751 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|7416014|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?I8/7EKbVByq67CRDkwfJuDM9xWuEdOzsPmR+lnlOdkq9qBUTzzgI6SpFu6If?= =?us-ascii?Q?3C/PUpu2QENqA6kGhZ8HsOpmCHCS7p+G6KLi5Am9Ax+ZWvZpATiHbwA37Uea?= =?us-ascii?Q?xugr/AHWKyJdj8uQm8AJoNFNxhhTIIFlwhSBN269usqD5gfsJZt3QexGkxHN?= =?us-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IhH8SOIQ3?= =?us-ascii?Q?3cSEr1lfx+OS6/QpCLpdRmqnvT+33vez7VAIVcEXo9C9WLYUHZlEbSVyHzIA?= =?us-ascii?Q?I+BK70g/FdufWi92HPrYx/ZEuHysZwjZt/xgOK0YUy4LkX1zE/kjGsb9hRkr?= =?us-ascii?Q?J/bXcYACCUDyzBdZ8a/Z9agUCHkD9dsBtZn4IMe7tUIdWL50EJ+ROcOWzn4V?= =?us-ascii?Q?32hPeP17qhIJxVVk5OxpA7O0ACdYLp1Fu6r+17/RAfrI2QUBVqfA4U2GqV5x?= =?us-ascii?Q?q/YoRBavmg0LUzEwvBySLGI/DpmQ++J4CvMRAdAmA9VhwDJXf0GTtB6X39YR?= =?us-ascii?Q?osYsG3ko3RWLAd60B3uTYaknJpmxaIGPVT3eNK3Gn2vmqvx5WKIg/LUTNLxv?= =?us-ascii?Q?N+mlLtW7jv1yuRUbBOiV6gJbsQGo3uEj1W43Z5t9kF4o4vU3YZ1g8pMXM9MT?= =?us-ascii?Q?P4Fqm/Yyc3QIJxu7JZhGOhxH/w81TLhBXTTeE4sgE8W4EY07CxSIAHjfbTeU?= =?us-ascii?Q?FloI+I1UpIspJf78HjA=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(7416014)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2025 00:41:46.6776 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2bef3d45-48f2-404a-3426-08de23169751 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: SJ1PEPF000023D2.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5820 Content-Type: text/plain; charset="utf-8" There is only support to translate addresses from an endpoint to its CXL host bridge, but not in the opposite direction from the bridge to the endpoint. Thus, the endpoint address range cannot be determined and setup manually for a given SPA range of a region. If the endpoint has address translation enabled, lock it to prevent the kernel from reconfiguring it. This is more a limitation of the kernel implementation rather than the BIOS. The BIOS provides enought information by CFMWS, PRM, HDM and PCI topology. In theory and if there is demand for it, support could be added for driver region setup. For that reason the lock bit should be set by the kernel instead of the BIOS. Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron Tested-by: Gregory Price Signed-off-by: Robert Richter --- drivers/cxl/core/atl.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/cxl/core/atl.c b/drivers/cxl/core/atl.c index 3b02999d3c59..4f645f71b397 100644 --- a/drivers/cxl/core/atl.c +++ b/drivers/cxl/core/atl.c @@ -161,6 +161,16 @@ static int cxl_prm_translate_hpa_range(struct cxl_root= *cxl_root, void *data) return -ENXIO; } =20 + /* + * There is only support to translate from the endpoint to its + * parent port, but not in the opposite direction from the + * parent to the endpoint. Thus, the endpoint address range + * cannot be determined and setup manually. If the address range + * was translated and modified, forbid reprogramming of the + * decoders and lock them. + */ + 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