From nobody Sun Feb 8 06:55:51 2026 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 6E47220E6EC; Mon, 28 Apr 2025 21:43:45 +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=1745876627; cv=fail; b=NjxIlzrEovOX93FqKv3tbOZwjT69GZYRNNM34qkQhzLnAmLS62i53F4tQBhtscFmTWUavqXK5p+MnrhnhIFWh5ye0bJ2EY4ldqhTKh5rmzuEbbQ4LJJFprDUjBd5qhMdZEJJGjvAyjZE3Zn7fQrYy1mA/9/f3gsZvmvzDSZtGFE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745876627; c=relaxed/simple; bh=mDFpznVzBzDQzNqPWSgOcNvLpjxeBaRJ4TfUZO1RjWI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sW77NxtLx4Qy9CxUJz6F9+ru/7zz/d3+A2x0MpkehqiuDQ0hpWl3u2wHG/gs7iqtrnieCFEgy/NIOQ5K8JzhE1Ua8G0lsyBuww6Ne3tY9PClWimGzqGcpnP3QMAcP/4ezkSDSz7UJ1N4A7hLmz+JSq6r/wwfpszbt+fT53o3SvU= 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=5B9/Zv3x; 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="5B9/Zv3x" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uAgVsh5CSoK6W66sVyj70idrYlPQl/s709f2NZf5N9Qvs09b4Emg6euji77QubIf7Q8N6YCRMIygMpP2CcHfwdbxKB1FrelNvCLvoj4qcIG58qB+nD3yP7n2xp/IJF2EyYXZ5fYrQkR3exQk12NwliVz2pSR5c8WGd4j6+idwyUbbkY7OyEdhk46z+rvyn6E7ETzETejD3AJK0BiDdnAhWljTkvq1pe+CcNI9iuSpZL6yEZqBR/TA1MlJWP+Y60Z6K/Oz1YdQlmmidpVIO79hvgA1XDGBC9SMuV/pugbEGpEK48CMxKQ+Yi+wwCtO5A5mG34rMjn9uS+tU/RbdVTHg== 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=Q9HFHJdXdCK48NlV9Ve8ZdukWSk5cjystT5AHZY50zc=; b=xYdbOVXIi/SJLdOroJ4i6uCh4RKp03HJoAI/o+uLZuO+9nllcqLoa7cDex3wc4Y/ptibA4V3egBzY4vn5TcioZkADmxx+PQw4BcLKBPklzqlfA3xSLRwNHKVd+cEWF9z8CsgmEC0DCfY9h7Sg9mU63vOKBVpbpjMDGdzZDJwQUOI79xIkAanXI4x37wdI8F3MJP7FXOGhxRFqHdq34WFtwI12wSoxqm0DXfPbU2Y/gI7uumEI9vcb5ZK+Ewty5AVAfE2sqN6H6QmL86ynGEAlvGsJFkmLaqSDDYYC23iPM8ow2tVh3bYyxxUK8tIMT/KlTGTi22LHOkkY0UvrhKG8w== 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=Q9HFHJdXdCK48NlV9Ve8ZdukWSk5cjystT5AHZY50zc=; b=5B9/Zv3xCaNaRsH0rWX1+zx8+TtTJdreysfCYOs9inCbUHKDCWJlnO5W9iR7yHcfNUk69I5fwXNGFcVjJJw5PVg7n/iXRsm/vze/Yw2FGnv4BgvByXLJx8KEHa++3ssMeyZcKWy2ouBf2DUmoXttYzh9OdSMHpKyJBHPGfHT8oM= Received: from BY3PR10CA0002.namprd10.prod.outlook.com (2603:10b6:a03:255::7) by IA1PR12MB9530.namprd12.prod.outlook.com (2603:10b6:208:593::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8678.31; Mon, 28 Apr 2025 21:43:39 +0000 Received: from MWH0EPF000989E5.namprd02.prod.outlook.com (2603:10b6:a03:255:cafe::5) by BY3PR10CA0002.outlook.office365.com (2603:10b6:a03:255::7) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.36 via Frontend Transport; Mon, 28 Apr 2025 21:43:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989E5.mail.protection.outlook.com (10.167.241.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8678.33 via Frontend Transport; Mon, 28 Apr 2025 21:43:38 +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; Mon, 28 Apr 2025 16:43: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 v5 01/14] cxl: Remove else after return Date: Mon, 28 Apr 2025 23:43:04 +0200 Message-ID: <20250428214318.1682212-2-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250428214318.1682212-1-rrichter@amd.com> References: <20250428214318.1682212-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: MWH0EPF000989E5:EE_|IA1PR12MB9530:EE_ X-MS-Office365-Filtering-Correlation-Id: 3dc846e9-776e-47b1-6d37-08dd869dbca4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700013|7416014|82310400026|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?mdHh5pDk7s+eErSAp4NrBOR4naPiPiWFSILbPPtJ3jyZ3XV/zfTgXqpD4Lmb?= =?us-ascii?Q?ijEg4haweDQUaqtcNoB+kJAWGAAPmO9n3fPh02DB3eNZotbHvw1FlcdvtCHy?= =?us-ascii?Q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NuT2RVZQyYAo6ls?= =?us-ascii?Q?lVZWky8QWcrFaXR/5QH8Kwf6BzI8BifdUSMXP4xNfj9JXjaS/cexIlAssLDk?= =?us-ascii?Q?Fmnlph7ORiaCbzezuCGpBKzemoWvAsGmEPiGQua40kP6EMgOspoSuh4NwL5q?= =?us-ascii?Q?/xjzpTaUN7Jv2QucJTJVAsJJmj2PGX5ttLhkEt1wbO+kQThcNT0nLhIkatx3?= =?us-ascii?Q?F+DNy89jNJMyMeiX+CGJfeehm9d25HQKeBZpUjh8xE2tqJRkEfUzdd32BCF6?= =?us-ascii?Q?DefRbblJDc6VTkNylqoiXH7PypKGVVmM1IOJOvir9Xuh9Xgklhl45n8E7wVH?= =?us-ascii?Q?L8N38Is1sKcEd42ImOYMBvhjtgPjiVJe21KbBcPKUi/+r83G8CFS2jl+V2Il?= =?us-ascii?Q?2WeebBnB5p9eW2qBxvoZKaxpZHj97p5J74kEi2jzpCqIwYJXqJVfhLvQuuwS?= =?us-ascii?Q?EWE+zWQmBnzYSSTfGrTVs1zTiziGZCVCd9zdzXOjkLOBk+yqqOroz+YiXKU4?= =?us-ascii?Q?4Ayuam37FPe4nQIQj2NmYM+gpq9PgEu2VXUb?= 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)(36860700013)(7416014)(82310400026)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2025 21:43:38.7819 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3dc846e9-776e-47b1-6d37-08dd869dbca4 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: MWH0EPF000989E5.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB9530 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 --- drivers/cxl/core/cdat.c | 2 +- drivers/cxl/core/pci.c | 3 ++- drivers/cxl/core/region.c | 4 +++- 3 files changed, 6 insertions(+), 3 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/pci.c b/drivers/cxl/core/pci.c index 96fecb799cbc..33c3bdd35b24 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..6bbe04a532e2 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -1940,7 +1940,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 Sun Feb 8 06:55:51 2026 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2060.outbound.protection.outlook.com [40.107.220.60]) (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 BDA952101B7; Mon, 28 Apr 2025 21:43:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745876629; cv=fail; b=hNAuH8PgPuLfxIqX9Z8b+8lQScaNWzxsXQh5r0VLKj1D7btoH799vqBXCzz0qguqK2SVy5jtj2OlhthrBnOwgfinvvS9JhotJbfmqspZnPA4ekD4NNcvkrOgPXaxjoMmihp/HB5hQjxss7YNeJOnp9LzO+/abIfI/oaKy5XjaVY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745876629; c=relaxed/simple; bh=AmJSccOiJ9QD+ArkYMtIs6l/h+EE24djVkLNpBq7EmA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DdTkZf355iEsqWBnQE1NI1eKDYWftUYWdL+RgXYXJjOunHrPGKrLHfnXssD4KYbDV0d+frGWZPg8wTL3QcFwZaKWk6FNGBy1grgAEmD2eMqrUan9idR5d1lOCxnBA2QGT9izfKb7yvqURZWNzc2sfiCOgThJG2DGKaKX6cqbiN4= 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=jSyMKGgN; arc=fail smtp.client-ip=40.107.220.60 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="jSyMKGgN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BbFImjIM2POgPjJ+s5vnIaclzQxZOAiwQuXTaSqeY+/quXidkw+cxyzVuzbrZOkD5ien/X2bbxzcoAT1Z4pqd+7o9S7MYIx1tG9gi2wlseeeP3996FHB+gR1Id12AaJQzhy+59Fs8I49RqHTmnxo7ndO4u9FDpL73m5/brl2rjNjuMSkwB4sn2LSQZIv6tYp0AIvKnAZDlTTFAINZXJyhTaEoIuHc7rZrDVaLv0s2Y5JenPWDVMhZ+CsIbrkaDcPkJaFIT6h6Dl8kqMfaTSVs+PaCmrySWgIgL3eZTafVFT1kLHl7M9R9gQlj3ut07/6gQZ+/qcIn+8XB/hmKhTO7w== 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=RgrwEtOF2c9IFK8ycvjLP1OoQMNUt3jeoc4SGZgCrxk=; b=YACmQvCi2NZiOpeGMgd/Tqk+r8o+jFHIBpuIHTsz6OyP4ergm4LCac/zI9srq9DV2f4UJHG+ZeZsllQyc267FpChagBgksT6VTPEOZsIir9v4iuzQO5xpC9UOYKkW6i7dSrXC0p7LiX4mLVYQ1/LATUMWF/XmZ9HCL7f3PcUh6JuyRYHxZzVW+MdPxJEu3qhOOZR9n1/cCFnQnn+6YCIEII3OVo0+ojVtnlVaHIim3i2rIOAnbmlViAQWfWHPzf2K1aGz7od+kCDOFtv0NvTaFeEyox4gSV4dLBKjy14f6oguIuwDMrVoYoUQLmtuKDFT1pP4b2FNBshZyI66oYu6w== 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=RgrwEtOF2c9IFK8ycvjLP1OoQMNUt3jeoc4SGZgCrxk=; b=jSyMKGgNeN9maAk5QW8aTnQ8+cyzdIT7hShBRtISyVJ2P1oZ4o7ZmI9oMU5KCIgtOr7q7Ma8G4fsFLDt10YkAJr0fIc2vMQY0k+wlMPbyHyvZZiOKM8sN7QuzolTAcXgDB/SzLMmN4Zr9GOXXQ0nfTLPnCOlck8b+37ncszkMso= Received: from BYAPR05CA0090.namprd05.prod.outlook.com (2603:10b6:a03:e0::31) by SN7PR12MB8002.namprd12.prod.outlook.com (2603:10b6:806:34b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8678.27; Mon, 28 Apr 2025 21:43:43 +0000 Received: from MWH0EPF000989E9.namprd02.prod.outlook.com (2603:10b6:a03:e0:cafe::e7) by BYAPR05CA0090.outlook.office365.com (2603:10b6:a03:e0::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.22 via Frontend Transport; Mon, 28 Apr 2025 21:43:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989E9.mail.protection.outlook.com (10.167.241.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8678.33 via Frontend Transport; Mon, 28 Apr 2025 21:43:42 +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; Mon, 28 Apr 2025 16:43:38 -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 v5 02/14] cxl/pci: Moving code in cxl_hdm_decode_init() Date: Mon, 28 Apr 2025 23:43:05 +0200 Message-ID: <20250428214318.1682212-3-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250428214318.1682212-1-rrichter@amd.com> References: <20250428214318.1682212-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: MWH0EPF000989E9:EE_|SN7PR12MB8002:EE_ X-MS-Office365-Filtering-Correlation-Id: b7391672-b265-47c3-e72b-08dd869dbecf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|7416014|82310400026|376014|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?zY2bs16ki4GYEN8X5HIHziuJO1WBeDV3mwaOsgwsCZpKOsO+Q8yH5AiuY+Ch?= =?us-ascii?Q?HI9VhcMD+UsSEsjBpdGf47A0ryN7Y5zBCOLgIB76vtZSSaQ/lDUtTciSeuNW?= =?us-ascii?Q?fXinRapSF7WGYSqIXwBGcLNBXhNgOZ7v3mS31Ex61AliLtwsNSSRIfgv5rLE?= =?us-ascii?Q?D6F5F9BNy849P34N2PgSoByQoPDC/euZUBB9oOP4LvFavMR+EKpz2XXfMTIb?= =?us-ascii?Q?UJpWpLgsBjSb9fRBHwoLhrki5n4UscoJnXWDCXYFxf2kOAcKBVpPdQ8znU2U?= =?us-ascii?Q?Sp+tKBPXi5qjYoFcOviaPjPfXo2a55JePu4hWTW8KKfnkDYlADn72onnBBii?= =?us-ascii?Q?KPrOB819B+mT6M/pRCxkelsqmzwpKXIHka/ZvcOxbJ0rjnfC0qbiDwP8h5qB?= =?us-ascii?Q?t2b3s3CEx/mKzrSG0+UoigqCuAgqWIs8mQ3Zu4qfaaQfmUMiQKGz5ML9ECp0?= =?us-ascii?Q?sKN+AVhAYaLtcEO61+V+1alAECmYwuOQUXU5ixmkkrVwh6Nm/af7Usg61/Fr?= =?us-ascii?Q?gr9O5PFMbx7DC08OrGCUh//hlduejUzutLrBGfEM7InhzU193sE3scUl7BB2?= =?us-ascii?Q?ZGWEUqMPiiIaji2yIXcn4tWxxieHWgX92sFrS33W+gDcEf/RiBBztpst8JeB?= =?us-ascii?Q?L1vWtpXu178byUOPfXvc77TfG8tzegwv2x58M8xbvC8Zc82bPJHi6K9pSehh?= =?us-ascii?Q?1I5k0bTBdMNc8IBDtC3pdQia5r6oQ4aaNh72nW6LpKT+lVRX2xMvRe1s0K4C?= =?us-ascii?Q?ylPTuwYorTgs7wa/Z87DQX62nOyulYyj9JW4SKAVaWSgK/TssWkkAuWkn4v2?= =?us-ascii?Q?H3yioSdZamXxTBGGbasNo0652zzXrU/DE/Ma06s9D7xpmmVoLZXy+F9T7cAj?= =?us-ascii?Q?8zrrg7WlEcVllDD4nrhk99Yh1mEUAE2DcgCvk7oT077Gc7ckwrCbzzcG5Y4L?= =?us-ascii?Q?v+WPs3Cr+2tR6O8xYHyU23oHvQ3FD1kOPYWo7pFgS30ljioSzeqP5nygVv4/?= =?us-ascii?Q?eWRi++nAkQ8dsROSYmvdvaq9fwdS6Iz+aiTajw9Npg8H3MyjJWij8cGdVPAZ?= =?us-ascii?Q?Fm54AnKE0XVmLACJEqAlAXoKPCMzlaHUhwIVCVHkPyd350ZxQWtQLvqG9726?= =?us-ascii?Q?8HMNNPFj1HWucq3L0C3C7iuWJH8xpEev8Vte6Zvcx3TT9cozkWGiAdOMRrx0?= =?us-ascii?Q?cuwrz8f8F7MXlMePbF5e8LDoKweK8CWmxyU9PdT4U4WPRRb+k/L+dtYpneRv?= =?us-ascii?Q?2NNFTVkU3HnO7o9Y6VqgqXC5jGlVNiRDLjz9+eTsXTSJjTq5+99c/cD3m4Tt?= =?us-ascii?Q?kD+u7cN1nT3v63j5Z83bPZxEgIkYweycEvCyhpLFhaoJCW626TUz4cQoZ7/R?= =?us-ascii?Q?Fd+zgOmbGL0QX5mk1ShIRI6RmkLI0m9OFaoP1J+SqtJhDeyBdEf1F3OqgmZC?= =?us-ascii?Q?FXYdM8wUT6xkL/zGgZopVp2VUHiQmoihelAtM71Cx5WpnrJ3conoQO2AdMk3?= =?us-ascii?Q?L1OVb0Zwz2Hbcoa9MPkyWoDrAL7tJWG3NIsH?= 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)(36860700013)(7416014)(82310400026)(376014)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2025 21:43:42.4215 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b7391672-b265-47c3-e72b-08dd869dbecf 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: MWH0EPF000989E9.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8002 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 Tested-by: Gregory Price Reviewed-by: Dave Jiang Reviewed-by: Jonathan Cameron --- 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 33c3bdd35b24..6386e84e51a4 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 Sun Feb 8 06:55:51 2026 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2056.outbound.protection.outlook.com [40.107.220.56]) (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 8F578211A3D; Mon, 28 Apr 2025 21:43:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745876632; cv=fail; b=YzMqIR2GZDn4faH+xLDTZKGQbJSZH7TieLkSHnVykRatuwPZTD/dCiYdQiPH/1Edlcjd8RdphMTRWxkXg9e/vpOPozUAv8FysqBcVVyToAXAAe0arCQCFLce1zoa1Gzyhh/7Or0cZ6eRvQGPMHqM/Q711aIS5qWu9IdHJdNNKSE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745876632; c=relaxed/simple; bh=xhBUp8nET9ppoakyWUBzHBaA6ntz6KsifpDpfw2il4Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=I/V/KYdfHOxjJ1Z2qkf1bJR4deWh1kYSPuXi3kP/pKOVhMOf7/bTSwoe9BXkeM2kZZmwiW1AEOr/Ce0AbfL54cS0sMYMGGyaBuey/IPM8mvkatXV1QZgDjdgJoXVoXPAkS4oOpETeTjrBE1zFvBUbUWO2e5iHc/5fp/lDrRa+RY= 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=JGIgtbK8; arc=fail smtp.client-ip=40.107.220.56 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="JGIgtbK8" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DndxzwRJrR/Vp+sqLEIaVtqDeXQU4QEBtFzXKxREQt+nzWOWCpP4TLbIF36LaLlKkm5Hdrcsz8dG3MX9VcjSr4a2ocLkHraux/c0S+hjH/6GhTb6cvwSJXtOuZehqH4sOgQx40g1rwk07YFr9zkFoRkj6U9P/bbmYbe3PIrRzw3eq3l1sGc1OhGvCpoT4iqhRkK+x8A/ahWoWKObvaiIbvnNZk0S0LgDNDHB+g2M5zFZ8jKcRUwCp6mQLNxKRYe9qnHxVdM7LlOHrwe+JJ6IZawJlBNSOeXdWSgd5zD937sTc82CHgEwuZ00lXV+eKvtaet62ZU9pmlj+4CezEF2iA== 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=wXoFh1cmutgh2xjo7yNx913plwwSQa1rFrtln0TUseY=; b=YIdaf8LuEDZUfaHNlWfW7WaguoZ3i8QSEB1c0jrfhi963bK0eW23gxx+yYJjfYLidsV5y357HXLJz+z3Fel5zi6Kj8nw/SE1SZdHlLSk2uZ24GJvcpFxSnEhhFECuRpsVwAuVvP+UgbdvXF8VO+I7PwBgS9OQ7kYEsOJJYhPxMLBYjgzjhR5UfqsSM+wr9W3+TSKpNJTAUIwzfXapfTu4rdXijrXlXoU5oZ4bJL6LwFfpWGTss8+ZJblM5PJnndtjkZ/+hp0WJWNVyK2FCrE+gAthCwwre20qrwd9YzkAFxcSZqC0ayTlaZB+75beGHOjL8b7xGDuVPBYcRvMhZvGw== 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=wXoFh1cmutgh2xjo7yNx913plwwSQa1rFrtln0TUseY=; b=JGIgtbK8roK59ghO0dZOMeV44z1eye17NoFzNlKX/q47MPc0I8MoBxpitVWRgAWwWn/H7HiIWOkw07z2+ljeUCIjlL9ayoGnVAN9Jl9enaalXK6/euQO9GzFRvsPyaLEcOZX0Dchz+Vu2iUXIZRL90+MM1YVaDblXwK+RePWrxM= Received: from MW4PR04CA0182.namprd04.prod.outlook.com (2603:10b6:303:86::7) by DS7PR12MB6072.namprd12.prod.outlook.com (2603:10b6:8:9c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8678.33; Mon, 28 Apr 2025 21:43:46 +0000 Received: from MWH0EPF000989E7.namprd02.prod.outlook.com (2603:10b6:303:86:cafe::7d) by MW4PR04CA0182.outlook.office365.com (2603:10b6:303:86::7) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.36 via Frontend Transport; Mon, 28 Apr 2025 21:43:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989E7.mail.protection.outlook.com (10.167.241.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8678.33 via Frontend Transport; Mon, 28 Apr 2025 21:43:46 +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; Mon, 28 Apr 2025 16:43:42 -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 v5 03/14] cxl/pci: Add comments to cxl_hdm_decode_init() Date: Mon, 28 Apr 2025 23:43:06 +0200 Message-ID: <20250428214318.1682212-4-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250428214318.1682212-1-rrichter@amd.com> References: <20250428214318.1682212-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: MWH0EPF000989E7:EE_|DS7PR12MB6072:EE_ X-MS-Office365-Filtering-Correlation-Id: 592b86bd-b559-4cfa-3647-08dd869dc10a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|7416014|1800799024|36860700013|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?mWsJyl/RTKtVDfdurR0XlBGuaIY1KsM80zcotcPCZRyIK2xBgfuGBZD89iew?= =?us-ascii?Q?QQmw7qDVLJLFBYj39gdAktBzOZh5Rv9s+y8cxK1HK50FiLFWjjggjSZi2+0p?= =?us-ascii?Q?jyTI/i5anH7ewZzQ12AfA9degU/CSzjMPJ+iXieMJ+VSYsTheonGOxdmYtxv?= =?us-ascii?Q?MC7Pg9My+3TYBQ27WRGIp/WsS2dSvXOWyyqcvhHW0vyYyfy+qOoVmdSHbbnM?= =?us-ascii?Q?ZLEdHaHltMUFKMsgATWXKuQVFNSfmD5UYGrBeH6KFVZX2EtQ+2axXGd9ZzjT?= =?us-ascii?Q?2auhqH9oWG1MHfIQe3ndJf6xV9qASEdwxJqV4OtslNd6NovocJeniZ40Ek7G?= =?us-ascii?Q?MUe4Zcaj00am7rJLJ3fnJ6yFIbE8YKjrZaBIM6FScC2ao0VLJFOApOez7+1t?= =?us-ascii?Q?IfiFLdRSLpS9KgCtH1twTG8h4OgeC+SlrCzyLbN8dEZHZ/nfZYgi0wdYOk8b?= =?us-ascii?Q?ZwP8YAuWZbTa3G9c/GPCxkSZDz74WD4XlYON8V3BwPnp9sR1vPgsac3Dg9HJ?= =?us-ascii?Q?iLOzDgBTYewrLH2dRFusj6Q8OKCHcVgLYPw7UN0BuDS+jh9/6AvvjA0Yoiiz?= =?us-ascii?Q?y6odicJaO6Kb8rIFWckJQo1A6qjDObwI9qo0RH2NpggwL8RMQcFsamZcdbOg?= =?us-ascii?Q?lhTZMvU4fcR9ZSBn8s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84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(376014)(7416014)(1800799024)(36860700013)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2025 21:43:46.1601 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 592b86bd-b559-4cfa-3647-08dd869dc10a 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: MWH0EPF000989E7.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6072 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 Tested-by: Gregory Price Reviewed-by: Dave Jiang --- 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 6386e84e51a4..80bfd8ca4f8d 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 Sun Feb 8 06:55:51 2026 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2085.outbound.protection.outlook.com [40.107.220.85]) (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 6DA7321322F; Mon, 28 Apr 2025 21:43:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745876636; cv=fail; b=FvZN/M1ag21om+r+R4scXRV3XNejcd3gI9325XTyNI8gDv6SDv13JhOq0wvMRdruAXHJnZzzUW7Xun+I0NdUzG/jL7OxkG/5gbdKF/6R76Pn3Os9gJNAlX2Igy0QkuFPVaTOeiSfKISxTaNa6gwtNkrcFx94Qs11JLOLZFsrAZs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745876636; c=relaxed/simple; bh=dA76GPQkGL5gtp+aLxEFSZNABClO5UBqLBuzgC9utOM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XV8oGkGIaksqbr0+KArLyfCeIcuDteceTRI1U/Mw3aWlVA5jRtmcyfswxt6Fq9uS34GuZtlm9/x1ojGY8B1Fe2RKJXza44RsWIfV4rXhGMNEWq9UP0VOIKikXo6Ht73HouIxu30MIeqKKrIqOgd2DIG5lBPYBUXUSS/kPJl9WYE= 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=rBOdA0oq; arc=fail smtp.client-ip=40.107.220.85 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="rBOdA0oq" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VH/K/zMBQppyqSmRk+ZRiJ6HhYU5e/9XlY8S/FrMlM38Z5PbTYb4yb1CpaJYVJYo+TUShtHAx0aUjWeK3yVmW7VoYqjBrgWRD5htHe0hFFdpunjUx4kto1OF5EYKytE2iM2aMFClkKm7YkbYW5Y72whOAx8NA+6kILwd63wGmeV5bRnDYqvOm1EWlXiGy7G9bYR3KPWzTOBJEh7gsTqMOBqZudY+NPKiy5uq0/p0NNWcNDZ1j8psJiS0QvO/8wM/NhTO8nqG3DOdeqMGaqyiSdF8pPbhyYjl7Z71seqNSZ0Q2yPrJ69IzAcjIG4Dk4vDMc5qKF/l961srqtMaRr13Q== 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=dAPrJ/XOJ497G4afTNY9T856wLA7xIIWtTRO9/CiB+4=; b=SNx4h/yJ3s+WYyD79XtJ6rsAJS4ktKwIAOpvXD1FsdTT0fDcCu0zZHb7TkMkaWFEvnBkP+bOAuOxx81TwiaqjVneJizHg3tq77MNVP4Dc3KO163kTR9kwZ4iMVhrPDIEMy/0dO02NLF7Lxmb2ggRum08CScS3J/QrYXfPPDlKreWXfJjyXPzWfQu4tw2hn/ZgicdFZC0yk3N63YjST3HHz+uwcKdIzv5g95eSWmGhyEwr7XYtD1QGMm8hiYpwO8o9PinixxJuEHeYz3pEEG7M7KcJ/Ui68jxhhzwcxNKSkOllx4NpXAzB8RtiyDSynABLeDUBYjexfwqSJRoQCxnkA== 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=dAPrJ/XOJ497G4afTNY9T856wLA7xIIWtTRO9/CiB+4=; b=rBOdA0oqSMK0gkm4kMfy8lMLUG/lToOOPt6sKMUgzirXEeUhgbS55GRkgtBJJ3UFr5yWy6gWwgkrlQyC009jUn8Wg/+6mX+YcW2NvxN2rIqMyn4UGoTQ8CUrCqP0zetjCM3+WGh5tUeDACuJpR3a4PRnenY/qpgIf5b0UWR1Y2Q= Received: from SJ0PR03CA0160.namprd03.prod.outlook.com (2603:10b6:a03:338::15) by DM4PR12MB8523.namprd12.prod.outlook.com (2603:10b6:8:18e::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8678.34; Mon, 28 Apr 2025 21:43:51 +0000 Received: from MWH0EPF000989EC.namprd02.prod.outlook.com (2603:10b6:a03:338:cafe::33) by SJ0PR03CA0160.outlook.office365.com (2603:10b6:a03:338::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.33 via Frontend Transport; Mon, 28 Apr 2025 21:43: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 MWH0EPF000989EC.mail.protection.outlook.com (10.167.241.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8678.33 via Frontend Transport; Mon, 28 Apr 2025 21:43:50 +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; Mon, 28 Apr 2025 16:43:46 -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 v5 04/14] cxl: Introduce parent_port_of() helper Date: Mon, 28 Apr 2025 23:43:07 +0200 Message-ID: <20250428214318.1682212-5-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250428214318.1682212-1-rrichter@amd.com> References: <20250428214318.1682212-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: MWH0EPF000989EC:EE_|DM4PR12MB8523:EE_ X-MS-Office365-Filtering-Correlation-Id: 2160e3e1-00a4-4b7c-6917-08dd869dc3ac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|1800799024|36860700013|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?WCiRy+u+vN0elDdiO15OozdRVC8u0z0FLxK8YL2gXobob7FwFgyba9YtVA2E?= =?us-ascii?Q?8ZXcSZVqaqMJUfNVbYsDeIXLA9r+yp5HPqEp1gXXURKibP5LbVGPhCNhAyJM?= =?us-ascii?Q?o8ZGvEvx/D90ya8YH5l1E68Inqj0kyJpeKfln6J5u22HyXH+RaSA1LPhfUXl?= =?us-ascii?Q?GD6srH7T13zQi6ebXf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-ascii?Q?PMUml8CUxYz5OGNZJKtC2NJrs2l+M4MyyvLXA19n3rbFB5CgpCkaerV2ux8a?= =?us-ascii?Q?iYYt7c+reI79vfgvPFt+5qvwmk6iO3X99x7QrneK9qWa2r41uQvE14Y+jYyM?= =?us-ascii?Q?TEE2gIkzErScsEXHQpQF6WEZxPbAJJ9vuw36DKN9e7jP8k0haZb2nqfEU6kS?= =?us-ascii?Q?s+CWn9pqLnjSht1SMR/suE6mnemkHoOu3O9Ifi0j4mxI6XUE0ZvEqSWO/2l0?= =?us-ascii?Q?JS+mSYxaZmKwfO20FjaDq45pRZiVyf12RV4KQ0xi8guWS20+2VhWEA1DnP4p?= =?us-ascii?Q?PGcyVSLshmkkcvMggTAy2DCo3dN13clxfG8lzPgbjXOZOqEn3Pg12vbfEh0f?= =?us-ascii?Q?TBo3PwMT0cl4GJCiu0+7D1KnaKRT+H/UQGKwxIcWTZHLHF1tT0ZhVlogoXge?= =?us-ascii?Q?diKeNKDfhZAkgt8g9Qm2AJ5RcIZxUcDxUaq5?= 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)(7416014)(82310400026)(1800799024)(36860700013)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2025 21:43:50.5748 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2160e3e1-00a4-4b7c-6917-08dd869dc3ac 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: MWH0EPF000989EC.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB8523 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 --- 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 0fd6646c1a2e..c9087515d743 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 6bbe04a532e2..e35209168c9c 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -1748,13 +1748,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) { @@ -1781,7 +1774,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 @@ -1861,7 +1854,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 be8a7dc77719..24cec16d02a6 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 Sun Feb 8 06:55:51 2026 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2085.outbound.protection.outlook.com [40.107.92.85]) (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 B5DC921129A; Mon, 28 Apr 2025 21:43:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745876640; cv=fail; b=raaLsHVSntg6ADkDTnDrWcH+v4Wh+jeTg6wlveIxtVLu1F+3lbNUgsdJ+yIAKddm9Iikz+88YgwWA9gJ3t2f/TSyY9i1/MtRZWstDos2hlrKynB6sJy7ndQ4yn6nD/r488r1Wtz6iQbqLGyjMSXAeEqeHLLApoOAs8piaGQnBww= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745876640; c=relaxed/simple; bh=VNKtQoLzoZiGEvZkxZ8tinJDjNVoPF1U3rU63RcRz0g=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EBQ5V1O4POIXId/jNolH9A7NsK/0uktVtgQZU7t5VvQ7xwMIaxbMjEitbt1egWWiZH5/bqmcKTeKMGrxLUbL+L6sv41OsLea0WalKqk35JD0Pahotdkq/niMT5AWt5XmxFn5+5A8fsvjag/TZA7kud9TASizXInCQxmIldpN2Xc= 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=VfaL1r8U; arc=fail smtp.client-ip=40.107.92.85 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="VfaL1r8U" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QqOy0S9U2CwpoQSlWroOQl4/0uhDLzJM2Xyh9P5kei+la/PbK9U4bRdhKih7KNWoGlvrsPfz81Ix/ZLJUmwSb0z52xH3CZ4zmxbqUSPQ88YWtefojmTdgvKElI0V+c7O57Z5wXcv63tbcSWvy2s1oNn0yRiE8/tD1gA82UacV8UiE3YVEKTfIHR/ig8BAUB6BBL7YKq3wmwofFzIOI/YJLAVyxVW6hzwzNjiDNYdJFH3X2Oocccs3lajWwm8TMkCyNeLBbZqBMiyY13w86FWpgjbWBAnp0fm2HLU+f0xL+HJJyK4vVxYTW1bfwyc8tnKPaQ9elJ/UkDysCReG67SQg== 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=jUUMx7IWo04izA0cAlKBBdrPd8Fki81nIButEmD15C8=; b=R3wauLkMCb7FY2EAbFT2hlp/ldW/AIgOyroAHFErCFirnxhHyrTm8anaJBNOHD88fBxcdase3/WC3vSvYLJz46gj5J6DXILoKkHfq5OwCSJfZ0WnnYqEyDmPZueQiXerSuq6ySOR0LuTowEH+hN9MVZI7C0U6cAlYTl6YRXnP2KdT5/OaR/l1XQstsu4+3Jur0Hb94jUhcYnuxnH3R6Z95g3pUx/+kv2aZJwHZZSWi4hHRS7z0OK550aUQI1b03eRcaKhBDVdXl/vx9PnnVFtYMFa4E2+3KlPZqLe0r5SqtI8gw1lGJJypLSWgelxczuIfAAWmSPz6f9vuFfw2+tDg== 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=jUUMx7IWo04izA0cAlKBBdrPd8Fki81nIButEmD15C8=; b=VfaL1r8UKBC03zvrOBzku9XrgizY5fE/0vnO3Z+Y1hbas1wANdma1mRys402YIinGqrCERnTiaqwtaiplqRoH6TCKpydOtNEi2lRii5MfY2ODnMN03MpexSEVuqCYxSJgc0RV02aWnnoFwze/LmWT5Fin3U+JNwTWXS6jrsYuRA= Received: from SJ0PR03CA0026.namprd03.prod.outlook.com (2603:10b6:a03:33a::31) by DS0PR12MB7770.namprd12.prod.outlook.com (2603:10b6:8:138::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8678.27; Mon, 28 Apr 2025 21:43:55 +0000 Received: from MWH0EPF000989EA.namprd02.prod.outlook.com (2603:10b6:a03:33a:cafe::d4) by SJ0PR03CA0026.outlook.office365.com (2603:10b6:a03:33a::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.36 via Frontend Transport; Mon, 28 Apr 2025 21:43:54 +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 MWH0EPF000989EA.mail.protection.outlook.com (10.167.241.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8678.33 via Frontend Transport; Mon, 28 Apr 2025 21:43:54 +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; Mon, 28 Apr 2025 16:43:50 -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 v5 05/14] cxl/region: Rename function to cxl_port_pick_region_decoder() Date: Mon, 28 Apr 2025 23:43:08 +0200 Message-ID: <20250428214318.1682212-6-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250428214318.1682212-1-rrichter@amd.com> References: <20250428214318.1682212-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: MWH0EPF000989EA:EE_|DS0PR12MB7770:EE_ X-MS-Office365-Filtering-Correlation-Id: a60f77aa-1595-480c-b3f0-08dd869dc5e2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?dq3JdjyflSCv+0nHlMZbtiJX/8p0uuzcIM6KQVrEdVUNbpI9T2StqUvNd9tI?= =?us-ascii?Q?DMEjguWnKgzW4z99eKvWxMTPLvl6b7zjSNshYGeh0YGLFGdU2PHQ58+jMoJA?= =?us-ascii?Q?ew/9pURVbpnobGHvc6edq6nRUy627pNC7VeMnUoV5Mxa8FM3Bt0i8K1G4AcZ?= =?us-ascii?Q?oA0bSMFlxPsqTvaS0WD/KPwmaz0pE0hvU5X/gw/1aWkL6c5+rimxgVe1d7e6?= =?us-ascii?Q?CH1e6mJmuj0KuvYhnJ8knbX3Hi3iayuUB0iQtFNuB9uScauCtI13IEDtk7MW?= =?us-ascii?Q?xoICKxIzByDpJmf/P39O5HKVD732OEkkCDTEzN99iL53BAEx+5cj9nTcoxHv?= =?us-ascii?Q?PZpDyIG46FCLsr3BGAzUqHWh1eaIigwTuRXNbUh8TFW8W7aiIb3VC+zNbs8q?= =?us-ascii?Q?8MRlyIIy498yvxnzx+LL7M2cg2xjBE8wZi0Ps1Yx6gD7C2Lq6HiDtBwtuf19?= =?us-ascii?Q?cdt8PF7uaZU7K1qDSRt/eoZMoBlnh3eWxBOAiVUR568JSb0TfOxE1i726jlB?= =?us-ascii?Q?KN1K7wEy5fTp5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Q?l7i9iydnrGhm0VNjF+htxP4uOQXk6roMHjQO8xTMOldI8gf3tqv7BrhrrQN+?= =?us-ascii?Q?8IjOZNR8bz2lGSttgIaLGlLjWOiqXYs5LYL9?= 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)(7416014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2025 21:43:54.2904 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a60f77aa-1595-480c-b3f0-08dd869dc5e2 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: MWH0EPF000989EA.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7770 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 Tested-by: Gregory Price Reviewed-by: Dave Jiang Reviewed-by: Fabio M. De Francesco --- drivers/cxl/core/region.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index e35209168c9c..e104035e0855 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -865,10 +865,25 @@ 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 for + * later recall when other endpoints might also be targets of the picked + * decoder. + */ 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 @@ -932,7 +947,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; } @@ -1020,7 +1035,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 Sun Feb 8 06:55:51 2026 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2085.outbound.protection.outlook.com [40.107.243.85]) (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 C23702135DD; Mon, 28 Apr 2025 21:44:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745876643; cv=fail; b=rILkqbMtZKCHp7Js76QWLC2Fr7M7DVnQzic2uaZgjNgr9dUXRMUqOfoMEI1kIhbuWYWEubYX5L5e6mvxxHRzmJQUIovVVZGQW2znyADHE+ytoDvJ3mfoQOIzNMIrOWOcYJBfy6LpNOZgr4wO6s4FZ+UM3ZhujMMcmd80vn4Qsz0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745876643; c=relaxed/simple; bh=T5iiKSvfCOTdtebElhE9QcBC+b/yo+nkYGEtWBABThA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=N0ly9AtdBxSGknbvfM8Dp5osKpHlhAKNDgzfOsNB13NO41sLMzNXEHqxusO+F8IjAoa6DFBX4DoCcOms9bygK1qyb8BXs1xuzJ9iu1n3WiT8KqXZ0wDpQAP67KWJCfPb11iA1xDUWv9A1j/YsaqTmrWO+NFKAuEHGwyH0wejrPw= 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=O3I2YO80; arc=fail smtp.client-ip=40.107.243.85 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="O3I2YO80" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oXELecGfn3DhMKgvinne7u7PfBsgapJ/iuJIalLZiU+0XWkS8ixQOWN3jMMM/8GCi3eooA/g05bhjZztevfe8eBiBhzlhGCxVdUsWplF4GHq1Ou8X8htGb77xoLsoDj8nyYpwykYylOckVkeXoVfGzpJno2nCtZfEdquF5671ODeWC047DiVqIsl3U8fciS3RxA8VYC83bZ+UuYrGX4BPMzyNQP+5rf0NA9I+sk1QShHKIALpilXoP25kZBtQbCXj87/A8U1VS/QLxITpuBXs4ZlVLxAcsfSOMSG36ZTvcM36qRzsSN5X83Udweqg3Iw5C+3bqhHbyyf2eLTbkN+3Q== 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=L5U/x81CQi74EKrZ7hZIcR0p77btfsbAjnHq74yXtmc=; b=bfAFGF3k3dHUPyHpi5LZiagWsV7YboEFxhfaREUxCU/HACU4L9eXIlgLSrD4iF1ysv4Efw3fTszzHiq5HfZPx8MQ/Ai0lkOouBz5uNo/JkiC32RujcQm+7ueWNZdwV83uAPr1u1lSd5pTAWTz82QL9G++qNOplS5MAf+1jRMHbbOKfWeEu+cGv63Re48dGC1fAJRW6TjOyyKdS1LR2pdLVY9CUD1R7Fe8a0rAZdjAMU+yRNDGKNlYacrIJMTy5ucEWbQFbcwZJ9RKXyOvSyh99w3jQ7G9sLbl2A5zpbBL/Bcaai5To9P6BxeaMcfKQO3mu0ifUXCNK/WzK9tQsq39w== 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=L5U/x81CQi74EKrZ7hZIcR0p77btfsbAjnHq74yXtmc=; b=O3I2YO80r4xPzqteucF5zdDi3j/uLLd0Avn9bJbmlytMrcwR5gBS2LIkAFl8cJFzJcUpnA8/TR3zdRLf2b7SdVRCn13vy8dfQpgbBMwLthjBkgVoTxGo3F7EuYzQCOCdo8rEPfIHsdOoOTLVJtoaabTcHGjfoZU6jn8JuFxOpYQ= Received: from BY3PR10CA0021.namprd10.prod.outlook.com (2603:10b6:a03:255::26) by IA1PR12MB6089.namprd12.prod.outlook.com (2603:10b6:208:3ef::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8678.31; Mon, 28 Apr 2025 21:43:58 +0000 Received: from MWH0EPF000989E5.namprd02.prod.outlook.com (2603:10b6:a03:255:cafe::47) by BY3PR10CA0021.outlook.office365.com (2603:10b6:a03:255::26) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.37 via Frontend Transport; Mon, 28 Apr 2025 21:43:58 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989E5.mail.protection.outlook.com (10.167.241.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8678.33 via Frontend Transport; Mon, 28 Apr 2025 21:43:58 +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; Mon, 28 Apr 2025 16:43:54 -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 v5 06/14] cxl/region: Avoid duplicate call of cxl_port_pick_region_decoder() Date: Mon, 28 Apr 2025 23:43:09 +0200 Message-ID: <20250428214318.1682212-7-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250428214318.1682212-1-rrichter@amd.com> References: <20250428214318.1682212-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: MWH0EPF000989E5:EE_|IA1PR12MB6089:EE_ X-MS-Office365-Filtering-Correlation-Id: 5c7e2380-e06b-4aa9-e953-08dd869dc818 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|7416014|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?zAk5v3s6ag/rPRt2oQ7vcFN4/X4NXJuu3mYwjJAzX/Q34+mJxvwkjvuQIKDb?= =?us-ascii?Q?BT4TdJU1ZwcdGo6WAtZ6PpHkQV/kfXeUd31nxsql9RCCt+tQJotWLS0Bv/zH?= =?us-ascii?Q?xXAB2kW7h5LSB48W+gJ38XEP1Tz0u0IcIwnMX6+f1Vv6RIN7fTL1UWF0i4Pa?= =?us-ascii?Q?bFWWzUKRDc5TR/lDnqZWLd+cAgRIvHLblIR2s1nayEvwK4+qBDaVXyVbdvND?= =?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7BcrqvnG/3dgAQGgBRrbkrqnVqBAs59nZli0dDCQ?= =?us-ascii?Q?p8kxtCa3Ba2cYVdM2BsMIF8QKaVejXHzH8a3Wqh38nO69u+OpFRGlP6mrcUw?= =?us-ascii?Q?O1N3E83HoEoRWaoox2RdWUhHs5/2545Bp52uIwuC1iVDJAKQui/C9uJjcAyt?= =?us-ascii?Q?TjKK6MHhykm/hu2GIMdriPSl30hoS1/oHPMqnRnoKWzmMDbtns1mjfB3Tfsw?= =?us-ascii?Q?Fz4AbhkwJzJbFiM1WWcgN/gewsFc7UIQBCWGHDmedK9gd8H8CdNBpcmAETpU?= =?us-ascii?Q?oSFY9DScPcCyWtgqLtUHpoaVm+hCNikQjX13w8szDALJ4c8QNwHIQgy9pHMK?= =?us-ascii?Q?L8OYZyMcSxobaYB5RyKR8xCRu8BGCEwAFgApj0O7uvxkHqCYqzCWImrhsbsv?= =?us-ascii?Q?0mLb/hI7Q+DELLimV+OvGzCVJ3z02Ae21W3B?= 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)(36860700013)(82310400026)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2025 21:43:58.0008 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5c7e2380-e06b-4aa9-e953-08dd869dc818 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: MWH0EPF000989E5.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6089 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 Tested-by: Gregory Price Reviewed-by: Dave Jiang Reviewed-by: Fabio M. De Francesco Reviewed-by: Jonathan Cameron --- 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 e104035e0855..fa3d50982d04 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -931,7 +931,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; @@ -945,9 +946,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; } @@ -1029,19 +1027,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), @@ -1132,7 +1122,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", @@ -1141,7 +1140,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 Sun Feb 8 06:55:51 2026 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2059.outbound.protection.outlook.com [40.107.223.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5010220F062; Mon, 28 Apr 2025 21:44:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745876650; cv=fail; b=AVOvrSD+vnbSdXgD326idLtqESZ/SHA3Vl63Arf0XXgmC4HloGLRNzO0KKvqehwFG3jeVvryssuL5JkfWmse3EIMmSRjISZYUkrxsbaQgs8pk2mLRaen2O1S94//aIor6T9zLXIijs12clf3PFQdBaLDuM/77mypju9aPzuA67E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745876650; c=relaxed/simple; bh=r87Omrazaokp5HoWoejoZi7GHpt3FSalP9MkTtyEkYU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=k5VOYFF2edBCrIRXo5mUq5+Vb52ibab+7RPv5bTG7zrt0VLvTMn3WaHE/eBt9esSNh+QWgndxrXzivfDv2f/+nBSu8n6Yg982jfavpSln7TtcbU4z/Yve/bWc4wJz4s8ShqG4/Ozn6RM3aW8Dog71d3OUTjpLabHafNR9fOoyOg= 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=ozGV/KpV; arc=fail smtp.client-ip=40.107.223.59 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="ozGV/KpV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GDeCHdosLx2kW35TyHeFVZ95UIZPjRKyRvdr++C+sD+aAp6COSpbPYyZCZaYvf6MWeDVH1zwe8HfqM/TMl+MT2Y9iFNzPPrnjbwgbsc/y3N/XPUOnZ+7sYI6jTzWVlozvsizMdChjyt4KoAILZ0HBYpiyILabcPyauAJU2vnRrMc0ycJ8pCf2kPuc/EzRMfUWfK9+NyUBwWgQS+clegLdfKPnWIg4KpKP/qMuwZOqMQE1bPB4k+7mWGRmHb/L1pNdKVcSkjf7R5aauGHcnilOlq3qUZRcD9GGUU7oYigt/o9I1TlkoleamAlfSYBAg+eSLt5EIQQs57fzBufZHvALA== 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=vTRYtTti9ZqFdSUDiiwfASrOVPMi6HqyiG0aQ19+IhM=; b=mjUXgt54+P00aLPjDbjnq4IUU5hs/fddp91+eti9q5qUSdnH+QdyRKEqrkWw/wpb6KbLERAOUrFTcH0QK1r5cb23lc2fOG7UZStsV20JZriuMmYAehzb5UpILscJ8kTpG9VBdX+UTR7icMZFi158QalrInp2+OZ7qu1SfAm5BLPSCTCX42/ptHhrYi7pWFwN0/wyenooYsyqezq6hmaJNVIp+7puYYccv+758mWPR4fLMgVEFnCd5eKI+r1vp1V13Vtnvq8FToIDMolpGUYjIvCKAtmkAzqo6Ltd1BAviCVlKg1V+57bBPBj+Jh7D2GAvVkD+JAP6kyJrzg99OpAvg== 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=vTRYtTti9ZqFdSUDiiwfASrOVPMi6HqyiG0aQ19+IhM=; b=ozGV/KpVqTWiE3ZoVfG6mG5C1ayMewM0JY9AtGWeKpPmYU/rkF3wdwj0knvnAC78O4GgcFKCy6HFd6UiQnAhiaOob2UOzRd9OHGq4Jnq0ZzkgOPvYqS7645f/2dm5ix8m70mj7/iuSQyL6JNBsYAuM1If8Kt0S9GKJe/HeIkVBM= Received: from BY3PR10CA0021.namprd10.prod.outlook.com (2603:10b6:a03:255::26) by MW5PR12MB5649.namprd12.prod.outlook.com (2603:10b6:303:19d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8678.34; Mon, 28 Apr 2025 21:44:02 +0000 Received: from MWH0EPF000989E5.namprd02.prod.outlook.com (2603:10b6:a03:255:cafe::7f) by BY3PR10CA0021.outlook.office365.com (2603:10b6:a03:255::26) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.37 via Frontend Transport; Mon, 28 Apr 2025 21:44:02 +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 MWH0EPF000989E5.mail.protection.outlook.com (10.167.241.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8678.33 via Frontend Transport; Mon, 28 Apr 2025 21:44:02 +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; Mon, 28 Apr 2025 16:43:58 -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 v5 07/14] cxl/region: Move find_cxl_root() to cxl_add_to_region() Date: Mon, 28 Apr 2025 23:43:10 +0200 Message-ID: <20250428214318.1682212-8-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250428214318.1682212-1-rrichter@amd.com> References: <20250428214318.1682212-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: MWH0EPF000989E5:EE_|MW5PR12MB5649:EE_ X-MS-Office365-Filtering-Correlation-Id: ccd5d3cc-2569-47a7-54fe-08dd869dcaa1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|1800799024|36860700013|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?CX1+zy4F4N5GoBbiRUZqX38xO0czpgV0R1q+gqw9j8FvVYlHf7rEYb/Wxv7J?= =?us-ascii?Q?7CFN/A6wy6Lr1eaVWkoPK2h3nS6YXE/syq8A8BAqDMXYEge6UnJPogEQlQ+f?= =?us-ascii?Q?aOF3EyLL8lKA/ID4O+16ZYXG8KZm4peFjMckTkeu0zopXX0KuSa/xVH08u39?= =?us-ascii?Q?6uVExnr/YNzeKTACLXjernq88DIbzFgJr/YgD0ozcD257nqyGQ8CUrhJA9+0?= =?us-ascii?Q?kIPIN44WmhzDBAcZqfJvj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=?us-ascii?Q?R5BS3oW3jtUHa5nf/Ior/WsAxSUBDQNFwqnqqRMLR8xMqOKBdQ9qmWSTvWyl?= =?us-ascii?Q?b9k6bzf/yi/4cx+jsugKamSX+8XKBMKtQm8uFHDgDGEB2HNLZrh+bba6Uz0y?= =?us-ascii?Q?Z3KTAZyi9twjc3inyg57jcMi7hWkfDS4BSXHKZ0K1gABElJbRdZCpYFbmnVu?= =?us-ascii?Q?Cn+H/2UQAT3WK1W4BJKvXl8G3jpWxg4OjZyNAK66F4xvk+/dTNW6Z4HbwENM?= =?us-ascii?Q?y6SLtBxLoQlo0IiroM46uiRQB2W+Xelw6SV1ZBhFL+5kjTCq2NqSyjKxuCj7?= =?us-ascii?Q?EkR7diK2tjdg8tRSPdDfBQ8nCBnbVEQeaxIxQVX7hApNO5eGbJDC6sSXtsv2?= =?us-ascii?Q?lT2c7haCEmgjfp9i8a7V1aW4CB5wCygPY6CP?= 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)(7416014)(82310400026)(1800799024)(36860700013)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2025 21:44:02.2508 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ccd5d3cc-2569-47a7-54fe-08dd869dcaa1 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: MWH0EPF000989E5.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR12MB5649 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 --- 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 fa3d50982d04..256d4dd631c5 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3385,9 +3385,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; @@ -3397,7 +3399,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 24cec16d02a6..960efcc60476 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 Sun Feb 8 06:55:51 2026 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2078.outbound.protection.outlook.com [40.107.243.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 36DFE21147C; Mon, 28 Apr 2025 21:44:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745876652; cv=fail; b=sAXun7Se6pHFipUHXxZYl2p9uglEKQ7S4rSmCKIncOU5dZHy2Cs4utPbP+iwpdtt97DnVJewfO1FOfBcgC0nDAe2lVfizInK3H1QKll4ofYFD6uJk6zYGWGNtEjrG5kCE+MpAwOywQZbeVrFUFpCWUe0z+mt8uxX9qDDw0CXLwI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745876652; c=relaxed/simple; bh=JgjiCycvwpo1sP2fDM3qbTIM6NT5cwNRfTnScdIvqSY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ETxChFczYbl15gak9A/ZIXc7NGfdjr0Nk6tPM7EWZg7B0lTjM4hpk7+6b2ZZ1/kX+9pUoAHlnwe3kMfgM4qm9tV0ovQnCwzXBFLkqIk5zJi/LeCfLDPxWRnRkcbSGdSP4E1fIjBp3led3QTS/zm5YuICTSLch8RDIHi8Zxf8iVw= 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=e3bhT5O8; arc=fail smtp.client-ip=40.107.243.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="e3bhT5O8" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qPsicUgrt8YaoVwd6oFKKo+fa/JhMQNsUet63L7mP2s1F5p5YSe0X6bUmx7joigUdPUvvlL3Q74RVSIeuADsxj75+Qhgh1NIhT3pYKdHNfLj6jBvaHLZUIMNoCwZuyj4BbitRvBH/2LNY5kAYQakE4ykxlgG1q7igFAgPTemVVok5w23BXherRm0W4o24PqWvJFnJFpAsnmLTqEAwwYTng0IPN44+p/1/WijuyYaeSKR2wX4eoRak8kYoPZOp8KFzncGmoImiZN4N22I0pedO7WIbZ1rg0/CXTx9bRp27xWJIdqInWaSr7nm7gS73ykkDb0YL1XrWeVzUOLnGPWEiQ== 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=3rJFfPT1Nf2V/qPwpmuxQ9z4wQnHoE/ofbScDZ4Fb8g=; b=Hn+byW7zWMTMSl1VYp//P0uwkr5x/PqCNr0H6o438vXsnfEGk4Itv6OxMnxZLqH2vjg05+bLatPs84B08E+tRrKjBOEi5DG5+M/A6PMi5sqCE6bF0ENlAEolCVdm7gEFP9Qvzg8BTFvUUbEYau5JDbYZrmKetfQBlXwrS58NbTwthZkl9fHN6AZUMsOdleJm0nVtwayLDTMKY8gw2eOCe5GZLPvqQGUrg9X9adqVf/o9X7TiXH3lv1i1oA5E/e5KSl6BCo+lTdZKxHVKez3sxJHm9xV3E7lkLIZnR//keleejZ3nyh5fLEs1ZMJyoCBlxxdN+i7zBMWd9mpmyPTOmg== 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=3rJFfPT1Nf2V/qPwpmuxQ9z4wQnHoE/ofbScDZ4Fb8g=; b=e3bhT5O8Pq8m0OXe0O8LJGpjTsZ0Xg01eR47HJjTVbsfm6iamyIXnKa0vPEUVTZ2QuD2IcuSXG5e3WbPI639B1IsfXb59VNcjMcVocBKy8y1e+w7unb09q7I0qa3eApfM3kC/uVcz/5t3vRv6qFTF4sFTYpN+P5fdpzGAdOXm/c= Received: from SJ0PR03CA0160.namprd03.prod.outlook.com (2603:10b6:a03:338::15) by CY5PR12MB6550.namprd12.prod.outlook.com (2603:10b6:930:42::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8678.34; Mon, 28 Apr 2025 21:44:08 +0000 Received: from MWH0EPF000989EC.namprd02.prod.outlook.com (2603:10b6:a03:338:cafe::f7) by SJ0PR03CA0160.outlook.office365.com (2603:10b6:a03:338::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.33 via Frontend Transport; Mon, 28 Apr 2025 21:44: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 MWH0EPF000989EC.mail.protection.outlook.com (10.167.241.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8678.33 via Frontend Transport; Mon, 28 Apr 2025 21:44: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; Mon, 28 Apr 2025 16:44:02 -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 v5 08/14] cxl/port: Replace put_cxl_root() by a cleanup helper Date: Mon, 28 Apr 2025 23:43:11 +0200 Message-ID: <20250428214318.1682212-9-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250428214318.1682212-1-rrichter@amd.com> References: <20250428214318.1682212-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: MWH0EPF000989EC:EE_|CY5PR12MB6550:EE_ X-MS-Office365-Filtering-Correlation-Id: 6bea1738-b076-49ca-f1c5-08dd869dcde2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ihhusdSEQZCaShc7klmoyKJS5wBACy8merbBja/WGyvB189uSOSSuEmnL4Hm?= =?us-ascii?Q?cik17WTGxeEf1UrTUzBbIw3FhKv2lWXYVDvaCg/lmbyDpUvdRhMiZJwepK5b?= =?us-ascii?Q?+BOk2kp7VFgGzEluAjHr0HOKT8Y3yUCR2V3bj17t1SCXF7rYr3pRrTtFiok9?= =?us-ascii?Q?0rxZezO7aTxqH8ABPxqfAKelNiZoF5SSWpWv6seFAqNb8qfjKeGkC3jWFj95?= =?us-ascii?Q?5agbIpEecDW9UmyuWke6+vPsw+nqEZYYCyHOkSEakx2FuVsBRHl7s8PpPNMF?= =?us-ascii?Q?1fbz1nFJUugo9fwN7xAoUhKxmJZm2Gw8yRvwCAeXF7FG2gpEw5retH51hLNC?= =?us-ascii?Q?lyuTMF1D8Sddhiusu6FvQ04irKvSrg3qQZm/mMponEX3q+np3BYZVnrH/Tc1?= =?us-ascii?Q?EyKutHY5htSnVvkYWOhchvJt+WtHaH1tu+jfIaPSSS0X0+9A5l/LnaNGy70O?= =?us-ascii?Q?7T2FKjL8m1KieIurR1WuwYR4QYn4WjJDpfnZ9qz8awF2Y92hbtxI84sLFJ8i?= =?us-ascii?Q?DW25LdOokjCfyuBBsk6vnhecmnC1XoYu5sYMlEnqbzVu5xtAhS02LoN6Xs6r?= =?us-ascii?Q?O+jPVLEQafTgVZg7X/1vRm+xMktRd76N6P6vQl4QWVH3VQRlfGZqlDJ6w0lP?= =?us-ascii?Q?0/oWYDKBoKeIXsmmyIygtuK+sRGg2pNTpGX01hgK6tffiXWcW+VXHg51bgzZ?= =?us-ascii?Q?QZ9DpjTP/u1Wy+wxCfalX1kexyY7RKfFDD3MgyLw7LD8QseHzdz7JeH1OfQX?= =?us-ascii?Q?tUNtDAEYguNcghQRC4retQCqX4jyPxCXC0N5CeSeg7d+lfRwawLv0QXZNTHj?= =?us-ascii?Q?nxuxnOwOZfqkdwr2ZINgJXKXsGfYm/ijkNgNbHM+vKtVcmwZUo6WbslBoG/b?= =?us-ascii?Q?GUjN0CCmEbivv9OOeMv0uOHYcb6xEX9hMUp004y7duLKNJXY5NTYwejCteWs?= =?us-ascii?Q?XaUZDBC+8rX1LFlcqxRi7xCcJOzfemXY3I9nTHcD5197NJC047w8LSw3DcO7?= =?us-ascii?Q?WtXtTnMD1XEsy79J2K+H4Yo10Eg0S2QYMXzU1Qp5m1hHgWB183g5OfaaSXn7?= =?us-ascii?Q?EVwZp5WoW2lJ0UogSv5L49QI6PZB8d//w8HVzGFjfcvRNvRIuBYxSq1kdAje?= =?us-ascii?Q?ejukoeXQA4EmDK6l1TOc7pxD/aOvIHL9OyDQ5i47WqEqZvw+IvvzrIcwz+SJ?= =?us-ascii?Q?NsnFlM44QJEpKmBEgb8fz2j/t91zKTHzZx2Z5HfIZHAD0vTFv7vzLni3Z4rb?= =?us-ascii?Q?vjLstdnds/rAP8d2k+lHP1A8Fv6rRn2dNST+IltQhDQj1M/pJs/SoFsfgd1N?= =?us-ascii?Q?jnmGyzAhsxrvolgmniWvaocz1GdD0t7GGjZYlXW9uvKOCUlpS4HG/Z/R6Jav?= =?us-ascii?Q?fCN/lY9GhT/ybt7awqF+0m2M87LPHUaufRZsZXFqPQwmb3H5p1Eo13Qg4dbZ?= =?us-ascii?Q?eOpdmOAtUn3OFgCxj4O8rAQMUvQ11IPsQurftPcl/CVX8ztZIDxw/jx0gn1m?= =?us-ascii?Q?oNX+9y/jpvf6HeJLqLaZ44dcZtNV/HyYIOHV?= 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)(7416014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2025 21:44:07.7140 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6bea1738-b076-49ca-f1c5-08dd869dcde2 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: MWH0EPF000989EC.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6550 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: Dave Jiang Reviewed-by: Fabio M. De Francesco Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron < Jonathan.Cameron@huawei.com> Reviewed-by: Jonathan Cameron --- 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 c9087515d743..e325f08aaf32 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 960efcc60476..ea06850ecaea 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 Sun Feb 8 06:55:51 2026 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2085.outbound.protection.outlook.com [40.107.243.85]) (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 03DC31B3934; Mon, 28 Apr 2025 21:44:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745876664; cv=fail; b=oIX8sz/huT3UcLvi4F+KF46BtZSJlLp4rBDwN2HO26yPkt4ntFSZfsRK0pmPY/oPrDEVbyAwRViLZin8ozQF39nmtU9Zb4jS5teo8engfrXbTZi7xtrC0g+tbiRt3/v9Om6EA2ildksANPXxbTEOA3xCDskDqhu7mW5NUg+l3Lo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745876664; c=relaxed/simple; bh=MI8mwOgHxYRW3OHmTuVQwaQ2DNUc1a+skDc9b8d4dX0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=D+ganqlGYbta3r2kbm6FhRd2eLKzkcn5MFk3Dp4r+Il88etkJl0ZpHJxL0ccSCdaobmvhR/oVbDWRs+1iO6BBm8UqABQmjpe8+x9Juq8Nyt2DRxY9lP9S9FoyUBX0yqwM0+/C1npL4jIgQPIUTNAlBZ4VqCKs8cl6u/z3jTk8Z0= 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=NSbMNLdt; arc=fail smtp.client-ip=40.107.243.85 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="NSbMNLdt" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=C32Sluy3mic5kU3C4HmVc/V/B9SE1KAZcknUIfIUAKn1jwWFNgNaxS6iIE3eij4gulEXcmDJ/sG7fk808/OLq5TKvmzKy4xE9Bg3ygMOI2oXw9SAVrWlcL4uFPC7QruHxtAMs67no/95IhwZp4eyNWRLmV+qwDnGzNMuMeoBfiysd1z1U36WxVl5b3vETIpI/sIJmoyoqKfdo6jthbi5AVhP3gAjClF6q1XCpBB7O5r0NCv0TJ2SumYRHYB4024DKyrzvvQbszd5t1nskMiZ/EWPhWGJPl5GTUrPrJJksYNzTLbMKzu7RJe6n2XE7eblpWjj+3ZkET7YjqLLFLrMSg== 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=C7XGyyxhtM7r/pgr7DHdDtSAOUhRElAzvOEIvHep3K8=; b=tIPLkJbYeikBmx+9K0oy5GlzP9wRBAB29WKpmi2tB16BEHu3KzbZrz5mtRhjkl313MvzayWG/h15KG1X1pqKpgcb6+djUOXm4E64WgWgRz6Qt16vUhPE9sw0QNte/tlBANPjs544yv5xnNXUpZI7+Ihr68TVdEl3584R9aJjtAklHDgRwbdwFQfQf1HWkdJvnuTu7HQQV4U0n2ZAO7/c5jS1TtMK856bhKhh5hBez79DYR6EJuyHPzp3gMPAOatt6jM/uYlS4DN8lpmMcqn7HRLzTkTDqxqhlDXZyfK2JBQ3muD5NJP8zTjXw2ptJdVawRuOF4udNOA9smlxCl/vLA== 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=C7XGyyxhtM7r/pgr7DHdDtSAOUhRElAzvOEIvHep3K8=; b=NSbMNLdtzjoQXDchOq6f0cbxiAlusAParJ3puFZnsNlfckXwLncAG3Qm4Oo/Neyypcn4XqTVbjGB2QshYc7fD9eeL1aQdhmJCKNNUnkyxnytslN7vhDbrGYZtwqr63W+Xwes1zhHlgEUG9w93Ms4+E7C5xOS2+iZwIN9XEKIG9U= Received: from BY1P220CA0026.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:5c3::17) by SJ0PR12MB7474.namprd12.prod.outlook.com (2603:10b6:a03:48d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8678.33; Mon, 28 Apr 2025 21:44:18 +0000 Received: from MWH0EPF000989E8.namprd02.prod.outlook.com (2603:10b6:a03:5c3:cafe::c5) by BY1P220CA0026.outlook.office365.com (2603:10b6:a03:5c3::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.41 via Frontend Transport; Mon, 28 Apr 2025 21:44:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989E8.mail.protection.outlook.com (10.167.241.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8678.33 via Frontend Transport; Mon, 28 Apr 2025 21:44:13 +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; Mon, 28 Apr 2025 16:44: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 v5 09/14] cxl/region: Factor out code to find the root decoder Date: Mon, 28 Apr 2025 23:43:12 +0200 Message-ID: <20250428214318.1682212-10-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250428214318.1682212-1-rrichter@amd.com> References: <20250428214318.1682212-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: MWH0EPF000989E8:EE_|SJ0PR12MB7474:EE_ X-MS-Office365-Filtering-Correlation-Id: 25119b82-3f25-468c-46b4-08dd869dd137 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|1800799024|36860700013|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?zSsLqEQ/1aykuhcV1PuVuzTHH/vecigvS0lpLXViRnJEapi+2aXy+1X7skj8?= =?us-ascii?Q?+Q8Ro+g19dSAcHVxTHn4DVbUXi297WTeqOep3ziCpJIYrPx7RwtY4a8ZnfoE?= =?us-ascii?Q?7YnKhFsL5FdR1JQLwzxmtpXjQFReJHoyBiQDTZg00L0sqPDdIpBRK5g3KKg0?= =?us-ascii?Q?VnJ9W3kC/vcnkZw81MJXAsWcn+NiwlR3m9aBNXzw2o1MWOnneWAqa/N0cODa?= =?us-ascii?Q?kCCTROQ0memLJ1Ru0eZoEQYQqWckIYKsG4NC3iNERgU37oQeP+W+1ulDTjF1?= =?us-ascii?Q?xaSkY6273+Rqwxs9uU34MU/F/FUzmnXBFgPBPJVrNgSLmhN6BfAhnVSOLw15?= =?us-ascii?Q?b9qPd5DmJULVS4kcWCgKGJf1nff8cS4KXc4kedhIKRhZZ6e4JYw9k92m3AnB?= =?us-ascii?Q?1uZD0cvmVKaxlDSe9FVnUSHL2fkWBJknbfxkWJqMvk9QKYOeuvT+2GSuHTbJ?= =?us-ascii?Q?OhjtS8dfJM5sgkyZjoooiMurF85Q9gMi6VBcIbdkSnafb5VLs8NUr7i85KTj?= =?us-ascii?Q?i1HK2UgDthWdAjqi3beVNq7HT1tfH7L+TcetW4hDsaVPX4ZDLvZkAO+sOO/v?= =?us-ascii?Q?WggI5IpYdpaMvSZv9/kB4u2reBGoGhjL2VPoZjI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USBrYj2ucFbofq?= 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)(7416014)(82310400026)(1800799024)(36860700013)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2025 21:44:13.2970 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 25119b82-3f25-468c-46b4-08dd869dd137 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: MWH0EPF000989E8.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB7474 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 --- 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 256d4dd631c5..0128dec80274 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3219,6 +3219,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; @@ -3387,29 +3410,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 @@ -3427,7 +3438,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 @@ -3448,8 +3459,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 ea06850ecaea..acfda0cf3f70 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 Sun Feb 8 06:55:51 2026 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2043.outbound.protection.outlook.com [40.107.100.43]) (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 6408320E706; Mon, 28 Apr 2025 21:44:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.43 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745876668; cv=fail; b=ZdHXVhThGlAro/6Ri2MF7uDtCDEu148Eyg07/m/llH6Dzrfsl4UKuKcVYv0Cu4VQtLBs5UP2f5GNiPHXT08+rPjMpmtPpa21J6sWRZ4zyYfSCiZ8/7sv+acpiEHoZkedYc+5DD6mgIr39o+iUg46WqWvdLuOv4xmlJysv9ldDKg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745876668; c=relaxed/simple; bh=MADQ+/YK7VPQijeSrfO8jcgaCOxsqTFp1CY+7cibaZc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=V+yeHBlO2VMUE5emd55toRw8MF0+camVQfA/rqGQ/NCFzwCskwTp4tzHssJRezJ8jjA+8VXuSpmyjclU48E1067xvvCbHWLcfNPaUPMbaNF+0qNGs75RH6yvSMvDV9rO4UkIYxRbxob1d4f57vXr/Q3t8sBJ3nVra1wfTnaG8nQ= 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=Uati5CWi; arc=fail smtp.client-ip=40.107.100.43 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="Uati5CWi" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=J1OQWlW9GcRXqu4Xz2hWunHRHNmjuMGTY2maxh2Zc2+NDiUHwORZYy5p367V+5AiQmRAz2p4DueQC8A+23loWPhBM60DpQY4tQQmiRII8RyUB13YHkjUxXKr8TPkC/KZ3eglKcdPQyxM9nsKxz7YFYkB3pKWeFr3FYP7gPKnC+3PTgcCwyxcY74Vo9e/bspkJDvGtPFmD/Qo/rzWEaN+26lfCsoXiBj7PAWcdxU2j58Q/ZYoDf/EI4YXrXNt4w0odeV9M/IgQLWVSP5nT6Cc/xRIsXclyyAKqzFDKm8Bxg6xMdnmzi+PMGroMkKhbsYsBnlkvVIIsFQNhW0kFrZwrg== 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=f9JPq43OINXqU5rnfDBVFG1eWXNONRDTDy0RDFSMUSQ=; b=ravuwxwjP2dIKjgTdDmdjUvW8OZ9LzJayXWqhXSF5rRgr+/mm8/jamsMfmZkQKkYDwHOfTxzjBL5nkjoxv0ayj/bl5HPum306FOJnzSlj8XGDW3PI3EYqs2MlEMqhTGXkQes33LcKRbuQLP/SuodaRbZaiQpW7qROjxzTN1ZOwa55iFAKTDafCwxfYPPK/8nvUu/IwGixEWJm+sonXoeYp3Bi1KuyF+m1YOS29RGPH8y2qmWIqz8HPvwUku0VRZg93Ml6ySHqN6UV8ftnEjAGibkJhtaGFL/3a/RtEhgCZGMG7SC/MuORoxFyn4trHRDlS0eJK9XEBjfbyiMGMdztg== 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=f9JPq43OINXqU5rnfDBVFG1eWXNONRDTDy0RDFSMUSQ=; b=Uati5CWiivtkp2YyXmibE/2+ZgJRFQ49zmBLM20c4l7QrFtDofgPWeK2VDLCHl85JjV6XBet/CL0fmWR22Uz3++L8MvBcw/ev+s1UlTb0eSX0kUwWSpNqnS3HTV1tUzkhWoAeUZzNtO3PMKlQ1OmTBe/2NfgM3k3jAAp4RBYrv8= Received: from MW4P220CA0028.NAMP220.PROD.OUTLOOK.COM (2603:10b6:303:115::33) by MN6PR12MB8567.namprd12.prod.outlook.com (2603:10b6:208:478::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8678.33; Mon, 28 Apr 2025 21:44:22 +0000 Received: from MWH0EPF000989EC.namprd02.prod.outlook.com (2603:10b6:303:115:cafe::f3) by MW4P220CA0028.outlook.office365.com (2603:10b6:303:115::33) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.40 via Frontend Transport; Mon, 28 Apr 2025 21:44:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989EC.mail.protection.outlook.com (10.167.241.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8678.33 via Frontend Transport; Mon, 28 Apr 2025 21:44:22 +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; Mon, 28 Apr 2025 16:44:13 -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 v5 10/14] cxl/region: Factor out code to find a root decoder's region Date: Mon, 28 Apr 2025 23:43:13 +0200 Message-ID: <20250428214318.1682212-11-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250428214318.1682212-1-rrichter@amd.com> References: <20250428214318.1682212-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: MWH0EPF000989EC:EE_|MN6PR12MB8567:EE_ X-MS-Office365-Filtering-Correlation-Id: 5e2b64c3-76f9-4fa1-6aea-08dd869dd694 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|7416014|376014|1800799024|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?n1EymnYHwFnn38elVfVtq3/GbRU0A8JPfMBQoeNfN4x2lHejybUtbnLkR32R?= =?us-ascii?Q?nCSUYpx4Phy1KkPjLKi/1dvA1HSLAP2B9DVsopPEGthHL/KujY/BZ8m8fyFG?= =?us-ascii?Q?j6btx6a8m1kIVL0HzCyY1BsDJWJxZLh5N5Mq2UU+Lhgm2cTh1Uai0fqSflEw?= =?us-ascii?Q?N3BfjJ9LTks1ouaNVcgz0BP6KNzKMLovonK4WXT7p0fptJ/iTHh2HKN3ZBZe?= =?us-ascii?Q?08rM72YuO7a/ygdyYzKF9S/yuyh8+6StE52tv2L6O989zsro6bBtkkpzezha?= =?us-ascii?Q?RldiYwINCWy7t+zr0DPqjuU39ghWwSCwy5l1kU2fThKYvKtNmkL6qiPD0lEd?= =?us-ascii?Q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93cPa?= =?us-ascii?Q?q+T2vGM5TZVAUn2+ZxA8atKXEb2lJEad+Y5utUwCYdbOZ1Bk/tWeZgjPIVlU?= =?us-ascii?Q?z0NfsDwSOoNytzLvAyzv7krHTJ4UY1v80WOERBS/vWBlPyBocckqJbYxq+9T?= =?us-ascii?Q?9+p9mnVH3CFcGFW9HKCpoZDAPyy/sw3GKxvthtSe3tYe1zAMli/zF65TH7wx?= =?us-ascii?Q?vy4zMjwNHo+XZfK9yx4V2RLmyP9c0q6eTuXVDssfRQ8IWIDrCVKZ8wDNByDO?= =?us-ascii?Q?XJIEplIlKxuQL7uiPq855uPIxQOmkk5nj5/N?= 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)(7416014)(376014)(1800799024)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2025 21:44:22.2978 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5e2b64c3-76f9-4fa1-6aea-08dd869dd694 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: MWH0EPF000989EC.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR12MB8567 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 --- 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 0128dec80274..a292d5c4c4a9 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3408,13 +3408,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 @@ -3427,13 +3439,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); @@ -3458,8 +3466,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 acfda0cf3f70..4565d8131c5f 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 Sun Feb 8 06:55:51 2026 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2065.outbound.protection.outlook.com [40.107.223.65]) (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 E4FD9214A61; Mon, 28 Apr 2025 21:44:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745876670; cv=fail; b=IDDA2QGVIDvwP1iQNbu8F62ImyJjdphtghTmbmu6ZsuAYxFPFcwyF7Zn8ZTdXps42shvLFdCViaGc/IB94HQtYabbCN1Fd/04fAob6bxujCf/ChyGpKN7ZGuohAcjdd4ED3QsdJkv3Qpa8eQhbbswyy7j6w5OdeEl8bp4Vt9G1M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745876670; c=relaxed/simple; bh=o2FYbs8K0XCEy1QTlBwcfYPirS0qM0ezh2DC35W1Bc0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UbwSMBO1qytwcyTq5PMJlWnWeiOyCo1FSZ+cqT1Xg4sfrgOvRadt1bMUz2QiWes6fEiuRev43OzbO/PXo+gWwe8sGGlvGLEGIWvPrvuSKgA7yKxX0lnEIjgwGJR0VtHYIyPDOE2j+yBTdp65HOyksyzr8ukp/pgzAYCN9MAsghg= 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=BYJs7Big; arc=fail smtp.client-ip=40.107.223.65 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="BYJs7Big" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RE6v8l4y1jCfZ2+B1joaicNwr2spafCbsJnfVSoLC2uF8EMJWg0wPbKW0p4ruxUepQRdvBENFiZS5fOQAjYAw1t50/nuAGwpvatYVqAVEAjVhTGE5poUa73M6qui0UfK0kbPbHevScWxhSZGTDCCchgWmf7CltomK9QDj2dbNtJZh4Zavs/ZtKjMssESLwQiFsjsPG0aOdjUKj8r5QR9aMhaifHOqXytTEKT6joxW3lNMzGGILbgJLPlUD/k4GiToeF8DEtC9ODQZk0kjKTSy42s0dz5vwpIWVd8mTC8iqtE60KFg4r02BKYp2Svm4idZ8krmCTOgA8YhU47Z+w9Dg== 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=US+TsgI/VGh0C3HSQl6f1nHZjbMhBcFdpqZWmRQdNi0=; b=tp7k0NQaaMn54fDFjMdJ4TNORif4Ci4bevSD6AVT3ctA6OKSJ0WyM+QznCaGXHEVshJ+elyeyDOHm5cFJ8munAdRnxhpR8e1R6dRHkMkOTuM3RmemkO2XUWbFA6d7gEcZrjqwiwMHKfQkAtlSa6HyXrCuOeilCq8Es8s8IhOHdD8QnOIAXS32W0qYchsi/1Zudp+NP3bp6FL03XzSIYN8DDS5f62hkNavgWTTdGIeYHpdZv2QWCDvfRAeFvPoH6+mX09auX9BeDoiUoU8qTv/KbYQXp2RILMlDjyvf+09+9bNH+HVQKWC/FUkx1LqNMM91OdlqBIDm8zsdgNHK5PXw== 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=US+TsgI/VGh0C3HSQl6f1nHZjbMhBcFdpqZWmRQdNi0=; b=BYJs7BigybUjlNJgUupaBOmli8M6+ooZkGmKeFqgBfYlK/cuV7p0UKA4yw+sH3Fj8V3s7vYqtJ0z5QHOonPwZ6KkbV5NYtrZ1rNNInUbsdNKoCU7dy4w7hnXHxvjptiXEm9wpxLoB+LG9TXb2KwmP62UclZGvOJDUkQMGCwmXGY= Received: from MW4P220CA0017.NAMP220.PROD.OUTLOOK.COM (2603:10b6:303:115::22) by IA1PR12MB7759.namprd12.prod.outlook.com (2603:10b6:208:420::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8678.33; Mon, 28 Apr 2025 21:44:25 +0000 Received: from MWH0EPF000989EC.namprd02.prod.outlook.com (2603:10b6:303:115:cafe::eb) by MW4P220CA0017.outlook.office365.com (2603:10b6:303:115::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.36 via Frontend Transport; Mon, 28 Apr 2025 21:44:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989EC.mail.protection.outlook.com (10.167.241.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8678.33 via Frontend Transport; Mon, 28 Apr 2025 21:44:24 +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; Mon, 28 Apr 2025 16:44:19 -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 v5 11/14] cxl/region: Add function to find a port's switch decoder by range Date: Mon, 28 Apr 2025 23:43:14 +0200 Message-ID: <20250428214318.1682212-12-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250428214318.1682212-1-rrichter@amd.com> References: <20250428214318.1682212-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: MWH0EPF000989EC:EE_|IA1PR12MB7759:EE_ X-MS-Office365-Filtering-Correlation-Id: 33bc4dca-fa9c-452c-38a4-08dd869dd80c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700013|7416014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Jw3fCDSi9+93yZuG4fdoVo0I5Bk2TwXEKlAIz1RSanEPo15eTK1lTBTSY7DO?= =?us-ascii?Q?sBqAxaePlKKFL1gqdfK8v+mU8MwavXF0VMAnu/cr3L1AujwU1sgiwSf/c+P+?= =?us-ascii?Q?JUDkHx68b/zsRyEd2cDO+bcgINRx77nE1lefxV6O6MmrZb7q/dmldUVEcYT0?= =?us-ascii?Q?Rpl2ja4YAzb5R4oqClcGCVjyk/immyFABN8xq0DESk7LLn2yd5rxsBwDrliT?= =?us-ascii?Q?jmtoho4LUnSJ2jzGlDCpU+oRO2iJc3SZVPShYBdKoqCOOZn8RiAVKFKbicUj?= =?us-ascii?Q?Ot3LUbZPhq3ry4cYc2WLkKNy4S4YJZUL7AWWyK5CH1Maskj30iO401FEOysO?= =?us-ascii?Q?/S5nvm0Clop0a47Z+s6XRAqLv33aTJ/4t7X2zjMJsqOt0dPQy3E19mv6Xnt1?= =?us-ascii?Q?MDDAgTDljDYpW5CJtlkH+XMDtvtXYO6R4w4MuRWvckpFoANFAOQq+o8UTG0h?= =?us-ascii?Q?+NTbiVfYbEu9wNObEQVwugOYAzl8NpJGfonN5GOctW9M9QIfSfYJfoL38iWx?= =?us-ascii?Q?mKFANBJKqsz0ipd3IORotxwPXdGZU3khZ9J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TdykVUFhbRMZZuvc+mKVNjHdmrZEuRPtjfey0DeJMr/xiMTgGR?= =?us-ascii?Q?O2yANyQHJXfMNpmiTNNVME06VrWcGuSFl9sj?= 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)(36860700013)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2025 21:44:24.7612 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 33bc4dca-fa9c-452c-38a4-08dd869dd80c 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: MWH0EPF000989EC.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7759 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 Tested-by: Gregory Price Reviewed-by: Fabio M. De Francesco --- 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 a292d5c4c4a9..ef5408301714 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3205,33 +3205,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), @@ -3239,7 +3245,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 Sun Feb 8 06:55:51 2026 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2063.outbound.protection.outlook.com [40.107.93.63]) (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 E9A48211A0C; Mon, 28 Apr 2025 21:44:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745876671; cv=fail; b=LIEx18B9JEYmdJvGXI1aqG4Qyxx/s1m9maGQ19Br9COcXsVmcVBsqEle5kSZaGqxeQqJ7W23CgsbI5IQMxRg6RD+f/cHoGGb/sqrU353kFCe/h2XDX8Bv4h/j8y0VRBe3QIkivX/HXBjpjDzH1P1ackTLdz2GVlpJr/r4Unf0Vk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745876671; c=relaxed/simple; bh=4CLf638OjMScY4W2CVrxy51HvsggIqw0ZZ0oZJI/x7k=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Dto1yiWkJfjr0Tsdq5UIfWUhtAEh8Gz9KyazQX4XNjmRWKbn8/a/dHCxDGYIsUmA4/9D5eq9mQAjbBoM6kruG1FGuAUQff/R7RgnJ3BFYuiLAUU81fm4DwDltcOnCdn21Hb6/8tTxwuokOp2vHi7l9myev5aUwauXy1EWSg3R9g= 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=tKphX1S3; arc=fail smtp.client-ip=40.107.93.63 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="tKphX1S3" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MdNm102kf6h+vg+gBzYGgePhjY2bEFtu2xffrPlo2gzwfrhwt4UlCD1vAbCpSFvuZRVY99WZWcKnj37q9yCGbT/LvQsvE1MuGuokBWuh5V4nOreMC6+tgAYmb0Sy1URb7/x7vvh12T+rvM3AZmBeERVSdlgGhSCjK72PWzAEO3a3kItasxfNXgjMsEQdehyOJ2HPJenqMYjGqJ1znRszhiC/lgE279izQhPVqyTwnrL51u3BuzvPYvfRATl1rGTfT6F5Skpt3X4NPXh9DjbAbn1WbNZgkUwFd7Mu0HEeRbos3VfV+csTVEUufZt7zhg/aD0+Zt8NfeNJ9aOcHUwlfg== 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=WznrfXShiLnY8YfHApKg4UKJgKOUc1LqdpZKx3qJjUo=; b=DN+hNyHi6zzmaIT2E8UhNx97mJjKw+1Ecs5NJbUSodWIlIUwjUGEgtelbbXlfpsnGLSlq6X+pPYAdC4gYxfdR500L0MqmUAD9YGBdFNNIEOq7VrnikSlLs1Vwpzxek0Jhr7bs19pOJ4FYnp9EB8poWzC/eUNW6Oq2OuhT4jZfdC7z/ogXMyZM8Wwtl0V0jORujQu3yZGT9fxKuaznj5NjMxzclUYW8/1FJN9CGbgf9ElErUw+igMy72Bk6pe3bIDE5dS1IL7eNdU9l5a/aQkgBSKRDqq1878Chx4adDqxqml9Ebe6tZtTukmvHMeCsCMmeJ5S6OrVmrWCDeSg/becw== 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=WznrfXShiLnY8YfHApKg4UKJgKOUc1LqdpZKx3qJjUo=; b=tKphX1S38FeBpqxBU8UTL4IDapzTZ4aTTMHT3yXnnpF1cvwOI/0ONa16dQ5jCTpBzqxtT9rf4Y/NHE08ZeKQnU+SKxijYqpDTZWJn++nKym9qfH6hFt1zz9Bd4XxGXSX2ZxFV6zEeApf8Vg6pWBIU5g6blspHPj6xIEclDEnXMY= Received: from BY1P220CA0014.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:59d::9) by CH2PR12MB4054.namprd12.prod.outlook.com (2603:10b6:610:a6::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8678.33; Mon, 28 Apr 2025 21:44:27 +0000 Received: from MWH0EPF000989EB.namprd02.prod.outlook.com (2603:10b6:a03:59d:cafe::4e) by BY1P220CA0014.outlook.office365.com (2603:10b6:a03:59d::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.41 via Frontend Transport; Mon, 28 Apr 2025 21:44:27 +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 MWH0EPF000989EB.mail.protection.outlook.com (10.167.241.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8678.33 via Frontend Transport; Mon, 28 Apr 2025 21:44: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; Mon, 28 Apr 2025 16:44: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 v5 12/14] cxl/region: Add a dev_warn() on registration failure Date: Mon, 28 Apr 2025 23:43:15 +0200 Message-ID: <20250428214318.1682212-13-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250428214318.1682212-1-rrichter@amd.com> References: <20250428214318.1682212-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: MWH0EPF000989EB:EE_|CH2PR12MB4054:EE_ X-MS-Office365-Filtering-Correlation-Id: 41e87d39-1766-4acc-cacb-08dd869dd95e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700013|7416014|82310400026|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?W8wItRkI2Q4MiSqhsoe4iYTNrB64mXZZKN8AoFXePh2vxlSvknC41O1Ya132?= =?us-ascii?Q?V6rAPZgMzhdlKi/HKf+lXKMtghHXA8zYjqPP0L69r/bZ6i0WmtG3ejh6H1DG?= =?us-ascii?Q?bVOtaQZcKSybMM0RYYWWpaAKGQKr+vAK7NHL/iwVomSz84eFEqlbJtQzJn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ea1AsdeEq00p/6Qx/h2b8OyHK7dpY6+SVMGMHg?= =?us-ascii?Q?Pj/uZowkqPkgPyT+/otWggCsJeDpwWJbUHXH4xKZBMVCB6JnAniZp8xfsKyz?= =?us-ascii?Q?+0hN4RWILTx6fWxHsG/5KLHUf0aOhCHMdkDy1yO0TbAu3VdLGUQ/yIgq9kvq?= =?us-ascii?Q?88LlFWWuOuplLoyGwP4YbGUPxEetVoWiQ6Lm7oYFKfyeWYt8NZDlBM33BNqq?= =?us-ascii?Q?X3cN40rYHDwu4rLvyv2f8A9gLluyPkJhnsi3rsAruAhhG54VN6wxyQCRLrs8?= =?us-ascii?Q?3BD7YXBIbkx3YZPrz7nxR58AwqrqDva2xSO9rscMEBS6SQ6LrI/ZrwfNEu47?= =?us-ascii?Q?mOhtZh3aHRJwcLxSdFqdwStKPa4sZ1WWi4WPpHyBzbL8atnqI1thiEoAo/3e?= =?us-ascii?Q?5OcNGetIVyeGKIFtE4B8cVm4H7fMe9A1D4X3eHtbfS5s10nUI/49p0qLqWAY?= =?us-ascii?Q?yL4GKBmzUQq+dAeuL02JZ5tJksGXaUhj888O?= 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)(36860700013)(7416014)(82310400026)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2025 21:44:26.9795 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 41e87d39-1766-4acc-cacb-08dd869dd95e 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: MWH0EPF000989EB.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4054 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 --- 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 ef5408301714..560c447d8136 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -2169,6 +2169,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 Sun Feb 8 06:55:51 2026 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2080.outbound.protection.outlook.com [40.107.92.80]) (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 70275215180; Mon, 28 Apr 2025 21:44:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745876675; cv=fail; b=e8In4Cewke12oyGDtT7RVrn+aqSWMkCiW8ggzfpXRm6ui1uOpR3+LatOaCkaZyyCuatmBZyiL0MgOUirhnIg3klJY8dzC34hN6Sf+Uo++/3pP/le4fzanLCGURknZUoCqK7enOyec+Ri27wlKJZMnv3fFBcMwjF3SJkvyFzvwGw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745876675; c=relaxed/simple; bh=YAIuaIHC+eZnIeZOcmlAMXekZv1hF8IDJg84RvYkDaI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gB0qa0zRhHNA2kROyZUaHNDR2j25QUREvkATpBDjHQE/i+hi1uJiuaiZQqcwtSVp4yv9DMIj2v20c1SfJocbBFZsYrOfCIsW3eGYRCnmWN4UjuaOmCKhmMQf+WwU4L/wSUOqjc8zLaLiEyTs5iMi/L6PfUE/pCd1b9j+xFaT5Zg= 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=KT5saur2; arc=fail smtp.client-ip=40.107.92.80 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="KT5saur2" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=R4DnqtjiDkJhLK6oXsTBGsZg2nC71gr7dMjtOFxtP4O5GLbh4cX9ZxA2FDKFAEU7RNnukJBrICFSaah+EiRBn0Rl5NwMkBidt1wtK6IjiqcilIaf7a5OtyWqe7093FlM1XjZwk2je9mmcRwmY0xVJmtotV63wZQS0a5H1H+hNK+zGVlxTUX8dZPe+EeFwtfRAWzA64q3cu0jof+o4X8rjaxSgLjFqBtjpVzfbr8WvYBz6mDOBOzqWf/4JOfZsP8Rw5LKwzRiaidj9grO6AOISS9xv19GPqXtcjWUHetWkaGkbaCp0zO1iYYYw7pVyJjS0fHnHslGQDwE4uSpm8tbbg== 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=mLcK/3lt3qYGPt2ywuHFeZ5UvHGiNxWomEj2NJbyaDE=; b=H+s7ZaumgeiIJ/8iSle5DRfsqPWeWI+ofeDxXlvcfa6J6Pki3ZxqIBtbhN6YPamcwuV9x2/h/Eew0S8AbesKqw+LkTtUUWKi99ixJumIXflUWY1igHHVkXckolVaE6bcUxfU0iyKr58tFqJUz3m6b3EdaykJ9iQiJ6rzr3wo5+b5zL5jzte5CjG+ERm5pMN/tGQQTIMmjSxDXDcQ2Ht7IFBCZ60IVqW4pDfFh1pSyJmPro/OecUCpg2yRt8/4msf2fGKIka+pknaJoDaRXIYmFlPWzuM/qkko+jZSHP6diUjrnx2JOSImFzC8tX1DWiFLuKeQ28KF6GnuX6OFL3y5Q== 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=mLcK/3lt3qYGPt2ywuHFeZ5UvHGiNxWomEj2NJbyaDE=; b=KT5saur2hYbFM6Al9LQ/i+IvcYMXZUBUDMlpNpFKl0qdIuWCSmJicYOIOUAJe6L9h3dS8Owsc7Z4mFOXjoPC5YtBKuOYK+S8lcaBM3k9Ha/Nc/tv8j2cpVGA5cDm/PkP0VRS8bwo7jQVajQfm9odNpax/9ASzg8kKowivp1+ERs= Received: from BYAPR05CA0075.namprd05.prod.outlook.com (2603:10b6:a03:e0::16) by PH7PR12MB5733.namprd12.prod.outlook.com (2603:10b6:510:1e0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8678.33; Mon, 28 Apr 2025 21:44:30 +0000 Received: from MWH0EPF000989E9.namprd02.prod.outlook.com (2603:10b6:a03:e0:cafe::c7) by BYAPR05CA0075.outlook.office365.com (2603:10b6:a03:e0::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.35 via Frontend Transport; Mon, 28 Apr 2025 21:44:30 +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 MWH0EPF000989E9.mail.protection.outlook.com (10.167.241.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8678.33 via Frontend Transport; Mon, 28 Apr 2025 21:44: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; Mon, 28 Apr 2025 16:44: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 v5 13/14] cxl/region: Add a dev_err() on missing target list entries Date: Mon, 28 Apr 2025 23:43:16 +0200 Message-ID: <20250428214318.1682212-14-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250428214318.1682212-1-rrichter@amd.com> References: <20250428214318.1682212-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: MWH0EPF000989E9:EE_|PH7PR12MB5733:EE_ X-MS-Office365-Filtering-Correlation-Id: db5a8c51-f675-48ab-3c4e-08dd869ddb7d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700013|376014|7416014|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?KgF1ZZNRAe8XWlvBeW2VCeTRohJrw4B2WJt/6wRsKoggJteElbNe1foaZb/u?= =?us-ascii?Q?MhwHcP3sWJoLOt+v3Gqx+g1tHnC8s2zhOzNzgDuhsoMwp4vcZ+EaUH1Crecn?= =?us-ascii?Q?XtA/qPdR835r4FEbMrpvVyU7AE9Uz53JxQG4q195emq1a48XgOorQJqJL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kjFp1sABYH9OZaSdVDFNkUjFNZy7l0x0Kq?= =?us-ascii?Q?XMwKDhKIS/DSgEa2fZPB06maUZtz120DB3EG6P1WdxpGkj5nosSKLM0QnAgt?= =?us-ascii?Q?VpsbNJvJOhCbv99afKaigVyT3SytVtUQjJ1+lTG69NrU9bIyjDAuXVSCkzDf?= =?us-ascii?Q?5pW+uq2JSSAewQCt8I3a+aEgVnx0WJte9R1BDNFf+WsaTCnL6pqL+GlWqVx1?= =?us-ascii?Q?/jrTmXjYyJFLUcQwWVI6PMSLKlVQ7PETnvR3lXeBfXxs4GMvIlvhGyh97WhO?= =?us-ascii?Q?3ton4sXS55dQxftuWbs+lUdUgANd8SzOizEYZEFWieBVyEiTHuxVbJuNAkj4?= =?us-ascii?Q?959hJ4A4ZKVUN2yQbynORHhCu+hCQ/7y3z5s9tUiPBxrhYhTqiF5Hfjzg/eO?= =?us-ascii?Q?iLNPLrW1BGPFVKJLeajCv17sIb+GBo+JKblXzy2d/6QaKOUJlGpceERTw5nP?= =?us-ascii?Q?Ve/ZteSqBw/H8Su3C5hCg0RWjXkFS7xgR6jt?= 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)(1800799024)(36860700013)(376014)(7416014)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2025 21:44:30.5347 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: db5a8c51-f675-48ab-3c4e-08dd869ddb7d 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: MWH0EPF000989E9.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5733 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 --- 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 560c447d8136..1d06295c7eda 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -1812,6 +1812,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 Sun Feb 8 06:55:51 2026 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2058.outbound.protection.outlook.com [40.107.243.58]) (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 DB18E215791; Mon, 28 Apr 2025 21:44:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745876679; cv=fail; b=l5v6AuOsicO5A9S4AE7/rTaYJBXoGnsVf2h6WHl9PXGQnFZHbyh295e8a+ekPpQETOvzVIqPqkH0/XGmXlsbFvG0y0gYKMC/sSeNJVEobbLAWXSFHRrxNm6z6/x1P28gnjSEt0hKWMY/J9T3EclBJ1Qs1vs4mx433lHmoUEAnx8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745876679; c=relaxed/simple; bh=Hk6Rzs9bsj0Xb6iJO+CzutYyfbPbYyDlx66+OL2Ye1Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=c69IdO9cVsnez3NFad5OHP5iNplDxFCKZsLLOdwDhX6EKjyTBNdmS/qCYPWwBWEuB/0H9V2zuAKUuVg/8yIGBMojtRAgfHqtSFdes7/GGja0Td8vqXGN4QpUxOie+4hDhxFxHkByjMJ2NvaTTFYLUKul8n35mCpOVNA9oeTNmaU= 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=AIOBKXjd; arc=fail smtp.client-ip=40.107.243.58 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="AIOBKXjd" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=I2iVKDnERXxNP7gKTr1Wu3fNEPZf5O+BAnR4FN4Hfx+Q0CK+V6EUrJlfHVi+o31d+bD9+qlcFSni4XiO1fvaVUdXKe3w/81qjFnz3MCxrn27CXZmaelZJxxeJFNbArfRF+UiVV9mUopGpvUH9s8qs+lCzSG56UFwZbuSZxxHQWLw9ygJxXZ6Hhe+iLDn4oT2sDob4LfjZQaBmPgopP+PxL+hAWQe2ue99B7JGQ+8AS5wzOswBHdhXH4LkKxeXO6u4rhOiVJ9rafAfiA9dayBhWPzvOjWFJLvohikPafnZ2UcXTMq1tFUKrDGG7SEH2HF+v7MttGUkeaHJ8i+gQEuOg== 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=yoUmLvbjBlJcptC7U6uZkzLDyzKwoK98b+0yM/CFpGpzIxypUAyi0SwVWH+leW20MvNlQn74g9KRBQpGqDTX3tM+bwMHsBJqI3y0vIBCoCMkrL7/+VFN1RRJNjRkDeUisJFmtsA/ZW0rOdUCT2/rmHAQVIs6bVa/MAZoRxngp56y6DMOCZ4CzQ81IYuEOdOKy2pSQvFpWApXUimy1UV1FLcsTGTObg+EzrsLhCdj8yeuHeQZgC4pAhtAzOZ+HN3i0t+nC4Pwb+PAhH/BWeYrmDuA3Vfd6FCCSHBa8+SXF7C6uj0qyibHO7MJlJ/1MgAAgXRQ/eFqzKmfZivBaRtRuQ== 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=AIOBKXjdvZ7xD2trKyBn22OOvf3sWmTW0FXlxCamrJ4omPJltPjBjFFco9t+sFsm8q7kbg3hvXEr9EIMFOnKb0F8nWqlpR3DD/D3C57nKNgoueifI/yN/E/sVbE/OnfJDwXNm+VeTfj8S4mrFY6eXPrCPkc+Kt5ktxUiJIK3M1Y= Received: from BYAPR05CA0082.namprd05.prod.outlook.com (2603:10b6:a03:e0::23) by DM4PR12MB7621.namprd12.prod.outlook.com (2603:10b6:8:10a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8678.33; Mon, 28 Apr 2025 21:44:34 +0000 Received: from MWH0EPF000989E9.namprd02.prod.outlook.com (2603:10b6:a03:e0:cafe::29) by BYAPR05CA0082.outlook.office365.com (2603:10b6:a03:e0::23) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8655.18 via Frontend Transport; Mon, 28 Apr 2025 21:44:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989E9.mail.protection.outlook.com (10.167.241.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8678.33 via Frontend Transport; Mon, 28 Apr 2025 21:44:34 +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; Mon, 28 Apr 2025 16:44:30 -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 v5 14/14] cxl: Add a dev_dbg() when a decoder was added to a port Date: Mon, 28 Apr 2025 23:43:17 +0200 Message-ID: <20250428214318.1682212-15-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250428214318.1682212-1-rrichter@amd.com> References: <20250428214318.1682212-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: MWH0EPF000989E9:EE_|DM4PR12MB7621:EE_ X-MS-Office365-Filtering-Correlation-Id: 29caada3-4867-4865-5a8d-08dd869dddc6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700013|7416014|82310400026|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?XvkhtCldDHgZQMBses3IYexQ6ULBVMl5qhHH38xbhjkT2IqlivN7MRT1sZfd?= =?us-ascii?Q?IdZ9FnlK9C6sRMxb/Bh+KU159WXQrviihhg1O9UDhgMvmdqQCqZTOrx0fRlq?= =?us-ascii?Q?xthN5mCj1uc34VJZyG+u16DjxXd7ZEbJDvLehgnHAPEAPC48RUPan0y++rBv?= =?us-ascii?Q?dEcutVc0WHgwJr1a18jf2yZ4uhcIpjAS0vyFPxsOYAVb7ZepQ5H6LVliQW5C?= =?us-ascii?Q?caGRcnF2kcXnnk011DXgQIgP7EuuvZPTLgPrHrN8exm1DZDOP4Q4R6Q9Jupg?= =?us-ascii?Q?M4EvkPGT1F/l9RJ7Vn8xoTyuNC3FysAaW/QcOBcsR+ai/rzYOd3x7Lg2DKeT?= =?us-ascii?Q?VZW94HyUeqrqOHUeN7tg3ctjH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us-ascii?Q?335B2bpkprqghX/pbla5h/udGt2+0khfw3pHHHYHm+FKF1OmaBHlNUM8P361?= =?us-ascii?Q?pbgdncSmImwdYNWux3PSlVnxa30+rBu3XCqHTt8Ipa7G/PYydiO7sRdl0j/f?= =?us-ascii?Q?s6HD9lLUIt4j85Lj3QMn7y+znR19eS2Yk3Q++WnAkZ1O3urcvGjlnFSwQNlL?= =?us-ascii?Q?rljlf2uGnUYRRKcdaY5WtGC4J8UukWFjArVdzIx1xAwIAXgOnf23Op9U4BfT?= =?us-ascii?Q?8emn7j5z8JzpZnB//eJ1KBfaYUl/R0ISIfA1?= 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)(36860700013)(7416014)(82310400026)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2025 21:44:34.3699 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 29caada3-4867-4865-5a8d-08dd869dddc6 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: MWH0EPF000989E9.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7621 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 --- 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