From nobody Thu Dec 18 10:37:44 2025 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2086.outbound.protection.outlook.com [40.107.243.86]) (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 6E7A9235041; Fri, 9 May 2025 15:07:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.86 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746803264; cv=fail; b=gT/zbZt3wSC49AcsavEdiCNQx+CciF682RLppBWoMFyMrng244UeuFtb/fY2JdNmfFPCBIEgm1SH1alk+3JRo5DpwwWgxHkq3F9Vfg8gnT2EaENpIxMx2unexnbLFjyaqdS/eyl+/NBejp6djkKlnzg91RTSr+/A/dTjKdNtgzY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746803264; c=relaxed/simple; bh=zxL9PhfYkd49rnh4aDzJTPzut6C7EoWZclKDeK15NwM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WEiTCMdQCt6MmUjklTgDhvhh6gtXvTx2GTogX8uR6T8wC/4B/EpiUzrO8+TCORpsHaUsNrPLaspLpsmk6Ytp0B0V3WECIbpTMyPnjNZ/Lg9+j7vBR41F8hDrLkoWDeFOMt5dHORoqtmKkcPJQ10hQ9OgC8muKDMmDobECFtv/us= 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=xbuqiI8Y; arc=fail smtp.client-ip=40.107.243.86 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="xbuqiI8Y" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Mf66HY9NI5LcfIwy43KQkliFcq0esY1gnx/v1hU6AV0TrAQ+9qs5FErhcte5fBsg9NR/oGb5hQ7bqU6foM56wJDqYE6qpGy3om6Ob2Zr/BeN2x1+/EHKXRF0BSGAOA06pKgeugWC0fVll6yRwCo+/S25VHYDZDFQiFuxo9lkLzFskjQ2Qk6TH7G9i96orFysbIUoktUZduZEpuiZnrdFsOsarjIwzifKsfkIq/s/fL+EWS4wsF2WviSWlmm4py2KdMb5OOtFYTX9H7FYNPtRmmS6+zPfYwODEdQY5YV5j/bBRvye2JEiQanHgr7++LN36n54kL/SjQPwaUoFldLZTQ== 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=U+SyfjaiUQIBFXtual+BSjo53IE6yLKZbsRbvsuqp20=; b=gK0C6hfU5NvgslvHVg+pH7rXYf4QawYe9gtNPEhtjvWpLYqxfOb7HyX6O3YR8m9pZKT4kwE0w5WMioJxdQyuIm1xsAGIQkOLyjYarNQ5YoyVl8u1i9n+/I9KbrkpY4Sgsat61+qrCAkZlo34sEdeZHkVmbQi9nCBCG1T+hyR4vI+HvWApIIcn5ZyyA7rIetiTVNbLuWTnbw9GH1g9xt9kSOlxUVpPjd6oFRLMOMujaEI8syNCjnWXkkNSgeL8Va5jcE7N7ePCXnro8fwLKi2qewP7xZwNxztogdJOGhc0Qvoi02+yfGVLvNqXFc6YbXF/+9YovGtYhapAuv7k790Xw== 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=U+SyfjaiUQIBFXtual+BSjo53IE6yLKZbsRbvsuqp20=; b=xbuqiI8Y3c9ylPDWA6m2PNLcfyYZscs5jdrwY8VGlYapZA8e+LecnlpX/vP9Lhu/OvWXWE6vZsarUlqOvMxY+MoJFiFq5BhxhE8I03cTAepzHTLwfWhfqR/ewqmXQoIEMs6p3LFkhFDVVHZT1tYhoQdtjnRLW7TXaQ6DSKnL00s= Received: from BN0PR08CA0023.namprd08.prod.outlook.com (2603:10b6:408:142::17) by PH7PR12MB8780.namprd12.prod.outlook.com (2603:10b6:510:26b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8699.22; Fri, 9 May 2025 15:07:39 +0000 Received: from BL6PEPF0001AB4E.namprd04.prod.outlook.com (2603:10b6:408:142:cafe::dc) by BN0PR08CA0023.outlook.office365.com (2603:10b6:408:142::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8699.33 via Frontend Transport; Fri, 9 May 2025 15:07: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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB4E.mail.protection.outlook.com (10.167.242.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Fri, 9 May 2025 15:07:39 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 9 May 2025 10:07:35 -0500 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 , Robert Richter Subject: [PATCH v6 01/14] cxl: Remove else after return Date: Fri, 9 May 2025 17:06:46 +0200 Message-ID: <20250509150700.2817697-2-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250509150700.2817697-1-rrichter@amd.com> References: <20250509150700.2817697-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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB4E:EE_|PH7PR12MB8780:EE_ X-MS-Office365-Filtering-Correlation-Id: 4fb2e8a5-697e-4d60-f3c9-08dd8f0b3d79 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|82310400026|36860700013|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?7dazQU3wCyDjg8OFnYasIB8FAum4rAZo2Ol3Eb8UHSnkBFNR6Zx1JmdWCTeQ?= =?us-ascii?Q?72vF+ThXPQ8KK2VneHDA45i8+RzkTDqziPFMQUNMmCJ1fY2llhDH7qaKYvOe?= =?us-ascii?Q?IixosC+AjshNPcRwWYe0uT360KcIq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?Q?HmFNSEJtNlcpd6wLwmcKukrZNB5nxPfjjFypHa54h+SxsQSlaTNOeeusm0YT?= =?us-ascii?Q?DjTLb+wlz1UVHYoavulzJFQW2MUdX0Tic/xmFVjEL2NOMcHn6ovcKwi6xAcj?= =?us-ascii?Q?rpDiUFUoFPpFdPave8XEXdSECULkLLSw2iYItN3PZI4b6Co+wjWTkmZkUW5N?= =?us-ascii?Q?ZW6pLxIHNn0O+avOQbs6ySA8qOTeBfZJs9/NBWzVyk9tleI8lOV2wIMkZOBy?= =?us-ascii?Q?aUg5Z3zr7PtJuKEyvDJkOuW6dsoHGUhorjL9Gc1VVt0whr6SC/cAwMYOX0HQ?= =?us-ascii?Q?bRziVrm6Jwny1A5Zrb52QrEoK1fZH7ww0bw+7zetSgvifp+e/sM60+WYXCTE?= =?us-ascii?Q?QZ8WTEwOpScLSjduHiKUgMRSnFDHwogjVScaY/uC/CxxssKH6bLtYDzIcVwr?= =?us-ascii?Q?FKHvTAkBVEUON6dCqJsK0qkEIIwF/+t3eSEe3qWfeHJKwh+q2OC367qhOObP?= =?us-ascii?Q?cdH3HFFy8rYIHkuNb/f9YONCUUd2PwVZwKQL?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(82310400026)(36860700013)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2025 15:07:39.4856 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4fb2e8a5-697e-4d60-f3c9-08dd8f0b3d79 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB4E.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB8780 Content-Type: text/plain; charset="utf-8" Remove unnecessary 'else' after return. Improves readability of code. It is easier to place comments. Check and fix all occurrences under drivers/cxl/. Signed-off-by: Robert Richter Reviewed-by: Gregory Price Reviewed-by: Dave Jiang Reviewed-by: Jonathan Cameron Reviewed-by: Davidlohr Bueso Reviewed-by: Alison Schofield Reviewed-by: Fabio M. De Francesco Tested-by: Gregory Price Acked-by: Dan Williams --- drivers/cxl/core/cdat.c | 2 +- drivers/cxl/core/memdev.c | 4 ++-- drivers/cxl/core/pci.c | 3 ++- drivers/cxl/core/region.c | 11 ++++++----- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/cxl/core/cdat.c b/drivers/cxl/core/cdat.c index edb4f41eeacc..0ccef2f2a26a 100644 --- a/drivers/cxl/core/cdat.c +++ b/drivers/cxl/core/cdat.c @@ -28,7 +28,7 @@ static u32 cdat_normalize(u16 entry, u64 base, u8 type) */ if (entry =3D=3D 0xffff || !entry) return 0; - else if (base > (UINT_MAX / (entry))) + if (base > (UINT_MAX / (entry))) return 0; =20 /* diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c index a16a5886d40a..ca9e38b222c8 100644 --- a/drivers/cxl/core/memdev.c +++ b/drivers/cxl/core/memdev.c @@ -153,8 +153,8 @@ static ssize_t security_state_show(struct device *dev, return sysfs_emit(buf, "frozen\n"); if (state & CXL_PMEM_SEC_STATE_LOCKED) return sysfs_emit(buf, "locked\n"); - else - return sysfs_emit(buf, "unlocked\n"); + + return sysfs_emit(buf, "unlocked\n"); } static struct device_attribute dev_attr_security_state =3D __ATTR(state, 0444, security_state_show, NULL); diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index 3b80e9a76ba8..71bfa3bbe436 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -415,7 +415,8 @@ int cxl_hdm_decode_init(struct cxl_dev_state *cxlds, st= ruct cxl_hdm *cxlhdm, */ if (global_ctrl & CXL_HDM_DECODER_ENABLE || (!hdm && info->mem_enabled)) return devm_cxl_enable_mem(&port->dev, cxlds); - else if (!hdm) + + if (!hdm) return -ENODEV; =20 root =3D to_cxl_port(port->dev.parent); diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 80caaf14d08a..25d2419179e0 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -231,11 +231,10 @@ static int cxl_region_invalidate_memregion(struct cxl= _region *cxlr) &cxlr->dev, "Bypassing cpu_cache_invalidate_memregion() for testing!\n"); return 0; - } else { - dev_WARN(&cxlr->dev, - "Failed to synchronize CPU cache state\n"); - return -ENXIO; } + dev_WARN(&cxlr->dev, + "Failed to synchronize CPU cache state\n"); + return -ENXIO; } =20 cpu_cache_invalidate_memregion(IORES_DESC_CXL); @@ -1940,7 +1939,9 @@ static int cxl_region_attach(struct cxl_region *cxlr, if (p->state > CXL_CONFIG_INTERLEAVE_ACTIVE) { dev_dbg(&cxlr->dev, "region already active\n"); return -EBUSY; - } else if (p->state < CXL_CONFIG_INTERLEAVE_ACTIVE) { + } + + if (p->state < CXL_CONFIG_INTERLEAVE_ACTIVE) { dev_dbg(&cxlr->dev, "interleave config missing\n"); return -ENXIO; } --=20 2.39.5 From nobody Thu Dec 18 10:37:44 2025 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2089.outbound.protection.outlook.com [40.107.220.89]) (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 BCD8C235041; Fri, 9 May 2025 15:07:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.89 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746803270; cv=fail; b=WjO/L1fxf5tPeiuEN+tRpB44f5WJiw2Z00dENijs5OCEhNtzwsKWZ1RaWv20eKb8iKSjplaVckht5NqD9p6FwL9a5A0kB+h95mDcn5EhWKPYzrO2iJq2TZ2RBVb8nx1hzyEVUqDUlnRZjS6fcJNTxrXL2XUQ8Nf4pMiF9MPpoug= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746803270; c=relaxed/simple; bh=MK60iwf8j81vlAvH+uU6orMh70e22BGn5Z7jeTBN+SM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NPBrs0+/BCMidf0DpUvqwRmthcY6qflYqIi4tuU2lBgzMYPE9n5bkLvX1KfIQ59yuGsZSbGzLrdi6ubKPgdrMgHYBJMQxnYjkEvBXA/yTgP80nSWqDYbwG7CS7QS61Wlv8wdDjus40tTHaMz+AhDvMyBoqcX8SQgUUNKzqtJz+c= 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=nRCblHJx; arc=fail smtp.client-ip=40.107.220.89 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="nRCblHJx" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SYztdzzlFd4CZHIbQG41F6wlsy3DLDVgDGQqTg/jfX2KypWgTBVYabdcfv8+EJG3ktWgTvCkOGhCg5uPTREj4xSOeBBjM9d1bL4RTDXXIfbNTpImZBvsmG693lx4Wm8UA+bjbTGGW6AcFxdnMSSJudZE8heKTUZ1yMkR13hj/be0RhkW6XJ5XKUb0SU3DuU5+nLqfB/ez0px05LNJ+IMeYcloXeg2IDXqnHIJGfgo534+gE6t6uVlKFvwfyQvnGhvD2BAfel2TLzGGspsU6bHftt6srfK9Q7bQ0MrHAunA489xKmWuiNm3FhGmYsYm0PnJ7dNG62jqmq/DYoVBDsOQ== 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=5PZiJ+rO9gNZWh/HkLnV1MDSN26KwMrxfBxEKryNXck=; b=sID7RkvTiD2vz19PgJjh89QP8WX5rl0fst2GBhak5xLaibGeeaA1GXnmVGeryTokSH2811DD1RpfyIwUWYVkzPFpcEvugg1inZQ6CTy5UOt8jmQmLCOtsSlpaHW23vhWkpj//dG50tLGcpnxHrRP6jA8n2STwMQ1dMvtz1EOcZ2+DmnGnVIqFjsnvMQIHNecvj4zL+cApO5Q7eyxZsok+g8DannIYt+dSy5a4NzzwwEtl52ey/NvjvNo6uwciyp11Ft3dECuAmp1QeeI5qv6HoncZkWi5DaaVm8aDN9furaaACYFlG0bhI67CuoNcZ+VvB9MdpwApX/CKKT3sP7R6A== 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=5PZiJ+rO9gNZWh/HkLnV1MDSN26KwMrxfBxEKryNXck=; b=nRCblHJxSnI3qpPVu5WW8xbuZdAoaM/Jp8ilmX2ZvnKvLVHuNEwpTOr6tFWRGqYA1BU7+oYQ/ljAPkB7vpA+P/AyQ7lL5BmcjgRwu1oYhxGyqYeZtvAnuA0xqWQ2IPo9OI9/Uz8NzVNzwcc00VBHR1nzPLSU/zvjrW+B7fpJXMc= Received: from BL1P223CA0030.NAMP223.PROD.OUTLOOK.COM (2603:10b6:208:2c4::35) by SA5PPF8DEAB7A29.namprd12.prod.outlook.com (2603:10b6:80f:fc04::8d4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8678.35; Fri, 9 May 2025 15:07:43 +0000 Received: from BL6PEPF0001AB4C.namprd04.prod.outlook.com (2603:10b6:208:2c4:cafe::44) by BL1P223CA0030.outlook.office365.com (2603:10b6:208:2c4::35) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8699.33 via Frontend Transport; Fri, 9 May 2025 15:07:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB4C.mail.protection.outlook.com (10.167.242.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Fri, 9 May 2025 15:07:43 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 9 May 2025 10:07:40 -0500 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 , Robert Richter Subject: [PATCH v6 02/14] cxl/pci: Moving code in cxl_hdm_decode_init() Date: Fri, 9 May 2025 17:06:47 +0200 Message-ID: <20250509150700.2817697-3-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250509150700.2817697-1-rrichter@amd.com> References: <20250509150700.2817697-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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB4C:EE_|SA5PPF8DEAB7A29:EE_ X-MS-Office365-Filtering-Correlation-Id: e9e2e844-c297-4a5b-5305-08dd8f0b3fc4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|82310400026|7416014|376014|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?DHrg6UY4hEmUSwW4MMwT09e8EU8gaMmjFKqAYBsNJYmGnMr/aK6MjulhF0fZ?= =?us-ascii?Q?2c6o5u6I426eOIvXP/+093tJ3jx/2r9Ub5FHGuDEg9X0TLg0fTwH6HcC08B+?= =?us-ascii?Q?C6BJfvJVlq0RdH+i2VNMiAdjoKxPeKvLyHx9UcrFPlqgV4er7JTvGlMkl4Z5?= =?us-ascii?Q?QMrCVtT5Mzx/ZKwvv4dZ3nvO1tSIQ9YQ/qqZo5wfx9u7mKfb85hL1Y35Xgg/?= =?us-ascii?Q?v6KSQ7JTC9mnZYU4ulZDSRMaG2P8Sjv+kyavVvj/N95Efkry2r31eau6w7MV?= =?us-ascii?Q?GaEAku/X+OJgxzAO88WeVLEK8bfgiobeAFHstPiTh6vMy3PK77KFe0UoEOLt?= =?us-ascii?Q?P15lsqXiCq6LSJ4Uc9eb4N4htFH2BHnLnfUUTwMvMbZxoOOYX1xLsZ3fCO1B?= =?us-ascii?Q?zpxVqAS/novxKUpVI80iU0PU344otu5Y+1eqmdcjjiZyDYC0omMGYFNRD4z3?= =?us-ascii?Q?Di3JepAit5L8jnzit8Ggy9Sf50oDbh+rvCAhJcXBoGVXhtKvumCradzgskac?= =?us-ascii?Q?eMIddEc0jFq+nmKk+Fuh0U70UP8u9wHuRhqpl7W3ZhG4UvyjEoVQ5rjrGZ+y?= =?us-ascii?Q?hlOr3s0tsphDH1sznFBiaHh9EU85ZsCNPXdZbJAU1g+r1gYx50pD2gZ19Elm?= =?us-ascii?Q?5jfWKgmwmxKjru4+XYBcz7PUZCQPWT78Q/5OP7WQQhOVF/qeje1I/jmg70Zj?= =?us-ascii?Q?kO4+G8BqSEs4RkUmfaLmK/dMGxk9TbU8VMINClbAihuxCs0q3cDvyhEk87RC?= =?us-ascii?Q?IS90m698zeyi11jB318TAXlei2tCjftHx6yy8MymE0ZKP43MB3M7Exmhxmvc?= =?us-ascii?Q?l30LS8ROx8n65zHVXAtr52n9MkAlUoqZTiMM9tOMU0/YgBEVG/4heAaV5dI8?= =?us-ascii?Q?cM5jnzP/mllGSS88B380POCLt++mF8eWOQ5ab7ADduk/LYMYVp3nmqoe+l4a?= =?us-ascii?Q?ez8meUW301t6igxnvM46euR4F3a4DJILEahSksLD3PSmr7Bn7AtyPZQ+c1Jp?= =?us-ascii?Q?jEG+94G/472H9mVrxFd10NES2XrEoMw5/CgAcmB2EVhGDz6n++mzhyV5oKcw?= =?us-ascii?Q?81tFhUQSy9ytKITSB4hiF7NnZsmmjLSXspQWoqYMStLxgsTCURPk7HQJQpQm?= =?us-ascii?Q?dlh6DscFAICsQO/gyqS+SLJX2RyFKZxOTKU0zozzhcjop+eRa7HZl93h7xTQ?= =?us-ascii?Q?OMpMFSZr1OUGNmpdwICeYTSac5QzcwoZLBD308/Hm/iIowVdopZl2N9UG0tX?= =?us-ascii?Q?8oBK7JKHNhHAF/BZ5IogWgaoQ1N+n4ej2126aNFDVwSRNfEdIe6ZHxId0bDV?= =?us-ascii?Q?Hj7QVbxgswml9Uk9E+E4AC6llb9w92lWoGKDkNycVacBthRxHgIbePxgTYph?= =?us-ascii?Q?ZpO4m3pMZoVyd/1VJo8UrErlCs7El/YQM1q3BUXhI8HhV/cMzAj4Tb+euAJU?= =?us-ascii?Q?PFe9BJoudujKyHy78y0lu6xock3fKs2A3zC4ABsyL82clBmSc0/WrPk8t1PW?= =?us-ascii?Q?2UTkz8GCWeJ7S6iT6oElmepI5Rkb9t+9e0rw?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(82310400026)(7416014)(376014)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2025 15:07:43.3291 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e9e2e844-c297-4a5b-5305-08dd8f0b3fc4 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB4C.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA5PPF8DEAB7A29 Content-Type: text/plain; charset="utf-8" Commit 3f9e07531778 ("cxl/pci: simplify the check of mem_enabled in cxl_hdm_decode_init()") changed the code flow in this function. The root port is determined before a check to leave the function. Since the root port is not used by the check it can be moved to run the check first. This improves code readability and avoids unnesessary code execution. Signed-off-by: Robert Richter Reviewed-by: Gregory Price Reviewed-by: Davidlohr Bueso Reviewed-by: Alison Schofield Reviewed-by: Fabio M. De Francesco Reviewed-by: Dave Jiang Reviewed-by: Jonathan Cameron Tested-by: Gregory Price Acked-by: Dan Williams --- drivers/cxl/core/pci.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index 71bfa3bbe436..159674c1c71f 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -419,14 +419,6 @@ int cxl_hdm_decode_init(struct cxl_dev_state *cxlds, s= truct cxl_hdm *cxlhdm, if (!hdm) return -ENODEV; =20 - root =3D to_cxl_port(port->dev.parent); - while (!is_cxl_root(root) && is_cxl_port(root->dev.parent)) - root =3D to_cxl_port(root->dev.parent); - if (!is_cxl_root(root)) { - dev_err(dev, "Failed to acquire root port for HDM enable\n"); - return -ENODEV; - } - if (!info->mem_enabled) { rc =3D devm_cxl_enable_hdm(&port->dev, cxlhdm); if (rc) @@ -435,6 +427,14 @@ int cxl_hdm_decode_init(struct cxl_dev_state *cxlds, s= truct cxl_hdm *cxlhdm, return devm_cxl_enable_mem(&port->dev, cxlds); } =20 + root =3D to_cxl_port(port->dev.parent); + while (!is_cxl_root(root) && is_cxl_port(root->dev.parent)) + root =3D to_cxl_port(root->dev.parent); + if (!is_cxl_root(root)) { + dev_err(dev, "Failed to acquire root port for HDM enable\n"); + return -ENODEV; + } + for (i =3D 0, allowed =3D 0; i < info->ranges; i++) { struct device *cxld_dev; =20 --=20 2.39.5 From nobody Thu Dec 18 10:37:44 2025 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2066.outbound.protection.outlook.com [40.107.244.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 57850235045; Fri, 9 May 2025 15:07:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746803273; cv=fail; b=ToOvUJOJSEwr5EsaTb4PntJv+GwCmrcoqnyW6S0Pi66OS20j+Wvm7Ez+FiezvjAX55MV9Oc3oPN/WanD+qNtVqhBGNTGMRq423DKbFl2pduCkwai0zbaSjBLimm6MOnEdjjEBwrW8sZp+q6hEOyN77PYkCGPcHaWHJR6Fsh/xXU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746803273; c=relaxed/simple; bh=iHKB39RozHFi/4Func1QyUEN7cQ8diRjz4oBAbrTJZs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TICQQZLWY0UAqiMAWYKm7ysJZckTGcqIwskC4O/PX3d5sjjDL0V08si8VaNx9M9bgxSgjTVS8oX+cP6nfPHFKJftT0CCzh9vvcyjjfnU8plqFlrAH3ukR19E0rzwAhekgK0tmjlPO+Q3wjB1sqYjEO+yvEzhXu9e8va4ynbAS/s= 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=j7VXMX9L; arc=fail smtp.client-ip=40.107.244.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="j7VXMX9L" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HvrmZkGwwutSg8cHa+ry2nQHQv7fgABnkYvMAlJU7Sh1ogK204WQtASWaVRuper4jWIiibrpbxX7hV975tugEDemQz5/wV27BQ96DyGvm6uGzAycx6nPKRDMbP2GYM1kTHYXf4iy0Si+X6R9ZC0yp1aZPe3hvnnMF+P0wyj1zoUSJgnJgq5hJB0Bb4zF22h06clqSdjmAu4/raiNoZXILuPiNC9kzJeNjX/O+AooqUrwZBVCafIJglXdX49Z+VZDI/ndd9z1YFJSoxkZfHGNNyMFt3xedOpMyfLGMo1lRpkQpUa1dVzV+kMWVDxo9fkYd1DXaV1L+zOVhNd5UqoAAg== 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=VmlKz4hckGSzi3kwzs0r9t474z4ZZSc5gHasoxqN2hk=; b=ayYx5tvT13GwCf5yGT28BHrr1cCVl/+idsHmkXu3Rcpm+7CtrtsYJcwZp1X1hjQU31nx7rEft8kyoE+S1r+X1Pnn7QuSx7IWLejn1zhFHkZBNT5dptgJzwfKiDiRV/aE1Q/3cYqsc/xk4I/0iT+p+N2D1uKmXINKpt5VlRMmtqFYvr5ou23YEPhieKKOhORHhvaAAywScdiCL7Ac+eKfPBGwnYZsHPB7CyAE9QUCWebR9umkP1V3KUXcj9hO2mun1PPdZGQNXlPX+PJepLpMo0yY8zNWCk0mZtxbLDb8x3n/+0Ri3TiE0wGlStv0g18XTFLc1xOy504YIKCqrq7cIQ== 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=VmlKz4hckGSzi3kwzs0r9t474z4ZZSc5gHasoxqN2hk=; b=j7VXMX9LN9Y9AbkY/KNhaIxsAsKI359qzGYbYlJ/c1g4byOhQRCi5XjdvI0wXtbNH9Bq6kMWpVH/rf+H/r8jxX+wn8I51iHFdX7VMpWhQCsPkK4vitvk/YSSNeV+FTHFWQj/vRuTv12q+JyVsQuFg1ow/BQjoY1tYtflLAF1JXI= Received: from BN9PR03CA0953.namprd03.prod.outlook.com (2603:10b6:408:108::28) by PH8PR12MB8607.namprd12.prod.outlook.com (2603:10b6:510:1cf::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.21; Fri, 9 May 2025 15:07:47 +0000 Received: from BL6PEPF0001AB4D.namprd04.prod.outlook.com (2603:10b6:408:108:cafe::76) by BN9PR03CA0953.outlook.office365.com (2603:10b6:408:108::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8699.30 via Frontend Transport; Fri, 9 May 2025 15:07:47 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB4D.mail.protection.outlook.com (10.167.242.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Fri, 9 May 2025 15:07:47 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 9 May 2025 10:07:44 -0500 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 , Robert Richter Subject: [PATCH v6 03/14] cxl/pci: Add comments to cxl_hdm_decode_init() Date: Fri, 9 May 2025 17:06:48 +0200 Message-ID: <20250509150700.2817697-4-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250509150700.2817697-1-rrichter@amd.com> References: <20250509150700.2817697-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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB4D:EE_|PH8PR12MB8607:EE_ X-MS-Office365-Filtering-Correlation-Id: 7b096d34-13fc-4672-52ce-08dd8f0b420f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|82310400026|36860700013|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?IYCeXnd07HGdVJJcJuLsbMIOoLOoKh2e1Kd891ihJm+n7sPRGab9EeQRvm2L?= =?us-ascii?Q?M40Q4j/GSGZ0/pt9Pfu+RJ1Mi4Fada/jSlqBjo0IDIiz7Rug8N4lx0/VEi4o?= =?us-ascii?Q?ZVt9Ux97YqvXyX9gq7987j9NWJBCLjDZ0ZiLmto5g4w8NC1ZEggXOEreGetM?= =?us-ascii?Q?IdDkLbIGJ5HdcemOC5se7PGAHIBeCGxP/8QGT5Z8G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YmMmWvlRAdGmzEETF76UbT++CKgnXXcNdZJHfne3d3/Fsd/?= =?us-ascii?Q?UeKSLKcr+4ETM9Liz1pKxI2oaJTdQCiDTpNzrvFAbg63cDzvKHIiVDjSdfES?= =?us-ascii?Q?wh8kEohfoTRmsCVDaE4ao5x/VElFP0o+bFbo38o3+bueB7tNYfJNqLCPryrD?= =?us-ascii?Q?P0yXC1kO+fyvOb5OJplpSRrgUfiXhVaTWNnBf2VY59k3e6qxs34lSjNpx9Lg?= =?us-ascii?Q?mN6hlPw2/Kf3kYYEjGzcOnuvTNh1uoEdywAQNPGwQMrsZldQSzL/5WWTBla0?= =?us-ascii?Q?7+kWWRrKzFVSTOc/KCotkysiJeD1QQF5xK8Pj7h9SeChSZvOrW2aBM8D5Mnn?= =?us-ascii?Q?VlWsW14JFvE6INwKbmQYcOhv2mJZnYKljKEcPQELykJ2j9Gj1jTZ/ior85rh?= =?us-ascii?Q?ulZwE4t2CmRx3hnzdKM+HclH2pYWII0UDXEC?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(82310400026)(36860700013)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2025 15:07:47.1738 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7b096d34-13fc-4672-52ce-08dd8f0b420f 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB4D.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB8607 Content-Type: text/plain; charset="utf-8" There are various configuration cases of HDM decoder registers causing different code paths. Add comments to cxl_hdm_decode_init() to better explain them. Signed-off-by: Robert Richter Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron Reviewed-by: Alison Schofield Reviewed-by: Fabio M. De Francesco Reviewed-by: Dave Jiang Tested-by: Gregory Price Acked-by: Dan Williams --- drivers/cxl/core/pci.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index 159674c1c71f..b50551601c2e 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -416,9 +416,19 @@ int cxl_hdm_decode_init(struct cxl_dev_state *cxlds, s= truct cxl_hdm *cxlhdm, if (global_ctrl & CXL_HDM_DECODER_ENABLE || (!hdm && info->mem_enabled)) return devm_cxl_enable_mem(&port->dev, cxlds); =20 + /* + * If the HDM Decoder Capability does not exist and DVSEC was + * not setup, the DVSEC based emulation cannot be used. + */ if (!hdm) return -ENODEV; =20 + /* The HDM Decoder Capability exists but is globally disabled. */ + + /* + * If the DVSEC CXL Range registers are not enabled, just + * enable and use the HDM Decoder Capability registers. + */ if (!info->mem_enabled) { rc =3D devm_cxl_enable_hdm(&port->dev, cxlhdm); if (rc) @@ -427,6 +437,18 @@ int cxl_hdm_decode_init(struct cxl_dev_state *cxlds, s= truct cxl_hdm *cxlhdm, return devm_cxl_enable_mem(&port->dev, cxlds); } =20 + /* + * Per CXL 2.0 Section 8.1.3.8.3 and 8.1.3.8.4 DVSEC CXL Range 1 Base + * [High,Low] when HDM operation is enabled the range register values + * are ignored by the device, but the spec also recommends matching the + * DVSEC Range 1,2 to HDM Decoder Range 0,1. So, non-zero info->ranges + * are expected even though Linux does not require or maintain that + * match. Check if at least one DVSEC range is enabled and allowed by + * the platform. That is, the DVSEC range must be covered by a locked + * platform window (CFMWS). Fail otherwise as the endpoint's decoders + * cannot be used. + */ + root =3D to_cxl_port(port->dev.parent); while (!is_cxl_root(root) && is_cxl_port(root->dev.parent)) root =3D to_cxl_port(root->dev.parent); @@ -454,15 +476,6 @@ int cxl_hdm_decode_init(struct cxl_dev_state *cxlds, s= truct cxl_hdm *cxlhdm, return -ENXIO; } =20 - /* - * Per CXL 2.0 Section 8.1.3.8.3 and 8.1.3.8.4 DVSEC CXL Range 1 Base - * [High,Low] when HDM operation is enabled the range register values - * are ignored by the device, but the spec also recommends matching the - * DVSEC Range 1,2 to HDM Decoder Range 0,1. So, non-zero info->ranges - * are expected even though Linux does not require or maintain that - * match. If at least one DVSEC range is enabled and allowed, skip HDM - * Decoder Capability Enable. - */ return 0; } EXPORT_SYMBOL_NS_GPL(cxl_hdm_decode_init, "CXL"); --=20 2.39.5 From nobody Thu Dec 18 10:37:44 2025 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2079.outbound.protection.outlook.com [40.107.92.79]) (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 13A4F2356C9; Fri, 9 May 2025 15:07:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.79 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746803276; cv=fail; b=LZBdQ0UlHNPxosBmMGUt4/UmQl8rKTrx2RJCrZx2UPFZVH8sBrrZAcqYqdkBpEQjLZCiZOrTMtkX3gn/7+p1dS1XPs1ekuDZcAfRvYNgNdl8SzOiUG3g4m3OJvF+3UC//tGBgkQ07nUSRrgqXorL8DvBXY77S5c2WISF0Vm/iCc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746803276; c=relaxed/simple; bh=Uwtk0cqnD+QEAXmj/V0yToLfY+sQ9BOzlrWGFF1lSlU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=F5TG86YMo/98gNaDORdpSwXq5wOIi8aBIx/bDJhJI89Y3BoWhEBxA+qwNJIeGBLtkwDh74ca0CzDgFqKeN75myZvL9ZtUeKjB0RHJ9vzJUx4nMOh9+7Mr7O87Wn97Vf81kY5b+0C03HjPHO3tIgsFe8eos03xr7L4Ft6bX79frI= 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=WWbcK4/2; arc=fail smtp.client-ip=40.107.92.79 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="WWbcK4/2" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qwIvv3xMVe4iRf56KggJCAWZV+bRjdSgfqdjCv0pM0kyebiejKrwY4ThDAa3+15Jbc7gy4RMvrDx0QDwF0DV7ilpcqHJFXnwg/nUGDeh3EsU+LtkhcKK8xagiMVGkLuEXtNLBR0OwjdodSPmbvkwh6Ngn2cMRvNvfHerf4bF6giJ5SieRgd7/59x5zp1s0QntNcfbnmCTZYiAkgeDYBvcPMmWUDpHgR4vRScpWnid3jQR6ae5p34ftaSwERUfenTbEvgSYItzpfrSH2IUmjmSdw8uCmPjolBK+5AjFuMIy07juFTXXAALNJ7aP65i1xs82CNlXuFQ7m8R3/A9Z9BMA== 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=Rp3HauOx3PtLWFHiD5R4IEeXO/Vc/vLevXC3Y+vqwCo=; b=nmqEVAMF6gEMvmE7g2KlMcCeELa5yhxfwXeLOmTQwtLrqkoK2XNRTBxW31eqBH79lw4yXn35gU4Q6UFxlMmmFenMus34Bg67PL4Lt3NUf6lU3WBV4H9iVCJraXIqwfMsHn/mF/9GYgB5+DmPEFGXaLxIbpS9Ef+7/ZCbsfa07RrPbfZTX9e2FTQ7XCDbKhVVzP6XpZifVLlE2Vo2m7/pzYSpkzzN3iCqWmGkNCxAKhE+o03RkCwGm1lIdJQmqNYR1op/lrZjNVz2kFWwBVJPIM1pG8Bb4gPPZeK9N3t39uTPXFw76SHZQqHsn22yhAK3v/Q2TUpfNz3/gLwodMfBeg== 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=Rp3HauOx3PtLWFHiD5R4IEeXO/Vc/vLevXC3Y+vqwCo=; b=WWbcK4/243OUUfMHp1S69/S3SaYID12CMzbgr5V1vNUX61Ke+6cWcctvYXFpYEKL/8DYTBh5VBTKmZuCz9wcZJB2a01tfGm/RIvXziIMtP7Kz73k5Ti5NiDDokafLSsbRI4gERmiMTUzG9z8MC7cifHDQzOvU5jW9rQ6EFlxVsQ= Received: from BN0PR04CA0199.namprd04.prod.outlook.com (2603:10b6:408:e9::24) by SN7PR12MB6716.namprd12.prod.outlook.com (2603:10b6:806:270::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.23; Fri, 9 May 2025 15:07:51 +0000 Received: from BL6PEPF0001AB4A.namprd04.prod.outlook.com (2603:10b6:408:e9:cafe::76) by BN0PR04CA0199.outlook.office365.com (2603:10b6:408:e9::24) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8699.30 via Frontend Transport; Fri, 9 May 2025 15:07:51 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB4A.mail.protection.outlook.com (10.167.242.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Fri, 9 May 2025 15:07:51 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 9 May 2025 10:07:48 -0500 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 , Robert Richter Subject: [PATCH v6 04/14] cxl: Introduce parent_port_of() helper Date: Fri, 9 May 2025 17:06:49 +0200 Message-ID: <20250509150700.2817697-5-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250509150700.2817697-1-rrichter@amd.com> References: <20250509150700.2817697-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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB4A:EE_|SN7PR12MB6716:EE_ X-MS-Office365-Filtering-Correlation-Id: 0a022093-34f8-485d-f523-08dd8f0b449b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|7416014|1800799024|36860700013|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?e8+h+J4QDQfPMEHOYiV0HdMgWNefPLk0NCxaRnd0cO6Oxhp73w/OseYFcrC7?= =?us-ascii?Q?Tzph+Qt9gDgYbhxse7s6lAVLEuuTFKC4X0Udh99JSpxQDOfjM/G/3w32+73I?= =?us-ascii?Q?heaOiZ7XmhXi477+Uit3AlpYqEAVHYlq+FjCsbWfwvKXV5nEkyvjdkaip36L?= =?us-ascii?Q?1TUonwe7gomTsNx4XqF3SeVyejjDUfFWwokme63GnQ8zEsgjqLRt7nb4iWMs?= =?us-ascii?Q?Pk6kfkclz92K3RC+y+PBi3jG92kBgMV7LNQG5sa/4U/LxlZlFN4S5rLTIh74?= =?us-ascii?Q?fk/2ERm5qJW3exJWb54vnADGdLI2wsrWowKlclpNDT/TGho5IgwQroXANAL4?= =?us-ascii?Q?e3+nIbZzxWIZuQfUGP1mAoSHXmUUgoRTtqeekbjywnUOYWy7s6pOzfJ3vJb0?= =?us-ascii?Q?EFkmWeOwkvoY4UHojgoWlH+hhAJ5JgqTuCr8TygjJnDo6UxrLEss4huAE4DM?= =?us-ascii?Q?GgIyTMT710JKgx3bjL5zHTTj1GQPsXiKSzclBV6eU3JnWekFp37d3tWCpkhe?= =?us-ascii?Q?gBTKBigaj1P/jdZt92q+RMZptmfxwQMGYD++exly9S6Od1eSmLxwshaL6m1H?= =?us-ascii?Q?JCTclSqzIJ4U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QYk6?= =?us-ascii?Q?aBulpxazGxGmAfFhUtenLFyY9gi96nyHYLYF?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(82310400026)(7416014)(1800799024)(36860700013)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2025 15:07:51.4536 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0a022093-34f8-485d-f523-08dd8f0b449b 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB4A.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6716 Content-Type: text/plain; charset="utf-8" Often a parent port must be determined. Introduce the parent_port_of() helper function to avoid open coding of determination of a parent port. Signed-off-by: Robert Richter Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang Reviewed-by: Alison Schofield Reviewed-by: Fabio M. De Francesco Tested-by: Gregory Price Acked-by: Dan Williams --- drivers/cxl/core/port.c | 14 ++++++++------ drivers/cxl/core/region.c | 11 ++--------- drivers/cxl/cxl.h | 1 + 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 726bd4a7de27..83cfebe8d3e9 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -602,17 +602,19 @@ struct cxl_port *to_cxl_port(const struct device *dev) } EXPORT_SYMBOL_NS_GPL(to_cxl_port, "CXL"); =20 +struct cxl_port *parent_port_of(struct cxl_port *port) +{ + if (!port || !port->parent_dport) + return NULL; + return port->parent_dport->port; +} + static void unregister_port(void *_port) { struct cxl_port *port =3D _port; - struct cxl_port *parent; + struct cxl_port *parent =3D parent_port_of(port); struct device *lock_dev; =20 - if (is_cxl_root(port)) - parent =3D NULL; - else - parent =3D to_cxl_port(port->dev.parent); - /* * CXL root port's and the first level of ports are unregistered * under the platform firmware device lock, all other ports are diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 25d2419179e0..569a56afd527 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -1747,13 +1747,6 @@ static int cmp_interleave_pos(const void *a, const v= oid *b) return cxled_a->pos - cxled_b->pos; } =20 -static struct cxl_port *next_port(struct cxl_port *port) -{ - if (!port->parent_dport) - return NULL; - return port->parent_dport->port; -} - static int match_switch_decoder_by_range(struct device *dev, const void *data) { @@ -1780,7 +1773,7 @@ static int find_pos_and_ways(struct cxl_port *port, s= truct range *range, struct device *dev; int rc =3D -ENXIO; =20 - parent =3D next_port(port); + parent =3D parent_port_of(port); if (!parent) return rc; =20 @@ -1860,7 +1853,7 @@ static int cxl_calc_interleave_pos(struct cxl_endpoin= t_decoder *cxled) */ =20 /* Iterate from endpoint to root_port refining the position */ - for (iter =3D port; iter; iter =3D next_port(iter)) { + for (iter =3D port; iter; iter =3D parent_port_of(iter)) { if (is_cxl_root(iter)) break; =20 diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index a9ab46eb0610..14e20b44f2f4 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -724,6 +724,7 @@ static inline bool is_cxl_root(struct cxl_port *port) int cxl_num_decoders_committed(struct cxl_port *port); bool is_cxl_port(const struct device *dev); struct cxl_port *to_cxl_port(const struct device *dev); +struct cxl_port *parent_port_of(struct cxl_port *port); void cxl_port_commit_reap(struct cxl_decoder *cxld); struct pci_bus; int devm_cxl_register_pci_bus(struct device *host, struct device *uport_de= v, --=20 2.39.5 From nobody Thu Dec 18 10:37:44 2025 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2057.outbound.protection.outlook.com [40.107.244.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26CB02356CD; Fri, 9 May 2025 15:07:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746803280; cv=fail; b=eRjo1D8itixu+gcb1S53lFjgy1Wgkwm5f0VbGMiIgDFmxxaCh/85M4NHO3qY+G45hYbqBriHhlhbGIcgxWMamsZxVVO/1KbrUQFvg0v47fdSPukI7pZjo39/IHFB9A65wIqg++wDt9GuXiJhrD7+Iuxn5O23LOKfFvjmmuZKdPA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746803280; c=relaxed/simple; bh=dpdL0+aTCPytGWzsC8NDShZQHemyi5PLdnH7WD7gUsA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=soTKdvhzutIrqMSfSNaZt5L1bYjKQ6ODDMMUZgvfP2uGBIgFZHKU9cYjz6KhOcsYT11+WOiXX4xoZ9hG/5I/Be//ux/bckcgK3Wk/RXqbIkpSTxFGRo+1mK0EgSL85LtakspCtikc3ZTYWEO63xMQlNSWx3zh7NjvTxxYhF2D+Y= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=0crDd8TN; arc=fail smtp.client-ip=40.107.244.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="0crDd8TN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=p+2Jp70W5hrr0WoCbc8WoqmBotySUWW5r+RJiTDUDkgBQ4ZT/FzGv9MpDKU9Na22S9M7zZG312jcF/4Qc5JreSL3quHShT/hcvg1nlU5QPvVunIeteknO8LATYR25tGFg8Qi3GVRGUXfhgkY5L9V5etli2P7PjymvpmNi7lHpZsItbdxK1chJH3f/p3Bh6SMpyR/+M/hVexrLWbRNQhm3ID5NRltluKSDL5dehTlUjDlsO2tdGxDiniXB6eT+amz/Yne0tB1V/6duOXG9uMopfzP8oatvjd/rN25bcsJGtz5uQ4eubutrOJMZ2jEbinKjWB1Nv50VrWBwLioMeHKAw== 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=wZZ0J8ffQlRyXOlxPhkmTKNBkOf7MWjX0Z9oAOu/Y1s=; b=G7xnMogwpJ7KKoju/pv/TDPDkAJETo4Aw1F59oZ0E5m4XewxXsEsiWHxx/Yuwkwt4TdSO+hGL01ouBDbIAuKkLQKAI8R8HO3C86yvPJCYhA3FYQKHcGaMdtt5r6cd6J4DP21tjUgfey6MjPqfBH6o9xh/fEyc2ivXcljV3fStsPB7/MW0QVZhHC/CCm96dKwA3HeXFQD6DNM1V1WYS5ueeBUskWnMb6qW7BLeUJqKX/TD75LUY7ExfMKlgFk8fGSPrs6T9WxHG4OLtghdK1lxdcr++xHea+vJmNLiyeb8WptAo9GJRzRwj6B/vri4mRntjKKG3ITk4pt67uY0H8p9w== 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=wZZ0J8ffQlRyXOlxPhkmTKNBkOf7MWjX0Z9oAOu/Y1s=; b=0crDd8TNQ14Fro9EL7tVaKZa3IwD3xQrUQFtTvvvTu8wwnWaSAx2PxLg1nDCRGktYQr14AzzxFe5J076UzVE4wHpShwp1VNyBSxL0asi8yIzcwDdvZJ+gfw7wsDu+UdCArBjiemGYNMJSMNHu3h8k0IthQX2xuRTCNCqeYD73js= Received: from MN2PR07CA0008.namprd07.prod.outlook.com (2603:10b6:208:1a0::18) by SA5PPFA403A61D8.namprd12.prod.outlook.com (2603:10b6:80f:fc04::8da) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8678.27; Fri, 9 May 2025 15:07:56 +0000 Received: from BL6PEPF0001AB51.namprd04.prod.outlook.com (2603:10b6:208:1a0:cafe::aa) by MN2PR07CA0008.outlook.office365.com (2603:10b6:208:1a0::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8699.29 via Frontend Transport; Fri, 9 May 2025 15:07:55 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB51.mail.protection.outlook.com (10.167.242.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Fri, 9 May 2025 15:07:55 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 9 May 2025 10:07:52 -0500 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 , Robert Richter Subject: [PATCH v6 05/14] cxl/region: Rename function to cxl_port_pick_region_decoder() Date: Fri, 9 May 2025 17:06:50 +0200 Message-ID: <20250509150700.2817697-6-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250509150700.2817697-1-rrichter@amd.com> References: <20250509150700.2817697-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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB51:EE_|SA5PPFA403A61D8:EE_ X-MS-Office365-Filtering-Correlation-Id: 9db6d953-5d9e-4978-e2bf-08dd8f0b46e3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|82310400026|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ok+ChPVdKYy+EZnRzv+j4zGje8mtF6E8qOUyhnF4Gx5PIA3s+Snt6YYCg3nU?= =?us-ascii?Q?G/Lhw6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?= =?us-ascii?Q?gj7ECDtb4sqcXdwqRg/A03elkcobtU+MFpy4Tf82bCbPTNGrkWr/0/GuCFff?= =?us-ascii?Q?3HLRgEIMWKjtMUh/ypKdhD+wYv1oSbfBdQqJsDmN9mxfmjUy5WRbEO8bgOaw?= =?us-ascii?Q?rNLWjlJv+ngvSkE5W8NoYvN8NR+XCFdOmP4C6lfY1HBOx3mROWPUV7bVXiZz?= =?us-ascii?Q?r/U9InVLouumzbfHrod7DnohELIujHJBm3WbHbzpTQ6tMrPJWzMErB+n91pC?= =?us-ascii?Q?Yz+hW8rL4FMeCtwPdDLFVofsvvc3kpX/ApXs6LoR8NFWgpPEWItyaWI5GH7p?= =?us-ascii?Q?9kYvnV5zip4H1rjgE7naKd1aY5isZbfjXqJe3fG50SZYs2ijRLmziOQp5L4K?= =?us-ascii?Q?teyXReJpZ54G/NX6Ph/0Nv9ztELmdkt8buv4VNGXDnNBZGVmCGDSX9swkVMm?= =?us-ascii?Q?iKDVCpu0UamqSyJ5C2t0GWMzy6w3lfJQhDYo+6zHIGHi12BBrM1KA6H9cQTH?= =?us-ascii?Q?2gVaThNpqA0dNQszRQeSV0icLX4caLo9mp2MjNm15ddtS/eSQ9bxA4FQ+l5E?= =?us-ascii?Q?LOdAs0fdVAWbYlSSQVHSj4QwoM3sVcbN3aiu?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(7416014)(82310400026)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2025 15:07:55.2804 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9db6d953-5d9e-4978-e2bf-08dd8f0b46e3 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB51.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA5PPFA403A61D8 Content-Type: text/plain; charset="utf-8" Current function cxl_region_find_decoder() is used to find a port's decoder during region setup. In the region creation path the function is an allocator to find a free port. In the region assembly path, it is recalling the decoder that platform firmware picked for validation purposes. Rename function to cxl_port_pick_region_decoder() that better describes its use and update the function's description. The result of cxl_port_pick_region_decoder() is recorded in a 'struct cxl_region_ref' in @port for later recall when other endpoints might also be targets of the picked decoder. Signed-off-by: Robert Richter Reviewed-by: Gregory Price Reviewed-by: Dave Jiang Reviewed-by: Fabio M. De Francesco Tested-by: Gregory Price Acked-by: Dan Williams --- drivers/cxl/core/region.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 569a56afd527..ddcf4e54e2cb 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -864,10 +864,23 @@ static int match_auto_decoder(struct device *dev, con= st void *data) return 0; } =20 +/** + * cxl_port_pick_region_decoder() - assign or lookup a decoder for a region + * @port: a port in the ancestry of the endpoint implied by @cxled + * @cxled: endpoint decoder to be, or currently, mapped by @port + * @cxlr: region to establish, or validate, decode @port + * + * In the region creation path cxl_port_pick_region_decoder() is an + * allocator to find a free port. In the region assembly path, it is + * recalling the decoder that platform firmware picked for validation + * purposes. + * + * The result is recorded in a 'struct cxl_region_ref' in @port. + */ static struct cxl_decoder * -cxl_region_find_decoder(struct cxl_port *port, - struct cxl_endpoint_decoder *cxled, - struct cxl_region *cxlr) +cxl_port_pick_region_decoder(struct cxl_port *port, + struct cxl_endpoint_decoder *cxled, + struct cxl_region *cxlr) { struct device *dev; =20 @@ -931,7 +944,7 @@ alloc_region_ref(struct cxl_port *port, struct cxl_regi= on *cxlr, if (test_bit(CXL_REGION_F_AUTO, &cxlr->flags)) { struct cxl_decoder *cxld; =20 - cxld =3D cxl_region_find_decoder(port, cxled, cxlr); + cxld =3D cxl_port_pick_region_decoder(port, cxled, cxlr); if (auto_order_ok(port, iter->region, cxld)) continue; } @@ -1019,7 +1032,7 @@ static int cxl_rr_alloc_decoder(struct cxl_port *port= , struct cxl_region *cxlr, { struct cxl_decoder *cxld; =20 - cxld =3D cxl_region_find_decoder(port, cxled, cxlr); + cxld =3D cxl_port_pick_region_decoder(port, cxled, cxlr); if (!cxld) { dev_dbg(&cxlr->dev, "%s: no decoder available\n", dev_name(&port->dev)); --=20 2.39.5 From nobody Thu Dec 18 10:37:44 2025 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2052.outbound.protection.outlook.com [40.107.244.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 E0AF92367A6; Fri, 9 May 2025 15:08:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746803283; cv=fail; b=TLD5+N4/s7wdX4oQY2mq72ejdTKKL5h8D+Wa9mvuelhfubLmfAABPCS+wk4ph6/r+MMMXpe9acSlUdlkdgKPGD6fW0BD2reZPWzOYh4LRUO++XMq7CDbzcIbznD7UHoeyM7lY9fU91TUQrvHM39pDtjxcKyX2cMXKNzo3lx+04w= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746803283; c=relaxed/simple; bh=Oamf70oASRqmy8o83ono98/8yJR8LM7Ps7+bvV1gsdA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SKUBwh0v0NlGq7W7ln9rEtBWTTijumUKjOB+yxYn/LEvoUsuXRB+i+xrB3qvJsINi8dx6d5ogZnNTHro7kC53zyFctC7tDyfi+88rhnTj70rLOc/3f4pDCWSntZ1SOkDcoshYM7+1X2WivIWcBOG3uiQ66GOsuXouSSf92ep8WU= 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=BfKMDkcd; arc=fail smtp.client-ip=40.107.244.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="BfKMDkcd" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bDTtSNXyaMG5//TpIJ5ziywmCIzewODdasNaYmmHT1ufyj3lbr2o/iFJh/481z9GipKof0Q/9U7TU9r7YCBZsbpzNIYf61+Dfg0zpJL/dDb731IUEpcTW0MYumd9hRhuV5StYhUKfxJKtfcr/iENVZf8fBLYnkQVRtZupa+ZXUby/ONAfWpKRQNaDgKfhNR/oGeXx6uBSwL6cBXTmz1lhH/IRSjEHxG24ef4SltBlDZrUx8fk4pIC4k2NP1MTKHvVjoLU+AXWbqpVLZ2VPkORrY6kL/rBH7XzRnVvjqFuyasyJVmyO7+R+B3H/ocwlU2XaG811RVu4vWWYBAt6hR6g== 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=VyKwseL9ZVVnFD3/stsUOnZ2nm7ScCg6wDGQwiE8BvM=; b=Edq412IF2h6wBansMXM5ja+0FEjlBZiJGusHWcqJBu/EpKH9eS7y+ZWHTFLy/L1XCDueg7GFHNRLiEMCuAMTjNLSMs9clevbhKPcD4NKDfjM3HqMW29DGZNXj7mPEFjg8lPZy6l3tYassNOqe92NVStrpfoLbxiKQEteL2MYN1vKUeQqbMcsBUWLq08gE3ks9s1DDwbcRk8B2ekG7PoeNoyKMFRz4eZtQK9hiBOip8VSndQKtLsJpKb3Ub5SqfSfEvGb9MFmOPO+bNgiXH9bQt4P49KF70tBmFgrOzsc7jNAUoF/gSzLOo9h+Aq8wi7V7YnZzcLWM4fq/8AVUDr1WQ== 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=VyKwseL9ZVVnFD3/stsUOnZ2nm7ScCg6wDGQwiE8BvM=; b=BfKMDkcdwFyTxMxtkbDihCoK6DMzG2KDpROrzuKOF8iFi2qMLGNmvVJVm44bZSREEEa9/lTU0LojWM38cThzNd7q5O00i1bCgBeN6Vro/+TS7TSqxOx6Unh8nBMLqz2oeeGhlcv0UKXu2J8iqD35bIFTUUXc4vsS+++7gTHbryY= Received: from BN0PR04CA0205.namprd04.prod.outlook.com (2603:10b6:408:e9::30) by PH8PR12MB6721.namprd12.prod.outlook.com (2603:10b6:510:1cc::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.21; Fri, 9 May 2025 15:07:59 +0000 Received: from BL6PEPF0001AB4A.namprd04.prod.outlook.com (2603:10b6:408:e9:cafe::bb) by BN0PR04CA0205.outlook.office365.com (2603:10b6:408:e9::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8699.31 via Frontend Transport; Fri, 9 May 2025 15:07:59 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB4A.mail.protection.outlook.com (10.167.242.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Fri, 9 May 2025 15:07:59 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 9 May 2025 10:07:56 -0500 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 , Robert Richter Subject: [PATCH v6 06/14] cxl/region: Avoid duplicate call of cxl_port_pick_region_decoder() Date: Fri, 9 May 2025 17:06:51 +0200 Message-ID: <20250509150700.2817697-7-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250509150700.2817697-1-rrichter@amd.com> References: <20250509150700.2817697-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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB4A:EE_|PH8PR12MB6721:EE_ X-MS-Office365-Filtering-Correlation-Id: 0c66ec92-5855-4f9e-7018-08dd8f0b4933 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?el0VamybHjJM1Exl5M8y8EbE31ijLucN2T0J8xON88gbIUD381EaxCCqGvth?= =?us-ascii?Q?pOZxehJr/O8IsLKl4HZn00LkYJIFcr3YZ+QW9jiKwUFJ44Aed4NAN9+0KTe5?= =?us-ascii?Q?z0l8kbyGQQwFOiu3aUPd5fFTusaczz9m90QYBqAnNwnYv57mH5igZ/864HJz?= =?us-ascii?Q?TYSp8/vmSj2r0CR7WDvcbuF9uKxXXsatQPbXg/XUAj/D5L4bVAEBNKa9ZZTS?= =?us-ascii?Q?2tafozPC2Dv0BTr7+AillHnwC7Rd6/w3Xd476ObDRCrBUncRuzh6l3imzKXX?= =?us-ascii?Q?0xU4SZ9gImnTnyoEUJHkTjTFnGXVUS2+IyzWflOFhFQgu5kKl0IewxtsjuG2?= =?us-ascii?Q?HtqJ5gRf+pa6LWOhxXSVr21VOOVbRK8yH+2S3XZHEMEN7dv3/0vSSkTa1lDo?= =?us-ascii?Q?gee1rD+fCWTsQALyWgy0jgHwXGYhb7dpKUWUYau7l9EaAVceWuSj7BbNhJ5L?= =?us-ascii?Q?MfiVtunvrUDkqVZ+QPWUeA20BycVGVknmMQbi9Cp8neN45L9EeeApLMM8p+t?= =?us-ascii?Q?swkDqI2JSUfW3e88VuEOTe8Vzuqr4lEpCbIzVwSOFx8N6l0fWsbiwNpOCQY5?= =?us-ascii?Q?2DRj1psdMbKKgZp4qHQe7Ij/hT66TEIwu0mjYjM2xCnHM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9+k9ELsOf3hGUs?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(1800799024)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2025 15:07:59.1557 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0c66ec92-5855-4f9e-7018-08dd8f0b4933 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB4A.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6721 Content-Type: text/plain; charset="utf-8" Function cxl_port_pick_region_decoder() is called twice, in alloc_region_ref() and cxl_rr_alloc_decoder(). Both functions are subsequently called from cxl_port_attach_region(). Make the decoder a function argument to both which avoids a duplicate call of cxl_port_pick_region_decoder(). Now, cxl_rr_alloc_decoder() no longer allocates the decoder. Instead, the previously picked decoder is assigned to the region reference. Hence, rename the function to cxl_rr_assign_decoder(). Moving the call out of alloc_region_ref() also moves it out of the xa_for_each() loop in there. Now, cxld is determined no longer only for each auto-generated region, but now once for all regions regardless of auto-generated or not. This is fine as the cxld argument is needed for all regions in cxl_rr_assign_decoder() and an error would be returned otherwise anyway. So it is better to determine the decoder in front of all this and fail early if missing instead of running through all that code with multiple calls of cxl_port_pick_region_decoder(). Signed-off-by: Robert Richter Reviewed-by: Gregory Price Reviewed-by: Dave Jiang Reviewed-by: Jonathan Cameron Reviewed-by: Fabio M. De Francesco Tested-by: Gregory Price Acked-by: Dan Williams --- drivers/cxl/core/region.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index ddcf4e54e2cb..988de8e49df6 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -928,7 +928,8 @@ static bool auto_order_ok(struct cxl_port *port, struct= cxl_region *cxlr_iter, =20 static struct cxl_region_ref * alloc_region_ref(struct cxl_port *port, struct cxl_region *cxlr, - struct cxl_endpoint_decoder *cxled) + struct cxl_endpoint_decoder *cxled, + struct cxl_decoder *cxld) { struct cxl_region_params *p =3D &cxlr->params; struct cxl_region_ref *cxl_rr, *iter; @@ -942,9 +943,6 @@ alloc_region_ref(struct cxl_port *port, struct cxl_regi= on *cxlr, continue; =20 if (test_bit(CXL_REGION_F_AUTO, &cxlr->flags)) { - struct cxl_decoder *cxld; - - cxld =3D cxl_port_pick_region_decoder(port, cxled, cxlr); if (auto_order_ok(port, iter->region, cxld)) continue; } @@ -1026,19 +1024,11 @@ static int cxl_rr_ep_add(struct cxl_region_ref *cxl= _rr, return 0; } =20 -static int cxl_rr_alloc_decoder(struct cxl_port *port, struct cxl_region *= cxlr, - struct cxl_endpoint_decoder *cxled, - struct cxl_region_ref *cxl_rr) +static int cxl_rr_assign_decoder(struct cxl_port *port, struct cxl_region = *cxlr, + struct cxl_endpoint_decoder *cxled, + struct cxl_region_ref *cxl_rr, + struct cxl_decoder *cxld) { - struct cxl_decoder *cxld; - - cxld =3D cxl_port_pick_region_decoder(port, cxled, cxlr); - if (!cxld) { - dev_dbg(&cxlr->dev, "%s: no decoder available\n", - dev_name(&port->dev)); - return -EBUSY; - } - if (cxld->region) { dev_dbg(&cxlr->dev, "%s: %s already attached to %s\n", dev_name(&port->dev), dev_name(&cxld->dev), @@ -1129,7 +1119,16 @@ static int cxl_port_attach_region(struct cxl_port *p= ort, nr_targets_inc =3D true; } } else { - cxl_rr =3D alloc_region_ref(port, cxlr, cxled); + struct cxl_decoder *cxld; + + cxld =3D cxl_port_pick_region_decoder(port, cxled, cxlr); + if (!cxld) { + dev_dbg(&cxlr->dev, "%s: no decoder available\n", + dev_name(&port->dev)); + return -EBUSY; + } + + cxl_rr =3D alloc_region_ref(port, cxlr, cxled, cxld); if (IS_ERR(cxl_rr)) { dev_dbg(&cxlr->dev, "%s: failed to allocate region reference\n", @@ -1138,7 +1137,7 @@ static int cxl_port_attach_region(struct cxl_port *po= rt, } nr_targets_inc =3D true; =20 - rc =3D cxl_rr_alloc_decoder(port, cxlr, cxled, cxl_rr); + rc =3D cxl_rr_assign_decoder(port, cxlr, cxled, cxl_rr, cxld); if (rc) goto out_erase; } --=20 2.39.5 From nobody Thu Dec 18 10:37:44 2025 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2050.outbound.protection.outlook.com [40.107.237.50]) (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 B69C3235079; Fri, 9 May 2025 15:08:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746803289; cv=fail; b=YhCUls8cznPGMN1N9k92yOedRQQaAAjkJerP3JERbeVi+T70OodT4vJ+8819ygcFBm486W6zI/8E2lf3qxzinFGQzvcv+pbY/c/yiZpusB5Hsy6NJr+pLh6/JHQsvxOH32fx/B0SkmJl6rWA560+vvPVqnwXetdw4t2i2mSX28w= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746803289; c=relaxed/simple; bh=1Eb3kJPR1k18bAlKlHJ80Ki0iQwLfDALtaSDrwOiacs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=V2xBZQh0e1vyYKMkncRB18hzrgAwTFH4JamK+raV4fpTDvNsuEwjjfcmu9NoeOvL1H5G3DAwwfj2nFSRFIEoV8NkcYKVzsJl55pMP0Bhl4tVCMN6N6nZZ3Sk+Fq0GD5f6N2iOqa+NDSSFDVl0WenLAkRhpFGj0kRg67HzOcaORI= 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=yCS5qTkM; arc=fail smtp.client-ip=40.107.237.50 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="yCS5qTkM" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QcaJGhwkTpUUbBZnT5BShQXzMHoECCF62PNjvw8RED6IwOLMH2l2M7SpxFweMrGxOx8yNepKTYsO9vsNGayyvRMiV7NpvUdiXwBuwgqJkkcTKDCsCs3TX7j96TW39tom/kFr+xymoVLpN+mUvUw82arbpLPAxhMUoCgaCcMFzkls71YLIWTlnsoCaQHd+p06hDyjca5LOIjmGkXZAsqH0cZ/Kq3RcFo6toPjE9UuFzs5SvUdxUyzw4M548rNF/RTW25PgcYSOox4s8tIT5XSbgshPwsrVVLBAftrFmZ8Yaj2Ih0cL9s8pABaHRfrQccQTJ8EDxXr0BxxZap/tJrZoA== 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=AlhlnOGnSqISvGH84t2AfbDNvmnVnGgNXukZQmIVfxU=; b=hxDF6UrDXGyYQ54JsPrkTUfufzJxJj91YS4XyymmltgFL4k4LrA+LQKQHZCHCft8TQNFyYDyEHqF4Gpqyen8zz87yYeNb958WHOuPxjAKsbTJKZZtJlD59Il3XWqruxl7f8ryKLeXQ3o1FZxG1U0rLFLE/+r09vAnplOCY0JxteJlFml0aTighglSuobrgfJd/IQrg2XnI1NHaZgXX2H5tQcJPd3OOcmQAOEQ+FGIGFyc7tETUNo78SWn51z4bFJdzwAoXtOzA4E18K7j5GbIru5ci0nWDRMQmpOqxlP1Id1ZrlFa8l3ALl4jPTm0l2qh0Fd9ZzxhG/JCK7bik2Xlw== 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=AlhlnOGnSqISvGH84t2AfbDNvmnVnGgNXukZQmIVfxU=; b=yCS5qTkMJXV8hqPo2HUqGTGmLUYzjZnDEpvxGV58yYbEpYu36MJ3pnbsIdoCQUZD+LmseR1m44tKf76pvpyS+Z0zK61MZtZEg2iVs4iHr2igh+uDpxW7+wfgSPgnxNh5Kb1EZU/srO37yHByuXGVsm3lB0ASHx2dyIK/vkYYtGg= Received: from BN9PR03CA0943.namprd03.prod.outlook.com (2603:10b6:408:108::18) by CY8PR12MB7636.namprd12.prod.outlook.com (2603:10b6:930:9f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.21; Fri, 9 May 2025 15:08:04 +0000 Received: from BL6PEPF0001AB4D.namprd04.prod.outlook.com (2603:10b6:408:108:cafe::99) by BN9PR03CA0943.outlook.office365.com (2603:10b6:408:108::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.35 via Frontend Transport; Fri, 9 May 2025 15:08:03 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB4D.mail.protection.outlook.com (10.167.242.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Fri, 9 May 2025 15:08:03 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 9 May 2025 10:08:00 -0500 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 , Robert Richter Subject: [PATCH v6 07/14] cxl/region: Move find_cxl_root() to cxl_add_to_region() Date: Fri, 9 May 2025 17:06:52 +0200 Message-ID: <20250509150700.2817697-8-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250509150700.2817697-1-rrichter@amd.com> References: <20250509150700.2817697-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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB4D:EE_|CY8PR12MB7636:EE_ X-MS-Office365-Filtering-Correlation-Id: 57a5a06d-9525-4341-1993-08dd8f0b4bcd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|36860700013|376014|1800799024|82310400026|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ucPnBg8sWCAS5f9wCsxecUu3w5pjCvxPNSOhS4ksmM6PfaRgFuaoEKCqHtCP?= =?us-ascii?Q?hfhwil+arAldnt+NujxNwyZbdVcyX1C94GVN/pM+BFo5MoX81bfZuhZjAbEX?= =?us-ascii?Q?9ToH01Q/2DrwgYzI0po28lyyjSxtrq0GDvqeG5o3Vr/AbcoBmL2GHzsgV9MC?= =?us-ascii?Q?3sLvG8C7a3riW/MlzrWl04RtL+l4783PyvgieE5C4n/rcWtfWjNnh7AmiCRu?= =?us-ascii?Q?DHsc5Th/7rkcN3tGhzAsfm7hNlkb/7h9DT1woar+BYcacUX3bC7HWxcSCAKn?= =?us-ascii?Q?LaQLHT9gZMKAcmIJbhTYaW9C/N/0Kd9TZJ4XJnOUySGKZQhd2hqflXrM5q+2?= =?us-ascii?Q?nUachkw9zMiVmd6dEBFzEBKl7Z2nL2cbWGR91Gwff1nJlrivBOQIeN7ZHHpu?= =?us-ascii?Q?9bn665GVxETQ2Hn05G0NOgd3i/dC3DGNcwTAyKEmAeeZTfq8XqKDydE2tCY/?= =?us-ascii?Q?mehFbvRKdshz7QRSfhh/pIOKyFhWnuqaWI6ARFJh2n9yVpnUsXi3aWAE6KQd?= =?us-ascii?Q?vWmnp5L/+P4EH9e7G5nAWFxB1Fb7LBM6naw7GKGAS8Z3P8Hi+wB/KPbBk/ob?= =?us-ascii?Q?JXpxxfhkkNCh5foVceMJwfkZdaUqgzUeXf++HnlN/JivD7PmzuO1OfdwU+/0?= =?us-ascii?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report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(36860700013)(376014)(1800799024)(82310400026)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2025 15:08:03.5179 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 57a5a06d-9525-4341-1993-08dd8f0b4bcd 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB4D.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7636 Content-Type: text/plain; charset="utf-8" When adding an endpoint to a region, the root port is determined first. Move this directly into cxl_add_to_region(). This is in preparation of the initialization of endpoints that iterates the port hierarchy from the endpoint up to the root port. As a side-effect the root argument is removed from the argument lists of cxl_add_to_region() and related functions. Now, the endpoint is the only parameter to add a region. This simplifies the function interface. Signed-off-by: Robert Richter Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang Reviewed-by: Dan Williams Reviewed-by: Alison Schofield Reviewed-by: Fabio M. De Francesco Tested-by: Gregory Price Acked-by: Dan Williams --- drivers/cxl/core/region.c | 6 ++++-- drivers/cxl/cxl.h | 6 ++---- drivers/cxl/port.c | 15 +++------------ 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 988de8e49df6..59d0d6becbd1 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3382,9 +3382,11 @@ static struct cxl_region *construct_region(struct cx= l_root_decoder *cxlrd, return cxlr; } =20 -int cxl_add_to_region(struct cxl_port *root, struct cxl_endpoint_decoder *= cxled) +int cxl_add_to_region(struct cxl_endpoint_decoder *cxled) { 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 range *hpa =3D &cxled->cxld.hpa_range; struct cxl_decoder *cxld =3D &cxled->cxld; struct device *cxlrd_dev, *region_dev; @@ -3394,7 +3396,7 @@ int cxl_add_to_region(struct cxl_port *root, struct c= xl_endpoint_decoder *cxled) bool attach =3D false; int rc; =20 - cxlrd_dev =3D device_find_child(&root->dev, &cxld->hpa_range, + cxlrd_dev =3D device_find_child(&cxl_root->port.dev, &cxld->hpa_range, match_root_decoder_by_range); if (!cxlrd_dev) { dev_err(cxlmd->dev.parent, diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index 14e20b44f2f4..3266be2fe5ea 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -857,8 +857,7 @@ struct cxl_nvdimm_bridge *cxl_find_nvdimm_bridge(struct= cxl_port *port); #ifdef CONFIG_CXL_REGION bool is_cxl_pmem_region(struct device *dev); struct cxl_pmem_region *to_cxl_pmem_region(struct device *dev); -int cxl_add_to_region(struct cxl_port *root, - struct cxl_endpoint_decoder *cxled); +int cxl_add_to_region(struct cxl_endpoint_decoder *cxled); struct cxl_dax_region *to_cxl_dax_region(struct device *dev); u64 cxl_port_get_spa_cache_alias(struct cxl_port *endpoint, u64 spa); #else @@ -870,8 +869,7 @@ static inline struct cxl_pmem_region *to_cxl_pmem_regio= n(struct device *dev) { return NULL; } -static inline int cxl_add_to_region(struct cxl_port *root, - struct cxl_endpoint_decoder *cxled) +static inline int cxl_add_to_region(struct cxl_endpoint_decoder *cxled) { return 0; } diff --git a/drivers/cxl/port.c b/drivers/cxl/port.c index a35fc5552845..fe4b593331da 100644 --- a/drivers/cxl/port.c +++ b/drivers/cxl/port.c @@ -30,7 +30,7 @@ static void schedule_detach(void *cxlmd) schedule_cxl_memdev_detach(cxlmd); } =20 -static int discover_region(struct device *dev, void *root) +static int discover_region(struct device *dev, void *unused) { struct cxl_endpoint_decoder *cxled; int rc; @@ -49,7 +49,7 @@ static int discover_region(struct device *dev, void *root) * Region enumeration is opportunistic, if this add-event fails, * continue to the next endpoint decoder. */ - rc =3D cxl_add_to_region(root, cxled); + rc =3D cxl_add_to_region(cxled); if (rc) dev_dbg(dev, "failed to add to region: %#llx-%#llx\n", cxled->cxld.hpa_range.start, cxled->cxld.hpa_range.end); @@ -95,7 +95,6 @@ static int cxl_endpoint_port_probe(struct cxl_port *port) struct cxl_memdev *cxlmd =3D to_cxl_memdev(port->uport_dev); struct cxl_dev_state *cxlds =3D cxlmd->cxlds; struct cxl_hdm *cxlhdm; - struct cxl_port *root; int rc; =20 rc =3D cxl_dvsec_rr_decode(cxlds, &info); @@ -126,19 +125,11 @@ static int cxl_endpoint_port_probe(struct cxl_port *p= ort) if (rc) return rc; =20 - /* - * This can't fail in practice as CXL root exit unregisters all - * descendant ports and that in turn synchronizes with cxl_port_probe() - */ - struct cxl_root *cxl_root __free(put_cxl_root) =3D find_cxl_root(port); - - root =3D &cxl_root->port; - /* * Now that all endpoint decoders are successfully enumerated, try to * assemble regions from committed decoders */ - device_for_each_child(&port->dev, root, discover_region); + device_for_each_child(&port->dev, NULL, discover_region); =20 return 0; } --=20 2.39.5 From nobody Thu Dec 18 10:37:44 2025 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2048.outbound.protection.outlook.com [40.107.243.48]) (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 10E0423535A; Fri, 9 May 2025 15:08:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746803293; cv=fail; b=EOtwXg3kbLWpAZNq04nCxVFYzB4yGNUOXKbURpnmrDsC0r8+SIgYWwZE702MSDySeYNS2dNtF9qDMl1daTCf+/6vZjP3VSp2Rc/unKVj/g9w6ucmkjmaFd4NpbggHHaGnSg6HTtYpi5JqDayZEYaa5v7nK6lTuK4q71QBGp1tss= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746803293; c=relaxed/simple; bh=LiOyBR2t0TVGy6/e19+mLy4sccL9nPWWrgfubA5muO8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eQdyA3Rjq9SaJ2cHZATGaFtp7N4beddLiE5/pYzisdl+ZbbY1ycse9moDtYAkbISLqqeS9lEwW9eKOFIeSmfJg5zZcwCURRb8E8dBwMmZxR0c3ZN79vnNmvV73wwqF+Elas9tTHfjDZaaOQWp8oRsUA18Xpvhb+OgdmiViy4o0M= 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=2gl3X4lM; arc=fail smtp.client-ip=40.107.243.48 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="2gl3X4lM" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=e8xUOSeeVMX5MW6DcAWn7u0YSCCioHJz//EP73zOvu3MpYC2eAOu4yKlMlTJiB1geUi5P1l5FGmYA96aUTa6KWwLVyURKbPvhkodA5k4Sc7VtIWEkuLj7V75lHsWxQUMUgKmxVNj28LWwgs1FBRSdjViaPd+m8yO9tbJ7dQ8cek3N1hTWzrTHnsMx83rMjJwf47/05uoaQOBpKCHWwtDlSudbJtiGiFNNSgbdig8WhAQmAp9kOXJ08qYkmoTMPri3XCF+u/dZmab6d756ofVjDuT2zBTguugA0PAvE+HkQZkl8rYSbPftNG/SJLLobwtVxydgx7rw7HvjAbEmhSE4A== 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=2OmkTjrCBqZhbkIgmxNkr2R9LO5tocoxGipADkPZYe8=; b=ABN8jzy3rSk8abpP3OpQFfBKDe3giVwfNoeS/1SjCZprm1Oz/W9ymJPC4AMWdAdh3Cyv5atvZetwja861IET6kxqXw/x6gGOTZQVEJ1KPtHzFHLx0pHVd2dWWg5RrWPUIsCP0EJaoDP/8tF36AgfTqhvMbVifBlb1rCudh1hbvoJnYD+kZ/xGmC5JC2Qt2V08COdGOvPMgaF0OVui4JR7XK0yIwjJbH657pg412qgy3T/m9LYwmxbg7BOAS8kmzvgHIbHTAzKPYqdm+D25T1Hy2Pex0L2ayzS4aNEUy55p8HtB/v6O2/+7nWxU1hOW+K8JzQ+X2DiKF+3l9Zp0cm7w== 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=2OmkTjrCBqZhbkIgmxNkr2R9LO5tocoxGipADkPZYe8=; b=2gl3X4lMIQAjH97bpK8YsLPtk6+oSwzYLcReNSRcOFpzgj5vQtNCoMcXSax7HzH0LWTA7+DH+i2Thcc6oRVhdEpn7I9IQbK1wzuwjtHwJSEEs6McnVbyWPLtIUn3PiynIiLKqJpGDbmQZYhN+jyYNEFSmE5+w1vO4OC4piHOnJc= Received: from BL1P223CA0009.NAMP223.PROD.OUTLOOK.COM (2603:10b6:208:2c4::14) by PH0PR12MB8823.namprd12.prod.outlook.com (2603:10b6:510:28e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.23; Fri, 9 May 2025 15:08:08 +0000 Received: from BL6PEPF0001AB4C.namprd04.prod.outlook.com (2603:10b6:208:2c4:cafe::6) by BL1P223CA0009.outlook.office365.com (2603:10b6:208:2c4::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8699.31 via Frontend Transport; Fri, 9 May 2025 15:08:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB4C.mail.protection.outlook.com (10.167.242.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Fri, 9 May 2025 15:08:07 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 9 May 2025 10:08:04 -0500 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 , Robert Richter Subject: [PATCH v6 08/14] cxl/port: Replace put_cxl_root() by a cleanup helper Date: Fri, 9 May 2025 17:06:53 +0200 Message-ID: <20250509150700.2817697-9-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250509150700.2817697-1-rrichter@amd.com> References: <20250509150700.2817697-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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB4C:EE_|PH0PR12MB8823:EE_ X-MS-Office365-Filtering-Correlation-Id: 069ecd2c-e371-42c7-6c95-08dd8f0b4e60 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?F6zcw7xOC5Yp48dXmPYZBbHHTYDZ0lz/e6cfvO+pcaMXMhiVpCqxeMFjXP9N?= =?us-ascii?Q?csWn9UxyOfOWwjTjXp70z3IK2PCG9OX/jfzQuanfdXIXwgvLR/McVn0qXj1W?= =?us-ascii?Q?616tpnIXnM8HtuoaXiw4t2HATOYJbZVJCnM2OdwBKzttX19YL7ga1RswZ15d?= =?us-ascii?Q?khe/xtuwpX1YuR3UuDga/pjrayqehEAF2mVXCppTw3yopjj6Z5cOmqMICuu/?= =?us-ascii?Q?tdkT4vHzCcaAeWW7jj3+M3bBQgzqDmYcwJSp754m8C7TKvbO23c9vV+rXw6t?= =?us-ascii?Q?PZdsfiP+y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ZaGQS?= =?us-ascii?Q?azRxv8jAkfPcJSiNTFDiIBM5gcHOx+wsEfN9DcePkcoqCjq+hvouuOntwDma?= =?us-ascii?Q?d3tPAUVj5xAIvc9Jfn43WuMDFGighdGjMIED9wH4X3noj7Rczg/PqRIdsqui?= =?us-ascii?Q?PdHPEg+RKT6QqXN+/6RbIIhQ/BRGdTehuMKFDhrB3VEURmmkG+r+ofqkIseW?= =?us-ascii?Q?tmCFc7XTETVHbYBWrF6H1I6eAkYXX0FhhNj3YTW0ILBamsENBTtvyTu+sqlr?= =?us-ascii?Q?vhY9jaf8aDb0EP6Gx+DA4D6JogTsoayCYSgSTpMkFgi+EnL7r+AzdMHxODeq?= =?us-ascii?Q?OTkQZ94eZjh9XBefEWwYvI72Bai8xZsfPFsG?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(82310400026)(376014)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2025 15:08:07.8402 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 069ecd2c-e371-42c7-6c95-08dd8f0b4e60 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB4C.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8823 Content-Type: text/plain; charset="utf-8" Function put_cxl_root() is only used by its cleanup helper. Remove the function entirely and only use the helper. Signed-off-by: Robert Richter Reviewed-by: Gregory Price Reviewed-by: Dave Jiang Reviewed-by: Jonathan Cameron Reviewed-by: Fabio M. De Francesco Acked-by: Dan Williams --- drivers/cxl/core/port.c | 9 --------- drivers/cxl/cxl.h | 4 ++-- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 83cfebe8d3e9..eb46c6764d20 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -1037,15 +1037,6 @@ struct cxl_root *find_cxl_root(struct cxl_port *port) } EXPORT_SYMBOL_NS_GPL(find_cxl_root, "CXL"); =20 -void put_cxl_root(struct cxl_root *cxl_root) -{ - if (!cxl_root) - return; - - put_device(&cxl_root->port.dev); -} -EXPORT_SYMBOL_NS_GPL(put_cxl_root, "CXL"); - static struct cxl_dport *find_dport(struct cxl_port *port, int id) { struct cxl_dport *dport; diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index 3266be2fe5ea..c3f50f2d5933 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -737,10 +737,10 @@ struct cxl_port *devm_cxl_add_port(struct device *hos= t, struct cxl_root *devm_cxl_add_root(struct device *host, const struct cxl_root_ops *ops); struct cxl_root *find_cxl_root(struct cxl_port *port); -void put_cxl_root(struct cxl_root *cxl_root); -DEFINE_FREE(put_cxl_root, struct cxl_root *, if (_T) put_cxl_root(_T)) =20 +DEFINE_FREE(put_cxl_root, struct cxl_root *, if (_T) put_device(&_T->port.= dev)) DEFINE_FREE(put_cxl_port, struct cxl_port *, if (!IS_ERR_OR_NULL(_T)) put_= device(&_T->dev)) + int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd); void cxl_bus_rescan(void); void cxl_bus_drain(void); --=20 2.39.5 From nobody Thu Dec 18 10:37:44 2025 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2049.outbound.protection.outlook.com [40.107.92.49]) (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 DE834238171; Fri, 9 May 2025 15:08:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746803296; cv=fail; b=Qx7FOD+UZFeLUuKunqK3TZzj9a+Q8sK2kWrLNLBEGUeIqSklANUhgWiKMQQL0KhShyhD3b0LmxWVGeiGqpgebv/V9Mjz/9WCU0/g448K42Iq7bFvHwfna14txifgTHruhFIadhCh0pKlRWmAfgjRm/LdKqoLGrFaTqP0nQZMEBg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746803296; c=relaxed/simple; bh=HkWViIPLlUWlJZyHyyYTWLIbnPtFd4YGG+Cd5XX9tPs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=u9JplE8aO+VKvMsWMJogzwJOr9N+sYbS/ZBtOg3GrcRuoypD3BKwGQgDQEDG/JJKHZwhmpXv+5VIt6f0L9TsSynIDEb/Zn2oNmuCGBQHPPPn+7+cHFDtHuVTIJ2Qu9zspBDFlRUQq15o3vI8fwCpRaaFWT2wrLdd2KXFX+3p7Ng= 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=gww9yrfI; arc=fail smtp.client-ip=40.107.92.49 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="gww9yrfI" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=txq5SoHOjLNjogyM7RgF1ak/PIsxovWSJQ06SoM9aFXPDKw0F/yuy9Pz1vBbtqT5ad/y6Y0q59umeMycGv2PRhZcXLqlZzb3z3KYtGy2ia5+aVjhU7e9kw0NrNTHONwsCwOcvFs88sDS4kRLS1rGJYLSv3OT7xrwykAM39nsK0zXTk7YkX04IMqOvteLcNbCo9oGwrx+XF3PajD1gsoIf8xJ37Ch5BNWliyfT9k0qmDGn4es69PwQjfbLeuHXi0L3DnPMzfrMujPUHwzJMl4vl/hikdkyKKPK6OE21/bVd2KkETEqrOyHgTfuqA9KQYOYnW6DDAeNBtZdweTa3H5wQ== 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=B9F+sFPlfNtRb2QT99WI8PKiEvRyDsJ0hn7SRu/KtxE=; b=neCHZnVl76VHKdwZZIPqYlb6RqtqRP7zYiFCLQWC11TQ9ZB6XiITn5TT55nIvl2ZMcSW5xoiOrtfAGvZ3THsD3Kbj50VXUrr7g2gdz7O5JajeJLUcvF//6muKHrX8BqYoNPAoceJ95qUlIQLrV3VuMJiDBEOxzW/iV7EEJcwBxRZzqZUf18q5dCk/HCLXghbzWQVrkRc7tcWkuK8jGfVgP4P1IUKk43urG7NO/jLpbaVvN0WA3/I76ZS+9RqlZiPwADHKqgwchWRSEnWa1ejfY4ULBlRPlP9EpgitvAhI7fkMCO3xIh49+sxz/ZsVijA+3/ljEGSC0iHcvJkvZBRvg== 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=B9F+sFPlfNtRb2QT99WI8PKiEvRyDsJ0hn7SRu/KtxE=; b=gww9yrfIDgLCWeIbfdUW53Z/TobtAg2Fte4ZE2NvcBAz7d6xluLSlwYyF1CLOXKGJRDWlccw9F3/MSSptV+7akmIm5hLla4/J/zO1KIaUUd3nUjyTd8gCUZciF92w/n/VtrcvxZppbuxpQDfCaqvg4MgX1ypt+1MTdW9vNOdk0Q= Received: from BN0PR08CA0005.namprd08.prod.outlook.com (2603:10b6:408:142::20) by PH7PR12MB6442.namprd12.prod.outlook.com (2603:10b6:510:1fa::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8678.29; Fri, 9 May 2025 15:08:12 +0000 Received: from BL6PEPF0001AB4E.namprd04.prod.outlook.com (2603:10b6:408:142:cafe::92) by BN0PR08CA0005.outlook.office365.com (2603:10b6:408:142::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8699.31 via Frontend Transport; Fri, 9 May 2025 15:08:11 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB4E.mail.protection.outlook.com (10.167.242.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Fri, 9 May 2025 15:08:11 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 9 May 2025 10:08:08 -0500 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 , Robert Richter Subject: [PATCH v6 09/14] cxl/region: Factor out code to find the root decoder Date: Fri, 9 May 2025 17:06:54 +0200 Message-ID: <20250509150700.2817697-10-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250509150700.2817697-1-rrichter@amd.com> References: <20250509150700.2817697-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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB4E:EE_|PH7PR12MB6442:EE_ X-MS-Office365-Filtering-Correlation-Id: 3f131335-6f7b-4c2c-5b08-08dd8f0b5099 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|376014|7416014|82310400026|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?RaGk/M7xTbJCXKE/GUlY2dOdUFYg+BZI1KH9FBM0D72bI0qRuyq08U7k+/jJ?= =?us-ascii?Q?P25uN8YPw/P+5rtDg+udvXe/dKWRlKciMUySrLlr+moPTVRNBpzK6QlA9gYR?= =?us-ascii?Q?fJUuyzG0saGtF7nMA86QU+f9gXVqyjSB0NfAULoS/K4zoPzHqhmK8jqhPKbb?= =?us-ascii?Q?y9nnWhjzUNpewDOfpumZ5qyM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=?us-ascii?Q?9gIz6UCQzVSVd7M1zS7PUHObYvqmHdDFJ2LXfa8zVJENuDllRnY7SQvBkXKC?= =?us-ascii?Q?v20OeUxsaPehndNAEIyyajV03ERBHZpxtJv2UlKDXpsmmIrEE7eo+Mev6tYj?= =?us-ascii?Q?7IGVnp2LXYxVb5CrQlzV2S2+mmJb1Hkjqxlq3IVWQ8165InOvyo1mOoQR/iO?= =?us-ascii?Q?2rM/tU+VKwsF9xV3gxMQGt/8En1VYno9qKOfXI4+D0YEvqSlal8DfnPz+yph?= =?us-ascii?Q?2HpobaR8uIyf36DUczS02KUGuGDqx43G7PrIYSKFFtclqwqr7risBbKs5GMG?= =?us-ascii?Q?xjljF3QiHsJEAN+0/84HkZFkd0KAMPjNliVa7LR98ukWdk385tuJqJmZvQlZ?= =?us-ascii?Q?SPA2cYSumArxiyM7MJIaV3+3zI5FneyIKlIA1wcxMcCmIZJW0XYo021t8fwl?= =?us-ascii?Q?4hje5IC+A0UTLSfYDbKEbN75YdDWP6aZoZMJ?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(376014)(7416014)(82310400026)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2025 15:08:11.5673 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3f131335-6f7b-4c2c-5b08-08dd8f0b5099 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB4E.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6442 Content-Type: text/plain; charset="utf-8" In function cxl_add_to_region() there is code to determine the root decoder associated to an endpoint decoder. Factor out that code for later reuse. This has the benefit of reducing cxl_add_to_region()'s function complexity. The reference count must be decremented after using the root decoder. cxl_find_root_decoder() is paired with the put_cxl_root_decoder cleanup helper that can be used for this. Signed-off-by: Robert Richter Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang Reviewed-by: Dan Williams Reviewed-by: Alison Schofield Reviewed-by: Fabio M. De Francesco Tested-by: Gregory Price Acked-by: Dan Williams --- drivers/cxl/core/region.c | 48 +++++++++++++++++++++++---------------- drivers/cxl/cxl.h | 1 + 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 59d0d6becbd1..45f5d2c7dfdf 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3216,6 +3216,29 @@ static int match_root_decoder_by_range(struct device= *dev, return range_contains(r1, r2); } =20 +static struct cxl_root_decoder * +cxl_find_root_decoder(struct cxl_endpoint_decoder *cxled) +{ + 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 *cxld =3D &cxled->cxld; + struct range *hpa =3D &cxld->hpa_range; + struct device *cxlrd_dev; + + cxlrd_dev =3D device_find_child(&cxl_root->port.dev, hpa, + match_root_decoder_by_range); + 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), + cxld->hpa_range.start, cxld->hpa_range.end); + return NULL; + } + + return to_cxl_root_decoder(cxlrd_dev); +} + static int match_region_by_range(struct device *dev, const void *data) { struct cxl_region_params *p; @@ -3384,29 +3407,17 @@ static struct cxl_region *construct_region(struct c= xl_root_decoder *cxlrd, =20 int cxl_add_to_region(struct cxl_endpoint_decoder *cxled) { - 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_root_decoder *cxlrd __free(put_cxl_root_decoder) =3D NULL; struct range *hpa =3D &cxled->cxld.hpa_range; - struct cxl_decoder *cxld =3D &cxled->cxld; - struct device *cxlrd_dev, *region_dev; - struct cxl_root_decoder *cxlrd; + struct device *region_dev; struct cxl_region_params *p; struct cxl_region *cxlr; bool attach =3D false; int rc; =20 - cxlrd_dev =3D device_find_child(&cxl_root->port.dev, &cxld->hpa_range, - match_root_decoder_by_range); - 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), - cxld->hpa_range.start, cxld->hpa_range.end); + cxlrd =3D cxl_find_root_decoder(cxled); + if (!cxlrd) return -ENXIO; - } - - cxlrd =3D to_cxl_root_decoder(cxlrd_dev); =20 /* * Ensure that if multiple threads race to construct_region() for @hpa @@ -3424,7 +3435,7 @@ int cxl_add_to_region(struct cxl_endpoint_decoder *cx= led) =20 rc =3D PTR_ERR_OR_ZERO(cxlr); if (rc) - goto out; + return rc; =20 attach_target(cxlr, cxled, -1, TASK_UNINTERRUPTIBLE); =20 @@ -3445,8 +3456,7 @@ int cxl_add_to_region(struct cxl_endpoint_decoder *cx= led) } =20 put_device(region_dev); -out: - put_device(cxlrd_dev); + return rc; } EXPORT_SYMBOL_NS_GPL(cxl_add_to_region, "CXL"); diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index c3f50f2d5933..371f9dcfb61a 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -740,6 +740,7 @@ 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)) DEFINE_FREE(put_cxl_port, struct cxl_port *, if (!IS_ERR_OR_NULL(_T)) put_= device(&_T->dev)) +DEFINE_FREE(put_cxl_root_decoder, struct cxl_root_decoder *, if (!IS_ERR_O= R_NULL(_T)) put_device(&_T->cxlsd.cxld.dev)) =20 int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd); void cxl_bus_rescan(void); --=20 2.39.5 From nobody Thu Dec 18 10:37:44 2025 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2088.outbound.protection.outlook.com [40.107.100.88]) (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 078E0238171; Fri, 9 May 2025 15:08:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746803303; cv=fail; b=bD7ZUjaxtCCzbY1LKqPW571VIg5cLzaoJ8Xxg+t9+w6PUJ5X780wFLdt+f88IW9EGOc74x6dxwkompQpMc8aS2R2XK88heIkXQn+KJ5LcY1AdNRKXLDw3CfoilxCoq6Bw3kySA/LhUVSL93OMtbKmzTLc+UJD5qgumsa3Kb4L+0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746803303; c=relaxed/simple; bh=8U6H7lnSEVPNbfFllcjL91wC7PobCR3JntkRpazSikI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YvMEVwVjYalKxOMJ2WvbzK23GzlIriuapVEP6l15GiGWin7AiC88IQsjW9JqVyk4qm87T3zStIm11VykY1R/+K0v3diu7ofKEadsOKtk52N1ULQbamLms+kRipV5Yyo1oFRW1D3FxuFmub0CSFasPMG2ui+HAqJ+WtR2g/7a2hY= 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=3thS45oO; arc=fail smtp.client-ip=40.107.100.88 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="3thS45oO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CgfYPs3ZjOdkW/247SqNZfYd0XQGWP8OiOwF27hjCnmSpV5vHbupGvyzVeCwhUST/Qh8/m+Yr1hquWk1ofxTJPFtCpqOrP/xVJgP+sWglkRR42pZrlfutSipwokGGTc5CSiLsdNbmHSiGwsk2Q4uqqs7S+XxGkVkQfHzewUfGa5f2RYqJe1jY8i8oXj4QAE6dIVd8stTq0dMaHDesREXDa3gRQME0hOhLZSne7/RuWb527+iYteIUnA3WjO/dyhAbS+tdeaYyjWBfnvgWak4hdr0zp1gPGTEFCTo4WwmHrXHGgX4knTXiFsRej85wV5Pw0TcKeqTxyX1H8c0BwVr2A== 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=aSf2G4JwtivsU8WcnNT0Tj/VPRfv3310Dev63tbzTME=; b=JMVQB9KodxpUfaEDQr9TP8nmk2cBvqNS0rZBooJCryAUaKftnAuhSmHt3YfIRjqKbaW4xnIF/v1Mz7MUAh9vJBl4+hBN3M3PnNeiLfL4Y0/b6o1SKgZNeaBIBiHJEGF4uU3tkzD1sNQDqg52AK8pwUoEmPAQ5wZCZ2MiIbbDVlgqkMYRPf9xYoiPUITb/uxjaGPCc9Om8JSLnTWpEbmng+MRwix4VvyBnHCv3zLQnsGQr/lyMcnlGnKjq1yQPOp143cj14kssQ06RK1dDYIcZMn4CXMpyi3/g4xKcWI1ch3EZHh/+lmdIlemTEhx70oD+nlUFVXuqmpn4c+X0OV8kA== 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=aSf2G4JwtivsU8WcnNT0Tj/VPRfv3310Dev63tbzTME=; b=3thS45oOPFcNFxNHDTtq1SON6qkeLjI7dZ9y1Ce21+7tOcJLwy6d6EUOpaMTgRV9rFQHe9Mm7DtIA8tYS+WWQkQnfh7Oe8g6N41Sbm/bFqbeYp+/vlJQBQ1+LBrg34/56u9ZmFbOWoSNINbwwrgMIdYd2i5NRoLkDZHv0InMxOE= Received: from BN0PR08CA0013.namprd08.prod.outlook.com (2603:10b6:408:142::21) by SJ2PR12MB8011.namprd12.prod.outlook.com (2603:10b6:a03:4c8::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8699.37; Fri, 9 May 2025 15:08:16 +0000 Received: from BL6PEPF0001AB50.namprd04.prod.outlook.com (2603:10b6:408:142:cafe::2d) by BN0PR08CA0013.outlook.office365.com (2603:10b6:408:142::21) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8722.21 via Frontend Transport; Fri, 9 May 2025 15:08:15 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB50.mail.protection.outlook.com (10.167.242.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Fri, 9 May 2025 15:08:15 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 9 May 2025 10:08:12 -0500 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 , Robert Richter Subject: [PATCH v6 10/14] cxl/region: Factor out code to find a root decoder's region Date: Fri, 9 May 2025 17:06:55 +0200 Message-ID: <20250509150700.2817697-11-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250509150700.2817697-1-rrichter@amd.com> References: <20250509150700.2817697-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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB50:EE_|SJ2PR12MB8011:EE_ X-MS-Office365-Filtering-Correlation-Id: 86604793-0a4a-4564-9f84-08dd8f0b5300 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|1800799024|7416014|376014|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?GCWZcFsIMiRHo5R8GuyOHF5DtIsQ9BmAiTPfTqJRt4zbXmNTq6QXTeqSfA0L?= =?us-ascii?Q?Y0jmNKRoVPd3HwoP4dYIhO/N5/IL3hCzWOLvsas3yfYzhxgIodzZNacg4vQP?= =?us-ascii?Q?FQwTtlJucwVALymP6goG7VGZmuUrFQYM8p764USJUC+9GgyM3lspSOluGjck?= =?us-ascii?Q?cAYx4SykshTRkteUxdV9kGbcQiAJqnZfKgeRR5W6DcWF8SxawvyUHrT4fsL9?= =?us-ascii?Q?N1NRPDgufvZhwSv8UVl+SPTuLcaQvlhmf6yBL8Y7R4Fv4/yfr6v9Ns9X96pf?= =?us-ascii?Q?C2rkWGyAYjHFjb7kN2YImc1kGaZVoA2DYGh24aVcXcsBM5ENMT/eaFiv4HZm?= =?us-ascii?Q?05NtCcPraDv1IQ7r7x87ZdfrPeND2/RnaluhC7AftHTgY9ePVFM6Af1JFc8Y?= =?us-ascii?Q?MyJWsziKB4vYlibxfF28Q36dPTrQYzd/jy/ppyukp5gdwPpVoBmzUQ0RVew7?= =?us-ascii?Q?E5MS2bZtDa6TRfstZr9bJEiVlK/V0QNJ8zgJmLaeMJrGtOXWtW91aoEkUL4a?= =?us-ascii?Q?aizWDpcoLAKI/zP05qVkJcufSOzTMvjcQ0gxinBO/hmymY/dmalym4p76yo0?= =?us-ascii?Q?47azrqrhjxU+uJ4Iye66ZqfgWc3ZVgvuSSY175tHu5zcc5umiBqqGmlSyRmG?= =?us-ascii?Q?VZvC288PSRdqVaVMmdSeh92/MyaQY2VpOFNlTcu2/da/TauFzBSQ8PuV870o?= =?us-ascii?Q?AuJjgZpxLTTkhl/v3s1T8NTe5QNjccH45Prxvaa8wlYQf0NW4onbed0rhSfk?= =?us-ascii?Q?51F1soUoRkWRBUkTEMcJcbrp4GZjEVu68zIIu6UCwkKj+ywFjZ61f0hlz5os?= =?us-ascii?Q?jEw1SMZVB64PsZUxA8di4hHnvPrjDOntohTKn1Wfkz1voao0x/H9ul6DPUG3?= =?us-ascii?Q?+03ubf6kGiNc4JzIx43dCjoHFIG7rRuhFpzXVdkoi5uUYseOOSlnVW5kmVaD?= =?us-ascii?Q?0iWSUvqeTh4GgLH7ZXZrgd4IUDubSuSxFB/jboDHewEQH8SbaCQ9HZ3EeBOF?= =?us-ascii?Q?H3i1ZvKLibfHkXIWpj+0RDx8sk0WKb5XGXAaMtYkL+QWuvVr8Pj3A82OJDwS?= =?us-ascii?Q?G28t1wGhnAN47DYY0yZjJYQ22YPjbOu/af+7Hw0KflIQ3pHlrizS1Q1VRmTz?= =?us-ascii?Q?CazZRJcK/J7X5kmw8FPJM+nAdz8TpoGYfSU+Aeiyjh+rnv6TJON+08I5aXZs?= =?us-ascii?Q?zly4U/xgIWt6j+hGgXxEAt/LBKgqvzVOvEVkIuguuCY4LqX6/PGfgvfSWMea?= =?us-ascii?Q?UfpPB4eodIRa0s80Y1xlsIqow4lc2FPJNpTjPRFoi4Kli89s58Ihy3Nr/R/1?= =?us-ascii?Q?W6f/W1SWlQbuirgOgtnqf5mP7ndECzV+ecb8YjjfwmmRqmwmcqxTmUug681K?= =?us-ascii?Q?7P8LXY13U/C2zk+PHP+Vvm6CglJ9kGreM1cX7SJcsc07+nvmMYRUmentJ50D?= =?us-ascii?Q?y4bmWfjavATSOPWquG7dBpX6UE+aPLxb0ig9DYYmod4Or5OG+kAcslffRfez?= =?us-ascii?Q?vv2ZtSFe2ZOyLhqNXHD8Vd8UVu48kz3XTgvf?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(1800799024)(7416014)(376014)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2025 15:08:15.6010 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 86604793-0a4a-4564-9f84-08dd8f0b5300 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB50.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8011 Content-Type: text/plain; charset="utf-8" In function cxl_add_to_region() there is code to determine a root decoder's region. Factor that code out. This is in preparation to further rework and simplify function cxl_add_to_region(). The reference count must be decremented after using the region. cxl_find_region_by_range() is paired with the put_cxl_region cleanup helper that can be used for this. Signed-off-by: Robert Richter Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang Reviewed-by: Dan Williams Reviewed-by: Alison Schofield Reviewed-by: Fabio M. De Francesco Tested-by: Gregory Price Acked-by: Dan Williams --- drivers/cxl/core/region.c | 26 ++++++++++++++++---------- drivers/cxl/cxl.h | 1 + 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 45f5d2c7dfdf..8fdf03058b2f 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3405,13 +3405,25 @@ static struct cxl_region *construct_region(struct c= xl_root_decoder *cxlrd, return cxlr; } =20 +static struct cxl_region * +cxl_find_region_by_range(struct cxl_root_decoder *cxlrd, struct range *hpa) +{ + struct device *region_dev; + + region_dev =3D device_find_child(&cxlrd->cxlsd.cxld.dev, hpa, + match_region_by_range); + if (!region_dev) + return NULL; + + return to_cxl_region(region_dev); +} + int cxl_add_to_region(struct cxl_endpoint_decoder *cxled) { struct cxl_root_decoder *cxlrd __free(put_cxl_root_decoder) =3D NULL; + struct cxl_region *cxlr __free(put_cxl_region) =3D NULL; struct range *hpa =3D &cxled->cxld.hpa_range; - struct device *region_dev; struct cxl_region_params *p; - struct cxl_region *cxlr; bool attach =3D false; int rc; =20 @@ -3424,13 +3436,9 @@ int cxl_add_to_region(struct cxl_endpoint_decoder *c= xled) * one does the construction and the others add to that. */ mutex_lock(&cxlrd->range_lock); - region_dev =3D device_find_child(&cxlrd->cxlsd.cxld.dev, hpa, - match_region_by_range); - if (!region_dev) { + cxlr =3D cxl_find_region_by_range(cxlrd, hpa); + if (!cxlr) cxlr =3D construct_region(cxlrd, cxled); - region_dev =3D &cxlr->dev; - } else - cxlr =3D to_cxl_region(region_dev); mutex_unlock(&cxlrd->range_lock); =20 rc =3D PTR_ERR_OR_ZERO(cxlr); @@ -3455,8 +3463,6 @@ int cxl_add_to_region(struct cxl_endpoint_decoder *cx= led) p->res); } =20 - put_device(region_dev); - return rc; } EXPORT_SYMBOL_NS_GPL(cxl_add_to_region, "CXL"); diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index 371f9dcfb61a..ba08b77b65da 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -741,6 +741,7 @@ struct cxl_root *find_cxl_root(struct cxl_port *port); DEFINE_FREE(put_cxl_root, struct cxl_root *, if (_T) put_device(&_T->port.= dev)) DEFINE_FREE(put_cxl_port, struct cxl_port *, if (!IS_ERR_OR_NULL(_T)) put_= device(&_T->dev)) DEFINE_FREE(put_cxl_root_decoder, struct cxl_root_decoder *, if (!IS_ERR_O= R_NULL(_T)) put_device(&_T->cxlsd.cxld.dev)) +DEFINE_FREE(put_cxl_region, struct cxl_region *, if (!IS_ERR_OR_NULL(_T)) = put_device(&_T->dev)) =20 int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd); void cxl_bus_rescan(void); --=20 2.39.5 From nobody Thu Dec 18 10:37:44 2025 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2042.outbound.protection.outlook.com [40.107.92.42]) (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 AE9652356A8; Fri, 9 May 2025 15:08:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746803305; cv=fail; b=CfvKVGKBLh3nX34kdvBzwjLleoM7x9JKbpTKXHf3WYxruyX/+kzJUdUlNNF6R/dpwLL48N7xzpnl+l6qFpPLOlz/yOkRaA1vXJ/pth/qz05pvaLMHoFXJqfTJpU3//DjABfIuEdv32QEooryCHiuJJQGCbL15X1XZlhhLxIhgh8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746803305; c=relaxed/simple; bh=EVY608MSRGAyJg6soKxpzCSkhW3eTBd4swI/fO4HQr8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TL2LNCb2XvNk1NwSsOQcrjzdQjTVIJfCrtjaPlwrAXsMRMYurdQaF4FnqjgxYIPF+nf6/8Ul2ozUbb2SMB6D8PFxDN5Rkd35rwtLcDwakpQb9PZwCdhEfcaU49jgUir8F13g8goickZnpplJsiMYezPK8wvLgXMUA3OC5ewdqmY= 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=GnHCz8gS; arc=fail smtp.client-ip=40.107.92.42 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="GnHCz8gS" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=egc+F+5w1WGAYr1CQNMkP2VYdVocIqG0P9Rv7wn/ebX8aEJ+jO/bQlCcLVCIYwFHLAbuMZ6jBJkuEuWK0HQ9HWjzN4uejUmJ9msrkDLxfO41ZuHW6rpkajIB7zGwJSoiUf7rAymkS1Pb+DtAsQPms/bZQe6GJPkNRzMn9svCxYMMLwvzWIHLn3ivZxfACSZ/xGK9cQzzwFSCnrikB2nLnwynx6LHOyhXhWaUKDeu4OH0dwzyNhAhXlgeTFkOY8JAnc59ootYMJsYy1s8RQgZer0+LENwboJOnpl0m+qsK9VeT0MiMvfxsZ6ZRAXL25DUDsO51zH+8U9B21ClcqfyDw== 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=pt/5lYbuBYr7QnCT42EKg7CM1j0/9ElH/ZocySjS8tM=; b=mgEJyLuk6eOlkgyINniJZ9vldDCs582kMQzo5Y4c22PYoHSqZHjJHnXqTWz5zGm2l6ejH8eatmIjLdTRflgaHErlAKMIUhpWKP6hO6upRE+YF9NM9j87n/13D0Sb/62K/6UathChJbJd0nEpYWOEfSnNQX2dqO5Jj+9WsK49xZqgaTJ60dsiRqooBHUyHBlI2oci70h/UmjrGHxMiG1c5UhV9aJx1OyTeFiXviFpDG9mFpvQz4B0TjB8HkkR/pquks25GI09dF9cZrWNVSbULuV59MhPdPJxPgVo6fGVN4myRxujYKKVm+864/2Dq/rHZGznoeMGAK8lvfsZP/lteA== 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=pt/5lYbuBYr7QnCT42EKg7CM1j0/9ElH/ZocySjS8tM=; b=GnHCz8gSm/YiqZEz1gnnyFh9bJX18KGrd3vRSzAF9aFSDf9zeaGTciXvJZTbFj9xyLTfO2SQ32c+aEhVDixwhIxlIEeZtE6Nr5QsgQ9SOpQcxN2XQzz3EdaQK2AJDhSnCBb37U+VIjwNCndDuYjFcYBzb0KkAmlqOfUpe5Ucveo= Received: from BL0PR0102CA0021.prod.exchangelabs.com (2603:10b6:207:18::34) by CH2PR12MB4230.namprd12.prod.outlook.com (2603:10b6:610:aa::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.21; Fri, 9 May 2025 15:08:19 +0000 Received: from BL6PEPF0001AB4B.namprd04.prod.outlook.com (2603:10b6:207:18:cafe::ed) by BL0PR0102CA0021.outlook.office365.com (2603:10b6:207:18::34) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8699.26 via Frontend Transport; Fri, 9 May 2025 15:08: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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB4B.mail.protection.outlook.com (10.167.242.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Fri, 9 May 2025 15:08:19 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 9 May 2025 10:08:16 -0500 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 , Robert Richter Subject: [PATCH v6 11/14] cxl/region: Add function to find a port's switch decoder by range Date: Fri, 9 May 2025 17:06:56 +0200 Message-ID: <20250509150700.2817697-12-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250509150700.2817697-1-rrichter@amd.com> References: <20250509150700.2817697-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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB4B:EE_|CH2PR12MB4230:EE_ X-MS-Office365-Filtering-Correlation-Id: 2b846e73-1052-4d7e-8e57-08dd8f0b554e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|7416014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?EwjFjvVLAb1sXYGxOd5RPs8cyc9NGX2/pdfCbQLGDwlBa5M/m1dvOrRJonoG?= =?us-ascii?Q?u9uYIyGRkT9THAg/4/ml6ftVGTbP3JpiPcBFy75HJQAYWW80xaVZ8SdPCGCp?= =?us-ascii?Q?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IbVecTl?= =?us-ascii?Q?uW+UbCFLkmmHdXANrAnUpole/2LnTqoxzJ/t1zUVg63fBREGM+Qwet+CfBkU?= =?us-ascii?Q?KuJExwxP8BiRMPOfJ4Oqk/FEnbzynaBp+GGaH/ZwzsbKcWFeRjSItbL7rxX3?= =?us-ascii?Q?ve5mWwQB5P2U2ruseLUg6U9nqsabxAB/LFY06HA/eCh5Qo3QAB3FaSu4BU/W?= =?us-ascii?Q?lAgIKG4Bjha/5aflOZkpf82G6wsgce88AjphzgYeykbjlQXi7XAbp2RcKYZu?= =?us-ascii?Q?2JGdDYH7ZlFY9ajG8dR9Ad7YvBYHEr+Y3ffWyDERH9IwyBvKGM76h+kiixdm?= =?us-ascii?Q?FNIwMNtdrJmyqCznSkqGD9EJ6eLp2FycyS1jHgxOuysei7bZp9w0t1bXU2ga?= =?us-ascii?Q?DKM2giJhVjlc5jqeQzi0uP//jMwTzbDLFj5BAmJGjmAVhhVl+duPq8BqZOEK?= =?us-ascii?Q?wlQ06MzUG5O5SkDpy0ISYgay/kNkbBxEY8MU/jDPvD7y3Te0Rkuz7iuJEVaB?= =?us-ascii?Q?I2WL5YU4/rSz7X7c8VXpPAb8jbz+T00t/0ep?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(82310400026)(7416014)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2025 15:08:19.4669 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2b846e73-1052-4d7e-8e57-08dd8f0b554e 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB4B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4230 Content-Type: text/plain; charset="utf-8" Factor out code to find the switch decoder of a port for a specific address range. Reuse the code to search a root decoder, create the function cxl_port_find_switch_decoder() and rework match_root_decoder_by_range() to be usable for switch decoders too. Signed-off-by: Robert Richter Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang Reviewed-by: Fabio M. De Francesco Tested-by: Gregory Price Acked-by: Dan Williams --- drivers/cxl/core/region.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 8fdf03058b2f..9d3f97ed664b 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3202,33 +3202,39 @@ static int devm_cxl_add_dax_region(struct cxl_regio= n *cxlr) return rc; } =20 -static int match_root_decoder_by_range(struct device *dev, - const void *data) +static int match_decoder_by_range(struct device *dev, const void *data) { const struct range *r1, *r2 =3D data; - struct cxl_root_decoder *cxlrd; + struct cxl_decoder *cxld; =20 - if (!is_root_decoder(dev)) + if (!is_switch_decoder(dev)) return 0; =20 - cxlrd =3D to_cxl_root_decoder(dev); - r1 =3D &cxlrd->cxlsd.cxld.hpa_range; + cxld =3D to_cxl_decoder(dev); + r1 =3D &cxld->hpa_range; return range_contains(r1, r2); } =20 +static struct cxl_decoder * +cxl_port_find_switch_decoder(struct cxl_port *port, struct range *hpa) +{ + struct device *cxld_dev =3D device_find_child(&port->dev, hpa, + match_decoder_by_range); + + return cxld_dev ? to_cxl_decoder(cxld_dev) : NULL; +} + static struct cxl_root_decoder * cxl_find_root_decoder(struct cxl_endpoint_decoder *cxled) { 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 *cxld =3D &cxled->cxld; + struct cxl_decoder *root, *cxld =3D &cxled->cxld; struct range *hpa =3D &cxld->hpa_range; - struct device *cxlrd_dev; =20 - cxlrd_dev =3D device_find_child(&cxl_root->port.dev, hpa, - match_root_decoder_by_range); - if (!cxlrd_dev) { + root =3D cxl_port_find_switch_decoder(&cxl_root->port, hpa); + 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), @@ -3236,7 +3242,7 @@ cxl_find_root_decoder(struct cxl_endpoint_decoder *cx= led) return NULL; } =20 - return to_cxl_root_decoder(cxlrd_dev); + return to_cxl_root_decoder(&root->dev); } =20 static int match_region_by_range(struct device *dev, const void *data) --=20 2.39.5 From nobody Thu Dec 18 10:37:44 2025 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2079.outbound.protection.outlook.com [40.107.96.79]) (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 052CD239E73; Fri, 9 May 2025 15:08:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.79 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746803307; cv=fail; b=qlajfYz103i2quaVWAKkUgX8Nj0ZWsvmo2ZudevdJFE109MPYrbTzn4t82VBvl9qNyGkvoAqbeyX//0yrdZwTRCTEc+0HEDj9deUAwxKpjKclAWkuAYRrQazrosoxLeOo5pJf/NnLzBXp3g/1A3TaWrxu50FqKDOfWeabbHlno0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746803307; c=relaxed/simple; bh=k0QFPMTO2PMxWuAw60B9khynwb61oBq+7bHjsIUUKnM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jGvPQ/8K3fu7wYTeJ/36GQZmE1jWDTCGQ9Lrt2yutjpsNb52UDLX+t2r/FhgfNiBFdaTRgBJf3OSoraOvZaIOjejcAokyhBmvUOmPHHCAdlhW6yVXv3pyLRmUNLIjxZ+Z5w83Il5b7bdZ8xIDu8wSTZgNlxq423PC3rUJHObsH4= 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=FVUDZ0iu; arc=fail smtp.client-ip=40.107.96.79 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="FVUDZ0iu" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qffzF9/p29pP3iu20uAMv39NyK9DpeZ3CoyPNMbrlaQwOj3fxfFZVMk3WNpoa/bQqYldfA04dnxsyQrnaPwQpbtn+SCXObJYYpbBMHj9vQo7FaQ1Rj8F44kM+18b7/q2uo1+fOaMaN9qQtClhISKsDLycLnf1e5OmbPJN1+8+0jgGRB8PeKDLdF5V8Ok+YYb30ablUtMQtUQ5QODNFmMgbdAE2498dRH2LQbF9OAnlVGt98M0wQ3UfxKtQZIFHUYvzYp+P1dvab84pQ+6fmMr5bpdrpoxMFY5vZ1OC6GLxvxsL++0YpSEihMNDvC/SJHpQt5ysrfL0If27cNgPSNaQ== 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=0dBoJHXDKcO5nAbJXIiGgVr9bkGDnaPMhXTUTJiesBQ=; b=HuXRoVHm+40UCpNuy1xMZ0V2f7DxCmHZwE/JPhyUxgXmtFJrTs6336GW6pA9c9PCDkj91DnMYXLuB1y2dx3qRNBjdnyXak0zsqSdf/yl0aO3zlLfYKe+QVAQCbTzaP2NmYeAGB1QiNUh6Q5zfSNhG7+Bc19Xbwn0J9StFsEIaThx0KQLIszUHV29NCRxGx0rJRye9OlsLiMXhgUMh13GwEAOsUMTguYNyHTfJFAxoXyiPOaYGicxO0PVMMZSWE7WqbP0TRZTvNHNMU1CdPeYMhC8V//oQFjeWuSd9/Z21VF77sJfNof6LsVqCu5vMaq/l1G7NKkpG2sqEsJdQOODNA== 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=0dBoJHXDKcO5nAbJXIiGgVr9bkGDnaPMhXTUTJiesBQ=; b=FVUDZ0iuaQRG4bvXCsAjcEr3+pP9M1Qscn9dKQoj8i1Db8dJadf5t6Z8iceLnJ/3DTT+ziAhkrso/7Sci+kMYdCDK566ovlDLPGt+6CkSSAaXIrby9z/vdho2JrJIq6VtggV+YBGfRU9KCu6dB3AF6FLc0uhFeuglMg9Ou1odUs= Received: from BN0PR08CA0002.namprd08.prod.outlook.com (2603:10b6:408:142::18) by CY5PR12MB6251.namprd12.prod.outlook.com (2603:10b6:930:21::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8699.24; Fri, 9 May 2025 15:08:23 +0000 Received: from BL6PEPF0001AB50.namprd04.prod.outlook.com (2603:10b6:408:142:cafe::ce) by BN0PR08CA0002.outlook.office365.com (2603:10b6:408:142::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8699.30 via Frontend Transport; Fri, 9 May 2025 15:08:23 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB50.mail.protection.outlook.com (10.167.242.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Fri, 9 May 2025 15:08:23 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 9 May 2025 10:08:20 -0500 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 , Robert Richter Subject: [PATCH v6 12/14] cxl/region: Add a dev_warn() on registration failure Date: Fri, 9 May 2025 17:06:57 +0200 Message-ID: <20250509150700.2817697-13-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250509150700.2817697-1-rrichter@amd.com> References: <20250509150700.2817697-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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB50:EE_|CY5PR12MB6251:EE_ X-MS-Office365-Filtering-Correlation-Id: 017fdf75-19ce-44e9-aa9e-08dd8f0b5787 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|82310400026|36860700013|1800799024|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?TGBEMeQumrKZ7JCVPsFnYVdFIPAhvtrk4Ys65KMn9YfK4ZrAxY4KKzk8Atl6?= =?us-ascii?Q?UMoGDVrlUFnZcFgYJvJaYVaQcF3Aqg1e5FgzR5NP/3ez5116e4XpFyibM5n7?= =?us-ascii?Q?n8dqS7pvYi5hVZBZTtdlmr6Q0LuxsUI6S7B4KjPHGDhyM8KQ7gpG94kFZTzJ?= =?us-ascii?Q?GNpMojckrhxFvZAo1xGHOIhD5s2a3BFts29XIDj7EZ0i/93SQzqPV3/QSGpT?= =?us-ascii?Q?SWdCxAB4NpBTv68Uj3p3Wzh0dWdnG3YNqeu4CuortFVAdR/rFioENL7aIttR?= =?us-ascii?Q?jtMFNkXIgarQh8R4cWEvbZ7uIdXLDlbmZ2bviEedg5aI7Tyn9EtRKH5zQ6HV?= =?us-ascii?Q?mBu4eDrgmP2ahFg1ex83p+AUbJuk22wtjQPKDB7fX1EmXVmQORr3ZWsDoqOk?= =?us-ascii?Q?Rl1VULHUEJ8MmKmpynxzPuxcPOVbrTRKUgPWNhgIJB2/5j1WrReal/2EWYpj?= =?us-ascii?Q?wURoH/zTXtdQ33d3jDr/rbmQS99l15LZ0wYfoTE63ogd7ev+osrMm9x8Rclw?= =?us-ascii?Q?0i62BPFuMhneptSnn71RDKB+V/6P/2F+6jJWQVC+a90fFreLwAvm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iNhagXtzhbQraOAeMbDyTJHB31Dp7HIqmKU6cK0?= =?us-ascii?Q?cfGWVlCD++FSq2zUQvNh/HMOEKwgxOCaoF5n?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(82310400026)(36860700013)(1800799024)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2025 15:08:23.1969 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 017fdf75-19ce-44e9-aa9e-08dd8f0b5787 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB50.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6251 Content-Type: text/plain; charset="utf-8" Esp. in complex system configurations with multiple endpoints and interleaving setups it is hard to detect region setup failures as its registration may silently fail. Add messages to show registration failures. Example log message: cxl region5: region sort successful cxl region5: mem0:endpoint5 decoder5.0 add: mem0:decoder5.0 @ 0 next: non= e nr_eps: 1 nr_targets: 1 cxl_port endpoint5: decoder5.0: range: 0x22350000000-0x2634fffffff iw: 1 = ig: 256 cxl region5: pci0000:e0:port1 decoder1.2 add: mem0:decoder5.0 @ 0 next: m= em0 nr_eps: 1 nr_targets: 1 cxl region5: pci0000:e0:port1 iw: 1 ig: 256 cxl region5: pci0000:e0:port1: decoder1.2 expected 0000:e0:01.2 at 0 cxl endpoint5: failed to attach decoder5.0 to region5: -6 cxl_port endpoint5: probe: 0 Signed-off-by: Robert Richter Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang Reviewed-by: Dan Williams Reviewed-by: Alison Schofield Reviewed-by: Fabio M. De Francesco Tested-by: Gregory Price Acked-by: Dan Williams --- drivers/cxl/core/region.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 9d3f97ed664b..861cf74d5c91 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -2166,6 +2166,12 @@ static int attach_target(struct cxl_region *cxlr, rc =3D cxl_region_attach(cxlr, cxled, pos); up_read(&cxl_dpa_rwsem); up_write(&cxl_region_rwsem); + + if (rc) + dev_warn(cxled->cxld.dev.parent, + "failed to attach %s to %s: %d\n", + dev_name(&cxled->cxld.dev), dev_name(&cxlr->dev), rc); + return rc; } =20 --=20 2.39.5 From nobody Thu Dec 18 10:37:44 2025 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2078.outbound.protection.outlook.com [40.107.100.78]) (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 7780823A9AD; Fri, 9 May 2025 15:08:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746803311; cv=fail; b=K7bip3XpVOkfqU9DgI13uoCfj9lhW9A7kymg6mgWRu9BR15TUjsvLoX1OrARwLHGa/udSk3hMgdI0mpTs45YiZikAEF/JW+ooq1azo5I3Qe3ukBRKqhsv9t2Y0gAnzY98EyBvF9I4IKCftIt+1+AEM5wQlIfyYdQuFzVXqckpZk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746803311; c=relaxed/simple; bh=T5TITUxf2vKPMOL7bhR+4lw9toaywTpay8s0S2xqg9I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YI9EeS44fcCkP9T+QVVd50eVNaCYXSqprxfnNoxmBmcD5iPcPy//D3eSEil/5Q+VcKNGOMfcTKpfR3N2fT4UmnFMtvX5W48gusvj5EvmyYrCa9y9Wqcdr0vBx7c/yBdPssZj2fxWSQNodnguTzd4g+FMk7O61PTBGt0fWqh50HM= 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=EtkdfO/f; arc=fail smtp.client-ip=40.107.100.78 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="EtkdfO/f" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qhaO1iG6SdtpopXwEqCJvnuhSz0L5QxKzHg3Qg8V6YkycJiWTbgJnXBse0W3BA8RNAJd/2UelawTdv3NYJAzb6kS7G/52FhPAWUpIdT0m6Co+sN8L9CSXEJtU9Jvl35jzDwslX3IVowl6XdPl1ilnBUIxIeiZbFsD/MLqPYs+DwnKK8p1jxPT58WNoF1M+KKgSIoLHZS8oVtAv70aeGrzQmhqmEgJQmFu6puhh6aARp9nbjulLJRJ8ekIQnSM0vdsDVN501l1B7xP2wwvxTUUnEjlcK1Lb46i3qX4hcHXcMBpRLsRJvnFKb0Y8v72t0IQpuL+iPeG+ImtGa3vUAjGA== 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=130sewlDL3gLms9y+hY/4CP5At3SUXlnV9LJ5dJ+THo=; b=xWWJH5PH0YG6fnya6LqQ27+7gbIKn2TsYTMcEDxW2oiEDR6U5SywikxiCauANWsUv1Lg1GZN6wVuYVXbSpo/8Q97vr/yZ8rRF1j2ePKMwRbqtmnEj+K3O6ejhZnaXmn9ylRPkYrSUYI+sfTB2Wzy8ti7UBNCE7hlPYbQYgvLuRi9UnhT1sl0eVXvq2/GVkyZwl0bvQzNvcSQbprNVcg8QoKsJQAZ5KkCFvbTR0GgRgm0u3px0PpmhF8mwb2LGvRDaRL5KLH5XvIHIagPc/ki0nBb/gCHIxpzS7R+5ogq9MECzL0hPxmOYgbZBk6MfwFfKyXLMmMIpYNK3N24nzTWQg== 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=130sewlDL3gLms9y+hY/4CP5At3SUXlnV9LJ5dJ+THo=; b=EtkdfO/f4UirOmP+JGD4HS7KAW5Lgy7YmIhyeohRlp+Rqqz8GAeVdhho1mHqRe2xDSA3wB7/opZ+gHny4c4DR0TmYJ9/nVPyw+UDVSlC9KSlMuG66GNPmkoA7et+QfwlpPTNHzRiHL/EJZ00Xw3tDKfAI1Jp88h1e+uyGzqMq9U= Received: from BL0PR0102CA0023.prod.exchangelabs.com (2603:10b6:207:18::36) by IA1PR12MB6482.namprd12.prod.outlook.com (2603:10b6:208:3a9::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.25; Fri, 9 May 2025 15:08:27 +0000 Received: from BL6PEPF0001AB4B.namprd04.prod.outlook.com (2603:10b6:207:18:cafe::1e) by BL0PR0102CA0023.outlook.office365.com (2603:10b6:207:18::36) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8699.24 via Frontend Transport; Fri, 9 May 2025 15:08:23 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB4B.mail.protection.outlook.com (10.167.242.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Fri, 9 May 2025 15:08:26 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 9 May 2025 10:08:23 -0500 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 , Robert Richter Subject: [PATCH v6 13/14] cxl/region: Add a dev_err() on missing target list entries Date: Fri, 9 May 2025 17:06:58 +0200 Message-ID: <20250509150700.2817697-14-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250509150700.2817697-1-rrichter@amd.com> References: <20250509150700.2817697-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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB4B:EE_|IA1PR12MB6482:EE_ X-MS-Office365-Filtering-Correlation-Id: b5299e07-2fc9-4e92-8c21-08dd8f0b59ca X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|82310400026|36860700013|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?44utbvbm9Jyn2VSzjQcklzK85smzDTDGTPMvQgJ3xk+UkGX6d/lIsv2giAAC?= =?us-ascii?Q?a9mNub2qn3J7muDWw4VfMogZhzM4A6Q/N3jJI0eiMZmXfXCF2xH1T5OTkoYy?= =?us-ascii?Q?BfvzgHOnZ5dScFS0hORKxReW7iF2j79nD1eSHAkZ1Fn4Rtwqde5kawYiuREk?= =?us-ascii?Q?52YyiWqNq/GeZpVoYJsd7v+FtNWzcTSGR+BQkQ0abM8IdEvcfWic/hxuWAUB?= =?us-ascii?Q?ePxL7bCLiJcY9jmpP6R99Q9Mww3xDkSlQDNwLyTiT4kFS3o1+CLcFcy9mglx?= =?us-ascii?Q?DR/vKuZoAh5N1JrwpTjnfuHRSxR0CzwFkGLhjp8BIbWZnHS0JqUvxcL9lsim?= =?us-ascii?Q?JwJREntVpMZnX/QgpiuW36aKUdPielrOkA3EAtoN5hfkQ6aYdqlSmBTnWH91?= =?us-ascii?Q?eZx9uLj9boxDjFb0Lr3vH1K31KyPsM3aSVnOlkpWv/I0Va3zj2WNK8kCPnW8?= =?us-ascii?Q?bBF4rrcIPHVLIpQ+RMbc1zffMlBvvjOzwpDoTHcM9vA0Z78Sd8RyOqk5YS6d?= =?us-ascii?Q?TCxP/x7BfxE4/6mUGHNLHztoeArGTaJN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ygXtcnToa9QnH0t80BgvANtKW4PYsrulhnOXjhrm5ZMJJ7rTVu?= =?us-ascii?Q?xqtk99dLoqTxGp1uRXE6f8J6KyyQ7VtDrnMV?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(82310400026)(36860700013)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2025 15:08:26.9825 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b5299e07-2fc9-4e92-8c21-08dd8f0b59ca 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB4B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6482 Content-Type: text/plain; charset="utf-8" Broken target lists are hard to discover as the driver fails at a later initialization stage. Add an error message for this. Example log messages: cxl_mem mem1: failed to find endpoint6:0000:e0:01.3 in target list of dec= oder1.1 cxl_port endpoint6: failed to register decoder6.0: -6 cxl_port endpoint6: probe: 0 Signed-off-by: Robert Richter Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang Reviewed-by: Dan Williams Reviewed-by: Alison Schofield Reviewed-by: Fabio M. De Francesco Tested-by: Gregory Price Acked-by: Dan Williams --- drivers/cxl/core/region.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 861cf74d5c91..bb69f59e27b4 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -1809,6 +1809,13 @@ static int find_pos_and_ways(struct cxl_port *port, = struct range *range, } put_device(dev); =20 + if (rc) + dev_err(port->uport_dev, + "failed to find %s:%s in target list of %s\n", + dev_name(&port->dev), + dev_name(port->parent_dport->dport_dev), + dev_name(&cxlsd->cxld.dev)); + return rc; } =20 --=20 2.39.5 From nobody Thu Dec 18 10:37:44 2025 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2079.outbound.protection.outlook.com [40.107.94.79]) (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 D2B5323C384; Fri, 9 May 2025 15:08:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.79 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746803316; cv=fail; b=WzfL5bDhalFfQKK1CtbUCCKjyompzjWUd48raqobt4zlpS4JZnqUj+VMC/HQPqTo45aECtHcSlQWvUZHf/4jrHNIYEUhlcB2cWICbzs6j07LjdY1iVgw+WaL7jqA3gUrwl0Okv37bdopch2+x+idT62HDUuz0pxjDeOyFizW798= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746803316; c=relaxed/simple; bh=Hk6Rzs9bsj0Xb6iJO+CzutYyfbPbYyDlx66+OL2Ye1Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kQqQQpWAmM+mDXSQKackzxYhOVnlBSSsZTNuHFXPRp6hFouBuNpX5Wm0mLHtcKzU0ye+r6tAhMNK2DGo79vR6qBzj1qkWfyJvh+vw0/X/oqCa/pK8N3+r5lwF3sjMnUMmlXjWBja5rWqyE2j5jtEvXBA1BGYXAhLn1zFDPQJC9Y= 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=LVGTOTtg; arc=fail smtp.client-ip=40.107.94.79 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="LVGTOTtg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=a5RznZKuBD5rleqBpvISGIGD/utcC2So3KoRw6qd67ZQHVWbDlDRr0BeLV2Ec6Pzjl99hOXoLNYoIkGvVaMhzjx64rmu/08E+VbzCDTQLdRyFc7B0Z7CBoKLNr0wkDvO9/G7KO+jg64H6lY8maGkx3JNYKk3wHqHG3F2HORxzpfcD/XA3CMpM/wQAqw+ssP0IJQ8gQBRBPStgTeIkXq1okplTIsRAljjirPY7a/VIEqHg27eCyIcu5ZzEJZT6KC8vmEEtPKuMYzIe+6n2ky/A04ZkLhV7n09EaJMRlaQ60KhYys+vTQotwQodEC0du6rcGLOC41CLGXh/qiLjUjOwg== 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=LeOk1dh3gae3ohCB7ddWkVbGzizQQUG3MQcfl4XOMxE=; b=LiitjevoOTPd+rmW0ALNO4E9ba3I11n3dUkAWziuZ7phDzpNg5IHNC7E43tb39oz14yWLOprqUSvbZ0BlAE7+XJY2YxNVN1lMV3wZ3haGQJqXbV48x8ctclMsJqNXGQanfdNJdm0WdEYlki8R93Tz910zbOt4JgcIMJCA4tJoeXne5C1QiRO2RGazU+yG/GcHEwBQ9hvk+EEukBh9RZ6vDlVdDhpqCStJyzuwPsVyRftAjRrGmUlzCK0mV9OlhbR9uOQFCPOS5ND7Xh01DDv+bzAA4SbVZeJeLEPcmL6P5HYx0qZA8a9X7panjUniN00mcWCcTSAK73o7hRpFAI/ng== 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=LeOk1dh3gae3ohCB7ddWkVbGzizQQUG3MQcfl4XOMxE=; b=LVGTOTtgEnzzyQKsqeMKh3LOAZnHvlTuktwkN/vL/TWEV0rtmAaiYZnH0IDvYHKEQ+1Prae9chz3qGuU5l/fA38HCM+xk91RAG7MDEls3p76s0vogoxH+tS/piZ63YQ/Z3diuUGdfVYGpkmPzWd4+fS99GiLCAs/qOzp6mxH7a4= Received: from BN0PR04CA0188.namprd04.prod.outlook.com (2603:10b6:408:e9::13) by SA3PR12MB7808.namprd12.prod.outlook.com (2603:10b6:806:31b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.23; Fri, 9 May 2025 15:08:31 +0000 Received: from BL6PEPF0001AB4A.namprd04.prod.outlook.com (2603:10b6:408:e9:cafe::1a) by BN0PR04CA0188.outlook.office365.com (2603:10b6:408:e9::13) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8699.31 via Frontend Transport; Fri, 9 May 2025 15:08:31 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB4A.mail.protection.outlook.com (10.167.242.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8722.18 via Frontend Transport; Fri, 9 May 2025 15:08:30 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 9 May 2025 10:08:27 -0500 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 , Robert Richter Subject: [PATCH v6 14/14] cxl: Add a dev_dbg() when a decoder was added to a port Date: Fri, 9 May 2025 17:06:59 +0200 Message-ID: <20250509150700.2817697-15-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250509150700.2817697-1-rrichter@amd.com> References: <20250509150700.2817697-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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB4A:EE_|SA3PR12MB7808:EE_ X-MS-Office365-Filtering-Correlation-Id: c9ee568c-4a1d-4fe9-d148-08dd8f0b5c2c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|82310400026|36860700013|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?3Mm7UyNpYXVqfHb/k4GpAWPsS+GOIBHPfh3jcoxqv561W9/U/5arZvv/UWcE?= =?us-ascii?Q?Nr2U0wjJ002cXk8XumW6mJZ1YTULF23KK+rb4ESHIDzgKFgspfTcfG21uCgR?= =?us-ascii?Q?EmbpFIQYBD3zMQ+7/YWTYtqhWw20A7xp7byV30B1mj+yBhBQ5ycWJtGy6n6i?= =?us-ascii?Q?268TJqUIMDMWH9BXVM50CmZ15w7uzFgPdMM0SDpP41K2kcp9HAoAjgJxE0hx?= =?us-ascii?Q?M0FRSeVQlGpyytGIjBiHxJYU2iBBtOID/vVTYlMgHIabTSCZQ6H6saD5+nqr?= =?us-ascii?Q?eLrVZUSHu/oIsBTHPWApkH3qHh5I54/1csFwltO4g81zXymx8V3IazJn63jx?= =?us-ascii?Q?dPVAzrLXuYeRgCOzI6QlXvLodigzgQF7eTiJpK3qqgxyjD+1Nla40WgHqD5N?= =?us-ascii?Q?wJ/PRQbBzEp0pujvb7+4TTvIBLmsvdIbSJ7M3mvlyG41sTh6XcN1aEqhv4SM?= =?us-ascii?Q?g39sKExlaNavOKhqCTM44dmejTcf81kSreqM+8AMORwOINEKTsGiMEc+If3Q?= =?us-ascii?Q?eVJ2yaoDxPrlr+58zqvBpgNhdYzBrLBGJWie6xLFcfB/d8xlJNGvHW4enKyx?= =?us-ascii?Q?NsW6ilp5+heOgzRibgUiBnsFZW3lJn25YMJ3GLbVG8YQAnfYDjXQlivFXMY4?= =?us-ascii?Q?bQpjY9n0ParmxAky+WkoQxTIA83jibKRKrmkbYWwZyQ5XRmHT8FjfzKQ4llU?= =?us-ascii?Q?hCe7m1moOCqKb/OxbcM3fjsWCSVZxYUeOW4ehLiWah+YRkH0lWgrm4xbWr3C?= =?us-ascii?Q?ZBou/PAlqY0n5t4wby6o1TMwA5WI0ONM8RWmWLwTkautv2NcgcIfrujVjBPg?= =?us-ascii?Q?Zz4AJwvXWx+X6uBFyXPrfa/dxxBk8eYcS5j38QMtWd5/NZ6+Axlyhrg8p4ez?= =?us-ascii?Q?pB03d6dxxy5IJpyGg6cKhcgFsDB++JH7xDDeEkhfqMTi/sy3vJdaSsnpj0mw?= =?us-ascii?Q?uHpZHzT32C+gXoSb9Tytan87h4G3lMRrCyuhqfkOmLmmTmB8YIWn4Y3OBgie?= =?us-ascii?Q?538qUghA4HHg7g+YeRcNIymKk5bB54hBZrIt5LuXSgwETukEtXlzU8571dme?= =?us-ascii?Q?V/qM1etCWXXqHy5hhfMnk4gPOMeS5JfT429yTfIeO6nHZ6TgIj5gZoDXXzKw?= =?us-ascii?Q?2AN0OqFKmnsm/8VgGOyTbouBSeXkBM7kvFSX/sUdv+ZVfY0XrI0K0v2V9MAc?= =?us-ascii?Q?C4C/+QxbI/aLN7mKSG0Q9XyOsYMuS1T9jtGWhOJEM3i/GBFVgnvw8HpjV1iN?= =?us-ascii?Q?zYzDR3PDQKrbWbdPe5YmBt1lpZsasFermX28WXr5ajEjJIAHIJXRnbhPkpVD?= =?us-ascii?Q?gC6OyRJOgfTSvDVDtJ5DIo3PYvrhVbcjbKfC5d4hje0ujjta0zaiMhrYYgiP?= =?us-ascii?Q?BvY18Nctpy86hKz/gillPJveERi8tvLpmuYi/tgIvm2jP+33S1Tn8Es3KONt?= =?us-ascii?Q?tPX7a4UZTtO6Mxnmqe6Cj9SrRl9maKfJMTTRcH1IxgOu9FctV/dKCasQp1lU?= =?us-ascii?Q?+pGwB17wX7kOLox5rg99Q8Be2eoMJk0KLMb3?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(82310400026)(36860700013)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2025 15:08:30.9875 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c9ee568c-4a1d-4fe9-d148-08dd8f0b5c2c 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB4A.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7808 Content-Type: text/plain; charset="utf-8" Improve debugging by adding and unifying messages whenever a decoder was added to a port. It is especially useful to get the decoder mapping of the involved CXL host bridge or PCI device. This avoids a complex lookup of the decoder/port/device mappings in sysfs. Example log messages: cxl_acpi ACPI0017:00: decoder0.0 added to root0 cxl_acpi ACPI0017:00: decoder0.1 added to root0 ... pci0000:e0: decoder1.0 added to port1 pci0000:e0: decoder1.1 added to port1 ... cxl_mem mem0: decoder5.0 added to endpoint5 cxl_mem mem0: decoder5.1 added to endpoint5 Signed-off-by: Robert Richter Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang Reviewed-by: Alison Schofield Tested-by: Gregory Price Acked-by: Dan Williams --- drivers/cxl/acpi.c | 10 +++++++++- drivers/cxl/core/hdm.c | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index 4eac068a1803..587ad5289f7e 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -419,7 +419,15 @@ static int __cxl_parse_cfmws(struct acpi_cedt_cfmws *c= fmws, rc =3D cxl_decoder_add(cxld, target_map); if (rc) return rc; - return cxl_root_decoder_autoremove(dev, no_free_ptr(cxlrd)); + + rc =3D cxl_root_decoder_autoremove(dev, no_free_ptr(cxlrd)); + if (rc) + return rc; + + dev_dbg(root_port->dev.parent, "%s added to %s\n", + dev_name(&cxld->dev), dev_name(&root_port->dev)); + + return 0; } =20 static int cxl_parse_cfmws(union acpi_subtable_headers *header, void *arg, diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c index 70cae4ebf8a4..00c2de629a34 100644 --- a/drivers/cxl/core/hdm.c +++ b/drivers/cxl/core/hdm.c @@ -34,7 +34,8 @@ static int add_hdm_decoder(struct cxl_port *port, struct = cxl_decoder *cxld, if (rc) return rc; =20 - dev_dbg(&cxld->dev, "Added to port %s\n", dev_name(&port->dev)); + dev_dbg(port->uport_dev, "%s added to %s\n", + dev_name(&cxld->dev), dev_name(&port->dev)); =20 return 0; } --=20 2.39.5