From patchwork Thu Jun 22 03:51:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13288213 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C564EB64DA for ; Thu, 22 Jun 2023 03:52:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229967AbjFVDwu (ORCPT ); Wed, 21 Jun 2023 23:52:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230081AbjFVDwk (ORCPT ); Wed, 21 Jun 2023 23:52:40 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2064.outbound.protection.outlook.com [40.107.244.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD7E51FE0; Wed, 21 Jun 2023 20:52:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LtkG0gooAB7a2eY7u25GkAWUVmcaC/PdGMdqO/ACkuUVoSaLjjoL137LpMUPz9bAy2bXYBA8EJoTkb2wxf544caOJo76cL4Gm21laOmb+0OIvk1nw8Fdn/cWlhgPC433PLDEa9FLrVqpBqnWPfClmCdLCredV+t6DP3i96xPXgVDGVMmBe/cOO/4mYWImwxKuiXXzQc3l+8M72wxIn37lJGA5s0OIIOnxPY4gin0OPUPcC37DmY5V3IB0HJ63ajbhKKxBIqS/QAyzpX9P95PaMnOnCW+3oMNfMJ1kmkUwEI0/Ks7dc8ttrgjuqiMn0agcGrSYRYZfcvlSzQsugiaDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=5mJVwN//roLFXnM4z7Qf7OWctnklzFk03oD5lVna0qU=; b=V/jp3IxRbRNtwGGPRaFZShR5SGqt+580IL3q+5GNFj4pmscmi8ZlSDPWJpMDYjg5azV5xLStngvMcjN2cF3/wkyTMINQ1Y+uqAk+GP5+bvMlxz9oVUHsOr1a+I52zi0shMMCfRWCi0z3OTXV7vk0920jFTxuSySba2wlskCds8TNP84SdTnW8Y8VnW/qv4pSqZ0lvxNPOkzQs75khteavdBRip+eb4a/gPNUowT+91CIDK6c2AWajy9sN7Kww28haMIwR4F6up0ELKkmT56IXoTmN/waLTAKrupTtZD5OIVtBcHeEjjzBF7fpmShNdGstoCZG0JiUowaIP6IMKurIw== 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 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=5mJVwN//roLFXnM4z7Qf7OWctnklzFk03oD5lVna0qU=; b=bkAJ5lKGSMkzJDpWz8Fw86X3GOBLAYqyEurh++C+JW2oSFCXfneoFSYNVlpNpLA+bcMw1vWpG/ZV/WKBMpaGcbHfJcTedbDPRlBiKnOrF3BsvxEnQu5hYgrDqowXTt/DS2MYXIy6kOQaPJ7FVFwof7IoTb6GXjrLHVjJhT/spf0= Received: from MW2PR16CA0051.namprd16.prod.outlook.com (2603:10b6:907:1::28) by BY5PR12MB4242.namprd12.prod.outlook.com (2603:10b6:a03:203::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.21; Thu, 22 Jun 2023 03:52:32 +0000 Received: from CO1PEPF000042AD.namprd03.prod.outlook.com (2603:10b6:907:1:cafe::6a) by MW2PR16CA0051.outlook.office365.com (2603:10b6:907:1::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23 via Frontend Transport; Thu, 22 Jun 2023 03:52:32 +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 CO1PEPF000042AD.mail.protection.outlook.com (10.167.243.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.17 via Frontend Transport; Thu, 22 Jun 2023 03:52:32 +0000 Received: from ethanolx7ea3host.amd.com (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.23; Wed, 21 Jun 2023 22:52:31 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v6 01/27] cxl/port: Fix NULL pointer access in devm_cxl_add_port() Date: Wed, 21 Jun 2023 22:51:00 -0500 Message-ID: <20230622035126.4130151-2-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622035126.4130151-1-terry.bowman@amd.com> References: <20230622035126.4130151-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: CO1PEPF000042AD:EE_|BY5PR12MB4242:EE_ X-MS-Office365-Filtering-Correlation-Id: 6db536ca-ba78-44ff-7247-08db72d41b7a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Z7ZfV5sn1g88fnYWMorqL1JrVtoGgBn+vHjStBBHP3p9/0yb1cb+QY419Dtrk1lWvPsoVWlioQaWrlkU62jd28xBIoFaj5PpwZEtZtiOSeAv/7mRMtW+UZVHNNr8Wzzu4GDr/CLv2b5YcbCKb8fG7hTFiVxIBulr8jvxWzKrp+Nk7/DtRQvsgGOTZKEtpjosDT8EVWuhXfm/eODQKPn0H3N+wpRsVAlHuU0tymdfJ+Rj8/OFcARY9KX4E2p6MPdBb1KvNpTlgDObp10/C+fYrmu1GTwry5rY0/BD3PCAk6tCkxdkFkoi+TnhwWo4N2uVy4y/EKYyHYAlumXubAcs898ASk1ePPcfneqJl/zRENu6dKRNkFOxPtwlK5ity6Dbn+PXwAUJtzIf3a64lDEQFiF0kbwepF0IEbXheFIJKpr61H7THHgwj8fiC+i4+PXFyMtjbP4FUT1YWUFn4h+lIXirKuFB6yNqIgJN50kMU8V/vK+EC9g5aqdR6BY01f8Lyj8Sd4RGv9yV8CNNYp9opAKg84UlBzGBZITGkFYA+WazngrIm8LG7GRwz4dWG2fqDP0UZCgKuVr4uKd2sgCXbq2ojzenQmDH7eTChrFnzj5JQrGZAqmuL++RLvhlJJbrqw6CNds5oRL3eaDRqNd2CkppJdcRhyPW0AEcxIKRhbRZ4EOf3RUhHWzn/LqaY9FAVRyjEhxHZtNGKA5SHYT3Q5a3V5FCxjaVgYcRAREZZ3cOZFU2ocXT3LsRvAqUW/6k 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:(13230028)(4636009)(376002)(346002)(39860400002)(136003)(396003)(451199021)(46966006)(36840700001)(40470700004)(36756003)(82310400005)(36860700001)(426003)(26005)(966005)(47076005)(478600001)(7696005)(336012)(6666004)(54906003)(110136005)(83380400001)(1076003)(2616005)(186003)(2906002)(5660300002)(7416002)(44832011)(40460700003)(81166007)(356005)(70206006)(40480700001)(82740400003)(316002)(70586007)(8936002)(41300700001)(4326008)(8676002)(86362001)(16526019)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2023 03:52:32.1137 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6db536ca-ba78-44ff-7247-08db72d41b7a 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: CO1PEPF000042AD.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4242 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter In devm_cxl_add_port() the port creation may fail and its associated pointer does not contain a valid address. During error message generation this invalid port address is used. Fix that wrong address access. Fixes: f3cd264c4ec1 ("cxl: Unify debug messages when calling devm_cxl_add_port()") Signed-off-by: Robert Richter Reviewed-by: Dave Jiang Link: https://lore.kernel.org/r/20230519215436.3394532-1-rrichter@amd.com Signed-off-by: Dan Williams --- drivers/cxl/core/port.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index da2068475fa2..e7c284c890bc 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -750,11 +750,10 @@ struct cxl_port *devm_cxl_add_port(struct device *host, struct device *uport, parent_port = parent_dport ? parent_dport->port : NULL; if (IS_ERR(port)) { - dev_dbg(uport, "Failed to add %s%s%s%s: %ld\n", - dev_name(&port->dev), - parent_port ? " to " : "", + dev_dbg(uport, "Failed to add%s%s%s: %ld\n", + parent_port ? " port to " : "", parent_port ? dev_name(&parent_port->dev) : "", - parent_port ? "" : " (root port)", + parent_port ? "" : " root port", PTR_ERR(port)); } else { dev_dbg(uport, "%s added%s%s%s\n", From patchwork Thu Jun 22 03:51:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13288214 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B77C3EB64D8 for ; Thu, 22 Jun 2023 03:53:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229984AbjFVDxJ (ORCPT ); Wed, 21 Jun 2023 23:53:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229993AbjFVDxG (ORCPT ); Wed, 21 Jun 2023 23:53:06 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2078.outbound.protection.outlook.com [40.107.243.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAAA21BF2; Wed, 21 Jun 2023 20:52:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=clXABx3YVqE1pSMktRQIslS1nTRVYGIKSTD7gLUNZ572hO5pYQsP9J1+CZ+zXOAIXMD2z15353NmHElLj+SzzDFhea3eBBeSEz3AeyzE4Qwlh1ogup+NnOxo80vl8H2RVtHeRa523MKgnd92jTjgx4JhSS1YizkkwTlBH+Lz1Ky4PxeAw9ZVItqHbZ5ndD4TGBQG2PwGHEnVNR99TDqLGNxlYjNRcHalPDArP83vhuWVKAiqHlj11DszTO4RXlZZR9VtBj1PjRPYvcpyzJolBf6+dqwJDDwyOSCTaibKN33jKK6ErSUNAYDe/hfMntnXPLnLCTcamWDI19ENcn+zQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=UebWhYTjSDMulwjytUBVUXAl38XaXPQ0axkBX8wU1P0=; b=dJy+2dVDw8iD1F8b2V7ZCyq2WJO8pn1+kzPRGgToO7yUstACStZ7tnAP8UmGulwWnm8vEZmnbhdHM1vtYnaqvbCYpJlYYGSvZIXr5aud0vv3Bi/04GGZKehyAl4ADRv8jlGUP3EGGbe8n8wkwX3d2gLJlwdid1Mh2vsBiil6wF+txVUOGf+TBeCBbV7Z3gIoIvg+2AHeRIDgyZWPlwe9hwtklw1iTxbu+U03yGo7z64oywIlCm+RE/HIJXbSuMT2LjjH495boAPmt8c0Sc5R9k176K7fldQnZxObQM8WIuo8PxxA/Iod5Sl4Hq4zrC7Ayv1sy2DJaA6AYVJKnisdfg== 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 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=UebWhYTjSDMulwjytUBVUXAl38XaXPQ0axkBX8wU1P0=; b=VnzZr0BP/PdErVGA/+T1119ENorAEqbthPGHf4LuuBnp5FoZWuy1qIkUExJnYfajEcgJ718MJXRXgq9hnuhLHZ/BarodGiUAi5jw4QanfUOU1q26crvsQa5BR6igx+lHGZT8TbAgORuvFssJ6aqX/SSNWcZATLJUsBpib9RpoFw= Received: from DM6PR07CA0125.namprd07.prod.outlook.com (2603:10b6:5:330::7) by CH3PR12MB7739.namprd12.prod.outlook.com (2603:10b6:610:151::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.39; Thu, 22 Jun 2023 03:52:43 +0000 Received: from CO1PEPF000042A9.namprd03.prod.outlook.com (2603:10b6:5:330:cafe::ab) by DM6PR07CA0125.outlook.office365.com (2603:10b6:5:330::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23 via Frontend Transport; Thu, 22 Jun 2023 03:52: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 CO1PEPF000042A9.mail.protection.outlook.com (10.167.243.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.17 via Frontend Transport; Thu, 22 Jun 2023 03:52:43 +0000 Received: from ethanolx7ea3host.amd.com (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.23; Wed, 21 Jun 2023 22:52:41 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v6 02/27] cxl/acpi: Probe RCRB later during RCH downstream port creation Date: Wed, 21 Jun 2023 22:51:01 -0500 Message-ID: <20230622035126.4130151-3-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622035126.4130151-1-terry.bowman@amd.com> References: <20230622035126.4130151-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: CO1PEPF000042A9:EE_|CH3PR12MB7739:EE_ X-MS-Office365-Filtering-Correlation-Id: 94f52e01-a774-4a2e-aa11-08db72d42221 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B8fTQJMez7pnWZktGMFl4mBxBp35JeKPOv7Mp/RhZvgWSDII5oNT2IpqD8D5l1idQrgz9UX5WcoPcJPkA6rFX7PYinS7qESmnRBhGtpr3k4m3SobXXbE3LV8maj9QY3ua/qEeK9nySDHg9rYV3JWIg8lGu7B+BY5M7YOY+tqtXk0fWi7D6vOTBWvJn4oB7Fj1G3Ll7N/OKcY/3BdGHktVjVKlIhjYwoT2TdWRPZDKyHdZbEOzeiO/d5C5mACSOI8vliCjwCLHOo4NrBQwDDoqSGG0sKSUs/0v9XKIE7Md92srov4TCLB7FUtnF5ijCU9Mv+nOJCeV9C1JpwNjaDgxWfPqp6ur6PkFTC7zLkgP/CVoocGrf0VJ0oRf7AUrJnC7/15IxBm77/KFa/gxw+flWWVkFJybKrw8uoUtn7tyZyU7mxvLiEleIGoBQDlQ+yBhESxFDpEHRWvSEXNfd5UtqnmnjXeZW6RNmeThgsLQODiv0DKPWLMWCkvu3vaubcUK91GN2ORUxhrgSOCIrZlaTRvIZ0TOws+Hn/YCvHB7x6CG6slhEwfKUrZJw6ihrWZAqG3uxQylU6U8GD8vyXz/FkWyngtzKmdNmVLPq9kRtPtPnBaRY0eCUFg4eJUAM3hoyz11zvGlwi8zmK23x8VlpvMYGY/SbyLzYMdT5wOutqXC/aoLQQtRqqw1ud9ba+qPw1zt9afA5fGl4j4e8ez/XaRgzoxKn9zlTxVP1UUzakc4pGCYSFAQ0FX5m9/b4XyFKg9wXmmLO4cAalpdSkU1g== 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:(13230028)(4636009)(39860400002)(346002)(376002)(396003)(136003)(451199021)(36840700001)(40470700004)(46966006)(82740400003)(8936002)(8676002)(7416002)(86362001)(44832011)(82310400005)(5660300002)(41300700001)(2906002)(81166007)(356005)(110136005)(54906003)(478600001)(40480700001)(83380400001)(6666004)(7696005)(36860700001)(4326008)(316002)(70206006)(40460700003)(36756003)(2616005)(16526019)(26005)(47076005)(426003)(336012)(70586007)(1076003)(186003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2023 03:52:43.2759 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 94f52e01-a774-4a2e-aa11-08db72d42221 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: CO1PEPF000042A9.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7739 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter The RCRB is extracted already during ACPI CEDT table parsing while the data of this is needed not earlier than dport creation. This implementation comes with drawbacks: During ACPI table scan there is already MMIO access including mapping and unmapping, but only ACPI data should be collected here. The collected data must be transferred through a couple of interfaces until it is finally consumed when creating the dport. This causes complex data structures and function interfaces. Additionally, RCRB parsing will be extended to also extract AER data, it would be much easier do this at a later point during port and dport creation when the data structures are available to hold that data. To simplify all that, probe the RCRB at a later point during RCH downstream port creation. Change ACPI table parser to only extract the base address of either the component registers or the RCRB. Parse and extract the RCRB in devm_cxl_add_rch_dport(). This is in preparation to centralize all RCRB scanning. Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang --- drivers/cxl/acpi.c | 51 +++++++++++++++++------------------------ drivers/cxl/core/port.c | 21 +++++++++++++---- drivers/cxl/cxl.h | 1 - 3 files changed, 37 insertions(+), 36 deletions(-) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index 7e1765b09e04..70cd9ac73a8b 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -372,21 +372,21 @@ static int add_host_bridge_uport(struct device *match, void *arg) return 0; } +/* Note, @dev is used by mock_acpi_table_parse_cedt() */ struct cxl_chbs_context { struct device *dev; unsigned long long uid; - resource_size_t rcrb; - resource_size_t chbcr; + resource_size_t base; u32 cxl_version; }; -static int cxl_get_chbcr(union acpi_subtable_headers *header, void *arg, +static int cxl_get_chbs(union acpi_subtable_headers *header, void *arg, const unsigned long end) { struct cxl_chbs_context *ctx = arg; struct acpi_cedt_chbs *chbs; - if (ctx->chbcr) + if (ctx->base) return 0; chbs = (struct acpi_cedt_chbs *) header; @@ -395,23 +395,16 @@ static int cxl_get_chbcr(union acpi_subtable_headers *header, void *arg, return 0; ctx->cxl_version = chbs->cxl_version; - ctx->rcrb = CXL_RESOURCE_NONE; - ctx->chbcr = CXL_RESOURCE_NONE; + ctx->base = CXL_RESOURCE_NONE; if (!chbs->base) return 0; - if (chbs->cxl_version != ACPI_CEDT_CHBS_VERSION_CXL11) { - ctx->chbcr = chbs->base; - return 0; - } - - if (chbs->length != CXL_RCRB_SIZE) + if (chbs->cxl_version == ACPI_CEDT_CHBS_VERSION_CXL11 && + chbs->length != CXL_RCRB_SIZE) return 0; - ctx->rcrb = chbs->base; - ctx->chbcr = cxl_rcrb_to_component(ctx->dev, chbs->base, - CXL_RCRB_DOWNSTREAM); + ctx->base = chbs->base; return 0; } @@ -443,33 +436,31 @@ static int add_host_bridge_dport(struct device *match, void *arg) .dev = match, .uid = uid, }; - acpi_table_parse_cedt(ACPI_CEDT_TYPE_CHBS, cxl_get_chbcr, &ctx); + acpi_table_parse_cedt(ACPI_CEDT_TYPE_CHBS, cxl_get_chbs, &ctx); - if (!ctx.chbcr) { + if (!ctx.base) { dev_warn(match, "No CHBS found for Host Bridge (UID %lld)\n", uid); return 0; } - if (ctx.rcrb != CXL_RESOURCE_NONE) - dev_dbg(match, "RCRB found for UID %lld: %pa\n", uid, &ctx.rcrb); - - if (ctx.chbcr == CXL_RESOURCE_NONE) { - dev_warn(match, "CHBCR invalid for Host Bridge (UID %lld)\n", + if (ctx.base == CXL_RESOURCE_NONE) { + dev_warn(match, "CHBS invalid for Host Bridge (UID %lld)\n", uid); return 0; } - dev_dbg(match, "CHBCR found: %pa\n", &ctx.chbcr); - pci_root = acpi_pci_find_root(hb->handle); bridge = pci_root->bus->bridge; - if (ctx.cxl_version == ACPI_CEDT_CHBS_VERSION_CXL11) - dport = devm_cxl_add_rch_dport(root_port, bridge, uid, - ctx.chbcr, ctx.rcrb); - else - dport = devm_cxl_add_dport(root_port, bridge, uid, - ctx.chbcr); + + if (ctx.cxl_version == ACPI_CEDT_CHBS_VERSION_CXL11) { + dev_dbg(match, "RCRB found for UID %lld: %pa\n", uid, &ctx.base); + dport = devm_cxl_add_rch_dport(root_port, bridge, uid, ctx.base); + } else { + dev_dbg(match, "CHBCR found for UID %lld: %pa\n", uid, &ctx.base); + dport = devm_cxl_add_dport(root_port, bridge, uid, ctx.base); + } + if (IS_ERR(dport)) return PTR_ERR(dport); diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index e7c284c890bc..1a3f8729a616 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -938,12 +938,25 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev, if (!dport) return ERR_PTR(-ENOMEM); + if (rcrb != CXL_RESOURCE_NONE) { + component_reg_phys = cxl_rcrb_to_component(dport_dev, + rcrb, CXL_RCRB_DOWNSTREAM); + if (component_reg_phys == CXL_RESOURCE_NONE) { + dev_warn(dport_dev, "Invalid Component Registers in RCRB"); + return ERR_PTR(-ENXIO); + } + + dport->rch = true; + } + + if (component_reg_phys != CXL_RESOURCE_NONE) + dev_dbg(dport_dev, "Component Registers found for dport: %pa\n", + &component_reg_phys); + dport->dport = dport_dev; dport->port_id = port_id; dport->component_reg_phys = component_reg_phys; dport->port = port; - if (rcrb != CXL_RESOURCE_NONE) - dport->rch = true; dport->rcrb = rcrb; cond_cxl_root_lock(port); @@ -1004,14 +1017,12 @@ EXPORT_SYMBOL_NS_GPL(devm_cxl_add_dport, CXL); * @port: the cxl_port that references this dport * @dport_dev: firmware or PCI device representing the dport * @port_id: identifier for this dport in a decoder's target list - * @component_reg_phys: optional location of CXL component registers * @rcrb: mandatory location of a Root Complex Register Block * * See CXL 3.0 9.11.8 CXL Devices Attached to an RCH */ struct cxl_dport *devm_cxl_add_rch_dport(struct cxl_port *port, struct device *dport_dev, int port_id, - resource_size_t component_reg_phys, resource_size_t rcrb) { struct cxl_dport *dport; @@ -1022,7 +1033,7 @@ struct cxl_dport *devm_cxl_add_rch_dport(struct cxl_port *port, } dport = __devm_cxl_add_dport(port, dport_dev, port_id, - component_reg_phys, rcrb); + CXL_RESOURCE_NONE, rcrb); if (IS_ERR(dport)) { dev_dbg(dport_dev, "failed to add RCH dport to %s: %ld\n", dev_name(&port->dev), PTR_ERR(dport)); diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index f93a28538962..a5cd661face2 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -671,7 +671,6 @@ struct cxl_dport *devm_cxl_add_dport(struct cxl_port *port, resource_size_t component_reg_phys); struct cxl_dport *devm_cxl_add_rch_dport(struct cxl_port *port, struct device *dport_dev, int port_id, - resource_size_t component_reg_phys, resource_size_t rcrb); struct cxl_decoder *to_cxl_decoder(struct device *dev); From patchwork Thu Jun 22 03:51:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13288215 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C1A6EB64DA for ; Thu, 22 Jun 2023 03:53:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229843AbjFVDxM (ORCPT ); Wed, 21 Jun 2023 23:53:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230025AbjFVDxK (ORCPT ); Wed, 21 Jun 2023 23:53:10 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2049.outbound.protection.outlook.com [40.107.244.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 312FD1FD8; Wed, 21 Jun 2023 20:52:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bf5FWZ5G+EeehMvKSOm5RiLKV+LS7g3cJkdPxJNCT9J25M/HIUU/ztiELB/MSsygf+UiYvcH3gr2l/G73hU0/ju6ItgvsHsqTPlJgO4eIaNwfYxvtXkTY0r+brn+hVAhZm8NdIW6YG4gNBF3Ze+3hwfDqFRm6Ca2xkXy/0Dw3vLBTuwyThk2D8bYgH6I8yfIFQC5Gad+qFKh/MxWWnxDuEx4K5ybkjUeTwjR/pEVlpwQTRrQd7/pB7+YDoTIOVvpBhcozxbsBo6aX16uL76ENZktuIEiWSVHvhhTsNyL8dPl0p4WLTSOjfLj74j4ACTqxJvuvOJOFwd/NRKCzlguAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=wE7UKIqt17UltAmUdPIFngXl5ezI54ZthO8oxdvH+fY=; b=IbTfHKLLmX5RBQdJ89zSJ3LfoYwD+nWd6BAYEJ3lhXb32c4jXNhIz3g10maEZFQECTbZb17nFdhVkpe1lEl8fgr2kQM6YADDHsQRp6BLL8PuZTTiwmRznG1km3cVryZaSr/EgaTLRemMENnKajKPkr3OKugP4wgZ2STHCJ/WKNMTXDXKUOp54XjQyFRLOt9TGujU3YG+hrOYihtbO43dtdusVIvWU254Tv//BtG1eMs5i3hZbO+rPaq26hK/MpawCVaaEXGp+VXYcNPuieSeobFuxWHSFbs7zF7ukr73kUbRVfW3hwOPH3Aj9+D+AigXMvGjo1qMjV0bJXH9Wsmw1A== 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 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=wE7UKIqt17UltAmUdPIFngXl5ezI54ZthO8oxdvH+fY=; b=HbEHLFmvVmcXTlHOThJR6UCQQFiRkzB0wx/P0Ts5vSNcb2bV0bqoXRcYyGFvsKuStRvHC5DV6Td3VE+v2VnnruPexnlKWymNJ/HZcbNk5RcjLiKSyYcBLJcNvhs+1/6ycvAa4kX8NVjYtpc+xtHtfqBvm+aiI+nQ3O4oIS5xFqg= Received: from SJ0PR03CA0011.namprd03.prod.outlook.com (2603:10b6:a03:33a::16) by DS7PR12MB6286.namprd12.prod.outlook.com (2603:10b6:8:95::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Thu, 22 Jun 2023 03:52:54 +0000 Received: from CO1PEPF000042A8.namprd03.prod.outlook.com (2603:10b6:a03:33a:cafe::aa) by SJ0PR03CA0011.outlook.office365.com (2603:10b6:a03:33a::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24 via Frontend Transport; Thu, 22 Jun 2023 03:52: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 CO1PEPF000042A8.mail.protection.outlook.com (10.167.243.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.17 via Frontend Transport; Thu, 22 Jun 2023 03:52:54 +0000 Received: from ethanolx7ea3host.amd.com (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.23; Wed, 21 Jun 2023 22:52:52 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v6 03/27] cxl: Updates for CXL Test to work with RCH Date: Wed, 21 Jun 2023 22:51:02 -0500 Message-ID: <20230622035126.4130151-4-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622035126.4130151-1-terry.bowman@amd.com> References: <20230622035126.4130151-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: CO1PEPF000042A8:EE_|DS7PR12MB6286:EE_ X-MS-Office365-Filtering-Correlation-Id: c7daf13a-93c9-4f42-7e1b-08db72d4288c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XXYXCXa0bH4FuaBgEVjcHnrVSvxfhrato30NcXoDzaY4Vu/IdgkwMZKqqLwBx7c5CAVEYnnNui6cXSWG9Y2ES8HB1ox85GVlQwEAsyP2zSC+CwA5HH0PlO+Kwf3tsaM2/9Qa1iD9QtcDFADqGCesjJN3bIQFdib9NBS1n8biVdGFj9qllNN6BW7HZZgU4hb0WsYvktaM1J69V8Syd48Y68gAQb3VUzJPHqB/4Dgv4PM/8vRlFdJGqa20GJ3KrPd2hctoc0Wy6g6ADw+zSq+sVkrOinWRJHXXH0OmwGxSOAq/X8YtbrAORNWC8HC34qlNKLVJ6IXcEsnxaCraCWA9zkfhOG7qyv+/k4mmmklpJrx2NH1pVd0HqN5obEkeoWy+mkAkpcxWHb+oH2wcnRAbhHdzNaTA8jgKwL8lzbe7Xp+Q72W2tVc20tO2F8CXHEwFmG22lF9C5BpyIsbYOYWGhEusOsyxSURwAOY7N0obZmmJjD583LqoVxCJ5Ci/JTl88LF8eevahH+jjhCLz2RsUOlTcYucS9/NOduz9IRQdCcKOFGhNLk8ZinrdlzovDablQ9HsAVAJB7/i8mnX3Uisgk4iniPTpQsJG+VPUvHmid4Cn2Z+mbyyMt+RjhbM/pkkfMGHCWritYK5fZRzHi7VrWUSAzFw6scM74LA5dMYsiaLKEPwYFCVgb5be4vd4/dEPHW6ahue/tWVbMBp5d2YgJhg7WA1+USC4NUGo3ZiocQSSjB/La0f9gSXHodDKpyjy5fYcIzINQScWNMUdrEMg== 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:(13230028)(4636009)(39860400002)(396003)(136003)(376002)(346002)(451199021)(40470700004)(36840700001)(46966006)(7696005)(478600001)(54906003)(70586007)(70206006)(6666004)(110136005)(186003)(1076003)(26005)(2906002)(82310400005)(16526019)(8936002)(4326008)(5660300002)(8676002)(7416002)(41300700001)(44832011)(316002)(356005)(81166007)(82740400003)(40460700003)(86362001)(426003)(40480700001)(36860700001)(47076005)(83380400001)(2616005)(36756003)(336012)(15650500001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2023 03:52:54.0423 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c7daf13a-93c9-4f42-7e1b-08db72d4288c 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: CO1PEPF000042A8.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6286 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Dan Williams CXL test needs to be updated to work with latest RCH changes. Add CXL test support for devm_cxl_add_rch_dport and cxl_rcd_component_reg_phys functions. Signed-off-by: Dan Williams Signed-off-by: Terry Bowman Signed-off-by: Robert Richter Reviewed-by: Dave Jiang --- drivers/cxl/core/core.h | 8 ++++++++ drivers/cxl/core/port.c | 4 ++-- drivers/cxl/core/regs.c | 15 +++++++++++---- drivers/cxl/cxl.h | 11 +++-------- drivers/cxl/mem.c | 4 ++-- tools/testing/cxl/Kbuild | 3 ++- tools/testing/cxl/test/cxl.c | 10 ---------- tools/testing/cxl/test/mock.c | 34 +++++++++++++++++++++++++++------- tools/testing/cxl/test/mock.h | 3 --- 9 files changed, 55 insertions(+), 37 deletions(-) diff --git a/drivers/cxl/core/core.h b/drivers/cxl/core/core.h index 27f0968449de..bd0a5788c696 100644 --- a/drivers/cxl/core/core.h +++ b/drivers/cxl/core/core.h @@ -63,6 +63,14 @@ int cxl_dpa_alloc(struct cxl_endpoint_decoder *cxled, unsigned long long size); int cxl_dpa_free(struct cxl_endpoint_decoder *cxled); resource_size_t cxl_dpa_size(struct cxl_endpoint_decoder *cxled); resource_size_t cxl_dpa_resource_start(struct cxl_endpoint_decoder *cxled); + +enum cxl_rcrb { + CXL_RCRB_DOWNSTREAM, + CXL_RCRB_UPSTREAM, +}; +resource_size_t __rcrb_to_component(struct device *dev, resource_size_t rcrb, + enum cxl_rcrb which); + extern struct rw_semaphore cxl_dpa_rwsem; int cxl_memdev_init(void); diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 1a3f8729a616..45f5299af7a6 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -939,8 +939,8 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev, return ERR_PTR(-ENOMEM); if (rcrb != CXL_RESOURCE_NONE) { - component_reg_phys = cxl_rcrb_to_component(dport_dev, - rcrb, CXL_RCRB_DOWNSTREAM); + component_reg_phys = __rcrb_to_component(dport_dev, rcrb, + CXL_RCRB_DOWNSTREAM); if (component_reg_phys == CXL_RESOURCE_NONE) { dev_warn(dport_dev, "Invalid Component Registers in RCRB"); return ERR_PTR(-ENXIO); diff --git a/drivers/cxl/core/regs.c b/drivers/cxl/core/regs.c index 1476a0299c9b..564dd430258a 100644 --- a/drivers/cxl/core/regs.c +++ b/drivers/cxl/core/regs.c @@ -332,9 +332,8 @@ int cxl_find_regblock(struct pci_dev *pdev, enum cxl_regloc_type type, } EXPORT_SYMBOL_NS_GPL(cxl_find_regblock, CXL); -resource_size_t cxl_rcrb_to_component(struct device *dev, - resource_size_t rcrb, - enum cxl_rcrb which) +resource_size_t __rcrb_to_component(struct device *dev, resource_size_t rcrb, + enum cxl_rcrb which) { resource_size_t component_reg_phys; void __iomem *addr; @@ -395,4 +394,12 @@ resource_size_t cxl_rcrb_to_component(struct device *dev, return component_reg_phys; } -EXPORT_SYMBOL_NS_GPL(cxl_rcrb_to_component, CXL); + +resource_size_t cxl_rcd_component_reg_phys(struct device *dev, + struct cxl_dport *dport) +{ + if (!dport->rch) + return CXL_RESOURCE_NONE; + return __rcrb_to_component(dev, dport->rcrb, CXL_RCRB_UPSTREAM); +} +EXPORT_SYMBOL_NS_GPL(cxl_rcd_component_reg_phys, CXL); diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index a5cd661face2..28888bb0c088 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -262,14 +262,9 @@ int cxl_map_device_regs(struct device *dev, struct cxl_device_regs *regs, enum cxl_regloc_type; int cxl_find_regblock(struct pci_dev *pdev, enum cxl_regloc_type type, struct cxl_register_map *map); - -enum cxl_rcrb { - CXL_RCRB_DOWNSTREAM, - CXL_RCRB_UPSTREAM, -}; -resource_size_t cxl_rcrb_to_component(struct device *dev, - resource_size_t rcrb, - enum cxl_rcrb which); +struct cxl_dport; +resource_size_t cxl_rcd_component_reg_phys(struct device *dev, + struct cxl_dport *dport); #define CXL_RESOURCE_NONE ((resource_size_t) -1) #define CXL_TARGET_STRLEN 20 diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c index 519edd0eb196..45d4c32d78b0 100644 --- a/drivers/cxl/mem.c +++ b/drivers/cxl/mem.c @@ -72,8 +72,8 @@ static int devm_cxl_add_endpoint(struct device *host, struct cxl_memdev *cxlmd, * typical register locator mechanism. */ if (parent_dport->rch && cxlds->component_reg_phys == CXL_RESOURCE_NONE) - component_reg_phys = cxl_rcrb_to_component( - &cxlmd->dev, parent_dport->rcrb, CXL_RCRB_UPSTREAM); + component_reg_phys = + cxl_rcd_component_reg_phys(&cxlmd->dev, parent_dport); else component_reg_phys = cxlds->component_reg_phys; endpoint = devm_cxl_add_port(host, &cxlmd->dev, component_reg_phys, diff --git a/tools/testing/cxl/Kbuild b/tools/testing/cxl/Kbuild index 6f9347ade82c..8a87d7d5f7f8 100644 --- a/tools/testing/cxl/Kbuild +++ b/tools/testing/cxl/Kbuild @@ -12,7 +12,8 @@ ldflags-y += --wrap=devm_cxl_enumerate_decoders ldflags-y += --wrap=cxl_await_media_ready ldflags-y += --wrap=cxl_hdm_decode_init ldflags-y += --wrap=cxl_dvsec_rr_decode -ldflags-y += --wrap=cxl_rcrb_to_component +ldflags-y += --wrap=devm_cxl_add_rch_dport +ldflags-y += --wrap=cxl_rcd_component_reg_phys DRIVERS := ../../../drivers CXL_SRC := $(DRIVERS)/cxl diff --git a/tools/testing/cxl/test/cxl.c b/tools/testing/cxl/test/cxl.c index bf00dc52fe96..f5c04787bcc8 100644 --- a/tools/testing/cxl/test/cxl.c +++ b/tools/testing/cxl/test/cxl.c @@ -971,15 +971,6 @@ static int mock_cxl_port_enumerate_dports(struct cxl_port *port) return 0; } -resource_size_t mock_cxl_rcrb_to_component(struct device *dev, - resource_size_t rcrb, - enum cxl_rcrb which) -{ - dev_dbg(dev, "rcrb: %pa which: %d\n", &rcrb, which); - - return (resource_size_t) which + 1; -} - static struct cxl_mock_ops cxl_mock_ops = { .is_mock_adev = is_mock_adev, .is_mock_bridge = is_mock_bridge, @@ -988,7 +979,6 @@ static struct cxl_mock_ops cxl_mock_ops = { .is_mock_dev = is_mock_dev, .acpi_table_parse_cedt = mock_acpi_table_parse_cedt, .acpi_evaluate_integer = mock_acpi_evaluate_integer, - .cxl_rcrb_to_component = mock_cxl_rcrb_to_component, .acpi_pci_find_root = mock_acpi_pci_find_root, .devm_cxl_port_enumerate_dports = mock_cxl_port_enumerate_dports, .devm_cxl_setup_hdm = mock_cxl_setup_hdm, diff --git a/tools/testing/cxl/test/mock.c b/tools/testing/cxl/test/mock.c index 284416527644..30119a16ae85 100644 --- a/tools/testing/cxl/test/mock.c +++ b/tools/testing/cxl/test/mock.c @@ -259,24 +259,44 @@ int __wrap_cxl_dvsec_rr_decode(struct device *dev, int dvsec, } EXPORT_SYMBOL_NS_GPL(__wrap_cxl_dvsec_rr_decode, CXL); -resource_size_t __wrap_cxl_rcrb_to_component(struct device *dev, - resource_size_t rcrb, - enum cxl_rcrb which) +struct cxl_dport *__wrap_devm_cxl_add_rch_dport(struct cxl_port *port, + struct device *dport_dev, + int port_id, + resource_size_t rcrb) +{ + int index; + struct cxl_dport *dport; + struct cxl_mock_ops *ops = get_cxl_mock_ops(&index); + + if (ops && ops->is_mock_port(dport_dev)) { + dport = devm_cxl_add_dport(port, dport_dev, port_id, + CXL_RESOURCE_NONE); + if (!IS_ERR(dport)) + dport->rch = true; + } else + dport = devm_cxl_add_rch_dport(port, dport_dev, port_id, rcrb); + put_cxl_mock_ops(index); + + return dport; +} +EXPORT_SYMBOL_NS_GPL(__wrap_devm_cxl_add_rch_dport, CXL); + +resource_size_t __wrap_cxl_rcd_component_reg_phys(struct device *dev, + struct cxl_dport *dport) { int index; resource_size_t component_reg_phys; struct cxl_mock_ops *ops = get_cxl_mock_ops(&index); if (ops && ops->is_mock_port(dev)) - component_reg_phys = - ops->cxl_rcrb_to_component(dev, rcrb, which); + component_reg_phys = CXL_RESOURCE_NONE; else - component_reg_phys = cxl_rcrb_to_component(dev, rcrb, which); + component_reg_phys = cxl_rcd_component_reg_phys(dev, dport); put_cxl_mock_ops(index); return component_reg_phys; } -EXPORT_SYMBOL_NS_GPL(__wrap_cxl_rcrb_to_component, CXL); +EXPORT_SYMBOL_NS_GPL(__wrap_cxl_rcd_component_reg_phys, CXL); MODULE_LICENSE("GPL v2"); MODULE_IMPORT_NS(ACPI); diff --git a/tools/testing/cxl/test/mock.h b/tools/testing/cxl/test/mock.h index bef8817b01f2..a94223750346 100644 --- a/tools/testing/cxl/test/mock.h +++ b/tools/testing/cxl/test/mock.h @@ -15,9 +15,6 @@ struct cxl_mock_ops { acpi_string pathname, struct acpi_object_list *arguments, unsigned long long *data); - resource_size_t (*cxl_rcrb_to_component)(struct device *dev, - resource_size_t rcrb, - enum cxl_rcrb which); struct acpi_pci_root *(*acpi_pci_find_root)(acpi_handle handle); bool (*is_mock_bus)(struct pci_bus *bus); bool (*is_mock_port)(struct device *dev); From patchwork Thu Jun 22 03:51:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13288216 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63584EB64D8 for ; Thu, 22 Jun 2023 03:53:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230089AbjFVDxc (ORCPT ); Wed, 21 Jun 2023 23:53:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229732AbjFVDxZ (ORCPT ); Wed, 21 Jun 2023 23:53:25 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2064.outbound.protection.outlook.com [40.107.223.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEC961BE1; Wed, 21 Jun 2023 20:53:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gCgqH0etcoI3roI/9G4fsj/eqWLziQyiJHQpYA0Ju6+WG6FB7f6QG3VGvbU+8Z0otbgVmDxTZgwteJuYnZW3LF91hYubEOIi5pOoXHvNjBxK3cL6xa348hUSaUy5TfzOAF6oZNDcxLgb7c4yu6Ung9TURrt0X0WWTTn0Wv4SLO7r8xR0201dq/mUunVFWpS0fnArM07Prsql7UQ9iqNAFIF2g8b3PogzxxsPgHHsXCQpGRwwfBYVU2ZHRxcy/F+83fwRwk217Sl13J9TJD38XermhJVKkMrN+rqJcmhWWeGwDlz6wzxg8U3w51o80SCJKac7h21hnjIinNs0OygiXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=ZfQMGml3MxX15dLvaWY6JcTZG/4JYvkuhNTjSQe/fbA=; b=JZICYSd8GgY0se9kQs3SBZRJFWMofZPjyt+IFyRla+ZqZZRyyzq56Bsq6bMC6qupEsTDnYthbpeeFTLbFx/eNpgSW064PlH/S8y1VW7bT41oFe6C61FtCLzL3c+2Pavi30qa/R8/QYUiKtjvttte0BV3VWifKYS/h8BRZccBnleVEzWgV051U1CQX26PMzW/hCUqhS27qgAIyRSvnY1NmxHMWSQdXF/ELAsijH1gBuBf9UYz20SjT+0tq4/vvAymuw5h+ArAmdtq7BLlOUzpyqyNmSq39WCAqCUXIDooPeM6FfJuRAj38OkHDPnhvqTaYvLLZIZ5RLVfMGDV4dyaIw== 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 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=ZfQMGml3MxX15dLvaWY6JcTZG/4JYvkuhNTjSQe/fbA=; b=fZ332koo6kS6kGUJ6uq9ZDJIIHklJRHT/ZyS6iLIuzCC5f0PgV6yfQTeKufHKhWSGQyvWs8h7mXx9w6S36g+JVLW0YpycRkrlcF2uUawVpRHZWCd7sEa3t/MCRQj91MzBDGVTbov15oDWNP8hJB0B7yHFuFMvfyc4OKpEnoCkP4= Received: from MW4PR03CA0119.namprd03.prod.outlook.com (2603:10b6:303:b7::34) by MW3PR12MB4428.namprd12.prod.outlook.com (2603:10b6:303:57::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Thu, 22 Jun 2023 03:53:05 +0000 Received: from CO1PEPF000042AC.namprd03.prod.outlook.com (2603:10b6:303:b7:cafe::b7) by MW4PR03CA0119.outlook.office365.com (2603:10b6:303:b7::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24 via Frontend Transport; Thu, 22 Jun 2023 03:53: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 CO1PEPF000042AC.mail.protection.outlook.com (10.167.243.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6477.13 via Frontend Transport; Thu, 22 Jun 2023 03:53:05 +0000 Received: from ethanolx7ea3host.amd.com (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.23; Wed, 21 Jun 2023 22:53:03 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v6 04/27] cxl/rch: Prepare for caching the MMIO mapped PCIe AER capability Date: Wed, 21 Jun 2023 22:51:03 -0500 Message-ID: <20230622035126.4130151-5-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622035126.4130151-1-terry.bowman@amd.com> References: <20230622035126.4130151-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: CO1PEPF000042AC:EE_|MW3PR12MB4428:EE_ X-MS-Office365-Filtering-Correlation-Id: 5df6b97b-d539-4d9e-a096-08db72d42f25 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Yyq781pFL748YxuyP0YRWRX5IYYz/9q/o1VvwlgfiqryRwJegdR5JP2tgJxHC/+4aKR63VJE6V3wXP/o/k1gWoKn8frpZQbuwBldlzu2QbDUOah8qeluLwh4zatwZJpHmDLgT5pe8vseZkAg7Wq5dFFCYrhBAeGDcFhQXMKDJzBgasQWPWkpKnWgWM/TB2XCTcKpDax2ONpF/kuYGiqow256bsvYVqzJR6rtD1uDZSkXq9qWQGRIEgVXB/1F4qnCxuOi/Q1nzQ1WUrFszPipDo7Qz7iQ81T25exqb0jFfewD+8eKAWJ79o7jHKPt0IOGyXnTqx7IomnDKQr274nv34GOZTmhzjnac7uQ/cFGyQ7njg4p8CinAA6JKVXUthXBmYI2Gi7I74PJwCUSI4XOniehuRZgsoe41oGd+vsB4nFTPMxCVukq7+BWKyukMXm4nkXtaXP7Ddl1cOTfUwnPGMqj9GnISAUSnEg7VoNYw0P5pzmAOX0O+j/OPdHN4DPZMIgywH7Mch8k7blpeEm+SHlQnmHA6Q9SMxXHstQFMDI8eLA2B1PDQc/M4DAkDYZ63nmEcLxjP/+RYd2DGKHiZtPGatkd12G+KA2VYrRl+vSd127r3rLqS42qdiToEbzNlfXutQni/6AJsuOXDP0tQDkES0Ris/GN/A6X7n+iYaiZJ+pGti6ViqjqRhv8iKn+/edsVi925tsxSKw4an/VwEA0mxGddGcyqfk6I1MmY4gdsPBMesVDSq2tzMYoi1sKs0f2WCRTSmxBCmhde3j7fQ== 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:(13230028)(4636009)(136003)(376002)(396003)(39860400002)(346002)(451199021)(46966006)(36840700001)(40470700004)(82310400005)(7696005)(4326008)(70586007)(70206006)(478600001)(36756003)(316002)(54906003)(40460700003)(110136005)(86362001)(83380400001)(426003)(26005)(1076003)(47076005)(336012)(16526019)(186003)(2616005)(82740400003)(356005)(5660300002)(81166007)(2906002)(41300700001)(8676002)(8936002)(7416002)(36860700001)(44832011)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2023 03:53:05.0966 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5df6b97b-d539-4d9e-a096-08db72d42f25 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: CO1PEPF000042AC.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4428 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Dan Williams Prepare cxl_probe_rcrb() for retrieving more than just the component register block. The RCH AER handling code wants to get back to the AER capability that happens to be MMIO mapped rather then configuration cycles. Move RCRB specific downstream port data, like the RCRB base and the AER capability offset, into its own data structure ('struct cxl_rcrb_info') for cxl_probe_rcrb() to fill. Extend 'struct cxl_dport' to include a 'struct cxl_rcrb_info' attribute. This centralizes all RCRB scanning in one routine. Signed-off-by: Dan Williams Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang --- drivers/cxl/core/core.h | 4 +++- drivers/cxl/core/port.c | 4 ++-- drivers/cxl/core/regs.c | 5 +++-- drivers/cxl/cxl.h | 9 +++++++-- tools/testing/cxl/test/mock.c | 4 +++- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/cxl/core/core.h b/drivers/cxl/core/core.h index bd0a5788c696..b001669a5133 100644 --- a/drivers/cxl/core/core.h +++ b/drivers/cxl/core/core.h @@ -68,7 +68,9 @@ enum cxl_rcrb { CXL_RCRB_DOWNSTREAM, CXL_RCRB_UPSTREAM, }; -resource_size_t __rcrb_to_component(struct device *dev, resource_size_t rcrb, +struct cxl_rcrb_info; +resource_size_t __rcrb_to_component(struct device *dev, + struct cxl_rcrb_info *ri, enum cxl_rcrb which); extern struct rw_semaphore cxl_dpa_rwsem; diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 45f5299af7a6..76888c75dae4 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -939,7 +939,8 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev, return ERR_PTR(-ENOMEM); if (rcrb != CXL_RESOURCE_NONE) { - component_reg_phys = __rcrb_to_component(dport_dev, rcrb, + dport->rcrb.base = rcrb; + component_reg_phys = __rcrb_to_component(dport_dev, &dport->rcrb, CXL_RCRB_DOWNSTREAM); if (component_reg_phys == CXL_RESOURCE_NONE) { dev_warn(dport_dev, "Invalid Component Registers in RCRB"); @@ -957,7 +958,6 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev, dport->port_id = port_id; dport->component_reg_phys = component_reg_phys; dport->port = port; - dport->rcrb = rcrb; cond_cxl_root_lock(port); rc = add_dport(port, dport); diff --git a/drivers/cxl/core/regs.c b/drivers/cxl/core/regs.c index 564dd430258a..6c4b33133918 100644 --- a/drivers/cxl/core/regs.c +++ b/drivers/cxl/core/regs.c @@ -332,10 +332,11 @@ int cxl_find_regblock(struct pci_dev *pdev, enum cxl_regloc_type type, } EXPORT_SYMBOL_NS_GPL(cxl_find_regblock, CXL); -resource_size_t __rcrb_to_component(struct device *dev, resource_size_t rcrb, +resource_size_t __rcrb_to_component(struct device *dev, struct cxl_rcrb_info *ri, enum cxl_rcrb which) { resource_size_t component_reg_phys; + resource_size_t rcrb = ri->base; void __iomem *addr; u32 bar0, bar1; u16 cmd; @@ -400,6 +401,6 @@ resource_size_t cxl_rcd_component_reg_phys(struct device *dev, { if (!dport->rch) return CXL_RESOURCE_NONE; - return __rcrb_to_component(dev, dport->rcrb, CXL_RCRB_UPSTREAM); + return __rcrb_to_component(dev, &dport->rcrb, CXL_RCRB_UPSTREAM); } EXPORT_SYMBOL_NS_GPL(cxl_rcd_component_reg_phys, CXL); diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index 28888bb0c088..7c8674079f1a 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -582,12 +582,17 @@ cxl_find_dport_by_dev(struct cxl_port *port, const struct device *dport_dev) return xa_load(&port->dports, (unsigned long)dport_dev); } +struct cxl_rcrb_info { + resource_size_t base; + u16 aer_cap; +}; + /** * struct cxl_dport - CXL downstream port * @dport: PCI bridge or firmware device representing the downstream link * @port_id: unique hardware identifier for dport in decoder target list * @component_reg_phys: downstream port component registers - * @rcrb: base address for the Root Complex Register Block + * @rcrb: Data about the Root Complex Register Block layout * @rch: Indicate whether this dport was enumerated in RCH or VH mode * @port: reference to cxl_port that contains this downstream port */ @@ -595,7 +600,7 @@ struct cxl_dport { struct device *dport; int port_id; resource_size_t component_reg_phys; - resource_size_t rcrb; + struct cxl_rcrb_info rcrb; bool rch; struct cxl_port *port; }; diff --git a/tools/testing/cxl/test/mock.c b/tools/testing/cxl/test/mock.c index 30119a16ae85..dbeef5c6f606 100644 --- a/tools/testing/cxl/test/mock.c +++ b/tools/testing/cxl/test/mock.c @@ -271,8 +271,10 @@ struct cxl_dport *__wrap_devm_cxl_add_rch_dport(struct cxl_port *port, if (ops && ops->is_mock_port(dport_dev)) { dport = devm_cxl_add_dport(port, dport_dev, port_id, CXL_RESOURCE_NONE); - if (!IS_ERR(dport)) + if (!IS_ERR(dport)) { + dport->rcrb.base = rcrb; dport->rch = true; + } } else dport = devm_cxl_add_rch_dport(port, dport_dev, port_id, rcrb); put_cxl_mock_ops(index); From patchwork Thu Jun 22 03:51:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13288217 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33240EB64D8 for ; Thu, 22 Jun 2023 03:53:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229976AbjFVDxu (ORCPT ); Wed, 21 Jun 2023 23:53:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230113AbjFVDxg (ORCPT ); Wed, 21 Jun 2023 23:53:36 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2075.outbound.protection.outlook.com [40.107.94.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD56A1FF2; Wed, 21 Jun 2023 20:53:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BpcgpMBY3gLOb5SWkYPzPgxsqIBNUSwtxRo5uUyicoVODMWDBuS+/fNGDPBDm5KqnLMb3kcDFt+PEh02sd0/BGw/IIk44eron3vi6dcULtqfYNCVJ9aVWbelWzqd3uCWAEDAjY4v3DmF3M5KXCJElyHkjEO5gJkQfBiFcw7vfNoZGfh082ZPZnNfheBcejVirheCYad3PYAqD7wRAlCJdq9STEmpGcFyM0yK5mTppxdOl0ke7ubZbcMm52TLYTNKha0AV2NeA2+1yVRe3ttRdiIIz5xeMw8hlUC6++fpzGb/iliXjWp+HnTQF319W700oH8L4mirOCnq0MUnBYu4qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=G3XQwXAHJy7GzCPDUQNM1GXGisSr3ZK/tvX5eovg+7Q=; b=FVwsRiSiBmV4BcwOZ8agJ7+26uRSWEwyAWixs/UXZWoDkZQukak0bOTfkQY2BeT6WQ5dlNoVyDaOLkNWyE8l88PDYi2zJQexFkXDlHzuc9vZCimKHVRk2LkcteKHBXq+WllDMciJ9AOLmFcvTz80YKf0CFlJOuO8ZHo6QvYMF+YaExCWV/7eMJvPlIiz/RRAVW53JqLOhPvmlj2OGADeTcaGWOWqVYZkgwe8QC+kTE1BD7NtBQpCfWMuJjam1jvo9z089WrAQH+0kRr6CM8OxhXyC3Fy+cIi3awPFILRdYbksUL7p58IPdGFRbEKa7Mc5VtVhYWFNz2fET0ifIyDxA== 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 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=G3XQwXAHJy7GzCPDUQNM1GXGisSr3ZK/tvX5eovg+7Q=; b=kNxjrcsp0r7+p3tKDOsUNwz7H75Cg+HC5Wjqkgbzv/eaWU9bypQg14bb2CGLo6rHiZTvCbJLuX8EXh2TeKvv9+YP2KZxN5D3r3uECNRpVxjpC6Jsz/kQIpnrQPSOTmdFGBGE3LOyCht4cxos3yJAQaL9wBQRuW9sE8woYURr46c= Received: from MW4PR04CA0322.namprd04.prod.outlook.com (2603:10b6:303:82::27) by LV8PR12MB9232.namprd12.prod.outlook.com (2603:10b6:408:182::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Thu, 22 Jun 2023 03:53:16 +0000 Received: from CO1PEPF000042AB.namprd03.prod.outlook.com (2603:10b6:303:82:cafe::6e) by MW4PR04CA0322.outlook.office365.com (2603:10b6:303:82::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24 via Frontend Transport; Thu, 22 Jun 2023 03:53: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 CO1PEPF000042AB.mail.protection.outlook.com (10.167.243.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.17 via Frontend Transport; Thu, 22 Jun 2023 03:53:15 +0000 Received: from ethanolx7ea3host.amd.com (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.23; Wed, 21 Jun 2023 22:53:14 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v6 05/27] cxl: Rename member @dport of struct cxl_dport to @dport_dev Date: Wed, 21 Jun 2023 22:51:04 -0500 Message-ID: <20230622035126.4130151-6-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622035126.4130151-1-terry.bowman@amd.com> References: <20230622035126.4130151-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: CO1PEPF000042AB:EE_|LV8PR12MB9232:EE_ X-MS-Office365-Filtering-Correlation-Id: 7cb0789f-579c-4968-0238-08db72d43593 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1sC/72IVoWGYMdpYAEdQ/CiBpZxh289da8RYfQbtlqY9YaJXit43oX+8l52OZBLe12MhKSOsmXj0HyGJ8QqzttnoTiCjYeMAj7xrAycPDjJfHtif564aunXsN4KWIf9CXW93RLy59w/OirNPJREKIZIpxpN+9dw+Kt/eVwGIOUCYB46UYJjnGXwmhO7xzVAkQZzSIak4y1SKFm6vdazqCNdJXAa8skpznqzmSjT7q99XTEy16IkHpXrJAJwletKjaq3Svx5w/C7CW/JjwjQd9oFCJKiasSVkUEiifoGDcafN/Azf+v1H4URG7TJ4EPBGWTIiuNe0ffLzRPzr8yvG2k/id/jPq7/g5HdPBOurtHlIhBdJ+ZV90yE4TRoE3hj8vcx6+7bKdvxULzEvUSGB4xkAWXn+33kDdfD4PMF9CoiwxHQN5isk0bPkMMInJM0/KjF9IRSFrOwvG0BAArglcSlowZ2Ien/QyfpUksFFtxr/eAvKUOWvm2K4JYMtvSX4ny/AQ9U37zjGDL6l9ERaUJ/fg+6WtNNPrTvjlxJSiXGD/+ky68m21vx9M+mNOTxC31LGU9cgJ1NdfI6PST/JHJiPqhh3CvFZdWTfDmzWPX5L3TuWmx7f1l2WREZwrHRdRthqzItTE++GU8Cd8hx2dbpHfAFrTDTqh8/zHJQlMPYvfv0Hl7IRhdX+dtfBy9lUw0XYjU+Nt+cxIIsthpOuPaOrgISY8iyFTzUnM+cN6oW4E6LJwnGhZ2IC8as3txc/lvHJ794JLCcOLeQ133vizw== 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:(13230028)(4636009)(136003)(376002)(396003)(39860400002)(346002)(451199021)(46966006)(36840700001)(40470700004)(82310400005)(7696005)(4326008)(70586007)(70206006)(478600001)(36756003)(6666004)(316002)(54906003)(40460700003)(110136005)(86362001)(83380400001)(426003)(26005)(1076003)(47076005)(336012)(16526019)(186003)(2616005)(82740400003)(356005)(5660300002)(81166007)(2906002)(41300700001)(8676002)(8936002)(7416002)(36860700001)(44832011)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2023 03:53:15.8954 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7cb0789f-579c-4968-0238-08db72d43593 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: CO1PEPF000042AB.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9232 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter Reading code like dport->dport does not immediately suggest that this points to the corresponding device structure of the dport. Rename struct member @dport to @dport_dev. While at it, also rename @new argument of add_dport() to @dport. This better describes the variable as a dport (e.g. new->dport becomes to dport->dport_dev). Co-developed-by: Terry Bowman Signed-off-by: Terry Bowman Signed-off-by: Robert Richter Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang --- drivers/cxl/core/port.c | 20 ++++++++++---------- drivers/cxl/core/region.c | 4 ++-- drivers/cxl/cxl.h | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 76888c75dae4..7d3079f5b7b5 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -605,7 +605,7 @@ static int devm_cxl_link_parent_dport(struct device *host, if (!parent_dport) return 0; - rc = sysfs_create_link(&port->dev.kobj, &parent_dport->dport->kobj, + rc = sysfs_create_link(&port->dev.kobj, &parent_dport->dport_dev->kobj, "parent_dport"); if (rc) return rc; @@ -658,7 +658,7 @@ static struct cxl_port *cxl_port_alloc(struct device *uport, if (iter->host_bridge) port->host_bridge = iter->host_bridge; else if (parent_dport->rch) - port->host_bridge = parent_dport->dport; + port->host_bridge = parent_dport->dport_dev; else port->host_bridge = iter->uport; dev_dbg(uport, "host-bridge: %s\n", dev_name(port->host_bridge)); @@ -847,22 +847,22 @@ static struct cxl_dport *find_dport(struct cxl_port *port, int id) return NULL; } -static int add_dport(struct cxl_port *port, struct cxl_dport *new) +static int add_dport(struct cxl_port *port, struct cxl_dport *dport) { struct cxl_dport *dup; int rc; device_lock_assert(&port->dev); - dup = find_dport(port, new->port_id); + dup = find_dport(port, dport->port_id); if (dup) { dev_err(&port->dev, "unable to add dport%d-%s non-unique port id (%s)\n", - new->port_id, dev_name(new->dport), - dev_name(dup->dport)); + dport->port_id, dev_name(dport->dport_dev), + dev_name(dup->dport_dev)); return -EBUSY; } - rc = xa_insert(&port->dports, (unsigned long)new->dport, new, + rc = xa_insert(&port->dports, (unsigned long)dport->dport_dev, dport, GFP_KERNEL); if (rc) return rc; @@ -895,8 +895,8 @@ static void cxl_dport_remove(void *data) struct cxl_dport *dport = data; struct cxl_port *port = dport->port; - xa_erase(&port->dports, (unsigned long) dport->dport); - put_device(dport->dport); + xa_erase(&port->dports, (unsigned long) dport->dport_dev); + put_device(dport->dport_dev); } static void cxl_dport_unlink(void *data) @@ -954,7 +954,7 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev, dev_dbg(dport_dev, "Component Registers found for dport: %pa\n", &component_reg_phys); - dport->dport = dport_dev; + dport->dport_dev = dport_dev; dport->port_id = port_id; dport->component_reg_phys = component_reg_phys; dport->port = port; diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index f822de44bee0..13cda989d944 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -1162,7 +1162,7 @@ static int cxl_port_setup_targets(struct cxl_port *port, dev_dbg(&cxlr->dev, "%s:%s: %s expected %s at %d\n", dev_name(port->uport), dev_name(&port->dev), dev_name(&cxlsd->cxld.dev), - dev_name(ep->dport->dport), + dev_name(ep->dport->dport_dev), cxl_rr->nr_targets_set); return -ENXIO; } @@ -1173,7 +1173,7 @@ static int cxl_port_setup_targets(struct cxl_port *port, cxl_rr->nr_targets_set += inc; dev_dbg(&cxlr->dev, "%s:%s target[%d] = %s for %s:%s @ %d\n", dev_name(port->uport), dev_name(&port->dev), - cxl_rr->nr_targets_set - 1, dev_name(ep->dport->dport), + cxl_rr->nr_targets_set - 1, dev_name(ep->dport->dport_dev), dev_name(&cxlmd->dev), dev_name(&cxled->cxld.dev), pos); return 0; diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index 7c8674079f1a..7232c2a0e27c 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -589,7 +589,7 @@ struct cxl_rcrb_info { /** * struct cxl_dport - CXL downstream port - * @dport: PCI bridge or firmware device representing the downstream link + * @dport_dev: PCI bridge or firmware device representing the downstream link * @port_id: unique hardware identifier for dport in decoder target list * @component_reg_phys: downstream port component registers * @rcrb: Data about the Root Complex Register Block layout @@ -597,7 +597,7 @@ struct cxl_rcrb_info { * @port: reference to cxl_port that contains this downstream port */ struct cxl_dport { - struct device *dport; + struct device *dport_dev; int port_id; resource_size_t component_reg_phys; struct cxl_rcrb_info rcrb; From patchwork Thu Jun 22 03:51:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13288218 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 047D3EB64DA for ; Thu, 22 Jun 2023 03:54:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230082AbjFVDyJ (ORCPT ); Wed, 21 Jun 2023 23:54:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230120AbjFVDyA (ORCPT ); Wed, 21 Jun 2023 23:54:00 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E868F19BF; Wed, 21 Jun 2023 20:53:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GlRmtfIm/nOHcZh2hsTBWOU+sSvkm4vhZDndAyv3DlJeWes3Z9z1y+Qhun0KS3datQLmPck/KzIzF1eiRIGqRR7MjH9FNxeL5r7sM5Uvayf+Ce5UGUBxf+5zcw4GNYHaf6m9Azt+NrBFqsXSj91B2ha/GX0YedaKJCupIQdO/VKdRFQGnNtwfOww4T8Sxc67NOUSnD8604F5JZTqsozqadkLAVTo/6Qs1P3no0rsvcWZ+WJb4rRvEoHIvxtiUBD8uKJkWjThoO7lVSCNivRmy+jltggEr38v86MzB9Ma/kh7XbVCQ9rPed/aKpCcvzpChgf+wcl46ixj91VdjoTnRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=YO8WyGZk2eYJ0XXgOqnwbTBu1J+vfDOORBTJBtxYdwA=; b=Cxpx0riH6gkIqEHf6qcAhUz1YzRYIW3/wrRvl4FuawpYMaa3kAUO4NtK/YzAGAnUrKb0n/dyyMm6fwpwNfV0l0pm84YKuMM7RZKGtVjezvQAPnA+cB4KpiGtb1U0BXzgthTsi2hsJPTFJhCcb+Xwxxbzj4qXy7ikHxdqsI1gkoVP9OnMUOTVG1oZfPyrT9xh/OYIGhvmp8CY3d1ms8ADUpxiUedcF/HKAZX0BaVhHrFUJmV3xss+cYysWtrnmyrARxFWUUKV97lyTQi0hh3sXGC0tpg1ZDpNzpiBoM56EmbbOWBdWObVBa3tCc7PRruEtkxtguc3xNc0t4+/QzsiWA== 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 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=YO8WyGZk2eYJ0XXgOqnwbTBu1J+vfDOORBTJBtxYdwA=; b=OjogZwEkX6QJ7cpk+EFMqLmP9KW4glTRrWphulfZwjMk3ecWRAYVvbxfRIUmui19oUqhpdB8GPfesZk0RtxsDJpEGZyO/RJKsfzPhif8mynZv21iKjkIBcFu5sUT4NPnDKQOvXhOzctLUqL7VTC6/62/lQUr0g8cO7n0riOqI7o= Received: from MW4PR04CA0321.namprd04.prod.outlook.com (2603:10b6:303:82::26) by SJ2PR12MB8927.namprd12.prod.outlook.com (2603:10b6:a03:547::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24; Thu, 22 Jun 2023 03:53:27 +0000 Received: from CO1PEPF000042AB.namprd03.prod.outlook.com (2603:10b6:303:82:cafe::80) by MW4PR04CA0321.outlook.office365.com (2603:10b6:303:82::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23 via Frontend Transport; Thu, 22 Jun 2023 03:53: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 CO1PEPF000042AB.mail.protection.outlook.com (10.167.243.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.17 via Frontend Transport; Thu, 22 Jun 2023 03:53:26 +0000 Received: from ethanolx7ea3host.amd.com (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.23; Wed, 21 Jun 2023 22:53:25 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v6 06/27] cxl: Rename 'uport' to 'uport_dev' Date: Wed, 21 Jun 2023 22:51:05 -0500 Message-ID: <20230622035126.4130151-7-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622035126.4130151-1-terry.bowman@amd.com> References: <20230622035126.4130151-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: CO1PEPF000042AB:EE_|SJ2PR12MB8927:EE_ X-MS-Office365-Filtering-Correlation-Id: 70c3e0a5-9f9c-4aa5-b97d-08db72d43c1c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bzumht6uAoRX9r/h6I85LTNjhIJiR9zQ6nZDy3Mkd57UzMMYtbv5LQW8BO9pQzf+Qat2peGNiIfW9nLzJqYUyx9Ykxt3U0ZCmy6YEQPYHFmnKox3siKMAKDrLVMMs9jYlKwDa+TZbpZ4UJU2j4XljogHw85N0mDGW7fyvl5XDRUx1e80NYoLPLLNh7qZInZOClTpYl2QU/WtRU1yNzTrXV4yl6OhcWtoOR5zD/+4KQ7VdnuxmeymAxc/C8CWFoGEUp7yUf94rTwIH5wKjk30UjJ7XhEPpWJBrju/gxssHXse24COnB9gaALoopP9a2FRalcrhvZ/cDTzDxid+ztEczsahxiQls6hBhc66VQ8We3aCXSsPCZPByFCF54lEUI/y6j5qZM7cSs1Lqh8HPdo4XHZiIEzpadbdULFcG7Re7IWVRvIFqUjQ61EOwUU6Z6oIFS3ZJxPDQT/RXpB1m37YNlvqkyCBxsgjHcHNhP6ycAn6R7EYKTluSCbL+lw/w/5wXS8dIGte6/8HWSomxsKYqOZpSUps1NKC3g+ktvn09q5OHHM63hEauBbTgb76ms0HXukxtVPP6ye3rMHclqqOysbElksL2kEm0uiWOr7O2npxJvckaPq4wTQ+mQoMl/kmtPEvKHYCBTeURnqbkGQmrGEsplkPGMqMzwj3oh3jiqVQCeYIxB4T6wnhs/T3rMj7J92fcXkfdoCVqjAYkOTSYOGWZeBheqqQyOsuEMFGyNki3nhMSOApFk3H8c0VztUJ7yl5MmdCEQzrv8oK05J+w== 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:(13230028)(4636009)(346002)(396003)(376002)(39860400002)(136003)(451199021)(46966006)(40470700004)(36840700001)(5660300002)(30864003)(40480700001)(47076005)(7416002)(44832011)(2906002)(1076003)(26005)(41300700001)(8936002)(8676002)(40460700003)(186003)(426003)(83380400001)(478600001)(82310400005)(81166007)(356005)(82740400003)(7696005)(336012)(36756003)(36860700001)(2616005)(316002)(86362001)(70586007)(4326008)(70206006)(16526019)(54906003)(110136005)(6666004)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2023 03:53:26.8487 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 70c3e0a5-9f9c-4aa5-b97d-08db72d43c1c 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: CO1PEPF000042AB.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8927 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Dan Williams For symmetry with the recent rename of ->dport_dev for a 'struct cxl_dport', add the "_dev" suffix to the ->uport property of a 'struct cxl_port'. These devices represent the downstream-port-device and upstream-port-device respectively in the CXL/PCIe topology. Signed-off-by: Dan Williams Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang --- drivers/cxl/core/pci.c | 4 +-- drivers/cxl/core/port.c | 61 +++++++++++++++++++---------------- drivers/cxl/core/region.c | 48 ++++++++++++++------------- drivers/cxl/cxl.h | 13 ++++---- drivers/cxl/cxlmem.h | 4 +-- drivers/cxl/mem.c | 2 +- drivers/cxl/port.c | 2 +- tools/testing/cxl/test/cxl.c | 20 ++++++------ tools/testing/cxl/test/mock.c | 10 +++--- 9 files changed, 86 insertions(+), 78 deletions(-) diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index 67f4ab6daa34..375f01c6cad6 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -67,7 +67,7 @@ static int match_add_dports(struct pci_dev *pdev, void *data) /** * devm_cxl_port_enumerate_dports - enumerate downstream ports of the upstream port - * @port: cxl_port whose ->uport is the upstream of dports to be enumerated + * @port: cxl_port whose ->uport_dev is the upstream of dports to be enumerated * * Returns a positive number of dports enumerated or a negative error * code. @@ -622,7 +622,7 @@ static int cxl_cdat_read_table(struct device *dev, */ void read_cdat_data(struct cxl_port *port) { - struct cxl_memdev *cxlmd = to_cxl_memdev(port->uport); + struct cxl_memdev *cxlmd = to_cxl_memdev(port->uport_dev); struct device *host = cxlmd->dev.parent; struct device *dev = &port->dev; struct pci_doe_mb *cdat_doe; diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 7d3079f5b7b5..cdfe0ea7a2e9 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -561,9 +561,9 @@ static void unregister_port(void *_port) * unregistered while holding their parent port lock. */ if (!parent) - lock_dev = port->uport; + lock_dev = port->uport_dev; else if (is_cxl_root(parent)) - lock_dev = parent->uport; + lock_dev = parent->uport_dev; else lock_dev = &parent->dev; @@ -583,7 +583,8 @@ static int devm_cxl_link_uport(struct device *host, struct cxl_port *port) { int rc; - rc = sysfs_create_link(&port->dev.kobj, &port->uport->kobj, "uport"); + rc = sysfs_create_link(&port->dev.kobj, &port->uport_dev->kobj, + "uport"); if (rc) return rc; return devm_add_action_or_reset(host, cxl_unlink_uport, port); @@ -614,7 +615,7 @@ static int devm_cxl_link_parent_dport(struct device *host, static struct lock_class_key cxl_port_key; -static struct cxl_port *cxl_port_alloc(struct device *uport, +static struct cxl_port *cxl_port_alloc(struct device *uport_dev, resource_size_t component_reg_phys, struct cxl_dport *parent_dport) { @@ -630,7 +631,7 @@ static struct cxl_port *cxl_port_alloc(struct device *uport, if (rc < 0) goto err; port->id = rc; - port->uport = uport; + port->uport_dev = uport_dev; /* * The top-level cxl_port "cxl_root" does not have a cxl_port as @@ -660,10 +661,11 @@ static struct cxl_port *cxl_port_alloc(struct device *uport, else if (parent_dport->rch) port->host_bridge = parent_dport->dport_dev; else - port->host_bridge = iter->uport; - dev_dbg(uport, "host-bridge: %s\n", dev_name(port->host_bridge)); + port->host_bridge = iter->uport_dev; + dev_dbg(uport_dev, "host-bridge: %s\n", + dev_name(port->host_bridge)); } else - dev->parent = uport; + dev->parent = uport_dev; port->component_reg_phys = component_reg_phys; ida_init(&port->decoder_ida); @@ -687,7 +689,7 @@ static struct cxl_port *cxl_port_alloc(struct device *uport, } static struct cxl_port *__devm_cxl_add_port(struct device *host, - struct device *uport, + struct device *uport_dev, resource_size_t component_reg_phys, struct cxl_dport *parent_dport) { @@ -695,12 +697,12 @@ static struct cxl_port *__devm_cxl_add_port(struct device *host, struct device *dev; int rc; - port = cxl_port_alloc(uport, component_reg_phys, parent_dport); + port = cxl_port_alloc(uport_dev, component_reg_phys, parent_dport); if (IS_ERR(port)) return port; dev = &port->dev; - if (is_cxl_memdev(uport)) + if (is_cxl_memdev(uport_dev)) rc = dev_set_name(dev, "endpoint%d", port->id); else if (parent_dport) rc = dev_set_name(dev, "port%d", port->id); @@ -735,28 +737,29 @@ static struct cxl_port *__devm_cxl_add_port(struct device *host, /** * devm_cxl_add_port - register a cxl_port in CXL memory decode hierarchy * @host: host device for devm operations - * @uport: "physical" device implementing this upstream port + * @uport_dev: "physical" device implementing this upstream port * @component_reg_phys: (optional) for configurable cxl_port instances * @parent_dport: next hop up in the CXL memory decode hierarchy */ -struct cxl_port *devm_cxl_add_port(struct device *host, struct device *uport, +struct cxl_port *devm_cxl_add_port(struct device *host, + struct device *uport_dev, resource_size_t component_reg_phys, struct cxl_dport *parent_dport) { struct cxl_port *port, *parent_port; - port = __devm_cxl_add_port(host, uport, component_reg_phys, + port = __devm_cxl_add_port(host, uport_dev, component_reg_phys, parent_dport); parent_port = parent_dport ? parent_dport->port : NULL; if (IS_ERR(port)) { - dev_dbg(uport, "Failed to add%s%s%s: %ld\n", + dev_dbg(uport_dev, "Failed to add%s%s%s: %ld\n", parent_port ? " port to " : "", parent_port ? dev_name(&parent_port->dev) : "", parent_port ? "" : " root port", PTR_ERR(port)); } else { - dev_dbg(uport, "%s added%s%s%s\n", + dev_dbg(uport_dev, "%s added%s%s%s\n", dev_name(&port->dev), parent_port ? " to " : "", parent_port ? dev_name(&parent_port->dev) : "", @@ -773,33 +776,34 @@ struct pci_bus *cxl_port_to_pci_bus(struct cxl_port *port) if (is_cxl_root(port)) return NULL; - if (dev_is_pci(port->uport)) { - struct pci_dev *pdev = to_pci_dev(port->uport); + if (dev_is_pci(port->uport_dev)) { + struct pci_dev *pdev = to_pci_dev(port->uport_dev); return pdev->subordinate; } - return xa_load(&cxl_root_buses, (unsigned long)port->uport); + return xa_load(&cxl_root_buses, (unsigned long)port->uport_dev); } EXPORT_SYMBOL_NS_GPL(cxl_port_to_pci_bus, CXL); -static void unregister_pci_bus(void *uport) +static void unregister_pci_bus(void *uport_dev) { - xa_erase(&cxl_root_buses, (unsigned long)uport); + xa_erase(&cxl_root_buses, (unsigned long)uport_dev); } -int devm_cxl_register_pci_bus(struct device *host, struct device *uport, +int devm_cxl_register_pci_bus(struct device *host, struct device *uport_dev, struct pci_bus *bus) { int rc; - if (dev_is_pci(uport)) + if (dev_is_pci(uport_dev)) return -EINVAL; - rc = xa_insert(&cxl_root_buses, (unsigned long)uport, bus, GFP_KERNEL); + rc = xa_insert(&cxl_root_buses, (unsigned long)uport_dev, bus, + GFP_KERNEL); if (rc) return rc; - return devm_add_action_or_reset(host, unregister_pci_bus, uport); + return devm_add_action_or_reset(host, unregister_pci_bus, uport_dev); } EXPORT_SYMBOL_NS_GPL(devm_cxl_register_pci_bus, CXL); @@ -920,7 +924,7 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev, int rc; if (is_cxl_root(port)) - host = port->uport; + host = port->uport_dev; else host = &port->dev; @@ -1374,7 +1378,7 @@ static int add_port_attach_ep(struct cxl_memdev *cxlmd, rc = PTR_ERR(port); else { dev_dbg(&cxlmd->dev, "add to new port %s:%s\n", - dev_name(&port->dev), dev_name(port->uport)); + dev_name(&port->dev), dev_name(port->uport_dev)); rc = cxl_add_ep(dport, &cxlmd->dev); if (rc == -EBUSY) { /* @@ -1436,7 +1440,8 @@ int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd) if (port) { dev_dbg(&cxlmd->dev, "found already registered port %s:%s\n", - dev_name(&port->dev), dev_name(port->uport)); + dev_name(&port->dev), + dev_name(port->uport_dev)); rc = cxl_add_ep(dport, &cxlmd->dev); /* diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 13cda989d944..39825e5301d0 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -906,10 +906,10 @@ static int cxl_port_attach_region(struct cxl_port *port, dev_dbg(&cxlr->dev, "%s:%s %s add: %s:%s @ %d next: %s nr_eps: %d nr_targets: %d\n", - dev_name(port->uport), dev_name(&port->dev), + dev_name(port->uport_dev), dev_name(&port->dev), dev_name(&cxld->dev), dev_name(&cxlmd->dev), dev_name(&cxled->cxld.dev), pos, - ep ? ep->next ? dev_name(ep->next->uport) : + ep ? ep->next ? dev_name(ep->next->uport_dev) : dev_name(&cxlmd->dev) : "none", cxl_rr->nr_eps, cxl_rr->nr_targets); @@ -984,7 +984,7 @@ static int check_last_peer(struct cxl_endpoint_decoder *cxled, */ if (pos < distance) { dev_dbg(&cxlr->dev, "%s:%s: cannot host %s:%s at %d\n", - dev_name(port->uport), dev_name(&port->dev), + dev_name(port->uport_dev), dev_name(&port->dev), dev_name(&cxlmd->dev), dev_name(&cxled->cxld.dev), pos); return -ENXIO; } @@ -994,7 +994,7 @@ static int check_last_peer(struct cxl_endpoint_decoder *cxled, if (ep->dport != ep_peer->dport) { dev_dbg(&cxlr->dev, "%s:%s: %s:%s pos %d mismatched peer %s:%s\n", - dev_name(port->uport), dev_name(&port->dev), + dev_name(port->uport_dev), dev_name(&port->dev), dev_name(&cxlmd->dev), dev_name(&cxled->cxld.dev), pos, dev_name(&cxlmd_peer->dev), dev_name(&cxled_peer->cxld.dev)); @@ -1026,7 +1026,7 @@ static int cxl_port_setup_targets(struct cxl_port *port, */ if (!is_power_of_2(cxl_rr->nr_targets)) { dev_dbg(&cxlr->dev, "%s:%s: invalid target count %d\n", - dev_name(port->uport), dev_name(&port->dev), + dev_name(port->uport_dev), dev_name(&port->dev), cxl_rr->nr_targets); return -EINVAL; } @@ -1076,7 +1076,7 @@ static int cxl_port_setup_targets(struct cxl_port *port, rc = granularity_to_eig(parent_ig, &peig); if (rc) { dev_dbg(&cxlr->dev, "%s:%s: invalid parent granularity: %d\n", - dev_name(parent_port->uport), + dev_name(parent_port->uport_dev), dev_name(&parent_port->dev), parent_ig); return rc; } @@ -1084,7 +1084,7 @@ static int cxl_port_setup_targets(struct cxl_port *port, rc = ways_to_eiw(parent_iw, &peiw); if (rc) { dev_dbg(&cxlr->dev, "%s:%s: invalid parent interleave: %d\n", - dev_name(parent_port->uport), + dev_name(parent_port->uport_dev), dev_name(&parent_port->dev), parent_iw); return rc; } @@ -1093,7 +1093,7 @@ static int cxl_port_setup_targets(struct cxl_port *port, rc = ways_to_eiw(iw, &eiw); if (rc) { dev_dbg(&cxlr->dev, "%s:%s: invalid port interleave: %d\n", - dev_name(port->uport), dev_name(&port->dev), iw); + dev_name(port->uport_dev), dev_name(&port->dev), iw); return rc; } @@ -1113,7 +1113,7 @@ static int cxl_port_setup_targets(struct cxl_port *port, rc = eig_to_granularity(eig, &ig); if (rc) { dev_dbg(&cxlr->dev, "%s:%s: invalid interleave: %d\n", - dev_name(port->uport), dev_name(&port->dev), + dev_name(port->uport_dev), dev_name(&port->dev), 256 << eig); return rc; } @@ -1126,11 +1126,11 @@ static int cxl_port_setup_targets(struct cxl_port *port, ((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_name(&port->dev), + 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", - dev_name(port->uport), dev_name(&port->dev), + dev_name(port->uport_dev), dev_name(&port->dev), __func__, cxld->interleave_ways, cxld->interleave_granularity, (cxld->flags & CXL_DECODER_F_ENABLE) ? @@ -1147,20 +1147,20 @@ static int cxl_port_setup_targets(struct cxl_port *port, .end = p->res->end, }; } - dev_dbg(&cxlr->dev, "%s:%s iw: %d ig: %d\n", dev_name(port->uport), + dev_dbg(&cxlr->dev, "%s:%s iw: %d ig: %d\n", dev_name(port->uport_dev), dev_name(&port->dev), iw, ig); add_target: if (cxl_rr->nr_targets_set == cxl_rr->nr_targets) { dev_dbg(&cxlr->dev, "%s:%s: targets full trying to add %s:%s at %d\n", - dev_name(port->uport), dev_name(&port->dev), + dev_name(port->uport_dev), dev_name(&port->dev), dev_name(&cxlmd->dev), dev_name(&cxled->cxld.dev), pos); return -ENXIO; } if (test_bit(CXL_REGION_F_AUTO, &cxlr->flags)) { if (cxlsd->target[cxl_rr->nr_targets_set] != ep->dport) { dev_dbg(&cxlr->dev, "%s:%s: %s expected %s at %d\n", - dev_name(port->uport), dev_name(&port->dev), + dev_name(port->uport_dev), dev_name(&port->dev), dev_name(&cxlsd->cxld.dev), dev_name(ep->dport->dport_dev), cxl_rr->nr_targets_set); @@ -1172,7 +1172,7 @@ static int cxl_port_setup_targets(struct cxl_port *port, out_target_set: cxl_rr->nr_targets_set += inc; dev_dbg(&cxlr->dev, "%s:%s target[%d] = %s for %s:%s @ %d\n", - dev_name(port->uport), dev_name(&port->dev), + dev_name(port->uport_dev), dev_name(&port->dev), cxl_rr->nr_targets_set - 1, dev_name(ep->dport->dport_dev), dev_name(&cxlmd->dev), dev_name(&cxled->cxld.dev), pos); @@ -1492,7 +1492,7 @@ static int cmp_decode_pos(const void *a, const void *b) if (!dev) { struct range *range = &cxled_a->cxld.hpa_range; - dev_err(port->uport, + dev_err(port->uport_dev, "failed to find decoder that maps %#llx-%#llx\n", range->start, range->end); goto err; @@ -1507,14 +1507,15 @@ static int cmp_decode_pos(const void *a, const void *b) put_device(dev); if (a_pos < 0 || b_pos < 0) { - dev_err(port->uport, + dev_err(port->uport_dev, "failed to find shared decoder for %s and %s\n", dev_name(cxlmd_a->dev.parent), dev_name(cxlmd_b->dev.parent)); goto err; } - dev_dbg(port->uport, "%s comes %s %s\n", dev_name(cxlmd_a->dev.parent), + dev_dbg(port->uport_dev, "%s comes %s %s\n", + dev_name(cxlmd_a->dev.parent), a_pos - b_pos < 0 ? "before" : "after", dev_name(cxlmd_b->dev.parent)); @@ -2059,11 +2060,11 @@ static struct cxl_region *devm_cxl_add_region(struct cxl_root_decoder *cxlrd, if (rc) goto err; - rc = devm_add_action_or_reset(port->uport, unregister_region, cxlr); + rc = devm_add_action_or_reset(port->uport_dev, unregister_region, cxlr); if (rc) return ERR_PTR(rc); - dev_dbg(port->uport, "%s: created %s\n", + dev_dbg(port->uport_dev, "%s: created %s\n", dev_name(&cxlrd->cxlsd.cxld.dev), dev_name(dev)); return cxlr; @@ -2191,7 +2192,7 @@ static ssize_t delete_region_store(struct device *dev, if (IS_ERR(cxlr)) return PTR_ERR(cxlr); - devm_release_action(port->uport, unregister_region, cxlr); + devm_release_action(port->uport_dev, unregister_region, cxlr); put_device(&cxlr->dev); return len; @@ -2356,7 +2357,8 @@ int cxl_get_poison_by_endpoint(struct cxl_port *port) rc = device_for_each_child(&port->dev, &ctx, poison_by_decoder); if (rc == 1) - rc = cxl_get_poison_unmapped(to_cxl_memdev(port->uport), &ctx); + rc = cxl_get_poison_unmapped(to_cxl_memdev(port->uport_dev), + &ctx); up_read(&cxl_region_rwsem); return rc; @@ -2732,7 +2734,7 @@ static struct cxl_region *construct_region(struct cxl_root_decoder *cxlrd, err: up_write(&cxl_region_rwsem); - devm_release_action(port->uport, unregister_region, cxlr); + devm_release_action(port->uport_dev, unregister_region, cxlr); return ERR_PTR(rc); } diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index 7232c2a0e27c..754cfe59ae37 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -536,7 +536,7 @@ struct cxl_dax_region { * downstream port devices to construct a CXL memory * decode hierarchy. * @dev: this port's device - * @uport: PCI or platform device implementing the upstream port capability + * @uport_dev: PCI or platform device implementing the upstream port capability * @host_bridge: Shortcut to the platform attach point for this port * @id: id for port device-name * @dports: cxl_dport instances referenced by decoders @@ -555,7 +555,7 @@ struct cxl_dax_region { */ struct cxl_port { struct device dev; - struct device *uport; + struct device *uport_dev; struct device *host_bridge; int id; struct xarray dports; @@ -641,21 +641,22 @@ struct cxl_region_ref { /* * The platform firmware device hosting the root is also the top of the * CXL port topology. All other CXL ports have another CXL port as their - * parent and their ->uport / host device is out-of-line of the port + * parent and their ->uport_dev / host device is out-of-line of the port * ancestry. */ static inline bool is_cxl_root(struct cxl_port *port) { - return port->uport == port->dev.parent; + return port->uport_dev == port->dev.parent; } bool is_cxl_port(const struct device *dev); struct cxl_port *to_cxl_port(const struct device *dev); struct pci_bus; -int devm_cxl_register_pci_bus(struct device *host, struct device *uport, +int devm_cxl_register_pci_bus(struct device *host, struct device *uport_dev, struct pci_bus *bus); struct pci_bus *cxl_port_to_pci_bus(struct cxl_port *port); -struct cxl_port *devm_cxl_add_port(struct device *host, struct device *uport, +struct cxl_port *devm_cxl_add_port(struct device *host, + struct device *uport_dev, resource_size_t component_reg_phys, struct cxl_dport *parent_dport); struct cxl_port *find_cxl_root(struct cxl_port *port); diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h index a2845a7a69d8..76743016b64c 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -72,13 +72,13 @@ cxled_to_memdev(struct cxl_endpoint_decoder *cxled) { struct cxl_port *port = to_cxl_port(cxled->cxld.dev.parent); - return to_cxl_memdev(port->uport); + return to_cxl_memdev(port->uport_dev); } bool is_cxl_memdev(const struct device *dev); static inline bool is_cxl_endpoint(struct cxl_port *port) { - return is_cxl_memdev(port->uport); + return is_cxl_memdev(port->uport_dev); } struct cxl_memdev *devm_cxl_add_memdev(struct cxl_dev_state *cxlds); diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c index 45d4c32d78b0..4cc461c22b8b 100644 --- a/drivers/cxl/mem.c +++ b/drivers/cxl/mem.c @@ -163,7 +163,7 @@ static int cxl_mem_probe(struct device *dev) } if (dport->rch) - endpoint_parent = parent_port->uport; + endpoint_parent = parent_port->uport_dev; else endpoint_parent = &parent_port->dev; diff --git a/drivers/cxl/port.c b/drivers/cxl/port.c index c23b6164e1c0..4cef2bf45ad2 100644 --- a/drivers/cxl/port.c +++ b/drivers/cxl/port.c @@ -91,7 +91,7 @@ static int cxl_switch_port_probe(struct cxl_port *port) static int cxl_endpoint_port_probe(struct cxl_port *port) { struct cxl_endpoint_dvsec_info info = { .port = port }; - struct cxl_memdev *cxlmd = to_cxl_memdev(port->uport); + 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; diff --git a/tools/testing/cxl/test/cxl.c b/tools/testing/cxl/test/cxl.c index f5c04787bcc8..4f62eb55f8b8 100644 --- a/tools/testing/cxl/test/cxl.c +++ b/tools/testing/cxl/test/cxl.c @@ -754,7 +754,7 @@ static void mock_init_hdm_decoder(struct cxl_decoder *cxld) /* check is endpoint is attach to host-bridge0 */ port = cxled_to_port(cxled); do { - if (port->uport == &cxl_host_bridge[0]->dev) { + if (port->uport_dev == &cxl_host_bridge[0]->dev) { hb0 = true; break; } @@ -889,7 +889,7 @@ static int mock_cxl_enumerate_decoders(struct cxl_hdm *cxlhdm, mock_init_hdm_decoder(cxld); if (target_count) { - rc = device_for_each_child(port->uport, &ctx, + rc = device_for_each_child(port->uport_dev, &ctx, map_targets); if (rc) { put_device(&cxld->dev); @@ -919,29 +919,29 @@ static int mock_cxl_port_enumerate_dports(struct cxl_port *port) int i, array_size; if (port->depth == 1) { - if (is_multi_bridge(port->uport)) { + if (is_multi_bridge(port->uport_dev)) { array_size = ARRAY_SIZE(cxl_root_port); array = cxl_root_port; - } else if (is_single_bridge(port->uport)) { + } else if (is_single_bridge(port->uport_dev)) { array_size = ARRAY_SIZE(cxl_root_single); array = cxl_root_single; } else { dev_dbg(&port->dev, "%s: unknown bridge type\n", - dev_name(port->uport)); + dev_name(port->uport_dev)); return -ENXIO; } } else if (port->depth == 2) { struct cxl_port *parent = to_cxl_port(port->dev.parent); - if (is_multi_bridge(parent->uport)) { + if (is_multi_bridge(parent->uport_dev)) { array_size = ARRAY_SIZE(cxl_switch_dport); array = cxl_switch_dport; - } else if (is_single_bridge(parent->uport)) { + } else if (is_single_bridge(parent->uport_dev)) { array_size = ARRAY_SIZE(cxl_swd_single); array = cxl_swd_single; } else { dev_dbg(&port->dev, "%s: unknown bridge type\n", - dev_name(port->uport)); + dev_name(port->uport_dev)); return -ENXIO; } } else { @@ -954,9 +954,9 @@ static int mock_cxl_port_enumerate_dports(struct cxl_port *port) struct platform_device *pdev = array[i]; struct cxl_dport *dport; - if (pdev->dev.parent != port->uport) { + if (pdev->dev.parent != port->uport_dev) { dev_dbg(&port->dev, "%s: mismatch parent %s\n", - dev_name(port->uport), + dev_name(port->uport_dev), dev_name(pdev->dev.parent)); continue; } diff --git a/tools/testing/cxl/test/mock.c b/tools/testing/cxl/test/mock.c index dbeef5c6f606..da554df50bac 100644 --- a/tools/testing/cxl/test/mock.c +++ b/tools/testing/cxl/test/mock.c @@ -139,7 +139,7 @@ struct cxl_hdm *__wrap_devm_cxl_setup_hdm(struct cxl_port *port, struct cxl_hdm *cxlhdm; struct cxl_mock_ops *ops = get_cxl_mock_ops(&index); - if (ops && ops->is_mock_port(port->uport)) + if (ops && ops->is_mock_port(port->uport_dev)) cxlhdm = ops->devm_cxl_setup_hdm(port, info); else cxlhdm = devm_cxl_setup_hdm(port, info); @@ -154,7 +154,7 @@ int __wrap_devm_cxl_enable_hdm(struct cxl_port *port, struct cxl_hdm *cxlhdm) int index, rc; struct cxl_mock_ops *ops = get_cxl_mock_ops(&index); - if (ops && ops->is_mock_port(port->uport)) + if (ops && ops->is_mock_port(port->uport_dev)) rc = 0; else rc = devm_cxl_enable_hdm(port, cxlhdm); @@ -169,7 +169,7 @@ int __wrap_devm_cxl_add_passthrough_decoder(struct cxl_port *port) int rc, index; struct cxl_mock_ops *ops = get_cxl_mock_ops(&index); - if (ops && ops->is_mock_port(port->uport)) + if (ops && ops->is_mock_port(port->uport_dev)) rc = ops->devm_cxl_add_passthrough_decoder(port); else rc = devm_cxl_add_passthrough_decoder(port); @@ -186,7 +186,7 @@ int __wrap_devm_cxl_enumerate_decoders(struct cxl_hdm *cxlhdm, struct cxl_port *port = cxlhdm->port; struct cxl_mock_ops *ops = get_cxl_mock_ops(&index); - if (ops && ops->is_mock_port(port->uport)) + if (ops && ops->is_mock_port(port->uport_dev)) rc = ops->devm_cxl_enumerate_decoders(cxlhdm, info); else rc = devm_cxl_enumerate_decoders(cxlhdm, info); @@ -201,7 +201,7 @@ int __wrap_devm_cxl_port_enumerate_dports(struct cxl_port *port) int rc, index; struct cxl_mock_ops *ops = get_cxl_mock_ops(&index); - if (ops && ops->is_mock_port(port->uport)) + if (ops && ops->is_mock_port(port->uport_dev)) rc = ops->devm_cxl_port_enumerate_dports(port); else rc = devm_cxl_port_enumerate_dports(port); From patchwork Thu Jun 22 03:51:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13288219 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF11BEB64D8 for ; Thu, 22 Jun 2023 03:54:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230121AbjFVDye (ORCPT ); Wed, 21 Jun 2023 23:54:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230129AbjFVDyS (ORCPT ); Wed, 21 Jun 2023 23:54:18 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2062.outbound.protection.outlook.com [40.107.244.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96F5A268A; Wed, 21 Jun 2023 20:53:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JNM63QIIo8eNVXi4VL+Lh4yMFURiyBeaw2fvPMybY/dKib1OcArw3YhqsXzyaZ2mi6eNoY8H5cBItNtcilqx30QepBrJ8dh/c+MSX4yk5Vjz6XHvctXmQlbPQFg1ZRi/SAIbAUL0blMYj09FElgCRQ4ewwzwL7MdP70eAtwd4ddqrK123hOSGBfDIupmC80n0SJQXOrZbKjT2Ll3O94gRTpQZYEc57JBObHvH7/3F+VOouYIyo3KUcAOD82zN9UOcSHw+dmVky62d5cTbB3W955IDH+iM2clCuuFZw7mIwjbAsjAPah09uAPi4OnbjTHtHGTbSMa0upyaguSxgkeqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=Wq/u5D+bx9jIqXYGIpZZFSmx4bnSQZCU9S92xb8m9GA=; b=gbOPaqTh/jKIMoDwtqcrNGpCKQqkFnhFP8RJBS8Zif7sjDG2zxajCrFLagGI6AWyKSwUBx2+CxRXCZzvc/j8BVXCmur+3pi1n9Up0kIvd91YTv3P2kbMGJI0gHAGa4VcSOD0zmbtfuhhn+vtnljgE+iNE4WVXVI5G0YCkgjyvfSwsztzDqqGAyozmqXnuV0vd1ewqhOSzXwBF0qbr0fLCZNMFYmyn+jlOGZVTWq4zE5vUJCUFDwHktrw2QT6mkcW7wtotWj7vJUA7nwOQ2p1GfE/LpzMYtI8AZUW4L9/LM0coMWBxvxYfakn43cq5Ux3mVfLYZ9lAxqUNlBzNZZ1vw== 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 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=Wq/u5D+bx9jIqXYGIpZZFSmx4bnSQZCU9S92xb8m9GA=; b=M5vGL41NSkNsOH48wT4Gv5HfS0rKbyEkTVADzRUqoa6SDkqP3RP8f1KorQxEUz408vxQpq5MjQypI028juT0lp754lmQ/uO2z7QzcortINl6aL2i9Z8l8gqxHkL9kHJzAzMHyW5B/iUkOgg2lVQdi26Bp8RRVzrVBCQWN5LQp0o= Received: from SJ0PR03CA0002.namprd03.prod.outlook.com (2603:10b6:a03:33a::7) by DM4PR12MB6160.namprd12.prod.outlook.com (2603:10b6:8:a7::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.37; Thu, 22 Jun 2023 03:53:38 +0000 Received: from CO1PEPF000042A8.namprd03.prod.outlook.com (2603:10b6:a03:33a:cafe::35) by SJ0PR03CA0002.outlook.office365.com (2603:10b6:a03:33a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24 via Frontend Transport; Thu, 22 Jun 2023 03:53:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000042A8.mail.protection.outlook.com (10.167.243.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.17 via Frontend Transport; Thu, 22 Jun 2023 03:53:38 +0000 Received: from ethanolx7ea3host.amd.com (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.23; Wed, 21 Jun 2023 22:53:36 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v6 07/27] cxl/core/regs: Add @dev to cxl_register_map Date: Wed, 21 Jun 2023 22:51:06 -0500 Message-ID: <20230622035126.4130151-8-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622035126.4130151-1-terry.bowman@amd.com> References: <20230622035126.4130151-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: CO1PEPF000042A8:EE_|DM4PR12MB6160:EE_ X-MS-Office365-Filtering-Correlation-Id: d45ebc84-c78b-49ee-c877-08db72d442c8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qi69Uhj6xsIxlclUDCBnl0QRlg/1nkUUZAhUrFJbC7OFK0G8bmyXn3Q3Vp9z+TvJ3iXiBH9jofkx/7M/OACzWLFDvcbOs0tHPbbhQ+nW4BE4oQEMAolX0+3gB6kCZrBYe+IaHuSgFHvY3yWSE3BtNkTGNBc7Z30U447bMgNvfgHVcoB3ZaJNHD/9voWDfpHxpgoGvk7vosCFMqM27XuBCGyvGmKleQ7Myo9dziiOFxJJn5KWhJ1WaA06SW5h2bUpNwdRG6HavTQtmXbnGoWRSoPqcy5fqGO3aa/5Q7NY+PKg9rXqLqnGPMqPlKyInsDJFklyqExerlMXljzTktDr7AjhO6VryP+8+IIxCiIMYT4lMxcCXnlvXBLAKiLE1bj2VbraymFWtxU44YuFg59bNc5W5+ydr144kebuMf5iUFOXRNR1h1+z5c9wLhLs2ruhbIhsqi9ZR1u3QzLwUTjcEwzC6QPZXe4QGHGyrcxdJMeu2292GO//TcAsouXyzceIgnpncZXPw6x/sW/K7lK/uA4zHwuqaqAfd2OOLzZGEbZcU79V6PFfHBeW1Iad2B/TU6FIuEDMsx+EAOHtEFDhAEDuQaWmtp8wdEdeYKLtI2HF6rmWaMAa3v4mibubhcxPU2PCgEq7TYJ6HKLQpR95jmN4Zn8Lp/HIXgLqWSAdRsqOSzdcRn5f1W9Un+jBiINp3ACqKz2PYn0m1XsJuM+Zd3F9WkbAERqBldndsJnH2xXH82vAw2JOCIVJOaEe3vTlKMD0vb++XavpHudDWbnhbw== 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:(13230028)(4636009)(39860400002)(136003)(376002)(396003)(346002)(451199021)(46966006)(36840700001)(40470700004)(8936002)(8676002)(41300700001)(40460700003)(82310400005)(478600001)(16526019)(82740400003)(356005)(426003)(2616005)(6666004)(81166007)(336012)(83380400001)(26005)(186003)(36860700001)(47076005)(7696005)(110136005)(40480700001)(54906003)(36756003)(4326008)(5660300002)(316002)(1076003)(70206006)(44832011)(70586007)(86362001)(2906002)(7416002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2023 03:53:38.0426 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d45ebc84-c78b-49ee-c877-08db72d442c8 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: CO1PEPF000042A8.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6160 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter The corresponding device of a register mapping is used for devm operations and logging. For operations with struct cxl_register_map the device needs to be kept track separately. To simpify the involved function interfaces, add @dev to cxl_register_map. While at it also reorder function arguments of cxl_map_device_regs() and cxl_map_component_regs() to have the object @cxl_register_map first. In a result a bunch of functions are available to be used with a @cxl_register_map object. This patch is in preparation of reworking the component register setup code. Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang --- drivers/cxl/core/hdm.c | 4 ++-- drivers/cxl/core/regs.c | 18 ++++++++++++------ drivers/cxl/cxl.h | 10 ++++++---- drivers/cxl/pci.c | 23 +++++++++++------------ 4 files changed, 31 insertions(+), 24 deletions(-) diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c index 7889ff203a34..5abfa9276dac 100644 --- a/drivers/cxl/core/hdm.c +++ b/drivers/cxl/core/hdm.c @@ -85,6 +85,7 @@ static int map_hdm_decoder_regs(struct cxl_port *port, void __iomem *crb, struct cxl_component_regs *regs) { struct cxl_register_map map = { + .dev = &port->dev, .resource = port->component_reg_phys, .base = crb, .max_size = CXL_COMPONENT_REG_BLOCK_SIZE, @@ -97,8 +98,7 @@ static int map_hdm_decoder_regs(struct cxl_port *port, void __iomem *crb, return -ENODEV; } - return cxl_map_component_regs(&port->dev, regs, &map, - BIT(CXL_CM_CAP_CAP_ID_HDM)); + return cxl_map_component_regs(&map, regs, BIT(CXL_CM_CAP_CAP_ID_HDM)); } static bool should_emulate_decoders(struct cxl_endpoint_dvsec_info *info) diff --git a/drivers/cxl/core/regs.c b/drivers/cxl/core/regs.c index 6c4b33133918..713e4a9ca35a 100644 --- a/drivers/cxl/core/regs.c +++ b/drivers/cxl/core/regs.c @@ -199,9 +199,11 @@ void __iomem *devm_cxl_iomap_block(struct device *dev, resource_size_t addr, return ret_val; } -int cxl_map_component_regs(struct device *dev, struct cxl_component_regs *regs, - struct cxl_register_map *map, unsigned long map_mask) +int cxl_map_component_regs(struct cxl_register_map *map, + struct cxl_component_regs *regs, + unsigned long map_mask) { + struct device *dev = map->dev; struct mapinfo { struct cxl_reg_map *rmap; void __iomem **addr; @@ -231,10 +233,10 @@ int cxl_map_component_regs(struct device *dev, struct cxl_component_regs *regs, } EXPORT_SYMBOL_NS_GPL(cxl_map_component_regs, CXL); -int cxl_map_device_regs(struct device *dev, - struct cxl_device_regs *regs, - struct cxl_register_map *map) +int cxl_map_device_regs(struct cxl_register_map *map, + struct cxl_device_regs *regs) { + struct device *dev = map->dev; resource_size_t phys_addr = map->resource; struct mapinfo { struct cxl_reg_map *rmap; @@ -302,7 +304,11 @@ int cxl_find_regblock(struct pci_dev *pdev, enum cxl_regloc_type type, u32 regloc_size, regblocks; int regloc, i; - map->resource = CXL_RESOURCE_NONE; + *map = (struct cxl_register_map) { + .dev = &pdev->dev, + .resource = CXL_RESOURCE_NONE, + }; + regloc = pci_find_dvsec_capability(pdev, PCI_DVSEC_VENDOR_ID_CXL, CXL_DVSEC_REG_LOCATOR); if (!regloc) diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index 754cfe59ae37..bd68d5fabf21 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -231,6 +231,7 @@ struct cxl_device_reg_map { /** * struct cxl_register_map - DVSEC harvested register block mapping parameters + * @dev: device for devm operations and logging * @base: virtual base of the register-block-BAR + @block_offset * @resource: physical resource base of the register block * @max_size: maximum mapping size to perform register search @@ -239,6 +240,7 @@ struct cxl_device_reg_map { * @device_map: cxl_reg_maps for device registers */ struct cxl_register_map { + struct device *dev; void __iomem *base; resource_size_t resource; resource_size_t max_size; @@ -253,11 +255,11 @@ void cxl_probe_component_regs(struct device *dev, void __iomem *base, struct cxl_component_reg_map *map); void cxl_probe_device_regs(struct device *dev, void __iomem *base, struct cxl_device_reg_map *map); -int cxl_map_component_regs(struct device *dev, struct cxl_component_regs *regs, - struct cxl_register_map *map, +int cxl_map_component_regs(struct cxl_register_map *map, + struct cxl_component_regs *regs, unsigned long map_mask); -int cxl_map_device_regs(struct device *dev, struct cxl_device_regs *regs, - struct cxl_register_map *map); +int cxl_map_device_regs(struct cxl_register_map *map, + struct cxl_device_regs *regs); enum cxl_regloc_type; int cxl_find_regblock(struct pci_dev *pdev, enum cxl_regloc_type type, diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c index 0872f2233ed0..0a89b96e6a8d 100644 --- a/drivers/cxl/pci.c +++ b/drivers/cxl/pci.c @@ -274,9 +274,9 @@ static int cxl_pci_setup_mailbox(struct cxl_dev_state *cxlds) return 0; } -static int cxl_map_regblock(struct pci_dev *pdev, struct cxl_register_map *map) +static int cxl_map_regblock(struct cxl_register_map *map) { - struct device *dev = &pdev->dev; + struct device *dev = map->dev; map->base = ioremap(map->resource, map->max_size); if (!map->base) { @@ -288,18 +288,17 @@ static int cxl_map_regblock(struct pci_dev *pdev, struct cxl_register_map *map) return 0; } -static void cxl_unmap_regblock(struct pci_dev *pdev, - struct cxl_register_map *map) +static void cxl_unmap_regblock(struct cxl_register_map *map) { iounmap(map->base); map->base = NULL; } -static int cxl_probe_regs(struct pci_dev *pdev, struct cxl_register_map *map) +static int cxl_probe_regs(struct cxl_register_map *map) { struct cxl_component_reg_map *comp_map; struct cxl_device_reg_map *dev_map; - struct device *dev = &pdev->dev; + struct device *dev = map->dev; void __iomem *base = map->base; switch (map->reg_type) { @@ -346,12 +345,12 @@ static int cxl_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, if (rc) return rc; - rc = cxl_map_regblock(pdev, map); + rc = cxl_map_regblock(map); if (rc) return rc; - rc = cxl_probe_regs(pdev, map); - cxl_unmap_regblock(pdev, map); + rc = cxl_probe_regs(map); + cxl_unmap_regblock(map); return rc; } @@ -688,7 +687,7 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) if (rc) return rc; - rc = cxl_map_device_regs(&pdev->dev, &cxlds->regs.device_regs, &map); + rc = cxl_map_device_regs(&map, &cxlds->regs.device_regs); if (rc) return rc; @@ -703,8 +702,8 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) cxlds->component_reg_phys = map.resource; - rc = cxl_map_component_regs(&pdev->dev, &cxlds->regs.component, - &map, BIT(CXL_CM_CAP_CAP_ID_RAS)); + rc = cxl_map_component_regs(&map, &cxlds->regs.component, + BIT(CXL_CM_CAP_CAP_ID_RAS)); if (rc) dev_dbg(&pdev->dev, "Failed to map RAS capability.\n"); From patchwork Thu Jun 22 03:51:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13288220 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 341B7EB64DB for ; Thu, 22 Jun 2023 03:54:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229530AbjFVDyk (ORCPT ); Wed, 21 Jun 2023 23:54:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbjFVDy1 (ORCPT ); Wed, 21 Jun 2023 23:54:27 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2072.outbound.protection.outlook.com [40.107.244.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E52C61FEA; Wed, 21 Jun 2023 20:53:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JWNjMRc+XlirNWq96thNc8+IR8V0u/ABu3ZXXQY9BPEESm3huYa3vFWIXOsNjCfEEl+PlINWL6Wf0g8hg+WVG/QKarjU+EAAcIWntjFaDpLHx3vGnj3ByNH4+4rGoZ+9Dp3EbplVY3nLb185qXgQ9X/qglRLgH54mKyDJ5u6e1nBP+eBQ7ZdGuAHC2j3zTgei6aEuk3SJpfxCZn5wkteYTnYmUFQyHM5tFwzFI3mht+rTQV3p9MbSdi8EMpIlmsw3PgI0OqsMO4VQyEjIuC0p1VurZKyvVys1dFMpFv1ySjCL+hO+mWL/UeYNe+i3f8vxRZV8w/fP/NoG/nWEaYu0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=/fPDt9oWCOA2VD7agqDbcIq75dtCSP481mqclj94gxA=; b=EvmgtZd5SA6ZkI8fAhaKTDV2IU6QNl9614RKZvzdyh0um7Q6WPqQhSDDaA2y1InoA7usDZBNscNoGP5eESd3PG0ERXh8ysV4sYQqB3ehkxrBYQ6YeIMdnYA9ZyWGbXi4MJshfjRzO5pzU2E0o44XgfwCJzDBhEpc85uOH2NIYdpunxJKalhqPOp607Ns6d2sDYBlhYO2WAuP7JL1Env0BQOaftG8T8Fm1OLI4VbXaZOL30/+tDuB97MnAfpnpkI5uhguhTFqpTFwEZL+FthGc+YHclA9zp5x1JeLd9Dr57eJpQYnXoNOr+NtpCu9uDI93I0EOMQ2DcxQE9PGrGEY0Q== 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 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=/fPDt9oWCOA2VD7agqDbcIq75dtCSP481mqclj94gxA=; b=WJc260rpaYXrPUd5amnEZeHvLprBt7x9n19CpiKpgY29A8SyPgf9X4+L35g3cjo/5ldBCfI5Vi+m71bBkuV6ECG6GtN3Boul70BX7I3Pem7CZHkT9FsYDONRs3Aib5WPJ8gahe/mRL946WUH4xHXJncJviMtkPsYzOkK6zSbdGc= Received: from MW4PR03CA0203.namprd03.prod.outlook.com (2603:10b6:303:b8::28) by PH7PR12MB7164.namprd12.prod.outlook.com (2603:10b6:510:203::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.37; Thu, 22 Jun 2023 03:53:50 +0000 Received: from CO1PEPF000042AA.namprd03.prod.outlook.com (2603:10b6:303:b8:cafe::e4) by MW4PR03CA0203.outlook.office365.com (2603:10b6:303:b8::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23 via Frontend Transport; Thu, 22 Jun 2023 03:53:50 +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 CO1PEPF000042AA.mail.protection.outlook.com (10.167.243.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.17 via Frontend Transport; Thu, 22 Jun 2023 03:53:49 +0000 Received: from ethanolx7ea3host.amd.com (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.23; Wed, 21 Jun 2023 22:53:47 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v6 08/27] cxl/pci: Refactor component register discovery for reuse Date: Wed, 21 Jun 2023 22:51:07 -0500 Message-ID: <20230622035126.4130151-9-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622035126.4130151-1-terry.bowman@amd.com> References: <20230622035126.4130151-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: CO1PEPF000042AA:EE_|PH7PR12MB7164:EE_ X-MS-Office365-Filtering-Correlation-Id: af6f1522-b55b-4a0c-3075-08db72d449aa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5WTVQOJMd4UVHcQ3DKUM3n9YCGL97+8gOy2iTlScQ7m6dDb2lMaAZs3rElcA7H87IRjw0oNOSm6UDg5pjjdYTgRW3Nwambc+eI2dgbaRm+4CgoL91YP85J2Nox0B2oqqJmDb+qYY3dC/MbKIcw+kYrQGaF/5OPHZ+5pSFIIbaMaCPw2FPgfru5cljTaj15g0CPYjIW+MZ3NEDkd4KzXhauu40FdYl8c/Cm1w6luBDJy4FjMmrR82UVeFLH3H4RdT/wMoPmbcJLIkxSf61Tv+Emlb2wFjsdURhWk0UOqDobiOsb/zwK2tWNLAkdHd4RNTrwCPKiI0XZDy+Fypr6rAhDowyLZmU+HxQDM97wHCYiItIfX5VCJ2DNLyRjj7RKIV3aIUfSj/IRNPIHco6b00ydKWtnV/eQZUjvllarmwog+fhu1O6IYWSEBk9o7VW2DeETEeieRzgtxEA2CZ7McXAc5M6YIVaaYedIslfI8j+bLHZ666Ibpes5ioVlXhwEvZDLWcoAV55SgM/d+dfu6QRWPCH2W3YfTSO+VaA085j9/UmXQyOXlDHsEWu3AZY57juO8jIWktj+yKq2F3oaNiVgCIsbln3Sa4uSEHuj3VkVDsfE9btN7wRvZ1QAXKROk4/YVNOWoXOZ48F+kC8FCmdsj0NzBwilhKpuj63i4TC671kg/f7CT9x28FGTiAwRt8Nly3d82J6uUHJ01Gu8o1tAuQkNffjeogEMZz1eRRrZPI3ADl91dMeiGmBNIMOJDcaT+Te0ln3P16FKQvtNgvgw== 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:(13230028)(4636009)(346002)(396003)(136003)(376002)(39860400002)(451199021)(36840700001)(46966006)(40470700004)(40460700003)(7696005)(6666004)(478600001)(47076005)(36756003)(186003)(16526019)(83380400001)(26005)(336012)(2616005)(426003)(86362001)(82310400005)(82740400003)(81166007)(1076003)(356005)(36860700001)(40480700001)(41300700001)(8676002)(8936002)(5660300002)(316002)(2906002)(4326008)(70586007)(44832011)(7416002)(70206006)(54906003)(110136005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2023 03:53:49.6174 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: af6f1522-b55b-4a0c-3075-08db72d449aa 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: CO1PEPF000042AA.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7164 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org The endpoint implements component register setup code. Refactor it for reuse with RCRB, downstream port, and upstream port setup. Move PCI specifics from cxl_setup_regs() into cxl_pci_setup_regs(). Move cxl_setup_regs() into cxl/core/regs.c and export it. This also includes supporting static functions cxl_map_registerblock(), cxl_unmap_register_block() and cxl_probe_regs(). Co-developed-by: Robert Richter Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang --- drivers/cxl/core/regs.c | 77 +++++++++++++++++++++++++++++++++++++++ drivers/cxl/cxl.h | 1 + drivers/cxl/pci.c | 79 +++-------------------------------------- 3 files changed, 83 insertions(+), 74 deletions(-) diff --git a/drivers/cxl/core/regs.c b/drivers/cxl/core/regs.c index 713e4a9ca35a..e035ad8827a4 100644 --- a/drivers/cxl/core/regs.c +++ b/drivers/cxl/core/regs.c @@ -338,6 +338,83 @@ int cxl_find_regblock(struct pci_dev *pdev, enum cxl_regloc_type type, } EXPORT_SYMBOL_NS_GPL(cxl_find_regblock, CXL); +static int cxl_map_regblock(struct cxl_register_map *map) +{ + struct device *dev = map->dev; + + map->base = ioremap(map->resource, map->max_size); + if (!map->base) { + dev_err(dev, "failed to map registers\n"); + return -ENOMEM; + } + + dev_dbg(dev, "Mapped CXL Memory Device resource %pa\n", &map->resource); + return 0; +} + +static void cxl_unmap_regblock(struct cxl_register_map *map) +{ + iounmap(map->base); + map->base = NULL; +} + +static int cxl_probe_regs(struct cxl_register_map *map) +{ + struct cxl_component_reg_map *comp_map; + struct cxl_device_reg_map *dev_map; + struct device *dev = map->dev; + void __iomem *base = map->base; + + switch (map->reg_type) { + case CXL_REGLOC_RBI_COMPONENT: + comp_map = &map->component_map; + cxl_probe_component_regs(dev, base, comp_map); + if (!comp_map->hdm_decoder.valid) { + dev_err(dev, "HDM decoder registers not found\n"); + return -ENXIO; + } + + if (!comp_map->ras.valid) + dev_dbg(dev, "RAS registers not found\n"); + + dev_dbg(dev, "Set up component registers\n"); + break; + case CXL_REGLOC_RBI_MEMDEV: + dev_map = &map->device_map; + cxl_probe_device_regs(dev, base, dev_map); + if (!dev_map->status.valid || !dev_map->mbox.valid || + !dev_map->memdev.valid) { + dev_err(dev, "registers not found: %s%s%s\n", + !dev_map->status.valid ? "status " : "", + !dev_map->mbox.valid ? "mbox " : "", + !dev_map->memdev.valid ? "memdev " : ""); + return -ENXIO; + } + + dev_dbg(dev, "Probing device registers...\n"); + break; + default: + break; + } + + return 0; +} + +int cxl_setup_regs(struct cxl_register_map *map) +{ + int rc; + + rc = cxl_map_regblock(map); + if (rc) + return rc; + + rc = cxl_probe_regs(map); + cxl_unmap_regblock(map); + + return rc; +} +EXPORT_SYMBOL_NS_GPL(cxl_setup_regs, CXL); + resource_size_t __rcrb_to_component(struct device *dev, struct cxl_rcrb_info *ri, enum cxl_rcrb which) { diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index bd68d5fabf21..ae265357170e 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -264,6 +264,7 @@ int cxl_map_device_regs(struct cxl_register_map *map, enum cxl_regloc_type; int cxl_find_regblock(struct pci_dev *pdev, enum cxl_regloc_type type, struct cxl_register_map *map); +int cxl_setup_regs(struct cxl_register_map *map); struct cxl_dport; resource_size_t cxl_rcd_component_reg_phys(struct device *dev, struct cxl_dport *dport); diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c index 0a89b96e6a8d..ac17bc0430dc 100644 --- a/drivers/cxl/pci.c +++ b/drivers/cxl/pci.c @@ -274,70 +274,8 @@ static int cxl_pci_setup_mailbox(struct cxl_dev_state *cxlds) return 0; } -static int cxl_map_regblock(struct cxl_register_map *map) -{ - struct device *dev = map->dev; - - map->base = ioremap(map->resource, map->max_size); - if (!map->base) { - dev_err(dev, "failed to map registers\n"); - return -ENOMEM; - } - - dev_dbg(dev, "Mapped CXL Memory Device resource %pa\n", &map->resource); - return 0; -} - -static void cxl_unmap_regblock(struct cxl_register_map *map) -{ - iounmap(map->base); - map->base = NULL; -} - -static int cxl_probe_regs(struct cxl_register_map *map) -{ - struct cxl_component_reg_map *comp_map; - struct cxl_device_reg_map *dev_map; - struct device *dev = map->dev; - void __iomem *base = map->base; - - switch (map->reg_type) { - case CXL_REGLOC_RBI_COMPONENT: - comp_map = &map->component_map; - cxl_probe_component_regs(dev, base, comp_map); - if (!comp_map->hdm_decoder.valid) { - dev_err(dev, "HDM decoder registers not found\n"); - return -ENXIO; - } - - if (!comp_map->ras.valid) - dev_dbg(dev, "RAS registers not found\n"); - - dev_dbg(dev, "Set up component registers\n"); - break; - case CXL_REGLOC_RBI_MEMDEV: - dev_map = &map->device_map; - cxl_probe_device_regs(dev, base, dev_map); - if (!dev_map->status.valid || !dev_map->mbox.valid || - !dev_map->memdev.valid) { - dev_err(dev, "registers not found: %s%s%s\n", - !dev_map->status.valid ? "status " : "", - !dev_map->mbox.valid ? "mbox " : "", - !dev_map->memdev.valid ? "memdev " : ""); - return -ENXIO; - } - - dev_dbg(dev, "Probing device registers...\n"); - break; - default: - break; - } - - return 0; -} - -static int cxl_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, - struct cxl_register_map *map) +static int cxl_pci_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, + struct cxl_register_map *map) { int rc; @@ -345,14 +283,7 @@ static int cxl_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, if (rc) return rc; - rc = cxl_map_regblock(map); - if (rc) - return rc; - - rc = cxl_probe_regs(map); - cxl_unmap_regblock(map); - - return rc; + return cxl_setup_regs(map); } /* @@ -683,7 +614,7 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) dev_warn(&pdev->dev, "Device DVSEC not present, skip CXL.mem init\n"); - rc = cxl_setup_regs(pdev, CXL_REGLOC_RBI_MEMDEV, &map); + rc = cxl_pci_setup_regs(pdev, CXL_REGLOC_RBI_MEMDEV, &map); if (rc) return rc; @@ -696,7 +627,7 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) * still be useful for management functions so don't return an error. */ cxlds->component_reg_phys = CXL_RESOURCE_NONE; - rc = cxl_setup_regs(pdev, CXL_REGLOC_RBI_COMPONENT, &map); + rc = cxl_pci_setup_regs(pdev, CXL_REGLOC_RBI_COMPONENT, &map); if (rc) dev_warn(&pdev->dev, "No component registers (%d)\n", rc); From patchwork Thu Jun 22 03:51:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13288221 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F410EB64D8 for ; Thu, 22 Jun 2023 03:55:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230146AbjFVDzA (ORCPT ); Wed, 21 Jun 2023 23:55:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230152AbjFVDyk (ORCPT ); Wed, 21 Jun 2023 23:54:40 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DC2B1FFB; Wed, 21 Jun 2023 20:54:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j4zMdpgj2gttXZMTVFfsMiMUAmbn5Ll5/Mj7ZBOCxFvduLIvJcAkSePBSr7J8UtjWlfiJoaDCYqFCyjgboptcMHFsG+HU/zkyU8rZs+v4v/FiFQRAtuYPx4RFh5CNrV2BEAy1BfU9exFFqmzBGwbEiWBQddWxsMzERfEGJ/wUDpIZSmV7IPXZC3DxxGLT3px9kgrBrtij6oxyXTH1RUo3hTevvsVWASqWV0zqN50l5yXcu7wsGcQ/DGOx8W6E5FQJEog4hrs4V60coUbJ/foZeWbTTjndf3bduUiVr/RBE5mHeSzn076orD/wuKZiu+JJEFHx8neR8UYu1ORVRDf3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=nCaX2UCbPwk3XHqmoekVr5xpfO8s5REsnJHptyPWvss=; b=WgpoEjialKmOvSEVhlG2XT4qI2ZjH/XCf73ep9Ag16Ssy7DxrCMXpV6UVDi0PhAUeFJRewMi4fDFUIXddhDYp8b+xGHhGUYjGXks/ujkXaNzcXPvyfocoxS01FQ1okRZQ4UBm90CYl5kv4YfLWgK0LaFwtjN1VgaSv9hAdXlEqUq7/z6Qd8V3dNjX0CiqpZJzPt+eoSAg+LN8VF2V86Cq6KMYSRKRIkQEHUoBYXliCsdXwrGKGnPZs6qhv6OXnMYQcXbpUuK9sOB1wVHjUYM/k7LXHPo5Z0OcnM+tR70v4YMviXUmOINEOhUG1KiFzRk9hz0Uk4sTb/QMr3B00hWuQ== 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 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=nCaX2UCbPwk3XHqmoekVr5xpfO8s5REsnJHptyPWvss=; b=bT+vdTfI8c3B2tIRy1um0rXuWSqL5L0aXt/ObTuJaWybTrYsQnhagHBopCfFPla2o6RlHnlsu9yjZGp9YT5NIKsuLuptmb0/a1HGV3t+FkvbLoPGJ6H98+Hb0RlrVH03v05rmtF+KV7lLHo9J6Ix6sGFuKX1YcMHpFxM/ZcxNZI= Received: from MW2PR16CA0057.namprd16.prod.outlook.com (2603:10b6:907:1::34) by SN7PR12MB8026.namprd12.prod.outlook.com (2603:10b6:806:34b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24; Thu, 22 Jun 2023 03:54:00 +0000 Received: from CO1PEPF000042AD.namprd03.prod.outlook.com (2603:10b6:907:1:cafe::18) by MW2PR16CA0057.outlook.office365.com (2603:10b6:907:1::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24 via Frontend Transport; Thu, 22 Jun 2023 03:54: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 CO1PEPF000042AD.mail.protection.outlook.com (10.167.243.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6521.17 via Frontend Transport; Thu, 22 Jun 2023 03:53:59 +0000 Received: from ethanolx7ea3host.amd.com (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.23; Wed, 21 Jun 2023 22:53:58 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v6 09/27] cxl/acpi: Move add_host_bridge_uport() after cxl_get_chbs() Date: Wed, 21 Jun 2023 22:51:08 -0500 Message-ID: <20230622035126.4130151-10-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622035126.4130151-1-terry.bowman@amd.com> References: <20230622035126.4130151-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: CO1PEPF000042AD:EE_|SN7PR12MB8026:EE_ X-MS-Office365-Filtering-Correlation-Id: 26fe5aa4-593d-4450-c0cd-08db72d44fd8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Il1cVbmdss2g73bIUskmt6I9LaEdB3doW0dO1eZRPNUH74zynNOprPsiTeG23OB8Pcv93GKh0EVunmGaym8qM+8DFzkDo8JUTEVoVfI5wlooHKCkdnwNU7jzwl2WSs3nABoH2tg0RjZiYKk1OYCH3XGgHLKtOXanyAeNJkm97WfuH3VA4pfNd9ve61CPr+ZJx0ZkBSRnX6x5GkbdySZ9FSoU5VVfuuMIp6S7cu4DeT7n3iRRKjbiBa2j+hDo88BO/FpvfGeYbHplHSa0NtjJn6GxVYrl2j4xIDLw58h/97FUSSOmeJDCN5JNs+5UKJQHSs+BtnWYrXlbKlV8jxQcKVLkGQucKlEiteCtUB4qARutDd6FtMXavPu7TBcWEGR8p4MHZ4bA+Z37QJ9oYp1jaa0/NM5GYNK/I2YRyuU4R/KFeh9zpZvNM/jUASNHhnZwefQSpHMph2fonvf9foIDU4EnTmpcdSIiPzr1hFDQ7sXfEHudMBUIzcNZ97dDadDhG9HaQIVBf5FLo7w9J6yTsKUGUZUQbfWW5WDZjmaQ6QeH6PGmJvbU5gW8Zf3Ot5RHcHp1LR+DBAXoOLNcLDxuuMPoGdse0j5BVZ7OFLcGUCsoocxtDEnOvS2w4iQcNTNB0NXjNf44x8eKKE3mqHa5wEeJp/Hf+uhNAmz67/d8Jl7R6/cLgha4GI/MhTEkS+2Qwwdb78iwb4SC2QAw6Vy8XotYZo68aSGR5coSCc/eXbjCYVBJSzU0wcUV+8qS4+ast8tfT2xXYnCX9ftnwcAJpA== 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:(13230028)(4636009)(39860400002)(396003)(346002)(376002)(136003)(451199021)(46966006)(40470700004)(36840700001)(44832011)(47076005)(5660300002)(7416002)(2906002)(1076003)(41300700001)(8936002)(40480700001)(186003)(8676002)(26005)(40460700003)(2616005)(336012)(426003)(478600001)(82310400005)(356005)(82740400003)(7696005)(81166007)(36860700001)(83380400001)(70586007)(70206006)(36756003)(4326008)(16526019)(86362001)(54906003)(110136005)(6666004)(316002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2023 03:53:59.9576 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 26fe5aa4-593d-4450-c0cd-08db72d44fd8 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: CO1PEPF000042AD.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8026 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter Just moving code to reorder functions to later share cxl_get_chbs() with add_host_bridge_uport(). This makes changes in the next patch visible. No other changes at all. Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang --- drivers/cxl/acpi.c | 90 +++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index 70cd9ac73a8b..0c975ee684b0 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -327,51 +327,6 @@ __mock struct acpi_device *to_cxl_host_bridge(struct device *host, return NULL; } -/* - * A host bridge is a dport to a CFMWS decode and it is a uport to the - * dport (PCIe Root Ports) in the host bridge. - */ -static int add_host_bridge_uport(struct device *match, void *arg) -{ - struct cxl_port *root_port = arg; - struct device *host = root_port->dev.parent; - struct acpi_device *hb = to_cxl_host_bridge(host, match); - struct acpi_pci_root *pci_root; - struct cxl_dport *dport; - struct cxl_port *port; - struct device *bridge; - int rc; - - if (!hb) - return 0; - - pci_root = acpi_pci_find_root(hb->handle); - bridge = pci_root->bus->bridge; - dport = cxl_find_dport_by_dev(root_port, bridge); - if (!dport) { - dev_dbg(host, "host bridge expected and not found\n"); - return 0; - } - - if (dport->rch) { - dev_info(bridge, "host supports CXL (restricted)\n"); - return 0; - } - - rc = devm_cxl_register_pci_bus(host, bridge, pci_root->bus); - if (rc) - return rc; - - port = devm_cxl_add_port(host, bridge, dport->component_reg_phys, - dport); - if (IS_ERR(port)) - return PTR_ERR(port); - - dev_info(bridge, "host supports CXL\n"); - - return 0; -} - /* Note, @dev is used by mock_acpi_table_parse_cedt() */ struct cxl_chbs_context { struct device *dev; @@ -467,6 +422,51 @@ static int add_host_bridge_dport(struct device *match, void *arg) return 0; } +/* + * A host bridge is a dport to a CFMWS decode and it is a uport to the + * dport (PCIe Root Ports) in the host bridge. + */ +static int add_host_bridge_uport(struct device *match, void *arg) +{ + struct cxl_port *root_port = arg; + struct device *host = root_port->dev.parent; + struct acpi_device *hb = to_cxl_host_bridge(host, match); + struct acpi_pci_root *pci_root; + struct cxl_dport *dport; + struct cxl_port *port; + struct device *bridge; + int rc; + + if (!hb) + return 0; + + pci_root = acpi_pci_find_root(hb->handle); + bridge = pci_root->bus->bridge; + dport = cxl_find_dport_by_dev(root_port, bridge); + if (!dport) { + dev_dbg(host, "host bridge expected and not found\n"); + return 0; + } + + if (dport->rch) { + dev_info(bridge, "host supports CXL (restricted)\n"); + return 0; + } + + rc = devm_cxl_register_pci_bus(host, bridge, pci_root->bus); + if (rc) + return rc; + + port = devm_cxl_add_port(host, bridge, dport->component_reg_phys, + dport); + if (IS_ERR(port)) + return PTR_ERR(port); + + dev_info(bridge, "host supports CXL\n"); + + return 0; +} + static int add_root_nvdimm_bridge(struct device *match, void *data) { struct cxl_decoder *cxld; From patchwork Thu Jun 22 03:51:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13288222 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CFEFEB64D8 for ; Thu, 22 Jun 2023 03:55:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230115AbjFVDzy (ORCPT ); Wed, 21 Jun 2023 23:55:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230112AbjFVDzc (ORCPT ); Wed, 21 Jun 2023 23:55:32 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20603.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eaa::603]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B0762116; Wed, 21 Jun 2023 20:54:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ASw8QodlcnmRFN6ohm9q8gTSsuenqnxF904qxUD1EBF47XeJxKtOeQnyugF0F3CaiP6unb7C1Kf2o89LUsvf02XvftXqLTybwrel9OPqWhl46wXnKuZgL7cx/8U5EBllUwZ1wZSPY2bbRgvxidW/wFaAh3P9J6gSQ7cUcXhhuCtup0F7Zgv4RyYIQpxOEZg8l+793KwjY340e27p5XSk5aZWm+5lkvSsIxUUw1EuvY3N5CmIUWsmFOxZD9XM3rHcNbn45Rp+HFFkpDbMVcdQDTHAaBE7WzSd3W1zalRaihyR+y7N2Sx0hvsIyrNlAq5QHItxnx+QLwj1fUrmVvFcZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=G7+D52Ajp1fAWi0SwTpRUWw6rM8Pi+Eac7Tv9OCFyLY=; b=JM/8djHecMqGik7ZaXHcIvqsX6Eebv7W8fGd26ATo+YRSUWv4TUay6wLvCMhZCIUOK9ai1oNT6cZet/aKKZlPvkrHraIrAJolNfVDPEhorjMuDQ8GnpC2oTqkdcouS7D6U3d5L5izuDLeiHH9ClQg2W18/GhnN3EyQPWh2uyilUbnUn+2NzAqjgTa1CbnK/4/8bR37PX4co6XoNunTTO9fYTQXO7t9uJE8AnQDKoif2GFeYDcCAgk0yzW1G8BEC8shCB7P0Utp05MbTGsIolQXWahsAxqmZKWVVF+LJgAso8PfGuEDFRjVwKcGZ4fA7+OBdEZTlS4dN+vWVIwjZ3JQ== 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 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=G7+D52Ajp1fAWi0SwTpRUWw6rM8Pi+Eac7Tv9OCFyLY=; b=UJu4i4Kzj4J/A4/GIiG4Gc8Y4V79v9CC5oNhKy6sYv4LCdhDZ/+D/qpViLQ4oHIPqcBfoams3CQakwCmRd0kCq3BztWvruYiVamOet81VjBvVEwgDNBemBacuAcxwtiCKyBlcW03KuSNdEeWa8SPbmmJrtf5Rie5G+vFmNCVfZk= Received: from BN9PR03CA0595.namprd03.prod.outlook.com (2603:10b6:408:10d::30) by SJ2PR12MB9192.namprd12.prod.outlook.com (2603:10b6:a03:55d::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.37; Thu, 22 Jun 2023 03:54:36 +0000 Received: from BN8NAM11FT027.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10d:cafe::4f) by BN9PR03CA0595.outlook.office365.com (2603:10b6:408:10d::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24 via Frontend Transport; Thu, 22 Jun 2023 03:54:35 +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 BN8NAM11FT027.mail.protection.outlook.com (10.13.177.96) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.41 via Frontend Transport; Thu, 22 Jun 2023 03:54:34 +0000 Received: from ethanolx7ea3host.amd.com (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.23; Wed, 21 Jun 2023 22:54:09 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v6 10/27] cxl/acpi: Directly bind the CEDT detected CHBCR to the Host Bridge's port Date: Wed, 21 Jun 2023 22:51:09 -0500 Message-ID: <20230622035126.4130151-11-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622035126.4130151-1-terry.bowman@amd.com> References: <20230622035126.4130151-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: BN8NAM11FT027:EE_|SJ2PR12MB9192:EE_ X-MS-Office365-Filtering-Correlation-Id: feb113a8-e474-4f9a-6711-08db72d46471 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7uOd8Ty0AJ5N2dnbfXcywqDiCJajIB5tpFb+QcACfYXehbkt8Ktjxxdt04lA8TOLQPBIX2dkuk392bSX2MPLRR9yEFAXQ+GLhXICv64UvAh0LOeQov6z7FLFe4s2QzrKwX6SzAWAWJgr/wKPX3bW8iNvLpzDABomyxKh2CNfmMROo63WLsWn9CWPd1zMR4geqcu2o/dADiq88X29Xh4aJ1OWOxyiSD6TkBHJiZZWr83zZdNJxU27YzVVgs4j6itIFhQ2getHr3UV/2zHTf5IT3SxLxRuxz7YlQbizsoc6wGm877R9bGA2TH+Iopbhk1kFd9zBLwt5AaFxz82FJ+8oPt8kPolvslo20HAz/azY0pSNRU3HAoCGOKimMUhevd7q2kcsVhwOBAKcRGT6QK77v0LOO69mTMFgFkkZGrCzsf0ykFD9gnP+dpg6RcEwTBFmdVhnSr7NaXerHsj4xN4AaEGE8+vHOojpR2XMYjIJ5S36K9qLO5uePanr2+JVAdQz1uBO/uRtHVJJoddiNgmBehaM5nUb5fT6MD03H4a2LNH65GD4HG/SfC8H71mpztMnuyurUOq68ByomiSgeLtl/2nxZcf8Q7F2eag+Lfb30glfW1VxQYagDGUlQcbJjusDcmgfW9oUeqbXW7L3nTOYD2tLDhcT8RG0th4j81Jjc4R2NZEGH6nbyrm69QQwHKIObV/f9pIKvpK/orqg1ByU76lxlHJ7fDLq9YQffkI6KuvN8Z/y54Qv3OFYLc2bybDaGUJWMmbVEsYCN0mYwPahA== 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:(13230028)(4636009)(39860400002)(346002)(396003)(376002)(136003)(451199021)(36840700001)(46966006)(40470700004)(7416002)(82310400005)(70586007)(70206006)(8936002)(8676002)(1076003)(186003)(26005)(16526019)(36756003)(83380400001)(41300700001)(5660300002)(4326008)(82740400003)(36860700001)(316002)(44832011)(54906003)(40460700003)(426003)(7696005)(2616005)(81166007)(40480700001)(356005)(2906002)(478600001)(86362001)(110136005)(47076005)(336012)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2023 03:54:34.6375 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: feb113a8-e474-4f9a-6711-08db72d46471 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: BN8NAM11FT027.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB9192 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter During a Host Bridge's downstream port enumeration the CHBS entries in the CEDT table are parsed, its Component Register base address extracted and then stored in struct cxl_dport. The CHBS may contain either the RCRB (RCH mode) or the Host Bridge's Component Registers (CHBCR, VH mode). The RCRB further contains the CXL downstream port register base address, while in VH mode the CXL Downstream Switch Ports are visible in the PCI hierarchy and the DP's component regs are disovered using the CXL DVSEC register locator capability. The Component Registers derived from the CHBS for both modes are different and thus also must be treated differently. That is, in RCH mode, the component regs base should be bound to the dport, but in VH mode to the CXL host bridge's port object. The current implementation stores the CHBCR in addition in struct cxl_dport and copies it later from there to struct cxl_port. As a result, the dport contains the wrong Component Registers base address and, e.g. the RAS capability of a CXL Root Port cannot be detected. To fix the CHBCR binding, attach it directly to the Host Bridge's @cxl_port structure. Do this during port creation of the Host Bridge in add_host_bridge_uport(). Factor out CHBS parsing code in add_host_bridge_dport() and use it in both functions. Co-developed-by: Dan Williams Signed-off-by: Dan Williams Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang --- drivers/cxl/acpi.c | 91 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 63 insertions(+), 28 deletions(-) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index 0c975ee684b0..89ee01323d43 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -335,13 +335,13 @@ struct cxl_chbs_context { u32 cxl_version; }; -static int cxl_get_chbs(union acpi_subtable_headers *header, void *arg, - const unsigned long end) +static int cxl_get_chbs_iter(union acpi_subtable_headers *header, void *arg, + const unsigned long end) { struct cxl_chbs_context *ctx = arg; struct acpi_cedt_chbs *chbs; - if (ctx->base) + if (ctx->base != CXL_RESOURCE_NONE) return 0; chbs = (struct acpi_cedt_chbs *) header; @@ -350,8 +350,6 @@ static int cxl_get_chbs(union acpi_subtable_headers *header, void *arg, return 0; ctx->cxl_version = chbs->cxl_version; - ctx->base = CXL_RESOURCE_NONE; - if (!chbs->base) return 0; @@ -364,11 +362,35 @@ static int cxl_get_chbs(union acpi_subtable_headers *header, void *arg, return 0; } +static int cxl_get_chbs(struct device *dev, struct acpi_device *hb, + struct cxl_chbs_context *ctx) +{ + unsigned long long uid; + int rc; + + rc = acpi_evaluate_integer(hb->handle, METHOD_NAME__UID, NULL, &uid); + if (rc != AE_OK) { + dev_err(dev, "unable to retrieve _UID\n"); + return -ENOENT; + } + + dev_dbg(dev, "UID found: %lld\n", uid); + *ctx = (struct cxl_chbs_context) { + .dev = dev, + .uid = uid, + .base = CXL_RESOURCE_NONE, + .cxl_version = UINT_MAX, + }; + + acpi_table_parse_cedt(ACPI_CEDT_TYPE_CHBS, cxl_get_chbs_iter, ctx); + + return 0; +} + static int add_host_bridge_dport(struct device *match, void *arg) { acpi_status rc; struct device *bridge; - unsigned long long uid; struct cxl_dport *dport; struct cxl_chbs_context ctx; struct acpi_pci_root *pci_root; @@ -379,41 +401,38 @@ static int add_host_bridge_dport(struct device *match, void *arg) if (!hb) return 0; - rc = acpi_evaluate_integer(hb->handle, METHOD_NAME__UID, NULL, &uid); - if (rc != AE_OK) { - dev_err(match, "unable to retrieve _UID\n"); - return -ENODEV; - } - - dev_dbg(match, "UID found: %lld\n", uid); - - ctx = (struct cxl_chbs_context) { - .dev = match, - .uid = uid, - }; - acpi_table_parse_cedt(ACPI_CEDT_TYPE_CHBS, cxl_get_chbs, &ctx); + rc = cxl_get_chbs(match, hb, &ctx); + if (rc) + return rc; - if (!ctx.base) { + if (ctx.cxl_version == UINT_MAX) { dev_warn(match, "No CHBS found for Host Bridge (UID %lld)\n", - uid); + ctx.uid); return 0; } if (ctx.base == CXL_RESOURCE_NONE) { dev_warn(match, "CHBS invalid for Host Bridge (UID %lld)\n", - uid); + ctx.uid); return 0; } pci_root = acpi_pci_find_root(hb->handle); bridge = pci_root->bus->bridge; + /* + * In RCH mode, bind the component regs base to the dport. In + * VH mode it will be bound to the CXL host bridge's port + * object later in add_host_bridge_uport(). + */ if (ctx.cxl_version == ACPI_CEDT_CHBS_VERSION_CXL11) { - dev_dbg(match, "RCRB found for UID %lld: %pa\n", uid, &ctx.base); - dport = devm_cxl_add_rch_dport(root_port, bridge, uid, ctx.base); + dev_dbg(match, "RCRB found for UID %lld: %pa\n", ctx.uid, + &ctx.base); + dport = devm_cxl_add_rch_dport(root_port, bridge, ctx.uid, + ctx.base); } else { - dev_dbg(match, "CHBCR found for UID %lld: %pa\n", uid, &ctx.base); - dport = devm_cxl_add_dport(root_port, bridge, uid, ctx.base); + dport = devm_cxl_add_dport(root_port, bridge, ctx.uid, + CXL_RESOURCE_NONE); } if (IS_ERR(dport)) @@ -435,6 +454,8 @@ static int add_host_bridge_uport(struct device *match, void *arg) struct cxl_dport *dport; struct cxl_port *port; struct device *bridge; + struct cxl_chbs_context ctx; + resource_size_t component_reg_phys; int rc; if (!hb) @@ -453,12 +474,26 @@ static int add_host_bridge_uport(struct device *match, void *arg) return 0; } + rc = cxl_get_chbs(match, hb, &ctx); + if (rc) + return rc; + + if (ctx.cxl_version == ACPI_CEDT_CHBS_VERSION_CXL11) { + dev_warn(bridge, + "CXL CHBS version mismatch, skip port registration\n"); + return 0; + } + + component_reg_phys = ctx.base; + if (component_reg_phys != CXL_RESOURCE_NONE) + dev_dbg(match, "CHBCR found for UID %lld: %pa\n", + ctx.uid, &component_reg_phys); + rc = devm_cxl_register_pci_bus(host, bridge, pci_root->bus); if (rc) return rc; - port = devm_cxl_add_port(host, bridge, dport->component_reg_phys, - dport); + port = devm_cxl_add_port(host, bridge, component_reg_phys, dport); if (IS_ERR(port)) return PTR_ERR(port); From patchwork Thu Jun 22 03:51:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13288225 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E70B2EB64D8 for ; Thu, 22 Jun 2023 03:56:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230158AbjFVD4X (ORCPT ); Wed, 21 Jun 2023 23:56:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230243AbjFVDzk (ORCPT ); Wed, 21 Jun 2023 23:55:40 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2069.outbound.protection.outlook.com [40.107.243.69]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 595941BD8; Wed, 21 Jun 2023 20:55:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LNHiWiK6L37hFRPBBedMRYIPbijaDIV881ALwX2CSI4+AfFaz2YHKfgzGx+93UvDTeed0wQ5oyGkBArcscUkY3tDwlAgRQirP/1+B8u7p+KY1CvznkP+FbpImNSj0kORQN68gBvdb13XKgPiTzNfPj+wo0xx0nkEYqt5ftMcYfq+lKnrTUbkkMxvnc+on3MPqkW8WCcvgvJLuHNJhIKpD/643vpFUvEtivN7tDs8dLeDAYebKlL9C+sSd7SlxcVSJTn7oi9pf8rbNYtRmem5tGzBKpYMm20GM+/i2UnmHdS4jNhMiX2970VrRbRWkR/GQCdUf3ID3pe4/oWeQ7w2CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=QayUoeXFL9pZZkSBfcDiLT7Wq6qSoSz/ZbOpneU2nbI=; b=feyo6v/OAu1BhcfKCCLXJgSNY1rzGWUyoIj9ofnkjJmWPa3X10OQZp/5eD1jG0WbBnQca+kmEEc5NgnoV/uNX7LxrjIHK9W3J7a2+nLFswkTFgWKp0MyLBFdOB6Kl2h9e0VpTCeLkwDHClWZMZ+SN/IwjLMRzjlGenwqikq1/LsXPr8BWflRs9ntSZiPt317cfdKIXOntiKPpMlMHaSkFC8GSflLeM2biMT8emR5XdgakZYO6pvJl9FDTMC0Pq9YODd0Nd0oLg38D1j8eR23mEJZC7j7/gFnLq44/zydNKqEHWtnDTj4gE8fp7TqNpeCZU+bcFBlc+AhEhWAXZ6rvg== 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 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=QayUoeXFL9pZZkSBfcDiLT7Wq6qSoSz/ZbOpneU2nbI=; b=GK0G1ZBJdngOiyHmVSslIUs1bpXOmtc0dL/AzncNvi6Q8FyRVer5F+ix4Jj83a0QkF2/dW06Mkb5p2+colhUcAqq7lkzuevT9gFFFUeQmlmR+3MjQI4MdVYEr72UYcAK2jhVFPgK2Uo7TOZE/n+0iLW4PDIZbGzhnNsUxxbs0qg= Received: from BN9PR03CA0306.namprd03.prod.outlook.com (2603:10b6:408:112::11) by IA1PR12MB6233.namprd12.prod.outlook.com (2603:10b6:208:3e7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Thu, 22 Jun 2023 03:54:44 +0000 Received: from BN8NAM11FT012.eop-nam11.prod.protection.outlook.com (2603:10b6:408:112:cafe::eb) by BN9PR03CA0306.outlook.office365.com (2603:10b6:408:112::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23 via Frontend Transport; Thu, 22 Jun 2023 03:54: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 BN8NAM11FT012.mail.protection.outlook.com (10.13.177.55) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.41 via Frontend Transport; Thu, 22 Jun 2023 03:54:43 +0000 Received: from ethanolx7ea3host.amd.com (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.23; Wed, 21 Jun 2023 22:54:42 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v6 11/27] cxl/port: Remove Component Register base address from struct cxl_dport Date: Wed, 21 Jun 2023 22:51:10 -0500 Message-ID: <20230622035126.4130151-12-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622035126.4130151-1-terry.bowman@amd.com> References: <20230622035126.4130151-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: BN8NAM11FT012:EE_|IA1PR12MB6233:EE_ X-MS-Office365-Filtering-Correlation-Id: 4bc9279d-7e14-49fa-7d39-08db72d469d2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DcCuhafmN6N6CTm1Z2m4AL5wa9FUBusrjAZRphoxXXowaFVTR7BldEYY0R22Mxf0QfPYEPbhszmEkcBfvH/qRRpgHShD06ZnI19mr3n/KZ2EMO2T4knBt0sbbOLIwJz1QZGUOkPMl/kHNyKZbK7gAIeSneEcy9iv4UwDNBYt4IJgVYPKxBWEvbbff/Y2oAL9sYyCcFCAKMsENHIxxyr6CwWVKg8c2iMnQAAd2ssYX77PfyJY/gZ0aibSIYXZeE7oYUidzY2+qofwdTTvGTKTFqKFdKOAGF+Co1LSlJhZegcSxUkvWMV7B7tU6v3AAaTTtecZadR4MO2O8SXAMyHX43RPLVDQlWqgSbzbdFytKM7pi+qdYf1tfW+4uyI2NN28wDMUS0CntatvglKrNt0qdmsvOOr1hLDjQKm5B38I1cjYVZaO+YH08ZDO4O8+SAvAyJGTxfrUNQf7isLr+cMYx7yyKd4Sq3RIcDyL77OcyxIuxGTVI6HcxPzMyKYFiNVy4IjGuMMCXRWdinRiarZbKl/Ll5dXFNHWNFGs9kPiHD36YMIza9JQTCmYXI1a5nsZl2cfEGx2FkqMK02JxC6eKf5lOrbD5k8tf0d5wDKCbbn9KT34Tha5B1hTC6reUia4ULXWd1h+HuFjk13iZ03c19v8KUtd/GajPdA+8NasZvhQumqX1DjLkr0p0fELMx9mhrBKUP83cyMrZr9E5xHG0gGOSVtIfCmbKnjtWsEtDXS+MRYIZ1/Hj2H6SntCGi4rR21uyGt9ok8uFcASxzqR9g== 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:(13230028)(4636009)(39860400002)(346002)(376002)(396003)(136003)(451199021)(36840700001)(40470700004)(46966006)(82740400003)(8936002)(8676002)(7416002)(86362001)(44832011)(82310400005)(5660300002)(41300700001)(2906002)(81166007)(356005)(110136005)(54906003)(478600001)(40480700001)(83380400001)(6666004)(7696005)(36860700001)(4326008)(316002)(70206006)(40460700003)(36756003)(2616005)(16526019)(26005)(47076005)(426003)(336012)(70586007)(1076003)(186003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2023 03:54:43.6623 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4bc9279d-7e14-49fa-7d39-08db72d469d2 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: BN8NAM11FT012.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6233 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter The Component Register base address @component_reg_phys is no longer used after the rework of the Component Register setup which now uses struct member @comp_map instead. Remove the base address. Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang --- drivers/cxl/core/port.c | 1 - drivers/cxl/cxl.h | 2 -- 2 files changed, 3 deletions(-) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index cdfe0ea7a2e9..e0d2e7596440 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -960,7 +960,6 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev, dport->dport_dev = dport_dev; dport->port_id = port_id; - dport->component_reg_phys = component_reg_phys; dport->port = port; cond_cxl_root_lock(port); diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index ae265357170e..7fbc52b81554 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -594,7 +594,6 @@ struct cxl_rcrb_info { * struct cxl_dport - CXL downstream port * @dport_dev: PCI bridge or firmware device representing the downstream link * @port_id: unique hardware identifier for dport in decoder target list - * @component_reg_phys: downstream port component registers * @rcrb: Data about the Root Complex Register Block layout * @rch: Indicate whether this dport was enumerated in RCH or VH mode * @port: reference to cxl_port that contains this downstream port @@ -602,7 +601,6 @@ struct cxl_rcrb_info { struct cxl_dport { struct device *dport_dev; int port_id; - resource_size_t component_reg_phys; struct cxl_rcrb_info rcrb; bool rch; struct cxl_port *port; From patchwork Thu Jun 22 03:51:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13288226 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 498A5EB64D8 for ; Thu, 22 Jun 2023 03:56:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230213AbjFVD4i (ORCPT ); Wed, 21 Jun 2023 23:56:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230214AbjFVDzu (ORCPT ); Wed, 21 Jun 2023 23:55:50 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2079.outbound.protection.outlook.com [40.107.220.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8331272A; Wed, 21 Jun 2023 20:55:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fmdcu5qeo8R/YCVANohoWn8YC5ToU45aAZFCiBlGElcbbbrJ5VZmpQOVLAdmUps3o9K3L7i6Oucmp5m5Nw/SJLnhLXXc4le2ssnwY7kgdYeKvWnZDZuMYXH7WfO5qYDpVeHbJaH/wX/I4D45CoQyil6U2Lb9Htib64ZtzvJhwtVV7KdqFdmN/tknd4DSVzR4GiJeDRd7os7AlwgGVZlshTwdD0CLkO6HXT+KIW4pFj250XM3kJo58TlfCUkNqMwDeR3r1RtzHWLXz5sX4gSgagwNJzROy9+dnGt3uaM4W1iZZ13Ca8qlUbh2F+VBBFJhwYK2XbDXVpN2lMkpukPZaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=8IqJ+mOd5KPwVI76S2Q/gRsUbFq6Y6yh5uPvLB4Nqb4=; b=jdOGFdlgiwzVuv3ItP1IlMi8trd1YvUmq8l/bUjEZg4YSdfwBz4MLJYXKhjzRJvufl/Qp6+b5xcXniz41yt1JcqE/RcimFyDbFz01Jlam8hOaQUZoh417j6rmQFPeJASXX2nGgQ0+vl/zGpAbHG5Kybla6EO7gxg8ir8jvRNFmIU6KTmr02IKR1KgkTv5EYWexAtZUzEm80mrI54OnVGEoxdIKyn+eRNKHo9fcXgpHW7k6rUOVH5BuJy+E+OKwM5FqW7Ug3VTZZ6GzgnLof0lrsVG1fYE6TLbIvCj7dlOs+0/0DKFf6rAMM488QccCXrso8cUgjmexP+rl6kbUZKrw== 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 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=8IqJ+mOd5KPwVI76S2Q/gRsUbFq6Y6yh5uPvLB4Nqb4=; b=JzZQst2yBx5MdpMEGZYeTAb98VdxA32j+OdRrBUYg404//fFhbtaVJewPPfDXCgeqqZER3w3jqDNdsIR4fjNPHfyAY3jtpsdAldaQwATR+GDFT6TAEIHabcC3UKlmetakoyGPjmnVZhoERJ+6SIAx/3aX4dbB3Pdt9GN7TkUTQA= Received: from BN0PR03CA0011.namprd03.prod.outlook.com (2603:10b6:408:e6::16) by IA0PR12MB8747.namprd12.prod.outlook.com (2603:10b6:208:48b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.35; Thu, 22 Jun 2023 03:54:55 +0000 Received: from BN8NAM11FT030.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e6:cafe::56) by BN0PR03CA0011.outlook.office365.com (2603:10b6:408:e6::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24 via Frontend Transport; Thu, 22 Jun 2023 03:54: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 BN8NAM11FT030.mail.protection.outlook.com (10.13.177.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.41 via Frontend Transport; Thu, 22 Jun 2023 03:54:55 +0000 Received: from ethanolx7ea3host.amd.com (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.23; Wed, 21 Jun 2023 22:54:54 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v6 12/27] cxl/regs: Remove early capability checks in Component Register setup Date: Wed, 21 Jun 2023 22:51:11 -0500 Message-ID: <20230622035126.4130151-13-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622035126.4130151-1-terry.bowman@amd.com> References: <20230622035126.4130151-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: BN8NAM11FT030:EE_|IA0PR12MB8747:EE_ X-MS-Office365-Filtering-Correlation-Id: 2e69c060-30d2-4987-016d-08db72d470a6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aw25LaJIPzsfACsn4YXYIzvQsRENHEFGulWlUWu8Kw5GDfrgMy/dtunw76LLRTOb+2TzaKXjL57tVVHamIzgZPBp2SWvxNCOYbiNoPFahCDxbmJlwtXPyS3THZaRaZbTo0tDWclNZIBoH50I3s9DFsaxXpkq3qq/THigvuwTmaiBr/3l1P2OEw6SUyxV7XW+0QvFJxlBjqcxZaic6EO7XXiZP5CUzVzKwstKXlKjiRm0+/YzzwT4pU0IGMWi5nhakza1G+UIUmihUhdyOVlYb0DPvLPx5l6DgvzXinPH6hguCusb+yuhqeCa6f2CNRZx6+DgBFWRmSS4qflqFNF8sSnlapGPbtbxnGSKiTlPhroLqYqsbDUF9P3JX5jXGuwnhIP162lz8q0yyM3P0HhkEDTG/7b/qYoe55QMUReEGBzI2Wa8CV0MWJtQngpkt5TB72YGHBkbtmuOa2TyrdTDbkMXcM1okBeXgdE3uXKPWJstVlBZbRZ/7RveAu0KimBB8OXQpQfm3XGdKvxIntbW5Bx9CZDNWhhT75EM+EYcBXeyt7jJAr5VIEbaAiglp50Rqnl8FgGHixoNntNFJksoRnyTHebE9RbafV3R4l40gQNyaJjHRQcOTu7g/VdAisMXHwMupxIvpcrT86Fvhw1JKGgDXH4GlA9VbHUB55C0XC8UC4kY/oLWjY1WGLvaAw3bKZp7nBkw4HyQtG9SRYZVvcyS/b7rqJjBGhjCM0qxQEU453T/ug/OBQnnn4VA7aXd3faBG788LkY39wMAFv0Zbg== 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:(13230028)(4636009)(376002)(396003)(346002)(39860400002)(136003)(451199021)(40470700004)(36840700001)(46966006)(7416002)(356005)(81166007)(336012)(426003)(2616005)(47076005)(83380400001)(86362001)(36860700001)(44832011)(2906002)(5660300002)(82740400003)(4326008)(54906003)(110136005)(16526019)(40460700003)(70206006)(8936002)(8676002)(82310400005)(186003)(26005)(478600001)(36756003)(41300700001)(1076003)(40480700001)(70586007)(316002)(7696005)(6666004)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2023 03:54:55.0992 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2e69c060-30d2-4987-016d-08db72d470a6 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: BN8NAM11FT030.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8747 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter When probing the Component Registers in function cxl_probe_regs() there are also checks for the existence of the HDM and RAS capabilities. The checks may fail for components that do not implement the HDM capability causing the Component Registers setup to fail too. Remove the checks for a generalized use of cxl_probe_regs() and check them directly before mapping the RAS or HDM capabilities. This allows it to setup other Component Registers esp. of an RCH Downstream Port, which will be implemented in a follow-on patch. Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang --- drivers/cxl/core/regs.c | 8 -------- drivers/cxl/pci.c | 2 ++ drivers/cxl/port.c | 5 ++++- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/cxl/core/regs.c b/drivers/cxl/core/regs.c index e035ad8827a4..e68848075bb6 100644 --- a/drivers/cxl/core/regs.c +++ b/drivers/cxl/core/regs.c @@ -369,14 +369,6 @@ static int cxl_probe_regs(struct cxl_register_map *map) case CXL_REGLOC_RBI_COMPONENT: comp_map = &map->component_map; cxl_probe_component_regs(dev, base, comp_map); - if (!comp_map->hdm_decoder.valid) { - dev_err(dev, "HDM decoder registers not found\n"); - return -ENXIO; - } - - if (!comp_map->ras.valid) - dev_dbg(dev, "RAS registers not found\n"); - dev_dbg(dev, "Set up component registers\n"); break; case CXL_REGLOC_RBI_MEMDEV: diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c index ac17bc0430dc..945ca0304d68 100644 --- a/drivers/cxl/pci.c +++ b/drivers/cxl/pci.c @@ -630,6 +630,8 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) rc = cxl_pci_setup_regs(pdev, CXL_REGLOC_RBI_COMPONENT, &map); if (rc) dev_warn(&pdev->dev, "No component registers (%d)\n", rc); + else if (!map.component_map.ras.valid) + dev_dbg(&pdev->dev, "RAS registers not found\n"); cxlds->component_reg_phys = map.resource; diff --git a/drivers/cxl/port.c b/drivers/cxl/port.c index 4cef2bf45ad2..01e84ea54f56 100644 --- a/drivers/cxl/port.c +++ b/drivers/cxl/port.c @@ -102,8 +102,11 @@ static int cxl_endpoint_port_probe(struct cxl_port *port) return rc; cxlhdm = devm_cxl_setup_hdm(port, &info); - if (IS_ERR(cxlhdm)) + if (IS_ERR(cxlhdm)) { + if (PTR_ERR(cxlhdm) == -ENODEV) + dev_err(&port->dev, "HDM decoder registers not found\n"); return PTR_ERR(cxlhdm); + } /* Cache the data early to ensure is_visible() works */ read_cdat_data(port); From patchwork Thu Jun 22 03:51:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13288227 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65643EB64DA for ; Thu, 22 Jun 2023 03:56:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230291AbjFVD44 (ORCPT ); Wed, 21 Jun 2023 23:56:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230168AbjFVD40 (ORCPT ); Wed, 21 Jun 2023 23:56:26 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on20625.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e89::625]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EEED1BF5; Wed, 21 Jun 2023 20:55:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VbqsO23Otzktk0u6AkErMtKYnLYUZm5ngogr+pjzgoyln/ZLKOPm/3pD9fQR5izqANDrpRhVpT1qEgbABC+aSiz0cgR+ls3zKpAQnlx8nqrGrIELvwjS/LzbHvJM1A+Dm+nqnIJ/VzX2OcSPKb+WvnL75hIwlUQpuLdqh1+DdcBtNXeXlrGAMOnfnkMWd1vi2rtry+1MTgXwN0oNmiKC9aYJ2Lwc876rkql/DMs1mmN0ZsN0p4Ek2Y/c1d1uqbsVIDqBTyfS3i0EOTDOQQrNhTE81fLKGSxr5uGdI9XGljFFPwr020IFM7+/v3e5qismOe7m5bH5K7u2/pNcA/PB/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=JImqAp9zoln5nJysoPYyHl2b/2Gg4IfkFwSEYsrRYgw=; b=OOHdXyXwUE3/iH2/a1jtN79/Ph3+gHaPaTR/otjr7kWFEA7V5IjWjpqY94FYJSI2x1r957S119/5wSEp5ogU4Pa1/6tXxGNyPTub37R5aFO8AiSe7ewwM0rvvkmiDllg0DMADYzTW9oLXf0bxnr7jdmDmvg4/gKVlCo32Wq/0j3MqKlhxU2hkbdn1+OPo2w5FC4KCBfy+RFDPvMAbKjnTtgMNyii4qZBhwd8cabgx/HHliEE0AtIWcz+rZky5M7MtUZb4MqybLVKPI6TEByv9m3JTHqy0M2ti915jvuQcfK/2/fkBq6LOGq4xNH8aZhcrJnfqUCz+NvTzUo8dyI5Ig== 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 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=JImqAp9zoln5nJysoPYyHl2b/2Gg4IfkFwSEYsrRYgw=; b=TGDfDePAe7VwIeOfnPEs+YA220Ll8jsFEuy6b7TcQpAHnvcJ1DzwicWhnkmQ+ZpoojrR2ogIGdX7dYOIO3Flx25AEawBea89NNgYlCwyVPPWS3hIAO/qvm7rMKdFydmV4jBdEyjqmu76JF/qdmq/PnND9nngFJ/y4ZtfwrRe9MM= Received: from BN1PR13CA0025.namprd13.prod.outlook.com (2603:10b6:408:e2::30) by LV8PR12MB9109.namprd12.prod.outlook.com (2603:10b6:408:18a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Thu, 22 Jun 2023 03:55:06 +0000 Received: from BN8NAM11FT077.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e2:cafe::c0) by BN1PR13CA0025.outlook.office365.com (2603:10b6:408:e2::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.9 via Frontend Transport; Thu, 22 Jun 2023 03:55:06 +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 BN8NAM11FT077.mail.protection.outlook.com (10.13.177.232) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.41 via Frontend Transport; Thu, 22 Jun 2023 03:55:06 +0000 Received: from ethanolx7ea3host.amd.com (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.23; Wed, 21 Jun 2023 22:55:05 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v6 13/27] cxl/mem: Prepare for early RCH dport component register setup Date: Wed, 21 Jun 2023 22:51:12 -0500 Message-ID: <20230622035126.4130151-14-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622035126.4130151-1-terry.bowman@amd.com> References: <20230622035126.4130151-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: BN8NAM11FT077:EE_|LV8PR12MB9109:EE_ X-MS-Office365-Filtering-Correlation-Id: d5c29e6e-a1b6-4476-db99-08db72d4772e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pA5VQX5d76RgfQpbyvQxpGcsF3qRo61NOCCl1Z/+9n9EDCtfBhXSd43Hi4x7bl236SH+RuzBrvFIDt70h2ZcfCbdKnKtaQYLdUDRB4Hz+JXlJLpSygB/atdmcaahZOWJTdiORuZ0XFzGxmBqRULSYX3v60IQ6jSflem8QZkknyDXtUe4i/I+e6NPAMHRvkH26qH+BUBSLWEHV1l1rK4DsQdd6xCEcoC/FTER89VuskzfOGyqvNwlcOu3aTTn/0VEMRSZM9CtrhNLuLuSPGsmtZz9upcM5gq9NClCW2HKGvGMyXfcUaFxq4dVQI7pMw8GfQrqksHW04jIsr+UexfY9NBWV1tdrJ5MR5tYCn4fc07Xlp11x6aCwTRccUnjG5VTidrR7blkwFQbhLfAdDyD3gtTbIgISHvf3O3slNP8XbP6l/4N7Zf3E8I6poeK2GVLELhxd4vkpHHrW7gPWINAEnBHZIIvNcldeT/yZI9qBixxeigZ+mO6jpnUid9+g8FHqKztYj9fcma6N9RkvPFYQ4tagGmP4uAI3MUyFQW1qOYsLnSmE8JoeLWNWQArxj1ffef4UT/qaqlUcwSTPQu6VZoO+fTDS43omA4y/mHZgIWXyh+W6J67vDqy/mSFbaJeesTOTwTSpR4Voj0W7sUJcTstNEaodIYQ2apiTmEmU3ORK5sZHjvxHvAuaBT1NIE1tHqHTWbLE/njQQF4VxrdJ51ztjoyRJztSO9puAoGxrgeadETMIWLGh2sYgLqlow5fhM1GtMIM1cl6yWYLUUSKw== 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:(13230028)(4636009)(346002)(396003)(136003)(39860400002)(376002)(451199021)(36840700001)(46966006)(40470700004)(6666004)(40460700003)(2906002)(426003)(336012)(16526019)(186003)(2616005)(36860700001)(47076005)(83380400001)(70206006)(70586007)(110136005)(7696005)(54906003)(316002)(7416002)(5660300002)(8936002)(26005)(478600001)(44832011)(1076003)(41300700001)(8676002)(40480700001)(81166007)(82740400003)(356005)(36756003)(82310400005)(86362001)(4326008)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2023 03:55:06.0937 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d5c29e6e-a1b6-4476-db99-08db72d4772e 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: BN8NAM11FT077.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9109 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter In order to move the RCH dport component register setup to cxl_pci the base address must be stored in CXL device state (cxlds) for both modes, RCH and VH. Store it in cxlds->component_reg_phys and use it for endpoint creation. Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang --- drivers/cxl/mem.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c index 4cc461c22b8b..7638a7f8f333 100644 --- a/drivers/cxl/mem.c +++ b/drivers/cxl/mem.c @@ -51,7 +51,6 @@ static int devm_cxl_add_endpoint(struct device *host, struct cxl_memdev *cxlmd, struct cxl_port *parent_port = parent_dport->port; struct cxl_dev_state *cxlds = cxlmd->cxlds; struct cxl_port *endpoint, *iter, *down; - resource_size_t component_reg_phys; int rc; /* @@ -72,11 +71,11 @@ static int devm_cxl_add_endpoint(struct device *host, struct cxl_memdev *cxlmd, * typical register locator mechanism. */ if (parent_dport->rch && cxlds->component_reg_phys == CXL_RESOURCE_NONE) - component_reg_phys = + cxlds->component_reg_phys = cxl_rcd_component_reg_phys(&cxlmd->dev, parent_dport); - else - component_reg_phys = cxlds->component_reg_phys; - endpoint = devm_cxl_add_port(host, &cxlmd->dev, component_reg_phys, + + endpoint = devm_cxl_add_port(host, &cxlmd->dev, + cxlds->component_reg_phys, parent_dport); if (IS_ERR(endpoint)) return PTR_ERR(endpoint); From patchwork Thu Jun 22 03:51:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13288228 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AC39EB64D8 for ; Thu, 22 Jun 2023 03:57:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230274AbjFVD5P (ORCPT ); Wed, 21 Jun 2023 23:57:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230217AbjFVD4u (ORCPT ); Wed, 21 Jun 2023 23:56:50 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2077.outbound.protection.outlook.com [40.107.92.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A86062697; Wed, 21 Jun 2023 20:55:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UJdL5lX47nf/5OCNqWWaUJ3kbZp9xATjrxnKas0rES/FQIIhsWuWWdpfGkDbs4fx3+QLBtRI9WtcnV7TwNEwytASOvdeZ7HVgOBzlZ0iLOOexG2eVH5Xyp93R9IpppYYVPnUwQf8FbpHyIsnVeHJcWaCuM48LoZibC8rE7uEwkJsdR7WyztMqiR+dUBdMEZK2wMr3XDF2/jeHuC8/Zak0yG3Z1jdTSfDPU/7ppc2zgMbeTxyyiRVZUEjr0HFR4b+9UNiMMJ1ogw5nyxUbDAPSipY7Cs5ZWNbJyDwtaDtslQ2z8eT19IvEZ1Ymv9oInFLSg9/irAHFoEKHA/XO6Nj2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=rBvELRqVB7hvBd5b5FCHAc83MFI4yeW3soNfKmg7peE=; b=Htbk/SxhlR4+E8ni6Dv/bY3xWs8OaGYdPdP1O7HgoK67mWOYY4/dlB91nnwGrvcfRctDXhWJEVjJro2Ig23ONKbFOw7ajfZ2fF651i0YD8536MQOw9BxisdJ8IslBWmu3ktBUpxFLnxtpuI3gysw3ZuF0X1Ff/49vnikvjKsVs9efF+z1qDS4s32Q+AWnI3laVA613EX8/eDKjXmEX5lnbKWIMiIE2hIffc9/gsLrLG/6w/6Iq5wE6KyK6nA9/Y0MCtzsJh7fecZ1dfLeMmf+cgcIy68pIIwTXA99GxNVH43S5cU5hLHNf0LWGVaUFTZQztwraNm3VF23UHF6QH7Lg== 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 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=rBvELRqVB7hvBd5b5FCHAc83MFI4yeW3soNfKmg7peE=; b=AMJZHmvND/YKcSB5YIKsaUU1ZgL4ekFb+mZ5jGDOX55LveQJo6p0eavusO7ku5BnDoe5N7pPCfxqMWldzOhgMbYN9GTEHtuhGWQ6zmVI+rnA84aDy1y0kXWpTQLaqIdRsbwe43/CoOaulqtm4HpVlWKSNbU/8mGU9RgxMFUUa0k= Received: from BN9PR03CA0078.namprd03.prod.outlook.com (2603:10b6:408:fc::23) by BL1PR12MB5048.namprd12.prod.outlook.com (2603:10b6:208:30a::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24; Thu, 22 Jun 2023 03:55:17 +0000 Received: from BN8NAM11FT033.eop-nam11.prod.protection.outlook.com (2603:10b6:408:fc:cafe::95) by BN9PR03CA0078.outlook.office365.com (2603:10b6:408:fc::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23 via Frontend Transport; Thu, 22 Jun 2023 03:55: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 BN8NAM11FT033.mail.protection.outlook.com (10.13.177.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.41 via Frontend Transport; Thu, 22 Jun 2023 03:55:17 +0000 Received: from ethanolx7ea3host.amd.com (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.23; Wed, 21 Jun 2023 22:55:15 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v6 14/27] cxl/pci: Early setup RCH dport component registers from RCRB Date: Wed, 21 Jun 2023 22:51:13 -0500 Message-ID: <20230622035126.4130151-15-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622035126.4130151-1-terry.bowman@amd.com> References: <20230622035126.4130151-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: BN8NAM11FT033:EE_|BL1PR12MB5048:EE_ X-MS-Office365-Filtering-Correlation-Id: bb8838a9-fad3-44c1-a538-08db72d47db8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jZDDFp0X1JXT/2RvSptqLkztj+iN9HR3V1Jy6oQxH4y+Kn5r5UloUNto9s5cK46wZz1PfgQsJHZpDAXsOW6pjB85CPQYy3BNGfRco1sRFxklazLIHkV2ePa2AutKDldKoHQvg9htS4+AmKEG4wYuUprV+uNbLWAJwY09cUKTzJ7Ve0lkq1m4NHvxr6QAp+0yWf60rmihGeNM3WXJE6DaqSx+chg3lhYprPEJWrWyArKlzuj+VlriybfE8/AzDD16dhXS1gRsrJ/4f5WLuV9t97vZ0kjAV05VP7xwJ2RTLq4RJwz0vCH8HCG1tM4dXeRq7ZlaI11u9LWbiBBv4QXlhGzWJ7UT1oPgZuHTNv4y1Mbv5Um7QThdy16iiYRCHb0Yh0PJ7EnooTcc3N2+asiTSdS7pvLy/YYhNPeKtn+DYZKzKFqYn097O4+GmuXmKleNyH65zVrvctFBj6tRXiqTXznsNHMJrEbDAWCxW68eiDa+PP4uCUC9jHjqArIxy1gy6zjJKSyg4Dz8YRymH/QZJaGJJ0URQ/PHEbmHcHh3EdkM+9GR7IcGZ6D4zMwnxZ81MGulRc79a2Nckc4hstHm3FmZUUFi2W/aJNOJWaqwXcF/t+b/8n87L3Tp+ea5FvJbNOQ4cKAAFJ6DP2uKS8PhsniWhJu9+FCRP4JZHa2j4LUDnmj1R/zgM10KMMfFv1iskHKg6qKHu8IkLSrKyn2s6GH6eTeA1QWedSYiTXv6ZnFrjPBeWJtzT9oxqwJZUNW1MQcDwFIzkiYlb9cxyFsEvw== 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:(13230028)(4636009)(39860400002)(136003)(376002)(396003)(346002)(451199021)(40470700004)(46966006)(36840700001)(54906003)(2616005)(86362001)(110136005)(478600001)(40480700001)(7696005)(16526019)(186003)(4326008)(41300700001)(316002)(47076005)(83380400001)(336012)(426003)(1076003)(26005)(70206006)(70586007)(82310400005)(8676002)(8936002)(5660300002)(36756003)(44832011)(7416002)(40460700003)(36860700001)(2906002)(82740400003)(81166007)(356005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2023 03:55:17.0474 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bb8838a9-fad3-44c1-a538-08db72d47db8 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: BN8NAM11FT033.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5048 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter CXL RAS capabilities must be enabled and accessible as soon as the CXL endpoint is detected in the PCI hierarchy and bound to the cxl_pci driver. This needs to be independent of other modules such as cxl_port or cxl_mem. CXL RAS capabilities reside in the Component Registers. For an RCH this is determined by probing RCRB which is implemented very late once the CXL Memory Device is created. Change this by moving the RCRB probe to the cxl_pci driver. Do this by using a new introduced function cxl_pci_find_port() similar to cxl_mem_find_port() to determine the involved dport by the endpoint's PCI handle. Plug this into the existing cxl_pci_setup_regs() function to setup Component Registers. Probe the RCRB in case the Component Registers cannot be located through the CXL Register Locator capability. This unifies code and early sets up the Component Registers at the same time for both, VH and RCH mode. Only the cxl_pci driver is involved for this. This allows an early mapping of the CXL RAS capability registers. Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang --- drivers/cxl/core/port.c | 7 +++++ drivers/cxl/cxl.h | 2 ++ drivers/cxl/mem.c | 9 ------- drivers/cxl/pci.c | 57 ++++++++++++++++++++++++++++++++++------- 4 files changed, 57 insertions(+), 18 deletions(-) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index e0d2e7596440..679226023f0c 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -1480,6 +1480,13 @@ int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd) } EXPORT_SYMBOL_NS_GPL(devm_cxl_enumerate_ports, CXL); +struct cxl_port *cxl_pci_find_port(struct pci_dev *pdev, + struct cxl_dport **dport) +{ + return find_cxl_port(pdev->dev.parent, dport); +} +EXPORT_SYMBOL_NS_GPL(cxl_pci_find_port, CXL); + struct cxl_port *cxl_mem_find_port(struct cxl_memdev *cxlmd, struct cxl_dport **dport) { diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index 7fbc52b81554..fe95f08acb69 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -664,6 +664,8 @@ struct cxl_port *find_cxl_root(struct cxl_port *port); int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd); void cxl_bus_rescan(void); void cxl_bus_drain(void); +struct cxl_port *cxl_pci_find_port(struct pci_dev *pdev, + struct cxl_dport **dport); struct cxl_port *cxl_mem_find_port(struct cxl_memdev *cxlmd, struct cxl_dport **dport); bool schedule_cxl_memdev_detach(struct cxl_memdev *cxlmd); diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c index 7638a7f8f333..205e2e280aed 100644 --- a/drivers/cxl/mem.c +++ b/drivers/cxl/mem.c @@ -65,15 +65,6 @@ static int devm_cxl_add_endpoint(struct device *host, struct cxl_memdev *cxlmd, ep->next = down; } - /* - * The component registers for an RCD might come from the - * host-bridge RCRB if they are not already mapped via the - * typical register locator mechanism. - */ - if (parent_dport->rch && cxlds->component_reg_phys == CXL_RESOURCE_NONE) - cxlds->component_reg_phys = - cxl_rcd_component_reg_phys(&cxlmd->dev, parent_dport); - endpoint = devm_cxl_add_port(host, &cxlmd->dev, cxlds->component_reg_phys, parent_dport); diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c index 945ca0304d68..99a75c54ee39 100644 --- a/drivers/cxl/pci.c +++ b/drivers/cxl/pci.c @@ -274,27 +274,66 @@ static int cxl_pci_setup_mailbox(struct cxl_dev_state *cxlds) return 0; } +/* + * Assume that any RCIEP that emits the CXL memory expander class code + * is an RCD + */ +static bool is_cxl_restricted(struct pci_dev *pdev) +{ + return pci_pcie_type(pdev) == PCI_EXP_TYPE_RC_END; +} + +static int cxl_rcrb_get_comp_regs(struct pci_dev *pdev, + struct cxl_register_map *map) +{ + struct cxl_port *port; + struct cxl_dport *dport; + resource_size_t component_reg_phys; + + *map = (struct cxl_register_map) { + .dev = &pdev->dev, + .resource = CXL_RESOURCE_NONE, + }; + + port = cxl_pci_find_port(pdev, &dport); + if (!port) + return -EPROBE_DEFER; + + component_reg_phys = cxl_rcd_component_reg_phys(&pdev->dev, dport); + + put_device(&port->dev); + + if (component_reg_phys == CXL_RESOURCE_NONE) + return -ENXIO; + + map->resource = component_reg_phys; + map->reg_type = CXL_REGLOC_RBI_COMPONENT; + map->max_size = CXL_COMPONENT_REG_BLOCK_SIZE; + + return 0; +} + static int cxl_pci_setup_regs(struct pci_dev *pdev, enum cxl_regloc_type type, struct cxl_register_map *map) { int rc; rc = cxl_find_regblock(pdev, type, map); + + /* + * If the Register Locator DVSEC does not exist, check if it + * is an RCH and try to extract the Component Registers from + * an RCRB. + */ + if (rc && type == CXL_REGLOC_RBI_COMPONENT && is_cxl_restricted(pdev)) + rc = cxl_rcrb_get_comp_regs(pdev, map); + if (rc) return rc; return cxl_setup_regs(map); } -/* - * Assume that any RCIEP that emits the CXL memory expander class code - * is an RCD - */ -static bool is_cxl_restricted(struct pci_dev *pdev) -{ - return pci_pcie_type(pdev) == PCI_EXP_TYPE_RC_END; -} - /* * CXL v3.0 6.2.3 Table 6-4 * The table indicates that if PCIe Flit Mode is set, then CXL is in 256B flits From patchwork Thu Jun 22 03:51:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13288229 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DFF4EB64DA for ; Thu, 22 Jun 2023 03:57:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230326AbjFVD5l (ORCPT ); Wed, 21 Jun 2023 23:57:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230306AbjFVD44 (ORCPT ); Wed, 21 Jun 2023 23:56:56 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2061f.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5a::61f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F18E26AE; Wed, 21 Jun 2023 20:56:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lXVnwR70G0IGyVSoaKkX0Kxp/LEFB5aWY78ME01n9OxBNMX1B7VOXJTXiLylT/QpPeHcV9fduYnE0p8qxdjm0CEhQEB7BTexhZiQDK/NjGtKi7QPTMkMJ72APZbBtVtmHhtUPe131ibOwjfPy7pELyvcHxZXGV4cm28HqITHWdnkQH+VuDz5uab/dEvofC+9aLaAN3X+2zgLtv06R8yYM3pP5snLrDZPQ5oOSig6bI94lFLVfO0cVq9C55GpuPCwRwQ0q0qf/7B1MB8iIjBfNlzDVbiVafdaVXAYKYzatbSgxoPiJnwOsuwW1RDMrRktf7n9ff8QvviDbzzDda6Xbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=RwLtl14xwOqBYvA14zKZwMZRXZc8ID2gmY3rWTKg6NI=; b=H5Md3mfXpDl8uaVp8fBwJ63TTZRmCILh0Zu7a+/H/7X7BqPLNAkyvn2/aJZaWuSJ6ZOA5XnaEzZlFjkZfog6Ff/lJZX6pFI03HtIzuM3BPqrXNGu+IV+KXueGIciDq1ysc3Szj2BMKKWjaImmy9ZY65crhygLaQWyOoi0qxVzrfMp3KyIlQnmlOddAf1fdQhiBVj8Jl5mO0Ldh4H9/UtTnHDq60n8NQPpRsXDMO9vzokW7b/uUO5w++JAug68xOM7yIXIPiNXvJYNL5DNiMmPVvxJ0RMrZ3o8qoBc8nBENxYy2WGejRp1coFtMwrRm9EtumQl89ogOG6v+pqmqVAig== 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 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=RwLtl14xwOqBYvA14zKZwMZRXZc8ID2gmY3rWTKg6NI=; b=wqMm0LFSDln8EdCs04TntOdKNc2+YSHfkD5kQ3oo3PFHzi04L+RF2BkjO3eVlNM2e2QpJX9sxezzj0PWVGaU7f7WxLEb6n0ovkB1YywZRTGxgstijDP+Lf9T60G7PQeJmdXMo4uz5cCVCbh+U0oO9YOlBO/5eWEP0gemZPS4k7c= Received: from BN8PR12CA0016.namprd12.prod.outlook.com (2603:10b6:408:60::29) by IA1PR12MB6458.namprd12.prod.outlook.com (2603:10b6:208:3aa::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.39; Thu, 22 Jun 2023 03:55:28 +0000 Received: from BN8NAM11FT070.eop-nam11.prod.protection.outlook.com (2603:10b6:408:60:cafe::e5) by BN8PR12CA0016.outlook.office365.com (2603:10b6:408:60::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24 via Frontend Transport; Thu, 22 Jun 2023 03:55: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 BN8NAM11FT070.mail.protection.outlook.com (10.13.177.50) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.41 via Frontend Transport; Thu, 22 Jun 2023 03:55:27 +0000 Received: from ethanolx7ea3host.amd.com (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.23; Wed, 21 Jun 2023 22:55:26 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v6 15/27] cxl/port: Store the port's Component Register mappings in struct cxl_port Date: Wed, 21 Jun 2023 22:51:14 -0500 Message-ID: <20230622035126.4130151-16-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622035126.4130151-1-terry.bowman@amd.com> References: <20230622035126.4130151-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: BN8NAM11FT070:EE_|IA1PR12MB6458:EE_ X-MS-Office365-Filtering-Correlation-Id: 8307142f-4d44-41c7-d7ed-08db72d48411 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k9w+GRd3NRp/vaeVErRJJZCnH/ByBjYyjG4qpG+iOzje1qCec1EjPoy27wEKDa8wIUrfPS5GFgFSiwfDluZLbvIPvlbfFjmnUeIylKFLCfIgONTv7WA1zjYPqKhbxVTl426rHIwJZXtGyREXmeSAz6UeZcShUmDwYsXt6zBToo4ZUngjHiLci7/LjIUnKiNXIHE+lgHqbTWmz5zjHeMBdZIY9TFXKSpS5AOeJL59l3oDqQrFQZe5Oi+51sxstX+ydQC1n7jwHIo/klvBD9xYme2Dh23rmZefMmNhPa+7W/h3AG6kHcnpvTacOJdi4tCAlxreYKfErCmc1B6YRCXsNno32lrK8ti4usTRXDvc6gyRm3OhRPr19hLJSJS3vK7aFVZ/S5ArCcohe8sKqKgQcWmmnPbbWtoVC7hMNAqXzU+2s90blxe+hcgvD3AKo6rqX9scF+cmbnM58TdjSqkQz4M2Tlkk2plOvTfBlARY5yLYUnnPrrkWlLJnb2rcMo3MIs7VlvIor4tRTZ436V6dffsbkLyjM0utIVSMnjAzAOwgZgTTQiNzm9JPMWpRsmm1cwtvbv+W+SQDsTldG9VFXa7W+4ISKvYGNuzU0INdqPQtuBfJh3B+UgW4bCH2LfkeKICaIatqndvKc2H/yDElZYTMOEvLHA3VdG/TKSptxjbDyJB06wC++l2sN0mEg/8eNKNdMTWQ16yYtmDIps3dgwssaQwhhDiLy85+vCx5f9ILgDFZ/jiqMmr5bs8O4C4AYM6Gbe+Wmw7U+4kdlTxUJQ== 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:(13230028)(4636009)(39860400002)(376002)(346002)(136003)(396003)(451199021)(46966006)(36840700001)(40470700004)(82310400005)(7696005)(8936002)(8676002)(41300700001)(316002)(356005)(70206006)(44832011)(36756003)(7416002)(2906002)(81166007)(82740400003)(83380400001)(26005)(336012)(6666004)(110136005)(54906003)(478600001)(4326008)(426003)(40460700003)(86362001)(5660300002)(40480700001)(47076005)(70586007)(16526019)(36860700001)(2616005)(186003)(1076003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2023 03:55:27.6827 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8307142f-4d44-41c7-d7ed-08db72d48411 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: BN8NAM11FT070.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6458 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter CXL capabilities are stored in the Component Registers. To use them, the specific I/O ranges of the capabilities must be determined by probing the registers. For this, the whole Component Register range needs to be mapped temporarily to detect the offset and length of a capability range. In order to use more than one capability of a component (e.g. RAS and HDM) the Component Register are probed and its mappings created multiple times. This also causes overlapping I/O ranges as the whole Component Register range must be mapped again while a capability's I/O range is already mapped. Different capabilities cannot be setup at the same time. E.g. the RAS capability must be made available as soon as the PCI driver is bound, the HDM decoder is setup later during port enumeration. Moreover, during early setup it is still unknown if a certain capability is needed. A central capability setup is therefore not possible, capabilities must be individually enabled once needed during initialization. To avoid a duplicate register probe and overlapping I/O mappings, only probe the Component Registers one time and store the Component Register mapping in struct port. The stored mappings can be used later to iomap the capability register range when enabling the capability, which will be implemented in a follow-on patch. Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang --- drivers/cxl/core/port.c | 26 ++++++++++++++++++++++++++ drivers/cxl/cxl.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 679226023f0c..2e239fd33df9 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -688,6 +688,28 @@ static struct cxl_port *cxl_port_alloc(struct device *uport_dev, return ERR_PTR(rc); } +static int cxl_setup_comp_regs(struct device *dev, struct cxl_register_map *map, + resource_size_t component_reg_phys) +{ + if (component_reg_phys == CXL_RESOURCE_NONE) + return 0; + + memset(map, 0, sizeof(*map)); + map->dev = dev; + map->reg_type = CXL_REGLOC_RBI_COMPONENT; + map->resource = component_reg_phys; + map->max_size = CXL_COMPONENT_REG_BLOCK_SIZE; + + return cxl_setup_regs(map); +} + +static inline int cxl_port_setup_regs(struct cxl_port *port, + resource_size_t component_reg_phys) +{ + return cxl_setup_comp_regs(&port->dev, &port->comp_map, + component_reg_phys); +} + static struct cxl_port *__devm_cxl_add_port(struct device *host, struct device *uport_dev, resource_size_t component_reg_phys, @@ -711,6 +733,10 @@ static struct cxl_port *__devm_cxl_add_port(struct device *host, if (rc) goto err; + rc = cxl_port_setup_regs(port, component_reg_phys); + if (rc) + goto err; + rc = device_add(dev); if (rc) goto err; diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index fe95f08acb69..37fa5b565362 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -547,6 +547,7 @@ struct cxl_dax_region { * @regions: cxl_region_ref instances, regions mapped by this port * @parent_dport: dport that points to this port in the parent * @decoder_ida: allocator for decoder ids + * @comp_map: component register capability mappings * @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 @@ -566,6 +567,7 @@ struct cxl_port { struct xarray regions; struct cxl_dport *parent_dport; struct ida decoder_ida; + struct cxl_register_map comp_map; int nr_dports; int hdm_end; int commit_end; From patchwork Thu Jun 22 03:51:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13288230 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9628AEB64DB for ; Thu, 22 Jun 2023 03:57:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230194AbjFVD5n (ORCPT ); Wed, 21 Jun 2023 23:57:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230195AbjFVD5D (ORCPT ); Wed, 21 Jun 2023 23:57:03 -0400 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2062e.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8d::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77A992947; Wed, 21 Jun 2023 20:56:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hD5ZUQYbqmYC7XI4TFqSWPUzAZuL8LAzuAZ4Y1spcxZVq9R3EcO57iLu93vNNOGeenTW6gyTISKo+rxoK2gBkvyeNWCDkMqpxDdrPQosr4rJRU1/4fyTDaCk6m3bABBNLMCXlda90n/tDofRX1sSqBmWsukhpHxDqgqjrPW9PbDnOktcbbZN0IEibsaeFW1NOKy4Dn0yaPipZqvO+1TI02ZKchp2hSL31npsUgd9z/ffM+ieLfLppRG0qM4DNHYWEUZLBsznwi2fUktrLsZGWF0SeQ7ZjTKhhf0aVwdv56uyoHTRKwfhydaL7eRSBl7v2jC575IANKYbVU/Jsgtt8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=WQqzNKS+p3Yjjar0WkUmWJnbHRjOuv4h456uwKvVzH4=; b=N3AjYCNt//eVIorUJPtjJ1it4D7g0BSOy/b18paqI0s8BuQZla4mxxEZmbSdh+LKDZLX3fqXmuCzo7LZ+kSYccYGHg977fAEEASEPkr5oYbdi0mY6ZOBsx4r2YyMqhEUt03f2yHk0BXry18HbsR7Y6GLe1doMc/tJFb10oTcMb/M9yg+MY3kbnmjzjCzS6qudktI1TPoyNyg/VqZnFwAvfcxlN2aurUta+MrbT4G/2uboIwDTTh6oBGR+F+1dHGyxFAZzOMIDi1GJ4GQcX2qvkegPw51TGdfuCDwGhcWr+mBKPvg4CIPZu0mT5rwzFnr8mcYq8K/d63o9ABbjF/jdA== 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 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=WQqzNKS+p3Yjjar0WkUmWJnbHRjOuv4h456uwKvVzH4=; b=RQNZlyujD4ceVI2q02qRlpxpZ5dEEsSNn5Hp17bDeOFbglcARgPz5TjR9Dmffv6GMi3885sgJxEosXqc8g3bFMWZDtXVUxLmAFSkmE+YV5TWNDJwPimVVAc6jU55KwPmdOmo+egMt3zFBekWRTKnL0yg4og2PQTmxceXfMky7wk= Received: from BN0PR04CA0048.namprd04.prod.outlook.com (2603:10b6:408:e8::23) by LV3PR12MB9215.namprd12.prod.outlook.com (2603:10b6:408:1a0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.37; Thu, 22 Jun 2023 03:55:40 +0000 Received: from BN8NAM11FT114.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e8:cafe::c2) by BN0PR04CA0048.outlook.office365.com (2603:10b6:408:e8::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23 via Frontend Transport; Thu, 22 Jun 2023 03:55:40 +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 BN8NAM11FT114.mail.protection.outlook.com (10.13.177.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.41 via Frontend Transport; Thu, 22 Jun 2023 03:55:39 +0000 Received: from ethanolx7ea3host.amd.com (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.23; Wed, 21 Jun 2023 22:55:37 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v6 16/27] cxl/port: Store the downstream port's Component Register mappings in struct cxl_dport Date: Wed, 21 Jun 2023 22:51:15 -0500 Message-ID: <20230622035126.4130151-17-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622035126.4130151-1-terry.bowman@amd.com> References: <20230622035126.4130151-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: BN8NAM11FT114:EE_|LV3PR12MB9215:EE_ X-MS-Office365-Filtering-Correlation-Id: b128c6b9-36c9-4a30-0f1e-08db72d48b0c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NyGuUrGhjBqtEh5QZ3REX90mfTadn8E3YGyHIIeo1kP8bTl8nyehAxPM3/qR4+wsqYtIXA/SXfTSX/uNHH3GoFrERtReKqwVgoRNZ9sUSbOG0P1GpAUDf4R+mi6FQfAXV688jonFT3PUB7iaHFnKm4tFbVr47TOzy8Tzin3z9hWfr09z/jk6nVIOfEQPTlXPaLFp6WgxQnp9Q7gAroqskgwEa9hHUGmnZgzg5yAJ6Vq8q6b1vbUsPg+Rry0dSS4i+R+iG654+jXBM1nNcW3Tm1gmkWgOxGnU06lLJig0O45abmV1gDJab99PYJmAnWg21bmvsLV5kX4Zg0UNUY+9LclIQ0ct5bOs9tZfrlGUjGSgDnaNr7h864mCOjQgGHDhxlLjoFII1rTlodxys9H0s/EpBCb5CChQRUvmnYEvJReYGuisDbdiqzMGaSeBmPaQrUgWTZlXVTfg1prEXFNBtc+Ki2UZydKVrMFzd6c5Kbb44PCkV6wXqzkfQaL752WLTzMkkNw4J2QVyHBVVTVJH8GJeM4WbQxVIaKr+sNc814sMEqj47uIi/+1sWhDiRBATtuYreog85xRSGEX3GBOzvgzLj4U2M7zGfi0At1tfEP7p6RZUKFUqii3wEm9G9wKfsw8lKJhmopiHod3j0n/9zN1Y6HLkRnpaJvebdWJ1XfNUJK4vTsJVGMIhpn2XuSTfpPi4t0KqLnEmuky7Cd8MbTuvQde19l+GKfxag2mWsbgjtbnKT4guuh4A847/y7dT37OuUnekAUXhTLivCeFcw== 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:(13230028)(4636009)(136003)(346002)(376002)(39860400002)(396003)(451199021)(46966006)(36840700001)(40470700004)(82310400005)(7416002)(44832011)(356005)(86362001)(47076005)(8936002)(41300700001)(5660300002)(316002)(70206006)(70586007)(81166007)(2616005)(336012)(36860700001)(426003)(83380400001)(82740400003)(186003)(16526019)(26005)(40460700003)(1076003)(54906003)(4326008)(6666004)(110136005)(478600001)(2906002)(36756003)(8676002)(40480700001)(7696005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2023 03:55:39.4044 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b128c6b9-36c9-4a30-0f1e-08db72d48b0c 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: BN8NAM11FT114.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9215 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter Same as for ports, also store the downstream port's Component Register mappings, use struct cxl_dport for that. Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang --- drivers/cxl/core/port.c | 11 +++++++++++ drivers/cxl/cxl.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 2e239fd33df9..45fe7d89f7f3 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -710,6 +710,13 @@ static inline int cxl_port_setup_regs(struct cxl_port *port, component_reg_phys); } +static inline int cxl_dport_setup_regs(struct cxl_dport *dport, + resource_size_t component_reg_phys) +{ + return cxl_setup_comp_regs(dport->dport_dev, &dport->comp_map, + component_reg_phys); +} + static struct cxl_port *__devm_cxl_add_port(struct device *host, struct device *uport_dev, resource_size_t component_reg_phys, @@ -988,6 +995,10 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev, dport->port_id = port_id; dport->port = port; + rc = cxl_dport_setup_regs(dport, component_reg_phys); + if (rc) + return ERR_PTR(rc); + cond_cxl_root_lock(port); rc = add_dport(port, dport); cond_cxl_root_unlock(port); diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index 37fa5b565362..b1adca9b27ba 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -595,6 +595,7 @@ struct cxl_rcrb_info { /** * struct cxl_dport - CXL downstream port * @dport_dev: PCI bridge or firmware device representing the downstream link + * @comp_map: component register capability mappings * @port_id: unique hardware identifier for dport in decoder target list * @rcrb: Data about the Root Complex Register Block layout * @rch: Indicate whether this dport was enumerated in RCH or VH mode @@ -602,6 +603,7 @@ struct cxl_rcrb_info { */ struct cxl_dport { struct device *dport_dev; + struct cxl_register_map comp_map; int port_id; struct cxl_rcrb_info rcrb; bool rch; From patchwork Thu Jun 22 03:51:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13288231 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43B80EB64DA for ; Thu, 22 Jun 2023 03:57:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230340AbjFVD5r (ORCPT ); Wed, 21 Jun 2023 23:57:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230264AbjFVD5G (ORCPT ); Wed, 21 Jun 2023 23:57:06 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on20627.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe59::627]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7C9E2122; Wed, 21 Jun 2023 20:56:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RmBueEQP/fAQN4VgeDSO0nWdG62IyX3Hwz84k+jREzfoBxk23iBo2T2B/zUuyxIEL7nPmUu27T7tBB0OBcjTEmtLSjBt8fitFfAWooLynuQGfpN9nXOMx3FCAPOEMCcIWxPv+grnO7Rl6sq9o1kB5iYft7M60Lph60p5EXB5eINRrVctB09pE7K77JAySblZxuLbdzlHyOaO+N+jlJSmj3kXx6KJiQRbr3a/e8Rryrp61uCAwZbFiLY5pT7UrqlZlVJ+KgVwkwoiBh/SIqHdOON8bPTWZiutW7d9nCyO2l3c66omhv6ZbX372DJoRByzaIKPAO7t8+7CaMkh2/Sw4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=B8D11d93aD0raN4W9zkc7ZDlIv/12QAi/az/g2ZWtzE=; b=SmzDkMq+0s7RfxbucP3wrtVk1GfvUz/IODqyYeMAvFeXeDlTLsxKUdtA/yENwbwD1Qz//6Cob2AyOQa/50fpr+LHq63rlKjJrrwbCJh+uIHmxD/Pa4pmSkKpERjz0n6irC2qobc10u3qaKuGzxYcCF0ePBO2NEPqj/HXqXna4SeqeIu0OFeG1q2OGZ9A4xpqPO3fInEa6pgno09rmWE6VS80z5xJn9X2xhg7NjdbDoTcYzEM0LS+gs4y/6jUrRZHY8QREGF5J440PiAs0cPLuZCPc+aH1tYKGkDFIUTWeGyWdYXi7TLVn+yD70Fy95Aoxct29vloSPuNa3CaMYr7Gw== 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 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=B8D11d93aD0raN4W9zkc7ZDlIv/12QAi/az/g2ZWtzE=; b=DaXCCzQBqN8YzvHfJ0vBYxsEtS5xzFIa+Udxm62VOVkJvKD3MIX9A5Y9+OpMuRRS8RyBdo9Pxr64RG6dDY5gF/+xMXihwQWmldsTuQogqzeUstsUhVV8HR/zLSYG8LD7njjrfwvYEQFnK1bDvmauqk9tHWhRWtmEkz2K7Dr1IYg= Received: from BN9PR03CA0223.namprd03.prod.outlook.com (2603:10b6:408:f8::18) by CY8PR12MB8362.namprd12.prod.outlook.com (2603:10b6:930:7e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Thu, 22 Jun 2023 03:55:50 +0000 Received: from BN8NAM11FT063.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f8:cafe::31) by BN9PR03CA0223.outlook.office365.com (2603:10b6:408:f8::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23 via Frontend Transport; Thu, 22 Jun 2023 03:55:50 +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 BN8NAM11FT063.mail.protection.outlook.com (10.13.177.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.41 via Frontend Transport; Thu, 22 Jun 2023 03:55:49 +0000 Received: from ethanolx7ea3host.amd.com (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.23; Wed, 21 Jun 2023 22:55:48 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v6 17/27] cxl/pci: Store the endpoint's Component Register mappings in struct cxl_dev_state Date: Wed, 21 Jun 2023 22:51:16 -0500 Message-ID: <20230622035126.4130151-18-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622035126.4130151-1-terry.bowman@amd.com> References: <20230622035126.4130151-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: BN8NAM11FT063:EE_|CY8PR12MB8362:EE_ X-MS-Office365-Filtering-Correlation-Id: 1dbae379-57d4-4b60-40bd-08db72d49129 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8WTPIc6i2wpS868rlj4PqVpRr3vWrjr48fBzgLpnUM+ZymaabLg9hzDD8bTI0D/MzPHe/CBDs4t+Wmehhp4QpNKq7DYxcWjHwN8G4SMt9J7Wk2ziuRN0pg8k00uf8tSySWAG/bD0tMHlvp2zldR9aDNX2kCkh8b/akRL1UXgbCanEnrojJVImK9op7s7r67+5uMECP5LUeFoPCOhoHqcl25qzRs5DqtWjYiyvIBPg/dqzPImU+K1xSPoeKJ95Pq2io4rPKJDG8/3i3wiItISFBCQOwD0QSo2be0VAz5qbwGw9V8wOmJj7tJJHw5VwCHb/Ix5N4T+OJWlVtNXTxlQyZ5KRbp3waYZs5YgsZj7RM6ZtP7FL5kAVPu+ZNNuDo+YUC5Vy0fMxZ2fWz9xdvb5Z6ZgZEE4dMyQeNnh8OzE3J7J252GbdUZskCNGMQpGOKezpkduXIAkWWP4EBHRHCeXYVSkN9g7hAQRfy3+Ku6F5UG0KeAFYEZ99965QlBln1P2XzSsqr68babdY+HX7QErXTiKeY4RQ52JQ8wvGstPzSv4iNv07VxxbOl1mjtbmCsK9OmcapK4PWl/dvZc9eCb3+zwm/HdP8AOxOVNyIGOfa/TK37pSlmALBGWsbiDxkjFfDLlqAazU8iIVmLdv1VHVI9lvJecK3LHBn9SYij+PMVxwtLpElzLN76tC5IudXi8RuSKNrrxjh86o5tVNuZxqtbS3hNkBls0/P3qsIA7FhmQziQxg0Rg4SNPhUyMp06EH6TFQnaT772r00rmbEUPw== 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:(13230028)(4636009)(39860400002)(136003)(346002)(376002)(396003)(451199021)(46966006)(40470700004)(36840700001)(82740400003)(356005)(81166007)(86362001)(36756003)(47076005)(83380400001)(36860700001)(54906003)(110136005)(40460700003)(7696005)(6666004)(426003)(336012)(4326008)(316002)(70586007)(70206006)(2616005)(1076003)(16526019)(8676002)(8936002)(26005)(186003)(41300700001)(2906002)(82310400005)(7416002)(40480700001)(44832011)(478600001)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2023 03:55:49.6621 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1dbae379-57d4-4b60-40bd-08db72d49129 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: BN8NAM11FT063.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB8362 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter Same as for ports and dports, also store the endpoint's Component Register mappings, use struct cxl_dev_state for that. The Component Register base address @component_reg_phys is no longer used after the rework of the Component Register setup which now uses struct member @comp_map instead. Remove the base address. Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang --- drivers/cxl/cxlmem.h | 5 ++--- drivers/cxl/mem.c | 4 ++-- drivers/cxl/pci.c | 10 ++++------ tools/testing/cxl/test/mem.c | 1 - 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h index 76743016b64c..8aee1a42d9af 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -263,6 +263,7 @@ struct cxl_poison_state { * * @dev: The device associated with this CXL state * @cxlmd: The device representing the CXL.mem capabilities of @dev + * @comp_map: component register capability mappings * @regs: Parsed register blocks * @cxl_dvsec: Offset to the PCIe device DVSEC * @rcd: operating in RCD mode (CXL 3.0 9.11.8 CXL Devices Attached to an RCH) @@ -286,7 +287,6 @@ struct cxl_poison_state { * @active_persistent_bytes: sum of hard + soft persistent * @next_volatile_bytes: volatile capacity change pending device reset * @next_persistent_bytes: persistent capacity change pending device reset - * @component_reg_phys: register base of component registers * @info: Cached DVSEC information about the device. * @serial: PCIe Device Serial Number * @event: event log driver state @@ -299,7 +299,7 @@ struct cxl_poison_state { struct cxl_dev_state { struct device *dev; struct cxl_memdev *cxlmd; - + struct cxl_register_map comp_map; struct cxl_regs regs; int cxl_dvsec; @@ -325,7 +325,6 @@ struct cxl_dev_state { u64 next_volatile_bytes; u64 next_persistent_bytes; - resource_size_t component_reg_phys; u64 serial; struct cxl_event_state event; diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c index 205e2e280aed..92c6151b7206 100644 --- a/drivers/cxl/mem.c +++ b/drivers/cxl/mem.c @@ -49,7 +49,6 @@ static int devm_cxl_add_endpoint(struct device *host, struct cxl_memdev *cxlmd, struct cxl_dport *parent_dport) { struct cxl_port *parent_port = parent_dport->port; - struct cxl_dev_state *cxlds = cxlmd->cxlds; struct cxl_port *endpoint, *iter, *down; int rc; @@ -65,8 +64,9 @@ static int devm_cxl_add_endpoint(struct device *host, struct cxl_memdev *cxlmd, ep->next = down; } + /* The Endpoint's component regs are located in cxlds. */ endpoint = devm_cxl_add_port(host, &cxlmd->dev, - cxlds->component_reg_phys, + CXL_RESOURCE_NONE, parent_dport); if (IS_ERR(endpoint)) return PTR_ERR(endpoint); diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c index 99a75c54ee39..ad4cfcd95e17 100644 --- a/drivers/cxl/pci.c +++ b/drivers/cxl/pci.c @@ -665,16 +665,14 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) * If the component registers can't be found, the cxl_pci driver may * still be useful for management functions so don't return an error. */ - cxlds->component_reg_phys = CXL_RESOURCE_NONE; - rc = cxl_pci_setup_regs(pdev, CXL_REGLOC_RBI_COMPONENT, &map); + rc = cxl_pci_setup_regs(pdev, CXL_REGLOC_RBI_COMPONENT, + &cxlds->comp_map); if (rc) dev_warn(&pdev->dev, "No component registers (%d)\n", rc); - else if (!map.component_map.ras.valid) + else if (!cxlds->comp_map.component_map.ras.valid) dev_dbg(&pdev->dev, "RAS registers not found\n"); - cxlds->component_reg_phys = map.resource; - - rc = cxl_map_component_regs(&map, &cxlds->regs.component, + rc = cxl_map_component_regs(&cxlds->comp_map, &cxlds->regs.component, BIT(CXL_CM_CAP_CAP_ID_RAS)); if (rc) dev_dbg(&pdev->dev, "Failed to map RAS capability.\n"); diff --git a/tools/testing/cxl/test/mem.c b/tools/testing/cxl/test/mem.c index 34b48027b3de..fd562a5fa06f 100644 --- a/tools/testing/cxl/test/mem.c +++ b/tools/testing/cxl/test/mem.c @@ -1241,7 +1241,6 @@ static int cxl_mock_mem_probe(struct platform_device *pdev) cxlds->event.buf = (struct cxl_get_event_payload *) mdata->event_buf; if (is_rcd(pdev)) { cxlds->rcd = true; - cxlds->component_reg_phys = CXL_RESOURCE_NONE; } rc = cxl_enumerate_cmds(cxlds); From patchwork Thu Jun 22 03:51:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13288232 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2964EEB64D8 for ; Thu, 22 Jun 2023 03:57:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230241AbjFVD5y (ORCPT ); Wed, 21 Jun 2023 23:57:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230129AbjFVD5K (ORCPT ); Wed, 21 Jun 2023 23:57:10 -0400 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2042.outbound.protection.outlook.com [40.107.212.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 222491BD8; Wed, 21 Jun 2023 20:56:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BIAcSn0mQN1Tr/wxDtO5ch3lofi9oLG6tmJKWeCRnwkFdjVSMqZ0fxVESj/+CTMY4ONuvOBLF4vLafdiVHex8V3roV8qi42GmdGBen/znQ6GROT6P40aDLvt67W1ontzCzDbZ+JHIxWDipY5wHlNxztdliBqglOCaWO6fuoxK0sj1hgCgzKwKmaWpgl24MZ2kmasnUscNTxqvakTDgXEUyUO43K2P+jkrxYxypK6PZUcTXl0DSFq+7NkDK6ihJnZt2cKJwx6skiloS6oCuruN3gJeEscb8mUo7cvzHgqACCTvpCSrdYBmXEApwChGea06x6RT0eHVmLaRg6hgjKiOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=E059ipK/zVOw/u131srGq0nmEWQWJEXPx4wZxTDqqJM=; b=fpAVh2OpZCjOZEirY13VRozbclPi/SE1NaYYwpilhtN9NGVieO/3GFwWFc0meZj/97zx4zkdRU1XPSbwfJHsaLzSeL1QTnrzyV2XLX4nZG074Se+gOUO4h0n45cs4OfCh7foBYXukE+8mHdnOiiHc3G+U9WVl97OzlbPLh9R7N6fltNLxzi9WAS1xh4PAnYZKi/Tb9HUKen7cvr5d4uIm40UtZXOr0curDuGIXdYNqLZwo8K2s2uiK/t3hktRqhb/Ck46cqt+OhHHsspcC2L95RaPSAVE1wuXVsa6FPW4Y2G7uc/eq6RCYrQ3Pi0Wtya6RmvMKnlkD59ox5f2cmcpw== 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 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=E059ipK/zVOw/u131srGq0nmEWQWJEXPx4wZxTDqqJM=; b=X8wlyu62QILaVck1jI1Lm0D8A1HRT1QcWdidvO+o7rzXj7CQyaeXTW59V3owsCGtCAkhXVrqwJPugpZYFfWIVN9Ev8dtv2dSztv+ziVRtE/5jxWW+QbJzC8wLW1hQnKpVoOmewLR9oBoeElU1WleNaUvFf7iNim74ioPDhLxQA0= Received: from BN9PR03CA0764.namprd03.prod.outlook.com (2603:10b6:408:13a::19) by DS0PR12MB7946.namprd12.prod.outlook.com (2603:10b6:8:151::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Thu, 22 Jun 2023 03:56:02 +0000 Received: from BN8NAM11FT097.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13a:cafe::96) by BN9PR03CA0764.outlook.office365.com (2603:10b6:408:13a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24 via Frontend Transport; Thu, 22 Jun 2023 03:56: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 BN8NAM11FT097.mail.protection.outlook.com (10.13.176.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.39 via Frontend Transport; Thu, 22 Jun 2023 03:56:01 +0000 Received: from ethanolx7ea3host.amd.com (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.23; Wed, 21 Jun 2023 22:55:59 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v6 18/27] cxl/hdm: Use stored Component Register mappings to map HDM decoder capability Date: Wed, 21 Jun 2023 22:51:17 -0500 Message-ID: <20230622035126.4130151-19-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622035126.4130151-1-terry.bowman@amd.com> References: <20230622035126.4130151-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: BN8NAM11FT097:EE_|DS0PR12MB7946:EE_ X-MS-Office365-Filtering-Correlation-Id: 54a8e1fa-8c17-4d0b-1beb-08db72d497f5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: e9PlWedjAs+MyAAEIyo8SvOtP16wShrKFcDrqKLniavPJfQprtwYGm8WTIcv8mgn9VFSSn8muNWqgFZnBpfwt05nHeEiVPFqWFuC1JOofdCnjx0vPhanUTJei8SeomAec2iQ01ewjhht2omrbw8BHOTbaM8JxooVKyBbZ1n34t8h3flxRwehlx28hVyL+/ZojeEuSyMF1zmwh+bq34tnE6o+HWchniQ2gF32tOH/GV5PKA1I+wkrOvXCOqMd/cV27BGjj8uEuHodxGH7gL/W3qqtHBDaNcL4VtXdjeEb4eHfQEK2JaAAmjqKVHupyCKxUqa2IjEHZ5H1H3V+vL9vGPHRFQBydYZTYzi0OfijwHjBQS8f8JQe5BugGY4jIz2tmukJEriawmwZEFJ1Lg7ZX34BBpktv0s5tfKGuVKSVok2WvQvjrj3JN6urYqxOhAfEvRjObgOaPR6uoBFectpVvQreBSf2PPqZkJb0ZtqQzSY5matv2z582wcSRePCJemw1BGQM1CPyB8rtd0SKCKQijLERL6WZfBVbVxQUnad63y6ZWtbln+vAEzXpQ5Hjmp1SYf88dwWRRYU/1UxzPOaEB2Or8JvLGeJKMBS9bCJedfKS5vuJLYI+b0V39frO2qSM163flshMULUWCrHBI9gCfBkbDwunTrwQAYQiHFYNUd7e1slBM/TTgV6hRFzKiRW8l7RXosVz/g0rJu0eaPw8krqBbQP4hYgD/3e3sqHl7Z4RC0rSv2VfdeC6kDpU6c8WdB+rZMbrSSxRxiKft8LQ== 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:(13230028)(4636009)(346002)(376002)(39860400002)(136003)(396003)(451199021)(36840700001)(46966006)(40470700004)(7696005)(110136005)(478600001)(70206006)(6666004)(54906003)(70586007)(83380400001)(2616005)(36860700001)(40480700001)(336012)(426003)(47076005)(40460700003)(86362001)(36756003)(2906002)(82310400005)(186003)(1076003)(26005)(16526019)(356005)(81166007)(82740400003)(4326008)(41300700001)(8676002)(316002)(8936002)(7416002)(5660300002)(44832011)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2023 03:56:01.0644 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 54a8e1fa-8c17-4d0b-1beb-08db72d497f5 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: BN8NAM11FT097.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7946 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter Now, that the Component Register mappings are stored, use them to enable and map the HDM decoder capabilities. The Component Registers do not need to be probed again for this, remove probing code. The HDM capability applies to Endpoints, USPs and VH Host Bridges. The Endpoint's component register mappings are located in the cxlds and else in the port's structure. Provide a helper function cxl_port_get_comp_map() to locate the mappings depending on the component's type. Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang --- drivers/cxl/core/hdm.c | 59 +++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c index 5abfa9276dac..8dcd9f0b22d8 100644 --- a/drivers/cxl/core/hdm.c +++ b/drivers/cxl/core/hdm.c @@ -81,26 +81,6 @@ static void parse_hdm_decoder_caps(struct cxl_hdm *cxlhdm) cxlhdm->interleave_mask |= GENMASK(14, 12); } -static int map_hdm_decoder_regs(struct cxl_port *port, void __iomem *crb, - struct cxl_component_regs *regs) -{ - struct cxl_register_map map = { - .dev = &port->dev, - .resource = port->component_reg_phys, - .base = crb, - .max_size = CXL_COMPONENT_REG_BLOCK_SIZE, - }; - - cxl_probe_component_regs(&port->dev, crb, &map.component_map); - if (!map.component_map.hdm_decoder.valid) { - dev_dbg(&port->dev, "HDM decoder registers not implemented\n"); - /* unique error code to indicate no HDM decoder capability */ - return -ENODEV; - } - - return cxl_map_component_regs(&map, regs, BIT(CXL_CM_CAP_CAP_ID_HDM)); -} - static bool should_emulate_decoders(struct cxl_endpoint_dvsec_info *info) { struct cxl_hdm *cxlhdm; @@ -145,6 +125,22 @@ static bool should_emulate_decoders(struct cxl_endpoint_dvsec_info *info) return true; } +static struct cxl_register_map *cxl_port_get_comp_map(struct cxl_port *port) +{ + /* + * HDM capability applies to Endpoints, USPs and VH Host + * Bridges. The Endpoint's component register mappings are + * located in the cxlds. + */ + if (is_cxl_endpoint(port)) { + struct cxl_memdev *memdev = to_cxl_memdev(port->uport_dev); + + return &memdev->cxlds->comp_map; + } + + return &port->comp_map; +} + /** * devm_cxl_setup_hdm - map HDM decoder component registers * @port: cxl_port to map @@ -155,7 +151,7 @@ struct cxl_hdm *devm_cxl_setup_hdm(struct cxl_port *port, { struct device *dev = &port->dev; struct cxl_hdm *cxlhdm; - void __iomem *crb; + struct cxl_register_map *comp_map; int rc; cxlhdm = devm_kzalloc(dev, sizeof(*cxlhdm), GFP_KERNEL); @@ -164,19 +160,24 @@ struct cxl_hdm *devm_cxl_setup_hdm(struct cxl_port *port, cxlhdm->port = port; dev_set_drvdata(dev, cxlhdm); - crb = ioremap(port->component_reg_phys, CXL_COMPONENT_REG_BLOCK_SIZE); - if (!crb && info && info->mem_enabled) { - cxlhdm->decoder_count = info->ranges; - return cxlhdm; - } else if (!crb) { + comp_map = cxl_port_get_comp_map(port); + + if (!comp_map->component_map.hdm_decoder.valid) { + dev_dbg(&port->dev, "HDM decoder registers not found\n"); + if (info && info->mem_enabled) { + cxlhdm->decoder_count = info->ranges; + return cxlhdm; + } dev_err(dev, "No component registers mapped\n"); return ERR_PTR(-ENXIO); } - rc = map_hdm_decoder_regs(port, crb, &cxlhdm->regs); - iounmap(crb); - if (rc) + rc = cxl_map_component_regs(comp_map, &cxlhdm->regs, + BIT(CXL_CM_CAP_CAP_ID_HDM)); + if (rc) { + dev_dbg(dev, "Failed to map HDM capability.\n"); return ERR_PTR(rc); + } parse_hdm_decoder_caps(cxlhdm); if (cxlhdm->decoder_count == 0) { From patchwork Thu Jun 22 03:51:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13288233 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F23B4EB64DA for ; Thu, 22 Jun 2023 03:58:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230212AbjFVD6O (ORCPT ); Wed, 21 Jun 2023 23:58:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230025AbjFVD5P (ORCPT ); Wed, 21 Jun 2023 23:57:15 -0400 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2057.outbound.protection.outlook.com [40.107.102.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93B9D2707; Wed, 21 Jun 2023 20:56:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YkJqbywX10WQnlaN4DoGkEx8Sx2fbk6LNFqeqHzVSPxHDE9XM3PoLDXX/02yhfBwez5g239Ut1Fx85CMigQhpWhMexTGdt/QbyFMAk3keTPJYDnarqUVssyx0ObbyYHynX40Ysu+JlCWZUiuDoVP8YBrqamjnikVprjFGCb0iWCu9qvPEBwJUjsf36UFDQrunGbr8pzj9YPCWQOQ9EtAKedsRnszQgv99BXDi/RZx/Rm80DanMiyDzjob5mhGsmmY40/f9gkbrcIHqzW6Ofq6dcuQ9FIczLZbRJ7XkA3Pj3dtsFjBoQNuBDHxqizRqBTizXuaFBVBp23207UaVITbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=o2YL/oZ6BWmVEt16T2PDMBavkZ/Ot2HLc0Mn5CnXsYU=; b=PnAUJYx68UdAjK9zUzo++EDnp4bMBIib7646YJCu11+GOqTIZJbvI6nZpGmAZky11PtExgKDnN3k2x53ntPuXW4bOtzY/aLMO9BPcMXA6K/V9k6F6J126xk5iKnNIKZbrace/imgjh/BCPf2BDiqDILxQHFXxGPaT/xdMHRzIRii+M7bjDT1yFrD58+9AMcd1mcSSEkb3X6DnCQ6NLpsH4KTnofuypN3dMfcX6RtHv6OQnmWu8Dck5+BzW719rTjCImupjDFE24Y6nC+pnAn1gV/JsfE/nIOFXO6nb0lLgc+k2TK4fKynuw8IMOLI5HYR3kP5J6f28ExQWwF1vLdtA== 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 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=o2YL/oZ6BWmVEt16T2PDMBavkZ/Ot2HLc0Mn5CnXsYU=; b=c3lUHbyf3o42HS/4+B5WTwSNgfIh0iwLbI5qFFZlL25VHo7fvkC04UriXR0jBMtZLdRei+axURXnVXGJFqHwGaXSn8ABsUmWoFFFBW5kyshvXQ1q9/TqYoJi7dbmtS3sTzFfZHV5In96QHLWlvzb8jZ/jbgkfE8SPlIrUXp8mRk= Received: from BN9PR03CA0055.namprd03.prod.outlook.com (2603:10b6:408:fb::30) by SA3PR12MB7808.namprd12.prod.outlook.com (2603:10b6:806:31b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Thu, 22 Jun 2023 03:56:12 +0000 Received: from BN8NAM11FT036.eop-nam11.prod.protection.outlook.com (2603:10b6:408:fb:cafe::32) by BN9PR03CA0055.outlook.office365.com (2603:10b6:408:fb::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24 via Frontend Transport; Thu, 22 Jun 2023 03:56:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT036.mail.protection.outlook.com (10.13.177.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.39 via Frontend Transport; Thu, 22 Jun 2023 03:56:11 +0000 Received: from ethanolx7ea3host.amd.com (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.23; Wed, 21 Jun 2023 22:56:10 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v6 19/27] cxl/port: Remove Component Register base address from struct cxl_port Date: Wed, 21 Jun 2023 22:51:18 -0500 Message-ID: <20230622035126.4130151-20-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622035126.4130151-1-terry.bowman@amd.com> References: <20230622035126.4130151-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: BN8NAM11FT036:EE_|SA3PR12MB7808:EE_ X-MS-Office365-Filtering-Correlation-Id: 682e35b8-78cf-4f22-8211-08db72d49e42 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 12TLP2MenOBQVNsfVAuB/7G3Id8om61T/rB+/AVA/QdNkkzyhF0NS0IU/6z86qq8N8gGXy7adXk9Ananwf8qr4epkgCAe05PZlwsdDVA4GLBzw5OOaPe53OhBvUJYdSP4tqfZMmrBgaOgSTFoWmOcj0psBloCet3V1GImg5J4bgxyqTF4agSMK0sYV+rvWvG4CTboVJ5FiURzCvRX2o9m83W/gVlbxnUvM7eOZpB2F5889lbLQZww8TJ7C1dnSFb1nUGvePXASXSPxORn/VAYx7AA4czwHp0oxzMJkJM89xpjYh2BC9blWx/exXdAjawnfGv1ChuC+XKxuCiPVPz7C72oHFDsxma4eEaCtjPRBAGftinIsQg+8jK+dHBsy6OTVGctfqHSoIQrdjoNPzODA67Ak6od9tvtCaODykfwcGTQHRMVnRVAwDE8mwM73xXPhgX0pvyVuzb5hqmpyXY6BhlHopNK7KJB6sVMZeyGehrUTGoyhqJ56Bzf6b5/3VW/kHbGGOe3BjJZb694WeCarREv8/lhP9MgrzYUU5nlwkZqjESJ3rbTaB3ugfQb4LN35kNYMB68g+f6O0zWia2E+OsQtdobXF3Mvf9nVCGWQ7HXc+cfGllSRM5/MlOqvtcLsPdaaZK5FJTnQfbXtMD/h/RcEuI2fuOtnusX3nu59X2vaL30kBkcpTbIzXs7JBtotQ9IGScyvfnGnEk0phiuvTSj4DeFrdVRXMwPgBb2MVOXIcJ/KlE27akfczxBwoEC6S7/J/R8MYmlDSYdA+XIg== 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:(13230028)(4636009)(136003)(376002)(396003)(39860400002)(346002)(451199021)(46966006)(36840700001)(40470700004)(82310400005)(7696005)(4326008)(70586007)(70206006)(478600001)(36756003)(316002)(54906003)(40460700003)(110136005)(86362001)(83380400001)(426003)(26005)(1076003)(47076005)(336012)(16526019)(186003)(2616005)(82740400003)(356005)(5660300002)(81166007)(2906002)(41300700001)(8676002)(8936002)(7416002)(36860700001)(44832011)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2023 03:56:11.6380 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 682e35b8-78cf-4f22-8211-08db72d49e42 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: BN8NAM11FT036.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7808 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter The Component Register base address @component_reg_phys is no longer used after the rework of the Component Register setup which now uses struct member @comp_map instead. Remove the base address. Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang --- drivers/cxl/core/port.c | 4 +--- drivers/cxl/cxl.h | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 45fe7d89f7f3..cfae8307de90 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -616,7 +616,6 @@ static int devm_cxl_link_parent_dport(struct device *host, static struct lock_class_key cxl_port_key; static struct cxl_port *cxl_port_alloc(struct device *uport_dev, - resource_size_t component_reg_phys, struct cxl_dport *parent_dport) { struct cxl_port *port; @@ -667,7 +666,6 @@ static struct cxl_port *cxl_port_alloc(struct device *uport_dev, } else dev->parent = uport_dev; - port->component_reg_phys = component_reg_phys; ida_init(&port->decoder_ida); port->hdm_end = -1; port->commit_end = -1; @@ -726,7 +724,7 @@ static struct cxl_port *__devm_cxl_add_port(struct device *host, struct device *dev; int rc; - port = cxl_port_alloc(uport_dev, component_reg_phys, parent_dport); + port = cxl_port_alloc(uport_dev, parent_dport); if (IS_ERR(port)) return port; diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index b1adca9b27ba..9f46a4e1fbec 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -551,7 +551,6 @@ struct cxl_dax_region { * @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 - * @component_reg_phys: component register capability base address (optional) * @dead: last ep has been removed, force port re-creation * @depth: How deep this port is relative to the root. depth 0 is the root. * @cdat: Cached CDAT data @@ -571,7 +570,6 @@ struct cxl_port { int nr_dports; int hdm_end; int commit_end; - resource_size_t component_reg_phys; bool dead; unsigned int depth; struct cxl_cdat { From patchwork Thu Jun 22 03:51:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13288234 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93B34EB64D8 for ; Thu, 22 Jun 2023 03:58:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230297AbjFVD61 (ORCPT ); Wed, 21 Jun 2023 23:58:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230191AbjFVD5n (ORCPT ); Wed, 21 Jun 2023 23:57:43 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2058.outbound.protection.outlook.com [40.107.93.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9FA61FFD; Wed, 21 Jun 2023 20:56:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UM3ItGDMgAxQtZ6pAyE75ILgn8QXbk2QaZyB0lVkpg3huk3QZn8SExs840XgDrTvigmSwl2QDNeLLNunb82pxdqmFxAY6AG7RYU6R9zsqZsejgQBk8QZDYSSacFsRFIEbEZDKdUYRCakbxve7u4WbDgDkewkPmY4Ewvzn4wc0KeHlNqSSa8VWFvBWRShvzaeTX8NfSnq+jkd0pdvOfNvCMc/5WwPv1n/hI9AJc4E8WUL2n79q73X6E+BE70NfzUgiS5/0k8RwQhpVnaF/BZuNdfx68WTfug7FI8n48doqYBuFLPWukE5pwG6lZe7fEL3A+H65N4GMqdIOFQBWY/grw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=elGP9FkYghUy70/jcm7qSXPKwzKRFZeI2IrOiqqgJDE=; b=YtmB5TkJSF9Mrfu394QnNcuB+152b2VMRzyTSFXnZD7bA+tj7e+c5Ldsy1GRgi5gnHcURXEVMOfTlofp0m7TIzxSf7Iv0NCgc3qn5YTMSxB+nHredOC7W7P9GZcxOFLkrWKjHFd5ddo+V1YkI9xvCQFrazVoF/TIw0rhmZ4PIcz1zXsHuH1BusvZrqArcn4TYDEfQXtnwAR63SKEpsRzsiXlbBaa2cxk88X9Bb/AH1gicKYvYgpvQDNuFgtZkfmGAlA2vX/e2e2sackn1RptERjvBq5SJY2ZjmjxJoRpRmH3W/vH2ug7wYJJMboMuoFOhI1gaKoV/IMml6Ri6xWSGA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=temperror (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=temperror action=none header.from=amd.com; dkim=none (message not signed); arc=none 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=elGP9FkYghUy70/jcm7qSXPKwzKRFZeI2IrOiqqgJDE=; b=sQ4325YV2JjknKbSh9TW3Wiebj1XXvqLP8XfdX1Vi98xwZnDcqkLEC9IHz7mPjqAtdPNhryDCiG7uS4QUsGbumNHY7HQhmypUmJZHzOc0o/Vusy9norW1zB7WUaZ3Phx8Zqy8PHovsQkQYk75EPgxcu6hjDNBrNzaGF9vYgWpNM= Received: from BN7PR06CA0057.namprd06.prod.outlook.com (2603:10b6:408:34::34) by SJ0PR12MB5456.namprd12.prod.outlook.com (2603:10b6:a03:3ae::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Thu, 22 Jun 2023 03:56:25 +0000 Received: from BN8NAM11FT105.eop-nam11.prod.protection.outlook.com (2603:10b6:408:34:cafe::69) by BN7PR06CA0057.outlook.office365.com (2603:10b6:408:34::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24 via Frontend Transport; Thu, 22 Jun 2023 03:56:24 +0000 X-MS-Exchange-Authentication-Results: spf=temperror (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=temperror action=none header.from=amd.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of amd.com: DNS Timeout) Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT105.mail.protection.outlook.com (10.13.176.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.41 via Frontend Transport; Thu, 22 Jun 2023 03:56:23 +0000 Received: from ethanolx7ea3host.amd.com (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.23; Wed, 21 Jun 2023 22:56:21 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v6 20/27] cxl/pci: Add RCH downstream port AER register discovery Date: Wed, 21 Jun 2023 22:51:19 -0500 Message-ID: <20230622035126.4130151-21-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622035126.4130151-1-terry.bowman@amd.com> References: <20230622035126.4130151-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: BN8NAM11FT105:EE_|SJ0PR12MB5456:EE_ X-MS-Office365-Filtering-Correlation-Id: c8bf6726-8a8d-4b0d-de93-08db72d4a50d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sEj5OcJKczv8jzw3Q+3/Rx4I891bvJY7smm34/cQgYP+6hElKKeOVHZXdNwctX5Hctzv8adnAMABuWcNly1vrRi9YalLK4yqcHFChpw36PsjqOmpFkr1qmnr5Vm4Rt5mFjDytLfBrclDHCYIIqfO0YsEdeN+6MBgJg4IsRvORVKr7t7HcK/1R3v6ETzC9/iHokO81Y8PskTovagl4xzsUOxirc6ukQ8hYA2J+8l/UWaWCxdINTM+ysLp7brVlGOWxufv43lHhLT+5ngPRzcEjsYkFUBkj4Ny9pDxy2yO9uyYIsywqqIsKSZgPjwBjvabBP1rCsuwoIXaAIkNwRAl0fcXzbeGk2p6h7SSqcSBfwE7sO5bMn4VpZ0fPp0jrNSiwA1RbjP/OtlxSSZRvnQeB9v0oYmZlQ2oIXEsSu32bqaomnml3uvp1jxD8wHUCGjnS5Ii93lJHQKY6CA3Q0nqlmTtzS8mkvAkAohCbbISZ9uFWA5ELUoDhWsMCICELOc5kzdPnt/GDBZwrL/KAzqOOFlp5PTpSQVcXI0Uib1autMhEoO7mVpPnNw+tnL01nMBmvhn7OfPW/LzxCLcm9Q5W2BzozILpI9ingR1i4iMjndJkuvb+AQH4609/JmOSSSw3iUNwfKhqqoKpWZZJCHTGj0NDxdWkMxsr6Q9ZSCdb/6Pv1td0HvAXXsDWa8DqV91LT3SXTDa8G3dqYl65PvEtHOGnEA/Ddagp/EBki8Cy7ZTTseKr2/MCJA71UnnmqWFrsBxCm06qC1Ft0Ijt+ugbw== 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:(13230028)(4636009)(346002)(39860400002)(376002)(396003)(136003)(451199021)(40470700004)(36840700001)(46966006)(7416002)(8936002)(8676002)(86362001)(44832011)(70586007)(316002)(70206006)(4326008)(2906002)(478600001)(110136005)(41300700001)(54906003)(5660300002)(82740400003)(1076003)(82310400005)(83380400001)(63370400001)(63350400001)(7696005)(36860700001)(2616005)(47076005)(336012)(426003)(40460700003)(81166007)(356005)(16526019)(186003)(26005)(36756003)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2023 03:56:23.0371 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c8bf6726-8a8d-4b0d-de93-08db72d4a50d 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: BN8NAM11FT105.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB5456 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org Restricted CXL host (RCH) downstream port AER information is not currently logged while in the error state. One problem preventing the error logging is the AER and RAS registers are not accessible. The CXL driver requires changes to find RCH downstream port AER and RAS registers for purpose of error logging. RCH downstream ports are not enumerated during a PCI bus scan and are instead discovered using system firmware, ACPI in this case.[1] The downstream port is implemented as a Root Complex Register Block (RCRB). The RCRB is a 4k memory block containing PCIe registers based on the PCIe root port.[2] The RCRB includes AER extended capability registers used for reporting errors. Note, the RCH's AER Capability is located in the RCRB memory space instead of PCI configuration space, thus its register access is different. Existing kernel PCIe AER functions can not be used to manage the downstream port AER capabilities and RAS registers because the port was not enumerated during PCI scan and the registers are not PCI config accessible. Discover RCH downstream port AER extended capability registers. Use MMIO accesses to search for extended AER capability in RCRB register space. [1] CXL 3.0 Spec, 9.11.2 - System Firmware View of CXL 1.1 Hierarchy [2] CXL 3.0 Spec, 8.2.1.1 - RCH Downstream Port RCRB Co-developed-by: Robert Richter Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang --- drivers/cxl/core/core.h | 1 + drivers/cxl/core/port.c | 7 ++++++- drivers/cxl/core/regs.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/drivers/cxl/core/core.h b/drivers/cxl/core/core.h index b001669a5133..87467c633123 100644 --- a/drivers/cxl/core/core.h +++ b/drivers/cxl/core/core.h @@ -72,6 +72,7 @@ struct cxl_rcrb_info; resource_size_t __rcrb_to_component(struct device *dev, struct cxl_rcrb_info *ri, enum cxl_rcrb which); +u16 cxl_rcrb_to_aer(struct device *dev, resource_size_t rcrb); extern struct rw_semaphore cxl_dpa_rwsem; diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index cfae8307de90..37ecd756b224 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -678,7 +678,6 @@ static struct cxl_port *cxl_port_alloc(struct device *uport_dev, device_set_pm_not_required(dev); dev->bus = &cxl_bus_type; dev->type = &cxl_port_type; - return port; err: @@ -974,6 +973,8 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev, return ERR_PTR(-ENOMEM); if (rcrb != CXL_RESOURCE_NONE) { + struct pci_host_bridge *host_bridge; + dport->rcrb.base = rcrb; component_reg_phys = __rcrb_to_component(dport_dev, &dport->rcrb, CXL_RCRB_DOWNSTREAM); @@ -982,6 +983,10 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev, return ERR_PTR(-ENXIO); } + host_bridge = to_pci_host_bridge(dport_dev); + if (host_bridge->native_cxl_error) + dport->rcrb.aer_cap = cxl_rcrb_to_aer(dport_dev, dport->rcrb.base); + dport->rch = true; } diff --git a/drivers/cxl/core/regs.c b/drivers/cxl/core/regs.c index e68848075bb6..60b7ba7f4030 100644 --- a/drivers/cxl/core/regs.c +++ b/drivers/cxl/core/regs.c @@ -407,6 +407,41 @@ int cxl_setup_regs(struct cxl_register_map *map) } EXPORT_SYMBOL_NS_GPL(cxl_setup_regs, CXL); +u16 cxl_rcrb_to_aer(struct device *dev, resource_size_t rcrb) +{ + void __iomem *addr; + u16 offset = 0; + u32 cap_hdr; + + if (WARN_ON_ONCE(rcrb == CXL_RESOURCE_NONE)) + return 0; + + if (!request_mem_region(rcrb, SZ_4K, dev_name(dev))) + return 0; + + addr = ioremap(rcrb, SZ_4K); + if (!addr) { + release_mem_region(rcrb, SZ_4K); + return 0; + } + + cap_hdr = readl(addr + offset); + while (PCI_EXT_CAP_ID(cap_hdr) != PCI_EXT_CAP_ID_ERR) { + offset = PCI_EXT_CAP_NEXT(cap_hdr); + if (!offset) + break; + cap_hdr = readl(addr + offset); + } + + if (offset) + dev_dbg(dev, "found AER extended capability (0x%x)\n", offset); + + iounmap(addr); + release_mem_region(rcrb, SZ_4K); + + return offset; +} + resource_size_t __rcrb_to_component(struct device *dev, struct cxl_rcrb_info *ri, enum cxl_rcrb which) { From patchwork Thu Jun 22 03:51:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13288235 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1DDDEB64DB for ; Thu, 22 Jun 2023 03:58:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230370AbjFVD62 (ORCPT ); Wed, 21 Jun 2023 23:58:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230199AbjFVD5o (ORCPT ); Wed, 21 Jun 2023 23:57:44 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2088.outbound.protection.outlook.com [40.107.92.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8811F2735; Wed, 21 Jun 2023 20:56:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gv6TX9aydwPTZhgkuWUEeD0Pq4X99B4wECCCGqTzIiFj61alwxNBCgcU1shslmk3EH3lSkGnQV52z0mt3v5m9fxWfeUlB3rC8zKVgTnwVju0aFB1UDz0mfPz4lzqRTrkoV+Xw+fFxUUf08VMH62aqhO2pAAT9w2OJx+QdwC86o9wYSEKf6EABxpDGKoSaSARHVj/e4VWqHPX2pA7J9nagB9V16ReSiUw7XIfGWCjVteNZfN0quKYTDPfo7YPalgAQlfGhqLxalfxU8uJ/HA0byzjpnHEa8TD3X+og58IXRqtDefGYgN7moixAeVQnCCC3PFcBw1CMNwFlza9/mQ7Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=smd23x7vtbGpItusRCOZJCxcGcy/8nAFZ2Kmy/SFPc0=; b=flTZ2BqGmnuUpoOA0ePcK2HAIX6UIzKjXBdeSdTR7ZaR092bDj16pL50VGuVNAmzpJyafC8HjOYFSMjgVosntXCBuHshKj7UIGmMPCrJZv7V270/0ugEAxVhwd/htJsChU+JmRxguB7EdIoFepklq0VySRBmxm1zaHfVtg36BY9NXMD4CmTFygJ5C9zW/DZq/TA1BYZCx20c0iKnKh3FiKCDFN07L9yQkEWD9F6jlg9khkOdPQN3yUbLoXaOWV3TGtkI/EmzWDFUpAZIlzwT1J1eY+PPiVFTLLPc/FkRiAwZSC6gIoIxCE9GRjTedRNSm6AtSc81oaDxDNxQHndzqw== 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 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=smd23x7vtbGpItusRCOZJCxcGcy/8nAFZ2Kmy/SFPc0=; b=euXQxCQ/M89h3mKoufBcRJdeQIhI9YTye4hMwK5fGDcSs+fTfFS+RZLGriK0g0uc8fo2Y6OJiCfcBInM36uELCwBQUmG/cWTLTH6bQaCnVTwg75sBwI5ocztGqkmgZpOF8eBSh4IGph4k31vGeJlvt6nMZsEP4eHFxt/RSNA4cY= Received: from BN9PR03CA0568.namprd03.prod.outlook.com (2603:10b6:408:138::33) by MN2PR12MB4207.namprd12.prod.outlook.com (2603:10b6:208:1d9::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Thu, 22 Jun 2023 03:56:35 +0000 Received: from BN8NAM11FT084.eop-nam11.prod.protection.outlook.com (2603:10b6:408:138:cafe::3b) by BN9PR03CA0568.outlook.office365.com (2603:10b6:408:138::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24 via Frontend Transport; Thu, 22 Jun 2023 03:56:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT084.mail.protection.outlook.com (10.13.176.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.41 via Frontend Transport; Thu, 22 Jun 2023 03:56:34 +0000 Received: from ethanolx7ea3host.amd.com (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.23; Wed, 21 Jun 2023 22:56:32 -0500 From: Terry Bowman To: , , , , , , , CC: , , , , Mahesh J Salgaonkar , Oliver O'Halloran , Subject: [PATCH v6 21/27] PCI/AER: Refactor cper_print_aer() for use by CXL driver module Date: Wed, 21 Jun 2023 22:51:20 -0500 Message-ID: <20230622035126.4130151-22-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622035126.4130151-1-terry.bowman@amd.com> References: <20230622035126.4130151-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: BN8NAM11FT084:EE_|MN2PR12MB4207:EE_ X-MS-Office365-Filtering-Correlation-Id: 948bbba9-d21e-4fcf-bbeb-08db72d4aba6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qcvNPL13fPpAWGNBOYgGcTpmaQrDHUrojaa9K1J3sffJOQ2hb91fXeGeOZCOVohZAtL+fXnZHDsz0cCBCEE1oUhUYTmQcqjk8x7RhShVaSyzmD0KYCUgzNlluzueDDWG0x2hO59H/BYWPPmIMRcAzskennbtLcjSsUl9N/6p8K43Sg3GPRocYsUaPZEACiyorI4EfVJjE1KquQnoIyijLcCE3fheMCjYsOhmdl2clqVW4t6SVezlG/Mmvha8x057m+er2r0QnPMJca6/uuxtYZviWyAp3MBWvAUy5FUj/Ix56fKV2EaJiOIwaYow7tJ1xVcbZms6f/3v0yxXNDzcf21HfztBbuzrfGEGWQdN71MRuxIvDClvFOdBDAAk6zv4X8k0lXbjNs9+BX8cYF4M6PZ71uX03gIMlgDnfP30Rh11DRyCCq2G99XjdG7COgVirg/rubADbns3YgPdLXqEFaLHMIUUXPfu4ZtRXuJfofcJXMUKkO0JCrr1TE2d8l+qJzYgOvu+Y5Y8qNi4HyTYPGMtoQ09Fn+lYPXTdBVAWptaqu3pJHT/EwnipbGC9pmJHHjqgtfewab8JTS9TaECEveRZK9Jun+AjZTxiCiECGhP5MvN3Jp7xLohHrbUzvyq/z70pLzR2Ap0Jqk6NNFV0OGoRBckW8awXLpqthXoSeWXbFlBGWbdWnxhvp7NkhD4zWq5nZFEgMomC1BRiVE243MusG3xro/JH/Wg7AKg2MWbk8O9oTgKqJRHrpOtkgH+suWYJ9wbJlSuU9dJeZw9aQ== 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:(13230028)(4636009)(376002)(39860400002)(346002)(396003)(136003)(451199021)(46966006)(40470700004)(36840700001)(82310400005)(478600001)(70206006)(70586007)(7696005)(36756003)(6666004)(316002)(40460700003)(54906003)(110136005)(426003)(86362001)(83380400001)(186003)(26005)(16526019)(2616005)(81166007)(336012)(82740400003)(36860700001)(41300700001)(8936002)(5660300002)(1076003)(356005)(8676002)(2906002)(4326008)(44832011)(47076005)(40480700001)(7416002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2023 03:56:34.1052 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 948bbba9-d21e-4fcf-bbeb-08db72d4aba6 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: BN8NAM11FT084.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4207 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org The CXL driver plans to use cper_print_aer() for logging restricted CXL host (RCH) AER errors. cper_print_aer() is not currently exported and therefore not usable by the CXL drivers built as loadable modules. Export the cper_print_aer() function. Use the EXPORT_SYMBOL_NS_GPL() variant to restrict the export to CXL drivers. The CONFIG_ACPI_APEI_PCIEAER kernel config is currently used to enable cper_print_aer(). cper_print_aer() logs the AER registers and is useful in PCIE AER logging outside of APEI. Remove the CONFIG_ACPI_APEI_PCIEAER dependency to enable cper_print_aer(). The cper_print_aer() function name implies CPER specific use but is useful in non-CPER cases as well. Rename cper_print_aer() to pci_print_aer(). Also, update cxl_core to import CXL namespace imports. Co-developed-by: Robert Richter Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Cc: Mahesh J Salgaonkar Cc: "Oliver O'Halloran" Cc: Bjorn Helgaas Cc: linux-pci@vger.kernel.org Reviewed-by: Jonathan Cameron Acked-by: Bjorn Helgaas --- drivers/cxl/core/port.c | 1 + drivers/pci/pcie/aer.c | 9 +++++---- include/linux/aer.h | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 37ecd756b224..41e79a36c1ae 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -2056,3 +2056,4 @@ static void cxl_core_exit(void) subsys_initcall(cxl_core_init); module_exit(cxl_core_exit); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(CXL); diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index f6c24ded134c..d3344fcf1f79 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -771,9 +771,10 @@ int cper_severity_to_aer(int cper_severity) } } EXPORT_SYMBOL_GPL(cper_severity_to_aer); +#endif -void cper_print_aer(struct pci_dev *dev, int aer_severity, - struct aer_capability_regs *aer) +void pci_print_aer(struct pci_dev *dev, int aer_severity, + struct aer_capability_regs *aer) { int layer, agent, tlp_header_valid = 0; u32 status, mask; @@ -812,7 +813,7 @@ void cper_print_aer(struct pci_dev *dev, int aer_severity, trace_aer_event(dev_name(&dev->dev), (status & ~mask), aer_severity, tlp_header_valid, &aer->header_log); } -#endif +EXPORT_SYMBOL_NS_GPL(pci_print_aer, CXL); /** * add_error_device - list device to be handled @@ -1009,7 +1010,7 @@ static void aer_recover_work_func(struct work_struct *work) PCI_SLOT(entry.devfn), PCI_FUNC(entry.devfn)); continue; } - cper_print_aer(pdev, entry.severity, entry.regs); + pci_print_aer(pdev, entry.severity, entry.regs); if (entry.severity == AER_NONFATAL) pcie_do_recovery(pdev, pci_channel_io_normal, aer_root_reset); diff --git a/include/linux/aer.h b/include/linux/aer.h index 97f64ba1b34a..8f124b904314 100644 --- a/include/linux/aer.h +++ b/include/linux/aer.h @@ -64,7 +64,7 @@ static inline void pci_save_aer_state(struct pci_dev *dev) {} static inline void pci_restore_aer_state(struct pci_dev *dev) {} #endif -void cper_print_aer(struct pci_dev *dev, int aer_severity, +void pci_print_aer(struct pci_dev *dev, int aer_severity, struct aer_capability_regs *aer); int cper_severity_to_aer(int cper_severity); void aer_recover_queue(int domain, unsigned int bus, unsigned int devfn, From patchwork Thu Jun 22 03:51:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13288236 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4290EB64D8 for ; Thu, 22 Jun 2023 03:58:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230303AbjFVD6u (ORCPT ); Wed, 21 Jun 2023 23:58:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230285AbjFVD6O (ORCPT ); Wed, 21 Jun 2023 23:58:14 -0400 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2046.outbound.protection.outlook.com [40.107.100.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE2EC1FD8; Wed, 21 Jun 2023 20:57:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bKm48FhNtlpxfuPtru1qHL6Yx4CQ7Xs3jCCkDcANvPDacY0w8N8Wj+htpZDTQP+OjMO9vmxAGRD0cgmrsPwpl5JIWTuROv5tTe6lvWP9elHk+TlI6jWS+a4zXvYOWydm+/dpdc/y4qtCa+tpQBRqzITcLudIL9vxEgvqE3PVt08nnsoh+shWKe6DFDHgmSY2HZ5jPTI6aPaWocb3sEbg2FE1Py8t5Rbr6QJKeXE9PWaUh0ogoz+ZK/djL0Km7NxN/Awncb8SxTQoSKC+dxqJuUwyXDi//qFWbDUt6otOzfqd4nC86OOmapOORNxka1PWbaINcskuWBqJKDiSZYCUUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=zJGb8iVAmjFWLMxEIW//gmwKAZ4/XIlDRXWXqsX637M=; b=dfIKlsVZxEa26Fhq9MPH0A/KIJ663MJEYAk+k/Y5+A6ztCR6M5A6hle+A74XKyDTyKn6BQYt4fRrzaiSrHd5hVs8rNZ0QEb38HPCyN4/VPCsqGTyZgdq29EYAm/+jASkmROmfVoPSY6nMMD2ZxeYuA9f6zysoQDxubBsXTCufGvcmHePoLbBvnSOV34tldtjsewQUjlwxen6KQP0owplrN7+yF6ZkGo5ry6crcaUs9kBK5r0o8PlczxZNpgghCBRqGv+k8hoabSpHc6wnUuAUYS19QgMHEBBPkixRKHlFgtUYIkGrZvuKaT39yZUKvhjdFtEVuOo4qaDS1fuxRHdvw== 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 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=zJGb8iVAmjFWLMxEIW//gmwKAZ4/XIlDRXWXqsX637M=; b=e2kotyawY+jC3MYvsNPYOTT6r/qLHmyemlJZlaB/AQ94SC+cY4+ftX2Q5aEJ47BlMweODv+0ghvAbHF+HN4ESM6MVx9dCcGpX+zNEKwAmMwJsoTNzb4LKc0I/BaNwS4I8asz7obtT8U4Yi0nHp9TNmAEtw+tOyV/uxHInsQLcrY= Received: from BN9P221CA0002.NAMP221.PROD.OUTLOOK.COM (2603:10b6:408:10a::9) by SJ2PR12MB9006.namprd12.prod.outlook.com (2603:10b6:a03:540::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Thu, 22 Jun 2023 03:56:45 +0000 Received: from BN8NAM11FT004.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10a:cafe::4f) by BN9P221CA0002.outlook.office365.com (2603:10b6:408:10a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24 via Frontend Transport; Thu, 22 Jun 2023 03:56:45 +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 BN8NAM11FT004.mail.protection.outlook.com (10.13.176.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.41 via Frontend Transport; Thu, 22 Jun 2023 03:56:44 +0000 Received: from ethanolx7ea3host.amd.com (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.23; Wed, 21 Jun 2023 22:56:43 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v6 22/27] cxl/pci: Update CXL error logging to use RAS register address Date: Wed, 21 Jun 2023 22:51:21 -0500 Message-ID: <20230622035126.4130151-23-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622035126.4130151-1-terry.bowman@amd.com> References: <20230622035126.4130151-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: BN8NAM11FT004:EE_|SJ2PR12MB9006:EE_ X-MS-Office365-Filtering-Correlation-Id: 9d3a3cb6-96dc-47c1-d399-08db72d4b1f7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qeKlBMlJjQ4JRIKsVNmeRFt9pCBQzvz+OI18sd09BLgTTpZoAskC2d4a5AVDvgheuZuHqWhT4pb0tKcZ6NjfKoItgasg4mPaMJ00njgslMHPHmb4t7jlRw0bmNFu1NopcE0KyyHUANerkGdNjo1mvyEKOS4psF89dyDoEoYdnt8aHLSe0Hj7Jh7CfHpXRKUAqKnKz6dL1CaAvE/M0DL0VcJXyJehcLQFqOxdKIZIDUTOqY0J7wz4WH+zhRbetOjdIB3M2j/G20BBAsjXoigY5BF3+R3ZnoNJtuKUNLJ0zGMoTHRxi1Ve0opCuCD+Cn/We1uSQIigPyNXx/dPpigCxQ6QBf/cBNF6O5xRIVhsfDx0tl1eDL8oHH9C86sQRgWg7J00iKeaoAbMVoDWsHVGINKY8YSsH44HSNhtJx/txMO2DRIle8moj/l/7kDPpDDSZgh3U/v4QYgbze0BjVwUl+nYZsLXs1rAFO2m7O3SKWnpWf6hTWUSrfbFJ/xl+serOmVqMV8v8ZXx8bb3dka0sp8P2ahbvopsc3PaVbQXfxANE0BvkyTbJaSTJtQvwNTjP0gvEaVwwVnQlIacvv/oajSLsYFAbi2zIIG8HuT1XHUxlSrhHM4Xju7suRR79UmPqRPrfg7YgrF7kYjZLGtgnpOdS3F/1gqRYWv5zP2gqpl1mDof4nDJMtNCCjtgYD9s1TIx9s+Ftyl8gHuJUSkbzqm1vMP4fok7ndnC8aONHB/1JmIp4kBnEL/RVW1yA7u61ICrtP78R65ARen8cAvLJg== 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:(13230028)(4636009)(136003)(39860400002)(346002)(396003)(376002)(451199021)(40470700004)(46966006)(36840700001)(356005)(81166007)(82740400003)(7416002)(44832011)(2906002)(40480700001)(15650500001)(83380400001)(47076005)(426003)(36860700001)(36756003)(86362001)(8936002)(2616005)(1076003)(82310400005)(16526019)(26005)(186003)(40460700003)(336012)(6666004)(478600001)(110136005)(54906003)(7696005)(70586007)(70206006)(316002)(5660300002)(41300700001)(4326008)(8676002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2023 03:56:44.7030 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9d3a3cb6-96dc-47c1-d399-08db72d4b1f7 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: BN8NAM11FT004.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB9006 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org The CXL error handler currently only logs endpoint RAS status. The CXL topology includes several components providing RAS details to be logged during error handling.[1] Update the current handler's RAS logging to use a RAS register address. Also, update the error handler function names to be consistent with correctable and uncorrecable RAS. This will allow for adding support to log other CXL component's RAS details in the future. [1] CXL3.0 Table 8-22 CXL_Capability_ID Assignment Co-developed-by: Robert Richter Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron --- drivers/cxl/core/pci.c | 44 +++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index 375f01c6cad6..9cb39835e154 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -665,32 +665,36 @@ void read_cdat_data(struct cxl_port *port) } EXPORT_SYMBOL_NS_GPL(read_cdat_data, CXL); -void cxl_cor_error_detected(struct pci_dev *pdev) +static void __cxl_handle_cor_ras(struct cxl_dev_state *cxlds, + void __iomem *ras_base) { - struct cxl_dev_state *cxlds = pci_get_drvdata(pdev); void __iomem *addr; u32 status; - if (!cxlds->regs.ras) + if (!ras_base) return; - addr = cxlds->regs.ras + CXL_RAS_CORRECTABLE_STATUS_OFFSET; + addr = ras_base + CXL_RAS_CORRECTABLE_STATUS_OFFSET; status = readl(addr); if (status & CXL_RAS_CORRECTABLE_STATUS_MASK) { writel(status & CXL_RAS_CORRECTABLE_STATUS_MASK, addr); trace_cxl_aer_correctable_error(cxlds->cxlmd, status); } } -EXPORT_SYMBOL_NS_GPL(cxl_cor_error_detected, CXL); + +static void cxl_handle_endpoint_cor_ras(struct cxl_dev_state *cxlds) +{ + return __cxl_handle_cor_ras(cxlds, cxlds->regs.ras); +} /* CXL spec rev3.0 8.2.4.16.1 */ -static void header_log_copy(struct cxl_dev_state *cxlds, u32 *log) +static void header_log_copy(void __iomem *ras_base, u32 *log) { void __iomem *addr; u32 *log_addr; int i, log_u32_size = CXL_HEADERLOG_SIZE / sizeof(u32); - addr = cxlds->regs.ras + CXL_RAS_HEADER_LOG_OFFSET; + addr = ras_base + CXL_RAS_HEADER_LOG_OFFSET; log_addr = log; for (i = 0; i < log_u32_size; i++) { @@ -704,17 +708,18 @@ static void header_log_copy(struct cxl_dev_state *cxlds, u32 *log) * Log the state of the RAS status registers and prepare them to log the * next error status. Return 1 if reset needed. */ -static bool cxl_report_and_clear(struct cxl_dev_state *cxlds) +static bool __cxl_handle_ras(struct cxl_dev_state *cxlds, + void __iomem *ras_base) { u32 hl[CXL_HEADERLOG_SIZE_U32]; void __iomem *addr; u32 status; u32 fe; - if (!cxlds->regs.ras) + if (!ras_base) return false; - addr = cxlds->regs.ras + CXL_RAS_UNCORRECTABLE_STATUS_OFFSET; + addr = ras_base + CXL_RAS_UNCORRECTABLE_STATUS_OFFSET; status = readl(addr); if (!(status & CXL_RAS_UNCORRECTABLE_STATUS_MASK)) return false; @@ -722,7 +727,7 @@ static bool cxl_report_and_clear(struct cxl_dev_state *cxlds) /* If multiple errors, log header points to first error from ctrl reg */ if (hweight32(status) > 1) { void __iomem *rcc_addr = - cxlds->regs.ras + CXL_RAS_CAP_CONTROL_OFFSET; + ras_base + CXL_RAS_CAP_CONTROL_OFFSET; fe = BIT(FIELD_GET(CXL_RAS_CAP_CONTROL_FE_MASK, readl(rcc_addr))); @@ -730,13 +735,26 @@ static bool cxl_report_and_clear(struct cxl_dev_state *cxlds) fe = status; } - header_log_copy(cxlds, hl); + header_log_copy(ras_base, hl); trace_cxl_aer_uncorrectable_error(cxlds->cxlmd, status, fe, hl); writel(status & CXL_RAS_UNCORRECTABLE_STATUS_MASK, addr); return true; } +static bool cxl_handle_endpoint_ras(struct cxl_dev_state *cxlds) +{ + return __cxl_handle_ras(cxlds, cxlds->regs.ras); +} + +void cxl_cor_error_detected(struct pci_dev *pdev) +{ + struct cxl_dev_state *cxlds = pci_get_drvdata(pdev); + + cxl_handle_endpoint_cor_ras(cxlds); +} +EXPORT_SYMBOL_NS_GPL(cxl_cor_error_detected, CXL); + pci_ers_result_t cxl_error_detected(struct pci_dev *pdev, pci_channel_state_t state) { @@ -751,7 +769,7 @@ pci_ers_result_t cxl_error_detected(struct pci_dev *pdev, * chance the situation is recoverable dump the status of the RAS * capability registers and bounce the active state of the memdev. */ - ue = cxl_report_and_clear(cxlds); + ue = cxl_handle_endpoint_ras(cxlds); switch (state) { case pci_channel_io_normal: From patchwork Thu Jun 22 03:51:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13288237 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 033B4EB64D8 for ; Thu, 22 Jun 2023 03:59:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230367AbjFVD7I (ORCPT ); Wed, 21 Jun 2023 23:59:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230346AbjFVD6d (ORCPT ); Wed, 21 Jun 2023 23:58:33 -0400 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2089.outbound.protection.outlook.com [40.107.100.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FAC22697; Wed, 21 Jun 2023 20:57:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cHXlzA5je4uz3arPXqpZKooMwTxRz80N7PumONN9trJP7crUETxH3ATsgY314y79/3bRjQKma7WOjvJ6tfjR9nuGYVg76NXTHRsSB/Qx0cx2yZG77Z/wliGOPGs/VW859xXkBgUG787wPkNcUvtsuxut/GsAM2j/SyOv6EwP2lygqNXIThecFz4ANyoG2sRkNrZwhFxwTeMx6E9yr/3bl7FTjLwPS8ucs9M88iiKhqz0xFAxMcMYtE8BzQoaCmc0kTl7F1j0rpfObYgGoCccbxV5wWeRPy1cvox43AgCltHI5EzCdmObHDdrzmxYl18d3KCUWvrL2hiJxCk0XSjQBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=45RvYwsX6lKhqKPEKxlfJXUv2r/hkF/Ik0fPbpsoL5E=; b=KdF+TzvyCeJJ1UqJN2G5Gy0T20gz8eR84tFrGI8+eat0xoKbOi2Z+Hv2Cwiw3dMgNZXWZGk5y8IsnxblpKKdskfm7Wlo+H0eBAPIG+ysde4Zf4PO25MoWwLx1sp2s+TVc/7kXW16roXjJuu4E0arsbeWx8rrx+m2k0H3GrzQ0xvLjt5vxJ9RZ83/269HvlWwiqyDUogpEdEbIpEOHsHO0aHN64YUv3ZWSbSWYSlX/xwaV0tZd/e+e6r3oQFCCIpkMTJ/AXn6FZIP+Z5eVHfpAWskb8OOauwmyZKEbY4/fFn6FVHUWMiVWM6/W6CPCsXg+YLwhyN1JSFpakoVCcYBjw== 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 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=45RvYwsX6lKhqKPEKxlfJXUv2r/hkF/Ik0fPbpsoL5E=; b=kgobhIjQFmK/t62CGHsQz0KJ4pS0lzTP97vUfyCpykYkApdK2TzF59E9axE152rgPlK+kgnFU20Jj1TxAjHRbuEM0M61ROhYSVCYtYVcEWUzVVVN9bNyoFKzWPFME3yzroQktIi8h+YMdktUDKOEgbhuRj8L145uqmpg7f2cwtg= Received: from BN9PR03CA0394.namprd03.prod.outlook.com (2603:10b6:408:111::9) by MN2PR12MB4096.namprd12.prod.outlook.com (2603:10b6:208:1dc::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24; Thu, 22 Jun 2023 03:56:56 +0000 Received: from BN8NAM11FT056.eop-nam11.prod.protection.outlook.com (2603:10b6:408:111:cafe::e5) by BN9PR03CA0394.outlook.office365.com (2603:10b6:408:111::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23 via Frontend Transport; Thu, 22 Jun 2023 03:56:56 +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 BN8NAM11FT056.mail.protection.outlook.com (10.13.177.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.41 via Frontend Transport; Thu, 22 Jun 2023 03:56:56 +0000 Received: from ethanolx7ea3host.amd.com (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.23; Wed, 21 Jun 2023 22:56:54 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v6 23/27] cxl/pci: Map RCH downstream AER registers for logging protocol errors Date: Wed, 21 Jun 2023 22:51:22 -0500 Message-ID: <20230622035126.4130151-24-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622035126.4130151-1-terry.bowman@amd.com> References: <20230622035126.4130151-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: BN8NAM11FT056:EE_|MN2PR12MB4096:EE_ X-MS-Office365-Filtering-Correlation-Id: 1880aeaa-7454-4ee6-eaa3-08db72d4b8db X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SH5+cyBKOTq5/HW7xOQDQdrcMDs++GyKGKwnHDbA5i6J/FwGaX//P5M8WV1bzyjd21c9z4T+BYtsz2kOJnSz1pF3zxe1kY2TDa0Oy0NTcSehUJki9BBaEx9hs3zvWY18iE7AgeJ5pPZBdWOlScZSr4SpfodplHqX1mEOquo1TjVvJp1VANesX9jlFlFCq3jpF8kt3HjFhAK2YVML1xqJ441AOCueZ9yrE/AeIrJM/Pk7O5e1Qe8Reh+M5yEapTOPD6u6h/K0sR+EVKG1x3bOe8QO3QHYZ37TDP6K4ZYIf70CPszlYXBnNOVbDHoPB9P9c+XIeeBhUROgAhzIM5+KlcGj49d8/ZJ3RnXxn8OJUhECRQMclUjjob6ruXxyDYF58MIPrygNn0cki+UyyoGIcGeu/NTE4LitzcZHdntcAP4/xrMGuOKHZRXL0rvTWqL9Cm9z/KuyoX0GNpU6YMTUYsAYubbSL+VHMZxBRQfYZBlcJbyDWRVxPTN8tmgwlrxqulcyPp2p+ByycHK0pEkxj8VRyt86YdUtVQl4zH9m75DS/D2QvSppZzbfHoXViw2Ak8ATm2W30ERvWUe9lolCR9+4Bn0G6B3EaXNQJ1g/qc1i7qfJxOf8mC/8stRQug1lZs5z2BzgvDq2+pX97hohS8QSbG+YXKWZlkoB33r2DoRbl/8tGlTm7BmVI8ScC88Ai5sHkxIzXu337ftpjkigEVCwRDa9OpjorxcKgGSVZ5iVrrD4B/VEpXr7XyoyoNxLAF1aXiqcAllS2LAWqfTgbg== 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:(13230028)(4636009)(346002)(396003)(376002)(39860400002)(136003)(451199021)(46966006)(40470700004)(36840700001)(5660300002)(40480700001)(47076005)(7416002)(44832011)(2906002)(1076003)(26005)(41300700001)(8936002)(8676002)(40460700003)(186003)(426003)(83380400001)(478600001)(82310400005)(81166007)(356005)(82740400003)(7696005)(336012)(36756003)(36860700001)(2616005)(316002)(86362001)(70586007)(4326008)(70206006)(16526019)(54906003)(110136005)(6666004)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2023 03:56:56.2641 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1880aeaa-7454-4ee6-eaa3-08db72d4b8db 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: BN8NAM11FT056.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4096 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org The restricted CXL host (RCH) error handler will log protocol errors using AER and RAS status registers. The AER and RAS registers need to be virtually memory mapped before enabling interrupts. Update __devm_cxl_add_dport() to include RCH RAS and AER mapping. Add 'struct cxl_regs' to 'struct cxl_dport' for saving a unique copy of the RCH downstream port's mapped registers. Co-developed-by: Robert Richter Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron --- drivers/cxl/core/port.c | 33 +++++++++++++++++++++++++++++++++ drivers/cxl/core/regs.c | 1 + drivers/cxl/cxl.h | 11 +++++++++++ 3 files changed, 45 insertions(+) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 41e79a36c1ae..87a12e69aa8e 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -943,6 +944,36 @@ static void cxl_dport_unlink(void *data) sysfs_remove_link(&port->dev.kobj, link_name); } +static void cxl_dport_map_rch_aer(struct cxl_dport *dport) +{ + struct cxl_rcrb_info *ri = &dport->rcrb; + struct cxl_port *port = dport->port; + void __iomem *dport_aer = NULL; + resource_size_t aer_phys; + + if (dport->rch && ri->aer_cap) { + aer_phys = ri->aer_cap + ri->base; + dport_aer = devm_cxl_iomap_block(&port->dev, aer_phys, + sizeof(struct aer_capability_regs)); + } + + dport->regs.dport_aer = dport_aer; +} + +static void cxl_dport_map_regs(struct cxl_dport *dport) +{ + struct cxl_register_map *map = &dport->comp_map; + + if (!map->component_map.ras.valid) + dev_dbg(map->dev, "RAS registers not found\n"); + else if (cxl_map_component_regs(map, &dport->regs.component, + BIT(CXL_CM_CAP_CAP_ID_RAS))) + dev_dbg(dport->dport_dev, "Failed to map RAS capability.\n"); + + if (dport->rch) + cxl_dport_map_rch_aer(dport); +} + static struct cxl_dport * __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev, int port_id, resource_size_t component_reg_phys, @@ -1002,6 +1033,8 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev, if (rc) return ERR_PTR(rc); + cxl_dport_map_regs(dport); + cond_cxl_root_lock(port); rc = add_dport(port, dport); cond_cxl_root_unlock(port); diff --git a/drivers/cxl/core/regs.c b/drivers/cxl/core/regs.c index 60b7ba7f4030..982ef79670c7 100644 --- a/drivers/cxl/core/regs.c +++ b/drivers/cxl/core/regs.c @@ -198,6 +198,7 @@ void __iomem *devm_cxl_iomap_block(struct device *dev, resource_size_t addr, return ret_val; } +EXPORT_SYMBOL_NS_GPL(devm_cxl_iomap_block, CXL); int cxl_map_component_regs(struct cxl_register_map *map, struct cxl_component_regs *regs, diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index 9f46a4e1fbec..12f11cf8e280 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -209,6 +209,13 @@ struct cxl_regs { struct_group_tagged(cxl_device_regs, device_regs, void __iomem *status, *mbox, *memdev; ); + /* + * RCH downstream port specific RAS register + * @aer: CXL 3.0 8.2.1.1 RCH Downstream Port RCRB + */ + struct_group_tagged(cxl_rch_regs, rch_regs, + void __iomem *dport_aer; + ); }; struct cxl_reg_map { @@ -255,6 +262,8 @@ void cxl_probe_component_regs(struct device *dev, void __iomem *base, struct cxl_component_reg_map *map); void cxl_probe_device_regs(struct device *dev, void __iomem *base, struct cxl_device_reg_map *map); +void __iomem *devm_cxl_iomap_block(struct device *dev, resource_size_t addr, + resource_size_t length); int cxl_map_component_regs(struct cxl_register_map *map, struct cxl_component_regs *regs, unsigned long map_mask); @@ -598,6 +607,7 @@ struct cxl_rcrb_info { * @rcrb: Data about the Root Complex Register Block layout * @rch: Indicate whether this dport was enumerated in RCH or VH mode * @port: reference to cxl_port that contains this downstream port + * @regs: Dport parsed register blocks */ struct cxl_dport { struct device *dport_dev; @@ -606,6 +616,7 @@ struct cxl_dport { struct cxl_rcrb_info rcrb; bool rch; struct cxl_port *port; + struct cxl_regs regs; }; /** From patchwork Thu Jun 22 03:51:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13288238 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18E1CEB64D8 for ; Thu, 22 Jun 2023 03:59:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230076AbjFVD7R (ORCPT ); Wed, 21 Jun 2023 23:59:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229958AbjFVD6u (ORCPT ); Wed, 21 Jun 2023 23:58:50 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2043.outbound.protection.outlook.com [40.107.243.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93C972961; Wed, 21 Jun 2023 20:57:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZM+2w9pO8INAwi9/r9Tqa0pWO3/frepQyNQ/CH0Vgeu84A74PanjODhaXrH3qbfe3i31IU+/U6328+21cunOSLLSU3sKUdt2rd6QPUe022IAC7AVHIrC9VzObvNhdRRmPo4yo0xZKFaYkpXaiAUN5FsrjPeVqpyQsT00eR+iRSUQw9OMdpoNujXM5nLoBtSeGJNByiPc+3IXm3hhLeRjzbKGE4LmpCuZmuNsXNfmO0Aq0pDjN4USJ7y34Os6tMlAl+C9McmyPueHj5pLH59tIwMPl2alop5TWLUMzqnQHA9U+saUHOgpN1rPsdesnDjmz2vNree2QY32DGICPWnjdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=N2/XgMTWuARAg6h/D9gYdx1ekNbDBST9o6bpKIvL1nc=; b=biBTBhaaxJriraAJJWLJ3byHtIm4nEPBqs2YbJH9swUls3z0G8hRizl+f+YCNsiOrm0tj316Xrym+gErsbS+4m1CjyIMJ7Jh3wsmqeVboaoK3gaim7BzLSjNwz+D8gwAkxRqOFJiFfn8/ZhtHGceJK9+zVFkYndmF0vOD4OfKD0qtEM25xdZk1Kjhg9F0Qi/8AnBKMTwiH8c2KlxMkbvOHV6ai1lfClBlCRp0J0Ybh6tkRSA5XA5uGslC9j7tUWKmpSWr+soGUYdcl47fyNjx+QgQoQc8rPWXaX8JwAEZoyXK36PZa7XN0CC5osaPv75cstOuuSD+XQ5g4NEUFmy0g== 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 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=N2/XgMTWuARAg6h/D9gYdx1ekNbDBST9o6bpKIvL1nc=; b=BlShjtIU7E6OVzWVyvrbyrl9q/89vKb+9W9n5FEieGZizrRqobIMnhobRMGT96bTeiLYLlcu3NGfnd3sue0/vvhYFOJ/uo8MpvrMn+cLpH3VlNGqB0tm2oktZlQWGb0jbZc7PIV4ZPK/yMX4YRuU4EWmKBRVLVEG1NBo1XLG+os= Received: from BN9PR03CA0597.namprd03.prod.outlook.com (2603:10b6:408:10d::32) by CH3PR12MB9100.namprd12.prod.outlook.com (2603:10b6:610:1a8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Thu, 22 Jun 2023 03:57:07 +0000 Received: from BN8NAM11FT098.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10d:cafe::ab) by BN9PR03CA0597.outlook.office365.com (2603:10b6:408:10d::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24 via Frontend Transport; Thu, 22 Jun 2023 03:57: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 BN8NAM11FT098.mail.protection.outlook.com (10.13.177.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.39 via Frontend Transport; Thu, 22 Jun 2023 03:57:07 +0000 Received: from ethanolx7ea3host.amd.com (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.23; Wed, 21 Jun 2023 22:57:05 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v6 24/27] cxl/pci: Add RCH downstream port error logging Date: Wed, 21 Jun 2023 22:51:23 -0500 Message-ID: <20230622035126.4130151-25-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622035126.4130151-1-terry.bowman@amd.com> References: <20230622035126.4130151-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: BN8NAM11FT098:EE_|CH3PR12MB9100:EE_ X-MS-Office365-Filtering-Correlation-Id: c905c40d-9c02-4251-b855-08db72d4bf48 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TaM9kTDH/dP8BInWBswDGC5AWtsULgL0h0yQzWYpSOOTONnAUX0/592+DQqK2Rji/MnTUegLBcs4+eTnE6bryWF7fOvQWQm8Oqvl6GAKHY+wJXJEDO3Qj79YsYexcjpY16rd5QzROIpMKaSIB03yFvWidRHBl6WeYww0VF0L7ccLpZNh3tx1kj++NzjuQRkQ0rsGmfaEHZCM9wsk5ipBT2mNKE6bAWotIzruPS1TOFh54PF9Zds0s/lnnaUCp4Oj4bl/qFn8eGjTpwMOmDw2HAr57Hg1/lCRQYaoIcTI5V+kKxHn5+h1CLQlFZpdCkH7FHoz1HHHUY5l8WG8pleWO1a6uHSvLByQ1wIUU51kNfbmltcCqox3zwDxtghMtsi6/SRomPk2IY4meBDxrCHWHwUewaJzgcUmb+J81aXOC+lL/gdm9V5YxKZwHBVYwtv4TpRGdWlljLRxDGRhGoCI+0Zb5kOVLhUWpyAzlqZVLBhRmC1RTfMWN449jGrR4k6uHSafq+7yiYFM0oOvWgVgCb1gdEYmPuZYK4iAofcnD+M7ylIbpFb/WxYbOzKJUZ6GABAv1HbzUoyDSYt2zJGe3tpj6vmyYY1DV2WoQuLvQAJIlj10E/6kZVtT0ynX+akSNNNHkcPKvHDSSRvGsEEsO9hPundaK73ezt23EkhSFK2YK8sDx+rvFfEaJgLATgt8qyfVJ4yptyt/ECCOM1m2mDyj353ykYxAix58PrD9/o6TuqpM9CMgJnowtvj76neaj8aYZy0tAj44BdjI9MWE4Q== 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:(13230028)(4636009)(376002)(39860400002)(346002)(136003)(396003)(451199021)(36840700001)(40470700004)(46966006)(356005)(81166007)(82740400003)(2906002)(40480700001)(44832011)(7416002)(36860700001)(47076005)(426003)(83380400001)(36756003)(86362001)(1076003)(2616005)(186003)(16526019)(26005)(7696005)(40460700003)(336012)(82310400005)(6666004)(54906003)(110136005)(478600001)(70586007)(70206006)(41300700001)(8676002)(316002)(5660300002)(4326008)(8936002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2023 03:57:07.0435 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c905c40d-9c02-4251-b855-08db72d4bf48 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: BN8NAM11FT098.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9100 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org RCH downstream port error logging is missing in the current CXL driver. The missing AER and RAS error logging is needed for communicating driver error details to userspace. Update the driver to include PCIe AER and CXL RAS error logging. Add RCH downstream port error handling into the existing RCiEP handler. The downstream port error handler is added to the RCiEP error handler because the downstream port is implemented in a RCRB, is not PCI enumerable, and as a result is not directly accessible to the PCI AER root port driver. The AER root port driver calls the RCiEP handler for handling RCD errors and RCH downstream port protocol errors. Update existing RCiEP correctable and uncorrectable handlers to also call the RCH handler. The RCH handler will read the RCH AER registers, check for error severity, and if an error exists will log using an existing kernel AER trace routine. The RCH handler will also log downstream port RAS errors if they exist. Co-developed-by: Robert Richter Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron --- drivers/cxl/core/pci.c | 101 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index 9cb39835e154..9e0eba5ccfc4 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -747,10 +748,107 @@ static bool cxl_handle_endpoint_ras(struct cxl_dev_state *cxlds) return __cxl_handle_ras(cxlds, cxlds->regs.ras); } +#ifdef CONFIG_PCIEAER_CXL + +static void cxl_handle_rdport_cor_ras(struct cxl_dev_state *cxlds, + struct cxl_dport *dport) +{ + return __cxl_handle_cor_ras(cxlds, dport->regs.ras); +} + +static bool cxl_handle_rdport_ras(struct cxl_dev_state *cxlds, + struct cxl_dport *dport) +{ + return __cxl_handle_ras(cxlds, dport->regs.ras); +} + +/* + * Copy the AER capability registers using 32 bit read accesses. + * This is necessary because RCRB AER capability is MMIO mapped. Clear the + * status after copying. + * + * @aer_base: base address of AER capability block in RCRB + * @aer_regs: destination for copying AER capability + */ +static bool cxl_rch_get_aer_info(void __iomem *aer_base, + struct aer_capability_regs *aer_regs) +{ + int read_cnt = sizeof(struct aer_capability_regs) / sizeof(u32); + u32 *aer_regs_buf = (u32 *)aer_regs; + int n; + + if (!aer_base) + return false; + + /* Use readl() to guarantee 32-bit accesses */ + for (n = 0; n < read_cnt; n++) + aer_regs_buf[n] = readl(aer_base + n * sizeof(u32)); + + writel(aer_regs->uncor_status, aer_base + PCI_ERR_UNCOR_STATUS); + writel(aer_regs->cor_status, aer_base + PCI_ERR_COR_STATUS); + + return true; +} + +/* Get AER severity. Return false if there is no error. */ +static bool cxl_rch_get_aer_severity(struct aer_capability_regs *aer_regs, + int *severity) +{ + if (aer_regs->uncor_status & ~aer_regs->uncor_mask) { + if (aer_regs->uncor_status & PCI_ERR_ROOT_FATAL_RCV) + *severity = AER_FATAL; + else + *severity = AER_NONFATAL; + return true; + } + + if (aer_regs->cor_status & ~aer_regs->cor_mask) { + *severity = AER_CORRECTABLE; + return true; + } + + return false; +} + +static void cxl_handle_rdport_errors(struct cxl_dev_state *cxlds) +{ + struct pci_dev *pdev = to_pci_dev(cxlds->dev); + struct aer_capability_regs aer_regs; + struct cxl_dport *dport; + struct cxl_port *port; + int severity; + + port = cxl_pci_find_port(pdev, &dport); + if (!port) + return; + + put_device(&port->dev); + + if (!cxl_rch_get_aer_info(dport->regs.dport_aer, &aer_regs)) + return; + + if (!cxl_rch_get_aer_severity(&aer_regs, &severity)) + return; + + pci_print_aer(pdev, severity, &aer_regs); + + if (severity == AER_CORRECTABLE) + cxl_handle_rdport_cor_ras(cxlds, dport); + else + cxl_handle_rdport_ras(cxlds, dport); +} + +#else +static void cxl_handle_rdport_errors(struct cxl_dev_state *cxlds) { } +#endif + void cxl_cor_error_detected(struct pci_dev *pdev) { struct cxl_dev_state *cxlds = pci_get_drvdata(pdev); + if (cxlds->rcd) + cxl_handle_rdport_errors(cxlds); + cxl_handle_endpoint_cor_ras(cxlds); } EXPORT_SYMBOL_NS_GPL(cxl_cor_error_detected, CXL); @@ -763,6 +861,9 @@ pci_ers_result_t cxl_error_detected(struct pci_dev *pdev, struct device *dev = &cxlmd->dev; bool ue; + if (cxlds->rcd) + cxl_handle_rdport_errors(cxlds); + /* * A frozen channel indicates an impending reset which is fatal to * CXL.mem operation, and will likely crash the system. On the off From patchwork Thu Jun 22 03:51:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13288240 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9FC84EB64DD for ; Thu, 22 Jun 2023 04:00:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230011AbjFVEAs (ORCPT ); Thu, 22 Jun 2023 00:00:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230168AbjFVD7w (ORCPT ); Wed, 21 Jun 2023 23:59:52 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2047.outbound.protection.outlook.com [40.107.92.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FC221BF2; Wed, 21 Jun 2023 20:58:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mET5W2e5afvCkloTny/zNyYQCn+Cx6KGmUzTVFUH+UaD/5jgyYW715+sKZldisTE9CgwsIi77NXvNGZ7uz0Hcv710ofLXioYD4hPHq0WFY+8bPvwQyBdmoc1pC17Xzd0ySVnyKIC+Jpty7899bTbEMM3qzSS80LwFYtcll108WE31sUpckSSSFpU+ZksO5KgE94uLGKednWzvHLqfXN6OOSlClLE4orzTf/VptFaQ688ANjZadGdFuIWQpcp20eyKs0V9OcUBAgu4We9A4ebUMA+EerPSJ+/OJL0jy8DbItK0BCxJFtk+lPuuTmN0KIl/5k4/67Jgp5hF/dzfxfTWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=7dzdAMBEGDFkSPI8yEapGzVikvApe9b+yymoXLELQ24=; b=Y3/in9TtNlziyPiSSrv9rhd0tnSC2fiEyMyGo3KjdOXkH2kIp8Z45KBJjRCxCeARt57AJLallYW+FK40WQfSffo+nEnw/COuG6YTAZMHoKFwhfPivRssv1ksAyMw6tirQ2z+yIHl1kM1+YF3akkpUj8S8UyPnnh3C/reEX0hTJSiVtCb7oLXt68z9TsuOhwkhjGbbRa339Qdj0P3cANvbHISlmWA8UomhDzKYe26wLW08hrSC9vVvlibwzLIBXy8xrj74eOwCcIYpnkoFMIizbM5DPjlwd9Wa6AL5X8zxpMvqQwQHlAAtj9FofM2EswPm1hSoZK31eSEsJDZh3IFhA== 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 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=7dzdAMBEGDFkSPI8yEapGzVikvApe9b+yymoXLELQ24=; b=FBKo5fPJm6q+Jtkbq3rFt1k8iT71h47Q9NHMbQ7cxkmvBNjW66cZp3HBfzK8KoGk8j8AE7hz2600X71UXTD9GqGNzZ2lPoeBvFwxxZKPGe9s3b9iZcQXdB/wrMRiNOI3OWDTlFBCwy9TxvXW051kiMd8xI9sLQZazZn+JEjxHiw= Received: from BN9PR03CA0613.namprd03.prod.outlook.com (2603:10b6:408:106::18) by MW4PR12MB6952.namprd12.prod.outlook.com (2603:10b6:303:207::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.21; Thu, 22 Jun 2023 03:57:35 +0000 Received: from BN8NAM11FT031.eop-nam11.prod.protection.outlook.com (2603:10b6:408:106:cafe::4e) by BN9PR03CA0613.outlook.office365.com (2603:10b6:408:106::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24 via Frontend Transport; Thu, 22 Jun 2023 03:57:35 +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 BN8NAM11FT031.mail.protection.outlook.com (10.13.177.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.41 via Frontend Transport; Thu, 22 Jun 2023 03:57:34 +0000 Received: from ethanolx7ea3host.amd.com (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.23; Wed, 21 Jun 2023 22:57:16 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v6 25/27] cxl/pci: Disable root port interrupts in RCH mode Date: Wed, 21 Jun 2023 22:51:24 -0500 Message-ID: <20230622035126.4130151-26-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622035126.4130151-1-terry.bowman@amd.com> References: <20230622035126.4130151-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: BN8NAM11FT031:EE_|MW4PR12MB6952:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a6f8fa7-405f-42f5-6881-08db72d4cfa3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HCGypy8GD/dkz8KZnPmdLUTjRzzS6FWxHXhikI9mU7mCAdo7NSBRclZp5X2Wgv4TIbpkuhpBdMDOGdAlOXdiG2N7NUzVsjGijtaVNhyWYJdiLM5M1pD5KTgQk8csOfGbZFnTup4Dx+6/yOT6UCo6ylJu9R/nvbcc4XggCVrDmbL9mJFehvQLlphn1mBsThK+Or6q9nUe03s/YTBxPAyRO+nPC+nD/Vgc4qEupItMBCa6aGmhczJrNsUck6M1mgNG1vvsh/e3aX952z2O8xy+73yJcfN0NwQKatKDTGwlK7rio+rZb1oopsNPfXqsENt+N/qomEVib+e8PVIByH23PMWH+w0Dhlr2vTJkDUfllPQ9H8l7xlETP/scdCA5vRuy72lVQNR3fDTcDw+a2A5JVOoj70YlhR5Q4mEEDMRRFD/L9IXeUc5s7d8TK2HxhDlKV3tY4ArDKttPUvr8HrIH1VUgWqIYhCLDld6flAo41v4rOedP6b2dh4Orj90WDYQyJrkGf1ucTAmhcRJsTB8AD3M/sgHZjGFYLTarug7X8wJOlxCcrTYwM58JK1grJDhYEnPB+vfCIJ62bJiUO3G1nQHqZufVNDJkZ92uv7MF33ucdnz1OjaKRbH3o9nXNhlkuqgrYgk2pFtAKG+fhHgtzy2pfb0FEgYaDbOWNgX4LDUf8gXb004nt5TiIVTRRmtzusfzSW+7grU4osocB2HHfV7v7+kOBMjAZ3AZY3OTYMG5xEVHyYudvWCWRmJyAMnB3uJfeeC56YXBrg5jZ8PlSw== 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:(13230028)(4636009)(136003)(376002)(39860400002)(346002)(396003)(451199021)(40470700004)(46966006)(36840700001)(40460700003)(7696005)(478600001)(6666004)(36860700001)(16526019)(186003)(26005)(336012)(83380400001)(426003)(47076005)(36756003)(86362001)(2616005)(81166007)(82310400005)(356005)(1076003)(82740400003)(40480700001)(4326008)(70206006)(70586007)(316002)(5660300002)(44832011)(8676002)(8936002)(7416002)(41300700001)(110136005)(54906003)(2906002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2023 03:57:34.4814 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3a6f8fa7-405f-42f5-6881-08db72d4cfa3 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: BN8NAM11FT031.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6952 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org The RCH root port contains root command AER registers that should not be enabled.[1] Disable these to prevent root port interrupts. [1] CXL 3.0 - 12.2.1.1 RCH Downstream Port-detected Errors Signed-off-by: Terry Bowman Signed-off-by: Robert Richter Reviewed-by: Jonathan Cameron --- drivers/cxl/core/core.h | 6 ++++++ drivers/cxl/core/pci.c | 29 +++++++++++++++++++++++++++++ drivers/cxl/core/port.c | 3 +++ 3 files changed, 38 insertions(+) diff --git a/drivers/cxl/core/core.h b/drivers/cxl/core/core.h index 87467c633123..880bac9db376 100644 --- a/drivers/cxl/core/core.h +++ b/drivers/cxl/core/core.h @@ -86,4 +86,10 @@ enum cxl_poison_trace_type { CXL_POISON_TRACE_CLEAR, }; +#ifdef CONFIG_PCIEAER_CXL +void cxl_disable_rch_root_ints(struct cxl_dport *dport); +#else +static inline void cxl_disable_rch_root_ints(struct cxl_dport *dport) { }; +#endif + #endif /* __CXL_CORE_H__ */ diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index 9e0eba5ccfc4..39a2f9f4f115 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -838,6 +838,35 @@ static void cxl_handle_rdport_errors(struct cxl_dev_state *cxlds) cxl_handle_rdport_ras(cxlds, dport); } +void cxl_disable_rch_root_ints(struct cxl_dport *dport) +{ + void __iomem *aer_base = dport->regs.dport_aer; + struct pci_host_bridge *bridge; + u32 aer_cmd_mask, aer_cmd; + + if (!aer_base) + return; + + bridge = to_pci_host_bridge(dport->dport_dev); + + /* + * Disable RCH root port command interrupts. + * CXL 3.0 12.2.1.1 - RCH Downstream Port-detected Errors + * + * This sequnce may not be necessary. CXL spec states disabling + * the root cmd register's interrupts is required. But, PCI spec + * shows these are disabled by default on reset. + */ + if (bridge->native_cxl_error) { + aer_cmd_mask = (PCI_ERR_ROOT_CMD_COR_EN | + PCI_ERR_ROOT_CMD_NONFATAL_EN | + PCI_ERR_ROOT_CMD_FATAL_EN); + aer_cmd = readl(aer_base + PCI_ERR_ROOT_COMMAND); + aer_cmd &= ~aer_cmd_mask; + writel(aer_cmd, aer_base + PCI_ERR_ROOT_COMMAND); + } +} + #else static void cxl_handle_rdport_errors(struct cxl_dev_state *cxlds) { } #endif diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 87a12e69aa8e..2d812bbaf05f 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -1035,6 +1035,9 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev, cxl_dport_map_regs(dport); + if (dport->rch) + cxl_disable_rch_root_ints(dport); + cond_cxl_root_lock(port); rc = add_dport(port, dport); cond_cxl_root_unlock(port); From patchwork Thu Jun 22 03:51:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13288239 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D445EB64D8 for ; Thu, 22 Jun 2023 04:00:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229825AbjFVEAm (ORCPT ); Thu, 22 Jun 2023 00:00:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229684AbjFVD7N (ORCPT ); Wed, 21 Jun 2023 23:59:13 -0400 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on20622.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eb2::622]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 982FF296D; Wed, 21 Jun 2023 20:58:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aukQy2+OJvygP8GhV3C72LgqrEorY18fgEo5g4jfL/dDyZnlXPvIyGM+KalU8EvDcaeBJyl9AF7nJMSykWCjld3KXzU3IdPB3BCdjZeBZll22RBD6bEBJknpxKyz3KfwXaWkJlcs2y5O9Xz58+u95UijULRNZ2ORodlKwn6C+rie8GoA5wQ95l+1CZrGPIt9Hc9OxedNsxk5qk6F3bcPl78lwoprRdiR7x9lofZOPGogadFQboI2xpMRq0RjHFI3abMS4vK54zhUbNW3XMNYTHR8RNxAOI9D4cGLQDOqCOk72VoBNpRCz6bcdX7CHnO2BHIm7YefyfDwS2e7ApSw6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=YEWZoqGQjZGiHM078woqIXSPHIqp1sJsoUluk/TlTf0=; b=mfViSur8fVrVwrarq9LJ3AXeifUqlkGnSGYZJ7SKiMfdi4cLEj4m34yZZAxL8vgfAPI8ZbmowKazGEs5Fp6MFtsKinm+8UlPBRKMk1CwLE9xaB4bPQg+kOKwwEufoCMW8EbrPOjMNyNQrFMB/zSaVBUR8WhutmbLEF+kY92TnulM3p9aTiuRk1CGV1cmsOAQAjTXHZ170esbZxUddD/QoVAeTnT7uvMniHUJ/aDruYKPqv5VdYm9hd7ujlQ5hsiRq6pOfEOl99sMyez5G7aMpQ8/VuGdnw4Ct8TEBUCpNW4p+Wz9XtPrsSY1k/ehYXJityUkIUokEPtir58ztPZRGQ== 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 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=YEWZoqGQjZGiHM078woqIXSPHIqp1sJsoUluk/TlTf0=; b=vUs3RgfYDOxihf2J01jMuqp+SxmiLKoesipuBoRkjxFVaMfKEFRci8julB1MQ6i4Krk3Xtgj8UMlOhdngk1JNWJksJGyVmjhxLND5C9S1lN3fyh/NFpIBuPoG8ny1iDTU3Hub/wKHDev5fAkT8FbHmZWVOPhrB6pCT+H1XF+zTQ= Received: from BN1PR13CA0025.namprd13.prod.outlook.com (2603:10b6:408:e2::30) by MN0PR12MB5810.namprd12.prod.outlook.com (2603:10b6:208:376::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.21; Thu, 22 Jun 2023 03:57:46 +0000 Received: from BN8NAM11FT101.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e2:cafe::11) by BN1PR13CA0025.outlook.office365.com (2603:10b6:408:e2::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.9 via Frontend Transport; Thu, 22 Jun 2023 03:57:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT101.mail.protection.outlook.com (10.13.177.126) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.41 via Frontend Transport; Thu, 22 Jun 2023 03:57:45 +0000 Received: from ethanolx7ea3host.amd.com (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.23; Wed, 21 Jun 2023 22:57:44 -0500 From: Terry Bowman To: , , , , , , , CC: , , , , Oliver O'Halloran , , Subject: [PATCH v6 26/27] PCI/AER: Forward RCH downstream port-detected errors to the CXL.mem dev handler Date: Wed, 21 Jun 2023 22:51:25 -0500 Message-ID: <20230622035126.4130151-27-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622035126.4130151-1-terry.bowman@amd.com> References: <20230622035126.4130151-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: BN8NAM11FT101:EE_|MN0PR12MB5810:EE_ X-MS-Office365-Filtering-Correlation-Id: 89d2a05e-686a-47f4-5467-08db72d4d66d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pStLA9xEtLiDlfKYjcxkn8z8nyMgzRqSx/E+CMb/11mWTYUO7d/h4Z16WCSZnXYtu9qiaIm1z9b42EurFDrGHKYrw+be8ceBzbkwnKE0D2xoF4K9IFsDTn5WYwvx3Vhw+JpMV0NqLYXp1hjcy/DXoC/8EYOGKgw4ndbjTsa+wSrgWUJ/yFajEWPGLSm8JrxQbbRR61um1CVpeaw18gQzql0avCw6ITx/jKCPD49wTC94WvXnhPgEPDfDbAXeFuQlvt4WnAAyE1sAkYfVsLDv28wrZ4EatJjrpt1F1eBOgEn7tO5ia52nwy1dxKmoMh+FDhz0yGkAi7JHufu9Qp3ZX4D7OCfhCCnjAjzsot9ese8/NsdjAIOlQMBGJeKLcr6nmLQi5FwcPynK0tT1w/MiENX28IgA5katFsfkyK/vXYrJw3bEx/emUPlmFotJ1Y1RjT9KmfZ7ZMoa9/tc6MuUgAhwwjAi43uj4Z6W6KLDOzypzQkZxnEeaKH0uUzBOccz/9GHVw767i9510hsB9iHl2q0qFjErdyP5RS6wM6GDHPJONl1FA8HC1BbvoqWQgII3db+6n+p7qDIESlGAJlXHKmA5vzP8Gj0QBOsXOxUZHRZEkpz5liAIqKdExLW5FSAiZdVm9ZbdyRP7+M0qTEUAVoApHTidBbkS0oLKAlbFQTtfEqo3BfIm9uNTV0Mh6t4q1xZBpIJE9n6sQ94f1dOaU3U8TVj9Ed9SQ9jiy8m2edHFDfmW4xK8RqkCw6yF27fVNp1mRbIbLRScwuLYVfgpA== 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:(13230028)(4636009)(376002)(396003)(39860400002)(346002)(136003)(451199021)(36840700001)(46966006)(40470700004)(40460700003)(5660300002)(44832011)(7416002)(2906002)(40480700001)(82310400005)(8676002)(356005)(81166007)(47076005)(83380400001)(426003)(36860700001)(86362001)(36756003)(82740400003)(6666004)(4326008)(966005)(8936002)(478600001)(70206006)(70586007)(110136005)(7696005)(54906003)(41300700001)(186003)(16526019)(26005)(336012)(2616005)(316002)(1076003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2023 03:57:45.8867 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 89d2a05e-686a-47f4-5467-08db72d4d66d 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: BN8NAM11FT101.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5810 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter In Restricted CXL Device (RCD) mode a CXL device is exposed as an RCiEP, but CXL downstream and upstream ports are not enumerated and not visible in the PCIe hierarchy. [1] Protocol and link errors from these non-enumerated ports are signaled as internal AER errors, either Uncorrectable Internal Error (UIE) or Corrected Internal Errors (CIE) via an RCEC. Restricted CXL host (RCH) downstream port-detected errors have the Requster ID of the RCEC set in the RCEC's AER Error Source ID register. A CXL handler must then inspect the error status in various CXL registers residing in the dport's component register space (CXL RAS capability) or the dport's RCRB (PCIe AER extended capability). [2] Errors showing up in the RCEC's error handler must be handled and connected to the CXL subsystem. Implement this by forwarding the error to all CXL devices below the RCEC. Since the entire CXL device is controlled only using PCIe Configuration Space of device 0, function 0, only pass it there [3]. The error handling is limited to currently supported devices with the Memory Device class code set (CXL Type 3 Device, PCI_CLASS_MEMORY_CXL, 502h), handle downstream port errors in the device's cxl_pci driver. Support for other CXL Device Types (e.g. a CXL.cache Device) can be added later. To handle downstream port errors in addition to errors directed to the CXL endpoint device, a handler must also inspect the CXL RAS and PCIe AER capabilities of the CXL downstream port the device is connected to. Since CXL downstream port errors are signaled using internal errors, the handler requires those errors to be unmasked. This is subject of a follow-on patch. The reason for choosing this implementation is that the AER service driver claims the RCEC device, but does not allow it to register a custom specific handler to support CXL. Connecting the RCEC hard-wired with a CXL handler does not work, as the CXL subsystem might not be present all the time. The alternative to add an implementation to the portdrv to allow the registration of a custom RCEC error handler isn't worth doing it as CXL would be its only user. Instead, just check for an CXL RCEC and pass it down to the connected CXL device's error handler. With this approach the code can entirely be implemented in the PCIe AER driver and is independent of the CXL subsystem. The CXL driver only provides the handler. [1] CXL 3.0 spec: 9.11.8 CXL Devices Attached to an RCH [2] CXL 3.0 spec, 12.2.1.1 RCH Downstream Port-detected Errors [3] CXL 3.0 spec, 8.1.3 PCIe DVSEC for CXL Devices Co-developed-by: Terry Bowman Signed-off-by: Terry Bowman Signed-off-by: Robert Richter Cc: "Oliver O'Halloran" Cc: Bjorn Helgaas Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-pci@vger.kernel.org Acked-by: Bjorn Helgaas Reviewed-by: Jonathan Cameron --- drivers/pci/pcie/Kconfig | 12 +++++ drivers/pci/pcie/aer.c | 96 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 106 insertions(+), 2 deletions(-) diff --git a/drivers/pci/pcie/Kconfig b/drivers/pci/pcie/Kconfig index 228652a59f27..4f0e70fafe2d 100644 --- a/drivers/pci/pcie/Kconfig +++ b/drivers/pci/pcie/Kconfig @@ -49,6 +49,18 @@ config PCIEAER_INJECT gotten from: https://git.kernel.org/cgit/linux/kernel/git/gong.chen/aer-inject.git/ +config PCIEAER_CXL + bool "PCI Express CXL RAS support for Restricted Hosts (RCH)" + default y + depends on PCIEAER && CXL_PCI + help + Enables error handling of downstream ports of a CXL host + that is operating in RCD mode (Restricted CXL Host, RCH). + The downstream port reports AER errors to a given RCEC. + Errors are handled by the CXL memory device driver. + + If unsure, say Y. + # # PCI Express ECRC # diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index d3344fcf1f79..c354ca5e8f2b 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -946,14 +946,100 @@ static bool find_source_device(struct pci_dev *parent, return true; } +#ifdef CONFIG_PCIEAER_CXL + +static bool is_cxl_mem_dev(struct pci_dev *dev) +{ + /* + * The capability, status, and control fields in Device 0, + * Function 0 DVSEC control the CXL functionality of the + * entire device (CXL 3.0, 8.1.3). + */ + if (dev->devfn != PCI_DEVFN(0, 0)) + return false; + + /* + * CXL Memory Devices must have the 502h class code set (CXL + * 3.0, 8.1.12.1). + */ + if ((dev->class >> 8) != PCI_CLASS_MEMORY_CXL) + return false; + + return true; +} + +static bool cxl_error_is_native(struct pci_dev *dev) +{ + struct pci_host_bridge *host = pci_find_host_bridge(dev->bus); + + if (pcie_ports_native) + return true; + + return host->native_aer && host->native_cxl_error; +} + +static bool is_internal_error(struct aer_err_info *info) +{ + if (info->severity == AER_CORRECTABLE) + return info->status & PCI_ERR_COR_INTERNAL; + + return info->status & PCI_ERR_UNC_INTN; +} + +static int cxl_rch_handle_error_iter(struct pci_dev *dev, void *data) +{ + struct aer_err_info *info = (struct aer_err_info *)data; + const struct pci_error_handlers *err_handler; + + if (!is_cxl_mem_dev(dev) || !cxl_error_is_native(dev)) + return 0; + + /* protect dev->driver */ + device_lock(&dev->dev); + + err_handler = dev->driver ? dev->driver->err_handler : NULL; + if (!err_handler) + goto out; + + if (info->severity == AER_CORRECTABLE) { + if (err_handler->cor_error_detected) + err_handler->cor_error_detected(dev); + } else if (err_handler->error_detected) { + if (info->severity == AER_NONFATAL) + err_handler->error_detected(dev, pci_channel_io_normal); + else if (info->severity == AER_FATAL) + err_handler->error_detected(dev, pci_channel_io_frozen); + } +out: + device_unlock(&dev->dev); + return 0; +} + +static void cxl_rch_handle_error(struct pci_dev *dev, struct aer_err_info *info) +{ + /* + * Internal errors of an RCEC indicate an AER error in an + * RCH's downstream port. Check and handle them in the CXL.mem + * device driver. + */ + if (pci_pcie_type(dev) == PCI_EXP_TYPE_RC_EC && + is_internal_error(info)) + pcie_walk_rcec(dev, cxl_rch_handle_error_iter, info); +} + +#else +static inline void cxl_rch_handle_error(struct pci_dev *dev, + struct aer_err_info *info) { } +#endif + /** - * handle_error_source - handle logging error into an event log + * pci_aer_handle_error - handle logging error into an event log * @dev: pointer to pci_dev data structure of error source device * @info: comprehensive error information * * Invoked when an error being detected by Root Port. */ -static void handle_error_source(struct pci_dev *dev, struct aer_err_info *info) +static void pci_aer_handle_error(struct pci_dev *dev, struct aer_err_info *info) { int aer = dev->aer_cap; @@ -977,6 +1063,12 @@ static void handle_error_source(struct pci_dev *dev, struct aer_err_info *info) pcie_do_recovery(dev, pci_channel_io_normal, aer_root_reset); else if (info->severity == AER_FATAL) pcie_do_recovery(dev, pci_channel_io_frozen, aer_root_reset); +} + +static void handle_error_source(struct pci_dev *dev, struct aer_err_info *info) +{ + cxl_rch_handle_error(dev, info); + pci_aer_handle_error(dev, info); pci_dev_put(dev); } From patchwork Thu Jun 22 03:51:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13288241 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5EF94EB64DC for ; Thu, 22 Jun 2023 04:00:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230085AbjFVEAw (ORCPT ); Thu, 22 Jun 2023 00:00:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230459AbjFVD7Y (ORCPT ); Wed, 21 Jun 2023 23:59:24 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on20611.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5b::611]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69890271E; Wed, 21 Jun 2023 20:58:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JgOi+Vz96tug7fsXIzfkL2opPNzONanhMdplmCkYaSu5GcCHBTB8X8ByIf4SqB7X4OD53BRVHldODYOQeqQ2eI/BBpGNczYAOxIXFJD1+PdYjdyx2JtsPTt/0ZUXcUPI1nEicgZGY5Dv5UI3OETCDQOZQJJ+S8e6Ax/bb247MNAHKahedpjJU4IiwYnz8ozEQBQnq6PQbVYq3zlF4+4CsOSUMzoZjYtPkBaiGejJJaGdxaE02r1AjlYOUBUD4LD6ERExHFgAwz0PXDvI9gRmNObcEDa2fFFBvFJnByx0MJb/ZpOi0Ms8M1cNF4iUIxA+jvmu3rUOzMdm17tw6ySLNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=CeGQ5wxvm+T/vHtnY2fziI7cVswcjWO6ScDOOc443ck=; b=WVnsVpT7U6dvhJEe3eLrrEwBL5Dt4fsaWaAmLeoFVhRJSqg4pKnppTos5JKV2LQUopzIbaYOCuvDuSJf1azqKeJNaFTFl5nvGeJo1IxNbC35ShLNbDPcitsLPj951CytwtCgq+cwrCsNS5bhARlYZu3jMnsCBMzey/bLeZtc+mhlGPlPiKEvRszU80Mm2njoJt/OfV8yJXWliRMeOsE0GO7jo3eK9d2QZAFOvCJkLPcGiQ8XKtuXwUH6HXTf+ucS6yFfhEhcr3N6mQDj0KHzp2KAPH95+nKmu4zYn7jri/JKMf449F1hz8OCtg8Lt9whjUrRXuLVrQ8p2ymbliHAew== 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 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=CeGQ5wxvm+T/vHtnY2fziI7cVswcjWO6ScDOOc443ck=; b=5fyvimfIdP3j7xkzgebVkEoxsVEN+Fj2SgbhkjgoILly/trf61aHX+4TZgvOzSXSEF6AOKX5lYIaBrqbgsJZsr3ppGgN1XWBbvgqVrmohVSNaU9Hlk+vkFmk6/sYvJwy9MYCHeccR0J75Eb46Tv9uM0EifIhPHCLGRUvn9Y/M8A= Received: from BN8PR03CA0009.namprd03.prod.outlook.com (2603:10b6:408:94::22) by DS0PR12MB7745.namprd12.prod.outlook.com (2603:10b6:8:13c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Thu, 22 Jun 2023 03:57:57 +0000 Received: from BN8NAM11FT074.eop-nam11.prod.protection.outlook.com (2603:10b6:408:94:cafe::3a) by BN8PR03CA0009.outlook.office365.com (2603:10b6:408:94::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.37 via Frontend Transport; Thu, 22 Jun 2023 03:57:57 +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 BN8NAM11FT074.mail.protection.outlook.com (10.13.176.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.41 via Frontend Transport; Thu, 22 Jun 2023 03:57:56 +0000 Received: from ethanolx7ea3host.amd.com (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.23; Wed, 21 Jun 2023 22:57:55 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v6 27/27] PCI/AER: Unmask RCEC internal errors to enable RCH downstream port error handling Date: Wed, 21 Jun 2023 22:51:26 -0500 Message-ID: <20230622035126.4130151-28-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622035126.4130151-1-terry.bowman@amd.com> References: <20230622035126.4130151-1-terry.bowman@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: BN8NAM11FT074:EE_|DS0PR12MB7745:EE_ X-MS-Office365-Filtering-Correlation-Id: 3cce9866-004a-46c7-bb1b-08db72d4dcce X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bvIk4vYyRb9pi8o3Z1/D+/o8dykExecaFobbYBJHRwGPX5FCSRSP/k09og1MVBHGLhN7Nfb8kPDTSxot68wFPWdWEN1w8HXAXMG6bSsKGK/stL9iScMpH+fRz+a6dq5WdnbfZImNfuewemiYWspF2PHFotDVOlUr2KiS7SZ6cAKddvNpBWqjVe4sndeyLoZ/Vbmk1cKotuKaRTx2520Y2ZjS+iTh+aofyHxGIEonnY2B05YjKirnAYuf+p/hIo01mprgrDqc399LCYLDL8o/ujHJCMciaqFKu2rgxx8jAWPkcaEb1JidgQ/eVhYoEfdj+ZbgHm3BMUzu5Z6YgV66/mDcF3nwk4GvCgYzd9+BfVyVUTK2znZmgczZttx4cJYVzCCcA13YTCDbf2rpm7cqNYBXPEviwl84NeuZpu61OB6bDui7/q9ZXANcPOzCFQ1CjP0b1JqASZ9o6e5PEsAY9c60D0yPgvYZq4g/bZBXYkgkfdhvl9dBcZWjnUokbNnx0c5P424eTetXjK8xQNkroOMCkj66BxbnzTYofwfKPfWBK89rietns24JHfbfCIEH6YX3LoLD55UHV0P4/lcar5ES82QOH+xeemnkF9GRy3JlYDgsIQfY3W/OWcETa5Qfr0KTjU5eciG4DoIbbPJBw4QQOQTJSK+Ej+iz8VcweE4tnT/L7Ys9TZXRxQNz3gDSvGLlRPFmIwU71qRorcTXirrlelyMMuGDdILofutTUIGiMCNyfyq4tpLWZJ33EQv88foafI+rLVp5jeTu56VPnLNiOoaEmW3jISu/4XsBTWU= 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:(13230028)(4636009)(136003)(376002)(396003)(346002)(39860400002)(451199021)(40470700004)(46966006)(36840700001)(7416002)(5660300002)(4326008)(70206006)(70586007)(36756003)(478600001)(44832011)(316002)(40480700001)(8676002)(8936002)(110136005)(2906002)(40460700003)(36860700001)(54906003)(41300700001)(86362001)(7696005)(82310400005)(1076003)(426003)(16526019)(26005)(336012)(47076005)(186003)(82740400003)(6666004)(81166007)(356005)(83380400001)(2616005)(36900700001)(309714004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2023 03:57:56.5757 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3cce9866-004a-46c7-bb1b-08db72d4dcce 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: BN8NAM11FT074.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7745 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter AER corrected and uncorrectable internal errors (CIE/UIE) are masked in their corresponding mask registers per default once in power-up state. [1][2] Enable internal errors for RCECs to receive CXL downstream port errors of Restricted CXL Hosts (RCHs). [1] CXL 3.0 Spec, 12.2.1.1 - RCH Downstream Port Detected Errors [2] PCIe Base Spec r6.0, 7.8.4.3 Uncorrectable Error Mask Register, 7.8.4.6 Correctable Error Mask Register Co-developed-by: Terry Bowman Signed-off-by: Terry Bowman Signed-off-by: Robert Richter Acked-by: Bjorn Helgaas Reviewed-by: Jonathan Cameron --- drivers/pci/pcie/aer.c | 57 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index c354ca5e8f2b..4f9203e27c62 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -948,6 +948,30 @@ static bool find_source_device(struct pci_dev *parent, #ifdef CONFIG_PCIEAER_CXL +/** + * pci_aer_unmask_internal_errors - unmask internal errors + * @dev: pointer to the pcie_dev data structure + * + * Unmasks internal errors in the Uncorrectable and Correctable Error + * Mask registers. + * + * Note: AER must be enabled and supported by the device which must be + * checked in advance, e.g. with pcie_aer_is_native(). + */ +static void pci_aer_unmask_internal_errors(struct pci_dev *dev) +{ + int aer = dev->aer_cap; + u32 mask; + + pci_read_config_dword(dev, aer + PCI_ERR_UNCOR_MASK, &mask); + mask &= ~PCI_ERR_UNC_INTN; + pci_write_config_dword(dev, aer + PCI_ERR_UNCOR_MASK, mask); + + pci_read_config_dword(dev, aer + PCI_ERR_COR_MASK, &mask); + mask &= ~PCI_ERR_COR_INTERNAL; + pci_write_config_dword(dev, aer + PCI_ERR_COR_MASK, mask); +} + static bool is_cxl_mem_dev(struct pci_dev *dev) { /* @@ -1027,7 +1051,39 @@ static void cxl_rch_handle_error(struct pci_dev *dev, struct aer_err_info *info) pcie_walk_rcec(dev, cxl_rch_handle_error_iter, info); } +static int handles_cxl_error_iter(struct pci_dev *dev, void *data) +{ + int *handles_cxl = data; + + if (!*handles_cxl) + *handles_cxl = is_cxl_mem_dev(dev) && cxl_error_is_native(dev); + + /* Non-zero terminates iteration */ + return *handles_cxl; +} + +static bool handles_cxl_errors(struct pci_dev *rcec) +{ + int handles_cxl = 0; + + if (pci_pcie_type(rcec) == PCI_EXP_TYPE_RC_EC && + pcie_aer_is_native(rcec)) + pcie_walk_rcec(rcec, handles_cxl_error_iter, &handles_cxl); + + return !!handles_cxl; +} + +static void cxl_rch_enable_rcec(struct pci_dev *rcec) +{ + if (!handles_cxl_errors(rcec)) + return; + + pci_aer_unmask_internal_errors(rcec); + pci_info(rcec, "CXL: Internal errors unmasked"); +} + #else +static inline void cxl_rch_enable_rcec(struct pci_dev *dev) { } static inline void cxl_rch_handle_error(struct pci_dev *dev, struct aer_err_info *info) { } #endif @@ -1428,6 +1484,7 @@ static int aer_probe(struct pcie_device *dev) return status; } + cxl_rch_enable_rcec(port); aer_enable_rootport(rpc); pci_info(port, "enabled with IRQ %d\n", dev->irq); return 0;