From patchwork Tue Jan 7 14:09:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13928990 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2060.outbound.protection.outlook.com [40.107.237.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 502E31E501B; Tue, 7 Jan 2025 14:10:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259059; cv=fail; b=CFBC36R78FHJhH14JB75eqSK4iYfETtBCSW49QjJBriSdxhk2Vy18dUuNntNU47iYcumgfJIukH0S+keq8APiM0niYhl+MKHQrjNXzgCoyG9KARSUgxJ5Nmvw9S3fsL/SedExNg0UYV+p56LdC6DK9Vy39TBaSlUTuPlpmf+lZc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259059; c=relaxed/simple; bh=Knzh7rD4YYugKswAaCwWKw31r1itlpMNNRBdWEfLVD4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SEPySdm1QLawXuix1U6V5CGeSynZpmlgNEZFFya00/6sLKXNhlX/Gap3r6fScDFTJV/gkMg4rC/pb3Wi4V2JyrN+wUhHQo5qFD736KWMEkLL9TR6aTLUkg8dAjmgvoJ2+WRO8UpBjJh1h1I/InlJvSafbjj/3sToao0fRcZS0PA= 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=L5fp+np9; arc=fail smtp.client-ip=40.107.237.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="L5fp+np9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oZGWUvtfZqAiR1HKD4WDHQY9+rLZ1P4+e/0iCzxpGVrS8migXnBPr4MvSqYLQ/sb8hvd/OSsp4WfhApwiwyOlJJLg2KXFYKzG9gu+VaCLCuuRVXD2DRWI1fARTUtG6SOyOZYUv0kHwSrA59Gbnba+JXuKHXWfsk7PVTjzBTfEHvCkWOJZ0Ptq+wJ1bF9bnli3est2+sx6ykndymDsq4GWXM1sHrclzIvEhkojrm93D5pu5VcI8m9tOT1PwAwfR712XTLJBp3i0w45lAVfwFqOfazfF453X2PPeiFwEwRv/j2VDTX37SbWvEH7NFvfM8cIHdyAOwzIgeVtfewAAUYxQ== 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=Nts77dc6NFfp170Ga9LgAuGpqzLcB71tNis0KMAtDMo=; b=dPPeTa4XPzW+xMioET32IYYgGqcqGRnblZr2d9H04wKFxp31B/sVqGuHb6DMF5TGuX86Due5VAU4v0LIgCkSSWtkvQyIkoCy6Ps/R0zSmCv/jVpce65LCIB5VjHuxeexAj40b4hx2lE/YzOr0cTgSSC/CfDkc401MNuUznZ3VymlPHmDvBmZ+sIKuiuyINFOH/qxa/n0RW8yxsn3fojji4D8oQbt5dPHZWa4OCmrMLYqt7ruNbAcQmX2lXbRg2QypnuJfMLOZqVC0JY9kiuaglwNgf+tYfxhAIMzCcetoESKqv44jBOsILTtLFF1yLm2bwlRCXIZdFqLhlqJ3G9mew== 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=Nts77dc6NFfp170Ga9LgAuGpqzLcB71tNis0KMAtDMo=; b=L5fp+np9Df2zg+tEw2G5pevR2KC/Em86nG9cra/+egvDLVZqZETGVaCxMIeb/Zskn3L4iGa54Uuu3TObEKsR8gLIJu/VLUgK02ml1j9ISKUUghd1eVAFRvRPhF4Sz4eMao7zqtD0rydWodl7X4H5EoJTm5sjEpsn9jWZ1cc0vxo= Received: from MW2PR16CA0012.namprd16.prod.outlook.com (2603:10b6:907::25) by DM4PR12MB6567.namprd12.prod.outlook.com (2603:10b6:8:8e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.17; Tue, 7 Jan 2025 14:10:45 +0000 Received: from SJ1PEPF00001CE7.namprd03.prod.outlook.com (2603:10b6:907:0:cafe::4) by MW2PR16CA0012.outlook.office365.com (2603:10b6:907::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8335.10 via Frontend Transport; Tue, 7 Jan 2025 14:10:44 +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 SJ1PEPF00001CE7.mail.protection.outlook.com (10.167.242.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Tue, 7 Jan 2025 14:10:44 +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; Tue, 7 Jan 2025 08:10:40 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Robert Richter Subject: [PATCH v1 01/29] cxl: Remove else after return Date: Tue, 7 Jan 2025 15:09:47 +0100 Message-ID: <20250107141015.3367194-2-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107141015.3367194-1-rrichter@amd.com> References: <20250107141015.3367194-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ1PEPF00001CE7:EE_|DM4PR12MB6567:EE_ X-MS-Office365-Filtering-Correlation-Id: 6d7a5bcb-8c48-4c3a-386c-08dd2f2513ac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|7416014|376014|1800799024; X-Microsoft-Antispam-Message-Info: zgSXXIjfKuPiccI2pMeUghMDmilmPEaPjolsElAAcpAyOAkQZaavq9kYhVfGy2tlH5A7QiTTwhWhxwQ7d7MN1rjG34azlMzs73WnftJtLzWeh2ypBmX15QoyY0gJQOa90iGpB4EoGDzKbwqvsJ+xO8SHvnPFXxwzozDbDA4JDj2/XmQLYL9ZGLJudmu5QBeIIlA5LtjDRIyvaC+VsWgUnDNSQzzTECx2ucW9rnklt1/zqbeCmV28WJRmk0w2qBKS1zdReVC5qZZ4oINsLTpCa69VHeypnW8Do17i+yfXn61ORWgXEWv/P+DRh4Dh6PR3eujI0TK3LfDOkhC0e5UwYirMCt5KM7liHmK6DpGJ/ZOi9FQH1g/IH8hq4JhXoScWH0rE03Pe2tcChdqXBO7f91BGJ3Cn2hbISt2JPwnTXtI4jnhd7MelVZtPsEUdNzAMlUoXKP/FcyRA2PRaZ+iSAT3JxxPwYkEvOM71PGgLLfa0uY5LwpExcLMFsgQB15HZTJQDz/i29feHDIEor5M0Pqo3/lk1k0p0fXou0HxjlVOpjIp8QDpV6408B0HfRP+pBs2Zmrr506r9WAyRSZXiImK6kFwVux/V/UbHs2qhSGmDdk0qpvU1YtIsRlfMo6b8qtSzJxnNNHeANRu4h/bb/O7Ab20Z1Dtuj15E5I/ZbWH+WWAvz2h16fQx2KqzKJ31Qphhpg+/9UGrqFavumpB4CpSH9sa0eA9uPcyH4jbKhGgy0tnUiDU/HvjLj98oFgQ3q8ErCc5JZwK7dyor6DrGoFvzXCAXiz/cgGvdaiVgRJio3T0+RFFwiMYxVo4rjn9EAR4cKxXEu1hEtoyRODslKugnN/Rw/0/pzJIOYG+kTV1lV1u6mHIYIser0/UPrinf2XEWHsNZSe4rzmtgHSF1zegSfY5pDRPKlNqab0NT+kuiknApIhvUeFOQaisDBsJ6WxyOZ3fuwAfQ4DGAYLsBKj11ccq2FnsD+N9jrTZLDq5cTQQJgH/PuzjaoUAofFabCR7N+Mip13sGL5kdtJDVNHBk+TfhNHxKZ4DAsGquxkBSYO826EWGxzfiqruI1lJiMshYfRioaFbH8iFwWe/mxixgBErdweESUkqOvobflagYZtU0Btp7Su/xfnFYF4H6gSp3HXaQeFCPHZvmsxZIEB1uezbemIyVk3Y2sTs/FcWQ/5UQyP9W5SKwitAfgILMHCU2NtSIpDl83dOuQtnoNqjsxPWqf45p7xTxfgKwih8azs9R7E7r+njZPiQ3ospV2+a4ttODSknke8JtQs6Hr7zOBZJOcuUm4+wsWqsw/paMYjkqP2prP7Vi9K1W5FzccVJvcFudnHy1id4ESz6zMb6jeADSAmjBBYYj2uAsUzsJP1XjK/foTHOyZunctyJRS6/sNCjay72OH9NWstiJVkkMv7Xz7XUu2mEglqOSxbjcFULFogEXL1sXy+ptDNSfYwkZhaoPrik/L+MWUv9NUYRGXc8jIJ5ml5a2aLOozg= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(7416014)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 14:10:44.5108 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6d7a5bcb-8c48-4c3a-386c-08dd2f2513ac 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: SJ1PEPF00001CE7.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6567 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 --- 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 8153f8d83a16..2e69d9f27028 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 == 0xffff || !entry) return 0; - else if (base > (UINT_MAX / (entry))) + if (base > (UINT_MAX / (entry))) return 0; /* diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index b3aac9964e0d..3e8d20f8955c 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, struct 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; root = to_cxl_port(port->dev.parent); diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index b98b1ccffd1c..9b3efa841c8f 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -1915,7 +1915,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; } From patchwork Tue Jan 7 14:09:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13928991 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2088.outbound.protection.outlook.com [40.107.92.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20A9F1F4293; Tue, 7 Jan 2025 14:10:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259069; cv=fail; b=eLheUJmwOzX+3/EoCdc2iKTTDV8Vh6DGkQ2Q3ljBLvpPHqvnzFucFUiH8mwf1iu9FVv42jycDhxUAQw2g142VIo8lxGyTFGZTbTYUsbZNNxwCkwd1DNn526zsNSj/qaBUJZ6sm8WZGhyK/FGM2mjzIo+KESsPAGzKAtpDPKFrbA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259069; c=relaxed/simple; bh=IFLNbphfPng2yUxiFVNSFscqaoTsWFcbbKOHYmoSnJA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hvxmoK+K750v+g4DpPXLSDrINK9yraUXlL/H3F4BvkCJDK6fv1BtuzgJMLMMkdVU6hZ8Gmja/aiSAZrvwH/BgJWLgueczXnUzJzhQEE2WkqkQigKg/k81eKD1+ZYiPmEZ+Ae7Nk0u4ghxqCIYu0G2wUdm963sL9qw3iypIO4/sk= 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=inUeNhDv; arc=fail smtp.client-ip=40.107.92.88 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="inUeNhDv" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=flkEko2N/MWNIAucr+J8GQkIEPGr1olfokYRyJSRBd31Q9E3zx7Cd6baeqwXYuSRJ4hmAy9qWenUseTXiBrAe/V7edUYX2NGD9CuQU0mkk04sUY64p6L0UMKPNiFKKtvZjVGc4CI0Rgz5pL8hb0qrVqK+PScgaH6Zb3awIUh2bxlqPr3zWzzj+m4BxQ2FKPqlm2+x+7/01qxyxktdQxyjOIPTl4a8C1FjXOgufGTlPNhwXOTTgqnl+p45/N108BdcjC/0Fumf53s+TZ2JVX37eK+G6k0b5Z9oGvx/o4Tm6d+E6wz13E1eZ/UG25G6rdP6WtKjIv192xgriCM4uzbRA== 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=xQ8cBv+5t5NsEn7HGLqiSaUbNkfiftUQ/tM3mwsLQvM=; b=HirJp3XFMy1neTOHYaCt1NWAPXaVZXNivZcDEzIh803CyJ+nNvHx+h8RBPTXc+GYBeFdJF2UVh1sB07OoKEJCMlvMQ4y0plxHF3ly//pkMAurADAi3c0oAflqR7Pm4/dom2DihXqTTITam+oXUegVl6cEWB97R84QsA9WEIPsvQiMykSQZR23COmatPbRA+NSFpnQLVSfATw9okAGgwd6H3ieVGCgLFopB4xOcv9EKjkL/cpvNts36RBWkTmnm2dRCngf/kXkIfjKeU0D6eoQz4QnXcfd50AzfNjSwRYBc1+rhJJtKRgOUKptRdH72Nk9iveFQ4GMgOXtUu3/Ua8GA== 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=xQ8cBv+5t5NsEn7HGLqiSaUbNkfiftUQ/tM3mwsLQvM=; b=inUeNhDvssEMjHqAQhWIeiTEY/oFCHYWs4PgCd/afyJvMGUTDv0A9TwS1Gi9KsZRomSA+L72CnzyVLQqFbcyK7ZPWJwDXMdQsL0GPV9iJE9WZjG1IhNITQP5jr04d4pj+AD7VKgXwe1Lc9XRzgsTKYq8mzBk/yyVTtWw8Qr1820= Received: from MW4PR04CA0088.namprd04.prod.outlook.com (2603:10b6:303:6b::33) by CYYPR12MB8749.namprd12.prod.outlook.com (2603:10b6:930:c6::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.18; Tue, 7 Jan 2025 14:10:49 +0000 Received: from SJ1PEPF00001CE6.namprd03.prod.outlook.com (2603:10b6:303:6b:cafe::d0) by MW4PR04CA0088.outlook.office365.com (2603:10b6:303:6b::33) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8314.17 via Frontend Transport; Tue, 7 Jan 2025 14:10:48 +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 SJ1PEPF00001CE6.mail.protection.outlook.com (10.167.242.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Tue, 7 Jan 2025 14:10:48 +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; Tue, 7 Jan 2025 08:10:44 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Robert Richter Subject: [PATCH v1 02/29] cxl/pci: Moving code in cxl_hdm_decode_init() Date: Tue, 7 Jan 2025 15:09:48 +0100 Message-ID: <20250107141015.3367194-3-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107141015.3367194-1-rrichter@amd.com> References: <20250107141015.3367194-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ1PEPF00001CE6:EE_|CYYPR12MB8749:EE_ X-MS-Office365-Filtering-Correlation-Id: b78f34d3-d310-4546-4c06-08dd2f25161a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: N8KHFo4cF1uiap7YcFPEnFOvRhZDOU4H/4hwQ1J+dUq+Q2wShmrmkwf5Hhcz2nz4CuFgyiDLqgVWR3jCwoLLyATx/xxJOaoCVOnDtG6a2hEG6wTNiGtMW5ZOOxqZQEfu73NSKhynxXepf0yLvR5nLbVGFpWuM4hqgUhap+SCR7SUHnoT/+S0bB1jxpkizKTGaC7iA0u6GMjHQCx+zyoeqM4vM/Dd6hm+VaY5Y5QC7bZ1GUX9MZvOhbgUSw7wi4M2n4ikR71BTSkISvcBKQpnnQv7Gq0T76062NRasnaF9vABlGaSz+Twio5j3cevRd6+V0/BMCwrvN17WlZK8IeqLkLRMXYxBapv5aL1kdg4VYieVD46EouO5LzmwehbVR/0fKdxfAs+LrqhmHEUHwVX2KWGYkZcDyr/0Zvrg3EauCAUAhce0pCQWEiYcPMMO2H/O+LkSQHmRBYhgbndvfWWw7oqnOqyeGUvKLniYL1m8SslYic4wUwK3X+gcneFyQRDyV0cEjRncEbmpsMyH6uph+xoSyzvs1431GFa6ahezqG6/O1g9PZnyVWGAQEcwpkrMc4yFo3dqVX3g3Jza4t7JH2K5GFwUZ2WsLByE4jH8w0djCiOllVLgwew0F80cmU617JM2SP8H1NgAwtYJ2BCWM9vRLndYnUjl8+dCKm9zUkcxG3KfUWlaXdzxoQa4SMEXbaHZ6y7iq7SrknsDTsz2ZOVHmJePwQiiOoziLelpSwrdgF8hHd4tCwCit3xtGUFCR3t//G0CU3HV8NXl5CQ8JcndmHevbQgXvZgPmWIO0gYZ6NdmxUJi9VablI7QCzttlyr9aW1wNQOWdqEyvpgEd9dOPnogb3v82jU4QXS7x8dMagtYNYVhoBNJtB2y+1WDWodf9wqdvuTnqtyv+4v0uyllqBLqtb0E/YauSQA1XCdwXWuSJ+Ef57AemONEiUXC6i7GW0ULCNSUx/Cc18hKT53GwJp2rHDamcF8CnmtekSO8VcbvZkKLDwXO5fDzTLlNJYU3FYuEeYztRj4LCMJz+y95aauPZ7V9jAt0qEVBVv8/rCnjQBdHgzxzjck+j83gZlgOu4EN4X4fVAukqFQ1WHvZjZWNLZCok3l+t6NcuEY2yoBy6T35aseeutlwHFsRzioZIXCiA2ADvBjlryHTcyjWiWNkEFeMvpWyjuMzD+eoQ9uTFn4tDhWBg/Gdv+cnz80JmSz5V6RlOCHN81+bjo0VtCETozKKzTmD4hjR1EIiTE8qrNtbVWAFHrGNWiwPaH1Aeb4KPVdj25Pgvfe5iyV34mmVuZJGe/9J5cw1oJNlx6XDWeRSzYajHhivkbu62OfYYXO4ztPIPYqMq0XGf7+1jCPGXjDXAAL9KrOPSNx5/bPeFdQ43F8DoorLyqLBcg99R1S8rLeAiDinvu3WNZhEdddSq1y+W9NIhnO9kq5IITu+l0ffcAF7bfim3JDiQB+1Kzu67xVsuXR7fdftX6oojobByCWAt4GyaI89M= 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)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 14:10:48.6033 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b78f34d3-d310-4546-4c06-08dd2f25161a 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: SJ1PEPF00001CE6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR12MB8749 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 --- 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 3e8d20f8955c..d206378c4cbc 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, struct cxl_hdm *cxlhdm, if (!hdm) return -ENODEV; - root = to_cxl_port(port->dev.parent); - while (!is_cxl_root(root) && is_cxl_port(root->dev.parent)) - root = 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 = devm_cxl_enable_hdm(&port->dev, cxlhdm); if (rc) @@ -435,6 +427,14 @@ int cxl_hdm_decode_init(struct cxl_dev_state *cxlds, struct cxl_hdm *cxlhdm, return devm_cxl_enable_mem(&port->dev, cxlds); } + root = to_cxl_port(port->dev.parent); + while (!is_cxl_root(root) && is_cxl_port(root->dev.parent)) + root = 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 = 0, allowed = 0; i < info->ranges; i++) { struct device *cxld_dev; From patchwork Tue Jan 7 14:09:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13928992 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2040.outbound.protection.outlook.com [40.107.220.40]) (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 7B96B1F4260; Tue, 7 Jan 2025 14:11:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259072; cv=fail; b=F1MOeEYJ0EH7hDADiJh4WOJUyQxq/wMiXPPmQ5DsSKLIGLdxMsbu0giN8Lbkk7Yl7/cbJP1wM8TqKPC0LNE6fDW2wQ4mhHViY+nm0Q05fvNQXmwaqSjGTYhDl8kpMAhnFH71HkJPXs3KdV4/8EFaCVzDtNN2AKhC93j+dJesiDQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259072; c=relaxed/simple; bh=88eJRNGXb6QfBwxgsEnvfSp9SIlfgka8fZvShbmsDyo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Hd1bC2gHSM5FS+4EuBOMN/HrwyXsDLefK0AKoY/xLEnS+JrK/HSGROqd0Jp74Jzmtpnht+V2qJzCI9AKh6jcoO+wgg5lg3btEOMfceEFMdbAStGX0WVK63QczxlHDpnajyetDlO+EYD213YFu6f+eZZv+3I1MUQHyYzqREQKAuU= 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=Gk/6r8Em; arc=fail smtp.client-ip=40.107.220.40 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="Gk/6r8Em" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xaIXFRrKlIKWew3cNqnls95YmUsVJanIXEeeQTL9VR6vm3Ch2Vohv4puQ7e/xpZzNES/HFZNyz+I9/OfEteMRE4xK4MS7caRt6MFT1bFaFpmZp17nfOCdg9jDN7nrCsZsCvY7ZjZUEAG6HU/mFDdMjrOdRrZADodQ7LjxjDn8Bqb/MgIFOTAGhqJexZplIStJinom6RGdnefD9QykwdpL64hj2klUmUUDRbm162hLoqSeTrkIe4Oxli0n8huekfDQSIyn4+Mc4oLuSuy4qR++p406C9iOl0sdjDDnZ8dpHB5Pl/iqV2FebPiHTKWiOLgEqJr+HaFd6h/xVN52x7A8g== 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=BDgAh42ndYYAV48pStfabZfS/s0ErZo3tcy70FNuNzg=; b=Y7OrYm6VcSkdl5YxawNkWkWhNfY/apv139KUbVzsIxQAjUfMTosez5/Vdo7a8TTvdiqHYhzi5KsbBCAILAYvZKwRdwohRBIL17m2vTzBrJBqP8DJWCNf4tl63PtUJNy4hBruO8f642VOkc/Y6MwE5grGacu6ehAXhlNcyehc3Xi+tO4RqQ/52V48E26yWv8vHKj3Zl8bqqSX7C0+oWEsqor7X16LwhRwkEFz5gHIr+HsvLaWPRaCIgj/AnA1Ra14sxRfDl9+HM2lNRTWCAELVibN7U937Os1wYadBWFT0FFiMMlvsePRJ0jBjOrvwoW2NryJy0Qy8ZhEZmqNeAsVkw== 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=BDgAh42ndYYAV48pStfabZfS/s0ErZo3tcy70FNuNzg=; b=Gk/6r8EmwDrGxzkiyZwuAh9LNsgR8lEMRkaMAeniEEo7VxP2AqJZriap/g1b2UFoCrfABhRD/kAwbvSZz8nYsrP4zDaPkyJyUxydlg0dbRGbKHfKC3RfKkb/BtxSqz0/UJBVQW1glaEJjU7KJ9N2Qg8c2bVirRWmkC5CpCTw8pM= Received: from MW4PR04CA0086.namprd04.prod.outlook.com (2603:10b6:303:6b::31) by PH7PR12MB9151.namprd12.prod.outlook.com (2603:10b6:510:2e9::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.17; Tue, 7 Jan 2025 14:10:52 +0000 Received: from SJ1PEPF00001CE6.namprd03.prod.outlook.com (2603:10b6:303:6b:cafe::4) by MW4PR04CA0086.outlook.office365.com (2603:10b6:303:6b::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8335.10 via Frontend Transport; Tue, 7 Jan 2025 14:10:52 +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 SJ1PEPF00001CE6.mail.protection.outlook.com (10.167.242.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Tue, 7 Jan 2025 14:10:52 +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; Tue, 7 Jan 2025 08:10:48 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Robert Richter Subject: [PATCH v1 03/29] cxl/pci: cxl_hdm_decode_init: Move comment Date: Tue, 7 Jan 2025 15:09:49 +0100 Message-ID: <20250107141015.3367194-4-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107141015.3367194-1-rrichter@amd.com> References: <20250107141015.3367194-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ1PEPF00001CE6:EE_|PH7PR12MB9151:EE_ X-MS-Office365-Filtering-Correlation-Id: 7ee0b73d-5f90-4084-be73-08dd2f251832 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|7416014|1800799024|376014; X-Microsoft-Antispam-Message-Info: swqwigfJaWuH+xkmVr+h58mtTeEYgVyIpal59D3trVd3Husc8IC2O/Gxn7saLovJL9wlE+fbsOl3dZxnZz2c9aZbbBoeqTtA3oFEDsut6cwvhTODoFb+BvZ08Tzv+62ZohuYsDkqPu0jTgYYRbSPVqfhN+RKJKqTc8NMg8f7W3Y0bI7YCxfMfgBqhZHWJXb62kbrosOXa2ZABpNiX0yb2r1mVzRQT6FTlduNJthA/tEJesdSuxx4ENJ4KpzX8VzVAHNgLT+WVsOQt+HRm5pnHNZPhFyZOdw/9GJkrqhRAlkpQYJgfVZ7joEiA2+7D6CgZu+sEa9kPKtc5ydsRwCvSZxzOk1xvwiyCqBy1SCDr+3znwWfJvxxCXhP6XXJ/lLmBHE+BqB8D6VWxcQJmGPX6eg780FGnDEoktmcNF5o7xMjDW04SBiaebTEvaflhx6hmdN+VXsgeIU1E8koeMN87V1rbcTPlThWKx9gk9bXI7lLG6acVmj6xBDJMk6mtu8zrgTXz5bVbhPACdrjO9UxuaBSwMHLM8ehtfZ8ZI/d9uJyuXCD8v+X3rgFsCNUG6afkwrqgn94gM1jRf4DShsDV1q1SpijF5iNsM9/mn4AJKG1O0ArJ43ejX2Cf6eF8KHcZ+pYv1DqBEj58rhenSUoCKHtCGd8uB3xmarZaY/HF542hoWMo8MgqjNtz9Hs4quf9t3II4koxyLS7PjOOHHQ2LNW92x06EEbhO9VDlEqFRBA39KYBeBX/IHbDB/QqToLC2Ht1FYo1B4CX7nVkCz1rR82FjGWS0Rp6EOX9fiSw9SF0ZLPExPMdFYxc82fgDfyrpwOXab1iuxeHiaYJ7BUtKC8H5LDI+Y4/OMD0DIx4bjKR2EViaoO1GTsC8XalpW9Do0Tx2VX3tWVszUXXaTgZ17Pp2lbU24C5ESpd3sEvkNEw3yXJReRJSS0M7ID9oQDykZvEdbo+sr4I6fqSXBLoiZ1sk9GBSqGecOPmGpfPokva+6eiwnKRx+E7EyJxfi9s36xzBaM5Y104xmLf1L2B0SNV1cPMKJz6WG4r4f+h8qA2erE+N8DtaB5ccA8ZF5jpyVkSJm0wwT2dgnSVRMKGRZh0k8hpUexUdcwDxSjw23GUHANf73dQRaFORq+VI/P4JWcc/lAX58JdLmrBQfHf6F3u0FXsNYDVosPDTm6pvvoxuWskj0HVDsURkc6Uuvzd0MuPLrXJpbywUDJm3AIk9g+JGyAWNcx3s6gMVno2D9Jee7uAxzjPgICb4y2oNakAfzMCQ4JG+q9TIxwK4uMgdv67jVVJrRkqIzEUhghP3mf3b72RhYlMSeoRHf1a+/KD52rOltIDoCCAy6hwTDbPN2xg5G0PILhIDQz5cXgUy/88LSN038sfkc0wyQuALVLUf+BXlQG+cLKnNme3ruNo9u/fgDo1aR776wHKMBv106GrG/YebRvDg7nlvYGL/GsPWI5zrRA7b9Ui7tVjaHWYXZhqsP5yUEf+KIiau6rE2Q= 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)(1800799024)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 14:10:52.1190 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7ee0b73d-5f90-4084-be73-08dd2f251832 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: SJ1PEPF00001CE6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB9151 The comment applies to the check, move it there. Signed-off-by: Robert Richter --- drivers/cxl/core/pci.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index d206378c4cbc..c7050c13f71a 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -419,6 +419,15 @@ int cxl_hdm_decode_init(struct cxl_dev_state *cxlds, struct cxl_hdm *cxlhdm, if (!hdm) return -ENODEV; + /* + * 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. + */ if (!info->mem_enabled) { rc = devm_cxl_enable_hdm(&port->dev, cxlhdm); if (rc) @@ -454,15 +463,6 @@ int cxl_hdm_decode_init(struct cxl_dev_state *cxlds, struct cxl_hdm *cxlhdm, return -ENXIO; } - /* - * 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"); From patchwork Tue Jan 7 14:09:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13928995 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2050.outbound.protection.outlook.com [40.107.236.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 592681F3D5E; Tue, 7 Jan 2025 14:11:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259075; cv=fail; b=kfMOIaZZ0x6WiogCdglvIWDHJufIu7DtToxHOWQPQlcl6wiCIvd+S+EWKP4XAMZ5AOxHfvrGmFMZVu0+uW63QAZT4siYQmRT17O4fJ1eptOjUvYwHUwcRpqBytIITB8eLai8yHPN4fXBP97zinOvNvcXy6eRKvuU/D2zL8ykfrs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259075; c=relaxed/simple; bh=438G+qvBdIW8qX1eM/hwhJdrZiUWnHM2y6DrtXRs2Sw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oPUlo28hZ1oclyfVNHBP0R1AKZkagztUdnkcgEnTTdPSyEGvLL5YwcxMaQATuHD0A9X4zElzypjgHW+dedG2qazqREgtQsjzh9cmk4qcTCgiEb+LLbW7mWk3ssvcz2t2LktmMgysYl7W6nPyh9gIfwyuMOywmyPae0sjGBdyFv8= 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=HoLHFi+q; arc=fail smtp.client-ip=40.107.236.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="HoLHFi+q" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OYNy/7xyGoVViV2M/32m+VN/BW3H95+jFX0oO90ZuaEZWW3X5AoZdXP04k+dqWlkMzq0RDtWg//N55TRNxnAeHmoY3cJXJuY9LIUfLuPhoeRPEPCaI+Q+gBCEM4H/1rlcI376L4d/Zyficd8GfZ2j+NPLaOy5MPwLkDXskOfWhwtr9UlxIuTV0Dyn3Au32j78quwkVmhMz4LU0Dx9U29R7790sKeZ5vGnov1dOeWn1+YL2hOg/Eb9vnwR4UE7rc8inp65QUqSVK3KM4lHB0TlBkZAWRofAWjd04nMMrxijSpbHDKwH4eqHpzAo/801eZGQDawqzW11A2cgmw5YYyyw== 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=ufE53pNySOALiuPVVso8hyS9fzh3aFaC4N2B094/egE=; b=dUFNWx4ejzz4dC/dnIids8WlE9n1MMqKq9pdcgik0mDVAUAHEY54JD2aAf86fk+1S0ipZ08pYRQx6sAYtiftPIgUCR97jGvvhg29XTiadjtD00Bd98GTZrpjj58dAXQZkfVjuN6+Jo9Jau1j+uTXCPOpxJ9nMTFHwFw6SiBrFoYkBfiXTUvksQB6tOr0FskCCKXLfet3sb9SD7BzZm485olIgTzZcPqPlMt4RDOTkZvTfH26PqgIWlc70GME/K/n6o9vmEOWsGHlabpIteu7PklZqfWpOKt/6QNHW7oqhSKvyE7jUziSrxB1iEx38fI9ZhIBYEIjGu4riRamoT9JRg== 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=ufE53pNySOALiuPVVso8hyS9fzh3aFaC4N2B094/egE=; b=HoLHFi+q6ZdlV2iQF9rj4Bbyrqx+y8p62/fk0xOc2wSg0+qX/Ejiid3tuw1I8qSr9FDt24VZ1M65stj1rKljHNfHbRapWZrGo8cwAWynYKPb+XrZ9sDB/6W5bmu/igKv2CpM8rpWJSK/iCacCKkmFMrJOMSLOQSG8mm7NCy0/Ik= Received: from BYAPR01CA0063.prod.exchangelabs.com (2603:10b6:a03:94::40) by DS0PR12MB7873.namprd12.prod.outlook.com (2603:10b6:8:142::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.16; Tue, 7 Jan 2025 14:10:56 +0000 Received: from SJ1PEPF00001CE8.namprd03.prod.outlook.com (2603:10b6:a03:94:cafe::68) by BYAPR01CA0063.outlook.office365.com (2603:10b6:a03:94::40) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8314.17 via Frontend Transport; Tue, 7 Jan 2025 14:10: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 SJ1PEPF00001CE8.mail.protection.outlook.com (10.167.242.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Tue, 7 Jan 2025 14:10:55 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 7 Jan 2025 08:10:52 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Robert Richter Subject: [PATCH v1 04/29] cxl/pci: Add comments to cxl_hdm_decode_init() Date: Tue, 7 Jan 2025 15:09:50 +0100 Message-ID: <20250107141015.3367194-5-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107141015.3367194-1-rrichter@amd.com> References: <20250107141015.3367194-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ1PEPF00001CE8:EE_|DS0PR12MB7873:EE_ X-MS-Office365-Filtering-Correlation-Id: e3246f20-eec9-41f4-4c3c-08dd2f251a5a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: CqU4KxfQ4Qzhex8y3pG7uP7eAzTSf6uYQ+Wfnh9UKES5wO691lzAyzqhV6fxJYWFleH50oMR142js8ks5Je9hFQro5Gujb5yeOlf1Z/TRlTV81ws9mbwc77sfSGBJHm6aetZ6omfBp5YDDaiGcYJRUwP0YBr+jsKWxRrU/PiNYhtLXEnrAmbfvOc9u2vKp28yn2LioMJqirN1dSr+a6H+UUi4NHWOcRkbR7taDCXcpjADhTJlgM/9SsxzFH6mlpUvHn3JlVyaXtG6qjBBVPw1hfutosjiXsATZrLJkFnHuWKAoifjdYZyxT9pKnswfFwHkDj4Bogy//LMBsOIWD0H7hsLUkVlZKMVq5g8PzyT+AMI9VY0l5Jis0iGT4pHYdoWDPdTRsT9RWz6QAWxCIQqO5LHwgrNaq1uLiCCGoqwN2Sr5zlZk3Cd4ab/lNfEoSknE7AAiow8jP+KpTI/nl4eTF5CmVjJrhOeawo8M1NDnpAOCSh1fgfMlE/mGY5VjDy2JX1MSqFR7rZ2sPpwL8Zpj1ZUZZ9C7cLaxZuKRv2A8R+hqHe/IOMjJT+oWgWDZOYYrruybcr2VRde4ZiW9yLITYHoa3a2LZJMlib+bmM/Uil6wUXigZdMqZu29plzsYAP05nQZ3BnFFubygCO2H6xEF0HufG1sxilSDBMbjRZ43Jj1Q4BIDnnbwFz0DRTp9clXKS94nMWIpiSYcSrBfzYJ0pu8ttCYlcX6uop7kkf/xDqkK4vs6Sq6Y4OF9Vf3viEpud/eJFCgcSnl8wit2P3h5NLP/sOHqeTsiyVTAJLBsucOAnvtUmGI6QsVk/ywLT7P8BZEkniCIsI7iunu+E1hVl4UjlNGzsZU5i9q8gvb/a3wJWC1E3IizLqKTqh2R83dIgQSrp2JXbTho9Cn2ypEjNbqCGA9u2zKrpiqYbHN1l0sC50uIWyuAEQrB9Dwolx25keM1bdssBHoqkLZw6Zjr1ya3eL7dMj7VkZrgs7im0ciPcDNDEFdlZ0X+OR67qfo+qqkD+0HycNBS6oJF8zSqBYN6LZA6YSAyhupScieFz/IU6/jcxgJ8iCa6v6aJpkShZLlfrKwGc3/QiPeQdZ86EGcD4SBQAApXZV02KpfPt8gvDRfDSWcDS0nKaYTzB6rTx7fgJLjbXFAO6eMTw8tb0z9B9VgaUnRGzTqK0GfNzCnbQnWSyYtP37P8294DUkPbLkKIunE33+2PGf7P8egUnubGkP1F0trZAvbO8lg8g0Iyi+BxR+CQDXQAdCpPZ2fF/tj+EMzI4Jo1B2KI2Zuz/HLYYJETvgCHPkGOdrj4h2DMbRLhuEbUeouTmAjPTbMsNDO2pBhgW1L1VC8Mw70XriBYxfX6pE3uk7r0PF+jSwhxSe1S0c5+mivimuoarnsmXyfk5PFZ9af28xXJCEiwxQbbtsWVPG74Y2UvMo1pWqiUUDh+GLn/g2fuhf/XSCH9WnrQi8Nhn07xXi6gATkuW8cAsmyaDvlgDTcMqN6g= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 14:10:55.7336 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e3246f20-eec9-41f4-4c3c-08dd2f251a5a 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: SJ1PEPF00001CE8.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7873 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 --- drivers/cxl/core/pci.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index c7050c13f71a..4d2154457efb 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -416,9 +416,17 @@ int cxl_hdm_decode_init(struct cxl_dev_state *cxlds, struct cxl_hdm *cxlhdm, if (global_ctrl & CXL_HDM_DECODER_ENABLE || (!hdm && info->mem_enabled)) return devm_cxl_enable_mem(&port->dev, cxlds); + /* + * If the HDM Decoder Capability does not exist and DVSEC was + * not setup, the DVSEC based emulation cannot be used. + */ if (!hdm) return -ENODEV; + /* + * The HDM Decoder Capability exists but is globally disabled. + */ + /* * 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 @@ -426,7 +434,8 @@ int cxl_hdm_decode_init(struct cxl_dev_state *cxlds, struct cxl_hdm *cxlhdm, * 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. + * Decoder Capability Enable. Else, use the HDM Decoder Capability and + * enable it. */ if (!info->mem_enabled) { rc = devm_cxl_enable_hdm(&port->dev, cxlhdm); From patchwork Tue Jan 7 14:09:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13928993 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2059.outbound.protection.outlook.com [40.107.236.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 B3C3F1F2C5B; Tue, 7 Jan 2025 14:11:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259074; cv=fail; b=TWVKzRPh3zQ1QQQs8wnkxFbXajTpS00f7LwVAgFiMcsVjiC7hHwNQoyaaUwbI+oASywolm7N4ODrPpp+Jl8ZtyEwVY06ksnoIM6hKwybFdfXkaQFQgBqdCHUtD/aAb0xrKbBKYbbk4HtsrHyihZikI3DWO89GwHRPZXywlTBOXA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259074; c=relaxed/simple; bh=EnjN4gMK6b9f2BUtTbjziUPEG1En35oxa4NuPahiDik=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FKNcdYDA6QWUDe6eQgwWj/hAURDKZ7GjQ/fSCTNRHzcPEpUDXjXOkMJSlFsOqiHTqjRXVhe5f7DjmIDneqYfBbaWM2DQTIhQy+zBQLEvr1st0cCgsygg6L0zd0FxIiwpGA6wolJ6ta4N9tyGnnzeo4eEAK+cdZw9DEpEM9viMF4= 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=J9foHtWh; arc=fail smtp.client-ip=40.107.236.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="J9foHtWh" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=R7fQxrr3d+Hv2CLI3/oZad5rqO1KuxsQe9G0BdyooOK7U+Bc16Vm/UqAQUldJqRAPD5RD3MjvBBHl4mGzpawfYe2h/25/RCO8vTzVZbcvJhu0caFX6WXfpzTI91gza4cAx6al1HaTmPFZEjPDRsJwat9pp6PRqLMFLgqnkrXKa5TE43AuvYjkTU4EyRMOtDrf/4fUnyvsGMcsLMcJtitFc+2WJwm/qwG1DwYcCyDZJzO1NHz3xGzhFijuNF5RAf07kN9BWRQIeA4LfRLkIykNYuEuY1plobk1gjPTy1m8d80ZvN1Z6fddZU8eFePvWAUahHdIJj1+a0WluqgF8aTzg== 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=whxyqsDgQ2ZyEwMy4Bj2/Dr14V03u5vdpzJP/Qvi6gQ=; b=AYDVBJl9XGxQiZGRsSgTRcVQMvPdxMt3K8G6YzVJ1lxOPj9uivnq5OdM9vjp0SifZXCTp5VYnfZz22SpduWQ0GOJPFeGKiwNCcP+/qR6PY6Cz5guVCjvI6SM0//qfGsGzWsEJzoLwOBClw19ezqW50fyOftz0QYnFtNosTaW0mqN5fjwRVfEz4QQqph/jxCFfWR2ySw23BcmR+0oqV08xa3lWbW2NCMhvVx7maTNpu09mMHVLBBS2IZMMsrroBTXvbfoBmPanImw6NdY+PjHdRS4h9UKH1Bv3BFvr780H6lbTVB1jMMQjbGqyG8F3GrMVoiGEK6QS5ZdaBQhy9uPkg== 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=whxyqsDgQ2ZyEwMy4Bj2/Dr14V03u5vdpzJP/Qvi6gQ=; b=J9foHtWhNDjum6U21mahE3G/yPJHMB1uJEtY3X+mL9UarQOnX4MRglZ2+h/TqQ6Lbiay4zx5tylYUXn5+lsjs2UiWj+/d26qNz/w5KRIX1SJKUb66SJaXgJzPDFUMrCQgH3wSryyL+q2ZKDPiV2dGAoQGpfhVpOgXl2oPSJhEzo= Received: from MW3PR06CA0027.namprd06.prod.outlook.com (2603:10b6:303:2a::32) by PH0PR12MB7487.namprd12.prod.outlook.com (2603:10b6:510:1e9::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.17; Tue, 7 Jan 2025 14:11:00 +0000 Received: from SJ1PEPF00001CE5.namprd03.prod.outlook.com (2603:10b6:303:2a:cafe::4b) by MW3PR06CA0027.outlook.office365.com (2603:10b6:303:2a::32) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8314.17 via Frontend Transport; Tue, 7 Jan 2025 14:11:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CE5.mail.protection.outlook.com (10.167.242.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Tue, 7 Jan 2025 14:10:59 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 7 Jan 2025 08:10:56 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Robert Richter Subject: [PATCH v1 05/29] cxl/region: Move find_cxl_root() to cxl_add_to_region() Date: Tue, 7 Jan 2025 15:09:51 +0100 Message-ID: <20250107141015.3367194-6-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107141015.3367194-1-rrichter@amd.com> References: <20250107141015.3367194-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ1PEPF00001CE5:EE_|PH0PR12MB7487:EE_ X-MS-Office365-Filtering-Correlation-Id: edb6c9ed-3277-412f-4920-08dd2f251cb8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|7416014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: myRnQnx0/2L0uNGwyPFMbn2uda9oXTV2xJVQpU2hfeBCiKUCgGN8JNR4riiK+XDgEYTJBHWtI8A2lFBnhH5jfVs1RABXL2+17gsRWxqH5DAxGqYp0f2qskRy3llh9S+ec8GGmE40+LJ9lE3tcozZji2Ob758e+TSQTIvzbiZI7Mzyy/TU0+mfsGZUOK1Jm0/UUDm0C8rwLw25sIO8kAcl2v8t65paMVUWOX2wGcSWrhk8eat0/9jB08r8lS9sBidCRkYQfDZE6a1F9Yj/G9uzLmcq5/IQrQCODXgXbyHLMYXd8913FoIvDRkZvV9idZ3tBN/Cn0l1BuKrQp+/sYyVxwRK8oUNhlUP27BiIwcT7vNpXhOGNBK3SLeP93ZZR/B3/gtptjw0lNNlZ4QEVSXNYOxPrU+lV8WqG6XoLk/KuCGpIgGcwmnSeVCFAHqv1UVNP/3iD4oiV+di0ENY94z5MxkKwqxeNZwK3GdfEVhhvleIZlKTB+fqO9jUv9mo0ooxwB8IyC/Liz+6j8bE+9rIKobPdWxfyQ70q2TX8TBQR/cGotd4tdTURxNFqaHIQ7UtmpBGUQt0JpRX2RAiY6xdOYSSxwQ0ZqfXQntFc8oo82RZgSB6pbIrPCrrlA6Mbsof4QoJOLbw5vVIbwwoDmBsEw1fizaAv1kUH1zTRSU/tNKBGmXDY807P7cwOompmAOzN8ONLHG7b3uM7cruRVa5d4if0rBBS6aXuLdvRKP9ULxGqIdUwZ3J2CR+O1XuaxENQz9r4q7k8473tLI8NbPQnq8/PUr43LYHbhZ4c6trbNICbQUlyqPxRfF99kav/vi1p379HhpocsCTwX/C9WxX5esShfibe08DVUDZ8Gjlz6AyzmmV7zGsMUWKY1ioaThKnrMR7dkaWVLqkwha3/9+PsqKtYM6XhPip1GUuvSfCno4jDDbkT/BxrB6qA1EVTdC991xqCtR0RB29gvCpj3sty6BMlvH+4sjXSI1Qxddy1t/MMSqE4tfweYC8B5qIJBL2s8/faZbxeKrQXVNy15Ibx4cOj63s27n6b6Zt8XKsghS4oiL3PxriZrBsjGDdJDfIIXxzLBgULvCIil79YcVBgjRfKQzRq6puP65RwnFwKhnC8LvpwXcy4EsJmT5nmlGQ5566N+R8gNw862j3ony6NZCD/H80+uP379QANBvoqGl1TttXQSoCusbQcNbZME1v7W8YbiH47XUEUeO9R0C+k3UsheY5cU99oZgWOTxgOMuO/EOPo0ZkTwAmQ+peWRKyplDfPOjAjQAlsj9b8MayLIRIkm47QgfIylDBL89gCyokIdIs9SJzE+8VFx0S021/ggIAW+rppTQl9ZBJPFxgLN40wicF7ZXshYeB1n6MP87LA/sCmlAc+ZUHAYYBMEoTdD3mcQtPEYwRMCFj+Rc2nhbZSKTILqgfESSacz+9Z5Uq5I66Nvy3LxFr1MbZdxdHkf6q++vEQocUzkn/C9I1i5RLQSKQXCLCCFEXsas7M= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(376014)(7416014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 14:10:59.7050 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: edb6c9ed-3277-412f-4920-08dd2f251cb8 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: SJ1PEPF00001CE5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7487 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 --- 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 9b3efa841c8f..752440a5c162 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3307,9 +3307,11 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd, return ERR_PTR(rc); } -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 = cxled_to_memdev(cxled); + struct cxl_port *port = cxled_to_port(cxled); + struct cxl_root *cxl_root __free(put_cxl_root) = find_cxl_root(port); struct range *hpa = &cxled->cxld.hpa_range; struct cxl_decoder *cxld = &cxled->cxld; struct device *cxlrd_dev, *region_dev; @@ -3319,7 +3321,7 @@ int cxl_add_to_region(struct cxl_port *root, struct cxl_endpoint_decoder *cxled) bool attach = false; int rc; - cxlrd_dev = device_find_child(&root->dev, &cxld->hpa_range, + cxlrd_dev = 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 fdac3ddb8635..5c1a55181e0f 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -872,8 +872,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); #else static inline bool is_cxl_pmem_region(struct device *dev) @@ -884,8 +883,7 @@ static inline struct cxl_pmem_region *to_cxl_pmem_region(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 d2bfd1ff5492..74587a403e3d 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); } -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 = cxl_add_to_region(root, cxled); + rc = 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 = to_cxl_memdev(port->uport_dev); struct cxl_dev_state *cxlds = cxlmd->cxlds; struct cxl_hdm *cxlhdm; - struct cxl_port *root; int rc; rc = cxl_dvsec_rr_decode(cxlds, &info); @@ -126,19 +125,11 @@ static int cxl_endpoint_port_probe(struct cxl_port *port) if (rc) return rc; - /* - * 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) = find_cxl_root(port); - - root = &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); return 0; } From patchwork Tue Jan 7 14:09:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13928994 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2088.outbound.protection.outlook.com [40.107.236.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B9421F37BA; Tue, 7 Jan 2025 14:11:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259075; cv=fail; b=lLeUzoNxH1Neipf7s7yyF4i/+xFaj8cNoLr6L5s2xwRQJMYB3uutIxWSs4n/b7KHcaSU1LqWDtfc+u4EZUbfsvmHm18woG0xXZ3se0ho3+1Fmow2lR1cYdeblq+MMylKLG9NGELFcBp1c68hDp6aGa98gxJ9TWxuyD3cWEMxwhA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259075; c=relaxed/simple; bh=GEBgT45HCyTyQX6vN1V3U6KUFqQlul0FwxLMGcduzBo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=X1O5ZVElQthlchhNNytKGhgaXt+qN+aue/MVE0nIUKCyZbsVbcBIqya9lnN1fxEZG3XQlyG1wqdfgDsx4PHzrms9fmwBMQFK/TcZIclLQ0oPq4j9rx/ktKXtCziaquv6TcYaa4VzZF4fGPbB9nDvKVcQjl/1VJdtTOF7uq4XigI= 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=c3WV9T/Y; arc=fail smtp.client-ip=40.107.236.88 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="c3WV9T/Y" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=anVbd4dBrW259mqzYjX6INXbCte8OBzmc5hxBZB5Gu7yAdyk8ZZmGzjCqM5PVB5nI4BcxbnA1Xwn2+FZj8uwq0+Pyzf41Lmp3ef7hp0uzM78ouMAVJRpQf1QS7H8mIkAjdIoCj+qtLIa3vozqjWM1OHP8VJrfOAVhaA/9F1Vvg2NvHfir6XvsFBLpRyEC+NxaIciinY6Gni9GdYX+frLc5K3JQIJ6USjc4aEH4X4MyXcLtgpsQs/SJ7Zpth8Lzo2OCGQ2QmAaZYr190S8rhs5qfHQG7Vt61xpiyiQE+boWriaqzjwb4IUA6i1irHXFsxt5dcyVDJICDKNzkgP2c8LA== 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=FRw3jMtytFaKXFztKmtkQdS2KYZAnLmCIu/YhHtVrfE=; b=nPHT9eIhOe53MB6RWU4T0Njfyq7Rzsok0WXm/Y9Oz1fSvHFqvRobETZamk7hhu8X7ZGYvmWnevW7FXeMo9xeiWdEoIgTsEp0LMD2DOsTSH8JoJDRmxQ3nU32DEmkyZjfbDTZDbjMMOV/6xUs+zJbcLUu1ydDdumgBfdAo8Yht228zZrJTbkhrgth++hBTJ6hu3UjXYc5Ki8mFhgJ5j8+j69Vc0GwUpIL4B1bRloaxGgJVXJOYUTxCPUP58Il3EbptGU994x2lfFVx6O+gWKwKtvsEJnVJ2BlKWvn+SmgshUwR3BbPWj/t/MurjVdf12BOksc9XDgwtagZCOI5tvshw== 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=FRw3jMtytFaKXFztKmtkQdS2KYZAnLmCIu/YhHtVrfE=; b=c3WV9T/Yu5y3yqU2Bi/H3SJtxMIQ5YZYk2BeKTkTGFLa7JCmK0WLFqxHrGJ+GNjkkfEPCAopOK2CK+CHrYuHnJ+1WeuEspK6pwkd1VImyWmbnAA+xT5atRFJLYtCKc8dIOV/hBu2zQxnRfCXHPEhquYq1gJu8auTSNP+pwugn+k= Received: from MW3PR06CA0023.namprd06.prod.outlook.com (2603:10b6:303:2a::28) by DM4PR12MB7696.namprd12.prod.outlook.com (2603:10b6:8:100::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.10; Tue, 7 Jan 2025 14:11:07 +0000 Received: from SJ1PEPF00001CE5.namprd03.prod.outlook.com (2603:10b6:303:2a:cafe::46) by MW3PR06CA0023.outlook.office365.com (2603:10b6:303:2a::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8314.17 via Frontend Transport; Tue, 7 Jan 2025 14:11: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 SJ1PEPF00001CE5.mail.protection.outlook.com (10.167.242.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Tue, 7 Jan 2025 14:11:06 +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; Tue, 7 Jan 2025 08:10:59 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Robert Richter Subject: [PATCH v1 06/29] cxl/region: Factor out code to find the root decoder Date: Tue, 7 Jan 2025 15:09:52 +0100 Message-ID: <20250107141015.3367194-7-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107141015.3367194-1-rrichter@amd.com> References: <20250107141015.3367194-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ1PEPF00001CE5:EE_|DM4PR12MB7696:EE_ X-MS-Office365-Filtering-Correlation-Id: 3f79c5c9-282b-43f9-b558-08dd2f2520f2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|7416014|376014|1800799024; X-Microsoft-Antispam-Message-Info: aUUn/X9g35ZhjXj/U5BAVAtmpVCHyjSX+36ivGvZ/xtdPvPjvRGCVc6L10W5xQ+qqjKRxHvAKOywxoKRmWVr3Bb8hHIVLvkS5uZ3aHqP6uYShUCszW2WGRfk/PHcrsY4yxAX9IoqmbKkKC85aYLq1aK78LxNVjihJxorr9uhS2XeaFpWPYgJKbFJzcwM6u61fm61ZKNBvnnrhGsQww7j7Ol06GuHhntglIsLUSuU5q8wlWX0JF1ZOBVZy1juLhyLDO8JBXZzDAMeOqzJhSlzos8atU53NoRtmDElo1OBcJanY82ep5laZHCUPBaWcy90MuVm2viaSX++tQc36rTL8Rwomlq7JhOy9VTN6pZSKYolRaVr+307+BtPIe754T6AG8uaEZNhgyNyE55Il1OYQtzHjdvAOw3kbH/X60t0HgZO1+8q8cQT3dEhenyAZ2jkyKD2D65UJanlo0y4lsXC2Y6B4wjO+qOJx06r2uRvVHp0xyqCH08rbsg3hWbZwbmiJ9eGvEl9tAlN1WWatq045TtCSM6On6Zm02QakMmtYOXv5Wx1fDxZVRabdPitTmhMjCUwd/mKEx43of6GJWOWDnWq46tZSuku1LWaczmK7pE4mAQ5lyHzu2LO45TYAqSOoICbq2BsMs25YKwCDfVUDK4H+7mecqfH9313WTCe9Yqk5Jfkkuyo9CvPb82V/EKRsHxHrMQmuju6+Ua/v/DREv3DN3UFrSaiyCKKXfzh3ETVc6AmzLylRTGFbWsg+3F1LCj0YnvnRK6rvQVoAPfqWDVwaysy6QOlZNv0NFJuJy9GGxQAn0DNYPQ/z0JM/OVhNbt1B50IuiFvVywH2Zg7UT2iHzJY6/mQ+v+1r+g4JzJvFQQ+JHS6uAzgoyVdTph6Z1hncJEjZ/RJWiOZoC4A5cVaEqBRyKA+8T6hSmLfjd8A6e9XCnfIdcvdLpquONndXNIAZ9k3E51rcDoKUbUfOWAclGWboMgqkJfUBAap4im2hvuiiA7JEKI0oGY5EBkpS89NEx+QRR8fOTLiQXr24Cia9xFe28J8NHULw9krrwk7+rN0DFXu/Mn60i2hfzCX2+zDBBybIxcbEQJsxhoxuFRwK95miQMX6GXiyh7c3DxXsgdH+g5dmDfZqhYdZIxSrBNl7MSbDr+JWWUnpzcjckkg2Y2OwbdykkH311MdA6YsANJaskO7/Y+kAI31gPL/q/iPGfAPtDL2Lx6IXppHLJ/FvEX2s1OEgXBQbjvjInNn4lP7scGcRzwFKcjvHHqB6UYxuzevZZ27qoqY1l6UZeHDnSxoeNJfeu7vfsoQRSYwqjMmtMArQA1Hf0GYZHybgo9sypQn61Wo3fsnGMoMnGjaBvSmw0SIsYmaWPXTlvVKda5rvwR+GVLChb8ETojNZu6rtgBYmYzV2b15qplVCqa0sHhPPzmYgJifVgyd2mhWe61Hg1lEySX2KgsjlbAipswmgqNglimpJdzrwSZI6a16i1qhHfqRwogO5oe9bQ4= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(7416014)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 14:11:06.7988 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3f79c5c9-282b-43f9-b558-08dd2f2520f2 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: SJ1PEPF00001CE5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7696 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 also simplifies the function cxl_add_to_region() as the change reduces its size and the number of used variables. The reference of cxlrd_dev can be freed earlier. Since the root decoder exists as long as the root port exists and the endpoint already holds a reference to the root port, this additional reference is not needed. Though it looks obvious to use __free() for the reference of cxlrd_dev here too, this is done in a later rework. So just move the code. Signed-off-by: Robert Richter Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron --- drivers/cxl/core/region.c | 55 ++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 752440a5c162..448408918def 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3202,6 +3202,38 @@ static int match_root_decoder_by_range(struct device *dev, void *data) return range_contains(r1, r2); } +static struct cxl_root_decoder * +cxl_find_root_decoder(struct cxl_endpoint_decoder *cxled) +{ + struct cxl_memdev *cxlmd = cxled_to_memdev(cxled); + struct cxl_port *port = cxled_to_port(cxled); + struct cxl_root *cxl_root __free(put_cxl_root) = find_cxl_root(port); + struct range *hpa = &cxled->cxld.hpa_range; + struct cxl_decoder *cxld = &cxled->cxld; + struct device *cxlrd_dev; + + cxlrd_dev = 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; + } + + /* + * device_find_child() created a reference to the root + * decoder. Since the root decoder exists as long as the root + * port exists and the endpoint already holds a reference to + * the root port, this additional reference is not needed. + * Free it here. + */ + put_device(cxlrd_dev); + + return to_cxl_root_decoder(cxlrd_dev); +} + static int match_region_by_range(struct device *dev, void *data) { struct cxl_region_params *p; @@ -3309,29 +3341,17 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd, int cxl_add_to_region(struct cxl_endpoint_decoder *cxled) { - struct cxl_memdev *cxlmd = cxled_to_memdev(cxled); - struct cxl_port *port = cxled_to_port(cxled); - struct cxl_root *cxl_root __free(put_cxl_root) = find_cxl_root(port); struct range *hpa = &cxled->cxld.hpa_range; - struct cxl_decoder *cxld = &cxled->cxld; - struct device *cxlrd_dev, *region_dev; + struct device *region_dev; struct cxl_root_decoder *cxlrd; struct cxl_region_params *p; struct cxl_region *cxlr; bool attach = false; int rc; - cxlrd_dev = 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 = cxl_find_root_decoder(cxled); + if (!cxlrd) return -ENXIO; - } - - cxlrd = to_cxl_root_decoder(cxlrd_dev); /* * Ensure that if multiple threads race to construct_region() for @hpa @@ -3349,7 +3369,7 @@ int cxl_add_to_region(struct cxl_endpoint_decoder *cxled) rc = PTR_ERR_OR_ZERO(cxlr); if (rc) - goto out; + return rc; attach_target(cxlr, cxled, -1, TASK_UNINTERRUPTIBLE); @@ -3370,8 +3390,7 @@ int cxl_add_to_region(struct cxl_endpoint_decoder *cxled) } put_device(region_dev); -out: - put_device(cxlrd_dev); + return rc; } EXPORT_SYMBOL_NS_GPL(cxl_add_to_region, "CXL"); From patchwork Tue Jan 7 14:09:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13928996 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2078.outbound.protection.outlook.com [40.107.237.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 C94821F4290; Tue, 7 Jan 2025 14:11:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259079; cv=fail; b=ZIj2Gckmme+KOxT/Z6KqSIOPkOhnFLaKWVdz64rGSLV+Gj0XPwh2jaG/vjZiZWA9QhnIZ8FymyGkCPIygKpJLJ/eYsx2pClvVhe19bWt3KR+sL8rVIEVj1ckZ/sLEbeMjYj7YM5KZdWnQitkMLIADpANeBJamY/f2H+JpsWKjzI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259079; c=relaxed/simple; bh=v5zOdAXmY514DJ2y8vIubrkkPqVRfqsAreOVLPKVHfM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IbxgeSGnb4OGatvyxZbz1u1ayIKQ+AzVx/4Ul+T+QGER/ThQKJ7SVGjgcdihErhsENfl2oTBJmYn6TXfA6l1gBB/VmHbEMcAwGa3tZvLtwqq6F+xJOWYBr6yaD6l3ciwWIQkbx/Rf9RWEpckyaQw7l4sm2RTysfXz9Uj96Gfd6k= 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=pPOKHlDY; arc=fail smtp.client-ip=40.107.237.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="pPOKHlDY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VddEnoJBsN5PrH1KLZIBKqnIdBOAT+p78mXynopaFzJHwQU5toVByxEhss8TjJhRO/rP+QkB0+OPD/UnF4OwJfETxsDanD0IcfMJpP3dYRfL9J2ajV3WFkGa9ZgbSd2coSem+No0DJSFchnGYnaaesyvd99gDpau+GcRVB1aWmHNIAklP+1fBnHZAxOUSSIVuo+v6Q3wYjBVT9IrF8ovilwiUa5JVlJw2LB+kZ/zyhDiTAgNMJ8TDtDJaM59Wf3EreLmD2elQX6zDG0JInh+QIXzBzhYMRdjxiS85tCMgtCVkGp+LY31npdCeGSlWE0WWxEqajeKlIRpzqvlTeEPbw== 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=JgfFAfWnt7uw8c3XpwKFfdt+2xDGEfx+G3Ovz0C8tJ0=; b=SfehcLxTd4DE4oaWjVanW3OfGjE2H4oO/ifkGOKhQoyHBrURpF5b1llWjtF+xBWNqIIQ5Y7C+5v0refpP+dKUKzUvqzPnn47aI+4fdyWpV9cdeNC4OOHTxOU9mqHVbe45R1C3153Eme8/+GfjDGKQ2dbtLQTpm0f6cRe9cNr3cmyrkf1eYNENNBZVKNanu9nrn+6HIjKSO/SipDpTtZm1SYghMJV+5SYi2KGLiOa0vP++bOdGyfPEwGGyUZy47J9TM+dxk0NN/43o6LvA/ibvJpvpyIkoba+JW6yo078TRQsnezHyYqtEpkbseULjFHPNP/TXUiKxYaAecXuzrSbFw== 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=JgfFAfWnt7uw8c3XpwKFfdt+2xDGEfx+G3Ovz0C8tJ0=; b=pPOKHlDYp+cWrQZyRflMHgDNRmUwWY6aGCZEiFYZOK4qZx64OEF62Dbz3T8s5nAbHBDBA+hia65yV9bJj4qxFAVLIGrDJ+kE83HOfWxSXAwGFIV0E1rplXy39bEbfmolEtJBPNGuktEmQ1bFQfAS3IoW9x6aAO7iBSuM9xK/i8w= Received: from MW3PR06CA0024.namprd06.prod.outlook.com (2603:10b6:303:2a::29) by CH3PR12MB9344.namprd12.prod.outlook.com (2603:10b6:610:1c8::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.17; Tue, 7 Jan 2025 14:11:07 +0000 Received: from SJ1PEPF00001CE5.namprd03.prod.outlook.com (2603:10b6:303:2a:cafe::1) by MW3PR06CA0024.outlook.office365.com (2603:10b6:303:2a::29) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8314.17 via Frontend Transport; Tue, 7 Jan 2025 14:11: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 SJ1PEPF00001CE5.mail.protection.outlook.com (10.167.242.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Tue, 7 Jan 2025 14:11: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; Tue, 7 Jan 2025 08:11:03 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Robert Richter Subject: [PATCH v1 07/29] cxl/region: Factor out code to find a root decoder's region Date: Tue, 7 Jan 2025 15:09:53 +0100 Message-ID: <20250107141015.3367194-8-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107141015.3367194-1-rrichter@amd.com> References: <20250107141015.3367194-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ1PEPF00001CE5:EE_|CH3PR12MB9344:EE_ X-MS-Office365-Filtering-Correlation-Id: c5ec538c-1136-4faf-6185-08dd2f252160 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: mcSFVvYfsePmFN7gUMCOznHXiQ4eckPf+cc6RuKwxI+WRXkJoA1643KLasfA7kZaymDWdYbitamqBteJMUzcWaIRVQMCRqLnC8VB6wbc1hwZh9+waVluWnbtQcm5jAAr3BMlHU+7nG1hCmhUrVYlecvjUxJNImCo9BE6CtItxQDitPb4UsHlwJoYFGn7oo48IIrpjovIaOox711RvjRnpxledsgvUgz5X6x3NqQvugm+ydXfxtXK7ofdBVOabNxotCTCaQJVcdvup3UD32H84vHeF0OhgxCR9JJuU6Zu1uWDGyUq1lKdlKGBDwJtdb5yU5oCsQYrc+2g1MvMU5zqR/ATDGFuiLbH10bAvkbmwHheEtvaITHlMWKVwBPLg0g5zoqiI6WlorQyJt1c6bMPGJxNPp5X1MsuCY1O7flqtKHOg2WZaOMndWTWd+F8NwwlQBCAaruxcZXDOeqTHh4x4OlDFE88rmxyv+h1eA/t+15j0G5FY6kIbxFzePKkzqVOaowjn5eOErGbnU/K/mLS6WZMNHLWbhNZbi2ipK9NSdJE0fKNDimfBd2DFNi33PxcoTEvF2qqZPqr58bsZbxbShWASn03QlZJ4SqzEWTPzjPdfg59X06utGVE/7adIeY6SWkoeVG06H/ibDrFBPioXxXYLCesA7Cop+6a0pzSzqhto7F8pR8vtNIUnWfUlW/amk454h1MQsrSm0g6/dpwBIbW9Gt1Ck7I+i/KROLaq3dcZ/uElNb529RLygC9JaFlA7ardABfh4zd5Oo18w7KlrVfPJu5+TQ2Atb2RWkSBq6vNNij2oJ6qliDbEnhtvOgNTYS4/2nDQdOEfpKUxvaALkd3JjPZ5MQXdSYgT8SeMMEq5gNiMAIrFoaQYgJaEtpFHyQSjbhJjVI0zvg/132+46pYLKcbaojcDVnY0hAzSrTKruYeRYbKZkKph72mBDerpSNDkIomiHVaUDpFWZElQJ7EQsqQP/njOHjkqm5G9hXZbTFVb7IWvC5j8JEr7FiFRjRkf5JhlAsgRFIm3PdFViGsIXRaaRq/riKozUiSfHe5P3H0SRBXuav3L2Yzl+nl2gx1rVhDh/N4DH7fls3VgmrqXYo+fgMQ1gLGoVbgb1ofAqY4gG3v88Pse4F1rXipSOmHuPlOkGTCqEn2jbDF5C0I1IUCiCeWF7c/sgoxNsBcBDsNOJUdDUSMQdH17ZSdu3RseLiE0RkCDOx0tuN71Y6YXbVWPuXlw+IIf18eUmZGqvekcyKtGo6AIzpQPzIdl1aten3o5FRn0ShUJuh1DtClKi0VsmGi+LgwyVjiQaRxPKjRDz3Lw4Ezhda9LpftO9KL+XPNmbg5pgujod045juDLp74Ako4zQn3Tb8tGdJUy4Jnrqy3c9DoxMQo9GBDymrSu1ZJvpmr6W0hWzrsOfNM8v8p67behN8Ogu8rAEKAc+azafpFIPE4EXNX723fyzP+WpcHcwp4Rb8Lg+E90E+uCIj7T2xsbjJBz6xxWI= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(1800799024)(36860700013)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 14:11:07.5175 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c5ec538c-1136-4faf-6185-08dd2f252160 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: SJ1PEPF00001CE5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9344 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(). No functional changes. Signed-off-by: Robert Richter --- drivers/cxl/core/region.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 448408918def..d5dcc94df0a5 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3255,6 +3255,19 @@ static int match_region_by_range(struct device *dev, void *data) return rc; } +static struct cxl_region * +cxl_find_region_by_range(struct cxl_root_decoder *cxlrd, struct range *hpa) +{ + struct device *region_dev; + + region_dev = device_find_child(&cxlrd->cxlsd.cxld.dev, hpa, + match_region_by_range); + if (!region_dev) + return NULL; + + return to_cxl_region(region_dev); +} + /* Establish an empty region covering the given HPA range */ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd, struct cxl_endpoint_decoder *cxled) @@ -3342,7 +3355,6 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd, int cxl_add_to_region(struct cxl_endpoint_decoder *cxled) { struct range *hpa = &cxled->cxld.hpa_range; - struct device *region_dev; struct cxl_root_decoder *cxlrd; struct cxl_region_params *p; struct cxl_region *cxlr; @@ -3358,13 +3370,9 @@ int cxl_add_to_region(struct cxl_endpoint_decoder *cxled) * one does the construction and the others add to that. */ mutex_lock(&cxlrd->range_lock); - region_dev = device_find_child(&cxlrd->cxlsd.cxld.dev, hpa, - match_region_by_range); - if (!region_dev) { + cxlr = cxl_find_region_by_range(cxlrd, hpa); + if (!cxlr) cxlr = construct_region(cxlrd, cxled); - region_dev = &cxlr->dev; - } else - cxlr = to_cxl_region(region_dev); mutex_unlock(&cxlrd->range_lock); rc = PTR_ERR_OR_ZERO(cxlr); @@ -3389,7 +3397,7 @@ int cxl_add_to_region(struct cxl_endpoint_decoder *cxled) p->res); } - put_device(region_dev); + put_device(&cxlr->dev); /* cxl_find_region_by_range() */ return rc; } From patchwork Tue Jan 7 14:09:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13928997 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2053.outbound.protection.outlook.com [40.107.94.53]) (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 7BCD21F426F; Tue, 7 Jan 2025 14:11:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259084; cv=fail; b=clS7SULmyXDKFpy4o2TE8wothT545q/yGUgRVvDFQ2Lhg4d7AjBYL8Uq4DIn807y06PMJIU3m9PDbE2BL2dI9iZ5BzccvyemKqYl8rB/Ux8Ms/1CLDTn15KvEc4izM4vblMgMXwlGgGFrjbLBkP7r+uz7U027rQxamg43ebspvI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259084; c=relaxed/simple; bh=D8D4TiZr2Mr5x74yHIEneazaWUKU94MjpZPQQrtjSqQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jdzht2pvvVDt1GdbPsXNQND76QKJKDTBhapaBR9RLdD8W7Jh1zEXDlY//hZMAbeW1cPsEnDuDLOimi57h0D+fiE3ENL+BsEC8FesojZLOOykQYn8gYXhI6LKyyO+m3Mr+WmqUTP89TB+6Iz5D1+y+MWvrY9uKo/beo9jfALLsUU= 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=2hVPlTlf; arc=fail smtp.client-ip=40.107.94.53 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="2hVPlTlf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NNq4oPOOFcBLj6pitEZFEUYfkU9PRszlAGX5i23o/Joxxzu+LKxhC4t5ODhfGECEcRdIh+zzrzJSrde9PC//EEX1SzQzMpeCY/p36sJrtiANnpiDv1fBJjxDz4doy7XDoAwR6BU+QSGCQMmdEou6Wo1oP6GJ8NSEdDhQYqGoqZNgjH+8urvUbbYIV8pdD7d/95KkFDmWH1DOLJR+Ko7B7oADR5ltr+K4Du/Gk8lLhxoygkoaUwUDxMc/O2sUOIsFhzzqjYC8V+Fxf5fvxBadKfhnda3U5uze099O1RBGFtA3Hzn/FWf58Aubjiw0zNg08bPDwS0FQhktfB/P6oOKrw== 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=nmALJ4MCR0cxq6nfoulbQnITOkOCtVHtbUVe2nKR3Dg=; b=oRAu6rzYtUGwYIgl5s5jLrKvXg1Pxf+I4CZGmPLr9kGQqmAfW+Ok+cisbEoJ0WsikfO2ir31xkvzeIgNCTV0XsH6cHLLprn4VdCLc3YWr3BWcVAh0Y5hSDiX5N0rIQRFvwL1sauxugntIdaox8bPW8OgmD9tiL5QI6LEgiucbHITP6AoUl2tYyY/b9Szv0zQbVJIceBxi4phPVIVStEPexZ0Pulcs4V16NPsMkDr+pAkdoLvkvcaJOhUaSlEIpxtYwcupV2ZUbHtRvoLAlVgbfC831J5MgYKpBjSkPhcnDRea5RWJZyPh0O0EdIypyOttVosyFxyiwxbyfaj3cvrsA== 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=nmALJ4MCR0cxq6nfoulbQnITOkOCtVHtbUVe2nKR3Dg=; b=2hVPlTlfvKWscstkplfGdltqDuwFcGCvkg4QgE2ztEfXKeL0yJvkAw2Lg8z0p5bU+0RxCCYhT4DrJCyrXCVoehNdiic2srAcaiEdcus59atm1LHbcyU5zU8O3mHBoeb0iatCFg/BE2AiWoM0fPagwvrNhnmpWtRFH8/OVJ584KU= Received: from BY1P220CA0021.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:5c3::16) by PH7PR12MB6933.namprd12.prod.outlook.com (2603:10b6:510:1b7::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.16; Tue, 7 Jan 2025 14:11:11 +0000 Received: from SJ1PEPF00001CE9.namprd03.prod.outlook.com (2603:10b6:a03:5c3:cafe::74) by BY1P220CA0021.outlook.office365.com (2603:10b6:a03:5c3::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8335.10 via Frontend Transport; Tue, 7 Jan 2025 14:11:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CE9.mail.protection.outlook.com (10.167.242.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Tue, 7 Jan 2025 14:11:11 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 7 Jan 2025 08:11:07 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Robert Richter Subject: [PATCH v1 08/29] cxl/region: Split region registration into an initialization and adding part Date: Tue, 7 Jan 2025 15:09:54 +0100 Message-ID: <20250107141015.3367194-9-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107141015.3367194-1-rrichter@amd.com> References: <20250107141015.3367194-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ1PEPF00001CE9:EE_|PH7PR12MB6933:EE_ X-MS-Office365-Filtering-Correlation-Id: d99f7582-f6b0-4a9d-3b08-08dd2f2523c1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: 6Liq+QoX1PCxgQ6NSKw3WBD5nKvmFbCDVVbaRvTap5z/ovG8pnJciLFac+kTCoFRp/npDNP+FbIjOcl8Ebyba0zBOK0JcsXZtkbas5Vpb3/21Y3zd8528xsj3kssNbPEMA4IgfzGW93uNcaHyqjPcBg2rAJDtUokze0cxggRYiqTQvEklph9NrCJiHPz0mDZug9fPCPShN3ezSzGkcXysSGsmXebAGuLHOLk29x6xDEGzl9XumcghmIT1PxArwiYbFQSN46e8VTsmj7coAiDVAHKxv0RCODq9sJyJxi8zfCb7jdfPEITyyTaoFrzb0aBCISnzYOCyBqVfKf8NjD3C+jWoi/svRG2Uxc7JWVc3c/BWOdi/zbfbeNuEzHZdUXUz7lGu+YgSKmR07f/c380UokKpflHVmr6q8fo/RCJV1WSvpsJeSTBQLNSAxd5uhclHFookRUHD+zz6QkxtCVuGS5bd1tDOzLMgGuNiJZPSneChWFUs4Y6JekxwXD2VWyabVuOd5OmW22LsVRh7M709m+IvfdTvCXY/gkbtwVoOxu0QQKI5CavAk5/P9HkS7kRHgrUYggc2lnsX8siOdeIhB4A8TUXPIybaNwWAQ86FYpjH+Yr5HeBgjjMl4Whn/U9AhIrhTzx9W4edCik3p+Vn6B676AuNaOUve4443oVGJp1V8yHFHi+hf5pxTMTREq4pcMYbKX3V9rbijBz64BAmdcmg0TAOb/nF/gwRtdrz0gUXZ7Z3gvET7eGK1EMFYv6DrSCEtxyw69l/trNl4ud6yreo/Jce+hBvhYRaZ1xS9/xGqJGr53W8kGNUnc4R9Sjx1rXB064Ybj3E5fQFYY4vIYzk9EPak1A2C3CcYe1sp+ljoMiPSYPeqm15h2VHc0h1cFJOMF1xLbmhMlAlt5reXB2o0CKj727ZVv+nZ94vM7O7HD1z6aR3CTHbpYYA6QZbYvbXl/1Ivx2N1QmLlWIztdDdJdM5OniiQge7xU6k3YplAO//BdDGQDcGMRoAZnexlopkSdQskTdzHw36i3HsrWTlN2bRczcgCyKEOzduMj2nmRb4oKaIgFo90SWonv5xCTQC0/Q00D4eNI/chDjRfcKW1ykFlpOAjiBq0hZpJgjZv5jlCAK5PftDGoZbbeSmnpTf1h+/bn+x9YQ5YEs5w0NpzJPiFGX9wbokAoxH2n7Vpd81TalCZZ8fIOU1jhA00K5YniXbU9gASW/3wxjejrgKyby7SISCvWDFF6YHJxR11UpF89NnRR9Pk0xSVN4SiOVsBu+KUT64xMKw8/osFJa47iuQ1Eu3/wZTEMz32AjODSwmjHMCwYE6vinaEwp0HEPKBf6VgAK9+Pbe8hwL2NDn1OjptaLUU/+TFuTgiynQAnGKG6PRxr/hsOlagtX6JcXJNbq46rPgJ/Y34ww8feRXHorua2CnjwvAV8Vc1kVBJAP3k7sF3AzUZ6eKeViVX0pR0TusIjkRS0Vzr9tjnQlBqWzKLOBxmxOxBJKBAc= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(1800799024)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 14:11:11.5077 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d99f7582-f6b0-4a9d-3b08-08dd2f2523c1 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: SJ1PEPF00001CE9.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6933 Before adding an endpoint to a region, the endpoint is initialized first. Move that part to a new function cxl_endpoint_initialize(). The function is in preparation of adding more parameters that need to be determined in a setup. The split also helps better separating the code. After initialization the addition of an endpoint may fail with an error code and all the data would need to be reverted to not leave the endpoint in an undefined state. With separate functions the init part can succeed even if the endpoint cannot be added. Function naming follows the style of device_register() etc. Thus, rename function cxl_add_to_region() to cxl_endpoint_register(). Signed-off-by: Robert Richter Reviewed-by: Gregory Price --- drivers/cxl/core/region.c | 36 ++++++++++++++++++++++++++++-------- drivers/cxl/cxl.h | 5 +++-- drivers/cxl/port.c | 9 +++++---- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index d5dcc94df0a5..5132c689b1f2 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3340,7 +3340,7 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd, dev_name(&cxlr->dev), p->res, p->interleave_ways, p->interleave_granularity); - /* ...to match put_device() in cxl_add_to_region() */ + /* ...to match put_device() in cxl_endpoint_add() */ get_device(&cxlr->dev); up_write(&cxl_region_rwsem); @@ -3352,19 +3352,28 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd, return ERR_PTR(rc); } -int cxl_add_to_region(struct cxl_endpoint_decoder *cxled) +static int cxl_endpoint_initialize(struct cxl_endpoint_decoder *cxled) { - struct range *hpa = &cxled->cxld.hpa_range; struct cxl_root_decoder *cxlrd; - struct cxl_region_params *p; - struct cxl_region *cxlr; - bool attach = false; - int rc; cxlrd = cxl_find_root_decoder(cxled); if (!cxlrd) return -ENXIO; + cxled->cxlrd = cxlrd; + + return 0; +} + +static int cxl_endpoint_add(struct cxl_endpoint_decoder *cxled) +{ + struct range *hpa = &cxled->cxld.hpa_range; + struct cxl_root_decoder *cxlrd = cxled->cxlrd; + struct cxl_region_params *p; + struct cxl_region *cxlr; + bool attach = false; + int rc; + /* * Ensure that if multiple threads race to construct_region() for @hpa * one does the construction and the others add to that. @@ -3401,7 +3410,18 @@ int cxl_add_to_region(struct cxl_endpoint_decoder *cxled) return rc; } -EXPORT_SYMBOL_NS_GPL(cxl_add_to_region, "CXL"); + +int cxl_endpoint_register(struct cxl_endpoint_decoder *cxled) +{ + int rc; + + rc = cxl_endpoint_initialize(cxled); + if (rc) + return rc; + + return cxl_endpoint_add(cxled); +} +EXPORT_SYMBOL_NS_GPL(cxl_endpoint_register, "CXL"); static int is_system_ram(struct resource *res, void *arg) { diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index 5c1a55181e0f..b3989dc58ed1 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -417,6 +417,7 @@ enum cxl_decoder_state { */ struct cxl_endpoint_decoder { struct cxl_decoder cxld; + struct cxl_root_decoder *cxlrd; struct resource *dpa_res; resource_size_t skip; enum cxl_decoder_mode mode; @@ -872,7 +873,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_endpoint_decoder *cxled); +int cxl_endpoint_register(struct cxl_endpoint_decoder *cxled); struct cxl_dax_region *to_cxl_dax_region(struct device *dev); #else static inline bool is_cxl_pmem_region(struct device *dev) @@ -883,7 +884,7 @@ static inline struct cxl_pmem_region *to_cxl_pmem_region(struct device *dev) { return NULL; } -static inline int cxl_add_to_region(struct cxl_endpoint_decoder *cxled) +static inline int cxl_endpoint_register(struct cxl_endpoint_decoder *cxled) { return 0; } diff --git a/drivers/cxl/port.c b/drivers/cxl/port.c index 74587a403e3d..6eb82a118bd5 100644 --- a/drivers/cxl/port.c +++ b/drivers/cxl/port.c @@ -46,13 +46,14 @@ static int discover_region(struct device *dev, void *unused) return 0; /* - * Region enumeration is opportunistic, if this add-event fails, + * Region enumeration is opportunistic, ignore errors and * continue to the next endpoint decoder. */ - rc = cxl_add_to_region(cxled); + rc = cxl_endpoint_register(cxled); if (rc) - dev_dbg(dev, "failed to add to region: %#llx-%#llx\n", - cxled->cxld.hpa_range.start, cxled->cxld.hpa_range.end); + dev_warn(cxled->cxld.dev.parent, + "failed to register %s: %d\n", + dev_name(&cxled->cxld.dev), rc); return 0; } From patchwork Tue Jan 7 14:09:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13928998 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2045.outbound.protection.outlook.com [40.107.236.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E1551F4E50; Tue, 7 Jan 2025 14:11:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259084; cv=fail; b=MzBYJMsO+lX7HXQy8CPa+NtqK+5K4fn3FtevAjCTHaQyLBfB9bWheCxTPyp5WPUVynMPN8MJkkK3iAQOFFDwLybNYrgeM+4wOSbI/rpVeIR97+L834xLFs6GUvEJYtO/LpNIlcmdbIxWzypSO+5lEIlknwhXHFLSsX6aVJCChJ8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259084; c=relaxed/simple; bh=KoKPF1vGlbPfl48GP3dZ+l7Bif0iVRlg4NOJ1+Sp1Yo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AK9AWjhqp2E8FLxV6dIFSPRAaVN/ZEvtNE8gHCqnalTmjeJS4zyIW2/RE/oFZjXQVU4FJsroeLpTwaHsi1lXZ5IxdhkbfEndrEhEDLMo/fPSWILQYHzV1OdM1Ncl+qk5m4esDPo8NfJh1pUmLJp1hGO26rLj+DIbXFY0lCWqlqg= 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=Oz6aoU9T; arc=fail smtp.client-ip=40.107.236.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Oz6aoU9T" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cQFH1ZAwwisdLpR2r2rpGojDT8BUE7AjWckN0+c7OCii+DbG6tb6y5hiR3OZ3ZYHK6szisOwWtN3Y5wv1CIJCyTZ91y/ifvHXRDT04WdlKGL3ep7E11wxHuHEVmxiKJalhEFe4V+6IicNsNSZ5a81ZfUZqyZrnD/KiyKkbGH0wrA7YjHiP8gsd4khLGm3xfeME2QBMif83NVDpXt6s3X1XR6UhQQqWypQiaFUbdeKWlhd6A35YTcB5wQ7Ibid75EbmHx5sbmoX/VM8XsDmbSUfLZ/v1ai4Czmb8DrFF55JCmPMkm4t6rrjZkan1yO57e+3uq+NHktaAhyE4TYxpQnw== 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=c9GZgDboK9f1t6dTj9Dr2LnfwxuZgxoMpReJXoWfotY=; b=Zz/oKJCiXGtHruJ17y7FFbMYq04IgOIbIpPuPLGGQFVFciEsz1TWOYW/ejCgIRTrw91PSEyeSOj4f4FJfgh9LROJ0AOXnomsrRCzl8pbZavo+TDChOjjKN3efdfuIVqysWzphDYzQRZi2Wz7e49H+BbNxHqv6F65PhCtjHpmW1ULUUn4y21CYFsoaGb3aa4KQ5R9kdQ53f4W5gN6eEC4qJlxPYIQKDt6pnDNQaRV1npHFLZF3xM6PraFzt2e7CZ+R5r7VA6Vo2rxIH01kdBmZDDbG9O9vjSHdxVfHaIf1Uha7snG+/TMoPbT7ioH7tiMXashG6orZTCe16Ho1t8lZA== 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=c9GZgDboK9f1t6dTj9Dr2LnfwxuZgxoMpReJXoWfotY=; b=Oz6aoU9TbddjjiywMuzg5TZXoIxvZBp8FBcsZfwgcyDQKrgnT50ZsDYDVc8RKFzBZ1w2qAa05UgdpvLhpxTuaLY5XQcDm9mouNBX8rzBVMw3AG0pukh9TArknjvU2VzNrH23gHdCfRSN7VRUxh4R/mxTC7rjgDPw+CyqUInjo1k= Received: from MW3PR06CA0004.namprd06.prod.outlook.com (2603:10b6:303:2a::9) by DM6PR12MB4155.namprd12.prod.outlook.com (2603:10b6:5:221::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.10; Tue, 7 Jan 2025 14:11:15 +0000 Received: from SJ1PEPF00001CE5.namprd03.prod.outlook.com (2603:10b6:303:2a:cafe::d5) by MW3PR06CA0004.outlook.office365.com (2603:10b6:303:2a::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8314.17 via Frontend Transport; Tue, 7 Jan 2025 14:11:14 +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 SJ1PEPF00001CE5.mail.protection.outlook.com (10.167.242.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Tue, 7 Jan 2025 14:11:14 +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; Tue, 7 Jan 2025 08:11:10 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Robert Richter Subject: [PATCH v1 09/29] cxl/region: Use iterator to find the root port in cxl_find_root_decoder() Date: Tue, 7 Jan 2025 15:09:55 +0100 Message-ID: <20250107141015.3367194-10-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107141015.3367194-1-rrichter@amd.com> References: <20250107141015.3367194-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ1PEPF00001CE5:EE_|DM6PR12MB4155:EE_ X-MS-Office365-Filtering-Correlation-Id: 0c711214-ed84-4567-3179-08dd2f25257e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|376014|7416014|82310400026; X-Microsoft-Antispam-Message-Info: X1SHSPw1pTWMmOlwP7ZEjsvr1n6ic8hScbRCPiyj0mB/OH8jnY7vG6XDKM4ms7JWCC00qdrS+sOmlpq3t6V7CuDyQ1YeVz8lK2bCEdPLT/ML7YJsEEEfC5pRerX+RXUgFAnpAZdLQx1eVynQYbkgy1J9rCdH340TlkRXqjyXe+cuaqaq0bCKwuZOEeAikKdd2KCOdJKAjQX48p5L5m0jn+ch0ZFNYWdzVAKpMXqO+VFHEcWqkB52axnla3C4hUf60lCTirOSRNq85lidf5hP4AA7qD/61fphMBbIP2FVjOlXGcR6l1D1rlMKLW60wJbXbkfHfWS9VTQT8Mek0BMdEQ1I7Pxfeds6oNkUYfjenARswdG3GDWdlXTA/w01Z9hQcriLscHvhNwk6bYKZhC7K34H9KxNQnfc1AvtXVJVXXm7HCE0ldj0OKGBJUOfsOv/7a7Cv2C8cr+NHk28jQVbutujs4/VdpC2vHxl+Odcp61WgZDyNSppiiTCX5HGrh1EIqbH+fQo3uNGyJ22pezlMzoI0H8JsZGH+bhU+KYWhLpkhPeYO7C7qMY4hvFdTU0oWLoQbg7E1wQqb4ZgC+gAsEPGFcA4sY5ED8cNnkXbxwCGnTpmuwk2Hm4Uuit1XD7tV2z9Z2KunUGUPq6W0qkLfg7eNjd4yvZf1IlAYV2Ep0W+7NAHPe0MnYSPnsMzQVaLY1r8I4yE7jL9Cgmcdk/KI1LnggjP11q0r8+erBaIuOJbttxYus3FzCow46tJVdMSYIY4OL/hrrTmOqILgDqijEh1Ga99XrP2jngY7Hx5wA1ouLiRaxFjg/gbJiyJXJRSppj3a5Gw2v3LhCi2/0fxSxmK74AlAr0PYGsglhbxYfhgcUYDDws+KTmmNIJVHJ1aBjyKWeQFqwNoD3IArqZI9sxJOnYtq6Q/v+3WnVf0te2B/EKWJ61Ur7ozyp8fyfAU6fb8KNoEDwZV9jgQ9W7LyToZFhydY3sOiG/0woR4l4HvSuby25Ynt/TZe0AROnvn52oMy2iSZk1ePk3ab5px5LsLVrnL6yfp0AvpgDjAUTNlLJdODePb5VAx6trJMvAc7wUVCU4Z0S5RJajFUPxzt7gioPFNRgbOQdHKyW5+/VZ44+2sFlwU0PTjQODbiihoKP3lnFGSP6E1WVACy8EtaxgYWzy4A0e2GJzSiLVW+TTcWFwBGd++SRmqbKQbGhoAKUHGBmfkb0rKinw02udc+1WzNzjpCH+2qJ2u3OzqEQHnFRTOnlW5yoiwsaKWB/XKA9SWtgPPmLabKq/AHzixYhZkDkZQawg/WXSB07zzipY3lba5KmG5n5ph05rewt7uM/i9Q2Yd4lUo0XuOhiuY+qKhnPImJ06i6CgDuDH2d/W0MPdaz5TTT8IxaqzdLRyE5Pq6GQ7g5SWPHi8pd47xSm46Zl5QfdaMQLJK+iSTkZkI+OoklBfyfpQ6rECPBz8ZS39dcvqfxn8DaJRGfHdO3qkh38X49VlCGFffuKChvnU= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(376014)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 14:11:14.4238 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0c711214-ed84-4567-3179-08dd2f25257e 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: SJ1PEPF00001CE5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4155 The function cxl_find_root_decoder() uses find_cxl_root() to find the root port. For the implementation of support of address translation an iterator is needed that traverses all ports from the endpoint to the root port. Use the iterator in find_cxl_root() and unfold it into cxl_find_root_decoder(). Signed-off-by: Robert Richter Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron --- drivers/cxl/core/region.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 5132c689b1f2..5750ed2796a8 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3206,13 +3206,18 @@ static struct cxl_root_decoder * cxl_find_root_decoder(struct cxl_endpoint_decoder *cxled) { struct cxl_memdev *cxlmd = cxled_to_memdev(cxled); - struct cxl_port *port = cxled_to_port(cxled); - struct cxl_root *cxl_root __free(put_cxl_root) = find_cxl_root(port); + struct cxl_port *iter = cxled_to_port(cxled); struct range *hpa = &cxled->cxld.hpa_range; struct cxl_decoder *cxld = &cxled->cxld; struct device *cxlrd_dev; - cxlrd_dev = device_find_child(&cxl_root->port.dev, hpa, + while (iter && !is_cxl_root(iter)) + iter = to_cxl_port(iter->dev.parent); + + if (!iter) + return NULL; + + cxlrd_dev = device_find_child(&iter->dev, hpa, match_root_decoder_by_range); if (!cxlrd_dev) { dev_err(cxlmd->dev.parent, From patchwork Tue Jan 7 14:09:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13929000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2085.outbound.protection.outlook.com [40.107.223.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 727F61F707B; Tue, 7 Jan 2025 14:11:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259093; cv=fail; b=cBD85YFnaik7kTQH14Wptv+m2Eq3pxXrZUQSQiqw0RV//RYO6/OBlJyeHrexyYaH1dJAvFe+c2GG3xJ0pI+aSu4fsyMkEaDuRHPv7NMqw0bYiA64Qd7ImAzlvEb06fUfJD7A9T+6KO0iPZTebVNkC3mCG4ICHS0d79CaCq3Jpag= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259093; c=relaxed/simple; bh=E2wpDr2qVc2Vj8Q3mc2S+KFC/Y7JLMXW8cpFHyq740Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=usIL8RA16X9xLjp7V3WhugnIyKb0P/ov8XlE+52AwpuAXG0c73Hjk10lsJTnq1n99w/jKD5GrAh16pSnaNFAvdPOet7QOXU68SJVAnNRb4ro3Ez0fbSHV/QksdkGiZ15MW0+EkoAS39ci515Klf0bnl8a0W4vnOGKYaxSt5BBFY= 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=GjZI9Piq; arc=fail smtp.client-ip=40.107.223.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="GjZI9Piq" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PqoDCZ54kWRhyi0NPdGslPt81lDm4/18yYDsRU/ZlbHyWCStKF/dZEFMa0r5fVqbWPT/p3mLJqswpilf5XKWAJZx6LXz6xvF73tb7jyT9Rzfu7FupHTeSdsmsMyTUyOrz0tl4d36FAzR19cZO6B2Jow8+YDk4oMgYBN+WRNGtZAqq+98S+1Ofh523vSvuN5VoGn0gfFgSYTKG7Cpv6zVv4H+qyttI8phdKG52bJcq1qcP09YcHa4ZNJQOMdUZcpFWq+EdXSsgLIXTdGox2pJ/91+mcH7IfdvNIKPmKxcDpfhBKekOnrWMV0mXNOfG4etR2YHFz1/pDuww7AO9npF3Q== 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=NbGYql5wadTo2HNfd8QYvNBrUqQ+W4fiY8DM+PIOBD0=; b=aJ/Xy/ZDuwVv0T7o8nSl3t3x45ca66Fo2htxtHe+pnazDhc+E2zgD/lW3jDGkkBq+3JD4TKTQXUGAtBqD1bqvr2VjpoGNZ/ns9RXOQb5XZm6I+hZvP1wgNJtlPm7GcvBouBV2psn17/UQtzXaVEmmIcWhElwGes9mzV8hltpWK/b3HeKBWKJG14D9rRQ/CnxxGPC+hmsk89yieGO2E30R3fcAx0lZy7pl2bFOEkvnh0O4/EFQUdst1Wh/IK5WAXv6tVr7qA5Vfwas2Nos+o/CEyZY/6l7EJWDpNIL9oR3+2+MXZB1ZMRX71VZ+DFNtGj7k8Pl5tpw7oxgcWjGYf9KQ== 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=NbGYql5wadTo2HNfd8QYvNBrUqQ+W4fiY8DM+PIOBD0=; b=GjZI9PiquA6j+lex5gXb2LZmqiGvYIlGyEREXqUDGDtMuiaJQkHyprHJpns5WfzCXSVdFsA1+Srew74mUF9FXB6qifmGRIQV9im9D0kMMKl/1pFX55RkxFtJYYvNgFGB+Vrfwf1oF4Ed3bZYVxc17F58ekQRq6lv8dVwCaaS+4Y= Received: from MW3PR06CA0017.namprd06.prod.outlook.com (2603:10b6:303:2a::22) by PH7PR12MB8105.namprd12.prod.outlook.com (2603:10b6:510:2b7::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.17; Tue, 7 Jan 2025 14:11:17 +0000 Received: from SJ1PEPF00001CE5.namprd03.prod.outlook.com (2603:10b6:303:2a:cafe::c) by MW3PR06CA0017.outlook.office365.com (2603:10b6:303:2a::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8314.17 via Frontend Transport; Tue, 7 Jan 2025 14:11:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CE5.mail.protection.outlook.com (10.167.242.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Tue, 7 Jan 2025 14:11:17 +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; Tue, 7 Jan 2025 08:11:14 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Robert Richter Subject: [PATCH v1 10/29] cxl/region: Add function to find a port's switch decoder by range Date: Tue, 7 Jan 2025 15:09:56 +0100 Message-ID: <20250107141015.3367194-11-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107141015.3367194-1-rrichter@amd.com> References: <20250107141015.3367194-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ1PEPF00001CE5:EE_|PH7PR12MB8105:EE_ X-MS-Office365-Filtering-Correlation-Id: 67366987-4f32-4aed-4385-08dd2f252756 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|36860700013|82310400026|376014; X-Microsoft-Antispam-Message-Info: usIW67d5Y543PQ0KAJdBUaFpjOsg4WKjiFITxHVvbsO62SmL7rfrsCU+Y39DWJPKTGgnTKGtabaKmEXV5u/QK5IKFfoQ9xtnwraxokzDdMH/QiR2xIhRPnCEHIiFDJcxq6nbbJ2v6om8jB8/GtiBQs35uZSbT4wvjUyibwuOnkZsXs4Ov5Uyh8VpWM4vGK97uvf6tKznzER2cgtqz5ezDHUEk0LZajqPq91QBRpT2PaGGUOEgm+qIhLF/V1QGaKLK1XNND+/1e1CxnGx+9Wa/PqPmEtYIGQw0aoHH4zjBxZ8v1BAvkCoDXv+sWt4lGIghRpz8wTQaDVbd8MtxNpb7u3UwCzh5FVvCMLxfS/oQKcCYxrLP+0AOODh/etrZLQ4Eu9wdsj0HvRdKPmuFGOvNne9c4C4+OW0NMaz+I0tJfL/J6Je8H6wKYaC1HsR5iPTA0QopWJ+a+lPk3mRT5MEtZ15qiTNyvSIIMv4ZiUo/Gy+TOvnVk0TLrLTHeXNP5IRYcn4LjruGNI/k4sQRjErxwQYDQIe5dQIRZqpmqt3IuBaAYFmX8kutz9ZvU3DBDkeHnHq/PZsayAVccu5aT8JibQHICyqUbFgc/p1zC9PbAsJVhpUKvTvqN6qw/BiiZ4uI24cdPU7w7pvvRLDsFu6rdetPINLHKGkJVp5YFe66Gl+y5Bhdedoc8E7R/HYdeSX9dSpNvwxNSZKkKJXEt0xHabL4x2rdjKGLqtSsBajofKrsB/LoPDufTpJ4T1Jcmeu45zI4a0rPq0aO4VQrqvGWdjVzr7kZ5gwjJAiFpvGSif0cCvh4cx5jS7m9cis2S7GJ1uRtQnEUwJM/Wf3t2iaDqPnrzpKCuR/j9I+OsgQDAJZ53gh+zgTGoG4P+AM60spEKOVm9LYXHcjcL2WLZZ0Qhp04jG3ANhwm08xE7hldVD4iSvGLK5e6oRvp8WdOtt1LbBTY1crPOGIu+NkPXJ6TWK+/kouW6RbQFgCZxK/PA5ewCPZDvZLmxoAGGu52PxEaviujjoTVOhd2kcl+sAwJlfrOubeMF6HhMs+zZ04VaBv3uRSEg5V1ez0PIFNrgG0V0eu166ooOId0/T/B9IcgZjDpI2XAduMNeNaVuOVB5ZMEdMH213BpTgaFEOaZdJeqYfXCQVjneWxN9cx7L9eSJPxikvWOA09w7PuLvbyZ5fvhEUZEvFGUH3t+sBbS3BXZQqEzduFf1xkGLlfLgEQiAw6A5pQW+QsZQzvh6K6aQ3TD+mtYYHWqmoLGWo7yFveEuvyAgFNPHTskN1fOeIsc1k4+imH++mGuNgchvgK76vf+T3mM8dOwnePEPeVup8Hwn/p5flwYd1gPb10dD2yCoZmypKTzgbRqCGhOyHTmqgxHL8/dNtVXNEYMfRhZlEVGSIYgpCfho7cwyzhz8qEzXuhhlRqkNQWdWOISNyR7BVqmS8tGl2IgOt7YETXj4QxphWFrzREA0LL4dqgfdin+brApZU0pzV8fKftDbb2O0U= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(1800799024)(36860700013)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 14:11:17.5176 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 67366987-4f32-4aed-4385-08dd2f252756 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: SJ1PEPF00001CE5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB8105 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 --- drivers/cxl/core/region.c | 43 +++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 5750ed2796a8..48add814924b 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3189,19 +3189,35 @@ static int devm_cxl_add_dax_region(struct cxl_region *cxlr) return rc; } -static int match_root_decoder_by_range(struct device *dev, void *data) +static int match_decoder_by_range(struct device *dev, void *data) { struct range *r1, *r2 = data; - struct cxl_root_decoder *cxlrd; + struct cxl_decoder *cxld; - if (!is_root_decoder(dev)) + if (!is_switch_decoder(dev)) return 0; - cxlrd = to_cxl_root_decoder(dev); - r1 = &cxlrd->cxlsd.cxld.hpa_range; + cxld = to_cxl_decoder(dev); + r1 = &cxld->hpa_range; return range_contains(r1, r2); } +static struct cxl_decoder * +cxl_port_find_switch_decoder(struct cxl_port *port, struct range *hpa) +{ + /* + * device_find_child() creates a reference to the root + * decoder. Since the root decoder exists as long as the root + * port exists and the endpoint already holds a reference to + * the root port, this additional reference is not needed. + * Free it here. + */ + struct device *cxld_dev __free(put_device) = + 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) { @@ -3209,7 +3225,6 @@ cxl_find_root_decoder(struct cxl_endpoint_decoder *cxled) struct cxl_port *iter = cxled_to_port(cxled); struct range *hpa = &cxled->cxld.hpa_range; struct cxl_decoder *cxld = &cxled->cxld; - struct device *cxlrd_dev; while (iter && !is_cxl_root(iter)) iter = to_cxl_port(iter->dev.parent); @@ -3217,9 +3232,8 @@ cxl_find_root_decoder(struct cxl_endpoint_decoder *cxled) if (!iter) return NULL; - cxlrd_dev = device_find_child(&iter->dev, hpa, - match_root_decoder_by_range); - if (!cxlrd_dev) { + cxld = cxl_port_find_switch_decoder(iter, hpa); + if (!cxld) { dev_err(cxlmd->dev.parent, "%s:%s no CXL window for range %#llx:%#llx\n", dev_name(&cxlmd->dev), dev_name(&cxld->dev), @@ -3227,16 +3241,9 @@ cxl_find_root_decoder(struct cxl_endpoint_decoder *cxled) return NULL; } - /* - * device_find_child() created a reference to the root - * decoder. Since the root decoder exists as long as the root - * port exists and the endpoint already holds a reference to - * the root port, this additional reference is not needed. - * Free it here. - */ - put_device(cxlrd_dev); - return to_cxl_root_decoder(cxlrd_dev); + + return to_cxl_root_decoder(&cxld->dev); } static int match_region_by_range(struct device *dev, void *data) From patchwork Tue Jan 7 14:09:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13928999 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2075.outbound.protection.outlook.com [40.107.244.75]) (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 38BB91F7086; Tue, 7 Jan 2025 14:11:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259093; cv=fail; b=HyW7ivt1QGgta5bJDin4eYp7W5kRwSuOClV+ZnsR9A08pIm9wWS66adseYTYeGbKDVhX/eOxgSfXURWDz9UPy6i/KrhlS8ORnZ6T5LWnKOyf720uBzDt37Iu4L/kh9b+AC/43PhKRn3VSSiU/68JsR3Wu5GTxeiZ1fptGAhqVvc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259093; c=relaxed/simple; bh=Za7dgU+BrqdH2ql8PzR24kIqnU1REa6VsxuLuvXvPkw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gZvAR4NGFr49ck8WI/kfdVfbs1Vy8UwHCyi+a/y31OAyJfILDKE06PzM3o2k084M8ODwgk9ZObQR3ffu6OSRkYB8t5hA4lSOPuSPJnQ5OT03WZU3GJre6mx4NTnTMoHEjrD36qdIxj1RSKlg9qH/IuhG2NzFo72YBuSyrVJdQ2A= 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=2eyEAIGQ; arc=fail smtp.client-ip=40.107.244.75 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="2eyEAIGQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Zq6Ndms6fW2DkNetsnzGmi3FjCxPpG21UkeHRP2czR6fKHn3LVQfkmRxSFjKlXRDjWG4cLSNbAZxcqUFbRK7b4X7SZSyGvRFeKJZUS9XX7H8FB+0kOriSKgyEJxva1M3fL/5vQgd3cnROEukyV55nDCp38FgGID/UboSkfL49QC3oh8TUj2ZPUUx9vGrbOsSiL9hZ7wT4R2arFg9lRI8QSB6qTXicV85xWjiJ+VAJVraDRJFtQU/6xZYICco4WcZCDuHCMl53q31j3j/sox7ufsc+UDxyjD3CtDIcIfUPPT65fyaKlpD15HO9ihJStBpnGxO0VDlGKp/09GI06LghA== 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=0WCBeL5jVq9Pt0WUb5ulXGX9cpFI0x7I153mlhnn7+I=; b=Xi7/er//g5Qjk5UwCD2s41UHoPi7PN/q6bLGOw9Y6sZ284Gum0NswmTM/eNpqx0BQyG593QRg1EGIombiM5g+7BKXQKI2VFbpoiSTgzflu9qenzOHPUUPdm8TeJmIBG0JRKcADXto/07EgLm+61Qrc9YBsyZn6S9I6qZBZ6r8l8SIE6oow97IulxK7ZkdFecm856PL9HRzWhIYpDY0ShSS6eesF5Bq6RZ0sRu0GLYBMZYOMCSpidPOJjGlKdFpgk51aSmP8REDafwHaRjGpiZJMlc76G+6hZ3z2ktELAJz3Qle3Kfuc8bieoGdYrq6/UVqZuAiJsHFv7FdVk/KQJ3w== 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=0WCBeL5jVq9Pt0WUb5ulXGX9cpFI0x7I153mlhnn7+I=; b=2eyEAIGQtOO4vG6DOJhC39F0w1B/qvlxNaL8ocI7QBt8B5CuUTJ2o1HGZQYGWuaCPisdq1ri2Zs2M1PSZ3s/wdZR9DwCgeUnwGkxilVDNfYU2ngKxvUjUrfNbYJFOuFFocdED07smTKmShRb3y8NLBa4N9XCITYgmUK6gA/V1oY= Received: from MW3PR06CA0001.namprd06.prod.outlook.com (2603:10b6:303:2a::6) by DM4PR12MB5771.namprd12.prod.outlook.com (2603:10b6:8:62::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.17; Tue, 7 Jan 2025 14:11:25 +0000 Received: from SJ1PEPF00001CE5.namprd03.prod.outlook.com (2603:10b6:303:2a:cafe::6d) by MW3PR06CA0001.outlook.office365.com (2603:10b6:303:2a::6) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8314.17 via Frontend Transport; Tue, 7 Jan 2025 14:11:25 +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 SJ1PEPF00001CE5.mail.protection.outlook.com (10.167.242.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Tue, 7 Jan 2025 14:11: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; Tue, 7 Jan 2025 08:11:18 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Robert Richter Subject: [PATCH v1 11/29] cxl/region: Unfold cxl_find_root_decoder() into cxl_endpoint_initialize() Date: Tue, 7 Jan 2025 15:09:57 +0100 Message-ID: <20250107141015.3367194-12-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107141015.3367194-1-rrichter@amd.com> References: <20250107141015.3367194-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ1PEPF00001CE5:EE_|DM4PR12MB5771:EE_ X-MS-Office365-Filtering-Correlation-Id: 9c27fb23-156e-4323-a96d-08dd2f252a66 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|7416014|376014|1800799024; X-Microsoft-Antispam-Message-Info: lxTizglWWWogIj9nmzUvb8F1PdoILyd7pBi2iVDtfvrO6EwjzPSsPdGKxiN3M467fJbFcP/TH7+If/KFHTapEYSqTKjb0BDuPlkYuxWzlkQ4u/4gJyIeErNTh1E5FtRZ4IHJuElHe+X8z7xHtabxiH7Jc/nbbTgrzVgJXek+APDsmdVOSapclKZLp8xkAEmZ8fhnGcOFG2/ynf+JkK26wkYb7tadk+7sD1E+xJnM4q2CNhuxLDUumVQixNKG1ltFdEYNVSTPkix0quWMPkGWlELOw/rxcu7ekfylDhpJrRj0TcqkKT/r/1Pivpm/IT3v6CiiywBhPGTnpnDO1X4OhXU8sWEm44/Mv32wIg2JPdRctZtUAFRTZYokuSEBbzfVEZbE7Os8rIDw74zERo8KjP6PjPRekrs1rwx15f4A73tnCrU3umHb8tyzeebLuIf1KXt0J5ik39R3YFUx/c4XDnCxTLZXBl8IJQzK/lsmS/v/DbAXgbCYrLUJ4A5S3to1cd/2UGxlmX7l6L/TqGszBiOxYeQOJUDTsKvy6BZ2xLaUp86XN6Q+jHBbTV9DbS+3N/QCwNNwGGZiuUYLlMo5dRKEQqWmZSPhJOBLAE1C5ObbTOtyZpjhfT2j6I+h7kXSyb53qeDjnS/YXgeE0QKunPDnfYiZWdz5zeSnsmvBnYBTB5ljkIOz7LYg+srBDjhBmrJdieueUjFjz/XK2hP+cQmeprwP9d9+JtOBAgYT7C+580TDEg7Qbh3SQOwoUVefqT8UbTw6wmBFDGBXHUx9KOR/N0K5LguC+Qggw99E0nM5SEzzDgDvY3QM865TXowAZK/eq4zVz8TCxke6zpAe6K4f9p/2i8yjfAABmCObc9YY04InpHFMyO/LX5TGKZ5DYzya6tBIV1g4jForVSo1Tnliig1AkAHYDPxmQvrE4Rkac6+woRePXAxxpv6riplJItV7a3DIHmw1lMCCwwITmRsU5h7bWGrtlm2BLtXU6K5GCLs3HhYLUjCLiG9CJtIR7MwIA5XYTsXQpY75N6Uil/mqh2o1YUZqp/e/oB2Omvljrtus3gNHV8Z0BVMehGyN/fdagChxN/n5LoXb6cNPEweMkrH2wzdgAlT7x+MuXso6QN+U0JF9O32sxcck1Ts3ioC48AxIAjbzVwJ5n9tBAJmslqCSayw1LUUL+RWIbTWPMIr4Z0AfyJYR3oaptJO2HaZVG5lh+VeCxs8givUNJs4xbTZzBpwbXs4guQOwU0PnJxyN5CS5DSo9nwHRk6WhC80B5VDYs36628Ca1NP4rbSSQUWYXX2zAQmvNvzWNCWa5HDwe3A9UVi7If5OWcSnFf4qqC7Dg7vT6Lygil1lW/aMFFzYSTDno279lbw69s8X3aaKpUdXYaHG/KuubvkpK4V9sDlgUqML3n96TBcsGfJs2CCmnX8lp8thftognbU23AE3u639om3n60nLM2NPp5J44nFb55JKStykME50GsSXoTF8jKd4gB7vYyg3aEw= 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);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 14:11:22.6582 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9c27fb23-156e-4323-a96d-08dd2f252a66 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: SJ1PEPF00001CE5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5771 To determine other endpoint parameters such as interleaving parameters during endpoint initialization, the iterator function in cxl_find_root_decoder() can be used. Unfold this function into cxl_endpoint_initialize() and make the iterator available there. Signed-off-by: Robert Richter Reviewed-by: Gregory Price --- drivers/cxl/core/region.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 48add814924b..6fcf56806606 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3218,8 +3218,7 @@ cxl_port_find_switch_decoder(struct cxl_port *port, struct range *hpa) return cxld_dev ? to_cxl_decoder(cxld_dev) : NULL; } -static struct cxl_root_decoder * -cxl_find_root_decoder(struct cxl_endpoint_decoder *cxled) +static int cxl_endpoint_initialize(struct cxl_endpoint_decoder *cxled) { struct cxl_memdev *cxlmd = cxled_to_memdev(cxled); struct cxl_port *iter = cxled_to_port(cxled); @@ -3230,7 +3229,7 @@ cxl_find_root_decoder(struct cxl_endpoint_decoder *cxled) iter = to_cxl_port(iter->dev.parent); if (!iter) - return NULL; + return -ENXIO; cxld = cxl_port_find_switch_decoder(iter, hpa); if (!cxld) { @@ -3238,12 +3237,12 @@ cxl_find_root_decoder(struct cxl_endpoint_decoder *cxled) "%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 -ENXIO; } + cxled->cxlrd = to_cxl_root_decoder(&cxld->dev); - - return to_cxl_root_decoder(&cxld->dev); + return 0; } static int match_region_by_range(struct device *dev, void *data) @@ -3364,19 +3363,6 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd, return ERR_PTR(rc); } -static int cxl_endpoint_initialize(struct cxl_endpoint_decoder *cxled) -{ - struct cxl_root_decoder *cxlrd; - - cxlrd = cxl_find_root_decoder(cxled); - if (!cxlrd) - return -ENXIO; - - cxled->cxlrd = cxlrd; - - return 0; -} - static int cxl_endpoint_add(struct cxl_endpoint_decoder *cxled) { struct range *hpa = &cxled->cxld.hpa_range; From patchwork Tue Jan 7 14:09:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13929002 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2084.outbound.protection.outlook.com [40.107.236.84]) (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 58F511F76B7; Tue, 7 Jan 2025 14:11:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259101; cv=fail; b=dnfllQ0vskVBBanoStdDKw5eUmAUUqHntgsEIHXOtvdaDkBYrvi+PdiZe1k4Yhx15CGI3Yu6vIk/FceV93LmhYE7nxCucyqNzK8ASrtS5OHXrUFFPF+qI2lqCIYEKs0JF68d5B5QxSjiSqu2SHd9HzgNcD0FjLqrgyNzRL+UvBk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259101; c=relaxed/simple; bh=64JuMkWp21qv0GM867D7HHuNu+CTe7sbi441kHj96SU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lcrJuH+EkHNyhWP/70UwVYgoeM5pvMFNMjUxBcEpLaogWGEVMoJFOXS3nKovDbrF34AIPKiOfAT8xOySoz+4pyjOfcrDAKSKyaSaLnzC6M2/8SfGjo3MMSZ0pw2P9160ebf2VuqDDlyM1LLwZmUyRRC3Q++cz7yB6hcew3sJXWk= 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=TMG4a0nk; arc=fail smtp.client-ip=40.107.236.84 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="TMG4a0nk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NhPVjLbeFyBkZUKn06IiW2RaEGjj11sOxmDZ0QHp4cMznmtiuEYNwZi0DDzgzoKu8RYrgcDrE4ONsOw9O50y+wl0hkm/EoyR8+U74tt3163mOFw0gnstGP98bQzZzm5zYq99HS0bcJ1GCinoDFyZEE/6heykseWdaKDfwpV+w82hvl11rTNPfP+3mvMKzlLXFVx13ex/+bzSgmZYP4Zb+YKxVBaxw3io9ZGDNxHECofWQqtXIXYim5i4m96om4YCK83lUVng6UAL7kbdJ1hjdYEvTdUS/sugUfr97lE1DJlNOkobey0O6K82D6fRzhSLrDnqf6dTzR4pr5SYK8KAxQ== 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=jqZiwzyq3Cf0DQuWSz3drRrmfbHZYz6RHWV8ZxR2p28=; b=f0p3UZ3Jopsna5huaxkzCpLg4FkyUkNSZ5xdf9DgMemUm+6cJf4BXorNTFx1CCuvxEfhDSUmKIUUdg7J6lafg2vLxondB5HWMqYOA+FKOtzwLBrIb6mND3+aitGHsV6DV+TL3vEyyPPfOB6kLMc56gqzXoKZnv/Pe3zehzBV7jiNLLsNP1zvBhbgElR1zZXEFUWS0zFLTwQanT4Nww8jxRuNIzn+n1WLQ80n+ih0jGB9vGUTqyyW53H2sl3OVHv0aydyvhuA8uOIPsrHyiGkREByGpbALdfnn6LNMqlhuUdD7ffht/akA1faLuBAF2D2mkLWg5maH5YuylnrJ3P/yg== 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=jqZiwzyq3Cf0DQuWSz3drRrmfbHZYz6RHWV8ZxR2p28=; b=TMG4a0nkLf8BEkgOpzIeTiDoFfyx607kVihjSlVH/MOyq+oXKA0fu4SOE+hWat3bEVP6r+u3AxTOxsvJMshB9YFEeoXW+Vk+jtqI/jgU2O53hHFm8GwnGg8LmHXNHpcLGNtty3wap3EXlsIxTmoEqSJTeYJStSdA9wGvHBdgU9A= Received: from MW3PR06CA0012.namprd06.prod.outlook.com (2603:10b6:303:2a::17) by SA3PR12MB8762.namprd12.prod.outlook.com (2603:10b6:806:31f::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.18; Tue, 7 Jan 2025 14:11:28 +0000 Received: from SJ1PEPF00001CE5.namprd03.prod.outlook.com (2603:10b6:303:2a:cafe::79) by MW3PR06CA0012.outlook.office365.com (2603:10b6:303:2a::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8314.18 via Frontend Transport; Tue, 7 Jan 2025 14:11: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 SJ1PEPF00001CE5.mail.protection.outlook.com (10.167.242.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Tue, 7 Jan 2025 14:11:27 +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; Tue, 7 Jan 2025 08:11:22 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Robert Richter Subject: [PATCH v1 12/29] cxl: Modify address translation callback for generic use Date: Tue, 7 Jan 2025 15:09:58 +0100 Message-ID: <20250107141015.3367194-13-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107141015.3367194-1-rrichter@amd.com> References: <20250107141015.3367194-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ1PEPF00001CE5:EE_|SA3PR12MB8762:EE_ X-MS-Office365-Filtering-Correlation-Id: 55488605-f73c-40f7-d5eb-08dd2f252d5c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|1800799024|376014|82310400026; X-Microsoft-Antispam-Message-Info: CyTFYb9hJwR1aT9UPWdzJjKCsxQB/UH5aI0Uu02uchpv8PLxBfuKofsnUyy/PyCS2tbT5h/PzcIFQ6ObpcXLiHCAewWA1GcQZRrQg0FPbGwMxCDdTxHNhU9AURr4M5wqZ1fneT7MHCKB0W2jWRK0gmo9dNBjelarDsko8a5KZYBa8TE4fPuEnEaXKlajVDnk/V92lQHVqSTSrSt6EXP5CeQLujYUOiJhg67Y57HwVLUADN/nRB/7e/J+QcLmDKZ5kySXLzts4NQLn/r8a6ClnMCCsKqq21z24EnVxkO/jMhIgE8ihzdyb2W0iByf+dYkUKng9VzAxIiLbCF3kagyw6Z+maCPMYCu17AUyfXUXDIeVPz2SZ1BoEmOpq8PmWGNK1u6B1ZOUs4OPJtHNF4AZ59oyZi0uXRE80blZe0+TWBfitywJHcYe4av/ZxVzuG0UTYl9q32zq6BA3ienAqXVObxSxjQyMWhSe/bgCZp/9M9yeCP83yBWirYv6YxW/1P8gCZClEfT3Azil4drgLiqtIua3G4QR0UlUOwyaJPlcSadrjf2FUfRxcWTG6zwmIF3/9LaHv7JRBH3cz+mZTSk3FrUzua+DP7EiDMFhhQxltNm22wrZt8Pn+lRHSkQY3DrX2MXJzuEzf05bCoowna9DO39qejy7eYzO8tkFHSOz3viLedlgDt4YWrLwi2Bm/zdeQu60v+jD03EqUrmfDVXGhfbIozvgnohm7+sMukjZVPzOB0i7QjsFacuAylvMR6yg126lASW4vDFDQ5ZWCor0bYF8gRM3S2M+3sN8g7er9ZG7JzLSzRjMnRX+OjrYuMrzS2EjU2dR8YdB74mhQ24bW+d1VAKVYuisrTI1udqM53jti0sjAxm9TahjzzfGdMcmNLfLW0+BbJOdtpcKrLGnlBojqhQjXuZzkFjDHTznzr1pMOaDtSdGGCvCOmfFfMPn+YCv7/vGY4tsioC1VqQWEjnxae/X47Z82f5CFI0F/tIWAQHeRv1glZ1wvJ3PeoWYKJ1bq6eAH3XLEe+qWq3zns7QAI93q+SSOZTkgKMNHrHvXGs3wzEdGFFG+RkzviS25+cAg1XJWgnq/ED8f3EMXNZWwTOtmL/uW+3T4DKTJlRltlRp6qUIOC0oZzDVDS9uE4af5o0aUQ4bDwIoUfO45o3oj6bp1M2+OahUDj0eUZTFE+rnAKd6ET+E8wLilwtcS9gq8GVWKZp/ortLts8TC1he8Zho2YdKSm++sFE7V/XVnb9WJoIs70yZu2Rx/4Ef2jjT6eTmASQe1bTtoIN8zQuMHiigBamOh56+mgQGk48T0jDfJx2JS1gkbi48pBM4nTCE1MhlX59HHV4jS+i+RitcaE9lXcbHMin+xckHlxYynm9O0vhZ/fgrqo5oYVgtfgK7yJbsDHl7PyMhdCwQNDDZ0UqGaslkdds/9JbMlEiHTRYoP63SYJ2+8kOM7ZWL1RJ6plJrTOo7Fq3Go16Ytz65ZUytT3GwJch8o0Ph4= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(7416014)(1800799024)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 14:11:27.6270 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 55488605-f73c-40f7-d5eb-08dd2f252d5c 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: SJ1PEPF00001CE5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB8762 The root decoder address translation callback could be reused for other decoders too. For generic use of the callback, change the function interface to use a decoder argument instead of the root decoder. Signed-off-by: Robert Richter --- drivers/cxl/acpi.c | 4 ++-- drivers/cxl/core/region.c | 2 +- drivers/cxl/cxl.h | 5 ++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index cb14829bb9be..b42cffd6751f 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -22,9 +22,9 @@ static const guid_t acpi_cxl_qtg_id_guid = GUID_INIT(0xF365F9A6, 0xA7DE, 0x4071, 0xA6, 0x6A, 0xB4, 0x0C, 0x0B, 0x4F, 0x8E, 0x52); - -static u64 cxl_xor_hpa_to_spa(struct cxl_root_decoder *cxlrd, u64 hpa) +static u64 cxl_xor_hpa_to_spa(struct cxl_decoder *cxld, u64 hpa) { + struct cxl_root_decoder *cxlrd = to_cxl_root_decoder(&cxld->dev); struct cxl_cxims_data *cximsd = cxlrd->platform_data; int hbiw = cxlrd->cxlsd.nr_targets; u64 val; diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 6fcf56806606..9443507ed4e1 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -2925,7 +2925,7 @@ u64 cxl_dpa_to_hpa(struct cxl_region *cxlr, const struct cxl_memdev *cxlmd, /* Root decoder translation overrides typical modulo decode */ if (cxlrd->hpa_to_spa) - hpa = cxlrd->hpa_to_spa(cxlrd, hpa); + hpa = cxlrd->hpa_to_spa(&cxlrd->cxlsd.cxld, hpa); if (hpa < p->res->start || hpa > p->res->end) { dev_dbg(&cxlr->dev, diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index b3989dc58ed1..be7685fe8a23 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -443,8 +443,7 @@ struct cxl_switch_decoder { struct cxl_dport *target[]; }; -struct cxl_root_decoder; -typedef u64 (*cxl_hpa_to_spa_fn)(struct cxl_root_decoder *cxlrd, u64 hpa); +typedef u64 (*cxl_to_hpa_fn)(struct cxl_decoder *cxld, u64 hpa); /** * struct cxl_root_decoder - Static platform CXL address decoder @@ -459,7 +458,7 @@ typedef u64 (*cxl_hpa_to_spa_fn)(struct cxl_root_decoder *cxlrd, u64 hpa); struct cxl_root_decoder { struct resource *res; atomic_t region_id; - cxl_hpa_to_spa_fn hpa_to_spa; + cxl_to_hpa_fn hpa_to_spa; void *platform_data; struct mutex range_lock; int qos_class; From patchwork Tue Jan 7 14:09:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13929001 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2047.outbound.protection.outlook.com [40.107.95.47]) (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 AB53A1F37AC; Tue, 7 Jan 2025 14:11:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259095; cv=fail; b=TCrlc3AO5igcfQVK9zr3DmfYN6U47VuBlBKAcJihzBfPdQ05W8SjnEfY44i/FK/v7FsyQxUiHOMhoSIjOXS6tjZC08HXQy7eQuhaS7aS7FlujI/5nN+iM8sbXtnkTCjU67+FdAJJR1aCXY/+yC1zxR7MxwzgBK+9Imyl5yTPxHU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259095; c=relaxed/simple; bh=49Owqhvzi7EBaz/dnOUBa3eElXPvEEPe8lpANlLDeoM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Kv9sqSTaOln6JMlEXpsgSnO3aXC9O6XM8VYqJgBJtTc1kcC9XdRe1/cCcf10GlVH0dJDO0+s+OWu+r3oI7gGvej3GbPe8KfcXs69mVa9e4tLccSmOqspVIxvMuM03J8zj4moFoO/m+mzEySLf96MV3351eYA4Dj6xmToYugTbX4= 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=5Hr/FdfM; arc=fail smtp.client-ip=40.107.95.47 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="5Hr/FdfM" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mSxACFmKg09Ksp56pKloT/V4XyLDLjjkLEZGIUuGoSVM0eLVlZS1p8Q45S3ihto7w1ZK8inuWRJxBTVRgB4QZH8bwwLY3CKTD2zzxNOtVfJu3bMqUx2mE54ut9YBdu0JhAyBeBliH1czXw7arvcHGbycAzKMlWA2AqLPZQ8iLMhei/VRHtrJZouzLA3ML+MQpDRORy/dYjt0sGDhlndcq1PhhlGwuzZ5Zb8PL+YXGzJC7pNrz16ra836yqficPmBbkcmBIVJ0m6F8DuDQY/hpH7Hvzaw5oL49xdsUqt/xYILVVPr6XF9H+pl+RVoRJV4g3K9RrcVm2gG4J2AssABBg== 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=TLlcVoJAeuAuIcaXLHZQryzisSbU/vw7VG+Btw8kGlg=; b=oUHYTjnVT/bG0UzPW6c5+ZZlTtJ3xO72CYxqRo0lGH1TeaOL3QR+H7sU9vhe3y1mkPubr/KP2CH3w4AVsaJAOl0wcw5cSURLotcWapcFZ1pg0uU6qOIPhJRqMwyZV7BkkTGVnpl1PxU+tNBPVRrkyI9YgjICLOR7uoDiE7vkfqj63CkC1SVs0IbAw8dEVsAsqThPK6KDjYt+3ffSUkpqYUIE7gU1gpQ4GxGuSA10MwoXu1llNZLXDBzu+uTtF8hz76eXDd91P2V90RMfl1qgLeee9N7ygT/bgOJmq+VCBQEhzOWjLfNGdRMqzApdfXY64Rr+IenkBPZ76Xp9Bx0wZA== 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=TLlcVoJAeuAuIcaXLHZQryzisSbU/vw7VG+Btw8kGlg=; b=5Hr/FdfMIcgT91fha6kEjiWIXp/gsxVYXgtWIWTYLfrgMJk2bJVabhcbvBjOy3FDVOwYzbn40GnZZHM/r13oh5oYZnA91hRfUsnLPeJVj1pprTlvXqxYcjEgJhLkrR8NZOrccAMKOv0XDfNWUudDq/u2G2fo9e7+i1UyK2tOf+4= Received: from MW3PR06CA0025.namprd06.prod.outlook.com (2603:10b6:303:2a::30) by MN0PR12MB6197.namprd12.prod.outlook.com (2603:10b6:208:3c6::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.10; Tue, 7 Jan 2025 14:11:29 +0000 Received: from SJ1PEPF00001CE5.namprd03.prod.outlook.com (2603:10b6:303:2a:cafe::a0) by MW3PR06CA0025.outlook.office365.com (2603:10b6:303:2a::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8314.17 via Frontend Transport; Tue, 7 Jan 2025 14:11:28 +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 SJ1PEPF00001CE5.mail.protection.outlook.com (10.167.242.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Tue, 7 Jan 2025 14:11:28 +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; Tue, 7 Jan 2025 08:11:25 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Robert Richter Subject: [PATCH v1 13/29] cxl: Introduce callback to translate an HPA range from a port to its parent Date: Tue, 7 Jan 2025 15:09:59 +0100 Message-ID: <20250107141015.3367194-14-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107141015.3367194-1-rrichter@amd.com> References: <20250107141015.3367194-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ1PEPF00001CE5:EE_|MN0PR12MB6197:EE_ X-MS-Office365-Filtering-Correlation-Id: d00c7a3a-520f-4c05-5965-08dd2f252de2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|376014|7416014|82310400026; X-Microsoft-Antispam-Message-Info: PoBo8k89JIptD0CmXJ5w/0UQz4Vcf+EVmjOY8TTHhQmHK+n3vpvtiJ+6FRXfZ1ERRSqSpKPrfEwM7/ZTxQq34+gN1aORIFDmXe/gPJgeWDHPizc9t6TDHIlSn4nXpSlWSLCsFGvXH5xrA5ysmt1cHyVi9uOK0PGw/fh87bJ6qlPJ0a9JjKqdbpkdqfBl2FkdBFm2QNLaq+oVv60TQ9oZjSuV+yRzYbUDjYBgi119dhYMWDZ96L96un49louNl5SOZnpHYLOEkT8mSJN482roq4w8NIbqH/c6zv6ZpebVcE0mawEKL47C2AjJZcVrt3LIhjBAifWC4hfHP9Z5hxEgCXtumhD+bUeCNN0x07zXhskRX65JztGlRlJWQKhOIe5kvql1rDXJpfDUjvAP8S5+s01fj8XZMElX+QMwOdpynHum4SbkeQmihGiRpwyNdtwt7eGMKEpkMDqAiN9VBggcoiTRmN15LoXS+kqTduaUVKeHFNGwIiZ8Nx6nEsfAXJfsfhMK5ZhCBQ8zrZ03yNbdhmQFg7YVcz8SF/vOeqWfLg4eqgvn0SL9ayylWG7N+6Qaut89U4DIfPmoOJ7VK4bFGLdMDw3riTYF6zPNVWta1hXfrGoricB6d1E1wkAeZDSp2ukJdRL9pJ6ynwj3htJ5jIDalufEi3JUWl3GRHoe5SiNuETbmP/RaGykSrZZAEmazK0h51BPNSaHSXjIHYy20FGpfCq3n6jPId/rstxtnY4U3TY+80pNVf9oCf9DhpbwYOZF3fLu/Mcp39z0VLjEPcCbDwqgSqZf+wDYcCqsCrT4MlEAWM/wyDaFzbW2+gCliML5nyiDxyz3LgowBjbSamnYCTksM2Nzaygk/rtGu281MIsFE1gXKZrcWwZickoYx5cbOkDWfWqKCG1oIMSrh8vELGuLGC7TukuGxmr4vmkJgf6DEY+SSGDkHdAeqtKFTBNbYlc5g8yCDfdaeSICiKcBUohNVH25A/EUi0cUX+/rmSD/XLsIeuDlgIL5xJ+QPrG48UHI0HnZT/8go6wHiP9IY2ckkFpnkRacR6GBmmKo2ePVWPbnAczCxm5APMuGF1EUGeCN/pO0rASQsCQHvFWX38R0zI1tzcVVl3xs80CIveec01Y/8plSIzCoWiZk8UCElY9SL9rQ2texP+CxdWq+5hNNK68fcDBYhcTLAc8zlhwg670G3GtObFEb9bd0e1bl7evNu4LtoY7LbpPcUuy6vKCREpY3rSjF197hB0DGnhWvXGeq1/UR7jJjxevelZJTUn8DxPFZDyorXweko8O7+66nK4NONprgsL0UaRogXhGhJQLK57c6iIYSoL6RnwoRqnSLW7M6kIW0Hi1iPyB/lR9oX02Z9NUJL/b54gf1qRD+p3fvHOa3t4AjP+W0WC/uul9en/2hXgpmMZvcYM+E5pwWd+YOMYk54ZX3vmfOPwxsrBibpzMQTsjDvVHxo1mjz7YdPILNs2p+P51yAlGLKzAqcWizKeNlzN602ng= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(376014)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 14:11:28.5020 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d00c7a3a-520f-4c05-5965-08dd2f252de2 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: SJ1PEPF00001CE5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6197 To enable address translation, the endpoint's HPA range must be translated to each of the parent port's address ranges up to the root decoder. Traverse the decoder and port hierarchy from the endpoint up to the root port and apply platform specific translation functions to determine the next HPA range of the parent port where needed: if (cxl_port->to_hpa) hpa = cxl_port->to_hpa(cxl_decoder, hpa) The root port's HPA range is equivalent to the system's SPA range. Introduce a callback to translate an HPA range from a port to its parent. Signed-off-by: Robert Richter Reviewed-by: Gregory Price --- drivers/cxl/cxl.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index be7685fe8a23..49280e0f8840 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -601,6 +601,7 @@ struct cxl_dax_region { * @parent_dport: dport that points to this port in the parent * @decoder_ida: allocator for decoder ids * @reg_map: component and ras register mapping parameters + * @to_hpa: Callback to translate a child port's decoder address to the port's HPA address range * @nr_dports: number of entries in @dports * @hdm_end: track last allocated HDM decoder instance for allocation ordering * @commit_end: cursor to track highest committed decoder for commit ordering @@ -621,6 +622,7 @@ struct cxl_port { struct cxl_dport *parent_dport; struct ida decoder_ida; struct cxl_register_map reg_map; + cxl_to_hpa_fn to_hpa; int nr_dports; int hdm_end; int commit_end; From patchwork Tue Jan 7 14:10:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13929003 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2049.outbound.protection.outlook.com [40.107.236.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 23C081F3D2A; Tue, 7 Jan 2025 14:11:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259102; cv=fail; b=WgccJmpvoSogZVZ3gECewpL0GfviUC5sis37nGMLveXkyYZdWWv5Xvkwx6Dm4Fa2TgJGorurt1aqdJsORUF/KdkouPoprICYnHMr5KMUbWE6TR71qAFgaWDc6naPpGZ7T+sfAZfiuzvZrRgpbM2iTy5pG0cmkcgHv0Us3VEl2JM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259102; c=relaxed/simple; bh=9Cy6ikxcE17B56wVZ4hytVBZFYAbBnPuJs6LAxcViww=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jpY43B2wprjmE1N+KhXaExyLUJIEsQWitNsT6Nu1qtpS6KHmG0ajbhTSUn2Go0F3HggUkgRDVuuHNL1oAyNDuHxh0IfV0SPBv8d41l4Y6VJsEKZ38hmzMwUzO6wmOqSoLHSCerKae/NosvhbmSUEsmu7HZgjZIl1i0yVQDSGAkI= 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=NIQB/+S9; arc=fail smtp.client-ip=40.107.236.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="NIQB/+S9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=htxCQDdViHSlBWLl8c7ExEVvmHEwLb6B78PUKvn8vx1HXJ3SwI3hNpchmOPFKPoBurgh5xCn93+EdqctTBnUukp1S/5ev1FxG0GNayBfCb2du0rDQd5DfNV6jviJnjH1QWMoKaBDkvZBWPy85aKmA1RW4NsT3DDCN0LLexC1wDNPE/cEjgle8Q5tFAL2iyG22lRy01ArZyePnxLa3tH69FETyG9/7NVjLpazlodxV+40q7Y9uM8cBefYJT/t2PzxY0mAti/cHpdpLZLtMI0veGLRHMIrtCZ0EJxxyWY4ZT/vc9ZPVmIvsboeDyg9hnPqraVc+CUIvxsy9o9YT3lOtw== 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=Oyw96nJ8ualpu+Bsk4Zu+3fVycxPgQ5EQrwHVhG9FRs=; b=ugi/bOmTk3GlOpPZfFFt1W/5Wz4WAaOX4u65LoGCgVGeHvz0+q+cBsMk1p45YJT9vxdUf9Ebj9PavetqREqlFnQH5QkysG3qqSPZL/6Ia+IyZSW8gkKussfuS24S/B0MZsnNkaXprYuERdIJr8cOW/2TkrBZFanoDgx0r3e89Zi/m64+VRjwZnIFEPv3lVF8XQy8wsxMnvXZIXOcllNR2kS6b/orh23T853g7dUJQgQWChYcKmRxpAH3ZU4X7N3t5svK47PzPY47tJF4Q8PnR/9t9fuaxoH7wQhauUnk+nd5aMDLpXCU50GhSPjYotGDI5f+5h1j4OSSX5f9DG7Eag== 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=Oyw96nJ8ualpu+Bsk4Zu+3fVycxPgQ5EQrwHVhG9FRs=; b=NIQB/+S9q3dEJ+6FaWayv6vr8/kRxEyLB4J/Ym/9Yy3PpJrPtuDSMLZ7PJ3Ejnap5ZsOh8pzD3z72sdYorzyEEcHjCCj5w18tn5OabydeC/fMTNZQqLD+85TAuoViRYio0Ool83PzfJIu4mxWeBvq7fjQ8NqLV9wqXYbn5oaVDM= Received: from MW4PR04CA0069.namprd04.prod.outlook.com (2603:10b6:303:6b::14) by MN2PR12MB4456.namprd12.prod.outlook.com (2603:10b6:208:266::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.18; Tue, 7 Jan 2025 14:11:33 +0000 Received: from SJ1PEPF00001CE6.namprd03.prod.outlook.com (2603:10b6:303:6b:cafe::bc) by MW4PR04CA0069.outlook.office365.com (2603:10b6:303:6b::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8314.17 via Frontend Transport; Tue, 7 Jan 2025 14:11:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CE6.mail.protection.outlook.com (10.167.242.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Tue, 7 Jan 2025 14:11:32 +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; Tue, 7 Jan 2025 08:11:29 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Robert Richter Subject: [PATCH v1 14/29] cxl: Introduce parent_port_of() helper Date: Tue, 7 Jan 2025 15:10:00 +0100 Message-ID: <20250107141015.3367194-15-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107141015.3367194-1-rrichter@amd.com> References: <20250107141015.3367194-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ1PEPF00001CE6:EE_|MN2PR12MB4456:EE_ X-MS-Office365-Filtering-Correlation-Id: 7253a726-3f2e-4f17-39f5-08dd2f253073 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|7416014|1800799024|376014; X-Microsoft-Antispam-Message-Info: wMxWluFhNcfWtbraqhJS139/1VWStR7fmA0oMbCStorQBt/ZQjDZP3e+XmgM4ciQOf+aeT7weQTGUuNnTbBHLXdy13iPz9Xe+V5OcFK7IflkW4cJVvhTesZeJCYy5enNWJhfMm9l6SG3fsR6ncRN6o253a1VVY2o7UHcM9GTeKsMv99HSrc7kEBOvklZyiaYltrx/gTx/BoWhbSMESByNYNdMy5kdhZy4GZVXFtIuee4SqCVKnUOX3mnOHTTC24+O8QJ6maBLQ3WJ4gTsDGLkwVAZXYDUHAxR4ohkg8CDF5cwl7jY5nlmctJ8J6we/G7JIIofnwf0MAsVjINPNdxTvcrdWT1k8W2sCj4E3x4C2svO6TOC0YYRyGcaruhvB1atFuTFcPddpFjC+vRjch0DSqS0YB9jEdKhaJhNJbIMQCeUmkKY5bjLxLvYYtVr230fbA4gdmyRW5WzJUtxEohc62bxnPWhGsCg8AjKY2VbT6CjOcC8Izhs38is3dnxx4+xhwzE5R3uBeSOCxUVOl7wJzo2x2LJj6GytP1QeAkeDc1LlRgb+eJyBUgn8BUZwiB/xLLZHeVGHXbcTqm6V0ceLdYchUIiBKQj53eft2rPBmoRhtbisDiQO2c7onVotXcYQRv83AGq6vOQixkjuSknZ/at13XPd8yf/obzBIukhEIlfDJab3nqIhr6r/O7O6Q70mKdvmF5wHImImV3dAhlcwioqU7daXcN+RsQt6b+uYtqtl/O2ML8CGvXmGjk+Q13WHcs5IiCCaoAYZXx64xCQn5wenwMQv97WOm6Ig+rnmsuQXWCbbXSPNAMR8wZKxlq5SqihES/cvl+dSLfMvfom3xiUACt9yUM/gpX3hQudkE4qQa3By+v/H9Ig48QW4yjcwzaNB/KX/sgWNaFAQ391FKesPObhf3rixWi7nMEEo7MziZVMuepUYkwih4HCf+g/jlKyettiSJVlAULg0/5b005C56O3clF2REwYKnV0KYR84tcKi4JtWtqJT73dmZFjc3RVtdWGRC9NlZHxGxoVPgMCRpTeJqluyEdUHTfyDBS2TEA8fGb61J8Ivb8tfk8LCGgZ0huaV8isuz2fJGOMELKVgB0hjBBtVkjdWF2S024MC8FHcQH1VfRdi78hhLeQLY8j/5HqykFaM1XGjW+Fw+oTp9Qj5VTHoLRWcOj65j7Vv2YmmmEH0dL1vAO0pCgmaeF5NBsk9VuhZGQ5qxF4tUNL5I1tqew4ZXo5mJzv80dlkM+cdQcnFaFxwSqKMcjf6VGOgYRQSBizZ+EcBYGsG9TGdvzPtPyK3V2mfDrrDTPFNp/1bfBtSZe2R56S4f+SWJgNAbOaxuaRzHYdgaka7nDbK2gdYbnDtXN8b0a4GoZ4ybOrnEk6YJme3EIXXzkDTSCtgfm6F7KD4yXxLt/BAuik/inqWB7Do2fEaw/srVhyu33ssoU7asnmEC2hCUhFcF0FqmVzMB7hQMzjrFKQEgCmnS1ssJqNU1QzV5Vvc= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(7416014)(1800799024)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 14:11:32.8069 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7253a726-3f2e-4f17-39f5-08dd2f253073 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: SJ1PEPF00001CE6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4456 Often a parent port must be determined. Introduce the parent_port_of() helper function for this. Signed-off-by: Robert Richter Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron --- drivers/cxl/core/port.c | 15 +++++++++------ drivers/cxl/core/region.c | 11 ++--------- drivers/cxl/cxl.h | 1 + 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 78a5c2c25982..901555bf4b73 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -596,17 +596,20 @@ struct cxl_port *to_cxl_port(const struct device *dev) } EXPORT_SYMBOL_NS_GPL(to_cxl_port, "CXL"); +struct cxl_port *parent_port_of(struct cxl_port *port) +{ + if (!port || !port->parent_dport) + return NULL; + return port->parent_dport->port; +} +EXPORT_SYMBOL_NS_GPL(parent_port_of, "CXL"); + static void unregister_port(void *_port) { struct cxl_port *port = _port; - struct cxl_port *parent; + struct cxl_port *parent = parent_port_of(port); struct device *lock_dev; - if (is_cxl_root(port)) - parent = NULL; - else - parent = 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 9443507ed4e1..09a68e266a79 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -1726,13 +1726,6 @@ static int cmp_interleave_pos(const void *a, const void *b) return cxled_a->pos - cxled_b->pos; } -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, void *data) { struct cxl_switch_decoder *cxlsd; @@ -1757,7 +1750,7 @@ static int find_pos_and_ways(struct cxl_port *port, struct range *range, struct device *dev; int rc = -ENXIO; - parent = next_port(port); + parent = parent_port_of(port); if (!parent) return rc; @@ -1837,7 +1830,7 @@ static int cxl_calc_interleave_pos(struct cxl_endpoint_decoder *cxled) */ /* Iterate from endpoint to root_port refining the position */ - for (iter = port; iter; iter = next_port(iter)) { + for (iter = port; iter; iter = parent_port_of(iter)) { if (is_cxl_root(iter)) break; diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index 49280e0f8840..c04f66fe2a93 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -741,6 +741,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_dev, From patchwork Tue Jan 7 14:10:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13929005 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2057.outbound.protection.outlook.com [40.107.244.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C72E1F8679; Tue, 7 Jan 2025 14:11:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259107; cv=fail; b=DUjH9sLWOnYu+mTvG8kDDW3XkyVlYyoQK9dqdjnjZRxINbI/YW1JXJa6oGa0ny5vpuOmEyXbkh+rRIc/NSZ146//kW/uvApXbONkEQLO6ysPwSsGPUZhEhlSGEqDCDmGh5pfbyeee+YOilNcus82niX8q3DYJ++yuw8xz+t41Jc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259107; c=relaxed/simple; bh=oM54NXk5g+NykARbvWACRxLsWnrBJJpLfAtBItrsZ9U=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=j0dAGqRys/BFlYH40uogl+UISa6yXmoYjenSgVzMPzeKD580idSIHzUd9NbokjF6dy6TEL2unkbq1H/i3h4/mqyl3a8npK6iToS3AWOQdWfUY77pTDtjZI05UsPTY/P4pyYBpl/+Fb53M+aF/U6Wqcf1Pbqt/8ugszcvn9uY3qA= 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=GVrwzWSc; arc=fail smtp.client-ip=40.107.244.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="GVrwzWSc" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tMU1Kw2f4mY4+L4TN986tSf+kzN+FDn6ojwUe+PXuCb5i2w7S4ZnBsks5JWIpH35pDouxq1eV4VM4Yb2MHGTglFLxk3aaH3IUyLNCvTBZJWd4eZt2H6N5zB1WO7hN8WlOT3xCg72dPsZ8ZDDhduoZdV8wWzCm0UR9VaRHLaUzviPqUezAMOY067k6wBh3/g0UIn+gMrdevqtBIwJM3+zqNVw/4Kkg4NMguIGVhIInSbMkNTEB5pBcswumzAuqKr4pY6IcEmCVuqNe38zht5g5AvbAJgzus+yChNwH4LsiMaY5uaw75gjFhwN5NU6uxaYqZ8O1ASl5ZXRo6BAj2Iegw== 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=FurV+X161dObJOCkRnyxwhHSQmGs7l1/YgFylg/ByQw=; b=aDv4p2GPYUdD4fghO4Uf/LNxLGckJvxpZBWf0gtKBL183GNMJ8SXaUvWaTIQYYSCYKZSoIsstftnRqUAzvIy3RoDbcNaQ51R+g/qiq4s7fXSIpoUPc4KnlOgkhL6caWBgESbUBOq1erUQsmqq9JL/X/fAFA2bNJ+W6dPbSB7t21KG1RmQHT6HOHVYDkd8TCVN43IaJOO6DfbNrXroC/fGDPLo+Z3Zty+FJHFgXY2tZ93C3zOraTeclw7ubkMMV4CU768yeHvgO/Jda928V4ebYzoSynZZcOgg3SH2LMUqUHg2uhjuf52VQp+MmExVC+KCXc5nHIqKLyO2uOsh9Ryng== 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=FurV+X161dObJOCkRnyxwhHSQmGs7l1/YgFylg/ByQw=; b=GVrwzWSc8w9dNWZuMdvLFE56FY5mCD5MNUMCLYa5MvNLK+voozakFpc9oQ7oig5iiZWVNgbts6mMlAIDnoWAMXMIUUvQ1BJyyYcxlmlYNldOimhYaYVOup486LuXG4JDz80XZq3SB1AL6vZxN5QEmg0ai/8XnA+TaqkEEUsbEZQ= Received: from SJ0PR03CA0220.namprd03.prod.outlook.com (2603:10b6:a03:39f::15) by SJ1PR12MB6027.namprd12.prod.outlook.com (2603:10b6:a03:48a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.18; Tue, 7 Jan 2025 14:11:36 +0000 Received: from SJ1PEPF00001CEA.namprd03.prod.outlook.com (2603:10b6:a03:39f:cafe::19) by SJ0PR03CA0220.outlook.office365.com (2603:10b6:a03:39f::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8314.17 via Frontend Transport; Tue, 7 Jan 2025 14:11:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CEA.mail.protection.outlook.com (10.167.242.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Tue, 7 Jan 2025 14:11:36 +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; Tue, 7 Jan 2025 08:11:33 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Robert Richter Subject: [PATCH v1 15/29] cxl/region: Use an endpoint's SPA range to find a region Date: Tue, 7 Jan 2025 15:10:01 +0100 Message-ID: <20250107141015.3367194-16-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107141015.3367194-1-rrichter@amd.com> References: <20250107141015.3367194-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ1PEPF00001CEA:EE_|SJ1PR12MB6027:EE_ X-MS-Office365-Filtering-Correlation-Id: bc1eab2e-6b99-4113-02b5-08dd2f25328c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|1800799024|376014|82310400026; X-Microsoft-Antispam-Message-Info: gzEMgdk7L62e6fIEWI2r4NYf9nmr3fWscVOTQw72socXra3/6LCjrwKemRzyWkeSAXTX4pXoLsILRaptudQYdUnczeeYA3zWLM69Z/es3SR47dMhBJJEDXa8le/ZslpPOSje1vspbbD+s8VPgeS5gYtDv3TqTEJbJ0WGivZvZoYxMOc0IfYGHuEZdviCocd02PYRofe0dqWoIG7hXgIYPRHv0FssovfWc07BTZznoEkSbP+6+a9sgZvULxdsXrFfqnaZjFcSI9f7P5Qv4Oym0TIgo4MfsISJwQz61tiPnbDFy9/WAO70cYxd487UWmyzt73ELPlFvFMScUHqEF0O3jPxaTZ6dxuSF9pigu4fK8Sc5t9ysLgXL8+YClDtO4XM385tb0B0rgo7tpFjl2pcfHepD0KiZDGFRowkER3ribfzyYS1PA3SltTZh3hI/6yadIs1/B33p5cg46ivt3Mzpf/2NJtnGoqZI+UHUS3OjrJ/TJmhYQBpCLU5YWoj9ONA4lxwY3hiqB9jUFwf7kJs72mHzN5U8v8UgUKv5fj518fyHye6TnTq0vsgAnYLdtVh/nlZpcNr669225BHg+UxLqPPKVjCSdDbQdMT2QywLw2CygF7qeT6H7XwMgkE/DTJWIOlC3zOrrizbgu+p+a2gU7PIaSizWdo4pXXlYJoV+wIwH0GA1UeK9SfFPvzdl6oP8AOSjh+447gaOVB2uLvIGWR9OPLNWHKA1bbtxwjrZY9QxcB3EWoM/SSgaKJXCzHgVGjUwAGilYLkXkmVweDFggoU8lo/yGyRTggvu7VS+xmoYr0W5+UsToh6pa1baPFHXgDy4gLvGJmNIwSLeWfkwPIaw9Ri0VM47X49MT+DzZP3em+B7qdXY+b6/dkBrRnxRY6ET5f6lwrrKvJPQz7EK6ACGjhL19Fzbpk0izKTxTtFcC/9hC5Di82j6z/g2kdxpnLqyvhgIFEdH5vhizPSx4MJGaCbHVo1QcMrRoylwPlAjUlfb/jGI+F4i4x5/7p/OdB/+9OTQusnohhtkclFWgrCun2cUQPypMmZBza9xA1Br6mT9MI8WUOHpaYXTxMDmTKglfTOQpjj0mhJP07fOnf8+9aqMHvsh6XZBpjejBxjdtkdVIY6kKF03oo1dXsuf1ynEpDFF4z15AlIpXshpzpgXI/+pzxlUhkKqLw7jzlKkxKPJo9hRruBAS6zEe9VlBnAU9kcIw9GZQIy13QrxNdm3GEpOUzXJKEEgkq9KzMKfZkmhm0MG65bfMgt4HvSdV9+l80AIcGCmEcugDUAV7lnDT4ncHrBJ8B7fJcaMomLRxiL82thaeYr70AlYb3b+8RXSAWRqw8G/pVYtM8wAJSl+Dg1FI3ZrWkE37JS3GCB6gTlqcgJYx41pTURKWCQyYElpAg0pp6kYkQdYbi+kx/O4qk08zbYdWzLKyq2HtiUyntw8E3DMrx19dO5ax4ewCpsfaeEAltzN5ZCbDeJb/Nlcnr9dxAYThx4czllE4= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(7416014)(1800799024)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 14:11:36.3247 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bc1eab2e-6b99-4113-02b5-08dd2f25328c 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: SJ1PEPF00001CEA.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6027 To find the correct region and root port of an endpoint of a system needing address translation, the endpoint's HPA range must be translated to each of the parent port address ranges up to the root decoder. Calculate the SPA range using the newly introduced callback function port->to_hpa() that translates the decoder's HPA range to its parent port's HPA range of the next outer memory domain. Introduce the helper function cxl_port_calc_hpa() for this to calculate address ranges using the low-level port->to_hpa() callbacks. Determine the root port SPA range by iterating all the ports up to the root. Store the endpoint's SPA range and use it to find the endpoint's region. Signed-off-by: Robert Richter --- drivers/cxl/core/region.c | 85 ++++++++++++++++++++++++++++++++------- drivers/cxl/cxl.h | 1 + 2 files changed, 71 insertions(+), 15 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 09a68e266a79..007a2016760d 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -824,6 +824,41 @@ static int match_free_decoder(struct device *dev, void *data) return 1; } +static int cxl_port_calc_hpa(struct cxl_port *port, struct cxl_decoder *cxld, + struct range *hpa_range) +{ + struct range hpa = *hpa_range; + u64 len = range_len(&hpa); + + if (!port->to_hpa) + return 0; + + /* Translate HPA to the next upper domain. */ + hpa.start = port->to_hpa(cxld, hpa.start); + hpa.end = port->to_hpa(cxld, hpa.end); + + if (!hpa.start || !hpa.end || + hpa.start == ULLONG_MAX || hpa.end == ULLONG_MAX) { + dev_warn(&port->dev, + "CXL address translation: HPA range invalid: %#llx-%#llx:%#llx-%#llx(%s)\n", + hpa.start, hpa.end, hpa_range->start, + hpa_range->end, dev_name(&cxld->dev)); + return -ENXIO; + } + + if (range_len(&hpa) != len * cxld->interleave_ways) { + dev_warn(&port->dev, + "CXL address translation: HPA range not contiguous: %#llx-%#llx:%#llx-%#llx(%s)\n", + hpa.start, hpa.end, hpa_range->start, + hpa_range->end, dev_name(&cxld->dev)); + return -ENXIO; + } + + *hpa_range = hpa; + + return 0; +} + static int match_auto_decoder(struct device *dev, void *data) { struct cxl_region_params *p = data; @@ -3214,26 +3249,47 @@ cxl_port_find_switch_decoder(struct cxl_port *port, struct range *hpa) static int cxl_endpoint_initialize(struct cxl_endpoint_decoder *cxled) { struct cxl_memdev *cxlmd = cxled_to_memdev(cxled); - struct cxl_port *iter = cxled_to_port(cxled); - struct range *hpa = &cxled->cxld.hpa_range; + struct cxl_port *parent, *iter = cxled_to_port(cxled); + struct range hpa = cxled->cxld.hpa_range; struct cxl_decoder *cxld = &cxled->cxld; - while (iter && !is_cxl_root(iter)) - iter = to_cxl_port(iter->dev.parent); - - if (!iter) + if (!iter || is_cxl_root(iter)) return -ENXIO; - cxld = cxl_port_find_switch_decoder(iter, hpa); - if (!cxld) { - 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 -ENXIO; + while (1) { + parent = parent_port_of(iter); + + if (is_cxl_endpoint(iter)) + cxld = &cxled->cxld; + else if (!parent || parent->to_hpa) + cxld = cxl_port_find_switch_decoder(iter, &hpa); + + if (!cxld) { + dev_err(cxlmd->dev.parent, + "%s:%s no CXL window for range %#llx:%#llx\n", + dev_name(&cxlmd->dev), dev_name(&cxled->cxld.dev), + hpa.start, hpa.end); + return -ENXIO; + } + + /* No parent means the root port was found. */ + if (!parent) + break; + + /* Translate HPA to the next upper memory domain. */ + if (cxl_port_calc_hpa(parent, cxld, &hpa)) + return -ENXIO; + + iter = parent; } + dev_dbg(cxld->dev.parent, + "%s:%s: range:%#llx-%#llx\n", + dev_name(&cxled->cxld.dev), dev_name(&cxld->dev), + hpa.start, hpa.end); + cxled->cxlrd = to_cxl_root_decoder(&cxld->dev); + cxled->spa_range = hpa; return 0; } @@ -3358,7 +3414,6 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd, static int cxl_endpoint_add(struct cxl_endpoint_decoder *cxled) { - struct range *hpa = &cxled->cxld.hpa_range; struct cxl_root_decoder *cxlrd = cxled->cxlrd; struct cxl_region_params *p; struct cxl_region *cxlr; @@ -3370,7 +3425,7 @@ static int cxl_endpoint_add(struct cxl_endpoint_decoder *cxled) * one does the construction and the others add to that. */ mutex_lock(&cxlrd->range_lock); - cxlr = cxl_find_region_by_range(cxlrd, hpa); + cxlr = cxl_find_region_by_range(cxlrd, &cxled->spa_range); if (!cxlr) cxlr = construct_region(cxlrd, cxled); mutex_unlock(&cxlrd->range_lock); diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index c04f66fe2a93..4ccb2b3b31c9 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -419,6 +419,7 @@ struct cxl_endpoint_decoder { struct cxl_decoder cxld; struct cxl_root_decoder *cxlrd; struct resource *dpa_res; + struct range spa_range; resource_size_t skip; enum cxl_decoder_mode mode; enum cxl_decoder_state state; From patchwork Tue Jan 7 14:10:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13929004 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2073.outbound.protection.outlook.com [40.107.220.73]) (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 ED7F61F7075; Tue, 7 Jan 2025 14:11:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.73 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259107; cv=fail; b=i/qGU3LQ6y+2C4qSeBiPaISjfcPltuY54tB7MhAE3//e4bpuWrhxTq5IfFkpyygucZt2N072UF+h/rbFM5PYm3NrQJ23gegGl/NO7Z4IxPIksOWHYCF/RoOw8upsphWwxOy1l6DtRiWz2eX4SPf5dZNeh02zH4pknCSpFlHX5yg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259107; c=relaxed/simple; bh=rNZRtzQTMD553IXiAYDSSF8MVNYmXQDPkFT38hGJN6g=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bRw7PQuG2xPr5BhHqh7+g+8UREDAO5oaCSjcLNaYWiuzGVchmqpPPdPpNATeqbabyIXhUa7tBJNpEo2g3i/KLf3gAUH3fQB+Ue2aKW+TZgOi3XmBUaPYB+AtJShXtwRsbvPp6mEZg1VnkTsRJUpoZCxo5tG4GAaihOBh9n3H3HI= 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=QEn/kk9S; arc=fail smtp.client-ip=40.107.220.73 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="QEn/kk9S" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MphZGfPsGgwHKDUceRym/zhK7yzBPzQ5gzfqQeFvNANN85PtOzfubYZiXR7i7sSU4tPhBQh3Voxnen5uhg6VkjHpTZMxIES3BBNie33PgG/rGtQDx3jJHmBoRwVC48oqriiOuRsqtpSFgGB28tViMr3fYnfhl6j9z4MEd5U7Vb9pMMNJFuzRFv7KFMnOyzDBH9qucRSLqy/SSnE+QpjLVJuZCcl9xcCDxqGDwObEQ/7obtH4owzQWeuOYxAP5NNhgBMQK/t9Z/m89BUI/nRwcKa9sqMR8/mtkcKhBS7KEY0DZ9kUVIhmzy9ik6A1eSaTD+BTJaaIYcMl0t0bPvybdg== 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=nnCChBjI7SQpu0xLR9cDcEpbd/eC43KRBYQi+wSDXCI=; b=PiiomaV29aaFTeCdMzl0CSl/ZimPR7MNdRbNVOfhL5Apj736pW6YF5vkRVQZty8EqRw/Up73QYGaZ0dLaHSC2eFDnktts0Gma67hJylLtFP7U8a2zVM9WurA1SHKVjNSI8QxT/Es8f4pnD3ETf/eG6gIstK/5APEx/J4TyBT8fntRXm6gKAf71alprvAsoSz9RM+NBSf3MlGBpGvTzl5OBHgV9oUZFcM8xP6kck8R0CXZMQidAFYminie0lpZqQljMdqxZdHEhBjRrGaPPgmSERhkFEcJ8goktNXxvuEX+quqDICaPi3db/YodhsTstZkms+so+0iCV4aa8XZFJCOg== 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=nnCChBjI7SQpu0xLR9cDcEpbd/eC43KRBYQi+wSDXCI=; b=QEn/kk9SQ+rJBLJnWAr0CPiHngGB+7VV/ZP0zTRyDJEEe6rsb7XjIzNevXhW/qomZdEKEA0jLXCa+a5Sy7icU0fBr49Lfvm5n6v19i9c/8HLq0bJOeyPCZMcjYxW01ttcy4eXdws83+GTtYBJC9nWbAOOE74p3zRB2kwtxDNJKo= Received: from MW4PR04CA0072.namprd04.prod.outlook.com (2603:10b6:303:6b::17) by SN7PR12MB6715.namprd12.prod.outlook.com (2603:10b6:806:271::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.10; Tue, 7 Jan 2025 14:11:40 +0000 Received: from SJ1PEPF00001CE6.namprd03.prod.outlook.com (2603:10b6:303:6b:cafe::f1) by MW4PR04CA0072.outlook.office365.com (2603:10b6:303:6b::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8335.10 via Frontend Transport; Tue, 7 Jan 2025 14:11:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CE6.mail.protection.outlook.com (10.167.242.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Tue, 7 Jan 2025 14:11:39 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 7 Jan 2025 08:11:36 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Robert Richter Subject: [PATCH v1 16/29] cxl/region: Use translated HPA ranges to calculate the endpoint position Date: Tue, 7 Jan 2025 15:10:02 +0100 Message-ID: <20250107141015.3367194-17-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107141015.3367194-1-rrichter@amd.com> References: <20250107141015.3367194-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ1PEPF00001CE6:EE_|SN7PR12MB6715:EE_ X-MS-Office365-Filtering-Correlation-Id: c255b0db-fce0-4444-0c30-08dd2f253491 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: s+ybea2Abpiwrt8i8sjXPoREBa5wjFU9rz1LiCZERwbmQWBKYxCy4fTQbup/+/N32SiyX5SBd1zsurR5a27B779XCZ9RdRfLiz1uM/vVfd7dqS/evXQ1LjYhPdFWMB7l9masZFjyqKQ03Ysvx7Ohny/0HirPrMjdIW4C8U+pwVcElXyJtPEM7EfqvDx6j9NKSU2ofQMFoSEOuWe60QvudXb6g3s6Ftklm9Jrkx7B/+Zi4k0ZeD2am47ym6FBhKB5TsY1BozBTrI5mgkC4iUczJVcf49Gt60CCrx+vTkgaJf/w9FOWIHAL+gCrW51SUgT+TKKWwx57t/yrC/70YMAqsprtgnhTgdQoWy4dbPgG9R8aVj2VMrhco5Q8mn4dwJE0Oo+HA4PuYGrQdZI8NZaLOqtfaQZQ0nilOWRh5/wb5q1T/gnjQChjrL+GAfN/MyMQYdDbYowOGH/c595QVGyLrVYhMiI4+nDqe91sIRw0fSrZOIlcwMYzCZs/DwZMBr1Q8kVAaAGMEABGaxEx1gk0YdAP28G34hV6QL1LmlU/+4uPA7gSSJeXqb2RgLw+RuscY6WIMRaEJD6Jv6AY6eJwBPOh3KWA/uLVOrvxNYjXvj4T5ezECz6jqJFpbalO4GgcloPf9qd5GkjxQxnCD7Nf/aFG8kLU4aEhvN6qRiY5oNB2hl92CXB1r5+zRBJXKIOLJ8Sws/0wlkEXOhMnGe9WXNgF/UpRphNivTv6yn8HPHuHr+OSPKLyjGqewTemFaHjZj+aui9YWYXTsL0zVKE8iLI5KTTwBEmzZbjk5hUvmivjUBz6MDjyuvjMTVClypyMBkabEl/vhpoD1ZelyznQk7jeup2Fr+jmb+MTtkOVk3n3kmw6JrMYX6oH9cCSu/7ycUxvcTUaSqTyuyWWtNWYiIApAnUL5NJxjqnfV+HFO7skAYFl3F9d4MtwgeYLJLVw+oZsYrVEquBrS8WXj/0/dU7IRxeXprHKIGBaQ5KQ6BrMZR4HpF3vj1h78XH+gzxIUv+WKndEj3Gkd+dI4rfWlnc/rvfg5z2DR6TH68oeKXfWQ0Qov9mEum9GQpZ+461u6b0vaUagYan67RGHgg9kZVsVwu63pqaumUp+zKlEvUlwNvIU6HUZux1TTvUWVjGKgKVlY5T02pZzWRT3AiQz9bN1oY2GlIoBrGSpZ9HXZff/DYP04e2uGP7K3SGMhY30lxMk9YZZlnDFfOAaEdJyuy1++Hg6QzF/Ol+XLm2CSRz4CoAZVKm6F5M6FxMzWYAiHM0inr/wJmZiNjFmRtnLvuZFgtB3cUmMYutvBuuXmZ+FLiXJwyWG3arZCQGWDF8VYqG5hjF+xJpLqDJQ2GeS1q812i2uDAaK6tFbnjlsTwTfwjuP9ITO1zAPaqoJDdcus5LTXViIByGxhkEBO3U2YL5uVsImRw7/aC9YFXAgdtAYPp8zdOwtVvOg9ltIsOFrJrfmnYoVbxEHdqXJ3N1GQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 14:11:39.7132 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c255b0db-fce0-4444-0c30-08dd2f253491 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: SJ1PEPF00001CE6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6715 To enable address translation, the calculation of the endpoint position must use translated HPA ranges. The function cxl_endpoint_initialize() already uses translation which could be reused to calculate the endpoint position. Use translated HPA address ranges for the calculation of endpoint position by moving it to cxl_endpoint_initialize(). Create a function cxl_port_calc_pos() for use in the iterator there, but keep a simplified version of cxl_calc_interleave_pos() for the non-auto-discovery code path without address translation since it is not support there. Signed-off-by: Robert Richter --- drivers/cxl/core/region.c | 66 ++++++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 22 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 007a2016760d..c1e384e80d10 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -1813,26 +1813,29 @@ static int find_pos_and_ways(struct cxl_port *port, struct range *range, } /** - * cxl_calc_interleave_pos() - calculate an endpoint position in a region - * @cxled: endpoint decoder member of given region + * cxl_port_calc_pos() - calculate an endpoint position for @port + * @port: Port the new position is calculated for. + * @range: The HPA address range for the port. + * @pos: Current position in the topology. * - * The endpoint position is calculated by traversing the topology from - * the endpoint to the root decoder and iteratively applying this - * calculation: + * The endpoint position for the next port is calculated by applying + * this calculation: * * position = position * parent_ways + parent_pos; * * ...where @position is inferred from switch and root decoder target lists. * + * The endpoint position of region can be calculated by traversing the + * topology from the endpoint to the root decoder and iteratively + * applying the function for each port. + * * Return: position >= 0 on success * -ENXIO on failure */ -static int cxl_calc_interleave_pos(struct cxl_endpoint_decoder *cxled) +static int cxl_port_calc_pos(struct cxl_port *port, struct range *range, + int pos) { - struct cxl_port *iter, *port = cxled_to_port(cxled); - struct cxl_memdev *cxlmd = cxled_to_memdev(cxled); - struct range *range = &cxled->cxld.hpa_range; - int parent_ways = 0, parent_pos = 0, pos = 0; + int parent_ways = 0, parent_pos = 0; int rc; /* @@ -1864,17 +1867,30 @@ static int cxl_calc_interleave_pos(struct cxl_endpoint_decoder *cxled) * complex topologies, including those with switches. */ - /* Iterate from endpoint to root_port refining the position */ - for (iter = port; iter; iter = parent_port_of(iter)) { - if (is_cxl_root(iter)) - break; + if (is_cxl_root(port)) + return pos; - rc = find_pos_and_ways(iter, range, &parent_pos, &parent_ways); - if (rc) - return rc; + rc = find_pos_and_ways(port, range, &parent_pos, &parent_ways); + if (rc) + return rc; - pos = pos * parent_ways + parent_pos; - } + return pos * parent_ways + parent_pos; +} + +static int cxl_calc_interleave_pos(struct cxl_endpoint_decoder *cxled) +{ + struct cxl_port *iter, *port = cxled_to_port(cxled); + struct cxl_memdev *cxlmd = cxled_to_memdev(cxled); + struct range *range = &cxled->cxld.hpa_range; + int pos = 0; + + /* + * Address translation is only supported for auto-discovery of + * decoders. There is no need to support address translation + * here. + */ + for (iter = cxled_to_port(cxled); iter; iter = parent_port_of(iter)) + pos = cxl_port_calc_pos(iter, range, pos); dev_dbg(&cxlmd->dev, "decoder:%s parent:%s port:%s range:%#llx-%#llx pos:%d\n", @@ -1892,7 +1908,6 @@ static int cxl_region_sort_targets(struct cxl_region *cxlr) for (i = 0; i < p->nr_targets; i++) { struct cxl_endpoint_decoder *cxled = p->targets[i]; - cxled->pos = cxl_calc_interleave_pos(cxled); /* * Record that sorting failed, but still continue to calc * cxled->pos so that follow-on code paths can reliably @@ -3252,6 +3267,7 @@ static int cxl_endpoint_initialize(struct cxl_endpoint_decoder *cxled) struct cxl_port *parent, *iter = cxled_to_port(cxled); struct range hpa = cxled->cxld.hpa_range; struct cxl_decoder *cxld = &cxled->cxld; + int pos = 0; if (!iter || is_cxl_root(iter)) return -ENXIO; @@ -3280,16 +3296,22 @@ static int cxl_endpoint_initialize(struct cxl_endpoint_decoder *cxled) if (cxl_port_calc_hpa(parent, cxld, &hpa)) return -ENXIO; + /* Iterate from endpoint to root_port refining the position */ + pos = cxl_port_calc_pos(iter, &hpa, pos); + if (pos < 0) + return pos; + iter = parent; } dev_dbg(cxld->dev.parent, - "%s:%s: range:%#llx-%#llx\n", + "%s:%s: range:%#llx-%#llx pos:%d\n", dev_name(&cxled->cxld.dev), dev_name(&cxld->dev), - hpa.start, hpa.end); + hpa.start, hpa.end, pos); cxled->cxlrd = to_cxl_root_decoder(&cxld->dev); cxled->spa_range = hpa; + cxled->pos = pos; return 0; } From patchwork Tue Jan 7 14:10:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13929006 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2083.outbound.protection.outlook.com [40.107.223.83]) (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 8D0E01F8904; Tue, 7 Jan 2025 14:11:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259111; cv=fail; b=s8fzECZ1OVa93zT6UtmFgW/ojmMuJMv5iCtk2KyA65+bC573VKAlEOPuqpNyMikqp/zr+632Ne7Uf3PxRxhR+aNMl/WlnYjfBAWhgQAf2sy2vZTO4RZyRZdTCcV/ZuLfaA22zgShQBE2oaFexjucd9liamQoaESkBJa4zJP41GY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259111; c=relaxed/simple; bh=qxbk5t87FOBOs2H06OOlmOEJT1gIjXiYBQYD+xrA1PQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ps82JgcfYSy8fM4Au0i3Q6dXOtPVTxvlsCyGW7rKV00f0CLpefHNWLqmOMCZXx5qf1IrFjRrO0hc+u1fr84nOS1ZqiKZjAxwMO33mDsPDyaTjTrCQEG6Q/ifBcXT0UdgUgO8WekanQ/wO9u3zdrq2WK3NpvWEvW5//hFHQbsY5Q= 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=4Pcd4WI7; arc=fail smtp.client-ip=40.107.223.83 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="4Pcd4WI7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XAvuAMZUHV7NitW73a1Pc0pJVo86uq8AfskdGRfE5yl5MEoqQQ1zC4eihC1Y2/ecOcEQM+SFPERu2yk+ObIbrjTOiJrWvaykyEZojnWuLYengjsjXYLfiiRZK/9wZwecAK8THMt/WXLKf3oQaWhWCdSBM3yah+Ka+8yuOnVgTUvyVTYUx8ZyNCZQzYw/8cbY6TftYd5Vhf/udhJxuBlOcuEQW5oTm3b9ulybvXIXcLXRDVxaUUp0pZHOF3a3Dq+ZPzCnM61UA94S5uu+zobDhuF6pLJtZ6t3vdGDRm2BASRqtDaiJJTNGygDY3vMSfxZAShBxe0cJ89I++DtuLnLew== 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=EwCzteXW8+AnvM22bExdiW5RNlXlDsZTDKHqmWsqbD8=; b=Znhn1ac9pg+Bgh5rwDejrm/L+BvxC1AvkQOTIImwafjc3RLn5YW5g0PSL6RAcmmY0n9YsSPJRM9F6/Tc23lG6IYiC+PxK0YgqNGRbX1cRhzeV8KVQz7AVeK2DlHjpFdqlpXSi/nf3dhFuHxPsWjeYUbaBnRvUaSq/hOtM5fHUppoZMtlAInF5dVibGeDRRJYiA/3bGhsDZe2Rcv9Nui4CvFtcZfqZzHKIk92SzHnM56EnNLNoxDn8S6xuNBxeU2h8XfIO+RWG7cWFQ/TQX2+6xTA18U0F1KwH/Ig09hacEPn+4OWTIGgeMG21RVk6/G3wT6iS+nbBWrgfQZlz4iDxw== 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=EwCzteXW8+AnvM22bExdiW5RNlXlDsZTDKHqmWsqbD8=; b=4Pcd4WI7OcV+YVQzaMx+BBlUDeMnPGyohLD/B3F7EbxgkqsneO9+bMn9DolVDM34eA6cPZZb28+seA66ugVoWYT8qMotGtp/7aypcOhaUn+Bx/PPf2DYAskLTrT6C8EDb5WWXkEeb8bpVkqrPK8ProEv9uiKmSwKQHLhnjTFpN0= Received: from MW4PR04CA0087.namprd04.prod.outlook.com (2603:10b6:303:6b::32) by IA1PR12MB8408.namprd12.prod.outlook.com (2603:10b6:208:3db::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.10; Tue, 7 Jan 2025 14:11:44 +0000 Received: from SJ1PEPF00001CE6.namprd03.prod.outlook.com (2603:10b6:303:6b:cafe::7c) by MW4PR04CA0087.outlook.office365.com (2603:10b6:303:6b::32) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8314.17 via Frontend Transport; Tue, 7 Jan 2025 14:11:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CE6.mail.protection.outlook.com (10.167.242.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Tue, 7 Jan 2025 14:11:43 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 7 Jan 2025 08:11:40 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Robert Richter Subject: [PATCH v1 17/29] cxl/region: Rename function to cxl_find_decoder_early() Date: Tue, 7 Jan 2025 15:10:03 +0100 Message-ID: <20250107141015.3367194-18-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107141015.3367194-1-rrichter@amd.com> References: <20250107141015.3367194-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ1PEPF00001CE6:EE_|IA1PR12MB8408:EE_ X-MS-Office365-Filtering-Correlation-Id: 6b6fbe1d-250e-4785-679c-08dd2f2536f3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: SsW3W5l/FY9ta6bnyqoa0WTECZQtNptAVenMXHBb9J1+jj5EgFp6QHytHaeJyULnVUd+Ql6mOGHMTWxnze8PmXc/I2kM2dr/uKx8vKMrk23wYul/Zfr7BJho35HRByv8mPmSoAAQn+7tUiRJG5XlocTDr2EcVb+rXWA5Duvf7o22/K8mHZSN5OAJlfcbeKA3pw1aNfq7cXF4POMw6WJyuIAOM5FLGaNTL2UDI3Y8u/M+64br3qO4BZAwoC75uX8zMjzqMOfHaEgfUW4Bveb9m6u3+C4ufgOgs94lpUiN7C/5yfxqUVEkdilopldpXD0z+HDLIwVeMu/Ok48NhlanaFFsAEYS9B+GIo2XWzOssMIuqTHTwW7oDZGfEIgazguVPpIDsUkMvZk0PVdMknBmUTc0ixbulzzv/hivTF5GscfKJVMWwy4GYg1h54PyP+KXItd+MlLkAnQvqkFZDn4+ixq4+zsfOkqaz3yrLYE/46N1FEiQU4VrglZzoqUe6Dj+wk2c/9Ij9CNy/ErtRJi2dcUMjX1/3L5eCFJqftHJcQYlxPBa14X8vOUs4GevRsWdK3Qit5R8aHZYDA9c/3rK21ZFlgAUXj7BnSlROlHAFu70+ezze8/ssA7UZF5ZmumnzxNT2sspMgkJItQbHMGzD2mxcyfX+Tj86RWgA+exC5BvNbER8czMdjH6hIACnnqNOgyoEKBj0ueXXzygGyCzTn5EX/tLqtt8MZQzNf/lPaB/Ng9K8y2p+KS81fi2xoCOSUbRXav43MD9coBns/Fpzp6EkCOFMJyj4DVNxuehJpVslhxSZVOW7Fm2qUrcqBGvaQIQ2G0FpPzUy+GOIO3QSOKIb/+HBE7mJtCuUut+RtrzvolLBIhilJOb8qCar5ovP2QWNmcALfkK3cQGxt+4vy2rxqyoQj5wkwhcbWcx2G5loi6hE2dVd2hIbckfs78NYsn2SzUuu6m4iQxWyojstlEDujlePaB2/ZOhkVTq3OV5js+XinCXOffV/sNVO6QB+YYFsnoOae32BqCM1HNlAA0bufUH7f5TnHn7Bn+Et55AuAgWuPyKxWGSwCTvNVzqKRU8lxC/CGBDoMbWCM+sNI6eNbonsin0Psb2YtCPZhRaOZWPiPoLHmMibjKjCcHcRfS1y9RwTiz3XegUa279bUtYGtw8rCUWaEa2eBKIo+4/gcxBwJsg4HNyhfKTdMWJ+m/TjJb6wsnbPf33T/jTLSIpPK7O+Cd+s9g+5lugzHgDzFAA464VAzNBt5O57c5rawchNh2HSJtfCT9c2nbsquGRuaonB9kvE/RNNQkf0xP0Veo13njhZbLH9YE24jJe5TdcSCxHN/pTHhu6TeWGqVhiwWrrAoKDKkD5C4ifS4rUZclX31KZPo73iDh6AF3I0RTumFDHVBKe0RSXKO7+9bxEXThMGDD8sdtvXu69HJP5qx7znx8gl5iQAneZG4S3NO1Sohe8Qip3hGkiSWZQCcIQJvR0pUS2HLF6FoATWZY= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 14:11:43.7132 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6b6fbe1d-250e-4785-679c-08dd2f2536f3 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: SJ1PEPF00001CE6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8408 Current function cxl_region_find_decoder() is used to find a port's decoder during region setup. The decoder is later used to attach the port to a region. Rename function to cxl_find_decoder_early() to emphasize its use only during region setup in the early setup stage. Once a port is attached to a region, the region reference can be used to lookup a region's port and decoder configuration (see struct cxl_region_ref). Signed-off-by: Robert Richter Reviewed-by: Gregory Price --- drivers/cxl/core/region.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index c1e384e80d10..2bc2028988d3 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -878,9 +878,9 @@ static int match_auto_decoder(struct device *dev, void *data) } static struct cxl_decoder * -cxl_region_find_decoder(struct cxl_port *port, - struct cxl_endpoint_decoder *cxled, - struct cxl_region *cxlr) +cxl_find_decoder_early(struct cxl_port *port, + struct cxl_endpoint_decoder *cxled, + struct cxl_region *cxlr) { struct device *dev; @@ -944,7 +944,7 @@ alloc_region_ref(struct cxl_port *port, struct cxl_region *cxlr, if (test_bit(CXL_REGION_F_AUTO, &cxlr->flags)) { struct cxl_decoder *cxld; - cxld = cxl_region_find_decoder(port, cxled, cxlr); + cxld = cxl_find_decoder_early(port, cxled, cxlr); if (auto_order_ok(port, iter->region, cxld)) continue; } @@ -1032,7 +1032,7 @@ static int cxl_rr_alloc_decoder(struct cxl_port *port, struct cxl_region *cxlr, { struct cxl_decoder *cxld; - cxld = cxl_region_find_decoder(port, cxled, cxlr); + cxld = cxl_find_decoder_early(port, cxled, cxlr); if (!cxld) { dev_dbg(&cxlr->dev, "%s: no decoder available\n", dev_name(&port->dev)); From patchwork Tue Jan 7 14:10:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13929007 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2047.outbound.protection.outlook.com [40.107.220.47]) (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 5591C1F8AF9; Tue, 7 Jan 2025 14:11:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259117; cv=fail; b=SD8CM6WUISJzD2/SKQXB2eG6AzbkqBsWYBxNpqC+hgmt87VSNt+cFJujkcuUgRdMKuuAwsiBfe5eEQ7BqcveW21xXJJhBwJ57apVojX9PbPXpsO37DBUEs4afcEAf5rQtcQYmteLPg8Exd04EEir2ZNjSYl51ePbv+uI8JNDmrk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259117; c=relaxed/simple; bh=q/VOQiZMA2ILDi5Ij9CpKNnl1y6sV8rlplRAAUaaD0w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EvkNsKelqcgyI8M7tLzJgAkt4j2okBDl+nFCx96avL5J0XAX6uq6K3zuNARqRAn5LyKdlm2ETTW5N6yd9GboND6c/muQHA29Y69C3vcxLaJIpe2lhRj64fX7Y+Eie1/iadm1i9BHQ063he6D11AxWDytvPR/rXnB9XrCUFfiNoI= 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=m3cV8lew; arc=fail smtp.client-ip=40.107.220.47 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="m3cV8lew" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KVs5almOAQfQ8PDGGgis9LYdGf7PjMJFE3P8rdevaUCxG7H0ZfzRE75osP2CH30s9FPnQltlmSSujSx5acvO6fZNnfDRqy5BSFBBENVh8Ojw4/digrvmCV70krRi9ekX4lbJiyobvoJ3NiuJKZ4mpTmTGgqINiVVwticm6u/N39J6FgnJPLeCdxlsEEcu/Nc5RxYqgWoZstnY6zVlG5GiRf9C3RrOnEICQlWKvWkI7BiQj8CUdi9w/1yq6UzjkifKR5LfeOpgjfN8QYZslVjZhCdogxdMBHLX5rNZwjZB8mip2mGkeYOhSI17B0MDrkgWXMMYhiFvsq9MxnXmRvK+Q== 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=h5b+6AHF+NusUsXe91xNLTCoHqSXgILzEZ8L8yfhgss=; b=cxUWPVj1Q7h8co9jbnH9xsZ45cHrmKmRcgnmrh/fbH0Jnot4hdLZC6SWpLlSW1xfmX3FIV9uFo4p/R4i+d3qBIA0PZAJbqF3QYx09oq+fHrS7Fu+ofIK5zbGy6cjOm1rTVpeCjdMcCIgp4N/Dkg7DcJeBsSoib5ivHzD7lp3Mucs+Uy9kR96DurLD5v9UjFaXori3Kl4Uyp3wBQeXHWcWVvppTtJNuKDy3Fi8omCgudiVYuqDHLNWGm/lbiqXgOB0PaWeigirNKN0rxs1CGT9l1PKL7VQpnT0sTw1bJ4d3fWOhq+LO62mMdt/ftH5116WObOgDR2/jtMbjAxGvM8dA== 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=h5b+6AHF+NusUsXe91xNLTCoHqSXgILzEZ8L8yfhgss=; b=m3cV8lewzPgDZUVopwyrsUD7+ZBIAZT8Fa4vF97Uc9GpqAqQnu3IeBY4rYZAUXbOooU7FXYNLKtDxYGLKQ4mxSjK6IR7cR/+4rKNMao3ig46eJgrgwY+KGA44oynZ+oJTUBHoa7oNE3gFumhdVDHa4slMdm6Ze5XRT91CIK/wUc= Received: from BYAPR01CA0071.prod.exchangelabs.com (2603:10b6:a03:94::48) by SN7PR12MB6792.namprd12.prod.outlook.com (2603:10b6:806:267::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.16; Tue, 7 Jan 2025 14:11:47 +0000 Received: from SJ1PEPF00001CE8.namprd03.prod.outlook.com (2603:10b6:a03:94:cafe::30) by BYAPR01CA0071.outlook.office365.com (2603:10b6:a03:94::48) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8314.17 via Frontend Transport; Tue, 7 Jan 2025 14:11:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CE8.mail.protection.outlook.com (10.167.242.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Tue, 7 Jan 2025 14:11:47 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 7 Jan 2025 08:11:43 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Robert Richter Subject: [PATCH v1 18/29] cxl/region: Avoid duplicate call of cxl_find_decoder_early() Date: Tue, 7 Jan 2025 15:10:04 +0100 Message-ID: <20250107141015.3367194-19-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107141015.3367194-1-rrichter@amd.com> References: <20250107141015.3367194-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ1PEPF00001CE8:EE_|SN7PR12MB6792:EE_ X-MS-Office365-Filtering-Correlation-Id: 81a6421c-bdda-4d18-fb01-08dd2f2538fb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: +D02BdQ1iUZ9X1p0VodaY+NumFZYNajXyUkaGzETGFqRVzscDycoX5zRKj4uaLKB229aEZMVRDkPRlvYAAhp5Tn6XyvEB3M/NNLzYm8/EvqlgoUpTPSbwSMVdK9fzCvv6aCZHCUhFsuSPT17oVzuNJp7MFQpUVftB34Fsp4ppP/TeXSX/agr1r+Us/4D5jzvgJUxBSOwWpYpq+T9qXLytsC2v+8+xgUv3EvpOhLAUS0iNDeISkaHQkivMCJPgjOCGolxktj9bdompRU10W2c9U3o5rdsUcLI5dDkOrcaOpFd/qPfKlKjBYbtLZCaXHgNrwwoImC+IBdm9AB+nKHpck8wwRiSXtCFwzd3c0VnwQ23OLoZ5VF/ZTvRAgiOl4wuWk06VfImqdgdXpCdMA6liYXgAdMaR2IAqz8jRX7OFFJQKlsJcVzXlo2hxP2UFnEWgPVDhUbt5blgE3/pQqMscWesc5SjduRE1rqA9e9fHy00XtOLDp6g8vDO0XQl/k+sESiMk0W2Vs8Zz8EMr79HzSAWM77ijOcCcNLKnTTrIDgEDQlKP8XHEUhIlr9ymTmD+M5+moqMyXIqUt7fdaW50A7lyqpwIJ24Eqyry9RX6hlP0cpFENIsYuK9F6hpSQx07R6C/9KCWgVwSSgSpKHEzZokxmUlMapjnVdGfF11plkrWlBM/ETeLqhcRMAYUgQKMLWCram5exGFFZlImGlIiEuXB8UlBaYLJazhPo8uhiS0L9BLqIxzvfi72tPGZ/C/cWu5C4JlMO9zvHYEyuQT2IOAHikOGXIpMBc5IfcWEjLrBWFJ0P9DbDEHZl6HQr9IbZkuEk9iLnD8mHJlW7x8sdbBDqTEB0P/zfG9rBCx/jxIYb5yK9c8I7QMNWOCJkTxHM5LwZ6Z1XOFDPa8QEAkJuwwxfdmwMaqUfHViKnOiyV/ilfodLNqZ8hAdV+/+qtl/UIOxmqHR02u8ND2VGQ4IsWGgk45OD7ELdENW3qCseBUuKAdsJYwE3Ds74wNs338rjLPSYxtdt8GUqek6Zs4ePX4umnx/FZn28mT1JXIQpYQXl4FccuUfdkxfK3EXYoeqJ/R/D9yB+2xyzzqRzON2rNlTcDc38wVgePansIrmXHKFpCmY5e0DWkB06qgzXuil8IuDTs3dUg3frq8gtjRJ+h4lgknol8LGNv/cI+sWan8u0hfjPBhVj8M/xGig2ht1haDGLwmPAVhclD/+GE8qnJX+Cds3o3XCKrULI34WZfz8qlMjsvn4WQ1LZ4/v6CniovPxPGQSWulRwiZjQE1AWU3kbxpHGq/FVhMcwFyoRBQWOKeMfCJ8qby+J3VCJmsbTDoz4aAHeh37VAYFDnNDXU/vfCBJ8iCd9W4MXr5b669UfEQxTQSih5TL8WkCMCG53zhfd3d9o2iBC2TpsrjjX4QM8fugcWvdditDJKtaiB8ckZg1qnnOeWPBke0dCc1eJsTsWBVxSqEiirgTsb9IVAhr8BM5lFF1jlyFbs+n4Y= 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)(1800799024)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 14:11:47.1249 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 81a6421c-bdda-4d18-fb01-08dd2f2538fb 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: SJ1PEPF00001CE8.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6792 Function cxl_find_decoder_early() is called twice, in alloc_region_ref() and cxl_rr_alloc_decoder(). Move it out there and instead pass the decoder as function argument to both. Signed-off-by: Robert Richter Reviewed-by: Gregory Price --- drivers/cxl/core/region.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 2bc2028988d3..b7f6d8a83e4e 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -928,7 +928,8 @@ static bool auto_order_ok(struct cxl_port *port, struct cxl_region *cxlr_iter, 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 = &cxlr->params; struct cxl_region_ref *cxl_rr, *iter; @@ -942,9 +943,6 @@ alloc_region_ref(struct cxl_port *port, struct cxl_region *cxlr, continue; if (test_bit(CXL_REGION_F_AUTO, &cxlr->flags)) { - struct cxl_decoder *cxld; - - cxld = cxl_find_decoder_early(port, cxled, cxlr); if (auto_order_ok(port, iter->region, cxld)) continue; } @@ -1028,17 +1026,9 @@ static int cxl_rr_ep_add(struct cxl_region_ref *cxl_rr, 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) + struct cxl_region_ref *cxl_rr, + struct cxl_decoder *cxld) { - struct cxl_decoder *cxld; - - cxld = cxl_find_decoder_early(port, cxled, cxlr); - if (!cxld) { - dev_dbg(&cxlr->dev, "%s: no decoder available\n", - dev_name(&port->dev)); - return -EBUSY; - } - if (cxld->region) { dev_dbg(&cxlr->dev, "%s: %s already attached to %s\n", dev_name(&port->dev), dev_name(&cxld->dev), @@ -1129,7 +1119,16 @@ static int cxl_port_attach_region(struct cxl_port *port, nr_targets_inc = true; } } else { - cxl_rr = alloc_region_ref(port, cxlr, cxled); + struct cxl_decoder *cxld; + + cxld = cxl_find_decoder_early(port, cxled, cxlr); + if (!cxld) { + dev_dbg(&cxlr->dev, "%s: no decoder available\n", + dev_name(&port->dev)); + return -EBUSY; + } + + cxl_rr = alloc_region_ref(port, cxlr, cxled, cxld); if (IS_ERR(cxl_rr)) { dev_dbg(&cxlr->dev, "%s: failed to allocate region reference\n", @@ -1138,7 +1137,7 @@ static int cxl_port_attach_region(struct cxl_port *port, } nr_targets_inc = true; - rc = cxl_rr_alloc_decoder(port, cxlr, cxled, cxl_rr); + rc = cxl_rr_alloc_decoder(port, cxlr, cxled, cxl_rr, cxld); if (rc) goto out_erase; } From patchwork Tue Jan 7 14:10:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13929009 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2062.outbound.protection.outlook.com [40.107.243.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C81D1F8EEC; Tue, 7 Jan 2025 14:11:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259121; cv=fail; b=hyxshXfsxgobdvipSVuu/GjvJ+CoFs2aU/IcgnVVWkE/SgISz3Fcpr6pLmkay1kZzBpheVBeumte5ak78CV+Tpg/RT2Jy6d8oJFmq9378La8YYpAsGxH4vnuxyblQwOLLXykuIV+hw2xeZUYS7bSVqF2poKjstHEWRD/2C4cIwo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259121; c=relaxed/simple; bh=fl3QtEP/Retc//l5rbxO4AS6MrOXJbUrXtt0pjfinwM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lA6fJk+gpF5cECwEpMPJP9SBgpzpwL8D3yO1/d8GDfUiUnpdmeLEdwoG/X9GKxxPC1KUrwKqP48yqfMvWpuRiL9neGssAoJJA6Yg5k/iWzllinarLInXSwUAdK0aQLcC9Au+tqRt4lsKazgOGTP1P9vO1BHzi1B7sKDz6TSuk+4= 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=trA5BSyo; arc=fail smtp.client-ip=40.107.243.62 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="trA5BSyo" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=M97SQMlOLcJPCvTFk8S441rYK+F/oecKG0aelq0B+gmM7ed7OA4azF4OP00+Mf38qKnxb8Bee/lSgD5gq9FhItjeRTiagGAQo9X9VA1avMkEbE4EEAmTrCOFuXBop946UXJ1R/YNo4qK7FuHP3voIoViEjNdgCde7kbjDnhRTI9kL8UNThBUGn8ZNOEEO2q3O3GogzkUqaRmgkuhK3QGhdHCuc8FahUUrOqCj/ieEhGySTZCmrn8w1YSm5gvCZuNZmO8rqJ4iEaQaVaB8rZejk0vY3S4lYfrnPS+O2STllOaz5wAXHzZTUu13cVntOHVltV356MI4AHBzNXfmdAZBw== 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=SBVB1bAHqkluVb6WURX7rQqZfuMVHD1m3mwacaTNR1s=; b=KxoVWdLUkC7J31j8J/CurQCEp+1jGeLXk35Rh58dCs7Fk+TyFDrI4l0WRh/TeeHBGjqic3osZS/67zKy97S678USFpePMnBryQtuc/cQ44avrvtvq5gC3+e9h6RZdwzxGmgOKlXcwAPj57EKLWyfwN+lXDmwtr9oRAKpEXohzfAOF/QJUjNsrT0bRnrgoTto/atNcNRt7i+G8danJLMTQID4kTUfZrWqSYGoT3k5GcwcqzxDRwWbsFb8I6jHvkeH05mf/Ncog4KbmAn+vvzRG2RW8sOtf0mKSolblHaxpOsUCc48QjECEGQOevDsWMGG164YsCm1bjRq4tX0BY1Nww== 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=SBVB1bAHqkluVb6WURX7rQqZfuMVHD1m3mwacaTNR1s=; b=trA5BSyoD1JZK4/Z2wTuyIazj9oDfVkdYClIVBRYvKUCtQ9J4Yfx7XulIzsGeY+1vw2UaOuO4Hp14YqGjkV8F3A/6TcS9Z2l7S2wPJPwmS9KsAnUerk2vp8Vnc99EQIX65ejpZqOZ6/Gt1i2dzbBAMPncENS93di/DC83cBo/7g= Received: from MW4PR03CA0175.namprd03.prod.outlook.com (2603:10b6:303:8d::30) by BL1PR12MB5946.namprd12.prod.outlook.com (2603:10b6:208:399::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.17; Tue, 7 Jan 2025 14:11:51 +0000 Received: from SJ1PEPF00001CEB.namprd03.prod.outlook.com (2603:10b6:303:8d:cafe::78) by MW4PR03CA0175.outlook.office365.com (2603:10b6:303:8d::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8314.15 via Frontend Transport; Tue, 7 Jan 2025 14:11: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 SJ1PEPF00001CEB.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Tue, 7 Jan 2025 14:11: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; Tue, 7 Jan 2025 08:11:47 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Robert Richter Subject: [PATCH v1 19/29] cxl/region: Use endpoint's HPA range to find the port's decoder Date: Tue, 7 Jan 2025 15:10:05 +0100 Message-ID: <20250107141015.3367194-20-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107141015.3367194-1-rrichter@amd.com> References: <20250107141015.3367194-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ1PEPF00001CEB:EE_|BL1PR12MB5946:EE_ X-MS-Office365-Filtering-Correlation-Id: fc7815b3-2b9c-4770-cd74-08dd2f253b1a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: KYKBVvFhFJ7lYEFufMsrZCbVnbK+wcP8gADX3uOS4ACJq+IkLwoLLhJ8m6Ny7kFDMtKuD+lg8zcQZHwVXWG+hniZMWC7rVozsA0Z0na4L/Zeo9iDYdl+d43bmXQa0C2tM5cTrY9sxCfFjCCQ9MGi/4ylN0NQyfcJsyYaoG/1NMbvWcig+BOXWDB+2K9cRQ80Q6sO+xvsk/5T0qoNHB3K0Otjo7IX49VMO/lrutU/ejhOwmPJHmrbb/6Gl9gQoVyOGzdpCLvZ4Ix39EfAJVFW3tIbmYPIMHVF7pXJ5y/JmNiU1HACsSBeEVm1bNqo79c0lpzxC0OyUrgVk4QJtmVjVAI2icI1nAj+eNZa/xQAnp3hpT0dFsxhBumhhTabFg9V6om2SOGmhHHkZKxoXDZnxoG6whOOPl2p5VhbQLIAml9vLBh2yR3sMTTbU9bLw7qSMqIcvY1VeagapjYlk54+y0iRKiA8kGdTpZeeYSQpbzPTGATnQOg6IQ0KgrDzqMlxvAj+Bs55EAMwy2uWnsTZc0NL235ij+t4Axjm9jzEfE6wxn19aYXqYjjqrPbTE9ZJIh98CIlWQq3DZ+6ix9BvHBbK6PNOPZ2Ctak4TdAVzUq5RdQKjcB4vqxXlaUZ4B0qqaq1wsJ5ez/6NVUsuGpcJJVfUftwVAi+0FNEGHdCnzJg7pWYeVWBxDQTcKCZdox/JrNdGlssy+bbfgEkIFk65IJ1zFJtm3yDAig+0/OVqz+9ovCk/vjDkjFZT7bm6J6uHKcxOfVVfd+s8P7xe4PgHoEofWMQfaMz112R+1yRUs4uKarLGdWzZoUlfN+mp4fdQTL+PhfKGcpPGQwjsDRvplJasYSMjxSMU99b1ECdgyQneond9OaizrgrkhZ9nkA2Q6tfLfH6vMevn+3rWArtbE89IpibhUQdGQc0JIzRwD0f1YjgWTMR9qACZSvoLQhDRnO2DJUW/zncBDOlZY31adjDXUxe7PSkeH7qWfrvJaZomkXzItZy8oj4tFadanbhfIW1X5j/zRCVJUgilhJrOfqMuQUsnp94qbke6VqfRysvl2uktw0eGKtSMfD4bhO54By1RIJDlKAw/pVU/I7yUY90CSArjt62x2UhsmKiY0GR+FnYggroThJP223ca6B0Smli04hT+/MbPokBM6MRlOK8S4QcMtWNkfLlD17P7rMvv0o8K51inHY1joVJV3vrICbLdXrmz5S7+yTzSerj9pUmKA/j0pcVJOqGYeJ/wmuTt7qM4Mts1GP32tYf2f2hGAw6a+CXtlwYPdp+u/tZN6aWsdMrWip5C52u6rQKMp3lNI5m3jrYx6CiOGvJJn3o+h1V2CvG+LVSKSYG+48Afr1dcMnTS+26WyL6RclGtR3dyjXH13ZfSTWfEKV0CfgFSPAETXfresi53Mni6gaOaGKzo1uMAIGRAmfqtKUTJmlaa3S14wtdtfo86C/B9m5JwV9iVM/4vlCjjuiA/0ajDc0r+tD0/G3MvkUVbupClag= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 14:11:50.6823 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fc7815b3-2b9c-4770-cd74-08dd2f253b1a 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: SJ1PEPF00001CEB.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5946 For the implementation of address translation it might not be possible to determine the root decoder in the early enumeration state since the SPA range is still unknown. Instead, the endpoint's HPA range is known and from there the topology can be traversed up to the root port while the memory range is adjusted from one memory domain to the next up to the root port. In a first step, use endpoint's HPA range to find the port's decoder. Without address translation there is HPA == SPA. Then, the HPA range of the endpoint can be used instead of the root decoder's range as both are the same. Signed-off-by: Robert Richter Reviewed-by: Gregory Price --- drivers/cxl/core/region.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index b7f6d8a83e4e..23b86de3d4e7 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -861,9 +861,8 @@ static int cxl_port_calc_hpa(struct cxl_port *port, struct cxl_decoder *cxld, static int match_auto_decoder(struct device *dev, void *data) { - struct cxl_region_params *p = data; + struct range *r, *hpa = data; struct cxl_decoder *cxld; - struct range *r; if (!is_switch_decoder(dev)) return 0; @@ -871,7 +870,7 @@ static int match_auto_decoder(struct device *dev, void *data) cxld = to_cxl_decoder(dev); r = &cxld->hpa_range; - if (p->res && p->res->start == r->start && p->res->end == r->end) + if (hpa && hpa->start == r->start && hpa->end == r->end) return 1; return 0; @@ -888,7 +887,7 @@ cxl_find_decoder_early(struct cxl_port *port, return &cxled->cxld; if (test_bit(CXL_REGION_F_AUTO, &cxlr->flags)) - dev = device_find_child(&port->dev, &cxlr->params, + dev = device_find_child(&port->dev, &cxled->cxld.hpa_range, match_auto_decoder); else dev = device_find_child(&port->dev, NULL, match_free_decoder); From patchwork Tue Jan 7 14:10:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13929008 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2068.outbound.protection.outlook.com [40.107.223.68]) (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 0BAFA1EE03B; Tue, 7 Jan 2025 14:11:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259121; cv=fail; b=AMu6PndbKBV4eMF1kq//0IFCTQyaAnFo3SEclLiXoeZdhONFhf1Lw6cnWb+c52dXEzI6tQoGUZdsPwx7RZv8eGdjXkZc7RhfoK9lz1tHjNlWzL5gqKBCw1yBTq3nTu1SBAjPJcaVI2LM6On7mPBM1wJvjBkqYqOfNSjf80G/irc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259121; c=relaxed/simple; bh=kvn5HdO+1ifl2uKsKyfnnESWhPSyxxd1nQWzXur+4Y8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BrV0aLkC8R+HQG5IEKI2hiooSsoZxVWEko4mP1kqWIsvEFV7Tag+qw1ORiYuKF6KXZJf6+lP125tiY+dQa3ELz3BXgbxoN8ABOBNxQmF6BggpZS9XvdWjHqk0UkkgEUwnt/A6nLPqnTzrbNqtWJIXE1W1btFjHgQwyL8Pzm2IRw= 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=pNqrCupJ; arc=fail smtp.client-ip=40.107.223.68 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="pNqrCupJ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=o9eZ8glmg/2kYRXC8Zm1fceqL+fzKU7Bny7IjPHO8mtX5NdLbyYgQgtXOUjWGE3wGT7cUDZ95fedyhK2Jdtl44+pvk+xOjhethi7HDmxxpk/tbc3gJvMjkC2ruit/MWvtkISbtMGVfoeWTbCL75DOd+dyXm+23aO8IWKzW+3VptYCZ4c5zt/K5nvVeo5JQOyMT3ZHsUst3PtbSRFx2EaAhksOLvlabRQCxw++fIX2R3mjc8V5EVvTT+Cht4qH+n0WaooFpPBUr8foEJJenVK3GX8/eAV8wr92KHq7vMRa+E1eaBSV9XuzXeqoJPIGI37vICGUVPdpe/IVZD3MG7hsA== 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=f4i0k6kxMxODHXgB7k06bZFlS6qOfvRUpHAa/0vTeOE=; b=nkEnw0dd6pADqoiG63ybtrGgkU9UzatAOkFJiQGLOS64YzrU5jvW5aCxMFpCQxFMQL/+QbFWxPtai1JJsQX1zaEXwMnH7ynt0kNirpX+RVshgKbc6oxW811Wcq9QLQ9tTCqzn7PDnX5RQYLlUlDdu0IxS57alcyLGhcxuvnBt2I7YNHrxxwxJHOF7ZYktFVtdLZPaMp03Zvt/+uYvfkNhbOxx+u2vKMOMBndDwLT4yojUtmn1miYl1RmUFEEjTQeSSreKdZiHNitlXETIdbj7zihB6YWk/6EnskTyF08sZajnS5wcILyRNhWb2i3KHHbHzeBrBFydPGo0Po3aOmTAQ== 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=f4i0k6kxMxODHXgB7k06bZFlS6qOfvRUpHAa/0vTeOE=; b=pNqrCupJ5lPTbSL70Qb25isWgG5jh4ZV/EzCIDpJKcT+UHvCkm294mjWbwhW/NxCnWgjXqLtTvNFHNRS1O18cIlU7sfDXWatiQCQnYt4eYeg2Rtee6STlFgAZvN5VQ4JgnNPNhxcdNpPucX6bklN/rjd0IlrlKZb2JZ8AkqpKkI= Received: from BY1P220CA0026.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:5c3::17) by SA1PR12MB7367.namprd12.prod.outlook.com (2603:10b6:806:2b5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.17; Tue, 7 Jan 2025 14:11:54 +0000 Received: from SJ1PEPF00001CE9.namprd03.prod.outlook.com (2603:10b6:a03:5c3:cafe::e2) 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.8335.10 via Frontend Transport; Tue, 7 Jan 2025 14:11: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 SJ1PEPF00001CE9.mail.protection.outlook.com (10.167.242.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Tue, 7 Jan 2025 14:11: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; Tue, 7 Jan 2025 08:11:50 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Robert Richter Subject: [PATCH v1 20/29] cxl/region: Use translated HPA ranges to find the port's decoder Date: Tue, 7 Jan 2025 15:10:06 +0100 Message-ID: <20250107141015.3367194-21-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107141015.3367194-1-rrichter@amd.com> References: <20250107141015.3367194-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ1PEPF00001CE9:EE_|SA1PR12MB7367:EE_ X-MS-Office365-Filtering-Correlation-Id: a42f1958-88e1-4851-3d07-08dd2f253d35 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: DQi0VA+xewD9tkWN55nhXbZlR9EZaxLMZlGxjetjkScfR17KzKjGUs//mCsurk1wSboyOt2bA97oRZZE33vrYbiD3b1dveVhv8FuI3LLep1688MZQQiJLlsAzmIU0XE0bCJCTxG0tS2QvJAaITzygtsIyqtSEqyknv0S6nQRPPeYNnvIpgIPex8BoiRpp/pMhKpEtwdNGc3zn8uox2lZR49HrrwauNT/9bP/MBanbVsrLBw+sM/wazL+onzdP859/fICIZTJSMugQO6EJfLh/N6qbe4kqd8LnKpWjdTGeQVUmDUzyu+BjGEax2yCbAG6MSNMQInbbIRIgNZAVXAcLpLD+ArKm1skdNib31FDOZQETn3MIc7sDHoKY9tdJ21bKepsmUoT6t6NJYxe6hDImQIUUYL5e0vBPaMDwVnI/6h8uZKMeTpJSrdM9fPu8TXMwa5uwZ59fQRVxMF60y381e/cNyeTAtBryArZNTTp36f8dX7CKbmwGQzz9nSZ15mZUyzYl5NBsgocf8V/5FzN+8hnAchEJV6VeXQ/kspye2ZSd7xxihLGy4IxI4ifr2BelJvKhLXLwjn6qsY0yc/BVjI+MPhAkItS48dm+FrzgQrfmVqiNcPPALGBC598ggALCuXfW7Io68LDn/4Gf2mSvH1u0C5BdkPyRDDBwfed592/du2oHA7+4Tk0C/VLXcIoagHf/qJ2yuFaJzSwCpEWDo2/2rZs3HGRTWahRbwTZAG9ZpFllPXbZp4s1lIhY+UMHZRY8JM1vyudKLAY6iwb+VJxgLYHoeQUc1beRwQ8kmwDla5nuoyBqeZX41r4Y4TalCS/COMa2aGkgiLjYiBvqe326GcC9hqQY0R5o+TBR1v105M9jsfy1VZoCQ0nrxx1A1ymqeqUloTpM8vw91rOfY9p3lJjy5xf/kXEVUkIPQQGmgnvlocGGOULyi3FExmBNcO9SnrYAGHng0ImsWOJV3qDjg8dVhzbI618BRMyP8LbXLnJarDG2ikM1ZNb7LuBEdeO4evbSJfsY6t40uJ31Fml6vVM/KqHeHJC1ZA13/oDc7ECnK2/uuHLXgXaUV3Bn+R2ssmFMjyruv0SGI3rsa+lMDnHGqSxPm7owndnw9JGuqL9441XekFyfRfVp1BGERaDJMO2oraxf6+nFsAy3LQrpFc8y3gbMMWJrd8rGbkLX7vDbtz6FFV4wBhfGwxxzAzI5l04YBLJDiJez76cAoQvTOqWO5Da0Qmc/sOMNvlR9VuiiMwzVN/ryQx6b5x/3lG1ixFqs21aBii4fhcseemKAeXXrFvNj4xgHcFdu+VkQJYYnoJRJoYC2B1PbdUmIeBDA7yJdmZl+m8aVHduw+KjR3fO+SOrCysnHw3yDII2yMMftBmVDGPY6FtCXN4zMQv/7USsPLInRA14cP5jhQ6elJYf1Q6a4YQmZSwDU5vEEYz0n/28XkqtJMloDQ1PhLBCTm59DuGaVGk730OSSELdlLbUDo0PlpE3k2Ik3Fw= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 14:11:54.2110 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a42f1958-88e1-4851-3d07-08dd2f253d35 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: SJ1PEPF00001CE9.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7367 This is the second step to find the port's decoder with address translation enabled. The translated HPA range must be used to find a decoder. The port's HPA range is determined by applying address translation when crossing memory domains for the HPA range to each port while traversing the topology from the endpoint up to the port. Introduce a function cxl_find_auto_decoder() that calculates the port's translated address range to determine the corresponding decoder. Use the existing helper function cxl_port_calc_hpa() for HPA range calculation. Signed-off-by: Robert Richter --- drivers/cxl/core/region.c | 63 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 23b86de3d4e7..8d7893878362 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -876,6 +876,66 @@ static int match_auto_decoder(struct device *dev, void *data) return 0; } +static struct device * +cxl_find_auto_decoder(struct cxl_port *port, struct cxl_endpoint_decoder *cxled, + struct cxl_region *cxlr) +{ + struct cxl_port *parent, *iter = cxled_to_port(cxled); + struct cxl_decoder *cxld = &cxled->cxld; + struct range hpa = cxld->hpa_range; + struct cxl_region_ref *rr; + + while (1) { + parent = parent_port_of(iter); + if (!parent) { + dev_warn(&port->dev, + "port not a parent of endpoint decoder %s\n", + dev_name(&cxled->cxld.dev)); + return NULL; + } + + if (!parent->to_hpa) { + iter = parent; + continue; + } + + /* Lower domain decoders are already attached. */ + rr = cxl_rr_load(iter, cxlr); + cxld = rr ? rr->decoder : NULL; + if (!cxld) { + dev_warn(&iter->dev, + "no decoder found for region %s\n", + dev_name(&cxlr->dev)); + return NULL; + } + + /* Check switch decoder range. */ + if (cxld != &cxled->cxld && + !match_auto_decoder(&cxld->dev, &hpa)) { + dev_warn(&iter->dev, + "decoder %s out of range %#llx-%#llx:%#llx-%#llx(%s)\n", + dev_name(&cxld->dev), cxld->hpa_range.start, + cxld->hpa_range.end, hpa.start, hpa.end, + dev_name(&cxled->cxld.dev)); + return NULL; + } + + if (cxl_port_calc_hpa(parent, cxld, &hpa)) + return NULL; + + if (parent == port) + break; + + iter = parent; + } + + dev_dbg(cxld->dev.parent, "%s: range: %#llx-%#llx iw: %d ig: %d\n", + dev_name(&cxld->dev), hpa.start, hpa.end, + cxld->interleave_ways, cxld->interleave_granularity); + + return device_find_child(&port->dev, &hpa, match_auto_decoder); +} + static struct cxl_decoder * cxl_find_decoder_early(struct cxl_port *port, struct cxl_endpoint_decoder *cxled, @@ -887,8 +947,7 @@ cxl_find_decoder_early(struct cxl_port *port, return &cxled->cxld; if (test_bit(CXL_REGION_F_AUTO, &cxlr->flags)) - dev = device_find_child(&port->dev, &cxled->cxld.hpa_range, - match_auto_decoder); + dev = cxl_find_auto_decoder(port, cxled, cxlr); else dev = device_find_child(&port->dev, NULL, match_free_decoder); if (!dev) From patchwork Tue Jan 7 14:10:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13929010 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2040.outbound.protection.outlook.com [40.107.92.40]) (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 7A55A1F9410; Tue, 7 Jan 2025 14:12:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259126; cv=fail; b=O7bUKrHYT3ceC4k8hrx9YTnvtS9nwGSiCotOdkH/Zxx8IiC7N1pRH534K2yodwpb6bDQX/GBQynbeT+v2XJHqW3LPtJnD2xGiZksuIwVCUo/YtF84qkP81kWs6eVuSJPuQKFy2GUxUbK38cqPCdSCoUudroc66FVkVCdKV8FYS4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259126; c=relaxed/simple; bh=p9LBCdQavmzWJ/r3GMF6qDmJZ5gnXuRVEtQL3R5JwHY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LPw1vaGdbm7GygJTYmyuGfofq2vhbtUiBoCJ4bMyuAKRY3/jOurYpBZPWBXYseMWPO1eTcPiKkopjg56LOSS54fCMpZpLsYLzVUGpGiNpMr68wtnkaD55Gck1HU6xyj1LYQljy3bJ1qfTwO0hhuSLMY/x1Jb8x0nOlnxZzfXTDI= 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=iQMCoy6N; arc=fail smtp.client-ip=40.107.92.40 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="iQMCoy6N" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wSDJt9tclKQZtUc2JG4sh5xA0gBsFOSpr4QGOc9LGegZCPzwFLz4M1hwj5P78KiXPxyf6HX3xhkqq5Qe6A4qENCrIx24evl34Smhg6flzVqzMQLkoMM0oxKVzbu46zaNkW4PD64gBfnMeIbpP/858oMCWYoZ3o/PMgBDMiWCroprZATswOAy3wExNbchb//d17oI4N7CHE4hw019wKfr8MRjzxAeEfCWXdpx3TGcVcgduWDivGOMrztlAWsBgf+O8OheZafLAlhfgk78ygN6EG+JZsFn1FzDG7iXErbxbeFUifYP8gOwLGTM9F8lp2rGVZ4W5TmUDvYErjMWvYbj0Q== 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=OD6yd1nSYN2DBTO7TDrpObOgN34VJlx/dEokoA+1UPs=; b=TLAcUx1HQG9jwVHYlrGgtgf5qJp2RkWDHOUCXgxWYUSbbVz8jWY/kgqH0VVZkf43QyajfrenUb0StJ9x/6y7a4XenBIPnQGH/WMi4CZ3R73P/VmFGm+s6/uIvaRzN5XZdzt4jUQ2wZvdYItAmoJptl85ojXBBTk9Q4DIInRHqlaYxNzM+WyJO9Rv+S0o2EUIe2FQNcjnN7Cb6t+F7wwoD2QEdn+L9M75XzN4iMojV3muTaUO+Sq6Al4b26gkh3kd2JDsMK/xm/oEZHWuOAtNDcqXTzlwRT+m77Y0rrqubjBnuKOzUKuGA8pUlhUrLB+5wgsKeNMSdQBQkZ6clF9Qzg== 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=OD6yd1nSYN2DBTO7TDrpObOgN34VJlx/dEokoA+1UPs=; b=iQMCoy6NaLM6FrI5mLZlegYkd0fZzhvedjnFoh1QmAriGoHBXnuh0BT0gvD6Bphywkaj96/OHZWjtLsFugEy3lLb8fwaHJeJmdnZvODD8BxkRvYyTzYadR3ojfemsLZ9GV8gS33s58+4hdi0gLm84jOk9tlaFpnqYcldMdGfpVM= Received: from SJ0PR13CA0165.namprd13.prod.outlook.com (2603:10b6:a03:2c7::20) by CH3PR12MB8581.namprd12.prod.outlook.com (2603:10b6:610:15d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.10; Tue, 7 Jan 2025 14:11:58 +0000 Received: from SJ1PEPF00001CE4.namprd03.prod.outlook.com (2603:10b6:a03:2c7:cafe::e) by SJ0PR13CA0165.outlook.office365.com (2603:10b6:a03:2c7::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8335.10 via Frontend Transport; Tue, 7 Jan 2025 14:11: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 SJ1PEPF00001CE4.mail.protection.outlook.com (10.167.242.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Tue, 7 Jan 2025 14:11:57 +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; Tue, 7 Jan 2025 08:11:54 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Robert Richter Subject: [PATCH v1 21/29] cxl/region: Lock decoders that need address translation Date: Tue, 7 Jan 2025 15:10:07 +0100 Message-ID: <20250107141015.3367194-22-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107141015.3367194-1-rrichter@amd.com> References: <20250107141015.3367194-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ1PEPF00001CE4:EE_|CH3PR12MB8581:EE_ X-MS-Office365-Filtering-Correlation-Id: 1b22c775-b508-4141-fee6-08dd2f253f3f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: RYTxV8QFPcHo4jkZevFgWunVVmQc1WSFsHYnX4+CfS8ITVtG4NBwdOo5SAl4m51ulejMS/s8zLar185SQ3Y95HnIqj5vOOy+uvJYIIx+yYJmjXCVH3/wjeM/K0xTmBuucAPEPHCSepUQja+7F2hQoBveOIyTnyzPw/hWhDgrEOmSDvL0Yf7fQ029vEgeCki0VPsl6N3MnPj1wRTbh+Tk8q3pE4V3TPyTenH7Q4jyLWkF9Pu1Qy+ELemoAaJYoRvRydRZi83xr3fMWOdQ9zWamHr2NW1GCXzzCTky9wANDQO63eCdSLMdyHZ1RKPS2SJOmMbRu6HxTgMo9qEc7b6pGZbJabcNpaHsuYijrBfPjplOnp7lVbs+Sl0+i04AMCQiJc2BvHXjnkrH/GTVkh0jpFe5WTMphMWABSNVxYY4GFYx0la9PJ27aYR8z9PBSd4hqpjSpjV87pwdvteAB3w+jBHwKEclZvptMwxZoqflBM5Yb4OX8v9TLWgRFuE/7cxpWJsPfGdWJT0hje7JYi6wTOx5jHMvo7ILgAra866dzZcs/hvCU6FCLMNVkZT2bmn/Q9zsmAJhuNzdxms8z5XzpthrzEe1I21fK5K5mmDZyg2Ouw83+VEY6iIE7dqiMaq3Dr/epIoCwtReWSwu1l5Yja5WGS8CakEP01WATLyHnm3QYEhdlRsfEKHv8REXNCyVcQ1NhK8j3jRaLI1paYBPKumKnSH7IweVIf08T8WZqdy1+QLLcarHglXsKWRx+20+kWxdQYXn50Syc+lKNqZph242lkJGpewl70lLKl6KneKzgBmSp4dVq6B+yjAQUP4riBgss42cBAGOq15hLZuUbWxrHvQc6CgGgI1Z3v/5YC07FI7M8ejWX9FpteH13jr2y3GHUTrt0BZlXQ8SPY7lm3KCIEtMUfus44RukacO6xjyrxJDogumQyHgIa48vz8vLoSUZLiu+Mtjudgi6VjpnjqC0QKsFsIIhsGjWBSAyWUFpOey9tg+Z1KBHpFkQ20ty4tUq7SEY7Ff3iVHvWH4jNLqyv1en+fYjIMAhWgSWTJs0ZzvBs77IVdhlWXTnH7wXC8y5YulvxAjrgeV6Uo8H4OAocrm2p0VxI/D5KvzRUeg1n7H4E9n6UaX39Jw6Qg8GPG8K5JR2JTtCiuzpmEjA/G969Lrb3kQhcofi9I3aZC0TJVLXyQ+F8cCzqhbivswzHadOLtI9pqu6bECign4uDUuV2rIXipic7Jf0+fbqvvqX2Tei6QI27zyTjDFRMPO12aznc/oKPWa3vlLCC/GsORIyrw1Nl6XXOqHO5FQ0Ujqw0EXldx85F0WxiNAw5zl6LEjQU9UH1o9/eBpk4FQTVvN2ZV+zNUuiBRCn/2sE1BR7bqRwB7fkljI+bxDa4elXrbGT+X+kul4ONlIYEcoGgxA8Ay7WZdxknFMTWwR3Rvshqw5qx6RyOqCd+DNsyCrDw/S9L14pzq/uJNvRyVO3JUC5VIidZJg0J/RCPcxLg4= 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)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 14:11:57.6370 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1b22c775-b508-4141-fee6-08dd2f253f3f 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: SJ1PEPF00001CE4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8581 There is only support to translate from the endpoint to its parent port, but not in the opposite direction from the parent to the endpoint. Thus, the endpoint address range cannot be determined and setup manually. If the parent implements the ->to_hpa() callback and needs address translation, forbit reprogramming of the decoders and lock them. Signed-off-by: Robert Richter --- drivers/cxl/core/region.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 8d7893878362..681c26abc26e 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3353,6 +3353,17 @@ static int cxl_endpoint_initialize(struct cxl_endpoint_decoder *cxled) if (cxl_port_calc_hpa(parent, cxld, &hpa)) return -ENXIO; + /* + * There is only support to translate from the endpoint to its + * parent port, but not in the opposite direction from the + * parent to the endpoint. Thus, the endpoint address range + * cannot be determined and setup manually. If the parent + * implements the ->to_hpa() callback and needs address + * translation, forbit reprogramming of the decoders and lock + * them. + */ + cxld->flags |= CXL_DECODER_F_LOCK; + /* Iterate from endpoint to root_port refining the position */ pos = cxl_port_calc_pos(iter, &hpa, pos); if (pos < 0) From patchwork Tue Jan 7 14:10:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13929011 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2055.outbound.protection.outlook.com [40.107.94.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07C751EE7A8; Tue, 7 Jan 2025 14:12:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259131; cv=fail; b=hJRaGbiaya3sO4/oypDT++zw7c3t7nyEdqOoPEAdsYLxGcsIstR2AR7svRbeRWqfg3KApSXjc9nactjTt5rtKXMs7QQ0dQ04KZ5YK6Ka91VsBXsaIOak4IjfHSdwZ24+bBi533ilhpNJZXhrH0Bq14L+AiGygmjAOnjYbwl/+zI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259131; c=relaxed/simple; bh=X+DieYdriYVGSYpsKWhikTVsPwBNyj7C7guC8LSgnLE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fTYX9/FyPaUHJzCbYIiMvZ4E5hAxcFsvmQ5yKe7VJLJNrFJ1T3XII0akykDVsSHA1Aiz6f+218Nk1+6ZTwq2KeZuUv9ckE4IcDfhDNp/C2cYCftvjr/GVZg1Nd+hjsumfy89DiW2cTZFtOg77IWuvvdXOrorunNbHuEShgeui4w= 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=Raudx93O; arc=fail smtp.client-ip=40.107.94.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Raudx93O" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=x3YCjQUvcfMdDNJQCSFKgOL1fEipapzexYaODlnviVkPiORiYOHJvMcpft3pAuJjqJT205WL/o9SVZyTrXDVnveFpatVp20HO3aifGtPkzmkvop/h+bIuvdOC8G+WjaZxlH0frgz90rmxYovaFsc4VKHwFhc4pwJB1P8L3YM0YILLNWPa3CF6N32eQfF5WBHlkhJ0Fmqmg6dma+ZolRocMMF0piPfH6NLA5j1gVNi8VNhAuhpBfNsyaP1nmXlfMbSvuICp8+1Ch8VF79OWzmsLe5PBmD1FOg+25C1kdiKSUPX1ntc79U1I6tgAQu4Lm/R3nEIQAcaC074HFF8RUuQg== 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=Vl8pz2MxoWjv/4KsxoK38+ZmjZeiEwV9FnJofb5gRzE=; b=puU/qoZObW/UYluxHnsf/cFjDjVTSf2QwHmWOgW5j5TURKZAfvoV4LjCBxDeD6yteUNJ4RQHpZiVWuCOvy8jI6IhIACy4IyQcO9QXtjG9lp0i9v/My7X4FoZyD42xjxWcaQmcBTZoUrwH+mylYVT4WZB8dgphf926pWz49GueUvPQxAGK5rxuQjLWL9ieNtEb9g4Fo95C1NUsFjG2YtZTb0FouSIKAC6NkIX8EU73NqowkLP2gU0Et0YiDi6JuChwCcz6gvl/wWtsB/wcinDzYtCn682r1VZLhTy0RzxkkqyDu5EhvPT/t4ObpGhtE4vdPjFQMzGuW/m+15TLzaRaQ== 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=Vl8pz2MxoWjv/4KsxoK38+ZmjZeiEwV9FnJofb5gRzE=; b=Raudx93OfC6UFTQ0hEFV3syY+e/ff254YLdXRBEu3X+v0VALbnMJQUpQc+YV8z+gwDZQugRIptfTNlDqMWqTpfH3YO3gSXltNsR/qBCPbT7ozarl53FunlU4TvbHluGt1C2uZUIn0crFbwEShdZyfIxspCUeCj4nH8tjPkojVIk= Received: from BY1P220CA0025.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:5c3::12) by DM4PR12MB6134.namprd12.prod.outlook.com (2603:10b6:8:ad::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.16; Tue, 7 Jan 2025 14:12:01 +0000 Received: from SJ1PEPF00001CE9.namprd03.prod.outlook.com (2603:10b6:a03:5c3:cafe::d6) by BY1P220CA0025.outlook.office365.com (2603:10b6:a03:5c3::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8314.18 via Frontend Transport; Tue, 7 Jan 2025 14:12:01 +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 SJ1PEPF00001CE9.mail.protection.outlook.com (10.167.242.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Tue, 7 Jan 2025 14:12:01 +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; Tue, 7 Jan 2025 08:11:57 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Robert Richter Subject: [PATCH v1 22/29] cxl/region: Use translated HPA ranges to create a region Date: Tue, 7 Jan 2025 15:10:08 +0100 Message-ID: <20250107141015.3367194-23-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107141015.3367194-1-rrichter@amd.com> References: <20250107141015.3367194-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ1PEPF00001CE9:EE_|DM4PR12MB6134:EE_ X-MS-Office365-Filtering-Correlation-Id: 4568c495-b854-44ac-ab47-08dd2f254150 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: uFLD1JheIBC9q4n9XLbZU51QsnSOeLNTCQSbcSqNEhYiwMNHD+RCXvE4XCAFLki3CyQdq1ufIZ2HztbrXUEs1cjRNgDI9ATzkvOw5kVblSn40mIcNvROCCG4J88R5CON4WZH/BvV7T+jHTDZVrzXYn0pXMzBVd0yKp9gWNuoRRo7C+x1z5KvpjICazzst3Ncx57KeeYeidPY6NuKgRtL+oz+Ggfmc/IyNW0X8wRbIJqY5Gx5NfKdSowttQwYZTP+S7A9CLgyPhz0B0o9ZUeJu+dlSvv3Z3hYRVesvfs3QLrJvzDLyhTegpjYawIyZbaYjKOo5+57KinG/vwTKcSGEIAqpPM8y+ilaZ4kcjwhy5hTDkpSDOI31JrV7cVL/+h6lFqoUCOas4S31oaooyJmM6/SUSIbj0HqMHY1vZoLIJrb7IkluZtljIURTzql/QMTPrOAUp0t+3zSahotxkl8wAYRl7DWzFfvsqT88yk7rqOWkSKq2qbMMtmX94yqB1zRDvTViF4/oBQNtTbi/32+Jx32x31y/xK4/xEzfgK5pJFH8tz6+AdeqWcnkcpje7Duyybpb8wCkN+vwwPcepliOvN1oKskb3MiwpYnFC2KC6imsTQKcsqiwHOQ5SARm/BPH8ArEMXdQg535+rRGK+Fa9Kp2jQ7aKsqTwkWR/AgJSeBoyZ8MgrfnPM8iw7pX6YZuf93LDXV9qai8WLW/aYBT4ogs4OJtACI/KaE4aNUjbUvPVZS4jygFR+X8MbSdqzLNNh+7twNDmpquDU69FUBlimziKxrXn5uePTgCP7JE9PGRQCPLKJdF5I3AArfpn6lLnWnIzr+17/HF1Db8aaqKWVzld5dA4VNG4f06NdBc7BIA/BQKwFSU2m530UzkJ4NvHyttpQLJSPIppyJBajbGqupsKT5VzDfv5OjxYChQOt7vxqKKBdtCgdeMqAP5vPqlcyMsMFbNDfi/ShpXggBiIRVbZxhyjGZoTDd1erZEYv/TBycw1NlFtXKb5C5sKt7uJ/2UyArmWmWAWd3rfGbTOq3luB7IL3v3u9zrOU4fD6RCpHjhk0Va/WaouhPzAiCGs76cnu8tNdSG/sqRzr3SDaEgt9CXfiFHuMpBzkmAmGc77iLrwLxWO+cIOdTvfimyFxl+P/+cF9KAlRBbUuKl9/Dv2cCmGHY7PMyGyb27AbW1t5FaaD+pSEySZRIKH4vprP8U1PV283GmSm4LtEaf5GHfn8+wDHoTyOkcCiWmYUeLhW9vwYXAl800aYt1ymeTb61xsMWBS52nY7aiqh4g86yAfWPkIPkog0LOtSs53UWjaN6pC5XN1hk0l+z/IdzW2mp1/tSUJZKLeupn6uV9X7h+Uy6jcjfCJix+A1Ch58iLydvLKCr+p2ab5wG0jtL7C6gURqu+EZkWgxOJXJvK//Y1g+qlw1UiStRgYD6py3k5pfA7DZbTFTRKGyYasFDj7ZFYW6j0/HaYi6XfRmMjpODT/ea0A4yRKMjJbOZ8DI= 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)(7416014)(376014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 14:12:01.1017 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4568c495-b854-44ac-ab47-08dd2f254150 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: SJ1PEPF00001CE9.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6134 To create a region, SPA ranges must be used. With address translation the endpoint's HPA range is not the same as the SPA range. Use the previously calculated SPA range instead. Signed-off-by: Robert Richter --- drivers/cxl/core/region.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 681c26abc26e..e218f0be2409 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3424,7 +3424,7 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd, { struct cxl_memdev *cxlmd = cxled_to_memdev(cxled); struct cxl_port *port = cxlrd_to_port(cxlrd); - struct range *hpa = &cxled->cxld.hpa_range; + struct range *spa = &cxled->spa_range; struct cxl_region_params *p; struct cxl_region *cxlr; struct resource *res; @@ -3462,7 +3462,7 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd, goto err; } - *res = DEFINE_RES_MEM_NAMED(hpa->start, range_len(hpa), + *res = DEFINE_RES_MEM_NAMED(spa->start, range_len(spa), dev_name(&cxlr->dev)); rc = insert_resource(cxlrd->res, res); if (rc) { From patchwork Tue Jan 7 14:10:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13929012 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2070.outbound.protection.outlook.com [40.107.237.70]) (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 982FA1F9EB8; Tue, 7 Jan 2025 14:12:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259135; cv=fail; b=NoCbFYvh1z3JBw1AgnoQNvt0Jr4EN9ziMDWcaFZL/alcVoZ3pRDRuMn8Jl/29NwrZF5d6iGkvGOVu6qwO4SIYo71d9zvu8PWUmfDjSyUpIru66+5DiakrZ91faC5yrwSoPHRP9E9YHo/Xw3z1JqERFa+SUvf/0mVdeNedsh674Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259135; c=relaxed/simple; bh=bTpgXzmT9yVfdG4iQvpZmwkXawaYRpbgatOrq/VPMgc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jhcEWUNz1caVBthyJh3mZGb17c9VyFmp0hruyN59q6Uv2782dy7UBLZmnvfO9Kg+2G35Fl35h1vxEZyk2mtefInv5+/5VMDkHG08N4oOQrRQcBLK6OjpmfPHxOVpJA+rnfV2FH99s7GLjP0zYmTKDSjaE8jlWlBzaWyCiIXt9uc= 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=4/EAiAut; arc=fail smtp.client-ip=40.107.237.70 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="4/EAiAut" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qXEtElBEYh7NmAdTbBLNQIi5mG31HHR7t1rRVS4F/2HS6jZXT9MhZMLgt1SzwT15GAU98fki90qPFNfIEGgNoU8LUWZUrOEbU5P748R3ABHwR8Zb1W6NLeCqcyDPHjvWvnPEz1h7eBNbNhpjqf/y9m5Kk0L6xHJEk3pz1paHke56Ven25q14PDQEMEsMmH3CgeXhKlqhTopJ8uGrrK/QSkOPSEHA/oj/sK+McmNyToNfINgmy2PjoT6pdZsWahOFRynC9HWg9popzEg4NbdcFFIpuq4/1FidFBkq17tAzxqdfoYbLLzEvWjwvQ+R31TmRQX2zqEbN19KXcjkWEB8Nw== 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=9ACrIQnX5bQSRPUb3ElQrwGpZqWWsoNyglDHCPBup5w=; b=pldzKkyK6RbtiF0Zyn8Ox1/iZZJRa8SiQdY/+UCEDtDESvTr1EwePuX/AkM40L3EAhegkT7JgCVWAsPc6/3xjDkfn1LDyuOr7tabo4eld9sW6mmYWIHNJ/uOqL72KqsEfj8cDDRHaPlJP3TODEXOY7/Obz47iCdKf/Ff7kqafRQxay+RRNQTW7aoVNivgrX3NOEVJ6/uPCWggegTAZQDpKwOsdVCeHFTaGxDw7CwH+ecXoG+KlwsZi9SOozGGwhN6IBBgzsuRFXM/fAWYKBzfxZNgxn2qmDL6zuBb5OhFfiwl2n7uVmnQICrNRkdinYyI6185SYZOrFgYhG77q6WBQ== 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=9ACrIQnX5bQSRPUb3ElQrwGpZqWWsoNyglDHCPBup5w=; b=4/EAiAutI5V3yaTrbwUAVL32o43y0OfMy5i8KErUYZHcbY0X5hn188I69qlpfKcfBqjf9wfcqxSmb30FJiGwKtuePwhg96cTleuwPyIQOcYTB2bu4Ywa41beDkan92EGhcyNUyORdgmEdQMScnnkmsWV9PhDAWYnhL+Tvle6oqg= Received: from BY1P220CA0024.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:5c3::9) by DS0PR12MB7925.namprd12.prod.outlook.com (2603:10b6:8:14b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.10; Tue, 7 Jan 2025 14:12:05 +0000 Received: from SJ1PEPF00001CE9.namprd03.prod.outlook.com (2603:10b6:a03:5c3:cafe::21) by BY1P220CA0024.outlook.office365.com (2603:10b6:a03:5c3::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8335.10 via Frontend Transport; Tue, 7 Jan 2025 14:12:05 +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 SJ1PEPF00001CE9.mail.protection.outlook.com (10.167.242.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Tue, 7 Jan 2025 14:12:04 +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; Tue, 7 Jan 2025 08:12:01 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Robert Richter Subject: [PATCH v1 23/29] cxl/region: Use root decoders interleaving parameters to create a region Date: Tue, 7 Jan 2025 15:10:09 +0100 Message-ID: <20250107141015.3367194-24-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107141015.3367194-1-rrichter@amd.com> References: <20250107141015.3367194-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ1PEPF00001CE9:EE_|DS0PR12MB7925:EE_ X-MS-Office365-Filtering-Correlation-Id: d4e35746-6bc3-407e-2e82-08dd2f25439b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|1800799024|7416014|376014; X-Microsoft-Antispam-Message-Info: Acl0Cjzn03X21PM2940Pv0obkAp/lo2XAL9lUEfkjuP9IOGyQLOPiDj1q2rJVnfIsBI0hO1dk1x60zkDeK09noqz1mkkoNvFAsS7CI+rt7fjiKT8yP4CPOSqaEz1ApJtwBizUBxaTFex/zsSsqxAUlJqYTD9MZRJumEiW8CwsupjcH54xxPx5AMLjG+Rp4ynHO75H/u7WThcxnqT1eOgFex5kl5RHnsdhU0E53jdtjGwIMR/5jIM0BV821fVcTxAtpmTnFlN+JFs+slDxKqaIPtCAnBjXbpT6pJvAsY7iDxrxKX7MiJqA4OReEuuI8Txiw4YGKOxNo0MYJL1mCslan14lQeQ27h10WO1cGn/Vu7j3DeMSsdnD9xfbFXu5FTrvsSo3+IZAIzyx3T5tzBMNTsG+hjfWwmLJvovtuZwnTzt9FRrWXCs8/O5CG20TuEqdFLSo0aqxgGKSL7SCCpdt56FgmIYV5LFOEPMjb6ZlMAjdcbCOUw/z75gj0Z2fGLgMKCkyrq7SJjVh3pb1d7vqSbwLS0p7AiYQ852GN+PYM2dSJ24ir4llbh4FmEDpgru7fONy5POJLO6eVByMLSImxVHMuvUgaklqeiOL75FE0ITtUlg1mTpt8/8Usho5pRJg9VNQcl52UFpURGwTO+ZJv66G9fX50NhOBi820gLElaSEakCpuuRYnqeIsPhicWaR6vMlAKT3opdPHR4ytA6P/EbeK5GKI83bcgF5VmX1hixD23gmYt1wwQ4xhp9zT4/L/vHeXa1B9ikD81CLhH87Z7Nubi9juU8nFR451iygFSQMQqg+sM7KTP2tl5N99HYxEpvBnOczlaZgS555wMD4GjBdpIJPCTgnQQvX7OxJD2njpZlYIK6RoJjB7OQb1STmhB9+Ybeb+Mthpz6QkpOkdfoWch8dfY6H3ZCELL8/qQZ0aNiecTxoKDrsV6dn3m2mJP6S4Nx0LC5dFbldHEyM4mauyKQlPQ3D8LwGJZ2s4F5Kb7Cb9eVKEr3GhLd7mtXEF6FS+SnOhm9unVT9CQ28pxVX8amPP63+ZSAmWvNBDHpCHa4oSvh5Vkut8t9rF79C/6g5zrUWinYpgXIlANXSysry79ABjpwpWSvi4UxkTWiJte0NPeEOt15WG6sENe9Up7Pdtt30igvxgzAXGnAD+wd8fX7NxZyP31Bibxbe1ycqSQlt31xh7LS+3rO6WSflWusAbTToyElYZuFoD/W1McMFSlPQH5HptnOnyGzn9vsScyjG7xW2CACM8gtq+LmwHCTQ4kn0KYJROD6DQRfgbTY/JsdVb6iHwpUh9cElD7guv/i1BXp5taSWTzS8MAuvKnfuv/Sib8pfgVVNQbSUp56WWhoKPsYfUSCBi/Zq3K5KHbDakojix6uAPW+YPVHCSHUCcYIvaUZgoC4QKyDaw1P+uQuKzz37y3/DUFGDEvZBcqq7teiFZmB0JEn8jhSxq+7hxh2Oqe7zdA4rOC1rkB04cOpUA5gqNU5Ww2CDx4= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(1800799024)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 14:12:04.9454 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d4e35746-6bc3-407e-2e82-08dd2f25439b 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: SJ1PEPF00001CE9.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7925 Endpoints requiring address translation might not be aware of the system's interleaving configuration. Instead, interleaving can be configured on an upper memory domain (from an endpoint view) and thus is not visible to the endpoint. For region creation this might cause an invalid interleaving config that does not match the CFMWS entries. Use the interleaving configuration of the root decoders to create a region which bases on CFMWS entries. This always matches the system's interleaving configuration and is independent of the underlying memory topology. Signed-off-by: Robert Richter --- drivers/cxl/core/region.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index e218f0be2409..c3322bae05b9 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -3477,8 +3477,8 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd, } p->res = res; - p->interleave_ways = cxled->cxld.interleave_ways; - p->interleave_granularity = cxled->cxld.interleave_granularity; + p->interleave_ways = cxlrd->cxlsd.cxld.interleave_ways; + p->interleave_granularity = cxlrd->cxlsd.cxld.interleave_granularity; p->state = CXL_CONFIG_INTERLEAVE_ACTIVE; rc = sysfs_update_group(&cxlr->dev.kobj, get_cxl_region_target_group()); From patchwork Tue Jan 7 14:10:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13929013 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2045.outbound.protection.outlook.com [40.107.93.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 04B421F9F62; Tue, 7 Jan 2025 14:12:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259139; cv=fail; b=YTBpw11CnTBQGG85Bt+zZUme92S0v9cYBG/m3qvSILyEfLMvCO5wAsBT2jwdA02nSuRk/R3DmT9PMp/GW3lFVMtKkXh3OPQiQPVmBGjjw/q1lL0i6xDy60HCoUQg3GIqkbXv291B1eqJOez2a0YAUjPCRb5psiaUkweVky0rTSE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259139; c=relaxed/simple; bh=1bRgQmNnBd8YlnuEkwby0ggKjyWzPSVrY3rP+h1aYp8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=inHVc5JGVD1Srb1S4Hoo2oGCTzaBWRnzBobhqcxVfKMrq0a0gSbT90+H1Xuu418nKA2Z5RhrXHwPbgZenUA2N2np0VItmOsGDX40AqHx0NtJNVfk+sZemKqpTygK60jYxRRPDQm7P/srwKCR8lv3uKdH46f8+7Pt5e+4egWOMXE= 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=PqozN4Wv; arc=fail smtp.client-ip=40.107.93.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="PqozN4Wv" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pGzr3AHLxE5W59fgb2oxqQ75qzFSEl9O6CMbXZvOxwmosYRSpWBJdh97ZhWgRhzCIcq5GnKPydxuE2ah+ufZtbsGqFPAeq7qw95ENxS8nmqGwfg7F2LMwVCLmyY320awxfeygTOw+jEvBXCnPAqReXv6AwTQj5sIfy0OL390hB23x0i+veOSIz65UXY4Q2e+gFc/g5N6WMUjawOZls4QAfRZqcLYGO9/h7coR00tN7+wVQuQr+kff+GxHGz9THwzSNeLTiDrmVtAjs1ELPVKcAOht3ugFAEOqqAlY4QXoaCV/bx/1Dai8HAo9ou70V0w8+Ia+jUlehhvFa1wjgU66w== 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=eAzuidAJrMfw7DRjezyawEeEkQue7uR7vQtmyTOR2IM=; b=VaUMajbwX0aO6ybGzGDISD6GQQhpXizJzBZv1djllaxkG8jmh3eIbYBdnDeLIS9O3mmKvzraPFkkBZBolx1XtRS8Q5/QGP/yKdPx9e6Yz2Cj20j+GkzQ2INZqEbzrAm7jQhQ98boQ3yNe7RDAjfO+wtiCFu/V5hBJZvusJTmwFIFouR29HgKR6triRfDt6oOZRyTn1L5pBgeHyyXQrEjmfjrM1/DwzIaDyKCTePP19Kn+/gaYy9Kvk/dki6FLUgHVT0hHubIqhxVQHZKekDTFT9uJ4Dot/O0rRiNTWv+4tyC7UWX/3K7KoMBdTiqq6PPc0mMlJ9rlqngH86khvppkQ== 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=eAzuidAJrMfw7DRjezyawEeEkQue7uR7vQtmyTOR2IM=; b=PqozN4WvqN7wm+C8wBBvGf4kJTvqmox6uhh2rXdhHHdhpOT6s/sbSGIc4NMtN3qOcttOHiyQ9tVUcpUQjvc1BFWnzZ1fYa6SmXYoKa1ffOwPa5ssLjsZd42AZG6AkNKZiU1mbwrqTwVAWbnIUBtvJIhoJJyKh0PU36Nz493RiIs= Received: from MW3PR06CA0004.namprd06.prod.outlook.com (2603:10b6:303:2a::9) by LV3PR12MB9409.namprd12.prod.outlook.com (2603:10b6:408:21d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.16; Tue, 7 Jan 2025 14:12:08 +0000 Received: from SJ1PEPF00001CE5.namprd03.prod.outlook.com (2603:10b6:303:2a:cafe::14) by MW3PR06CA0004.outlook.office365.com (2603:10b6:303:2a::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8314.17 via Frontend Transport; Tue, 7 Jan 2025 14:12:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CE5.mail.protection.outlook.com (10.167.242.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Tue, 7 Jan 2025 14:12:08 +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; Tue, 7 Jan 2025 08:12:04 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Robert Richter Subject: [PATCH v1 24/29] cxl/region: Use endpoint's SPA range to check a region Date: Tue, 7 Jan 2025 15:10:10 +0100 Message-ID: <20250107141015.3367194-25-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107141015.3367194-1-rrichter@amd.com> References: <20250107141015.3367194-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ1PEPF00001CE5:EE_|LV3PR12MB9409:EE_ X-MS-Office365-Filtering-Correlation-Id: 3599724e-e87a-4c9d-31c3-08dd2f25458a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: +VpeDWFK0L8VUTMa/RmKpu9zKp8kdlVLIS2gC5Eev3aNbeGWUEoD6P0dHuGFBUGER5oTrJJpDH7CAV1nH7MXXwqyD/LVnjOF5W1AMh9439eW3mRVWabwRhMsspPnF+GnyEI5AtGzRfxUYJrlWLTs3a8mBIBrEAwazcVErQcRCWM02iUMoF825xQ9l40paWe60t74BrUBociK3FzJ6OnxHCC8eAmPXOsirlGgSecij1BpOl/Mx4YbPk8HXUjZC9jQ8LTkwNHj3pgJ8oeMeDaX+8ebLL14omW3NmDU9oGq1a5OCl1P2n5nUb5lRGOtql2jis7sA3ptQzRBtl0b55fOZMpXO0SM3LNGLZlALZsrisDSldOq4YVFQYBk2WVOxH8JJqWXD/59vINaouZk4iXQvI+EmYNrRrkI6L/L2LUqtW18nK/ZJMb6Tot4rvgL06MVcX+CCcBgcOV+9PMbRP8NQcFMEA6ju0MMZzTwffc3YgYSNlJLW33kU4EV4vB/sSInqUxPGBZYcd0Fw9yN9jDMLS8gqEvegtIOqLZdz44wX2SAvdCqrQzQI5RhJ0Rzda2HUU07/n+7vFMtomPNsA70p4S+iOauiVr6BQxfrUYS5drnxM/XTL7thRt0O/cnKONPwJCCzNqXF7Mek4beT0wOhZmkv3ddsFpOAaU81UqnAoQU77IoKazWDdjF1dHjblY5QWRgk5lwMPBbeUBM2lG4KYmRC046AEX3PGrL+skhxSflpK5eHhoIsYV4yifP/oSo/UE9o3dO/b2UU4u1rf0XhWhthxVnklo8USkcK3mOW62Euen3CPxcOTi1gJlrgmjxBuEw8OIzU+hDIU/Xf+0JBptMatMsLLMNIHsf5hDH1aAra1JCgmNcNDkl7agsNzhy1yK9Is3Oo5x/4rdsg6Kxlb+KLH7GMMMkLFn4t1A4EOQK6o4XZHSuO8tFySWi4yclD8NipX2//GP1rl9tj3iCtbzQmetJ0/0CyklXSo5fslS+HhXTNAex4lfIdbDfsRwEjG+Q8VxEgGLn/GG6YCxibo6OL/Wo8J4DhImLp1vZK5JkR4gpY4z+g7KtAxbpeG6c6IPborUhPTcDdZT5WMAQ/9vp4elVCn+lgiCm1Cot54l7CGCdkLV9nktyKYsD64IkGR5n2vAYJFXqMG25NAivJeRtjKDvndPyGB3J/cBkeltEl6/KibbZaGMRNW+/QVX6nXyYVTRM74zgbkzUpyA7ljC782MFJAOp6rpfIVJqbnWS6eh5aIupZJ31HsjDX+btE1exfryw9LjehBiFWEEtIWh98H8sCpMYCSPcPtfgeTzDMjYPKYLy07noczjuDG+gO58VcE4QokZoN+Fp6QTNh6DK9h5cdYMVg9+/U7cjlKE9C51ITa5vG5jnfswVtXCrhtDBdrjWO6gmTAgclgsIbxQ76kGYFqDWG4+2/ZdbZHU1F/rB8Q0BRH1hSEcViEqIFSxBYd4CD1b0sHGyzTt17lZuQt0ZAjhShcxQz29281c= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(7416014)(376014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 14:12:08.1271 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3599724e-e87a-4c9d-31c3-08dd2f25458a 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: SJ1PEPF00001CE5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9409 Endpoints or switches requiring address translation might not be aware of the system's interleaving configuration. Then, the configured endpoint's address range might not match the expected range. In contrast, the SPA range of an endpoint is calculated applying platform specific address translation. That range is correct and can be used to check a region range. Adjust the region range check and use the endpoint's SPA range to check it. Signed-off-by: Robert Richter --- drivers/cxl/core/region.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index c3322bae05b9..1dae7d36d37c 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -1516,22 +1516,26 @@ static int cxl_port_setup_targets(struct cxl_port *port, if (test_bit(CXL_REGION_F_AUTO, &cxlr->flags)) { if (cxld->interleave_ways != iw || cxld->interleave_granularity != ig || - cxld->hpa_range.start != p->res->start || - cxld->hpa_range.end != p->res->end || + cxled->spa_range.start != p->res->start || + cxled->spa_range.end != p->res->end || ((cxld->flags & CXL_DECODER_F_ENABLE) == 0)) { dev_err(&cxlr->dev, "%s:%s %s expected iw: %d ig: %d %pr\n", dev_name(port->uport_dev), dev_name(&port->dev), __func__, iw, ig, p->res); dev_err(&cxlr->dev, - "%s:%s %s got iw: %d ig: %d state: %s %#llx:%#llx\n", + "%s:%s %s got iw: %d ig: %d state: %s %#llx-%#llx:%#llx-%#llx(%s):%#llx-%#llx(%s)\n", dev_name(port->uport_dev), dev_name(&port->dev), __func__, cxld->interleave_ways, cxld->interleave_granularity, (cxld->flags & CXL_DECODER_F_ENABLE) ? "enabled" : "disabled", - cxld->hpa_range.start, cxld->hpa_range.end); + p->res->start, p->res->end, + cxled->spa_range.start, cxled->spa_range.end, + dev_name(&cxled->cxld.dev), + cxld->hpa_range.start, cxld->hpa_range.end, + dev_name(&cxld->dev)); return -ENXIO; } } else { @@ -2051,13 +2055,12 @@ static int cxl_region_attach(struct cxl_region *cxlr, return -ENXIO; } - if (resource_size(cxled->dpa_res) * p->interleave_ways != - resource_size(p->res)) { + if (range_len(&cxled->spa_range) != resource_size(p->res)) { dev_dbg(&cxlr->dev, - "%s:%s: decoder-size-%#llx * ways-%d != region-size-%#llx\n", + "%s:%s: SPA size mismatch: %#llx-%#llx:%#llx-%#llx\n", dev_name(&cxlmd->dev), dev_name(&cxled->cxld.dev), - (u64)resource_size(cxled->dpa_res), p->interleave_ways, - (u64)resource_size(p->res)); + p->res->start, p->res->end, + cxled->spa_range.start, cxled->spa_range.end); return -EINVAL; } From patchwork Tue Jan 7 14:10:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13929014 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2042.outbound.protection.outlook.com [40.107.244.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8C861FA16F; Tue, 7 Jan 2025 14:12:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259143; cv=fail; b=N7Ui2ZF8aAUxOj5tyg/UA6N/LKc2h23j4z9abvEBtO/7pLSCJpvf0yNbKId5GEMHEgpJEsqT4wjm0aWyJqoFAHsMPTzXGJx1eNPzCFHr3gEuiHzqdBAP4d7bn0b+OPmHh7jp3Ta61jNhZY1q65NXhFy39/53CKC7hB0cz2Zvewc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259143; c=relaxed/simple; bh=kjN0O0cUIlFyHd4lfeiO0KE5UmK08ypeWssTVuYSqtI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cfCXBVVYZ9lIkwyLAlnB3ilruAFFqCZkpRYOjBLSnoE6xP0/Bl9Pp8sApkgXM3ieghTfEs530KoVMJz0G4ULe6Yg+eH+vFMCL4B86xhRmuvJ1QAypo5EUPO8dBXXFRL+Zsalmx0fNDZrVpp7H0xTvee0NwPJxsG/IBREIP03pkc= 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=zcVjvsHp; arc=fail smtp.client-ip=40.107.244.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="zcVjvsHp" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eH7xIfdAW0Amx71OAb/7HpQAZzIISJyzv0qT5Dqk8HVlYc20yMXAdoQ2K4yAFKsALChW7km4lAI8aMhAP7+ZXNaKJEJX/b5pe/AWRZn7Xfsrr3U3jRFf+5d35kBWTbfGhiMv5GVd9v6MLAAFaJbdWsGooZLeZwExg75LXL7NXsGCFzlgbxhHltA80j2d52nTtMS9gpeVilzenzc4B1PnoE5QPoGe5pkl7rnaEyItp0jbX2Y3BuV8ZrEHqoljSybwa2uzvDXwhaT+04PYxGX9LKxOXEv19ifriqgOmHZwuWaputJ+dnBiYZeOfGK4pDMC3/sOBdUBt4zf1og3qf4r5g== 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=Y994vWkys0g7zEti2U9zKv+Zm5YNcPqW/j/BZnGvMsQ=; b=Y+UvLbJiOsr2+CuXw1YUewfRtkfknq+zE5cEVQ675yTuVLm2B7tPpvot218htx8u0wGQhwyQeQ+0Yc+i5IlcD1WBuYBXIoEzzYgooWaEO+Yf7pWRNKwPP6A59kMwEkA5sgveg7NBfeCiElwmAC3dp8modC/cItubIUpeOlCbPJBTyeJQIjGwMkcjxIu9q/Ks8obaEpa0UhsH/DyxFb/swd15hj6kTLUHlKw4I4AmvB+Whb7UIApQGJdBugAZCxQEoE0c8+UpaQJUr7Tbzz3y65Tv1meUdaC6b0aNtWQTd2pZG177YHz0J88vGXkR4uQytavzDgVE7wCzPCgCJWl7Lw== 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=Y994vWkys0g7zEti2U9zKv+Zm5YNcPqW/j/BZnGvMsQ=; b=zcVjvsHp9fd2qVWWYyQQHdG9msvrXHocuG2CaDsUKqT/Tw730bSu5SMs/BK7fucW2UVER3/dTgFZLXTQNXUowFe9DzfuSffplH68sn25Wh1XDqDpkT4C7N+P3nHnvpFqDkYQkNQyDM2Q3+V83wHVqpnVswbfXWCYUmtxsnwKODk= Received: from MW3PR06CA0002.namprd06.prod.outlook.com (2603:10b6:303:2a::7) by IA1PR12MB6116.namprd12.prod.outlook.com (2603:10b6:208:3e8::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.16; Tue, 7 Jan 2025 14:12:14 +0000 Received: from SJ1PEPF00001CE5.namprd03.prod.outlook.com (2603:10b6:303:2a:cafe::42) by MW3PR06CA0002.outlook.office365.com (2603:10b6:303:2a::7) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8314.17 via Frontend Transport; Tue, 7 Jan 2025 14:12: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 SJ1PEPF00001CE5.mail.protection.outlook.com (10.167.242.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Tue, 7 Jan 2025 14:12: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; Tue, 7 Jan 2025 08:12:09 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso , Robert Richter , Terry Bowman CC: , , Gregory Price , "Fabio M. De Francesco" Subject: [PATCH v1 25/29] cxl/amd: Enable Zen5 address translation using ACPI PRMT Date: Tue, 7 Jan 2025 15:10:11 +0100 Message-ID: <20250107141015.3367194-26-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107141015.3367194-1-rrichter@amd.com> References: <20250107141015.3367194-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ1PEPF00001CE5:EE_|IA1PR12MB6116:EE_ X-MS-Office365-Filtering-Correlation-Id: 81adc4e5-6f84-4304-e606-08dd2f2548a8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|7416014|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?+2bKWCDAMs3qD5lByz/Ixfgu0Gv6xJ5?= =?utf-8?q?iENAs90Vkx3nufdLfXOTF5jgqQZBrijZDPS2ZtUeViQFg9UFduN/Gz58dZc+ICXX4?= =?utf-8?q?6snbO4FdeeJIAjWUzB1asmiQG8JpmZNV+lX6dsuLU13cMhEqlUQJCZ60/myNkrBj2?= =?utf-8?q?GGyPoNe5hdU+ZYKibDcZmUqBJJusx3VsvjH0RolE4WJlLFqJR4CwKsfL76Rh6qFGK?= =?utf-8?q?2GoMkg0hugFg3LEYBInCns3rzhGvKvQk2O04wre85MVkeMcJOa8Y5kUKVWW9Lv4Vi?= =?utf-8?q?lkepmqgD69BUHNw0URwZpQ7ttFZkj9nyXHbncFQ2vMJnRJw/iN9eC5D/5RcqXamP+?= =?utf-8?q?L4/ndkRgWUgQ5ZsVrCb6qG6PS6WPkhvsIrn1egKSnQArW42oPFQsvxH0Sv21hQkvI?= =?utf-8?q?cUe1A+SMtj6ptAyEOHe0NW5usMeDsoQBLtYiuP1Des75RJU8SDKbbJeS7dNjCZjUe?= =?utf-8?q?PyIPy1ebs4ilO6wnBGAJbA+b2f+2kte3FYS0f8tPk23hpkLZamlmjpoEAANQLeto6?= =?utf-8?q?SHfw/0Iot4YR/xvWQ6c+1UPDx40SJ8emkMQ121bcfrIsMZiB3BQjkncivc7GSUNC3?= =?utf-8?q?8WsErVy4oi/CKfieRuibja4yEDW5v2H2a3JM6hHA7yyKoj93sAkwDeVXNSoR500EO?= =?utf-8?q?x1Cmyf7N/rfZoKmoeO1N4siMdOMEHOEynoAjw1hhv58eKXTIOl21311sbhQ6GPMSR?= =?utf-8?q?MA5Y3v5RTN4oMzvX8bFzUojZG8QN3D2VNcTNsNUPbsQYlbBvIlj5SZGo701/+eCpc?= =?utf-8?q?dx+YbhmJjZqxd7H6f+TkvGqBJHPqIRg2x76J1MOYFZaCN8rWac07UAWqwqQAj+jPW?= =?utf-8?q?LQCPdh2IiaWfd7YCQ1hDj/u7dcMso2Lgo+SOH3Wrmyr1QZUw2t5QVp6YVgbCw8f3D?= =?utf-8?q?IMqO6iSjJnMYYGzS4EzFuoR/TvnFoMw/g9t7xVF7pDAeX8qXVDyj6IW/a3mIFpddL?= =?utf-8?q?gGa940Hk29EgGSsrZRXoW9esj/KP6EHTblYYFmY2FyeUlYu7BaQXofKeofyf9x3MH?= =?utf-8?q?9JAEfIxk+eGw41JGkTKQLKeUzmbBJUfAg/SzeQi5o7H8Eb9SVy8DXpsJDPYD6HVMd?= =?utf-8?q?sL5EN7U5HPOe1SvlhgWsbAAsHrHFNuWR2eZS6ulZ+R0cE/PxFgSPY4DcwVCEogdbY?= =?utf-8?q?IfNUmhK0F6+PqFR17mYcLF1iP37MIpUzxd5PydUohb7h28fqo7Rxd3L4EOEArnsgo?= =?utf-8?q?ma4b+2iKwvnAsjfHRaDsqksVrp+YHg4Bis0qwnRXBC75Q6Vv0YLkXUq21frUYCLHZ?= =?utf-8?q?n5rfBVqve+37MQ4fKh3MZKyWwwVwdhgWEepZdhlUjwVtIPDRXLNse1dgLMIKvXEfe?= =?utf-8?q?Ask8YIxh12ApyzirPSNx1cFKsAIoU/0cf5BjA2Xtft94drB7/GvP7jjKaSBaMT/v9?= =?utf-8?q?aJEU1vIQQynHh5eNo5WtmBMBfnx1HrQlBYVacmuXxG5twvAtHCtZJM=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(7416014)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 14:12:13.4083 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 81adc4e5-6f84-4304-e606-08dd2f2548a8 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: SJ1PEPF00001CE5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6116 Add AMD platform specific Zen5 support for address translation. Zen5 systems may be configured to use 'Normalized addresses'. Then, CXL endpoints use their own physical address space and Host Physical Addresses (HPAs) need address translation from the endpoint to its CXL host bridge. The HPA of a CXL host bridge is equivalent to the System Physical Address (SPA). ACPI Platform Runtime Mechanism (PRM) is used to translate the CXL Device Physical Address (DPA) to its System Physical Address. This is documented in: AMD Family 1Ah Models 00h–0Fh and Models 10h–1Fh ACPI v6.5 Porting Guide, Publication # 58088 https://www.amd.com/en/search/documentation/hub.html Note that DPA and HPA of an endpoint may differ depending on the interleaving configuration. That is, an additional calculation between DPA and HPA is needed. To implement AMD Zen5 address translation the following steps are needed: Introduce the generic function cxl_port_platform_setup() that allows to apply platform specific changes to each port where necessary. Add a function cxl_port_setup_amd() to implement AMD platform specific code. Use Kbuild and Kconfig options respectivly to enable the code depending on architecture and platform options. Create a new file core/amd.c for this. Introduce a function cxl_zen5_init() to handle Zen5 specific enablement. Zen5 platforms are detected using the PCIe vendor and device ID of the corresponding CXL root port. Apply cxl_zen5_to_hpa() as cxl_port->to_hpa() callback to Zen5 CXL host bridges to enable platform specific address translation. Use ACPI PRM DPA to SPA translation to determine an endpoint's interleaving configuration and base address during the early initialization proces. This is used to determine an endpoint's SPA range. Since the PRM translates DPA->SPA, but HPA->SPA is needed, determine the interleaving config and base address of the endpoint first, then calculate the SPA based on the given HPA using the address base. The config can be determined calling the PRM for specific DPAs given. Since the interleaving configuration is still unknown, chose DPAs starting at 0xd20000. This address is factor for all values from 1 to 8 and thus valid for all possible interleaving configuration. The resulting SPAs are used to calculate interleaving paramters and the SPA base address of the endpoint. The maximum granularity (chunk size) is 16k, minimum is 256. Use the following calculation for a given DPA: ways = hpa_len(SZ_16K) / SZ_16K gran = (hpa_len(SZ_16K) - hpa_len(SZ_16K - SZ_256) - SZ_256) / (ways - 1) pos = (hpa_len(SZ_16K) - ways * SZ_16K) / gran Once the endpoint is attached to a region and its SPA range is know, calling the PRM is no longer needed, the SPA base can be used. Signed-off-by: Robert Richter Reviewed-by: Gregory Price --- drivers/cxl/Kconfig | 4 + drivers/cxl/core/Makefile | 1 + drivers/cxl/core/amd.c | 227 ++++++++++++++++++++++++++++++++++++++ drivers/cxl/core/core.h | 6 + drivers/cxl/core/port.c | 7 ++ 5 files changed, 245 insertions(+) create mode 100644 drivers/cxl/core/amd.c diff --git a/drivers/cxl/Kconfig b/drivers/cxl/Kconfig index 876469e23f7a..e576028dd983 100644 --- a/drivers/cxl/Kconfig +++ b/drivers/cxl/Kconfig @@ -146,4 +146,8 @@ config CXL_REGION_INVALIDATION_TEST If unsure, or if this kernel is meant for production environments, say N. +config CXL_AMD + def_bool y + depends on AMD_NB + endif diff --git a/drivers/cxl/core/Makefile b/drivers/cxl/core/Makefile index 9259bcc6773c..dc368e61d281 100644 --- a/drivers/cxl/core/Makefile +++ b/drivers/cxl/core/Makefile @@ -16,3 +16,4 @@ cxl_core-y += pmu.o cxl_core-y += cdat.o cxl_core-$(CONFIG_TRACING) += trace.o cxl_core-$(CONFIG_CXL_REGION) += region.o +cxl_core-$(CONFIG_CXL_AMD) += amd.o diff --git a/drivers/cxl/core/amd.c b/drivers/cxl/core/amd.c new file mode 100644 index 000000000000..553b7d0caefd --- /dev/null +++ b/drivers/cxl/core/amd.c @@ -0,0 +1,227 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2024 Advanced Micro Devices, Inc. + */ + +#include +#include + +#include "cxlmem.h" +#include "core.h" + +#define PCI_DEVICE_ID_AMD_ZEN5_ROOT 0x153e + +static const struct pci_device_id zen5_root_port_ids[] = { + { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_ZEN5_ROOT) }, + {}, +}; + +static int is_zen5_root_port(struct device *dev, void *unused) +{ + if (!dev_is_pci(dev)) + return 0; + + return !!pci_match_id(zen5_root_port_ids, to_pci_dev(dev)); +} + +static bool is_zen5(struct cxl_port *port) +{ + if (!IS_ENABLED(CONFIG_ACPI_PRMT)) + return false; + + /* To get the CXL root port, find the CXL host bridge first. */ + if (is_cxl_root(port) || + !port->host_bridge || + !is_cxl_root(to_cxl_port(port->dev.parent))) + return false; + + return !!device_for_each_child(port->host_bridge, NULL, + is_zen5_root_port); +} + +/* + * PRM Address Translation - CXL DPA to System Physical Address + * + * Reference: + * + * AMD Family 1Ah Models 00h–0Fh and Models 10h–1Fh + * ACPI v6.5 Porting Guide, Publication # 58088 + */ + +static const guid_t prm_cxl_dpa_spa_guid = + GUID_INIT(0xee41b397, 0x25d4, 0x452c, 0xad, 0x54, 0x48, 0xc6, 0xe3, + 0x48, 0x0b, 0x94); + +struct prm_cxl_dpa_spa_data { + u64 dpa; + u8 reserved; + u8 devfn; + u8 bus; + u8 segment; + void *out; +} __packed; + +static u64 prm_cxl_dpa_spa(struct pci_dev *pci_dev, u64 dpa) +{ + struct prm_cxl_dpa_spa_data data; + u64 spa; + int rc; + + data = (struct prm_cxl_dpa_spa_data) { + .dpa = dpa, + .devfn = pci_dev->devfn, + .bus = pci_dev->bus->number, + .segment = pci_domain_nr(pci_dev->bus), + .out = &spa, + }; + + rc = acpi_call_prm_handler(prm_cxl_dpa_spa_guid, &data); + if (rc) { + pci_dbg(pci_dev, "failed to get SPA for %#llx: %d\n", dpa, rc); + return ULLONG_MAX; + } + + pci_dbg(pci_dev, "PRM address translation: DPA -> SPA: %#llx -> %#llx\n", dpa, spa); + + return spa; +} + +static u64 cxl_zen5_to_hpa(struct cxl_decoder *cxld, u64 hpa) +{ + struct cxl_memdev *cxlmd; + struct pci_dev *pci_dev; + struct cxl_port *port; + u64 dpa, base, spa, spa2, len, len2, offset, granularity; + int ways, pos; + + /* + * Nothing to do if base is non-zero and Normalized Addressing + * is disabled. + */ + if (cxld->hpa_range.start) + return hpa; + + /* Only translate from endpoint to its parent port. */ + if (!is_endpoint_decoder(&cxld->dev)) + return hpa; + + if (hpa > cxld->hpa_range.end) { + dev_dbg(&cxld->dev, "hpa addr %#llx out of range %#llx-%#llx\n", + hpa, cxld->hpa_range.start, cxld->hpa_range.end); + return ULLONG_MAX; + } + + /* + * If the decoder is already attached, the region's base can + * be used. + */ + if (cxld->region) + return cxld->region->params.res->start + hpa; + + port = to_cxl_port(cxld->dev.parent); + cxlmd = port ? to_cxl_memdev(port->uport_dev) : NULL; + if (!port || !dev_is_pci(cxlmd->dev.parent)) { + dev_dbg(&cxld->dev, "No endpoint found: %s, range %#llx-%#llx\n", + dev_name(cxld->dev.parent), cxld->hpa_range.start, + cxld->hpa_range.end); + return ULLONG_MAX; + } + pci_dev = to_pci_dev(cxlmd->dev.parent); + + /* + * The PRM translates DPA->SPA, but we need HPA->SPA. + * Determine the interleaving config first, then calculate the + * DPA. Maximum granularity (chunk size) is 16k, minimum is + * 256. Calculated with: + * + * ways = hpa_len(SZ_16K) / SZ_16K + * gran = (hpa_len(SZ_16K) - hpa_len(SZ_16K - SZ_256) - SZ_256) + * / (ways - 1) + * pos = (hpa_len(SZ_16K) - ways * SZ_16K) / gran + */ + + /* + * DPA magic: + * + * Position and granularity are unknown yet, use an always + * valid DPA: + * + * 0xd20000 = 13762560 = 16k * 2 * 3 * 2 * 5 * 7 * 2 + * + * It is divisible by all positions 1 to 8. The DPA is valid + * for all positions and granularities. + */ +#define DPA_MAGIC 0xd20000 + base = prm_cxl_dpa_spa(pci_dev, DPA_MAGIC); + spa = prm_cxl_dpa_spa(pci_dev, DPA_MAGIC + SZ_16K); + spa2 = prm_cxl_dpa_spa(pci_dev, DPA_MAGIC + SZ_16K - SZ_256); + + /* Includes checks to avoid div by zero */ + if (!base || base == ULLONG_MAX || spa == ULLONG_MAX || + spa2 == ULLONG_MAX || spa < base + SZ_16K || spa2 <= base || + (spa > base + SZ_16K && spa - spa2 < SZ_256 * 2)) { + dev_dbg(&cxld->dev, "Error translating HPA: base %#llx, spa %#llx, spa2 %#llx\n", + base, spa, spa2); + return ULLONG_MAX; + } + + len = spa - base; + len2 = spa2 - base; + + /* offset = pos * granularity */ + if (len == SZ_16K && len2 == SZ_16K - SZ_256) { + ways = 1; + offset = 0; + granularity = 0; + pos = 0; + } else { + ways = len / SZ_16K; + offset = spa & (SZ_16K - 1); + granularity = (len - len2 - SZ_256) / (ways - 1); + pos = offset / granularity; + } + + base = base - DPA_MAGIC * ways - pos * granularity; + spa = base + hpa; + + /* + * Check SPA using a PRM call for the closest DPA calculated + * for the HPA. If the HPA matches a different interleaving + * position other than the decoder's, determine its offset to + * adjust the SPA. + */ + + dpa = (hpa & ~(granularity * ways - 1)) / ways + + (hpa & (granularity - 1)); + offset = hpa & (granularity * ways - 1) & ~(granularity - 1); + offset -= pos * granularity; + spa2 = prm_cxl_dpa_spa(pci_dev, dpa) + offset; + + dev_dbg(&cxld->dev, + "address mapping found for %s (dpa -> hpa -> spa): %#llx -> %#llx -> %#llx base: %#llx ways: %d pos: %d granularity: %llu\n", + pci_name(pci_dev), dpa, hpa, spa, base, ways, pos, granularity); + + if (spa != spa2) { + dev_dbg(&cxld->dev, "SPA calculation failed: %#llx:%#llx\n", + spa, spa2); + return ULLONG_MAX; + } + + return spa; +} + +static void cxl_zen5_init(struct cxl_port *port) +{ + if (!is_zen5(port)) + return; + + port->to_hpa = cxl_zen5_to_hpa; + + dev_dbg(port->host_bridge, "PRM address translation enabled for %s.\n", + dev_name(&port->dev)); +} + +void cxl_port_setup_amd(struct cxl_port *port) +{ + cxl_zen5_init(port); +} diff --git a/drivers/cxl/core/core.h b/drivers/cxl/core/core.h index 800466f96a68..efe34ae6943e 100644 --- a/drivers/cxl/core/core.h +++ b/drivers/cxl/core/core.h @@ -115,4 +115,10 @@ bool cxl_need_node_perf_attrs_update(int nid); int cxl_port_get_switch_dport_bandwidth(struct cxl_port *port, struct access_coordinate *c); +#ifdef CONFIG_CXL_AMD +void cxl_port_setup_amd(struct cxl_port *port); +#else +static inline void cxl_port_setup_amd(struct cxl_port *port) {}; +#endif + #endif /* __CXL_CORE_H__ */ diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 901555bf4b73..c8176265c15c 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -831,6 +831,11 @@ static void cxl_debugfs_create_dport_dir(struct cxl_dport *dport) &cxl_einj_inject_fops); } +static void cxl_port_platform_setup(struct cxl_port *port) +{ + cxl_port_setup_amd(port); +} + static int cxl_port_add(struct cxl_port *port, resource_size_t component_reg_phys, struct cxl_dport *parent_dport) @@ -868,6 +873,8 @@ static int cxl_port_add(struct cxl_port *port, return rc; } + cxl_port_platform_setup(port); + rc = device_add(dev); if (rc) return rc; From patchwork Tue Jan 7 14:10:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13929016 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2072.outbound.protection.outlook.com [40.107.236.72]) (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 593681F239A; Tue, 7 Jan 2025 14:12:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259147; cv=fail; b=qUgs6WaMGIH/FxoxLhfaYipcq3OYAKiypxE8SJ8rEpAGOOms27j7Uy7pwP+b4Z7TdsllKhJRjzQuvgxjynWFXm452D+s7fvS5/exAPRm0VbppeojHO1TR6AeS4Rp5WZ9tstT8rgZhHayPHVdgeiwuVDEy5AVr+bSUFeVfRdjg0s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259147; c=relaxed/simple; bh=Y8XUqli4PCwPiMfhS4fBrcAbRCM9gjg3e+km+xUfNu8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uY5vUmtIpKwZOv8vj2m9b6FT3Ycm1GDwj9LHLUOtXi+R9q+y/02PMOz/mQJBd6kuuuSoNwbEeBmM+nbV9W3BukTHR4XRtUiW2W6O/wNwouo4EKtoWPWq+RBwX5CqqQwcGGjtxasyNVGYTLgFJ4ZdS2xDg0r6vQwpr4RQXLcU6jE= 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=Vswb4Zyl; arc=fail smtp.client-ip=40.107.236.72 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="Vswb4Zyl" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ybDkh7EMxMPv0XjbaE33ayP5I/WmUqzbNvSs6qCrqbNaf6T3VYjBfMG6sjdvthi6nX56Wq6etDNDRr0by2aZiDEXlrjT1sJWQWw3Wweobv2/3KX7A2DymLkKGSStWTG6LXPzVGJN998EjU6AcYw3nK7W8uB/9Epzg6Twro1Qu9LLXOCYtinkA7urQZTy0XkIht8p9DOqq1DApP5kJwjXNmiH/7sQYlVI1eyCs/8Mbl6dfbUvmU5czRgYKWd2iuYSrs6AiekmvrL/o12joslKOvNO4aQgNlbvxGoMIBOmMpcPrezQ6PMKICN9+96MQ523GuNWSrVml5obOoLiDQPzcw== 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=AVloCcpSzCrE0aWSgqgROV7rVJsnrKLA1LX0aJiD1xU=; b=rVkRa0BLJEaCR9iWcBAY9o6lnFCMiZpOQ4TWWMd9MG/ebfUT1vK2YQZLKJp8116p5EqtdAM8gk3+Wmb2vRuSqO6NJrMNAF7bck6i+4F4fqbcmS8twXYJqCz5WJE9le4HfAoHE9OiOteM3R7cPcJxXGGNAUUtWIaikbKct1FxfXhzm8cY7wvHc9zidkMaecLelCD0pGt+LPT+J5HRHEAIv8liS0mC8QmiUUPRpyr3o/hwM8AM3P67EsIDlMGwBj4AUKQxxum19vDD0MKHIP6FIN5i6xOVHEajdmv42ldiqT94yh9JzJqbI6aR1TU/jtVt1Y6ZKlxLwRe1sheJOJj1MA== 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=AVloCcpSzCrE0aWSgqgROV7rVJsnrKLA1LX0aJiD1xU=; b=Vswb4ZylxDv6G2KvMEuF09b+Co/ggERBWRoW9nNrVdQcZLBGbIG9PGzA2eFTE9X00MwaGsJMIZ+P9InokoMxdgjwCHq0OzU8fqMsoanv49sy4NQjj1vCg0z6H6x2rjyi8HYYOKGS6ERfJM5IwpyM9meIwG9UwvWhMFrIQYryOxU= Received: from MW3PR06CA0028.namprd06.prod.outlook.com (2603:10b6:303:2a::33) by BL3PR12MB6523.namprd12.prod.outlook.com (2603:10b6:208:3bf::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.18; Tue, 7 Jan 2025 14:12:17 +0000 Received: from SJ1PEPF00001CE5.namprd03.prod.outlook.com (2603:10b6:303:2a:cafe::a1) by MW3PR06CA0028.outlook.office365.com (2603:10b6:303:2a::33) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8335.10 via Frontend Transport; Tue, 7 Jan 2025 14:12:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CE5.mail.protection.outlook.com (10.167.242.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Tue, 7 Jan 2025 14:12:16 +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; Tue, 7 Jan 2025 08:12:13 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Robert Richter Subject: [PATCH v1 26/29] MAINTAINERS: CXL: Add entry for AMD platform support (CXL_AMD) Date: Tue, 7 Jan 2025 15:10:12 +0100 Message-ID: <20250107141015.3367194-27-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107141015.3367194-1-rrichter@amd.com> References: <20250107141015.3367194-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ1PEPF00001CE5:EE_|BL3PR12MB6523:EE_ X-MS-Office365-Filtering-Correlation-Id: 4251a331-b920-4d6a-a9a5-08dd2f254a72 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|7416014|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: 3rgvrc1TQ9mnxATFW6SmMXTxxKrc3rhKlX90/Z9HP7YTOFdwsJalxRY7U8n1Xg6eFltOX92fDJZ/Pa7I9sV7hM0aqN4C6P+2APgsnSeEc2jd1jLiyscR6Plll7kOKNEvhUUKWfIMxkepToFveGFuK5IDo3aJdxcAj3cepM8fPeRmC7ZEL2AR+axxJPv6bF4b7o3+9NuoSatX5yTJfDuaBl1OY03NTA4EG6D15S+y6mF6N3ZXi/EudEd4Z8ywOOnqvQYrXbTK48vluwThC0mmb/MSPVMuYsVjf/0w1qiIjVsT58yYzvS6rVLRaEQZh/ht2WUjdpQb+qQJZ8F68iSrRdtiZZ52i2zXQNpxm/o8jWda0f2DVZH8jHhnoKilXB70kkxac2oaE50R2OjT5bbwWAlIqzhNuKE+An7HoWTSGwdH3vZRyJCSmdxpYtgFhjJosamGVAs/usGrINz8VYLqUq4SPfKeewhlVzI72EZNQsGWCmx2GlTAodUf/ESiZD4Yy6GlsRytr8ZfYkVhc0CiFSoMtTM90nNLsZu1dNjYrhkYNwpMm+Lk4jo73b6OwbjqViAto+82dKj3n+yxHRuwMYRV9+WpjMFgAb51E5hk7ixB6UClY2h2Dmb+B2JUxHw0JaYXbV5YBrhiKM/J9HqK0LIzS3Nuo5S2gTCm3pv3D+1cHBgsuce0RbiqERgSn6B0FLM0mObl5OVmJadvVbSm4mz8bd3QoTvekGA5yuTVOdeU4wHy+eTQwtGzcvm91DU+WcZPssSyFP+RwItr5mfUKhsFNcPtF2kRv0UBuPyZtkVj/Gvi6JDeSBv9bepNpRt/mGsqw9+tu4NlexNFzWYhcw46UV7T3elHJoOY7pikYacei0aQFSf7vf4JljyDth1YmxDj+g8Bk4a/VeRHy4d62faRkSwYVmXeVDc2q/8gH5Q6qk/tUO8ppsOmY+VybMNjUApRHgZPvSKJsLU4GZ6SDjXEkRKaQOs0i53bCPRFj9T1YK/aB7uJUPgkrS72Sd8AyDwZnD7T5epQ3U5ZxOHvz4VqdSKwNxQH0e2IlFgcqrfVgrJeftSguIhJtTR/mCGyymI+vEgGrYIom3WqtfPBvIb3aTCr2wevPK3AjeVfM4jyomCCv2lsTDsgkcdINXW/v4ppGybyOFm/iYohMyhbguRCqtxF6eItirev6kfjStIrl3eaHz5CX+5MM3oW0VHfDrvdXBdmAaaIRTwFIeBaexSL7arHQelScFAykJKgwhzbxZmQ2fZuBPWcxgmPsDf8iWmH6K9pxEXf6DMr2y6/D8g+T8LKwR9p/BM9qCSUMNRgN/m8erAWoDhZSTM8IFvVSFy670zXrsskOFmwnaLvMAfiaIYDlZPiU8IGZcNfw1KH4p9O/9P7G0LA0QAxmlz4yubW8K97j1Da3555cWUBD+pMa60d0hxUZjbwSz64nJTRQ3cfbrrIiOkbn+mVcXXwhejmP3WU8/BlyWfM9ZxzliSdL553x5yrnoi8P59LefY= 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)(7416014)(376014)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 14:12:16.4083 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4251a331-b920-4d6a-a9a5-08dd2f254a72 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: SJ1PEPF00001CE5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB6523 Adding a maintainer's entry for AMD platform specific CXL support. Cc: Terry Bowman Signed-off-by: Robert Richter --- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 910305c11e8a..13791005995e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -5778,6 +5778,13 @@ F: include/cxl/ F: include/uapi/linux/cxl_mem.h F: tools/testing/cxl/ +COMPUTE EXPRESS LINK - AMD (CXL_AMD) +M: Robert Richter +M: Terry Bowman +L: linux-cxl@vger.kernel.org +S: Maintained +F: drivers/cxl/core/amd.c + COMPUTE EXPRESS LINK PMU (CPMU) M: Jonathan Cameron L: linux-cxl@vger.kernel.org From patchwork Tue Jan 7 14:10:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13929015 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2049.outbound.protection.outlook.com [40.107.223.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 715801FA25F; Tue, 7 Jan 2025 14:12:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259146; cv=fail; b=Rw2wFbchU556JWlJCOo3vG0Q6V6PvVX9hHhEcqIQoFfe8KYMoeJIFoisnu9p8Z7sW8ynb/h59ZbHAgYX1IAlUVqG5Kt4tGHm6BeuAErHx3qG1qUZGe9LekFCOvV2ejyrQp1y5jWdCcAdbwzu8FjYVlBgcOEwdT8eq6/VLl5kWRw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259146; c=relaxed/simple; bh=0XwhWY3qxYnX9MTP3WL/usVaznhNRz09UNtcnLZxXHY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cex/8C2jbMauSgJzcBwu4XgmRUiLqzaCfcLxHiNa2K6R+B9EDygER0ILTwRR2yy8Q599OKU+fwWSd+tmWq0UcfYaypQaSI9i4Z8tbTspxcoLHX0Jw5l6h2Fvo10kZEZjTRNsnMlWxhSolsDhYFECwZD1cIHC+esytarCuR05NUw= 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=tHeHc9FV; arc=fail smtp.client-ip=40.107.223.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="tHeHc9FV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qCkgfvyHxpsAyHUSNaL1WjFFIZ47b5KUgmnkXd8iB/WfnxiDMZx28DFXsGd6d4sJsUdfdzbwJUHvlVdf8+GItoxc7ag2TRPq0ZCz6sUz5ffY8o5AszgwZIHLOftsU0Y2mmxDOqiymwriK6yPTdUkA8hAF3HCm4bt7IoHHKk9O3l3cExQkEQHUxQnQoJxUUrCTR2hSZxu9uq/3Pe1gsSwUBB4/JCHEYnhiNg8gVgpODDANk0XxVmNFdgiclbVCzLPoelhHSuGLVX3C1WgZHVi4uofM+hoP+SfyTeJWFCOGrWIdjJWHrBdUjBOvwb5h+0CWwFmefkY07YAEKrn5mLZ2w== 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=4Au3GOQ2k/hUYkvWG3AzsQoE4pMGOhp+COxtWTBaXwA=; b=s37XL03skGCP0UWrw5QgIsP9HgH5t48+i9DyAnQDiSXM4Z9Ve0ACeRUXx7kfDpk8HOQSp83Yg4WQApiwwyMeGBAXmL66BnwARmz9SHX920UC+zt/s26oCBHDkKBk2Vl3Ng5+1g4VpOF+xkqkHYjgOj/qq9vRXuChxJwXKA6kFJaid6yELq4IABpQnbSV9oO0CAkJ36RuQvUCHjErtpltlgBuUndUvDEaXRrFjyDsqHVmkjRVI9V5cnXqpfjVXV7lKLaYnR/Sq/p/pjL84hIa7djd/eJ/PYiU5s41poRz90dHv+yLtfLzYlZPsbl3kgS7vn0djQ3w2Lzkq/ebleZa3Q== 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=4Au3GOQ2k/hUYkvWG3AzsQoE4pMGOhp+COxtWTBaXwA=; b=tHeHc9FVFmfM54tvEo7GiMhFfASpNDLtMBKNgAB0FUvLoNShVbHhmb2zt44779mne/5ic+/ThiSMyQkGGce4U+dLlvMQz0ntMOlVNCzAWNi4gr6S8lXXcHIXR5DUHqTf4xq6TjimPxWbSxyXy4R3ZWJh4ta++Xbv6nqTVuj0KxM= Received: from MW3PR06CA0015.namprd06.prod.outlook.com (2603:10b6:303:2a::20) by DM6PR12MB4404.namprd12.prod.outlook.com (2603:10b6:5:2a7::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.10; Tue, 7 Jan 2025 14:12:20 +0000 Received: from SJ1PEPF00001CE5.namprd03.prod.outlook.com (2603:10b6:303:2a:cafe::32) by MW3PR06CA0015.outlook.office365.com (2603:10b6:303:2a::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8314.17 via Frontend Transport; Tue, 7 Jan 2025 14:12:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CE5.mail.protection.outlook.com (10.167.242.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Tue, 7 Jan 2025 14:12:20 +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; Tue, 7 Jan 2025 08:12:16 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Robert Richter Subject: [PATCH v1 27/29] cxl/region: Show message on registration failure Date: Tue, 7 Jan 2025 15:10:13 +0100 Message-ID: <20250107141015.3367194-28-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107141015.3367194-1-rrichter@amd.com> References: <20250107141015.3367194-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ1PEPF00001CE5:EE_|DM6PR12MB4404:EE_ X-MS-Office365-Filtering-Correlation-Id: eb654305-b5a2-4e8b-a46b-08dd2f254c94 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|7416014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: oJEbxCXe4omcODrPz+bGQrnP+wt3qiCgZejQPyAvsgVAXXCoGsi3WHEV1UbVBPauD3CbRYf83thGqXvUI2khCiFPrAWh4nNp/+3dm+KddC+JUjIXzsLjDXeIolxLYEvAIYAx1DMzdiIS+QPLnHXJ2ty6y1hcibEulNZh6Kque2/A3TFc0hkXXk2ZqBQS/Q1hSIMiqAhILtB1TAGeOXMj3wRAkZQp6rnlNbS7TSgBdv8NMAU9VQKT/ZshrCRISkcXEwBjPsFpGQVbH5AChQCPX22wR6tVoRc8ZK52UhxW4TD+wcAq1y2sl7Ip8f+2QlWpMtjd5rmHPhMOgByQvM8DR0V+pljZp/ckhOsXflgg8z1yDpRA3S/+UMg1Y3fYUy8xUObSbZ+VmwK0yI55/dK26yG3K+z9NjGnPfmyOfmDfll+o6/MFSLqifthaxDv6FHPgayCDnAhGUbR0NHd0ix0t769C/ZUsAMAaCjqFVLXNXmomyjdj4GNdNY+7hcp+lJf6L676q19Ie50Hqu5EPW56QGiobaUmBuDO/AGOXCTv/LF0tf1ppAjqCcllPBleIvw2SywaAm5j2R0Qt/Vzg5VEvk1M8RAlyVrggdXyU5n3nc/4ady0mGUkRwRysffYVMZiMwExQ8bjM+hgDzlRcO0jeTgiD6yeJ0cNNFWwKvkVSy24+B7yZbPmYUC+2FfPDViJMGhIGkAONZu+/xaBlfcbYCoyhtB0KDOk1zLlmi3t0L1VbZtopx46+IgsrlPTXMqhsMHpbhtF3Fr7NYPHILdGmkTWEM7AiELmHMIT1jk9zRLZ6VaIQ20XQMRRrFmmlgBlV5dl3Zm+qrZMsax9AZ2auWwlzfryEnS5M25Qur/jRZDfgv4VUVdj0PTB47avlQ7tzXOtFs2TacsLR7IdtcPNmOzjYW24LNftTa4A8RcOkqwOk6UEb9/R28BcqEMqlMtFXlJ+7CaaSBP73ImrkjS4yCabkQztMhhhQIRJDnKdKPT4E6Wd7DdyPydY/inKN8fqsAHdKb4jmkDYCEOVh2/JV+aDLzorS5vU0bLBw1bAvLppFb4Xh7pN4lXi5CPRVQ6kKAOsv1OaHgtV5985m7b/hS6NuOEwdJzyRDvIlJw8IwZC4IQhI8osDVIhQmOouqUKxmKsWQITbtLqNgaWprgAKmczDDMOI7/0KavBO+g1k8HW2jIf2rBvaJx1IrLIP/GENUueHAJkFMGAk+G1FgAikLcrqfDmnbFXQmgOQ4f4HoISDUurh3ak/U7I4AYahgXr/5fno+rafIMMKNvCpgf8bZHGgg39SnotnMEkKAu6lJgfGtyUDLoiSMxB56thF+vJhTtbMJbhjdZhBdWwJJWptUe3fC1msxPDmvvIEF186tNaiIzEoeW4O4UjT/1ncI7IayH2WEGDVbVwzTzCH4hAulY6qxub5XUiBBmCz3/h33ERyXsxrsvzMRzkP3JsbWioxQWaHkLD9idP+OvdjRLzYP/V40xQYzVccARskjKHw0= 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)(1800799024)(7416014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 14:12:20.0021 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eb654305-b5a2-4e8b-a46b-08dd2f254c94 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: SJ1PEPF00001CE5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4404 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. Signed-off-by: Robert Richter Reviewed-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 1dae7d36d37c..775450a1a887 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -2240,6 +2240,12 @@ static int attach_target(struct cxl_region *cxlr, rc = 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; } From patchwork Tue Jan 7 14:10:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13929017 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2065.outbound.protection.outlook.com [40.107.93.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 945DB1FA8D6; Tue, 7 Jan 2025 14:12:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259150; cv=fail; b=Uu83nhyjoGlEBsIG/OhaUPVkoZnnNZvC7y84EAG4BzALUh2BXZwLqfcOqafgjCBAeQj3hMCii+6nv5f7+i5w57CDTw+hMDaMeX9whZImyJHwVRrLoGIU0dPrvbq0F9eIFD2XAbOSbKpWLh6s8dJy9+gOd5PFxfs2ATIcsYfTK/M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259150; c=relaxed/simple; bh=ltVSZYUDqOErKixLI2njqZZBhN7B+3pbLc16BsWMwMw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=brlB+gkKyOy3uYcYu20ojFektPp+KhTd4y4Au9hZ0awGRuDGCunEhgrWkZ1HmxIqImDUaVWXg6kIM+s9fTwzyM55xrbBGrlYjbhhvc1unofQf+6FnecPGxTAG3PA58ZfRUHGXRGYxvA9XeIZS9a7xp5blHL/Xs3XI/0ymCyvD00= 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=khb37MtL; arc=fail smtp.client-ip=40.107.93.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="khb37MtL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=M8bVXK1HV3yeOurXXy8rDiPRGNS0hr4SXOu5mEp3t+jmoLy22AXpSo1SJl2bN3+MbpTX7AHhY8eSmajV2mnuo3yT+5IVnphhf7DR6KXoRpxZAWBAddKcw1QZg/mhdj8jWgiCvgewNDHYbxFtySpV45kOHrFdX0U5zsvhUVTfp5wUxXSwOPQW5XmuuVXj/ahIK15lPtBQF/l3p70Db2GP4YY2w8wVTbXVCa92SS9sYJEW9UxpO4dMylhzCt+GbTaWl2OM9gJa2Dar6DX9mgFL+wrvzdc+vYvJirR8zwm5S+2D6XW8PHdrXlpQp4niZJUrFSvC3en7pnPLMxhsd557/Q== 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=+HI9n9xk2m2ulDe51PEdczSAoHXXWNMV77nPNnvzblE=; b=cC2L2xSltWYj800XXiwYUOKuOl8IgdQzNCOzeAsdAmFGFiqs5kLAaffWhieRQPyWo7j9kKyoq7aJ6/QPNLJomXZOLrImG3FXNi0rPMYF/q9qbXEJgm2sB5DIwsayzbIJ0edMl4+D8vFNnnKcnPFO60Yx+lhmnKjgQe62EA3X6PWN0vtzF6tht68fnuvxjq1jh+/x6NOXAT6HNDfh7i/HkAwEn22hmQhipsRol3l9ppYRqwfVeoPawirG9SIu/W5U8TV9zOvt9mh/L8YdpxvtLrOQ4jw3xUJKiTqQj+9w79zIu3CVDDdOAzklMSgcpkpXYhBNY7/j8Ec0tCHLZs4ezQ== 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=+HI9n9xk2m2ulDe51PEdczSAoHXXWNMV77nPNnvzblE=; b=khb37MtL/S6qfU1rEr9epcx7nHu63h7oP3JsLKcqEPohbx5dd4J+VgCRA4QCO3urSJsh3ACqg1tYPJopRIxmnhKtDv3gyc15FaSYfO+VZ/Y69VVsM9+WxiT5LAU40ujz4pcgDTc62GZMVvJyW0U9jzighnINQ/Wcf0PaRBgE/C8= Received: from MW4PR03CA0164.namprd03.prod.outlook.com (2603:10b6:303:8d::19) by CY8PR12MB7636.namprd12.prod.outlook.com (2603:10b6:930:9f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.10; Tue, 7 Jan 2025 14:12:24 +0000 Received: from SJ1PEPF00001CEB.namprd03.prod.outlook.com (2603:10b6:303:8d:cafe::3) by MW4PR03CA0164.outlook.office365.com (2603:10b6:303:8d::19) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8314.18 via Frontend Transport; Tue, 7 Jan 2025 14:12:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF00001CEB.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Tue, 7 Jan 2025 14:12:23 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 7 Jan 2025 08:12:20 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Robert Richter Subject: [PATCH v1 28/29] cxl/region: Show message on broken target list Date: Tue, 7 Jan 2025 15:10:14 +0100 Message-ID: <20250107141015.3367194-29-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107141015.3367194-1-rrichter@amd.com> References: <20250107141015.3367194-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ1PEPF00001CEB:EE_|CY8PR12MB7636:EE_ X-MS-Office365-Filtering-Correlation-Id: 6887323d-3fe7-4b44-689b-08dd2f254ea2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|7416014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: D09noa57KkehBh/xdg3BZtmbwsUgocBtQX/EnOJZCJCJFpZV3SfE1tU6oM/cUlkd8+JFgnsGS/MkazUXYNKtkQGbvvLr9dis5STUyFCNSXcERzDE7mxrdSmPmvMNRXPVB1/e57hejqq1NSgacEbrTrnesYuzL0huDT7x+onaw/1JSn9ILvo6PA0/1ugk4LmVyzQ03HCf/C+mC+38GoHfVHX5SEJqfrtwd98nBacVrX+Cwge7sEJ+E4vgsdy1Ark+lHwklpjcJKh+bJ733ZcYz1Qq9f110ZpmRbQbDc6yTfdA8en5IeRRVN77gcvVbRTvwNGPjkZ9xtK4lQp6/YwwEYkjQie/YRT0BNPqaNwU2iW2mvEUeH6HUKs6ZBcteuTi08ngYcCUFSc2t+hLZDbK+ZuJWLtOoQk7iNLemfE63ZdgeJR0eJGFEz3zjn9sDI/dPGfJlNWm4GAXVa5m7bjDBmHkxaKC/fGX+Jgw2NKCfuvZtas6v8503Rysdvx7flZ966a8rwqlvLfUyk2vpyXPOZIIhg9QxmuctQyVQjJXhLuKB0EtMpRN9ymwhc9AuRwZeGvrW2UP5dvqI4JraGfzwsLMFA/aNK9g4TbozQUqPReU2zP9IgreoV1B10iQD0ydtJix1gxdKDl0t4Lv2Sebi1eapxO1fb4ftg0y2Hov+BVW9irLwz42vJzGLbbj58lgZ5706iuWMWANTZ7zeaDDqBNo2d1mK326LtFlQo8co43QohKavHXNKHNI9vJ0+vL96CnX3fdwvJC+bSkjVjvXaBKun7xY5tGlFD5IvbZ37yRZIBgX2VpzcUlNg4G0OHyzeH0aZEf3tUeISRL8ar5E+U+Oc+x4gfbhZ5Ii4F1sYuXViFEliNRDQyOuSMd0tf+McsMvAc5NsEGU3SEseKSFdL9wHMiuSnQecB9TOJLeujwKVViyhZ66B944DtSBbgRMJoicuijj89nbGXD/0yyBA5DJMP+dfpGJK352FMlMz8rFzSn9Voxp5FA3YJwZNuRNkp2CiJ1Q0PBwXHgePBbte87jjv0Q2oRhgNJmMcD/8kLrFMA6ZxQGh4LUQfvB3IerOeIz9PZfrO8kfbMdP2UaqQTG1weSSDIGQCjYnpHICIEajhDk5k1DNISSAVRWoNY8yZMXcXQbfe8bHRQI1goyqX9LuRPr8XJaxlAhtXu8W4gK/NIhItDvX/iSxwMzYSYDxOUKKoAh/fUfk4ocr4TEbx5+RpQrymjlGtVdKaKJFyw7pKquPHSP/CLHOVNMFPhQSGuBl/kIOCNj27hnRyQQU3spWnvrPZdQyHd4PBWslPtFk/jtWx26lsC5fWHRKCQ4d2tMPGoEEyRzd49rhhGD2Z4Oaix/SyIBTSIDPyV/Fx/eC94Y0/13s0xs4cN8iAuzb5SpxbcQy8fqCuAZCRbd9DleimRMvAU6i3dwukHPrSY+piCWGxJCygy6N+ZTktB70VShY+zVEuB0dOL0WupO2qlDhMgrf7G24Fzq+Azc/AA= 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)(1800799024)(7416014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 14:12:23.4477 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6887323d-3fe7-4b44-689b-08dd2f254ea2 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: SJ1PEPF00001CEB.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7636 Broken target lists are hard to discover as the driver fails at a later initialization stage. Add an error message for this. Signed-off-by: Robert Richter Reviewed-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 775450a1a887..2af3b6c14f46 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -1870,6 +1870,13 @@ static int find_pos_and_ways(struct cxl_port *port, struct range *range, } put_device(dev); + 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; } From patchwork Tue Jan 7 14:10:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13929018 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2062.outbound.protection.outlook.com [40.107.237.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F028C1FBCAD; Tue, 7 Jan 2025 14:12:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259157; cv=fail; b=TtrGYBy1j8kWM1sUgsrLOcLljoVaSrbBHu1KQCEag+Pb0MY+gAIBO9bhHe/zzyqypH7rJufuTF8/RYJOPCLvlvIIrqGiJxTmMI3esUvTasDdlyXZGgZhzLVZo2dNl2kVAf3k7tlcB0im7SXjXRr37yONsZnlaXpel/Pa9rp4tB0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736259157; c=relaxed/simple; bh=sgWMsD99cmtznBWecqRI5uszKEIDKiEhWQHo80Ys7+E=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KZoCf/S/+hookujP3thO/N66pu2PG7WB76cKibU2eslo0VbmOM3Q5tJtYCdLLcSJy8h0i8NJaUb0DPzqsJa3Q/hrpkcdiaHeUD1mFqtVUkVrVZ5rC8iEteSJ7ACWfbFFbdGu+ip9pL5bEVKkfAmpXfnRm34EhnBNl2gYrByDHNE= 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=a/vTlQf/; arc=fail smtp.client-ip=40.107.237.62 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="a/vTlQf/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OBpUOKAlvcMm1oI9h0bniQEhmjW3sGZMgFeLFeM28NwzTCiZYbvemTK95g7kMltLytTXMO4k710k1SgiKCPiLraDSA1WDMjc7+SKaMB2D65J/tw/4JSVf5/5qUXTbcXLQW0BTGc4npVQw8V8c86y5SNBHML5asSwhcHJW1hz1eK0dfwdhRy3eBO3ukofOcUtwN9IUZ7YD379WvEi5rDDxEOaGZG/JQw56yREknZljBVdTnZN5QTiEcF2wwRov2T8TQ6t638tDqIj7zfVF8JfjDx4j2slIXpBR3E5n8xdn9xIJFtIqWuvFg00EAjD0syeo7rYFyrrrxtrj91d+s93tA== 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=EfsVssPsAzfVBpqa6ajs/QG36MX9NcCVxF32NI9lg24=; b=rZa5M2zgOAbVElrwtJHeLMO41AUlZ1o2VT2QSAhFGHhPtXjjnUshnlwVbX+gjY1rPNECCJtfxrQ87+GdNTOJRdLW8VpvCBewpz9fXYrYApKdCfs04IQvWIBFKhTjE+8Ka0ipzi2Ii8iQHGoLdYA8gunPkcrBNwN0nuWxz/oYcOzV/UgyZrbQ76X5hlJBc5Ewo31ctNNoptDFc+I1f6MjMqgTnxjQdQmQBcfujMnwFJLZo8bhg131QrlWxIz+N9ZHJqh8ymLE/T73Tv3HRcXO8FTAnPr1tJHXwprfZBziymmwkd32r77LPmlKdGkMOolnlq9c75qlDee8mCuHIsc6Rg== 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=EfsVssPsAzfVBpqa6ajs/QG36MX9NcCVxF32NI9lg24=; b=a/vTlQf/iEHUwFUN/5h6oRnxzWWvQeqqjXMgA3Fbu2IYZhWGt3dcJHJiwWvCtb3HN0n2k/21Dw5kTG73R10tVgiUoTpXIBfxnOxpPVuYrJihSX9BOSSdjAjV7pQtsrzjflLAXlYR+ETBDcRX2gjrweh77Q9uqqpY3gtBWIJtGbY= Received: from MW4PR04CA0079.namprd04.prod.outlook.com (2603:10b6:303:6b::24) by CYYPR12MB8856.namprd12.prod.outlook.com (2603:10b6:930:c0::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.10; Tue, 7 Jan 2025 14:12:27 +0000 Received: from SJ1PEPF00001CE6.namprd03.prod.outlook.com (2603:10b6:303:6b:cafe::fe) by MW4PR04CA0079.outlook.office365.com (2603:10b6:303:6b::24) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8314.17 via Frontend Transport; Tue, 7 Jan 2025 14:12: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 SJ1PEPF00001CE6.mail.protection.outlook.com (10.167.242.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8335.7 via Frontend Transport; Tue, 7 Jan 2025 14:12:27 +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; Tue, 7 Jan 2025 08:12:23 -0600 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso CC: , , Gregory Price , "Fabio M. De Francesco" , Terry Bowman , Robert Richter Subject: [PATCH v1 29/29] cxl: Show message when a decoder was added to a port Date: Tue, 7 Jan 2025 15:10:15 +0100 Message-ID: <20250107141015.3367194-30-rrichter@amd.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107141015.3367194-1-rrichter@amd.com> References: <20250107141015.3367194-1-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: SJ1PEPF00001CE6:EE_|CYYPR12MB8856:EE_ X-MS-Office365-Filtering-Correlation-Id: cdb8254e-f4b9-4dd3-9649-08dd2f2550cb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|7416014|376014|82310400026; X-Microsoft-Antispam-Message-Info: vcoWKMy9h7y7n+//aooMMaICjlF+O29pA+DQY7rEMZzy5Sfk0AQCoioH1HN4moQdWAQAsGjvnfdQN0e9B9kUCdf+ycVRJGvyOzXKYxb1pTbefnNre5nk1b+vV1rhPXmGI1vLb6ddH3odefJD+xKb3rtmKzDX73xps35bfEytfLbWQMq2kawf2alFUE7MrmKuFFKb6oojuHWkCy2r7WI4Yw1hDkj7KKwtme7OceL3FXGpnLWgsPTzOjnSjmFAFVN0qIXL8QUQMoqOeERIu+0V1NJyzpBHQPOa/UPdT23h8VMtCvHJmoJIjwv3Mm7RHdmQOR5TcngYsy3c61N55by8coBNB/VxraKwmHwfpeXZT00Wpf2SfxiiyBDZjweZsUBNQsgqoiesHHpYBheuLwuJAjaugsKv60W3iMT5SGF+WxQiuK5vApcB2nkOdn1aDowhXNtogmYorcdCrTGib6dRDlsZxaMypm/cyo8y/mEYAq4UnZmohSIGENvNgbPHEKWsdIwDV/ZWYUqxMs0E2+nxyPqtoVM8TiUSaoefmgxjCV0rSmoiS5FIdJWOha2/Cvdt1EmxFkYx7uXkb6G5W/YyD0KXF1flQmLq52nYUesQ30ItdJwrw3PbBQhP04IQPOLLiaS7kuIf1QskWZcE89p1zCE2bQehxil2/A7ozMvyxYkkHnBo6XhXj3si72gYCl46BSOshDKdBLZtIuQQXrh8auvioC/M/eQS3ou/e3TDdIrgbjorPArZdmFnES8R2J7uRFB0KKNchUagTfVnJxfK3cjSatYg7Iakbo1gJO+2jUW0IfSvpxnKN1sJ2SAZCrwacr4Mav4WluSp5eGte8y8wzpaRNYP78ZLpwaFhAl4eA2vWVkO1a93I0EBxCKBwwizpaAXGCxUx9fdK+pTkyofsqWUWz/2sdm+7zD7ixMacri7AkahxkYJwcTDTClSd9u3caSe7Kbdik2qKSWGXuGCjedWUyyPP+4GScmpa3fWsNbYY2/13oktlh7iZPWlW+kyaVx5v0W9DHFSaTT2zKeKPId5X6mEI1Iy2kFN15PGLj2L/5GQD/q3fjec5QCZ0i8QBf+2gSg0ygrvj8QZAZ0h3FdrHSABlsVnlpBsP3eaZHqePQ7CJtXpqAK6TXuFWNJEXoVkVsmQmAOxP5PhtRxu58aTvVxlE2OZWFIPV3zRyOq7Jd5nFPVyCZFNKsVMoNCCbi9y64EqzQugfsIOw6LSHOBcV2Vepmr9asGrW8VZBaHoIzaHi1yBnibxzPL4bw23AExnNUlAVBkgrg/YeoQTtfAhtX0cXzeLpoi9b3s/R2Zx67zkycGxynrbVufB8VJm1PzOy+dhKK3Y2hubV2vq/PMFDDITUank/xYhSUckHmZ2VcDsugGGHH1J7Qn8Jmw8M5T4u2t/Xxm1+yRxxveMY98wEyporvn4QYPJtNQGJTot42td2NR89j28fst/zyS0/tKdQv3LN4KzXyrYqQjmqZst+BbzM5/rfCVHz9A30Xs= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(7416014)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2025 14:12:27.0730 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cdb8254e-f4b9-4dd3-9649-08dd2f2550cb 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: SJ1PEPF00001CE6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR12MB8856 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. Signed-off-by: Robert Richter Reviewed-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 b42cffd6751f..ac74b6f6dad7 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -421,7 +421,15 @@ static int __cxl_parse_cfmws(struct acpi_cedt_cfmws *cfmws, rc = cxl_decoder_add(cxld, target_map); if (rc) return rc; - return cxl_root_decoder_autoremove(dev, no_free_ptr(cxlrd)); + + rc = 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; } 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 28edd5822486..7d6778f908c8 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; - 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)); return 0; }