From nobody Sat Feb 7 18:28:45 2026 Received: from CO1PR03CU002.outbound.protection.outlook.com (mail-westus2azon11010052.outbound.protection.outlook.com [52.101.46.52]) (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 5834535C18F; Fri, 14 Nov 2025 21:39:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.46.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763156398; cv=fail; b=OlX2UtX+XK8a3xv064WtHY3MPVJo86l5TFHysfJu2EBsU8frkJ/3fTDuM5PVd7P+2b+I0mFX9KrkrOWizDWW1YIMUTDXfz7evUapm3TtPXk25UX9cd5K0l9W+e+8QD1nwEP0JDKWZDyMilYwkG4222nIyGz6Qt8nfMUklqZNFz4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763156398; c=relaxed/simple; bh=JLS8R12RZ5/HQZ4HENy0nQbnkZZ+1UT5vPEOczjcX5E=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YBMK6Ioe1F1ljmsauc5nO0HVR10+PeqHIBRgKa99zr4GQ8SvPglgT02DgIgkPZYzEsshwoElN3KAzSZ9kcIKTkrTpnNRWiXfaPoEOKjz8pahO1n77/nkgiCp3FwCaAOqAgdxUp+NolPeEEHlHR/PKXt7VfPsmSjFqLC+dpTEV9k= 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=QPN2d3l3; arc=fail smtp.client-ip=52.101.46.52 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="QPN2d3l3" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TpG3qIT+9IzrIWdCjq7EoV6fIDZqjJagJy8lADLZBn9aaTIaztPLG/ONIdNtP/tAbq4zMUlNi1ls7Mx/TCCwinq2Z0ja5kVqrh89/DbDSHmE2xQAgiw3wuWCVQtAV9bVSQFLvwIH3elEmgadk5p7xKmZ6phBcV0mfpxtMubtpdPXAPccuVQLD6h+bsbVOPy/3HCYWQwBHCV7z45KrNyAtZljho4N+PPH8uSOlPOX/JV9S5C/fya4KvcZBFxawvPRcf6nM5xpfnuqN5dgzNSsxyr0oGv29Engxw1+4C9gqGdhdfCCp0fhpj/yXUKKuYAFDxyKvIDc+TEiQv87YdifJQ== 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=TFvktY/gOakU0ky3nlY2mTuljawcw7AbAGDE3XtynnFC0zEpJzMyJhXWEsO3p+vC8/NEBbOvQ30r6YWfcNAY0JOlKZ6VFg+4Poc15YkhltGGzG6BFdEVQmzG1jdM4p625uxtl2YQcsksdjnoyHfN39pOSxnsZTf7X0j1/Ht/TXVkMIRm4cJd9BCvMtnckXyuphuNO/++SiAgGAtmSWeSbu5zVNlXYAe27qWKbEfGfZF9fm8HurzkSjR91jnfDgURAeXBpKAYzUvtwbz/KkTJTRvJewOYZTNY+vwMUCbvLE8POCqHitMOsCvbJfwGq5iVPpbv6Ej+pYCWkkOnJJ0XHg== 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=QPN2d3l33uHfCgpJ1LQpnd8gcpwWMJjlXcLJGbgZNe68T7woz7O0shTrmoIDWUECUD/xQcQLRqBiUBELXr+anF2k68T3uYSgAn3P1Gz8G213b4JpHqZr9IJvIGG11kpmKw3zTfdSmlKgOYMwJw/t8Jr2mdDkt8yHLNna5wBouIw= Received: from CH3P220CA0007.NAMP220.PROD.OUTLOOK.COM (2603:10b6:610:1e8::35) by IA1PR12MB7734.namprd12.prod.outlook.com (2603:10b6:208:422::11) 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 21:39:49 +0000 Received: from CH1PEPF0000AD81.namprd04.prod.outlook.com (2603:10b6:610:1e8:cafe::a6) by CH3P220CA0007.outlook.office365.com (2603:10b6:610:1e8::35) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9320.18 via Frontend Transport; Fri, 14 Nov 2025 21:39:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CH1PEPF0000AD81.mail.protection.outlook.com (10.167.244.89) 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 21:39:49 +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; Fri, 14 Nov 2025 13:39:46 -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 v7 01/11] cxl/region: Rename misleading variable name @hpa to @hpa_range Date: Fri, 14 Nov 2025 22:39:14 +0100 Message-ID: <20251114213931.30754-2-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251114213931.30754-1-rrichter@amd.com> References: <20251114213931.30754-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD81:EE_|IA1PR12MB7734:EE_ X-MS-Office365-Filtering-Correlation-Id: b48c858f-e9e5-4064-3b3a-08de23c65673 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?exUKulab6YDTCeEfF3spgvndnzFpOODyirQIC7Wqq0hUr4DWZc0ELobdZwi8?= =?us-ascii?Q?xyttIoFSkYlPegaZeVylVvM21pzZTbu6gqSZwLHkfWQalJvIZdyNT1f7oK+1?= =?us-ascii?Q?pvdsa344u8OuNan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us-ascii?Q?M1nGWk/NM/3l0KysxJl8uUmnu8BnqnXd1l1h4EQoqhCtX87ni0tyXegBkf0h?= =?us-ascii?Q?n3K70CQYsM79CeGawzwc+jsglF4QzeNlP7KILlqSUXEAqfTapfJ1g5h6BN9K?= =?us-ascii?Q?FmAwMuUQBAJXjQ1cP2cgSfkG56Tg1sLqv2D/6yJppcAjhbRngwfmb3pkYN2S?= =?us-ascii?Q?OfModqr4Jj7Ybc4qaH2QnPRRwN2fDqln7RaZquRjQ6dDnjcl1gz7SQDCvbFQ?= =?us-ascii?Q?UjI6W1isW2bWAFyhZqDnExLqlEIBaVa1vE9cdtN9skU9mgZW/miTKZRz6T9u?= =?us-ascii?Q?eU57aNxBHL/OQq3tFaZQRISw8vHzB53kjrDplZmyY0F/59cKDYp3GbcxhNFR?= =?us-ascii?Q?9pg9h5PDmp89hUDQ85pC7z32ct4F+i2XqlmA8KiNU32m3+nx56N79pbHYXro?= =?us-ascii?Q?oMCDetLeLkgTP5VB42dKSBqxN0XsV5gAzRQyplLtt+v18Mzs3HON1DLXpEjj?= =?us-ascii?Q?jj/u7XXT22/VOimAJctTRLhek0ioRZEGKijszfue+WUuHoD/xSiAIJ9YWoIH?= =?us-ascii?Q?hUGa4gSyuTkZJxzYxp8=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)(36860700013)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2025 21:39:49.3545 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b48c858f-e9e5-4064-3b3a-08de23c65673 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: CH1PEPF0000AD81.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7734 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 Sat Feb 7 18:28:45 2026 Received: from CH1PR05CU001.outbound.protection.outlook.com (mail-northcentralusazon11010016.outbound.protection.outlook.com [52.101.193.16]) (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 9AA6735C1AE; Fri, 14 Nov 2025 21:39:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.193.16 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763156402; cv=fail; b=RXSkx6Kue179rO5qePLG6+kZDZKBpsZneF6swmTkJz/p8w2hbcZI34yjrhZ31AbUQ3X17FcNaNR+ilNRp7EUdXvN3Ly4JzWMXRQcFx6WxpgRjCIZuIiy/ubmiEYd7A+RNk/EkggrTOkTGzfLUxZbryS9Zzi/vGroJVXYjG2R+Xk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763156402; c=relaxed/simple; bh=rFeByDsxyBOl4GvAKL+jHGD/ANn3GVYNmoAXQhkpfUM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XNf707TDs91X5zo3Et2SYsonOpYQjjpDxXkHk2cg8fgNXwl/1YP3taYEjghR+8oQ0TD23TJMwiadgGW+BaNn+8YMBjvzQVaLIh4Aa0UEk5UB2vSyoUQoU/dMo8POTugAhso8pQW+EY5lEHhM1EPDbNsgoWGr/FBKWi2O2iLegW8= 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=ak3Dv5h/; arc=fail smtp.client-ip=52.101.193.16 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="ak3Dv5h/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fJgwBjuZu2nBC/mIUMfpbFlF8pxIuwJkcDzGIYJ/xtlz6ED0rwLxba9vmto1Gyszn/bC2w65EehTFd4bj08DcixPkQvk3S69VNhCfPcliaLge93f9LqrP/XyULfqnKOEJoeiMtUNGAGv5w9kLOE4Pbaf4nYODka7X0sBrnQOe/QRe4UznLzfG5eD2/kQWXRaOr/gWKhqKd9dSy8wqlV3JV8MInKqgz2ZTFa69JdEEfqiCcwHmjB6PiAG1Fx765EDB03vDQQhqL2VEUS1Wg7SfgOer2JA94sYNuxdwThqI9M4XOpEapheh7GKkmyK8r+CcUDkZs9c7Snv/gm68oZi6A== 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=ydl7ZvWaNwV2B0UiDnCABjEzxdjBLCEefPu8CJLOugcWT48rDJwld89w8jcSGNGdd/egezeOcOtFrnVRiO6nztoti+nKqYZZSxXTVOz5Tb2ceUWuN5mQ3F8Hobqx+nERRBYMc2j4482wB4Z1GhXTW55hLj3D9HzGnu8bZfxDgcU+JseReqdwJZ1EkmkO3BpaFNqn28dSGyzyHNHcGcJPqYCjQlPgTIF5Ts+BUUv6kIbLRC+FPo4IaJ4j3yakwsttObToajzqwfIUqDWNgivJWxdfi0btlEVuNw7u8oMGQ0Ql+5BXCUuCycB6clMNBkS6FJDN4g/yhEuRg3up7p+Baw== 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=ak3Dv5h/LWElE4ot6iIogiIrZY9YvuFz8OVgz/MEXmAv3JqQkTkJCHwyz6urcrndIV8adVKB1vz3/odu0I4QPlXVV+18iNLbymfEwIEdkzYpDUiw5F4JtGM4ien0eLG6MmBx0U30MyBH2STN4Hm+CbaHo4bniqxjKCGHdRDsWlE= Received: from CH0PR07CA0002.namprd07.prod.outlook.com (2603:10b6:610:32::7) by BN3PR12MB9569.namprd12.prod.outlook.com (2603:10b6:408:2ca::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9320.18; Fri, 14 Nov 2025 21:39:54 +0000 Received: from CH1PEPF0000AD7C.namprd04.prod.outlook.com (2603:10b6:610:32:cafe::3d) by CH0PR07CA0002.outlook.office365.com (2603:10b6:610:32::7) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9320.18 via Frontend Transport; Fri, 14 Nov 2025 21:39:39 +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 CH1PEPF0000AD7C.mail.protection.outlook.com (10.167.244.84) 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 21:39:53 +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; Fri, 14 Nov 2025 13:39:50 -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 v7 02/11] cxl/region: Store root decoder in struct cxl_region Date: Fri, 14 Nov 2025 22:39:15 +0100 Message-ID: <20251114213931.30754-3-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251114213931.30754-1-rrichter@amd.com> References: <20251114213931.30754-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD7C:EE_|BN3PR12MB9569:EE_ X-MS-Office365-Filtering-Correlation-Id: ed4adde6-7325-4d67-9d8b-08de23c658ea X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?QWHTWqo9FXQBnU0eA9Nnh45TZBWUTbCmyViZnSmGVC1ufkzBFVR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22IG4mLMwCAqvwSN6g8USc8dR8K1p8hTDyXaSGJmTv8OryJx/tp?= =?us-ascii?Q?NgHgBXfIOuDC3hSep3MvqCQRPBd4OtzWHdMOCjwtiG48IRENgX5wx36g5z6d?= =?us-ascii?Q?OcdjqZdsezRIw6FtsbHrBSjPAcbnGG1SMkWl3bh5JxdzXWp9pJu7PDP7MGIk?= =?us-ascii?Q?othm2+N2y97cONJvFSwHsiGN71F7JfihLvr4Wul1+xx7dXukaVMgCWvrC2Ht?= =?us-ascii?Q?SzZCHjwv5geUE2FphUZHivNZJY5OqB9AXett9vqhgWPFky2T7OZiAANGR6GJ?= =?us-ascii?Q?jm2YjiitSBpt7k17JbOeeaPhdcVcV8P+QKkN9LQg1eWfehZZpuRZ7xeCCIW3?= =?us-ascii?Q?9EjpW+vnjoAr0TljelCqompBNh+S4RHdRxSwLJvzinQ9mloBL7mKUeAi5N1k?= =?us-ascii?Q?nxb+qwOOmOLUdHqxObqbdBa0xeTJjapBjOfkGdzhPgCrTqwLHocDfsSdvbwp?= =?us-ascii?Q?wlTIhmZB2MvSiilJz1l+lI530q6264Xn6NUhSly576ncZ9Wd9lAFooIBUWVd?= =?us-ascii?Q?rp5ihMyYhYIoRCiFgXkRqSZH+zyoDOq47iUQ8AMWvr3PsAxFiYTJEX2dIqPj?= =?us-ascii?Q?fdKm0vqlmX1ey03juJ/IYmK0PSRAIIKr17y/jAxuE1ko5e2wQ0DwaTkbyTfq?= =?us-ascii?Q?fNGmQG+KhaHKXrivnoI=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)(7416014)(376014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2025 21:39:53.4901 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ed4adde6-7325-4d67-9d8b-08de23c658ea 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: CH1PEPF0000AD7C.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR12MB9569 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 Sat Feb 7 18:28:45 2026 Received: from CH5PR02CU005.outbound.protection.outlook.com (mail-northcentralusazon11012007.outbound.protection.outlook.com [40.107.200.7]) (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 EA74D35CB6A; Fri, 14 Nov 2025 21:40:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.200.7 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763156404; cv=fail; b=RhLfyony90XBGssjiDGD0cdyJu/NIv4QFoFuPQ3GdfAB/J4ppzRrghiGlNF16QGYhBRBCasZFMqUjDbB8aF46x3KM7a4mOeFQrtu8nUnS1ZJcQFGkhGXccnZqwirimfzYexYTDJpB4OuYEXWelMl6Vn7iRKBBmYitsOl+W0yg2g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763156404; c=relaxed/simple; bh=/m4K2MszO4PSIp4MRyq1YJ6RQplFH23mK8hnk27UTb0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=s7gd8tsqUjfLNC41zeipZ/hdROsPWJaKmVQSezM5eVi46vwzbf6rFEshAhsLLfltJwwCldSSBioKgISlWtOncdgBGtO+b9icYx35ovnvbAFgwJ5F91BcfpiGR4lgv2XhMqnBwFDG3L/jxHMKV4HkTzldnYkd470HYJVWyUyhleA= 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=Fo7rfqMC; arc=fail smtp.client-ip=40.107.200.7 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="Fo7rfqMC" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IYgSZaKR24bU7arNnRo4YW8Rv+O0WvX79W9DK0q6vATXrRAVqvnaebeevJ6ZklEa3SDl+EaCUy1On+sJoQSSiuVJQXZywvvKe7iLjhovB0EtMr4w/ubKB/ZH780fSRtdZ+qGgS4uSongx9/YVfzCjcIpDPBBt87W5++YpP7qRKhWYrT2RmM1lsH80Kib/giMa5W/Yp6rgZYO/TOHXNEHvE32OAgRAS1R6yS0E7jHNfnsu5bWCNUZk1Ctg+z9TnTIVkYIdj6mL3AqdUefYC/xVntsAdvgQ79HlGscSZpg2n/hpCml5SASgCvFYxWoIESuNBKRyrpmIjuDYqe8g7ti5A== 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=NnoECqhkUURPnwcmGOovzJcQk7K3XOR8fgHVELtdBcgdz2lrB6WKdTWBXV0RNBIbz6ELLiVNUSLkTFm437aIaGA15n/TzPr6pJKiTwpDDJBNREWRMOnTd6Xjb2C0lKeLd69xxCyeS26wpbMYyZAd5HmWfhTZ8LjeusUKhNzK8KRko3/HBGyoU7A7ob7FCljHHADZZGI3a0exZB3SAfT/sAhWWJ3QEbmHoeYqBy/S/nK/+qKywhh2N+2xLgUqzuJeu5ixrhcq7ZWYsFkfjo3ffI6EphjgnOMJBRmR5VefG7hm+xv5fcWFgriaCa7/92cjgH75filBrykXfLCVAyPcUg== 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=Fo7rfqMCcfNxmd+ztRHqwrAnWOYjq0i7FZbhpgJcmGA1jzzXmd54JFaBQMwxN8EkU+ZZj5mP2pWjLvkvRsYhGCciVTWr0UlaqENf4DOP4kxx116Q7LToOwzFV5ASacnNHgOth+8BC3PVGApjcIxA7to1aaMWEy4wIpjPKlA5d4Y= Received: from CH2PR18CA0004.namprd18.prod.outlook.com (2603:10b6:610:4f::14) by IA0PPF002462CFE.namprd12.prod.outlook.com (2603:10b6:20f:fc04::bc4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9320.18; Fri, 14 Nov 2025 21:39:57 +0000 Received: from CH1PEPF0000AD7E.namprd04.prod.outlook.com (2603:10b6:610:4f:cafe::7d) by CH2PR18CA0004.outlook.office365.com (2603:10b6:610:4f::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 21:39: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 CH1PEPF0000AD7E.mail.protection.outlook.com (10.167.244.87) 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 21:39:56 +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; Fri, 14 Nov 2025 13:39:53 -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 v7 03/11] cxl/region: Store HPA range in struct cxl_region Date: Fri, 14 Nov 2025 22:39:16 +0100 Message-ID: <20251114213931.30754-4-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251114213931.30754-1-rrichter@amd.com> References: <20251114213931.30754-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD7E:EE_|IA0PPF002462CFE:EE_ X-MS-Office365-Filtering-Correlation-Id: 50487877-3a18-4753-5c3e-08de23c65af7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Xk94FdOrouBIEEQp9HhB/NmpJqflI4QCn/2/Z3FM7ug3hD6AB8bBvde9irq1?= =?us-ascii?Q?JkQ5WJuCtKGM9PO8z3DBODjCn2wRqjaCeb1YFHyEOcv4TiVk/FcHip70PMxs?= =?us-ascii?Q?RQC+9hitdR+fF6190DU+Ns//IryxY/HlNj1HQ0zZxosbuA8ObQw5u7BXHOTm?= =?us-ascii?Q?rEhGsfHWSViS0Yt1yK8Vg6P+8DqXGDptbvMzjKu04JihnKyISyJqPSKjN3Wl?= =?us-ascii?Q?MYV3QspbxYqlLspxpFwzjryBuQktepUtjwKUK7she9SRfqe/MMQh9czmvfzm?= =?us-ascii?Q?YjPPAZCITddhdZMmgXc/+uhSqXCxSJXP+1SgNKLlFBhX9hhQkYDGR77Yc2fW?= =?us-ascii?Q?0JnhriutzvwKoXSSEhmykWNN5SIcEl/GY5RdSgytejshlZ2lKwGcNgva+Wff?= =?us-ascii?Q?j9yxDDpZ15MajjwCsnL6iK60cAHAYRzcqouJ2eaAK7Prbp7UsUiHUfP4Y7z7?= =?us-ascii?Q?ANBtplL2n6/uFlfT6Uc7AifaIizE+Zk9BAAKER3U17EJ+ZBa9BKtPl88Wqq3?= =?us-ascii?Q?Xn7VYnUi4elVgh8g7pFcBVT3Wwj+FHpRXq4CPD45pGwkrghY765DOS3fNlhO?= =?us-ascii?Q?F/B9F3bAFQoGclwijBsYMy7iainUAzfwLwvZAFjLZy1JEin1etLX6GS4O3M7?= =?us-ascii?Q?u9HnyqE8xC8yu+kAnkV1gJeuEDc2QdKA040lvTo/eqM1/4Z3Bv8FOuY9piUV?= =?us-ascii?Q?HUW0hNDZHv1Pw/L1jR7vKNkOr/3sXtVDj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L:1;SRV:;IPV:CAL;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(7416014)(376014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2025 21:39:56.9300 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 50487877-3a18-4753-5c3e-08de23c65af7 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: CH1PEPF0000AD7E.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PPF002462CFE 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 Sat Feb 7 18:28:45 2026 Received: from CH1PR05CU001.outbound.protection.outlook.com (mail-northcentralusazon11010013.outbound.protection.outlook.com [52.101.193.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3CA7435C181; Fri, 14 Nov 2025 21:40:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.193.13 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763156410; cv=fail; b=YEMrB2F+AknpLz5/5eDfe1e9yP1iNkL4icN4fRFIaZEZkyhA++79oH0RPjq4VGVGOKgQs2Hza8RWKEyKHzAAatfcBMbh+rbxu8MifWOFYAlFDSU8pNpGPEC6fRM0bYrQ2qW4CrFF5br2+7qbcCka6kqGQ57dfz2yIOURB85SvIg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763156410; c=relaxed/simple; bh=Ruw6cex6Mkl3tOYxwXtIS9uSljMfdsGuorzsuHZfGmI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=N5oi1BaQhj/TKYRRYBxAt5qmTAlO47Um11StkNUUp6IcIidM5trvLJD32mwOEAjSC+ld2MipbA3eTT/ajpLrSc6tr+GeuhPTQVqEg6Bujfei0EmyVxo8zKcRJGhUSBpoOHY2BXcoD5UIbEcFBNt07MXbO1zmnPCBoP7vql31mtA= 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=4enY1ekF; arc=fail smtp.client-ip=52.101.193.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="4enY1ekF" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GkQVZIkMR7WW3lEWNX5F7BCWPHiDrApK5o4cVPlLv2RRBvbkivciOJ+/4hpUF6+OdP1hRXiMchT4Zj3p8nE1exUqTHnXkS+Vdg9QZtfPORwj+2WO+/gqOiC2QDvLN2Sqd2xi8s9mFRyZOTZnct1b2FSuaRWoLmPGIkz7gBXGy3c1c5YW2+i9s0RCu+1JSJ/1JWYQbDU2+dSFmCJ2yuS1rvOuhG9TWMV2o1QLNW1yFLPB1LrUi+HbAqMDTwOIkFqL7Q5QlX5QCL9Oy6DsT6QUXpTRrLTtfHC7YH7hGr6sra3brsdbWeTXbKaQlU7e5rFmVYBeV++gyxzjrNtrNgmZwg== 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=OYPy8C/lElJLo32LUyS8Qzu5LJvsr0BJzOPmOYApzDv0/nSz5VKIN8CDBwcltbVjFqCzD2UwfVqL670vq7+r+h+RY4mdCS39027z9UL/rD3irR1GcblKxntKvU23GsmhJNfw8Jq+rPXgjSV8TZbZ0Z2nPiQ1kCov6dUcIT0MeF2tEifUPB4dDugMWx8rwz6/q2j4QUaI2rPkC7dlqRBNu8qVaeJYWY3HOEuOduGsKS5yMh7vKd3sLwADX3Xq7tEB1WnFY7fzbZssr3lNxNJY7l02VT7Cd4eTUaSLqx68PVM2qPcP77qjscP1jWJ8sJ67Xlfc1vY4dbW/3Lpt/Afz2A== 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=4enY1ekFUoFhUkRabB8kXFS3ePo4LPG5iuXBkJfvg9dE6XqqR4Q1XtPUrIlamJ88k5Zc2zLIUbp7zfT3k9yID4YgtEQ/RYxN6M5A1VNknylBVx7CwAsdhB5RHobuY/5iboL38A+lXMphksjT7S7byhK7tZPIc6obza++jidXghw= Received: from CH3P220CA0003.NAMP220.PROD.OUTLOOK.COM (2603:10b6:610:1e8::17) by CH1PPF189669351.namprd12.prod.outlook.com (2603:10b6:61f:fc00::608) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9320.18; Fri, 14 Nov 2025 21:40:00 +0000 Received: from CH1PEPF0000AD81.namprd04.prod.outlook.com (2603:10b6:610:1e8:cafe::5d) by CH3P220CA0003.outlook.office365.com (2603:10b6:610:1e8::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9320.18 via Frontend Transport; Fri, 14 Nov 2025 21:39:58 +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 CH1PEPF0000AD81.mail.protection.outlook.com (10.167.244.89) 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 21:40:00 +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; Fri, 14 Nov 2025 13:39:57 -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 v7 04/11] cxl: Simplify cxl_root_ops allocation and handling Date: Fri, 14 Nov 2025 22:39:17 +0100 Message-ID: <20251114213931.30754-5-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251114213931.30754-1-rrichter@amd.com> References: <20251114213931.30754-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD81:EE_|CH1PPF189669351:EE_ X-MS-Office365-Filtering-Correlation-Id: 18519ffd-b7a7-4a40-8df5-08de23c65d08 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?QMfCHvxWz2inUy2G6PIgURdo0nnZc+DCYxLR4FVa+sfj1N501D6HiNYpbGgj?= =?us-ascii?Q?2qE9N/FHIk3xAUO+4awUbTs9RuqReald3DL6Nfr4ZCfcIKTNfaQlwscV6WtT?= =?us-ascii?Q?D+pw+pqZ9ReBQL6/5gJm0fuGVPl4s+oNwutNlMtJUDZxrIRhOo7SAzAUImo7?= =?us-ascii?Q?jix6BNk9TiQJg4lFvzwGYEWbc3Tnx6bnFSnWXgbsyApgGDcMjMPXpDU0ATso?= =?us-ascii?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80rakB1iX/FTHeCYesjZtCIFqKd?= =?us-ascii?Q?DBam0+iR/MC2mryvVV5jdacT5RFmJVzEJZxXibzNSVVgpm8+dErPhvhpc9AJ?= =?us-ascii?Q?mbcwmC4Lg2s18egGadPC6kUnEUFgVGid41OKoZbXiJoz2c1sIg1/7xbKK0iw?= =?us-ascii?Q?N0D9TGb5pM0J8IS8rvwVUmzARTxKb41x43ypGiZmidteJaHfSaRvypqIzxN9?= =?us-ascii?Q?KI+tXhNNjM8Ip1YYH/DErTJE+MWZuhD1e/IJ+iCpfj5Rp0ngHuG0UYOZby5y?= =?us-ascii?Q?xnZ7R1RKOZ+s5Yg5NMunf271Vb76l30sQmkCJWKA8YNCDsI/vEn+nyInAQo7?= =?us-ascii?Q?DB9H/AB+WJDho/HTKwnQ8mqw8mdvmUBR9pRSXUyYjENM7zbymp1CH9Rgkbs8?= =?us-ascii?Q?0JriS4l+N15mxFsuaEDE4stnmNanVYxDqtia7pRERIgSLVxLSmUevFrcveNN?= =?us-ascii?Q?ikwsZzMoDShLp1C4L+4=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)(7416014)(376014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2025 21:40:00.3979 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 18519ffd-b7a7-4a40-8df5-08de23c65d08 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: CH1PEPF0000AD81.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH1PPF189669351 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 Sat Feb 7 18:28:45 2026 Received: from CH4PR04CU002.outbound.protection.outlook.com (mail-northcentralusazon11013024.outbound.protection.outlook.com [40.107.201.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C71F335E52F; Fri, 14 Nov 2025 21:40:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.201.24 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763156418; cv=fail; b=I19FiRn4kQjVu9o74tEcv4DdMBODzJDoG9BzqJ4F4Ib3h4c3tLh2288ybB7UDQS0Y5kPzY2hZQMiBKPZxnZeQ0lppSx7C3wx/lLNptynsjz4AfdQd/TOnwwo4J38CYyRe58MbEBKhhUoQUbtMIKUPV64oCSCOlV/nSNebU5f/Qc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763156418; c=relaxed/simple; bh=NndT+k3MCNINVWqo3EPl3NPWWiToLoamysBBp6eJQKw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ad7G5rglMDpvAFrFVHQNtgtVp894eQIi2OWjUFpL0W64FJFXKtELRwFwLI60LRINE2iEaNv6XV4GoyLDN+qq1pnl/NgA/JMs7X3Pe/CkFYefDkZHImfk40sO+TlsF5DnKQy+EcY0R0OcFe+87GP2RyOEdriuD8BN9bz+V/pirKA= 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=qYRpsvHF; arc=fail smtp.client-ip=40.107.201.24 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="qYRpsvHF" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UmPTmRMX/4xcDblJ634Qap7pb9p5+uCISM6ltOwjxARoWnO+Kxig/HY74HP7Zzdn3uqKDLKx2VOYCQQGZjiNPAsweHqTj0aVXbmUk/HTYJ7qcaSP/tWyq6RdyWP2lvxfLhg8aONWfinor32nAs9P021GBQzV16EdbtGLIy3pyWhYlNb9Ur8zvLDYKapwWCMG6qFuNr5Q1HLH6r9I6sw/f99y8jbCnNuHsviAI4V1Kr46FEMpkG9AW2pcVEPhVBM901cEVfFW95DiRJ7VUUotyqEZ3jaTxDLeaMzPlCQqIf2pJorYV9FjR7ZwbEb40ubSOZr7vVBEtWZPrPNgDtaJzg== 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=LhAKzcbLFrZkdy8uGVo6tXwb8J43sV2XPEmSRCPiEl2iih9kS4TttGWZvUqUPMh0cdxXz/Nr6BsfF/WAmbXcxFNU9ki6JJGqPbKcYHfBRC3v07kVUYwWSCMUN5Bg7nczYvcejbzZOU9QJL9L0w0Pkq+zC9cJp0AYugS/qlrnJeflwY7Zyz6Wf0KdB0vBhGMdU6zSGTYr+yMACehCFgtecWW6WSNtJJNhb84KvgDSrOY6hlEvlKODpB0A4+ZmIP1rlCY6t8OLo8Ro/4+65CCMXX8iLKkPe4PRNlciReMrrHgKbI147G+OXbGbn9gkqo8uywPLNuhkGOLgTq34cOx9TA== 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=qYRpsvHFsl4iC4naxbrrVL+I957YUayG9Iui8dG+Hg0dZaAJZ857wpjryRrx+KIWZ4jJ2k1ci2x4tBhXzmaMx5pWnt06Qlhay6Re/ahGgAmHuqRsQokueo4CBmDPtFzFuy9CLIRp0x+O03WDy0bRPW3f8Ual5XK6CbuMFvXICCM= Received: from CH5PR03CA0010.namprd03.prod.outlook.com (2603:10b6:610:1f1::20) by DM4PR12MB6399.namprd12.prod.outlook.com (2603:10b6:8:b7::15) 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 21:40:08 +0000 Received: from CH1PEPF0000AD80.namprd04.prod.outlook.com (2603:10b6:610:1f1:cafe::8d) by CH5PR03CA0010.outlook.office365.com (2603:10b6:610:1f1::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9320.18 via Frontend Transport; Fri, 14 Nov 2025 21:40:00 +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 CH1PEPF0000AD80.mail.protection.outlook.com (10.167.244.90) 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 21:40:06 +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; Fri, 14 Nov 2025 13:40:01 -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 v7 05/11] cxl/region: Separate region parameter setup and region construction Date: Fri, 14 Nov 2025 22:39:18 +0100 Message-ID: <20251114213931.30754-6-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251114213931.30754-1-rrichter@amd.com> References: <20251114213931.30754-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD80:EE_|DM4PR12MB6399:EE_ X-MS-Office365-Filtering-Correlation-Id: b71c306c-4fed-4fa7-0488-08de23c660c0 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?GoH5t6cl1xX8JTdrmnzVeWGV9tuM3clCRPpcqvdQV85k8IRvmkFYSHDAn2jU?= =?us-ascii?Q?zxAQYh5k2zNPHWBwbAdzUJoaO2jTeacZZBfH4kQ5Z5fnkk9G+SWEaGgqfZwi?= =?us-ascii?Q?6yOVygdcsz2wRv+7x9/V97iMJrPs7umJnGWXE2JQeW1Z866cBM8Fi1ygE6MO?= =?us-ascii?Q?WNDO+I4DeuRWYuki3hw7dTr1gM4m1SD80ZmYbixRylhVV9pJGzH0ENFWUwHq?= =?us-ascii?Q?RFiLlb1BlvOJO+vLYMZuLhJYY7IQJMpJO6SS3hw8H2/BEAAuqbwbkBbnj5qb?= =?us-ascii?Q?SR6wsKM1/fKNk7VolQrar8v+W7mKPTfselFJpVsXXkHyqN7aK+jrw212eoWH?= =?us-ascii?Q?IH+uXZ9mcJXraJWGrKXNva2bR0/QbfwZ355MJx8vjWqUneic5ECRpIm1y/0v?= =?us-ascii?Q?BAQ8vq4lyMg4T0a9EC0IXFmb6zN85k31M+3HvCJg5w7BSCtfaueJwtZWjqB8?= =?us-ascii?Q?HT5jhu+cYTEjdTC6ptLk05AR+LJXJD3lXdQK1wnqvDHAjswXY9L/kJASYtTX?= =?us-ascii?Q?5gnjU33Tr44KxpxgFlBqxbA2gA+ur+1xxuNNV2qXWfbzbbagP2YUwISrZUjW?= =?us-ascii?Q?09LS8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KfFvv1ckQj?= =?us-ascii?Q?+QN0dGsZQ9M2q36PMzfKSguzDb94yucGWj0eEpIIdCp7nt+vRpozocF7HMaj?= =?us-ascii?Q?L9UB15bJslxeS5DM44I=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 21:40:06.6328 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b71c306c-4fed-4fa7-0488-08de23c660c0 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: CH1PEPF0000AD80.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6399 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 Sat Feb 7 18:28:45 2026 Received: from SN4PR0501CU005.outbound.protection.outlook.com (mail-southcentralusazon11011044.outbound.protection.outlook.com [40.93.194.44]) (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 3874335CB9F; Fri, 14 Nov 2025 21:40:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.194.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763156414; cv=fail; b=m+tgQlPDlASNbPFbmmb44ZebEPjg47iPyKjSm5zBK9Wzhdp2ju7QqmPE6Qt+rVBUp8T/YIaj/KVLWKOVE5ib+BQesPrWOVpcej/30Mvvb70OWfE7EkSqQ3M/op5/9C3ySxqbvxITqxlj29woszeCcusd7oXKGPVFIa6hexZ6Zr0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763156414; 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=ktYY+ZoRVk5cAE+WM8oHz7BZfMhiw8TahipkcUs/xKCMX1N3vvM/adMFpyVp7AFD8rDC6CL0WxSjXrt7tX5k+7Oes1WU9kmlsGOwiSp2eWnYUXrVqqGQnVTnS3gA0xgfWMYg3MHZGkSnR+t7AN12vGOkemoq3AO200v0XJGyRdo= 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=nE0ssVXX; arc=fail smtp.client-ip=40.93.194.44 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="nE0ssVXX" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wNHrqN3g9HvwbTTqmPiDjiaVe33xRfZ537HPs1YfUTnscO1h0HFt5DGLNn0NepuUinir872N9E3HOHo9GyrIeQHygwc2AMZf4MJfuYO5X16j1q1daVcc+6svcsMDaSdCnmRy18Zch7F0ftkTiKvTnr+AUh17Ey8aGDkQT047gH6iJs9qIsBUR5eG+YZdFYje+DoFpvGtWPQ0wOsxBGF3HZXH9VuhIOX86ApCzVSNrYMgRjSKJrh1Hn0/PArPU6s2F1X+pLkt0nKHcAJ5ZGKixzfWRoWlInD/AHmzVBaYOHjExm+ksZ3KSg2OE1qgS6hsGlOBm+ctDVcsxswhHDg3gQ== 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=CneXsAaszevoR/ophqgwj9dxpzat8+4w5pKuo+BhcNbXjNG9qNFTN1FoQLUdjfTjzK6rNgFtGoIEm3VcblCF6gOTduzR4fT2nsUmlTW4wTbI7SSgHPTTsG9DW9RSHxyGu2xxW6VXo1ADL9tO3+CPzMPlMYFSZV++XiH49dTZIFsJtI0X/lKkiGJMn4MDntUf5feRqw2iMa2EgHM3C01A7egyDZzfQOxfSWpyLLdjnsfLJ6+YeuS1vzh3MtMdyrIRZsgRYwyG5CeOZAHE9s6UV4oBMfQPEZrMwd8whWT6cnDE2wpHjePvmzNpbN0dnPfikPtBqv+8H/pD3s2zBWOvPA== 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=nE0ssVXX53RA2crKZ5E+CrZJ9Lh4KB2B4YAFusguaFTFmnRip+8kB5iene02FqsMDowZZUxZ2Kru3bAT+bhmLomDy47Eb2qowIbLmHMmT32JZUwQgK7mPTVxYueuw1d20u1t1P77JVp2XzSQ+9eF7DZ+Wu8LVXWXN3BdDsWSXVI= Received: from CH3P220CA0006.NAMP220.PROD.OUTLOOK.COM (2603:10b6:610:1e8::34) by MN2PR12MB4488.namprd12.prod.outlook.com (2603:10b6:208:24e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9320.18; Fri, 14 Nov 2025 21:40:09 +0000 Received: from CH1PEPF0000AD81.namprd04.prod.outlook.com (2603:10b6:610:1e8:cafe::c4) by CH3P220CA0006.outlook.office365.com (2603:10b6:610:1e8::34) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9320.18 via Frontend Transport; Fri, 14 Nov 2025 21:40:08 +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 CH1PEPF0000AD81.mail.protection.outlook.com (10.167.244.89) 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 21:40:09 +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; Fri, 14 Nov 2025 13:40: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 v7 06/11] cxl/region: Add @hpa_range argument to function cxl_calc_interleave_pos() Date: Fri, 14 Nov 2025 22:39:19 +0100 Message-ID: <20251114213931.30754-7-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251114213931.30754-1-rrichter@amd.com> References: <20251114213931.30754-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD81:EE_|MN2PR12MB4488:EE_ X-MS-Office365-Filtering-Correlation-Id: 763a34ec-5ae1-4222-6063-08de23c6626c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|7416014|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?kmC+lEBHREeSSW6KlKeesxNTJNPg7DP94mWg06Ngg/FzRPwpQ7O2hFic4qu0?= =?us-ascii?Q?bKKENqYu+DHzlEgmmhcHT02ASFWnKCtT+AKmWcucDDpgp4MMdHhDXIlU5XRb?= =?us-ascii?Q?W5+wF1LGCNAMuH9mcjvvvIyVaB/361QJlg6r8ppJlC93vGyvc/9/4eMYCPH5?= =?us-ascii?Q?d4CZXhd+jZOJvOXvR1JqlGN9xOFC+1jegfL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siaMm8/5sFZKplWX4BWA+EKqjapQE8Mxr/oSfcVQnM05ep15b9K3?= =?us-ascii?Q?0he+gFZkD8NPnD82cQ0DYUYf/ZpZdYVcLndnMp6D7Xy1or4CpxkKS60dqIqc?= =?us-ascii?Q?Dd6b7BQpzNN7LzJFxR9Z/VdpS3mfGWn4AKk/GIPXNu40YbcELYhtM2Pyzkm3?= =?us-ascii?Q?b3/nPEQ5shijwQQSmYBD33GwfbSjx7sBM1lpjFPstFDQqCtIuEIfzxXJK0cy?= =?us-ascii?Q?r3tFyINobX25+XPWwmpBtG05JLZBs5CMOt42HfTySD7IvRAsXzcow3s+k2+d?= =?us-ascii?Q?6c0GAMMQTnFqz78n3tjfhnvh+wZnAhmxaC9wZII5YXoEm9NfUuBTrIUZ9bJm?= =?us-ascii?Q?MPYE0Ov8ToBSljHRBLP/PQpj4Dyg3RdXbO5wsTh2+OHcYHIUlvENs1KURSUF?= =?us-ascii?Q?Twpfj8M3UqzkDnBwr+1lUqmhBkFfIv9wpL6w2odGTCuSBn5dX6HQrnLSPVzX?= =?us-ascii?Q?W9qukbiGo7FBTeOMwOk=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)(1800799024)(36860700013)(7416014)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2025 21:40:09.4393 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 763a34ec-5ae1-4222-6063-08de23c6626c 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: CH1PEPF0000AD81.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4488 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 Reviewed-by: Jonathan Cameron --- 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 Sat Feb 7 18:28:45 2026 Received: from DM5PR21CU001.outbound.protection.outlook.com (mail-centralusazon11011019.outbound.protection.outlook.com [52.101.62.19]) (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 EB14035E522; Fri, 14 Nov 2025 21:40:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.62.19 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763156416; cv=fail; b=C7H61pq3fQGIIL9eaMX+BQPWzOSZbBNF7gcGd/2Ntn9KZPzJ5TyBcKoJxpMKCw45MEe/jqauLUKEC+WgovZbOgkjVg3PoBIS8wybqFM6T/LPXrdGrfYEyP4ZDwbEW5Sk6yEPg+nRydyKUA30gZC6BzgH1BVtthgVanFXNJle9JE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763156416; c=relaxed/simple; bh=d06gooiMiKPsC5Bx+E7CE5qgN7rQevYOEQx6OxWdwIA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Oqc+RUQoVMF6akBbXQNPvaKMlHsa1WaU6wWbc22ALisN6NgL7iWytf9Tf1raWZ3mzgeEXex/ZBdqa/fy4HHfwKDsqnPkibLXWIMbt1OQTfu6IStXTJ8QGbGWN1lsTvKYImuAqJTE15kwVoyS5avm74zngtkdY831U3kE9FTx2TM= 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=mKx1+qrZ; arc=fail smtp.client-ip=52.101.62.19 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="mKx1+qrZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pyBKd3cwEMPVKbdKnc2dYRwPSRkz0YdtQpjuxiYhEtg6I6lmXpBXI9BQmWRKBz/8dA3e9YgDM7GpbQHHVr7q/yOnfIJCC0gKkjwnItZSGwhXcp97yCpKZokXmIf7ukfZVPzHOApaOm/h81+keya08c+JIifJK30WobBMkbSnQS29WmtmltcnyvDmWhEHvWXF1oi0it0JfE5ZNRox+/dd1lsG8iH/XV95ZLgJYEvz6bmrsLeOE0Zk1/SRPMqdVBH+8XlPDO2VlgndEzo7Nj+7KQtUtoZ3Siu4f5VlGNI5fOMfeYXgF+BYqh3uS0Ixatn+V8NZbdlu6l/Da8ThThNlzw== 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=pqf43SCzNFUdLRLaRcRmamnQvPZopsTsl9SPMDAzlg+XgGkK020E53jC0qCKnmVNQqe3B7rhzS8lMMpZRtdcryOpmE/PbfXU3DwHyElepUMxKiVnT+n6/Fyjl6m08b0e1dnWJNLdo8kxYR1wUC1by759SiJT2nW22V2SI0NX1O8tjaSPSLqNy2zbBVj5r8c+VtFaEROITUSCwyTWIy8wCSHcvr8c6RCfy47oS7PEKut+r+OC9oWpy01d8aN6bcgjtF/gqqFyZInKVU4NwzmgETitIYHaUvsSK3moyoOlzQTvOYRGiHT93wnBU3Osr8Pltdf/VSy42a0/sHjoxSrPPA== 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=mKx1+qrZhn21/EPIj7RlyIbpqTIJ0fK0sAxb1oaD/AUHtCyB+5ZbQnM4ZtlVJVJq0hLWYCFIBOtYwmRumjS+y1l+XCUF9V3BUuUdh4x9JSMVqJ1ZXiieY0S0oYVTa28ymYSernPngzxpZIzW9iGhjDdPutDelFPhh7bFwEf9vxQ= Received: from CH3P220CA0024.NAMP220.PROD.OUTLOOK.COM (2603:10b6:610:1e8::30) by LV9PR12MB9805.namprd12.prod.outlook.com (2603:10b6:408:2ee::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9320.18; Fri, 14 Nov 2025 21:40:11 +0000 Received: from CH1PEPF0000AD81.namprd04.prod.outlook.com (2603:10b6:610:1e8:cafe::4a) by CH3P220CA0024.outlook.office365.com (2603:10b6:610:1e8::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9320.18 via Frontend Transport; Fri, 14 Nov 2025 21:40:08 +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 CH1PEPF0000AD81.mail.protection.outlook.com (10.167.244.89) 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 21:40:10 +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; Fri, 14 Nov 2025 13:40:08 -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 v7 07/11] cxl/region: Use region data to get the root decoder Date: Fri, 14 Nov 2025 22:39:20 +0100 Message-ID: <20251114213931.30754-8-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251114213931.30754-1-rrichter@amd.com> References: <20251114213931.30754-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD81:EE_|LV9PR12MB9805:EE_ X-MS-Office365-Filtering-Correlation-Id: f6ee0684-fad6-44cb-812d-08de23c6634e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|376014|7416014|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?SxRYMcubOqbOXaE4sO8Zk1AGTeF7s+xEkbK7H08esYLFAzLocFpk8zB9Axx2?= =?us-ascii?Q?X/PjDl94h/nQr0fat8P2Fj0sLQ78355AVHkrN3KUlYYy9byPlvy36vNsa73V?= =?us-ascii?Q?oLKL2eRSa3fLvAADGyPST5vThINdVBl86uYdHH3Vd094E3m6K5XvubFFnkRJ?= =?us-ascii?Q?Nubx5lmXElzN45aUIrCGLI9rGAT13VVo9iQmdj0iM176kBumaeGDkTmBNcCB?= =?us-ascii?Q?p7PYCR0563u8j31ofjt1BWhlfH4lxpiVg7ijfpZu6emFrACv2MoVsA1X4u5Y?= =?us-ascii?Q?Sh3adJslNfDPCVnliVSRpvdyppHdS9ZedH+jdg0zfHuQP+GS+7JbWTFngZt1?= =?us-ascii?Q?d92Zti6CRh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B?= =?us-ascii?Q?twPzAtjVjS2LB6UNe2TYnE042296kgPQZZ648o78sATLnuGMpK+lbGZCBHJk?= =?us-ascii?Q?svCfdrQMiajAbxSPDYUxZbxfS7FA6RDjvUnPKTT6iOattwNSRV/PofuvZ9J1?= =?us-ascii?Q?varNMxSzvBDGsXm/Kdvfs+S8myvzTdVxRYUMN+YB3ypGPB1OfFjjC99d6NId?= =?us-ascii?Q?OBDVhf04+ng1PNWXtTCtOJcwj3/u5lnUHEc+Y20jOSmWI4WZIOlJhCugsVyN?= =?us-ascii?Q?1zCpOLhyIOhhFlPWu+hroo1UluvlPkaPtvsa4iOVrC1kwjZUVwwR2wFwIsD3?= =?us-ascii?Q?Y8ixQ3ucj8N5C5CAoeA=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)(376014)(7416014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2025 21:40:10.9219 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f6ee0684-fad6-44cb-812d-08de23c6634e 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: CH1PEPF0000AD81.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV9PR12MB9805 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 Sat Feb 7 18:28:45 2026 Received: from CY7PR03CU001.outbound.protection.outlook.com (mail-westcentralusazon11010062.outbound.protection.outlook.com [40.93.198.62]) (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 4D18B35E53A; Fri, 14 Nov 2025 21:40:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.198.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763156422; cv=fail; b=SElpNbwk2YexqnN68xh5cYbwrkIns3pqgbLttK/7kAQjnbyiRQAl7JngzVtwUbkVc5jHG7ttHnPkZjMwBb4A/8eT1BHP0FdO4jvWaFXdKTqFiVRSqy1dPBPz+iPV8KRHIYI/NeZNEYUmR4Q7bY0H9dr+t4jX7wAJPp60evxsl68= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763156422; c=relaxed/simple; bh=GS0tkR1bxoAWbCbJFlmi6dlSShLTzJvNkXsbjHidgek=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GF4d0R1/f+L5VoAG+HkJOI/HSqa8Fa7cq8tyJ6xfk2IBR8E2G4O/hl01FarVGX2fatJfYY8oh8GZqceE3gTaYxgoV6T+12W0FNHKM1kaudP+t5X1y0ISS31wKAcb+DjwHTqEDZbYQEs7hb141xlgzXf/9LgepPBg94dloj60a9g= 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=S55hAKh7; arc=fail smtp.client-ip=40.93.198.62 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="S55hAKh7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tprEVPmg323lqN7/HabEWPQD0kq86eMXggjDS2iKXNQEGQ5Sjn4G2wvbzd/95rjNTZRXBWnuFclMM+F7HvA0tGUieHsBKuBoyfB/IoltwpKV6AxbVtcswHvgu9hhWFIJaBRNbD3HGZEgARrwe2JuCcvo+Lf3pzvhYO0tJdus1aq8FiHmpgzP6osba7k50z4CNTaSkj/trUM46TH8/ccy6Nw2A2fybVelkzNL53M93w39AS2/rZvBRWt3hmNLlr35Zn3C214IKn7afCvLAY4XErLj6ZYblBUaOrKURRRRNcHGkjWYiEE9VEbcEYq/InMe2wo/zQZ6zhdtrHu4+VaXIg== 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=R8lfE4eb5jS6SITXihfIxSzDdcoQ/8hNbk6YaS1JkQKz9sDXwZQs/uxxESk0KHPb8CzFBAbv8NcNrKRx2RjRx1KRW4NJWkhthajOlUqDRi1e6kI4AFoKgFWfPE6zgAQQjlmWAYlcySNIJf9tAxtTEhGGE92x+7xfDRX0mmMSsfS+G8U6rm10StD4t0FuCP+F1n2BRCiLw1Af6F+v6Uw1eChBh9GDb/YHPeWiMnILyi+HdlsXQhv8qi6IWmP/t05ebEplsWaABfgfuHtGXja2H6MZviK8mzqeEm0DJ1kpjs6RK9gzs44WmWNraTmNXOR1L7rXHxEcFitA30V8Jq0x1Q== 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=S55hAKh7qnXc3fgFGzcDUMTiZ1EqcXgQpXgHXewr6w5PlWodokGC+ylQktTu1zTOpJ13NShwZ11vPlaSEHDy5BOUuK5OuXnYKd+jqws4k46FPasAVMERGvKilUqtOZPmOa4yh5ndMbz95aIF2zywwJuuYuqdV7XKkPeoxkZb6nA= Received: from CH3P220CA0007.NAMP220.PROD.OUTLOOK.COM (2603:10b6:610:1e8::35) by BL1PR12MB5825.namprd12.prod.outlook.com (2603:10b6:208:394::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9320.18; Fri, 14 Nov 2025 21:40:15 +0000 Received: from CH1PEPF0000AD81.namprd04.prod.outlook.com (2603:10b6:610:1e8:cafe::28) by CH3P220CA0007.outlook.office365.com (2603:10b6:610:1e8::35) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9320.18 via Frontend Transport; Fri, 14 Nov 2025 21:40:12 +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 CH1PEPF0000AD81.mail.protection.outlook.com (10.167.244.89) 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 21:40:15 +0000 Received: from rric.localdomain (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Fri, 14 Nov 2025 13:40:11 -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 v7 08/11] cxl: Introduce callback for HPA address ranges translation Date: Fri, 14 Nov 2025 22:39:21 +0100 Message-ID: <20251114213931.30754-9-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251114213931.30754-1-rrichter@amd.com> References: <20251114213931.30754-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD81:EE_|BL1PR12MB5825:EE_ X-MS-Office365-Filtering-Correlation-Id: a1fba19b-c93e-4d80-7733-08de23c665c2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|36860700013|7416014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?qWvT8m5BnQzYvb38HXsX/5HZp30ZTetwvoVg4q3c9ODWT9TZpotZgLZCcEHr?= =?us-ascii?Q?BX2zhkinnAY4vymYIJN742zP1khWGOz81p4xJpgk5dM++x7qh8h6FB8Zf2Ns?= =?us-ascii?Q?F3KY58mpC1I13YPuLg29Nw8TfaiqmAtuhG0NhmfKfW3P7qhQgKnZY6o8DBh4?= =?us-ascii?Q?VgQXCFClbH2Gxm/+ZUPa/C6A1Hg8e/oH09vXNAf3t27fZeZDPY9RrcIyPG+/?= =?us-ascii?Q?LhNEIf2+wc26Eai4HTxSfDjA6vwRJ25P2tWrM19fyHMvZuHgIWB2WzgjjoOB?= =?us-ascii?Q?jI0QX8MNcXakb44mioq7sae6bekdhToqBctrBc3Oze3Sc1I1ddD9T0fwzPWy?= =?us-ascii?Q?5Gs41imy43/pnZL+K7EBABujZbW+bXgJmMJ+81DRVQ5RZggWAw1oB/ymKT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2IllHY0Wbyjv3M6tbI9R8KBtXaPd?= =?us-ascii?Q?aY/RaQdVkwkWybH5qewEIrSoteET1YABRKJhySehI/D9NqpUMAlQlnzsj+rL?= =?us-ascii?Q?H26uA923W8uzQR+tJPpl0UCNl3XhwVWByoITOdTGZT7dC2EcmVxlXtbjvhW6?= =?us-ascii?Q?72dNTJ5dVrED4B3rZPZ9nYZTB/g5ZFHbCl3vNWdpVjjbvQ3CYLSukRjVAaZi?= =?us-ascii?Q?+mDAO3UTIuyIPPGaZKqjttMyumW1ugiPt/X+qhjKI/EZhe5AQeaghLiD90+e?= =?us-ascii?Q?NtDYlOxDI/RZT6QczsU=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)(1800799024)(36860700013)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2025 21:40:15.0334 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a1fba19b-c93e-4d80-7733-08de23c665c2 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: CH1PEPF0000AD81.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5825 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 Sat Feb 7 18:28:45 2026 Received: from PH8PR06CU001.outbound.protection.outlook.com (mail-westus3azon11012003.outbound.protection.outlook.com [40.107.209.3]) (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 7C3F935CB63; Fri, 14 Nov 2025 21:40:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.209.3 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763156424; cv=fail; b=S3ApWDfGM548MhFRbXOCACYdahNyKtvWCcTGu2PFClSFHOmwNl4f6rA/8zEMBnnKVepVKikzoPko+h1iubjVQiLr3U1FdlbxPBvYPbsrvfAfUeojnS/N3PhVWZSTH7cykHth4ghOPgv9L6PLZO2/SHR/Njn0FDxbSuOJ1nKmnWk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763156424; c=relaxed/simple; bh=ZwEUSBt3BzCW4o1QzK5TYxo+6JhVfVXjnKYALU7/JtQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=L5+eV3MjAEHJvZlMZN/IkRynn/X9fpVczniLxrv6snhaQqzHVgZyaSCHEBAIM/MZcvCgfgTssKKC8ekRzMkQ8blF7sd098fZ7mSXJ1W5szwMJbxRQaKpnDfs0N3u+nmUcXzDRFSm2LQ6Oc8KlgN2S9lz8BpWnTs4qEKszWFP8iw= 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=rLCoUC8/; arc=fail smtp.client-ip=40.107.209.3 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="rLCoUC8/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dXJda5zBpatRWBp5cW9yhth/aRgK32XOcD/cYCP3T0Bxpfi6UYCl4ep48ls02w6AOkWRxn3iYhl0qvIp17ceLT18CVviB68pKAvQEuJV9dq8T2EmqY+4Ptef3zdJ/ERvAFxpUk/PeHV0Cye1D6Ta+u9FVCRx4v0qVQynPH/FiLcwQ/vMQb4QiWWOk1ZWgEmm5Fgkg02Oc0QZyBiS2syDca9ry/rYNt2yKHdW+IqhODbi/2cun4QoUSNQLcVbsDZ4Q3gl4puYjOQNcRYdwjrrfJX7Lxxq6waOxJdkSKtucOaLtD1TxZjLubb7T+U7Wodg+UcCvEy9Vf7Sdg/UWmeTpg== 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=aQTSnz+1bBLcA5HYXZ8MG9ZeB3BvhL54wMX0clv86tpdOO2/BLghvgyY2NLQkgZQIGkfLqfq89T9DfuX4k38S3O1Y/MvHj01F7Gtm2M7eiqqAeFMG9Ewr3zemkza+A5vPbV3f4gw/8ZZaRfo1gtJOEfWgZ0acn0ctstAgDs6tVqU7+XW+6yvjNpeFqsl2qWNb7SZEr3sJzzOdwdd1oIvPzkVv3Wuh9redieVu4ahzk8Jd/RvghkFEfyUM8sw2wvFVtdJ0GSXvjJvkb41VjRlmoeoZRGojAj/KGjp9q95m+z1yQqPrWHlgRUPLo9p5belbwdKVWxMvjqQIuUj4E3aMA== 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=rLCoUC8/x1wFUAsHuKrsqoGzry2obfxhsOE6gmpkWrHMWtwiTjrw4RKbPXjFfbn1hBF8oTblWej8XjtRdi87ew4CKROjhJwuXFO6bmyECtRYD9i4Zg0Dr++obSI6OtFzhJPgk8RF6NJp5JAAZz7HnLYohhn8k3x9P91aUpIS/ks= Received: from CH0PR03CA0362.namprd03.prod.outlook.com (2603:10b6:610:119::9) by IA0PR12MB7627.namprd12.prod.outlook.com (2603:10b6:208:437::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9320.18; Fri, 14 Nov 2025 21:40:18 +0000 Received: from CH1PEPF0000AD83.namprd04.prod.outlook.com (2603:10b6:610:119:cafe::fd) by CH0PR03CA0362.outlook.office365.com (2603:10b6:610:119::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9320.18 via Frontend Transport; Fri, 14 Nov 2025 21:40:13 +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 CH1PEPF0000AD83.mail.protection.outlook.com (10.167.244.85) 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 21:40: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; Fri, 14 Nov 2025 13:40: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 v7 09/11] cxl/acpi: Prepare use of EFI runtime services Date: Fri, 14 Nov 2025 22:39:22 +0100 Message-ID: <20251114213931.30754-10-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251114213931.30754-1-rrichter@amd.com> References: <20251114213931.30754-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD83:EE_|IA0PR12MB7627:EE_ X-MS-Office365-Filtering-Correlation-Id: 61a298e1-48e7-46af-3f0b-08de23c667a4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?GeSVmIwaBenB1fnw4APE/3P+ccQ2krnjZHAc9oHJimumsLWcxmqOGf2DOF9T?= =?us-ascii?Q?AbNvnsCboztx7aapZ4T22buKai67BjefXGyNSrOUUOyWv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N8ruIWho2LggbZgxeAiXyaAEchy3vE0Ia/28ry+1qB5qgOkR?= =?us-ascii?Q?V7MfcXCh7iWWnyr1nEk0klhdoY3lpP/Ndg5hg/zbEtcpDpK3k49QJgsNm2ia?= =?us-ascii?Q?K6WmVIJ1nqEYhJnPCaSXxEaD2ln29mK4ykvf3q/wM5FB+kU7Ow1cWFfdtd/N?= =?us-ascii?Q?0FiylrF28XGC+yCSSqbhhWqnZAC+A8SaPO28h2Jwo3iOl4CQfXxk+2eR02nq?= =?us-ascii?Q?f+tFibi9kXLrsI24vSZOD72erIxMXdbyJK8OsS5dHOlTOsTQgTYaR61i3w3U?= =?us-ascii?Q?jwELtZRYe9//EwTpQjirvKM4KxUAMVFfUpTnwkCSqB8moFmgfcBPwYXbm0VI?= =?us-ascii?Q?H/HKyK4i/TIBNMUjp4dN5+7IvMXc4KXfbINsjMn7zE2vLoJxFeKCKLLdxcya?= =?us-ascii?Q?yGyFR69FIOGVBjqGuMv4PaZ2NiB6Il7XZVf91H780EQ8SaBQLysQKXlsaNYD?= =?us-ascii?Q?0umtXbxNUGN7gOqSLoaIEyGVcVnbsyHBhIKYhSdF40uD69OoJzIt5pc+hSys?= =?us-ascii?Q?OreNGGZZbdrV2FeEeJDyxCEtzEK3n2882jp6c5JboIY6nZbc5+x9zXZyHd2D?= =?us-ascii?Q?YMwVWFzJNFkcWL9Z/Fs=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)(82310400026)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2025 21:40:18.1959 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 61a298e1-48e7-46af-3f0b-08de23c667a4 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: CH1PEPF0000AD83.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7627 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 Sat Feb 7 18:28:45 2026 Received: from BYAPR05CU005.outbound.protection.outlook.com (mail-westusazon11010015.outbound.protection.outlook.com [52.101.85.15]) (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 4463135F8B5; Fri, 14 Nov 2025 21:40:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.85.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763156427; cv=fail; b=amF5MVprvEvSqudtfB0vGJVdVlaq8jHU6o2HbVpY4L1Yyfip6MXJQcmz/aQ+68G5qLRQt7f+B+pZ9d7VT3r/86HbmGq67ufySL0eW8buqQaQjX/ZPsNoIu3zi3yc8rjDFmtWNp0OWAuGRd6OdHz8WbrsO7ebglIdo0NtXmGQoU8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763156427; c=relaxed/simple; bh=miiZW+wiLtdC3ubhN4wSwOXpWqfScEy+lsDAJI3zjnY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TwSqOtg71/aNI5crDQXx6RiVi3StEuHwLSrqvVDRYQ988UANO0tB4RHn43ryEY8Ddmp0XF9RLD9pAd0vlej+jTk4UWDcRS5bK7+jDwm/bgHhIH4n6zPy4VZ5rDV+1zb/6gNxhQDJQZD7I51Zd+L0jPyojg9GMSiyRzXrUNOvUso= 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=AKnE1UBN; arc=fail smtp.client-ip=52.101.85.15 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="AKnE1UBN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Q2Z86Dd1LTz1UWWdmsO3TlYTcUE9C8BJB6yjqPpS2a/CSCZdN5h+fLTVyiD8Pc/UHPfhydjqq9lKP8sJvku10oONEANtvaLbFgVSAEKObIVZXpC1oBz/t4+fEibnFbkcT/DMP7X475dTnzGdYRxAGn3IFmk57TN1mfGnmtJXBFh9dR7Do/SvBcAsDXhDRMfYpEEoTEVSrIopbzWKScY7jQaJW/kJ2KfvvDAV4LKBBiMCtnbZEkwIRUq3zpe6j5UttWuXpnHomtm1K2l4NoK9Ou5al18eLIEzSOe+sl+g2mO7RqDYWj4N+eBt5xLGauCHZfzVJV8IRv9U9BoB5rj+eg== 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=IXrVuKEkuNH1U64lExsLwimQPDlpFzVucJjPZy2AA+kNSNQVsObwJHUdo+P41lk9/Wy8xOHBVoQjDaV55oRNYVsgh9p9ZfhmaUv9LY7Hpl4r3wY91qZZgyDwCEwaPzEFxQnmrqe6EYGSfOLpYv3YQq7TzUc4EweM1os66ChlGku8SdK8bqsArCqLWNJit42nd0Be+K7d8hjHYAQ6e+c1mjAc+h0qfPhPFiDkuv7ZkLuj/M6qZ7xhpmd+a6iZvw5lvd0BHhU/kDVMVtMAYSR/GUC+pLXK+TMgxALXdL4U1kFd+g+OyoyVp+qi5BFHxCnG50CrJk8cWpLncqQSLvn8dw== 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=AKnE1UBNEpDwur5C72NelY/bAHC35/8ttVMsBKewpJFjdTt8S9BFB4Njd9wmCYcb+kv3ZTcD6sRcbJy08WQwh7ftTLnB6uREj0TSYb1xssawD43wLNCbTSM0NPC86JYqtK35G5WoTJG4ymSAErZOqqOubtwW/d0MuOWsTQEeUlE= Received: from CH0PR03CA0362.namprd03.prod.outlook.com (2603:10b6:610:119::9) by CY3PR12MB9679.namprd12.prod.outlook.com (2603:10b6:930:100::11) 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 21:40:22 +0000 Received: from CH1PEPF0000AD83.namprd04.prod.outlook.com (2603:10b6:610:119:cafe::6c) by CH0PR03CA0362.outlook.office365.com (2603:10b6:610:119::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9320.18 via Frontend Transport; Fri, 14 Nov 2025 21:40:17 +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 CH1PEPF0000AD83.mail.protection.outlook.com (10.167.244.85) 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 21:40:22 +0000 Received: from rric.localdomain (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Fri, 14 Nov 2025 13:40: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 v7 10/11] cxl: Enable AMD Zen5 address translation using ACPI PRMT Date: Fri, 14 Nov 2025 22:39:23 +0100 Message-ID: <20251114213931.30754-11-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251114213931.30754-1-rrichter@amd.com> References: <20251114213931.30754-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD83:EE_|CY3PR12MB9679:EE_ X-MS-Office365-Filtering-Correlation-Id: 37a29e83-9fd3-4ce7-c656-08de23c66a38 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|82310400026|7416014|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?VEV1clhEZ2hxUm9LUWtCRG91VWYvNVY3QVRjUjZJYjRmSDlPOVpmdFFadUVH?= =?utf-8?B?aGtKWjQwODVBZk5BbGxFYXYyeXFqaXpURVdyWnFrK25ueVpGdE5ySW1iWTln?= =?utf-8?B?ODhpVWczNk5YRkVsUXRVdDhGWVQxUGYreHBpckFKRmRmMVBHUVJSbXBxRUhN?= =?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FZZdW1wbGgxbGk5SjV4?= =?utf-8?B?Y3NEM3FteFBHK0c0MHFDQ0EvY1VxakZUYVh6NzZlQUxmMDVFMnkrWGFmSEo3?= =?utf-8?B?MTQwL3dscXd2V2psTDRxYXptL1lsYzdSWXRBS3VWWUlEZ0NaSlVsQk1ZWG1F?= =?utf-8?Q?ibuY=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)(82310400026)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2025 21:40:22.5246 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 37a29e83-9fd3-4ce7-c656-08de23c66a38 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: CH1PEPF0000AD83.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY3PR12MB9679 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 Sat Feb 7 18:28:45 2026 Received: from CH4PR04CU002.outbound.protection.outlook.com (mail-northcentralusazon11013034.outbound.protection.outlook.com [40.107.201.34]) (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 3932A35CB82; Fri, 14 Nov 2025 21:40:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.201.34 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763156434; cv=fail; b=DkUX+d4QUnuR6SJQ1SomdtTJDb5x1g85bOJTK74ahPdwHglv2yJFf3qT9WCJvx8hmfzqky8zQDXRE81NlOQEPerrH3V4wGgR9KvEi6aacmnLolBcq+qH4xruN815iH0ZmObj9JoaA3uQ+1MjhspUfMrXHizhqF/u/2S9YHZVrc8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763156434; c=relaxed/simple; bh=xOPCtWUT7P33EpmfjLoxTmamUfTttbHgy4EzwsFjQPM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fD4loZL91b9j5k1gk//Rn4prH67e6+OUMnB2gXMlODUjIdnbrBTH7kK3OLGb/Y7f6WMHLdLyV8NYE5wzjzGkIsglrciG+UXolI5skKvVbDr39D9LtkeMTexNkBIMHFp8qNT47aUPAfWcJ6OmsOkvbuRwuEdExCj5ooBjBiHUycc= 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=YBgkv2D3; arc=fail smtp.client-ip=40.107.201.34 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="YBgkv2D3" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=I49uU2Ip/0O/XYdM1DdwdQRLMPV+ixipOCfVbRd0/KdlWf+1SPHl/EVk5Eg4SpztZNbby5vV27yAitR7t8aaNGQ0N8f06G2BULUwLjh9wBRmVOg63GiixrMRB0PXOzMUABUULx4tRGG3geEOTouFTPCZsUX4HTIoIuGWnn4b6l6LVggulwULq2fA4QSSd9hjLtkb/kGbJTRYuykPU3WGVNSElRW+LFfu0Ma4ge2JUGnUNoaV2HhyZGxINN5H+2Fzq/P29fvoBSwpvfSxB/fulGnf1xerkaU3MbMc9OUPS1CbNMqo8lyKDgGlHF0zzOw5U02HZv+LJ3yiCczCkVi4ZQ== 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=Q6+t0NUqYHH+N9Awb7wmAQ3Agmg0K9uESM7TBBKj0Uk=; b=asqnob32Z0WZxH4FWXS9OmvlICo9WYkhqoGidjOMycup4ZxJO1nKyi2fqm+/z1iwyWExhqTMQhhCHQtgbNIOcNTocDOeUKP/nn4IG9WTFeAW3LD5ckONyIwYPZhvkdSBDbdc4mTewqUhDHNdVAJ0N8gYHxY9/vd3K1we/HDlFSMwhkyaASpxdHcSqeIWm7CaRIJ2vDVlGJdnuzFYZ1w3Ssf/zy1fW7V3bMg+OFa2y58Zy0Smu/ewnn5e2dI12xm9ng6ECPFXW7krKgJ99N7q/ZE5hCzm6CVGpaeJITvCUt4fEHO1d3WEWVuZKeFDWA7HgCV1F93bxidAZQl2is8v9Q== 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=Q6+t0NUqYHH+N9Awb7wmAQ3Agmg0K9uESM7TBBKj0Uk=; b=YBgkv2D3adE9QYgrYPkVVeO9rU67oNC1waPNYMddfS0A630FnNweAN+BSvyR3e/DFjko6bUG53Z0h0x6IAqMNZZzbalkZRr/UrIp/l9kcH//a+YqUSOZiRJyJu5JLrDeKJ1Gyv2MEWJjIq1m+9lLXSHxDT2ZKm1ySBKMaJFqtCc= Received: from CH0PR03CA0384.namprd03.prod.outlook.com (2603:10b6:610:119::26) by BY5PR12MB4099.namprd12.prod.outlook.com (2603:10b6:a03:20f::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 21:40:26 +0000 Received: from CH1PEPF0000AD83.namprd04.prod.outlook.com (2603:10b6:610:119:cafe::dd) by CH0PR03CA0384.outlook.office365.com (2603:10b6:610:119::26) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9320.18 via Frontend Transport; Fri, 14 Nov 2025 21:40: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 CH1PEPF0000AD83.mail.protection.outlook.com (10.167.244.85) 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 21:40: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; Fri, 14 Nov 2025 13:40:22 -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 v7 11/11] cxl/atl: Lock decoders that need address translation Date: Fri, 14 Nov 2025 22:39:24 +0100 Message-ID: <20251114213931.30754-12-rrichter@amd.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251114213931.30754-1-rrichter@amd.com> References: <20251114213931.30754-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD83:EE_|BY5PR12MB4099:EE_ X-MS-Office365-Filtering-Correlation-Id: 0dceef04-95e5-4aad-3df0-08de23c66c2e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|82310400026|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?sUIL593AjT8AusIt0bfXPIgfAftq8NJs+NYVhiUtPoQ01e8Acc26mYtUUG2l?= =?us-ascii?Q?fLiAyNeRdEQihFIUgexfSMldxcLXpijxtC+YwMSq0C3zix196gsUxWlRezMv?= =?us-ascii?Q?g2WPHCXVMRjWgkGWkUEHAHfrWau7QAGNaV0a7G7itWMJt3vIxVvknu5MCXDI?= =?us-ascii?Q?l1ZtYWWNrU+u/HhWvF0UDPy1sjXVX3gdH3BgFcjJWyO7Lm0njJNg4oJh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mmHVYLvSL/T5HV12jfv6hFwhAkYAC+aM?= =?us-ascii?Q?CPYJY9hoYrlOAZun1rTeC31txRspL1t3oP7ywLGU3rLwx+l628/0vSJBe5rL?= =?us-ascii?Q?kwrpaXnbReh/Rkw8wwla7DX3HdVDHUaAPyJGBZGNSw+i6Ie99sSCG6P5nfk8?= =?us-ascii?Q?o3+r3Rijxmh0XYUlb8im7l89bZ5jdCaAkMpfhtZ6Mj92R0VlLJEPBYQL2ISv?= =?us-ascii?Q?hwP1M3yq+T/r5jMM/88o9kC13PCwaiTrseHlbW0fRKe8+BymXEC26MqC7t83?= =?us-ascii?Q?YlBKMZnNJPv3oeMlOE8Wfswia7UzjiXXxWehxp2H/hlT636DmYeZmckxHdjY?= =?us-ascii?Q?0LcWszCBa9bFJFh3JEVOKzmPEzGeBsqocVyJ18jX/IwBrqNHxQe4Gkp5kYTv?= =?us-ascii?Q?K/UHq7ACbOikAX4xsXohmI7MaU9W+Q0xG5BFJCg42pOKFLMuFqwrKtmE3u1v?= =?us-ascii?Q?cMFoDgYgjbV2n5U/I+w=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)(82310400026)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2025 21:40:25.8102 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0dceef04-95e5-4aad-3df0-08de23c66c2e 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: CH1PEPF0000AD83.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4099 Content-Type: text/plain; charset="utf-8" The current kernel implementation does not support endpoint setup with Normalized Addressing. It only translates an endpoint's DPA to the SPA range of the host bridge. Therefore, the endpoint address range cannot be determined, making a non-auto setup impossible. If a decoder requires address translation, reprogramming should be disabled and the decoder locked. The BIOS, however, provides all the necessary address translation data, which the kernel can use to reconfigure endpoint decoders with normalized addresses. Locking the decoders in the BIOS would prevent a capable kernel (or other operating systems) from shutting down auto-generated regions and managing resources dynamically. Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron Tested-by: Gregory Price Signed-off-by: Robert Richter Reviewed-by: Dave Jiang > --- --- drivers/cxl/core/atl.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/cxl/core/atl.c b/drivers/cxl/core/atl.c index 3b02999d3c59..0590890bd093 100644 --- a/drivers/cxl/core/atl.c +++ b/drivers/cxl/core/atl.c @@ -161,6 +161,24 @@ static int cxl_prm_translate_hpa_range(struct cxl_root= *cxl_root, void *data) return -ENXIO; } =20 + /* + * The current kernel implementation does not support endpoint + * setup with Normalized Addressing. It only translates an + * endpoint's DPA to the SPA range of the host bridge. + * Therefore, the endpoint address range cannot be determined, + * making a non-auto setup impossible. If a decoder requires + * address translation, reprogramming should be disabled and + * the decoder locked. + * + * The BIOS, however, provides all the necessary address + * translation data, which the kernel can use to reconfigure + * endpoint decoders with normalized addresses. Locking the + * decoders in the BIOS would prevent a capable kernel (or + * other operating systems) from shutting down auto-generated + * regions and managing resources dynamically. + */ + cxld->flags |=3D CXL_DECODER_F_LOCK; + ctx->hpa_range =3D hpa_range; ctx->interleave_ways =3D ways; ctx->interleave_granularity =3D gran; --=20 2.47.3