From patchwork Fri Aug 25 23:31:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13366411 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 A658CC83F0A for ; Fri, 25 Aug 2023 23:33:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230426AbjHYXdD (ORCPT ); Fri, 25 Aug 2023 19:33:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231172AbjHYXcs (ORCPT ); Fri, 25 Aug 2023 19:32:48 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83D1E210D; Fri, 25 Aug 2023 16:32:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RulkMzR+aOWcngkFbnUWD6g3Runstjdq+Edi4U11k2FrNa7Aeo+NWSO33xLKU2jq9xE8jB2FIjH9nRNnjhFqB0V5QbDswHLk7SSsEef5MUrel43OVD3D0sF1MXzltvtqQd9AOTqdmy7IRK/NKMITwRWAS7nxXrw9r8b525nnMm7FHgRaPivBVvu8kFTMIUyNj+2Ir8MaiRikmdPw28I8oBGwvK2GIij9WHXdEFJbNqZd/f+At4Dfzv1T/QsaiTrEiQCIsicNlsYPQoz8cWjRWp10CdaiQQ1X/mgy/Q/ekbqHfTg9uWpv6HZFp+oFnAKeQkYzGJiWnWq4WJuIV5NsRQ== 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=56RYeX9FEUbjjvfF0XQyGJKCuOAJ9jsg5sVDPyKjJzg=; b=XQdvz1ecqe6VHBkve5+RIexJ2wUzk2CNXjJgBrE0MIEpYLJyhlJ7VavsDyy9bMUl4gyh2ZohKRvo30PSehsAF20YD2HpXbSRGnP/a+zeZM/XlnCBeIphFw5n9BboPlzd4rLIFoCZzfc/bbncelXcqAqAOsRBIyKubN40j0rOm2milz6CcVZStXnJ2dinsTUrqxzTlUBQvdkauGIyiDSYOkLGs1MQXmTE5/lCyy5OFhX92PRh8BV/KSogveeFJBvM4/UtZEcFusXcxvEJOD7UhqMTPcNLxp9/Fjxs9hcKpoE6Cc9PfFSzDOQDjwXCX+9CCRcqSuS4fLYF64voD1P+uA== 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=56RYeX9FEUbjjvfF0XQyGJKCuOAJ9jsg5sVDPyKjJzg=; b=0ELkmF/KVv/oHJMibx8apZhUlB5u5MKtoVJydUMomLk856sFl5Olf9IL9CdS/wviCIkaUE5oUKCOsd9k6oK1bUcu+zWUczGJF43Iqd/uSAZkuT/q33CKBlXi3LR4P4LY06fzFXOWzatqk4eCGdxw4YWWDukuiigaYnmMtZqF0RQ= Received: from CY5PR15CA0016.namprd15.prod.outlook.com (2603:10b6:930:14::11) by MN0PR12MB6296.namprd12.prod.outlook.com (2603:10b6:208:3d3::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Fri, 25 Aug 2023 23:32:43 +0000 Received: from CY4PEPF0000EE37.namprd05.prod.outlook.com (2603:10b6:930:14:cafe::97) by CY5PR15CA0016.outlook.office365.com (2603:10b6:930:14::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27 via Frontend Transport; Fri, 25 Aug 2023 23:32: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 CY4PEPF0000EE37.mail.protection.outlook.com (10.167.242.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.15 via Frontend Transport; Fri, 25 Aug 2023 23:32:42 +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.27; Fri, 25 Aug 2023 18:32:41 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v9 01/15] cxl/port: Pre-initialize component register mappings Date: Fri, 25 Aug 2023 18:31:57 -0500 Message-ID: <20230825233211.3029825-2-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230825233211.3029825-1-terry.bowman@amd.com> References: <20230825233211.3029825-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: CY4PEPF0000EE37:EE_|MN0PR12MB6296:EE_ X-MS-Office365-Filtering-Correlation-Id: f115d1ae-a1ca-4dd5-9b94-08dba5c3945b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yEITG7zDfJitDyIREunCG8Co5FynZ67U/C2tNhdWC0eGwvZc9ANgzrNmLISxQ8fi0HCjrfk5MCynOuc59ypG+Tpz98y4TY+IB2O0Mz6v1YguwX0nYpe8Dk0wzFZXFeswhYoLzZVfmD0f5F6BfftWIFHff1JEmFtyoeAmH4Kk3X8/Niql9/lF8nNRPLzJuPfZJMxhPpVc8JhbY+xpHNHWByxD8SPSxSvVruEwadhfONH99z+eVr7cyWuaLG9ffbGPlkHY/3u9VnD+vDQ7d3uA2fd5epVxMt1YuhE0EisoMBBh4+4GWwSuDs0cn00wNZa/0LI1325QsKSsR4YbqlDH0PsDWwJX8oYpjqd3kvChHLVNqbUOg9WvjJ1bc+lgoWWrLvRAjHnh8M3CwzNK11xRi2HuEzu2I0qxQFTUGRcEV4p3Da3/g2w2fcFJkwvlX0svZzJ+MSmiacSclF2MdSojg2GOtYK7Q8/fv1gYBLAdN/HpNzxInz/2E9TWqy0VLEmI/owQtPYlGGAR30tfgNKknM1MzrACOXH/EctpR8H8Sj99MM7Pc4q3H33U03zWTJKkp+EGK5DWenEPOnrAA6BRCGDj58xRxkcrOaB8ZCUSBmXRsLx2I2HqaYGJpicqK9t6pQld5RNhyk9DyrS1hyftNzRAtKe9P+rBPxxXWR2R094twmqXE5hAVE6v0Bvhja2dccfgGi0b47iBiwekMvkBU7YM5rzk2lUsyPhMflEZhyAGvZvPGyxQvOVsR3byXnUsI7Nxnf0LzTMbOqpGDFMb4g== 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:(13230031)(4636009)(136003)(346002)(39860400002)(376002)(396003)(451199024)(1800799009)(186009)(82310400011)(46966006)(36840700001)(40470700004)(54906003)(7696005)(70586007)(316002)(70206006)(81166007)(478600001)(110136005)(26005)(36860700001)(44832011)(356005)(6666004)(16526019)(40480700001)(82740400003)(41300700001)(86362001)(2906002)(8676002)(8936002)(4326008)(1076003)(40460700003)(2616005)(5660300002)(7416002)(83380400001)(36756003)(336012)(426003)(47076005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2023 23:32:42.8044 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f115d1ae-a1ca-4dd5-9b94-08dba5c3945b 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: CY4PEPF0000EE37.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6296 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter The component registers of a component may not exist or are not needed. The setup may fail for that reason. In some cases the initialization should continue anyway. Thus, always initialize struct cxl_register_map with valid values. In case of errors, zero it, set a value for @dev and make @resource a the valid value using CXL_RESOURCE_NONE. Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron --- drivers/cxl/core/port.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 724be8448eb4..2d22e7a5629b 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -693,16 +693,17 @@ static struct cxl_port *cxl_port_alloc(struct device *uport_dev, 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; - *map = (struct cxl_register_map) { .dev = dev, - .reg_type = CXL_REGLOC_RBI_COMPONENT, .resource = component_reg_phys, - .max_size = CXL_COMPONENT_REG_BLOCK_SIZE, }; + if (component_reg_phys == CXL_RESOURCE_NONE) + return 0; + + map->reg_type = CXL_REGLOC_RBI_COMPONENT; + map->max_size = CXL_COMPONENT_REG_BLOCK_SIZE; + return cxl_setup_regs(map); } From patchwork Fri Aug 25 23:31:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13366412 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 C03D9C83F04 for ; Fri, 25 Aug 2023 23:34:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230505AbjHYXdd (ORCPT ); Fri, 25 Aug 2023 19:33:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231178AbjHYXdB (ORCPT ); Fri, 25 Aug 2023 19:33:01 -0400 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2065.outbound.protection.outlook.com [40.107.102.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41FBD2114; Fri, 25 Aug 2023 16:32:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JN7YpM61ScrIPD0ZqMxrLEnX7YWZCxhk9Ofz0IlrINiVJhf+fDaY2VvW9bnef3L9i6gHVXHvnkjzj8QEveujZaO4PFh81d8YwlhzRTMJ8q/XxkeznNEZp1hd2htUeu1ec5LCt5JK1x20qcTNPAABgr9B1GggaAXCz1oB+EFxqS2b42LPxZjGocxhnocPjU6R7qNxylN+8jw96DKpKuUgJ1Kmdzj0NwZWYR3viB1qJvoRToBKEQbowNQTda/dmkR6IvusrbVTcesr/FljLnxuRPOrODxdRn27FUPmMW7Hu1tMUDUKMWJFwJSu2VVwTa0cfelSjQxiN/5LGMiY1oR+6g== 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=xgg1Y9NYkQQlAypZ3mejX5mXhLZcQCqhttGh1FfK68o=; b=BhjoZTXI6mA8rfPQ4jiFXt2lSavQi8GvbLLVvaV+FqRZ9n5bpkkiocpannlGMUzIwmtH0KHn0C4HylhftPmm7fuo09pyhmBkaSk7PdMCcnKmiNoAmN34qFp/jumoiun+K5A26aMaBVwWJlAsPxMqqN3WVzTLpKiRwgILJI4qZoMhw79g4tn8H4N95GqvlEnPMrgR1gMHr1x60LrAq3xGR3x86Byx+OK0t1tpWWyqOB2eqoFrOlnMfqiOFMX2bCMzC+7fe8Dmc5Io4s9hH0acyToPgnzoSqTzzCpTbPgOKLCFTF5DPlCpd9U/yT9/AqI59rF17Io0xjrbp015BBXBCQ== 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=xgg1Y9NYkQQlAypZ3mejX5mXhLZcQCqhttGh1FfK68o=; b=JFdzYFzIUPvuazeHBq6wik/uR3b1/QCAQM8IPz23gcsq/qYvxfNk2YdL8bOKrJuVjiI33xdM0I16DI1H5WFJEcIDHPWKrSCTSFOwocvXcDmeumwhjbcUI1PGp+WMkVjef1JlgvqgDYW4w9thE1rBZOr3t+b2CQ9WKWYwu0mORug= Received: from SA9PR13CA0120.namprd13.prod.outlook.com (2603:10b6:806:24::35) by CH3PR12MB9454.namprd12.prod.outlook.com (2603:10b6:610:1c7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.34; Fri, 25 Aug 2023 23:32:56 +0000 Received: from SN1PEPF00026369.namprd02.prod.outlook.com (2603:10b6:806:24:cafe::c0) by SA9PR13CA0120.outlook.office365.com (2603:10b6:806:24::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6723.20 via Frontend Transport; Fri, 25 Aug 2023 23:32: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 SN1PEPF00026369.mail.protection.outlook.com (10.167.241.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.15 via Frontend Transport; Fri, 25 Aug 2023 23:32: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.27; Fri, 25 Aug 2023 18:32:52 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v9 02/15] cxl/regs: Prepare for multiple users of register mappings Date: Fri, 25 Aug 2023 18:31:58 -0500 Message-ID: <20230825233211.3029825-3-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230825233211.3029825-1-terry.bowman@amd.com> References: <20230825233211.3029825-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: SN1PEPF00026369:EE_|CH3PR12MB9454:EE_ X-MS-Office365-Filtering-Correlation-Id: d0320372-253d-460b-d81e-08dba5c39bf6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +4Heeb5GuqX2UWHSUvt55uK6sJJK0l+tGceLZoTNcxpnEG306Nk26ccpq0ui/IUO7VMkNRrT3nCk/oR7g4n7pEpD7gRHs3bW//KCIUC/y2tKCi18Rs39hGR5Jgwd5PdLqAT/eAxt+z9Mj9o2X0FnNbGud054Yme1wkzUvfqKtxW7dZyopL0HoeBPfs27wQzB/tegn4oId19ZOacPY+fI/HqxyflOp17gxgwZqtpDOF/TO4PAzmzKU7v+wx7krje1SFzkHxj1BMGmLd0AaIu0Ekme82K1KTN29rKna1RCoF3K75hxwnot4pnL09QcacqGzx9WWfCv+ozGOCIEpIP+NzEWeqR8OeBstA4JTSa3An4D7POKUyO3+eVXFJj1U6Y6BcNjGYb9qYD1XoQHufOrAieRMrBjlCrveHgZthq154CI3ebpfhqwQCydp7DSdY/ma/ogjDoqcNDiCJW32KaAqjrtPn+F/7sdPmaFbh7MkgoBLPFftMAd30dSgC1avXeQSufddodWop9N/h+g8mUsopbpsxxn3aHPbx4w5RXei4/dp1BN5ywLdCuzIyFrSeCWOGAObpNDk/hG4xtRfrlhMfHakmNFNcMJNH5gdARWgQeyyBhrsiD990Y27QN0F8TUQlxUseCecuzgmXIpxNBvFtWnmIWtG5C+Wbfe7J7vLdabHG2MWm+lu3JnmNO/6FQN4K8Q6cTy7AuUCl42J/K0Vs57Pt0rSvK2w0WXzM5I3VsybtropEO3XZHTmun3TFgBc7KxeIG+2QpXiA2sZN0PIQ== 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:(13230031)(4636009)(346002)(396003)(376002)(39860400002)(136003)(82310400011)(451199024)(1800799009)(186009)(46966006)(40470700004)(36840700001)(7696005)(478600001)(426003)(83380400001)(2616005)(336012)(1076003)(2906002)(16526019)(26005)(7416002)(41300700001)(316002)(54906003)(8936002)(70206006)(110136005)(70586007)(44832011)(5660300002)(4326008)(8676002)(40460700003)(36756003)(40480700001)(36860700001)(47076005)(82740400003)(86362001)(356005)(81166007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2023 23:32:55.6283 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d0320372-253d-460b-d81e-08dba5c39bf6 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: SN1PEPF00026369.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9454 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter The function devm_cxl_iomap_block() is used to map register mappings of CXL component or device registers. A @dev is used to unmap the IO regions during device removal. Now, there are multiple devices using the register mappings. E.g. the RAS cap of the Component Registers is used by cxl_pci, the HDM cap used in cxl_mem. This could cause IO blocks not being freed and a subsequent reinitialization to fail if the same device is used for both. To prevent that, expand cxl_map_component_regs() to pass a @dev to be used with devm to IO unmap. This allows to pass the device that actually is creating and using the IO region. For symmetry also change the function i/f of cxl_map_device_regs(). Signed-off-by: Robert Richter Signed-off-by: Terry Bowman --- drivers/cxl/core/hdm.c | 3 ++- drivers/cxl/core/regs.c | 4 ++-- drivers/cxl/cxl.h | 2 ++ drivers/cxl/pci.c | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c index 4449b34a80cc..17c8ba8c75e0 100644 --- a/drivers/cxl/core/hdm.c +++ b/drivers/cxl/core/hdm.c @@ -98,7 +98,8 @@ static int map_hdm_decoder_regs(struct cxl_port *port, void __iomem *crb, return -ENODEV; } - return cxl_map_component_regs(&map, regs, BIT(CXL_CM_CAP_CAP_ID_HDM)); + return cxl_map_component_regs(&map, &port->dev, 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 6281127b3e9d..dfc3e272e7d8 100644 --- a/drivers/cxl/core/regs.c +++ b/drivers/cxl/core/regs.c @@ -201,10 +201,10 @@ void __iomem *devm_cxl_iomap_block(struct device *dev, resource_size_t addr, } int cxl_map_component_regs(const struct cxl_register_map *map, + struct device *dev, struct cxl_component_regs *regs, unsigned long map_mask) { - struct device *dev = map->dev; struct mapinfo { const struct cxl_reg_map *rmap; void __iomem **addr; @@ -235,9 +235,9 @@ int cxl_map_component_regs(const struct cxl_register_map *map, EXPORT_SYMBOL_NS_GPL(cxl_map_component_regs, CXL); int cxl_map_device_regs(const struct cxl_register_map *map, + struct device *dev, struct cxl_device_regs *regs) { - struct device *dev = map->dev; resource_size_t phys_addr = map->resource; struct mapinfo { const struct cxl_reg_map *rmap; diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index 76d92561af29..ec8ba9ebcf64 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -274,9 +274,11 @@ void cxl_probe_component_regs(struct device *dev, void __iomem *base, void cxl_probe_device_regs(struct device *dev, void __iomem *base, struct cxl_device_reg_map *map); int cxl_map_component_regs(const struct cxl_register_map *map, + struct device *dev, struct cxl_component_regs *regs, unsigned long map_mask); int cxl_map_device_regs(const struct cxl_register_map *map, + struct device *dev, struct cxl_device_regs *regs); int cxl_map_pmu_regs(struct pci_dev *pdev, struct cxl_pmu_regs *regs, struct cxl_register_map *map); diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c index 48f88d96029d..88ddcff8a0b2 100644 --- a/drivers/cxl/pci.c +++ b/drivers/cxl/pci.c @@ -827,7 +827,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(&map, &cxlds->regs.device_regs); + rc = cxl_map_device_regs(&map, cxlds->dev, &cxlds->regs.device_regs); if (rc) return rc; @@ -844,7 +844,7 @@ 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(&map, &cxlds->regs.component, + rc = cxl_map_component_regs(&map, cxlds->dev, &cxlds->regs.component, BIT(CXL_CM_CAP_CAP_ID_RAS)); if (rc) dev_dbg(&pdev->dev, "Failed to map RAS capability.\n"); From patchwork Fri Aug 25 23:31:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bowman, Terry" X-Patchwork-Id: 13366413 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 75930C83F05 for ; Fri, 25 Aug 2023 23:34:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230444AbjHYXde (ORCPT ); Fri, 25 Aug 2023 19:33:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230466AbjHYXdM (ORCPT ); Fri, 25 Aug 2023 19:33:12 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2087.outbound.protection.outlook.com [40.107.244.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12E6E2114; Fri, 25 Aug 2023 16:33:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Lb6N6I4mtdY7I+vUVqArybTIa79kNODknG8sbloOe9k6u/E2OBD+BffCYeqxp2XlWLl0BaxQPXmXg23CTRGys9l4rkwbBK8KEKYbGB/3iyUb8P3nWIySlBUCdlF02rTwD3hDojvxevxbUA+0Bf4TQgEisUkaHczRanweQBAc0FyGoWGZKzEvi3IAdn4T+8FNd/M4GpDgMIIo1nElwNGrRIAcosEovZLaafcUrAMcvY2+tJfcL5wVWw9OpjEuGaYZWu3j8gtEWtujxEnIzb58j7PtuE77Qys6V1Yqe+j/95RHfZMbAm8mOjMm3rA9QZWhc8dq9t31ZurCWxmoH0W5vA== 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=BKlpMDJDL9fWN792EBmuV7O/wcdDmYalrl04zaCbHe0=; b=dyLgRvJ5hMQxVbxCwexZDsGLVjVvKj8t/oFXn18TS/cX5jqnxHlFHwDLvHGpKvMLbmFIZ/LDk1AbGsug8q7jvQ6e61cUzIXFe1ojrARVgMYVx3lsY5rh+n9xck+/DnDpvV5pMeagvEozZcZZwRxAJvsMH6JLNYwWK29jDxgjflV/bJ6QAOHxMJxKAKHd2r+a1E+nItI2E++lEZCZssAbXjwtAWbKrXK7Wpy0aO0E8VNID3AukQYzs7bdmcfWF4F+/9CGLGjH3dmAx5BypBx1PupwgnkSLkt0CtOLOfJZBzRxzJIH0Ha8uarA6BjRQch+3DrpkI51JYea4LLNFi/6ZA== 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=BKlpMDJDL9fWN792EBmuV7O/wcdDmYalrl04zaCbHe0=; b=BG2o22xpqmY2/FgH6PhloP8UGhfgEub+n4CXJDmMMNEVXJOQICHpJEl4TPDGURLYLv3GEG0o5hxxraoqResiWs3jddRMgq6yHFA/5zzvvDKRw1AyVwNJ2nhvNoQGH4OGCx9VxE8qc9UhuOvaiNnHR5T3NsTBTiol49fInH5hqTk= Received: from SA1P222CA0165.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:3c3::11) by DM6PR12MB4355.namprd12.prod.outlook.com (2603:10b6:5:2a3::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.29; Fri, 25 Aug 2023 23:33:07 +0000 Received: from SN1PEPF0002636E.namprd02.prod.outlook.com (2603:10b6:806:3c3:cafe::47) by SA1P222CA0165.outlook.office365.com (2603:10b6:806:3c3::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.30 via Frontend Transport; Fri, 25 Aug 2023 23:33: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 SN1PEPF0002636E.mail.protection.outlook.com (10.167.241.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.14 via Frontend Transport; Fri, 25 Aug 2023 23:33: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.27; Fri, 25 Aug 2023 18:33:03 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v9 03/15] cxl/pci: Store the endpoint's Component Register mappings in struct cxl_dev_state Date: Fri, 25 Aug 2023 18:31:59 -0500 Message-ID: <20230825233211.3029825-4-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230825233211.3029825-1-terry.bowman@amd.com> References: <20230825233211.3029825-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: SN1PEPF0002636E:EE_|DM6PR12MB4355:EE_ X-MS-Office365-Filtering-Correlation-Id: 2379d9d8-722f-40be-8b9d-08dba5c3a1db X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3MWnvzybFrYyf9DO3b2XYpY8PJkEWC7cYyZT0pi92JKtV/UfDC3zxBweQ15qC/gBq/TCyzaFj1ipnvGFsgz2orj5cMf1/TBO2B5JmtQcwfQWk+CqSMV7Z1SCJdItiFxuh6b3zJZmNgWsnnRPvEZBfjYIaM6eOg8fg0G2gEQPc97FMpj/uJ0B6K7SjTuDO+HifdIcKqTkVK4Me7KL1t23MxuQ3UfVkCpWZB2XsMR09LUJCbbTJsUkPHXrnOdn7VSzGE369vsJyyc5xDmteCGvDSkY9KDvWJ9BL/NHjJ/Hu+qOG9QuBG/Wn/V3BqLdlbhqRz5wRVuTcMR70xQU763u8W6oDGl7WsRNn4i6Nh85vEvLvH+fYwtoqMVI1Vp/KFDsaxStyOdjCrKvPkflhqCF14WPABcjs06WOo5AFJ9YCB3Wp2npiGt5VuKU/qyhpFRmxDI++Yz7XWPFs6+EOiN8H8JOyLOvyN6R4Vb6ahSCxu0bsVDVZEJgQAv13p5mMk4w0vOMM2i9BLnJB0kwNbqXbGm4sgMC9m0EljsGrgDRLFQNa6DQZt8pqJOiCGS5WwepxLIJalYGvf1qVUgjG1VTR19Tni8Jmdkeus9EZiawwS/VZ7EHT+rS1ZOEF4X6+7l7EwEv0VZMQ7/cyI2uk3z+Srim48lEfLZ95xmiVxSWZNibS859Scby1Vg7ApFGTKkTyp6G6Tu4EDEHQhjQ0DzVx/Ljyg/7r3zwLuXk+rGhrEGIdnH3XtdK5x04IZOY9wUyf/phCejLYgHQxCf4vcwRHQ== 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:ErrorRetry;CAT:NONE;SFS:(13230031)(4636009)(39860400002)(376002)(396003)(346002)(136003)(1800799009)(82310400011)(451199024)(186009)(46966006)(36840700001)(40470700004)(82740400003)(81166007)(356005)(40460700003)(8676002)(4326008)(8936002)(54906003)(41300700001)(316002)(6666004)(36756003)(7696005)(70206006)(70586007)(86362001)(110136005)(40480700001)(47076005)(7416002)(26005)(478600001)(16526019)(336012)(36860700001)(1076003)(44832011)(83380400001)(2906002)(2616005)(426003)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2023 23:33:05.5314 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2379d9d8-722f-40be-8b9d-08dba5c3a1db 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: SN1PEPF0002636E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4355 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. Keep the Component Register base address @component_reg_phys a bit to not break functionality. It will be removed after the transition in a later patch. Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang --- drivers/cxl/core/mbox.c | 2 ++ drivers/cxl/cxlmem.h | 2 ++ drivers/cxl/pci.c | 10 ++++++---- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c index d6d067fbee97..4c4e33de4d74 100644 --- a/drivers/cxl/core/mbox.c +++ b/drivers/cxl/core/mbox.c @@ -1333,6 +1333,8 @@ struct cxl_memdev_state *cxl_memdev_state_create(struct device *dev) mutex_init(&mds->mbox_mutex); mutex_init(&mds->event.log_lock); mds->cxlds.dev = dev; + mds->cxlds.comp_map.dev = dev; + mds->cxlds.comp_map.resource = CXL_RESOURCE_NONE; mds->cxlds.type = CXL_DEVTYPE_CLASSMEM; return mds; diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h index 79e99c873ca2..607ee34b0ce7 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -382,6 +382,7 @@ enum cxl_devtype { * * @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) @@ -396,6 +397,7 @@ enum cxl_devtype { struct cxl_dev_state { struct device *dev; struct cxl_memdev *cxlmd; + struct cxl_register_map comp_map; struct cxl_regs regs; int cxl_dvsec; bool rcd; diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c index 88ddcff8a0b2..f8ad601b314e 100644 --- a/drivers/cxl/pci.c +++ b/drivers/cxl/pci.c @@ -836,15 +836,17 @@ 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_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; + cxlds->component_reg_phys = cxlds->comp_map.resource; - rc = cxl_map_component_regs(&map, cxlds->dev, &cxlds->regs.component, + rc = cxl_map_component_regs(&cxlds->comp_map, cxlds->dev, + &cxlds->regs.component, BIT(CXL_CM_CAP_CAP_ID_RAS)); if (rc) dev_dbg(&pdev->dev, "Failed to map RAS capability.\n"); From patchwork Fri Aug 25 23:32: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: 13366414 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 E1108C83F08 for ; Fri, 25 Aug 2023 23:34:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230494AbjHYXdf (ORCPT ); Fri, 25 Aug 2023 19:33:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230491AbjHYXdU (ORCPT ); Fri, 25 Aug 2023 19:33:20 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2088.outbound.protection.outlook.com [40.107.223.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BD912109; Fri, 25 Aug 2023 16:33:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SEtyWq0o7Z//ExYh7gzA6fD5sM7dkYBX7yixE/+iWaQXeplZ1DimEeBtG22qAUqBPkMAbIhFzqJx3xsjzh3GHYXt0b5gSsiANBMTMVWmGqNAcqABQM0XzpzQhRhaFjVFwgLyvwG3AqXZUZzMg7yiuJng2Y97Rn4wmRNWlo8gXZ4msRz+PhGlnFL8ztX3XjUJ/jRRlW/JxDftrACQsHY/RBMFHEkwwhE+A8C04F6QmCZvD45RaiWVbD2Vg0eqCIQO5gNuavbA3l8rIE9sqs6Vd/5B5yiq76v5KqevV8ayDmGhKOlfamyBYNzXdUAiEG4KafBYboa3j6uRGL69o0kPSQ== 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=ez/GtIEBkZtSlarHIWr7C1gHp8BkLT1hF52qsJuG3DQ=; b=OZt+o/AQVSmoANPRYT6foB02apujBrkox4y6VWUkaZqzKoE2q0rwBjWI3UOjUSJvqZ+8T2oVYQPl1StD2VGyohnelyH5MdsGKBCc01mN3qWpw60+eWLe6VeLPZqC1+UgDUi06kVftulta95md8OC+QbisTwyaYW77Gv128gkeB+1pRAQCtWRwvRYQjVwO7ymnpBYCOwoQTbxsU6bvB9mylJbyA8l8Xslfgc5+kc+bh35dQYIOJcvHIofVVOXr7REtd6f9UaWgOdFGtCG5wgPBWrwKigk2XsmzLhuFh7xBIxpeQ0Qb8wBEzxAV5JUsJlLMDMPfH6can0+qxUGdYoujA== 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=ez/GtIEBkZtSlarHIWr7C1gHp8BkLT1hF52qsJuG3DQ=; b=njQC9IoIbcispZqbKnNANcaZ0wcBCVGNoXaYw1Byl9ODChiUYtviiZrZp6j64oDMYGyPFwIEugvDGBIOghtEBuvHlXXm3OR++W0gbE0RuOI6BebCkoId4g43kzTmAsGQtf8BxaY6k/Z8IDrZ667d4jG/D0z++G5JsJiQsMOZV+0= Received: from SN6PR05CA0014.namprd05.prod.outlook.com (2603:10b6:805:de::27) by BN9PR12MB5049.namprd12.prod.outlook.com (2603:10b6:408:132::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.29; Fri, 25 Aug 2023 23:33:16 +0000 Received: from SN1PEPF0002636C.namprd02.prod.outlook.com (2603:10b6:805:de:cafe::6f) by SN6PR05CA0014.outlook.office365.com (2603:10b6:805:de::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6723.17 via Frontend Transport; Fri, 25 Aug 2023 23:33:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF0002636C.mail.protection.outlook.com (10.167.241.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.15 via Frontend Transport; Fri, 25 Aug 2023 23:33: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.27; Fri, 25 Aug 2023 18:33:14 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v9 04/15] cxl/hdm: Use stored Component Register mappings to map HDM decoder capability Date: Fri, 25 Aug 2023 18:32:00 -0500 Message-ID: <20230825233211.3029825-5-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230825233211.3029825-1-terry.bowman@amd.com> References: <20230825233211.3029825-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: SN1PEPF0002636C:EE_|BN9PR12MB5049:EE_ X-MS-Office365-Filtering-Correlation-Id: 7514e013-78e9-4d28-336d-08dba5c3a7c1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YnXRETPWAC+/O0TPIo4clEXM+dp9CGGEfDGFaZARHgKyIoXoswx4rSawvtgpCLia6cSi+93zzp5RNJki66h3F8WK/kKSvhALBWNDvfiKn5AtiRgV/tKHJtgi+6Fp2/zSMBFHT9mIdPWpwFTGyAQfS5eVe8i9KGPz0RBIuaEAARh/Myn/pv4nBTSjxuZnBXJtXj0P6xA+l/WToEc4B1JSop+VTWwojrtMQgrM+cGVJYwY2Gloj4NDSshcSe+Ae4cly5a8J4YnaeLkP8K9RClXndxPfUi2G8RsSHo7EJpo73lTOCrbSdSVQn/lEb68Jw0zmjkXiN6Fq97LPgeRblwAKxL3w29NEpXjKHAuOxTup7zzpQMNgC5y3R816oM37aPyso/6uKBj6M4y3b00UtpWGOgQH9FtpMRvC0tLUJusECmEmNkngIEwgrt0nuZU9Ioi0jaT2ecEm0T2lQaNOVgLd/bobKq03MvmDW+C5IEdi0jyjr1AdJ0HGbPTUmB+EHxqPuCxZhF7npqmMhLOdYl+ZkpGeeqb6n5+JjDL6PjUF8vM6ANIsARS/fyXihawt+Xf1E0wF7eUofw7bWEzbOXn2zPbQCYvzO0NHuLElo37/Xiby0B+8MfzX99JRkqPOwNsF4qBm+UTsmC3ddgjZr8R0v1DX4UOXJxoPM6Jcxj5ykXli+fCjJo6BIGOEQERY2yOLvXN7hqSHlnXgaEdT933BDFOg6dylOes21Gqvll0Y3T0eW5C550GbZ7s2MtjJo44mM3T+gY+KGPmZ3a9pyovbg== 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:(13230031)(4636009)(39860400002)(376002)(396003)(346002)(136003)(1800799009)(82310400011)(451199024)(186009)(46966006)(36840700001)(40470700004)(82740400003)(81166007)(356005)(40460700003)(8676002)(4326008)(8936002)(54906003)(41300700001)(316002)(6666004)(36756003)(7696005)(70206006)(70586007)(86362001)(110136005)(40480700001)(47076005)(7416002)(26005)(478600001)(16526019)(336012)(36860700001)(1076003)(44832011)(83380400001)(2906002)(2616005)(426003)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2023 23:33:15.4094 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7514e013-78e9-4d28-336d-08dba5c3a7c1 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: SN1PEPF0002636C.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5049 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 | 65 +++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c index 17c8ba8c75e0..892a1fb5e4c6 100644 --- a/drivers/cxl/core/hdm.c +++ b/drivers/cxl/core/hdm.c @@ -81,27 +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, &port->dev, regs, - BIT(CXL_CM_CAP_CAP_ID_HDM)); -} - static bool should_emulate_decoders(struct cxl_endpoint_dvsec_info *info) { struct cxl_hdm *cxlhdm; @@ -146,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 @@ -156,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); @@ -165,19 +160,29 @@ 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->resource == CXL_RESOURCE_NONE) { + 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) + if (!comp_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 ERR_PTR(-ENODEV); + } + + rc = cxl_map_component_regs(comp_map, dev, &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 Fri Aug 25 23:32: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: 13366415 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 19102C83F0A for ; Fri, 25 Aug 2023 23:34:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230501AbjHYXdg (ORCPT ); Fri, 25 Aug 2023 19:33:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230495AbjHYXdc (ORCPT ); Fri, 25 Aug 2023 19:33:32 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2040.outbound.protection.outlook.com [40.107.223.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4298F2114; Fri, 25 Aug 2023 16:33:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lcM4gcyvgPqj4XGm/F8mx/cvbzvBihgH/IpMWVKS+erjY2L5y16JBow0tkbwZq9RyNGAPGZrHyvcnHExcYkuSZ1zvZ5P6tvkIZ0gWIiCvq8diuGMKy0/IhCD9BVWAa/B3FXm8uj8XI1nECfP8OmqVXa+4BiTEmWKhP4bgJkcA5pC5wWIZPiaAG52aNxn7dXPsprENmBn1R4/aHQDJh8lPcNQsmeJzLop9f1cMCMOYE2R8Oz8CLKglUMnWEzkkCFEYk3b/JkOn85U1dVpWO0esMnyYtxYs8dM18UOiJjYrhCVnh8hDzHIwue0L4XnvWc2uE2kpE/QGqg2mYhwfL8A6A== 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=lJgXFYZ9wbemLABODh/lNfldKXu+EY5UKueoeWpDyzg=; b=ePUW9apiAqAcuB4Q9sHWaZ1/Stkx1/iFAm6+SUYXprfrFUtlo+H8ZC34Aev+xrngneJn+vKM6GWw5zOz6u66Wjo+DG00XYaTXoplaSarLjhl4mbn2/gFqk0987SSHvNencS/g8h5qiE4M7zthtpbYg0TpUHXIQPVNIF59/zv6Yywi+cpNO+iH7IuF6JJYJAXPT/QLu1SQYSllwKOHgcaIX0MHwhRsrWKonR4h/O0NxBJkx2ZUiem1FOoektJ+U9AhS2SBib34xxTGLI6hpiNvaMc5vMMQCPJyIH1BQMFz+BKW6D32hlqXlscBfSRmL40THmik073wETCR+CBhe49DA== 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=lJgXFYZ9wbemLABODh/lNfldKXu+EY5UKueoeWpDyzg=; b=adDxPZEkJHTNchVaymENLgmvH2IAz/mi3yPForo9TvCUL7rH2Fj+1LvZOP0vx7BsckmsaCgXgPcu+uJQ5qZbijlmcCsxz6ImxPTvLnLgqTw5hFX2/C52gem1S0ud1M21VDaZg0qbbosAsG1rNo/Q9uECpz3v7bLbbFXRm8YoKik= Received: from SN6PR05CA0032.namprd05.prod.outlook.com (2603:10b6:805:de::45) by IA1PR12MB8496.namprd12.prod.outlook.com (2603:10b6:208:446::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Fri, 25 Aug 2023 23:33:26 +0000 Received: from SN1PEPF0002636C.namprd02.prod.outlook.com (2603:10b6:805:de:cafe::e) by SN6PR05CA0032.outlook.office365.com (2603:10b6:805:de::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6723.20 via Frontend Transport; Fri, 25 Aug 2023 23:33:26 +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 SN1PEPF0002636C.mail.protection.outlook.com (10.167.241.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.15 via Frontend Transport; Fri, 25 Aug 2023 23:33: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.27; Fri, 25 Aug 2023 18:33:25 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v9 05/15] cxl/pci: Remove Component Register base address from struct cxl_dev_state Date: Fri, 25 Aug 2023 18:32:01 -0500 Message-ID: <20230825233211.3029825-6-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230825233211.3029825-1-terry.bowman@amd.com> References: <20230825233211.3029825-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: SN1PEPF0002636C:EE_|IA1PR12MB8496:EE_ X-MS-Office365-Filtering-Correlation-Id: 384a713e-7bd2-44dc-49d8-08dba5c3ae4d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: huFQUza0CO/1Ljub0TQ/dRZY7n59lhK7BlxdQXBJ47YKv5jPi+nSy051Op9QeqfWVwXAuoStFycNxc+Gfp8vpD/QUSOqMELQ5H3su4PwJ4OLmoE9gX+0oQVM0wMc43Rnz8s4/CM+lAaNsD6eCHX6tNQBHvD6SMczUmNvhgfBjQuQlyyGORUV0HWWjYR185Aa1uw6nIKQo+uWzZ3mvs76cCcoLRPlLKQOmG0t/umw+rowBex2goVF5dw7nJQ37wtgkH4go+iFuC5JvSkYHOWCYIsBHXUBqQvsVdZ4SKJB6Wo4VG1ilEiu93lYwMGl3veMUgSYQZSSd3jahQsVkSDD1R3t79X7aWIckdGJhFU57nOmc6BnnSim6Lwxns0Neh8/6kJjCZ13YqCP4gnweOUQoe2TesisfJKYaup//iNpMqMbcHdb0OjM6IidoLNi6a1g8HSR5V917nLEnPrhQDiTnQzdaeU6Cl95Tl2MF31yCSTZrnS27l/zpNXXHREtICdUlxxcvYS9Ff1lRfKetXQew+cS0Wc99Rl17rjLtBA8soRrK/xs6bTKz2nhCWNk360XG+lpOfwXXsUva2BmiollwVqIy7aJuHamDWgeSnzMH5DVsX2YNLuWog8mus9iuzV34e8trP4N7CKi+0UYaRLFSDp/Tclsg8LIBygyytIDLmEhBjV8YiwK1w8WFwEHEm9TB5mXEcPZ0WDXxuLj94iZQ6qDfN10HpNWRfWQhbfALt1mkaHu/phgmOYhZImW1iwB8prrQTBKBPUwtH2rFduOVg== 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:(13230031)(4636009)(39860400002)(376002)(136003)(396003)(346002)(82310400011)(186009)(451199024)(1800799009)(40470700004)(36840700001)(46966006)(54906003)(70206006)(70586007)(316002)(478600001)(110136005)(40480700001)(16526019)(26005)(6666004)(82740400003)(81166007)(41300700001)(86362001)(2906002)(356005)(7696005)(4326008)(8676002)(8936002)(83380400001)(2616005)(40460700003)(5660300002)(47076005)(7416002)(44832011)(426003)(1076003)(336012)(36756003)(36860700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2023 23:33:26.3938 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 384a713e-7bd2-44dc-49d8-08dba5c3ae4d 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: SN1PEPF0002636C.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8496 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/cxlmem.h | 2 -- drivers/cxl/mem.c | 4 ++-- drivers/cxl/pci.c | 3 --- tools/testing/cxl/test/mem.c | 1 - 4 files changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h index 607ee34b0ce7..fdfa6e5dd739 100644 --- a/drivers/cxl/cxlmem.h +++ b/drivers/cxl/cxlmem.h @@ -390,7 +390,6 @@ enum cxl_devtype { * @dpa_res: Overall DPA resource tree for the device * @pmem_res: Active Persistent memory capacity configuration * @ram_res: Active Volatile memory capacity configuration - * @component_reg_phys: register base of component registers * @serial: PCIe Device Serial Number * @type: Generic Memory Class device or Vendor Specific Memory device */ @@ -405,7 +404,6 @@ struct cxl_dev_state { struct resource dpa_res; struct resource pmem_res; struct resource ram_res; - resource_size_t component_reg_phys; u64 serial; enum cxl_devtype type; }; diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c index 317c7548e4e9..3af3218ebe0e 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 f8ad601b314e..b71f1c7d16ce 100644 --- a/drivers/cxl/pci.c +++ b/drivers/cxl/pci.c @@ -835,7 +835,6 @@ 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, &cxlds->comp_map); if (rc) @@ -843,8 +842,6 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) else if (!cxlds->comp_map.component_map.ras.valid) dev_dbg(&pdev->dev, "RAS registers not found\n"); - cxlds->component_reg_phys = cxlds->comp_map.resource; - rc = cxl_map_component_regs(&cxlds->comp_map, cxlds->dev, &cxlds->regs.component, BIT(CXL_CM_CAP_CAP_ID_RAS)); diff --git a/tools/testing/cxl/test/mem.c b/tools/testing/cxl/test/mem.c index 464fc39ed277..aa44d111fd28 100644 --- a/tools/testing/cxl/test/mem.c +++ b/tools/testing/cxl/test/mem.c @@ -1423,7 +1423,6 @@ static int cxl_mock_mem_probe(struct platform_device *pdev) cxlds->serial = pdev->id; if (is_rcd(pdev)) { cxlds->rcd = true; - cxlds->component_reg_phys = CXL_RESOURCE_NONE; } rc = cxl_enumerate_cmds(mds); From patchwork Fri Aug 25 23:32: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: 13366417 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 879E6C83F05 for ; Fri, 25 Aug 2023 23:34:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231133AbjHYXeG (ORCPT ); Fri, 25 Aug 2023 19:34:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231217AbjHYXdm (ORCPT ); Fri, 25 Aug 2023 19:33:42 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2073.outbound.protection.outlook.com [40.107.244.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0526A2129; Fri, 25 Aug 2023 16:33:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FLNOYmXf1mCAOvE6LfTltTVfm6uaYaDw2G8LmJJFEGx10sFMHGY0PIzPo6Rxmqvgyj3rap2EUrFBNggvNfDH1TwFYvX3Dq0jzUho8uoCx99pvsumjsEtvqRr9HbgZyyi+uB/mr/la8xENluC/xCMEeLvqGOVsrYs2C+g1eEazpjjGG6FxBfClsHjhncnBl7SCSzFcHQ6bgSVRZjhdp64f/iAXW6ruXjl39BEMU3bLBPM1j0A+pfhw5LCWO+mSjYBZ8DiQmDbfr3fcdzlHBBT/WcYb6+LBiUU1W9Hhuu8bnYXuzcPkNbNv2KfTrHm+2C1xMZfjk2EAI17v6Fu4kZcnQ== 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=tQrlvBOOh12RJZjvDBQHPgre4Unn8cO3Ogor/WzFBR4=; b=U1NrQOk1bu47qqAsT/LsQAISB4ohtTUHbnfC0FFZf7SdGxixJY58bzmytR827zXuhqBOAGhWrFuPmr07bUwtjRN7m2IwOcQtWTLoQfHBsKcBDqUI/0G8SR7+/TJcybz2Q7K4KsAd4m0jShFCF/dFmqyF5HvpWeTfIykDFLaNdGtrl2L9Bf/jlh0RPS+t8X5jD6jBcua7c850pPybmixsrecGgi/+aKQ0aYWruShRi4rLeHYlol1TKFCKPsqATJenoAfEPhb8zP+7p0Hy+0tyGbgw1A1zFHOyRgPCJU1aijZO+Jple348o/vdt8/PVutGC9SUR5ttdWrcAsg7IT9gyA== 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=tQrlvBOOh12RJZjvDBQHPgre4Unn8cO3Ogor/WzFBR4=; b=Uv8J9drPJI2J9TzCyHEmhIh+MFUahj/C72rNpJczSGgTbMtTO3e8zRwBfAw+Zx/q0zo0vjx3qIDJrNHQirsxg8XtGxDflWzRUThR9qWV0658Ptz9WKTxjfgXSwWPHSRyfbidzYMbmImo7SwxAucWcTCz1bVO+YTFWtaJ2YLEtuE= Received: from SA0PR11CA0189.namprd11.prod.outlook.com (2603:10b6:806:1bc::14) by DM4PR12MB5071.namprd12.prod.outlook.com (2603:10b6:5:38a::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Fri, 25 Aug 2023 23:33:37 +0000 Received: from SN1PEPF00026369.namprd02.prod.outlook.com (2603:10b6:806:1bc:cafe::56) by SA0PR11CA0189.outlook.office365.com (2603:10b6:806:1bc::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24 via Frontend Transport; Fri, 25 Aug 2023 23:33:37 +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 SN1PEPF00026369.mail.protection.outlook.com (10.167.241.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.15 via Frontend Transport; Fri, 25 Aug 2023 23:33:37 +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.27; Fri, 25 Aug 2023 18:33:36 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v9 06/15] cxl/port: Remove Component Register base address from struct cxl_port Date: Fri, 25 Aug 2023 18:32:02 -0500 Message-ID: <20230825233211.3029825-7-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230825233211.3029825-1-terry.bowman@amd.com> References: <20230825233211.3029825-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: SN1PEPF00026369:EE_|DM4PR12MB5071:EE_ X-MS-Office365-Filtering-Correlation-Id: 7005fac2-cd0c-4996-cb6b-08dba5c3b4fa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4Bq2fFKdJAMk96Y025YoP0WBfRhy4f6OydGIE0xJZ7vo/LwdQGFw4SEYdt3wqcE0W7ICvL1ztYXsUGC38w9Xp7gL8FHIJDpbFnlbcK/68aNJnkj43AYISmpFqwdxOIobKKMelwBSMTuPNlGGvnnUrYritdnGr+powMLXgU+JT2zsETcArytctlb4HAAXIFPBgfwWbF6wX61iZyv9sz2y86V62dCOp+YJ7bSSgcYm60aKMuxwCeTJ55Wpl6PSDvlddT8t8gtFh2+qHKGAdf+zI5mIA7SMnfuVU0x9IRfyxz3vSr7iPlTqXV21RaL7Qm5tA51VLL6Ls2mQnSTS8QEeZVvEuzxdNnRQpLRq5H5+lkUQMhLo73+eaquoCwf5QQC82rmEmZpnz4c+q1yq639fUa0cnpzHeBS6oqa1/rxP9ZktuNSjPjG09JslucjdaMSsYQTtIfa9UDAdVm5YhNLEet5p90XJmxneqkJuaNjILg/ebD3od4m/biwPjcQZrZ/9VYrGFslvbSNXBYgx6XIiFYRSNqy/E8YfKjMDhVMppSSqs6RmvqOerrSrZyxVn9sbfMWz4pWjQsGr46OjVNC15ZbkqtJk7jVfrpo56M8OPsgeCEqwS28KdQGyfchqTi+mr8gtT8OT7b5NpvRh8ScR0qj87V3LFDMhGHPOzsCfyBod4a1WyfU3JUi4JuSIY11Dpx8228ply09U/ixbNENUJlW0ky9AoISXwe3KVxlzG7jiIO+445ncHxhhUvkkoF8qwmoIH8L/e3iIIi8OwF+53Q== 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:(13230031)(4636009)(39860400002)(376002)(396003)(346002)(136003)(1800799009)(82310400011)(186009)(451199024)(36840700001)(46966006)(40470700004)(40460700003)(1076003)(2616005)(5660300002)(8676002)(4326008)(8936002)(47076005)(426003)(36756003)(336012)(83380400001)(7416002)(44832011)(36860700001)(26005)(40480700001)(16526019)(82740400003)(6666004)(356005)(81166007)(70206006)(70586007)(54906003)(7696005)(316002)(110136005)(478600001)(41300700001)(2906002)(86362001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2023 23:33:37.5972 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7005fac2-cd0c-4996-cb6b-08dba5c3b4fa 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: SN1PEPF00026369.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5071 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 2d22e7a5629b..99cf5cfbbcb2 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -618,7 +618,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; @@ -669,7 +668,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; @@ -730,7 +728,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 ec8ba9ebcf64..b4383697180f 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -578,7 +578,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 @@ -598,7 +597,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 Fri Aug 25 23:32: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: 13366416 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 9A42AC83F08 for ; Fri, 25 Aug 2023 23:34:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231224AbjHYXeJ (ORCPT ); Fri, 25 Aug 2023 19:34:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231359AbjHYXeB (ORCPT ); Fri, 25 Aug 2023 19:34:01 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2069.outbound.protection.outlook.com [40.107.220.69]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93E8D26BB; Fri, 25 Aug 2023 16:33:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y58ZREMtV5Uu9NPiuUlykIO8lxKKGTPVeJEwu0TRm2Fc05Z6yIxs4U9RVR0S40+wLtuZNlwe4OGjhcPofSHThxHiVBFkymEWnJQ8lMvCYbjsWdvoZ/UqvuOjlz79D272OKO0skCaaXXj1ziZ2YocsQKLIR+wrjo6pdO4vwj4L+/GUT8ynZx8COykJPFgMwb4DlSxZItWd0GJMVJ9qQKAGSg1chJbK/tw1rvMdmMLHPb6JJXuyz/GaV3D2d65RQWh68NCl9mbhO/nk7E3DhZEvbd9knM/BmPAiq602XpiVEp53vDcJpeVekMb1q+A2/odNb2bKCuwpvXA1T97FO1bxA== 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=22swpCBrB4JtUoKYDJMG5Bon9IKAGBSs78uzHU4Uuo8=; b=AFBmtW3hmQsEaLPGymCwt+b2E9hF4yh2CJRlU9g+iixMkM1xY7EoML5I8MqVQ+W0xktwf40q75bz8xWVJGzo/aeNik+38EQERKI8ofo0JernbjbAIT8A2T5jpIW35gdXmnsVbaw2MtQFrFX6I7ablHjBVJTpfZnAf0H98UgODxbLUCsMnOsHFCZs2Mn8J9qUxc1j9IymzRCx2SyaGEQfdKeD0tpU9olywdZRbZvRSDnw6YCp4xVlzh9Pe3WyoSq+hVnRu/cArx5v2qbsYWJelnCYqejZKrYLfd6M/RlurBi8wv54t9l2dP2Nv1uB0aKE5bohXNrL+/bbkLQnS5a/Gw== 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=22swpCBrB4JtUoKYDJMG5Bon9IKAGBSs78uzHU4Uuo8=; b=3zPfD8HxhgxiymCnvk90oFWcR/Q940iXCWArF48ykip4g9rThenu8B18M3gQ9FeQ8iVRGp4CpFhxNX1UuTPVlRZphJ9GkGkuTkThQ6vch2KlV8HgGJWRkn+CMI0WNSCgLYtBP7rsLmo0dav9/axEZbc2wf9WxbN+MTVaLc/RUw0= Received: from SA1PR03CA0018.namprd03.prod.outlook.com (2603:10b6:806:2d3::29) by BN9PR12MB5066.namprd12.prod.outlook.com (2603:10b6:408:133::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Fri, 25 Aug 2023 23:33:48 +0000 Received: from SN1PEPF00026367.namprd02.prod.outlook.com (2603:10b6:806:2d3:cafe::62) by SA1PR03CA0018.outlook.office365.com (2603:10b6:806:2d3::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.30 via Frontend Transport; Fri, 25 Aug 2023 23:33:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF00026367.mail.protection.outlook.com (10.167.241.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.14 via Frontend Transport; Fri, 25 Aug 2023 23:33:48 +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.27; Fri, 25 Aug 2023 18:33:47 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v9 07/15] cxl/pci: Add RCH downstream port AER register discovery Date: Fri, 25 Aug 2023 18:32:03 -0500 Message-ID: <20230825233211.3029825-8-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230825233211.3029825-1-terry.bowman@amd.com> References: <20230825233211.3029825-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: SN1PEPF00026367:EE_|BN9PR12MB5066:EE_ X-MS-Office365-Filtering-Correlation-Id: a31edfc4-d1c5-4a14-f7f7-08dba5c3bb5a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l1UOIukJWzeeYswaL5Dng2vsfCc7Z2D9m2muIwXTFs1rc/02xvZICxTmtzXP9gaK5D3+gZ2UJAIqthZCXpTilqhrRAx2DRFZIFHhdpcz7swxRH17ox+A+/juhYNliz/g3MMAfTQOsPjuYp6ZPXH0i6vEW4uK9yqZY/HJ0fAFp6Ggt1Y6XAXMp/K0qqxooNT9DQPvov3wgBzs8xbnq8E9m78a3CNLk2dV7cN4Ds7W4wEG8oz4kr3GlGsZiVBJE0lwa+Rjl51gaGIr6eR5LKDHj6IYuYSfl68+QY7C7dnV6dcOH/8aphec60erBkqBTiYMpE7t1vu9oqS51aVE8MRKH+9vwJGXVtX/1vg9xM9OzE9AysaYxXqageQqu4OgdSqJAVWspjZe0QTKLNLzIawnUeJdeglWbwx/YK+dsJJfMHpAYf3WWnpA7nlWQ6IoLCWpCNaVHx/zAHVmkm4oyUIToS1loQ1fz31a/8JmShDSwHT3Jc+Kr3D55DQ9Y3ElTBujcT9eMzZMF4FLFMy4DOS8ney/tL0PRBEveVMAVMJVpPdMcZrTLTAg95wl9oGA5GSBAKi0syIY7nm9l8/bcawO4NALSNxFTI7yJacMFE/XRBOPk3Pb0JwpTwhtBWk8/l2HBrZ3nThDrRh+6slKyVIbCYlzP8okAd9zrRlpN8w+wNAle1uWBTgK2sAxIkkSZpuhbqyXMoQA4PULX5TZHCQNcgOfuwY1Epp2JM8IHpylvuj/nal55VEgNQGxb2YW6dTsb0gRNXdSN9qtjDchrYN3Mw== 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:(13230031)(4636009)(39860400002)(376002)(136003)(346002)(396003)(1800799009)(451199024)(82310400011)(186009)(36840700001)(46966006)(40470700004)(81166007)(356005)(82740400003)(40460700003)(8676002)(4326008)(8936002)(7696005)(54906003)(41300700001)(6666004)(316002)(36756003)(70206006)(70586007)(86362001)(110136005)(16526019)(40480700001)(47076005)(26005)(478600001)(1076003)(36860700001)(44832011)(336012)(7416002)(83380400001)(2906002)(2616005)(426003)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2023 23:33:48.2939 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a31edfc4-d1c5-4a14-f7f7-08dba5c3bb5a 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: SN1PEPF00026367.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5066 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 | 6 ++++++ drivers/cxl/core/regs.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/drivers/cxl/core/core.h b/drivers/cxl/core/core.h index 45e7e044cf4a..f470ef5c0a6a 100644 --- a/drivers/cxl/core/core.h +++ b/drivers/cxl/core/core.h @@ -73,6 +73,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 99cf5cfbbcb2..8dd9a44e8a7d 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -978,6 +978,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); @@ -986,6 +988,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 dfc3e272e7d8..c8562cdbd17b 100644 --- a/drivers/cxl/core/regs.c +++ b/drivers/cxl/core/regs.c @@ -470,6 +470,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 Fri Aug 25 23:32: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: 13366419 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 C1905C83F04 for ; Fri, 25 Aug 2023 23:35:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231220AbjHYXei (ORCPT ); Fri, 25 Aug 2023 19:34:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231303AbjHYXeX (ORCPT ); Fri, 25 Aug 2023 19:34:23 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2044.outbound.protection.outlook.com [40.107.244.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B82126BD; Fri, 25 Aug 2023 16:34:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TAkBB36V6aWLSe01PVFBKbxJFjX+N+vuO3Nz4kOzWtUX+Vk8gy1mW/S4C5L3AyPffqGznDqZaLb6WwVtLkIE4tx0wIt+V+lWjQLP+suaYPjHcpCLHpm1w7pUaXeq6jX7DwzeIlw4LCB6w7ICckaZjMK7dEQv62JUslotMS/zGKmcLx2ka27BBvPRe5YFYjYhjax50IXe6Qq19tH3fZ/pGK5f56ZsE2yRZ8lO8Pp35yTThCfocUMNTdyVejY6oDw5EwmlzYy8JYsBqM4ph1fCHaveeXWUhlvKkmHm1jsxErnEk8R6LSbIPNOi73lMwkUUmXcgUCXXG7olWrN7FFkWPA== 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=btQEIKahGA+dVKNXsDbpcedjVIVjE9vkFI70RgFbKSs=; b=jP37kRM6efNRDUp+GPzzo8uQqVOklsBaKK4hIMEC4bWMaWm48BsE6eTxhEmYDachJZMMqZKm8MoaoliyK3AeFNX06GxezKfmhZHKimh55PVpbUHjJy9BSuxsgy2xGtWqxPuGo4o4JHr4fBBxIBj340OFl3EvK0GDtwS5t0iOgjdLeoiakI3bu79UWzdlav3hc7ajY/DV6nHuoubc3UCVqLcZvdHGgGWN42bn9CMYuRxUP5N9ft8DQ/FCVm9qXrVB0DxQw+CDICr6QcWks9nsLfqBT7Hd6soj00i+5BtnqeSgJ8/bs44MSTqyDfYUbT8J4xO3Ups2n+i7wUYcNcP+5g== 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=btQEIKahGA+dVKNXsDbpcedjVIVjE9vkFI70RgFbKSs=; b=tdyTcO+SdL7Zjiz9uJdofarHWITlZ+hg0Q+BYTuBQTeFTcJ01VzbhLozgKgoLEeJZKHk5QPCNo5uL2HqhJ48h8GyeCC5HuF/3IW0AoC/YZp4EcHTKTH2YjRpAVOXBPq5SAL6wNAiJFuOrYY4OXyDQ1qzP1tfvqTu60JeYe6udDE= Received: from SA1P222CA0034.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:2d0::7) by CH2PR12MB4857.namprd12.prod.outlook.com (2603:10b6:610:64::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.34; Fri, 25 Aug 2023 23:33:59 +0000 Received: from SN1PEPF00026368.namprd02.prod.outlook.com (2603:10b6:806:2d0:cafe::73) by SA1P222CA0034.outlook.office365.com (2603:10b6:806:2d0::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.30 via Frontend Transport; Fri, 25 Aug 2023 23:33:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF00026368.mail.protection.outlook.com (10.167.241.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.14 via Frontend Transport; Fri, 25 Aug 2023 23:33: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.27; Fri, 25 Aug 2023 18:33:58 -0500 From: Terry Bowman To: , , , , , , , CC: , , , , Mahesh J Salgaonkar , Oliver O'Halloran , Subject: [PATCH v9 08/15] PCI/AER: Refactor cper_print_aer() for use by CXL driver module Date: Fri, 25 Aug 2023 18:32:04 -0500 Message-ID: <20230825233211.3029825-9-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230825233211.3029825-1-terry.bowman@amd.com> References: <20230825233211.3029825-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: SN1PEPF00026368:EE_|CH2PR12MB4857:EE_ X-MS-Office365-Filtering-Correlation-Id: dc0166ce-a6d0-49a0-157a-08dba5c3c1f4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q0jpy0ZaHOBQvh1lTvQDQds9Z0IOUJzdBddtM2VU6BILPOj4kPgKc7RfXpkpqNWhrSIThBAhO/HGVv0e+DJSq6hN8vVrVPJ0IxwvKGgOQViFhduntZoVbFquFLrxD4qJjJXKNtOxqgcLBXRlQwwQiUXpJQdsoursUj6oLKG5ReTJ68Iy7JwRgQoFtJi9DWwpSPznjtrf+kw9fHUs+pt2jmJWYLvZacrABTTER+2pJYjwRKbd9k2t2OdZFZrJl/jdBXWvLKKt9XuzBkFg4f0qgsJIPYwEKZsfnBOmVSyp4vhQiDRit4jiWCm+SGqlakVJh6QXyrqcSG9s8Y1giRdvC8fs7LYyk3hz2Xi4MYtGrEEytESZfI9BYc7lGwXUatJvg1S1vIjxPwXPLjJ+RgIti6YDaiX3nYYuLCsOlwtEQvb49FIgnJzttrDUvuICSbY2Zym0OY3xG0SBgHAsDCQ6CtnJ9N5Ni3lBasZa4McrDq0rojlL6V8XjlK8QvzYAiW8BsJ+mGYUUVEMlNjBCxQGQQAeDsvW5FQeWZv0TqBy8Zb+EHOzaXyY1iKLw51RUowIz2KUF5wSz01dlDbtZvlPPOBZwlIZraDSxzuQjXeuwjjjlB7oc50kxyqBb9Tlb3bME5YWLHmBoiv9iZjyIY0zEJFQmBQUsnoZj8XjFdNTElAIECPjGzyaF/rSmDPjIA2aam76vrmjiA1y/SO7ECcFEUJ1UobznUrLJQq35Uzqy2vlM4k2mjH8ea0Pd9faI7Ap+LVgTOz8ozRPR6EreCYsRQ== 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:(13230031)(4636009)(346002)(136003)(396003)(39860400002)(376002)(1800799009)(451199024)(186009)(82310400011)(46966006)(36840700001)(40470700004)(7696005)(6666004)(40460700003)(36756003)(86362001)(356005)(81166007)(82740400003)(40480700001)(36860700001)(47076005)(2616005)(83380400001)(1076003)(2906002)(336012)(426003)(16526019)(26005)(478600001)(110136005)(70586007)(70206006)(8936002)(8676002)(4326008)(44832011)(5660300002)(41300700001)(7416002)(54906003)(316002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2023 23:33:59.3636 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dc0166ce-a6d0-49a0-157a-08dba5c3c1f4 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: SN1PEPF00026368.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4857 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 Reviewed-by: Dave Jiang --- 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 8dd9a44e8a7d..f3bb7ea37b44 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -2062,3 +2062,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 Fri Aug 25 23:32: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: 13366418 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 7305FC83F05 for ; Fri, 25 Aug 2023 23:35:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231245AbjHYXej (ORCPT ); Fri, 25 Aug 2023 19:34:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231420AbjHYXed (ORCPT ); Fri, 25 Aug 2023 19:34:33 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2075.outbound.protection.outlook.com [40.107.237.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEF4A2D50; Fri, 25 Aug 2023 16:34:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WVPamRPfTGNNw9MDxHP/VaRXn8gAZ+k2UrHvEr/lG9qlYCuQWS6qXvuPyeW3baLp3Iv72e7krZgTKL9LExpCJgILK3ibkIvsjFvtcCqZYVNVu/2vk3a2Uyr+4ufT6+wLDkAJHko+1j1knGLPbsHiRDMZf1lK5IaOd11qx5mpfp+VmTtX2TItXqDstCoF9XnRSJod1/ImRZhltY9HfeHqVVebbdVCzOZq4WbBftBXjmsimaSXBrq+XdM+hqzF2mWcuABtwyA+quxaXdKt6nsO6rHxwLVu4z3nbt65+DMrtLgIEgEiX21n1Vab+V+kBqCAFis5SYE4sxwjIonkuhDn1A== 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=VdkeZNvPc3j4XjGaPvDKt4cGD4c97qZFxGq5V/vHyeo=; b=LjK6DqVWm36dljL7A+Irq5YV0XNEFMDCMoPMMFBwvTLNZdOW15jqY1HqTJW97Dda8kAGBzWucJCnCqFZCkDQ78ozMPspyKg5N2dG41ZfDbzyggpSF44jQkKLiFcGT9hwW/FSn2P745UYLBbihoNV/Zi5KHB1mjOobZqcA2RVA/juKb6HQB9RJ+XU2jczOmhh+T+N9MT2ZbRKZbnEZkNjljj/aQ/MNONUGoDYUoBr2TapXxiyHMq4R7VclOxkh/hPBN6OM443N9BigMncr1cRdx91OQC2uA3smdoyKtLlhBq7yzw/TZ/MBI+NKBsf+d6SePx3+s4bN08rGjNtmPicvg== 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=VdkeZNvPc3j4XjGaPvDKt4cGD4c97qZFxGq5V/vHyeo=; b=hpyKgoQWhxf2dw1+CZnH1lZn8+V0QkJn+kyp4/kD9Ko4TtPjYRPK66kZkgYlMgapWTjByOb6f4JctwJhcsV/rdYOStAClxNSQQ+K5rpWCOSqNdKmuczFQfmM9dZfzaixkQVCMFh2BZ3daGEbNwAoZq8fb+0244Zr1qOq9/rgXN4= Received: from SN6PR05CA0017.namprd05.prod.outlook.com (2603:10b6:805:de::30) by CY8PR12MB7171.namprd12.prod.outlook.com (2603:10b6:930:5c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.29; Fri, 25 Aug 2023 23:34:10 +0000 Received: from SN1PEPF0002636C.namprd02.prod.outlook.com (2603:10b6:805:de:cafe::1) by SN6PR05CA0017.outlook.office365.com (2603:10b6:805:de::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6723.20 via Frontend Transport; Fri, 25 Aug 2023 23:34:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF0002636C.mail.protection.outlook.com (10.167.241.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.15 via Frontend Transport; Fri, 25 Aug 2023 23:34:10 +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.27; Fri, 25 Aug 2023 18:34:09 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v9 09/15] cxl/pci: Update CXL error logging to use RAS register address Date: Fri, 25 Aug 2023 18:32:05 -0500 Message-ID: <20230825233211.3029825-10-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230825233211.3029825-1-terry.bowman@amd.com> References: <20230825233211.3029825-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: SN1PEPF0002636C:EE_|CY8PR12MB7171:EE_ X-MS-Office365-Filtering-Correlation-Id: 05f2dd10-1273-47a1-a3dc-08dba5c3c87d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B8/nBKjLMoDOiATisppwspMHA5WLIJik+V/PJF0NAaZQgoX2PPL+K5bCflT94saflLeo2rLlNRvZ+KWAluRR//8uJQqC1C9eNDtEJOdT0Y0f60K8yz40+iDvWeraS1Wp+bEkssSAFl1a8aBWKBhNk+niScJ3M0/ueWuZbbRc/UF7kTd1Loudaqxd8C4wnKSD5WPSkIb6wQ8O5ooBh1Tsjx7Sf97yY2QtaPtd2Wrr7gKWxdPK+Yrj4ZMsFIMoaQ6kp0iEqomKxl4WkNnrq88Hezb7l57dqKyaq90cciNzO6PGqnHW2+/dQyNzRTkaRvSvLL+Ja8uyhr7ymMAaWQOcJRTyTEsD5vx0cfroZ6eUXHYxEIZMbCa0vNrmpBMc3CmqDItopFBSFFgz9V4RfRD8s1xOv1V/SD6Es1i1B/YBe0ONgRz1JoJVU+pTHVko+RU2PM+6Nz4HLFcnlMpyfg/wZ1XOGBU1s8bJycVkAmAuiLfRx2+N313XiDIQpa0mCNjLHSeCQMwRq41Ps7cZzwuaQ15NCCX3eJcfx46K/lDpkokWTDrJfRbgn4Oh41vpglxSDRqDGOJ6vve94+S0rpoRsmG16r0EwDdM0i3hiBOiIfMKxm3HpkJT0P8oP+6iv3IRBU5IeDuE8NiiAhv3gM6fOOjzL53UUVxdUTQfl4v/bqsQ/sPY6uZtAoGj51jTdthxJvfZKaAVBkF7qO/+1omS/lF/RGZ265tz0Tt82RoxqPxSCy6P+AQ2HYzGX9Zn1PSY9w6Ov/Mp9J5EG9is31o5zA== 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:(13230031)(4636009)(39860400002)(376002)(396003)(346002)(136003)(1800799009)(82310400011)(451199024)(186009)(46966006)(36840700001)(40470700004)(82740400003)(81166007)(356005)(40460700003)(8676002)(4326008)(8936002)(54906003)(41300700001)(316002)(6666004)(36756003)(7696005)(70206006)(70586007)(86362001)(110136005)(40480700001)(47076005)(7416002)(26005)(478600001)(16526019)(336012)(36860700001)(1076003)(44832011)(83380400001)(15650500001)(2906002)(2616005)(426003)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2023 23:34:10.3315 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 05f2dd10-1273-47a1-a3dc-08dba5c3c87d 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: SN1PEPF0002636C.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7171 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 uncorrectable 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 Reviewed-by: Dave Jiang --- 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 c7a7887ebdcf..edfee8035820 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -646,32 +646,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++) { @@ -685,17 +689,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; @@ -703,7 +708,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))); @@ -711,13 +716,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) { @@ -732,7 +750,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 Fri Aug 25 23:32: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: 13366420 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 52B53C83F04 for ; Fri, 25 Aug 2023 23:35:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231464AbjHYXfK (ORCPT ); Fri, 25 Aug 2023 19:35:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231483AbjHYXfA (ORCPT ); Fri, 25 Aug 2023 19:35:00 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16F792D46; Fri, 25 Aug 2023 16:34:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b8aTalKUPUPu0PIbThhovb8iKjRn3Jt2IKJXKqDBqkJIPeDrdDPgaPs74Ly8GeOC2hl9g4OQQgnr3djhWbKgbOdGUYXmo68UQYVKraW0f2a8epufjySpPNhzqdMeBNQPv9tOgjOA005k+tsRSWTgET7DduTq6LIawZ3kebt+2/x4b/JVfEUEUG8OzmRwGFbDfN1JdAf4NeDdZTWwutiVylnlPCvwiOK8+0fVzPHqmbWbGWGzUd6AeyqjSR9fXy9Ix5mnoGXPk+LEPPNv+hup75y2Pj247LyFi34Al2fBZE+998q60bhAY+6xrfPuT/kHwY2nOzVYFwJ8/hxpBXuKhQ== 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=D3IZX7Q9P/TJEBatpsJlr78YlkkbpyRmEaO1Jf98tNs=; b=fa81ADP5BPp8/Y4TBN+pW0qhikyk0oylYrdwUuJx6UPG5HSk8Y57FvNhpDwGQRUtqz4XKtd6Q93CAW2ifOxLZQUZ83jLWz0eRpOOBlARA6sSa9EirVHmroL857QrSwqL/TzvXOid/P/hV3HQrFwwr1me/813VwxGLr/3qU8ziIRy/4tSZ9dpxzWkfPAB6qmXQvFVU/mWcsjZeLSPP/ONWPCDW+/5g6x6ZFLeY96iWr04HHywSVK8S84D1iuDoZRynrh65AjLVXp+6BcRZu18CTRhexBowr5BbaF9n4Okyhler8qOqlvrrnUl+/M0hRHqIaF8okwY8TcljFFnO4hwKg== 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=D3IZX7Q9P/TJEBatpsJlr78YlkkbpyRmEaO1Jf98tNs=; b=B1vraNaWMGDY5QXLRsOKHvJn4X8FZ3aq7DdikZtFPlKf2zzZEIBtWtBMr51xkS2acYZNRxDMp71TXeeGAx1ZPrShjfi8F6npcLi579EXcVNje/UC6rIqmiz6y7AL9dhGrjRGkUiuKfWyEcBPRBtpMGdLzUmjVwU6pqKUegQAO7Y= Received: from SA9PR10CA0003.namprd10.prod.outlook.com (2603:10b6:806:a7::8) by SA1PR12MB9004.namprd12.prod.outlook.com (2603:10b6:806:388::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Fri, 25 Aug 2023 23:34:24 +0000 Received: from SN1PEPF0002636A.namprd02.prod.outlook.com (2603:10b6:806:a7:cafe::a9) by SA9PR10CA0003.outlook.office365.com (2603:10b6:806:a7::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.30 via Frontend Transport; Fri, 25 Aug 2023 23:34: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 SN1PEPF0002636A.mail.protection.outlook.com (10.167.241.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.14 via Frontend Transport; Fri, 25 Aug 2023 23:34:22 +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.27; Fri, 25 Aug 2023 18:34:22 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v9 10/15] cxl/pci: Map RCH downstream AER registers for logging protocol errors Date: Fri, 25 Aug 2023 18:32:06 -0500 Message-ID: <20230825233211.3029825-11-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230825233211.3029825-1-terry.bowman@amd.com> References: <20230825233211.3029825-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: SN1PEPF0002636A:EE_|SA1PR12MB9004:EE_ X-MS-Office365-Filtering-Correlation-Id: 70397a8b-ed66-45c9-026f-08dba5c3cff4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hgpTv/AFKv9kleE2Vby7WNoSZd0h6v9DrCTr1JzPMvmDV80R5CGOzim9tfMxyfcra8Ug0uFH+4WwauAA5Li9WnJs1zS/B7VHaubaz38SHAQxIthsVYOL6j5c+cnFX3lchZFQRkC9CN8UubMtDnrMZRW3PdQNIUxVkmSVu6FDyBvOJNsFgVUn+Rl3ltCR+ybVsTDwdUMP2NYlUXEuAmyCJx4PQ0gWTIHJdZ7Wv7DhwcRln6UrnHVakJYWlHdSVP4N6r8nhS9aGEgk9RUWe3LI9KZgWjyqNU/0X4HJW9PeS0cVk5EP46+o8PN83nZnMdw/JaZuFRLmSI4VbmTxTApg1z/X82VNZexgGNnTSVomwMZ9CXOCBa1JIpILjj+KkFRL7G5aBkX38cF/an4CkyzPvwlRBIowuZfyXOEGeJ05R1a2YGK98zBhwDb6sjgKWamaOjPYBnxMnmnKiAkM/yLADie5g1YBO58LjI4FAs9oUGDKto5jbhfft9DkqJNAhi6RBBmiEgX17lbwnLeAK3rvkPUJHpcTp9jDOTHKQrbLAIfko5wbLQWtTLYWDBFtNDSXCwq+45XFuiJTFPDj5I9nU1rmKxErIY/mu/lh9wdRLX4KSf30Nl8KzPT9T2fnTTjwkOKiRsYuMuWJT49NnK+c2jhIQ4of4RxQLNF4G9Irn+2pd9FQSyXPd0z0A3czjY+lJ0x/YU/3ZJ+yaDDCcvHOW2QJInOQeJAOUBCQvZiuMxKTHE4w5Azju3e8beCu74aIFjyTNjKg2M34kxyQIFTT+g== 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:(13230031)(4636009)(39860400002)(376002)(396003)(346002)(136003)(1800799009)(82310400011)(186009)(451199024)(36840700001)(46966006)(40470700004)(40460700003)(1076003)(2616005)(5660300002)(8676002)(4326008)(8936002)(47076005)(426003)(36756003)(336012)(63350400001)(83380400001)(7416002)(63370400001)(44832011)(36860700001)(26005)(40480700001)(16526019)(82740400003)(6666004)(356005)(81166007)(70206006)(70586007)(54906003)(7696005)(316002)(110136005)(478600001)(41300700001)(2906002)(86362001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2023 23:34:22.8513 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 70397a8b-ed66-45c9-026f-08dba5c3cff4 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: SN1PEPF0002636A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB9004 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 pointer to the RCH downstream port's AER and RAS registers. 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/port.c | 34 ++++++++++++++++++++++++++++++++++ drivers/cxl/core/regs.c | 1 + drivers/cxl/cxl.h | 12 ++++++++++++ 3 files changed, 47 insertions(+) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index f3bb7ea37b44..5fae1c06de22 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -948,6 +949,37 @@ 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; + struct device *dev = dport->dport_dev; + + if (!map->component_map.ras.valid) + dev_dbg(dev, "RAS registers not found\n"); + else if (cxl_map_component_regs(map, dev, &dport->regs.component, + BIT(CXL_CM_CAP_CAP_ID_RAS))) + dev_dbg(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, @@ -1007,6 +1039,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 c8562cdbd17b..5cb78b76c757 100644 --- a/drivers/cxl/core/regs.c +++ b/drivers/cxl/core/regs.c @@ -199,6 +199,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(const struct cxl_register_map *map, struct device *dev, diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index b4383697180f..251cda10c283 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -221,6 +221,14 @@ struct cxl_regs { struct_group_tagged(cxl_pmu_regs, pmu_regs, void __iomem *pmu; ); + + /* + * 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 { @@ -273,6 +281,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(const struct cxl_register_map *map, struct device *dev, struct cxl_component_regs *regs, @@ -625,6 +635,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; @@ -633,6 +644,7 @@ struct cxl_dport { struct cxl_rcrb_info rcrb; bool rch; struct cxl_port *port; + struct cxl_regs regs; }; /** From patchwork Fri Aug 25 23:32: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: 13366421 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 DB5EEC83F05 for ; Fri, 25 Aug 2023 23:36:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229870AbjHYXgN (ORCPT ); Fri, 25 Aug 2023 19:36:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231284AbjHYXfv (ORCPT ); Fri, 25 Aug 2023 19:35:51 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2074.outbound.protection.outlook.com [40.107.223.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F5FF2D68; Fri, 25 Aug 2023 16:35:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Yq1BHnNwRh5wr5F9eXJAG7ohdLqVk69/Vv2c3bgxMrHkkSmQLr3tPH+9/xtYNMThpjNHd0rAAVpNW9qRtcHEMpCN48bcUD3G84KMtk2SsovvdXksdDJsNrjccsIiSs5AvBspp1Sp+6QIq2JiPf1Rr87xx0obnfiDqg7SNBhlHkWTmzuGNYO+gFs6GsXOHiYIjQCyE28wKk4JoBPUww+INJTwoLus0rRCMv36YeoGsgoXWu1evhtxkQ0Jwzf4iC8j4vvkHT6GOFf4Sq/rFbXU84A/6qJwpjQIly/h96TUyLgIbY03e8ypyUzed/pgr8u73NrhFol2zQvE+hP9ANPSLg== 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=zrropQhLceQl7tGToOfeISiMGtGWPfSCW9YAyl/WFo4=; b=gKQgV36KlnW/fvinZ5xyx2lbtEZYjRo14WeeBxGjWEGqbg59lYlmn0XVsnT45ovuV95LkwIz04X2ZZjLp9MVb4IqkzQDDMvQEGzFvkvlHOt/eeM4F+n3AkU70utVro9zvURFZl8NX6Y7xWvuzo99SyxLaVk2FFaq6zFdTrP4NFKgpZews59LaIxpzXIrK72wJlPdZJPKYFOSJRGAguVtKM9NhC/lPRPAbZYogoIB1rIury2qNAODoeI7gE/TsZaauA6i5l8NJFAKuaAkTBCx/4O48KtY/QaKM8rLelLGzwBPCj6Txme7rg+2mtgbEMsSkKZ9qsWPqAQu4bVJmh2lJw== 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=zrropQhLceQl7tGToOfeISiMGtGWPfSCW9YAyl/WFo4=; b=hmNIgBGAsoN0uHSH4BifGrsM7Snu19KS8hTlqIjq5rozA8OcHSDuP6jaCfsY4cYN+mktP3d8bmqvlbSgUv4ENTQ9JKSOVwON7BTzEALFcZ3mxRxCZa2UQMwq2kPJPaZCxwn/SgEbRk47aaHR/KOK2CD/UUTLi2qQqoQsPp9Jihg= Received: from SA9P221CA0018.NAMP221.PROD.OUTLOOK.COM (2603:10b6:806:25::23) by LV3PR12MB9213.namprd12.prod.outlook.com (2603:10b6:408:1a6::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.30; Fri, 25 Aug 2023 23:34:34 +0000 Received: from SN1PEPF0002636C.namprd02.prod.outlook.com (2603:10b6:806:25:cafe::c6) by SA9P221CA0018.outlook.office365.com (2603:10b6:806:25::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.34 via Frontend Transport; Fri, 25 Aug 2023 23:34:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF0002636C.mail.protection.outlook.com (10.167.241.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.15 via Frontend Transport; Fri, 25 Aug 2023 23:34:33 +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.27; Fri, 25 Aug 2023 18:34:33 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v9 11/15] cxl/pci: Add RCH downstream port error logging Date: Fri, 25 Aug 2023 18:32:07 -0500 Message-ID: <20230825233211.3029825-12-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230825233211.3029825-1-terry.bowman@amd.com> References: <20230825233211.3029825-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: SN1PEPF0002636C:EE_|LV3PR12MB9213:EE_ X-MS-Office365-Filtering-Correlation-Id: 2e31e5b9-4d6f-492f-d9fe-08dba5c3d681 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ollb/4oOhLBtFN2HqX6U82+vBIww9EjyBP68gWCzum1LaF4050kRh00YYqiNFC/fJjEkRb92OeZ1WAwduf6sAAPqBivbUwkmSTlip2ul+wfuSSrDgBQqiDNjLbHcIYWzWPBwQ6/ubunuuuBQtuZhjPu10LJudfvXEOh/1t02yOtNCfNFhyZbMNH8k4OYYp3ClyN8B5pKp51+222GiJjvnFjmmvwpvwWk51Z5xuSz9kL+Xgu8+zXNkjufBnDNE0m/TjA/RAE1wr/18Nndybfr7euuHwYh21WI7qj31f/lz04YcASOXDF5jrtcv2KSGXPbAl2WKqldVRLHlKjmBovO1F+P/MtZvhGNHfBfXdL89za3qPU5uW6lU653u3ghTR2MBajQj9dwc+pJPLMpbEypgNfgdUKwB8XJsbNyljQHUwkyLe+8juJKZvax6jPg8SPCE4iM5SyUMxSQUVLdS6atsQk5QGzv6ze/jfztKgBVPARfl4uyITWnlKX5uI8YQZtBM5aicnm2XdiPKe2vFgRnPTwMkXtTSz+Ts4mhgGpB2qJX4NBNngqsuO97RZ50jR8torl70vUMHdjDs1CCLlDrpoveTuh5uaiurOEgFdHvzg7wjMmA883zZWV6OAkHW+klR5X/qZiJ7vZf0tUV8gqELRbu9czpOIQGOa09Hpth8CiFjB3GWGxcOjx8A/A8M+nU94noJmKDrtT+6Vgyti+8f4vc+izAp0tIQYTBGLRbk5SvV/0Lw8kS+aZJGKub+ekzmZzR0rafTQHZY0k3BvhWXA== 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:(13230031)(4636009)(396003)(346002)(136003)(376002)(39860400002)(82310400011)(1800799009)(451199024)(186009)(40470700004)(46966006)(36840700001)(1076003)(5660300002)(8676002)(8936002)(4326008)(2616005)(16526019)(26005)(40480700001)(316002)(41300700001)(2906002)(70586007)(70206006)(54906003)(110136005)(7416002)(44832011)(478600001)(7696005)(81166007)(40460700003)(6666004)(36756003)(47076005)(36860700001)(83380400001)(336012)(426003)(86362001)(82740400003)(356005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2023 23:34:33.8472 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2e31e5b9-4d6f-492f-d9fe-08dba5c3d681 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: SN1PEPF0002636C.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9213 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 Reviewed-by: Dave Jiang --- 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 edfee8035820..1c40270968b6 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -728,10 +729,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); @@ -744,6 +842,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 Fri Aug 25 23:32: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: 13366423 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 31483C83F05 for ; Fri, 25 Aug 2023 23:37:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231527AbjHYXgq (ORCPT ); Fri, 25 Aug 2023 19:36:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231247AbjHYXgP (ORCPT ); Fri, 25 Aug 2023 19:36:15 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2056.outbound.protection.outlook.com [40.107.223.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 314F82D4B; Fri, 25 Aug 2023 16:35:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JBFr3ed7ZBreEju8v5IdJmT2ttXuMo+LTqC8oMn4ufl3FRSunuExroLrCJ79qZYh9sNgNQLA13BoIuNj65tvKKFpQxe24kMF6xy8Oj8xadiJQ40uCYY7xp4oEbE8ek99vuLz1TzRi339DcDluP1q+0sM0y4BX8aG4IVAzejZUsKgEZkdAQ942Hc81pjwV4Lp05jRniQ9bHsDS70yWDwvxT6QU2F3MXgLpZSG1+MeXiYWwjyEU1YkvX00/otPJLNWayXuWwItT7eU3MrNhjHaj25AMMI90szPx089r53KpatlpCh0KyfA/ccHuuEUEPiNIgiY051z8LQn/0IjQNSmcw== 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=LURjg1NMzLqOEURxypN/s/jAS9t6lum4/XDI3Mnb0ms=; b=U5KxDPOXK7WHoMBmbMvxryF2OYkLZO4xoVeavJ+Xf7ESUjpwa/WTcQUCIceRGv2ZZFp5xbmvsO6Z5YhZ500KhxUhr/zzDXw86U8fOmnVv8l18/KQEhAZHfi8YRY/vBTUp/U93v3kZk7AiX4zoYM+chmkQ4ncE4rPdbZVNW1LsBlWYDcgJ9uZvc40+ArKtKxtO0NaJDxG77BHNOeY8sGH9GcA57rOmsPNyAG7OhmTIB6MS4FgzYeSUTtyAafTedOpnepdeCl3zkE+mddemjtaRnMZK5vufA1MY37spJcDOxcYdQOmpnKBJKwLJzA9RJwPBZOeXB6aqHPYeV6yF8FGgg== 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=LURjg1NMzLqOEURxypN/s/jAS9t6lum4/XDI3Mnb0ms=; b=0KxUPfOLz4UuCvBNtfqC+dwjiwhyPfl6cKZ2m5Pf7GquzxFhVbqmyG8+FA/MQyoRIf/Bxhn5mjpAGVzeqtZLMuFlJ03GQyDXZS4ndSV3zCW9r4FHdyytUXoT2moNIPvTPCgHL0bTqZia7ZKVT3bOHqjHhD9vkgCr0cqP6/asRrw= Received: from SA9PR10CA0017.namprd10.prod.outlook.com (2603:10b6:806:a7::22) by MW6PR12MB8759.namprd12.prod.outlook.com (2603:10b6:303:243::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Fri, 25 Aug 2023 23:34:45 +0000 Received: from SN1PEPF0002636A.namprd02.prod.outlook.com (2603:10b6:806:a7:cafe::2d) by SA9PR10CA0017.outlook.office365.com (2603:10b6:806:a7::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.34 via Frontend Transport; Fri, 25 Aug 2023 23:34: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 SN1PEPF0002636A.mail.protection.outlook.com (10.167.241.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.14 via Frontend Transport; Fri, 25 Aug 2023 23:34: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.27; Fri, 25 Aug 2023 18:34:43 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v9 12/15] cxl/pci: Disable root port interrupts in RCH mode Date: Fri, 25 Aug 2023 18:32:08 -0500 Message-ID: <20230825233211.3029825-13-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230825233211.3029825-1-terry.bowman@amd.com> References: <20230825233211.3029825-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: SN1PEPF0002636A:EE_|MW6PR12MB8759:EE_ X-MS-Office365-Filtering-Correlation-Id: cb3eefd4-ad4e-4bca-d288-08dba5c3dd09 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GqBuROiruQIqQP/Toir9ux5vRnYDkNrgqnISsJ9IQcaqohErSbRnrl8QfXnOKhT1Zc3swr8e44eM+bHa7XHGKDrBC8a/9ZfpmSTfjQkizT8xQXnV/KKBs5gDLPAj0C9tlMGh+OPdt4ofa9xiy2LKOJAQpNuL0e0f6X4JWrAkNhcvR2J5sGgJTCZqRzQBpWRFKpmMvQfuqV2CSg9p3Mm7RLH3yUf2liiI/InDT2OQlOzw/Q2ZmaLYgD0dGkdKGs3gCsBUfLQ5UedU/KV8d38qWsnl/CedyilRddwXH3cVoRPqSByNG+psDUCotBdqjIh2xLsgE2U1occ7ZiJBsDA6vbWDjuN8SEqoSDFIxIL57PXiO6Hs8bxnPuAI3VUdocvt1D0DffnAhdUjT9iEGu3TjD0tkkVGbALOmzfT3PMJYcEkj1NLFeGgHGBsSHGhoaB5Y7Na9vvU585DfQAVLdFtvyl7RHuJ4Y57RNLQYz+2RIg7ME8s1EyPkfJrS20HaZ5Me7DuUp20F3iQhUCMOXw6fvCpJjAQR286hYUeiMwSKl8kM1CFj5XkJP7LKImuLUUME1rWzggJGaj/WPSUirEGHcYvZXsGkRDsV0vF+wUioYljfIMwEgUjj9kIp6qGkBNcp6mstWAByZGI6v5wsl6UmOFF8QBw0daAwlraEPNXvLTZX6RNBjsX3jjxc13MtudgyIKDj5ZYpTSOIIiYHDZeZ3CGJFp/xjobk5KUMNZmAoqOK4Tbn37o0US+Q3vlSQ2orPsam61WT8zuxt1j8XL0Eg== 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:(13230031)(4636009)(376002)(39860400002)(396003)(346002)(136003)(186009)(82310400011)(1800799009)(451199024)(46966006)(36840700001)(40470700004)(54906003)(70206006)(70586007)(316002)(81166007)(478600001)(110136005)(40480700001)(26005)(16526019)(6666004)(82740400003)(41300700001)(7696005)(86362001)(2906002)(356005)(8936002)(4326008)(8676002)(83380400001)(40460700003)(2616005)(5660300002)(47076005)(7416002)(44832011)(1076003)(426003)(336012)(36756003)(36860700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2023 23:34:44.8046 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cb3eefd4-ad4e-4bca-d288-08dba5c3dd09 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: SN1PEPF0002636A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB8759 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 Reviewed-by: Dave Jiang --- 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 f470ef5c0a6a..6b037030b936 100644 --- a/drivers/cxl/core/core.h +++ b/drivers/cxl/core/core.h @@ -87,4 +87,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 1c40270968b6..e306d3c9638b 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -819,6 +819,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 sequence 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 5fae1c06de22..11495dbc5fbd 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -1041,6 +1041,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 Fri Aug 25 23:32: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: 13366425 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 E1CEAC83F09 for ; Fri, 25 Aug 2023 23:37:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231247AbjHYXgt (ORCPT ); Fri, 25 Aug 2023 19:36:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231480AbjHYXgm (ORCPT ); Fri, 25 Aug 2023 19:36:42 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2073.outbound.protection.outlook.com [40.107.243.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3C0626BF; Fri, 25 Aug 2023 16:36:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I+CdJgx6QBWJHN3L014H2aZ/Y8QK8idONkiGSMxizc7Gc+kay937OuKBugpP6wdZS25xRF4Us2QI0/YhSKjiT0EJ7onSbO5klWJclkYv2dzgsULilK9TzZe7QLFm+GEAQaLHFlaAk3GJA7+zm4JbMfjSMhJyHiquWWKubMWJlfgc14wvFi5Yc+QweJriITmi6sWv2m593DMXilG7T2L0a8Iq0UPqw9/OTgW+DMxn5Myo2QZpfOMJ6ReWYVqZJhSw4zF/5/MgYvxqdQcjfnovZfD8kanHsk/RARA363E6wABC8JAdtpXsIBVYCIDFos1KcgwqdmbuWihUYZW3pQA0lQ== 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=IYstJQr+GL/LJYik1NBn6/QzGLgvbSnp0Bwgf2p2jSI=; b=b3zRSsQeq7v/rQs5P8WGYUqVWLspyaYZWMOmTd9OiKl+LecO+2252Gy2elwO6T3OVpJSR32uwwt7erGdiT7EuZUoIJ/5LKvQ6mlsQZ0YYJpmab8gVjF8M+LnX84nmgApZJMqf7QvzT98P5GGVJuakQr8SzYTCPDWxdW9gtGLj4crU3VJPAA+z+wcsax3J+rTcM2PI34u1j1X/FsCxo6UbnnoDcRX2XlneY/y8TM9fbHejKdRiLielqBF4tTWwcZXbHDZJVLDUx5Sh5q6F4cbVLm3j7EdtgKQ8lDWRI7B19vp4W9+KNlFdYlihM08eSvxEb3Db8MJOGtrPyLULSOlkA== 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=IYstJQr+GL/LJYik1NBn6/QzGLgvbSnp0Bwgf2p2jSI=; b=eGHARprM5sbMlH6pQH+KKkECsm7/prZjHYYILYhfiV3FdEXCUFX4d+1EA5KreQenKNBH3EQ9tslndVNNaBamb7wsbBmsx970mMZdVCm10zFXF39bDpu7bqRjaiTo0TYHqQE8qMZl6bgoIFonEavGFQYWAi5goUae9k1yzpwvgdU= Received: from SA0PR11CA0208.namprd11.prod.outlook.com (2603:10b6:806:1bc::33) by MN0PR12MB5905.namprd12.prod.outlook.com (2603:10b6:208:379::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Fri, 25 Aug 2023 23:34:56 +0000 Received: from SN1PEPF00026369.namprd02.prod.outlook.com (2603:10b6:806:1bc:cafe::52) by SA0PR11CA0208.outlook.office365.com (2603:10b6:806:1bc::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.25 via Frontend Transport; Fri, 25 Aug 2023 23:34: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 SN1PEPF00026369.mail.protection.outlook.com (10.167.241.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.15 via Frontend Transport; Fri, 25 Aug 2023 23:34: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.27; Fri, 25 Aug 2023 18:34:54 -0500 From: Terry Bowman To: , , , , , , , CC: , , , , Oliver O'Halloran , , Subject: [PATCH v9 13/15] PCI/AER: Forward RCH downstream port-detected errors to the CXL.mem dev handler Date: Fri, 25 Aug 2023 18:32:09 -0500 Message-ID: <20230825233211.3029825-14-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230825233211.3029825-1-terry.bowman@amd.com> References: <20230825233211.3029825-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: SN1PEPF00026369:EE_|MN0PR12MB5905:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a655e4e-fd50-4aa0-1429-08dba5c3e39a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: i3g/M/4a/vcsezR4bSfWcQl0mspMS45Y9fscMJk7d0p9dODsuEaAEGodBPFHmwWn+2A+9n37hEKK2S8mieJOn2lWmsQG9m5tKvFC6x9wALCMiXo0xoqQ3l0zW+pXCJBrYv5Wctew7LrkARf8Z2zSmO9Kk3i5PUwh7BqOnlEStVtCk8QQJ2YjbzvKpks5yz69HD9ItSs7x/udkWVfoYyfT1LvXXW2ej8h3dbRUzyiMJL0I2Bwx6tzLdWZvhzqU1FKXJDN3dgry4yHi9PnuZhvgSOYcPcMgjNFYUmrz0e/9NppOf32rn2Zg6bdkqFelPK06cu2AF/8cPHNABVb5QwQOMSb0q6TlKTFpuuhBjNur2HO/P55zwilBjPHrbfXLDsyUqDwlQ7+HAHGD7EI59axsuMeE/SqreaVxdojbPAhDPkHbrq2yCppdUvHSCHtSsNOh0V72uSOlueRPKAvP4GoMTxBX0LRCspWMk46O2gQ1oA3KhEJV8mMy7aPmPEAZlV+CrhBxyU/AwwGulPhQxVBzcwRlWMdHIp8IZ7RlmkiAQPd7MZxjAt3Hzf+s3oBuxpzfngmMUBC2oUIW+V2hqtcSldEcnuofJMaoz9UC6GQ8jbx3j+DnCMypo0qUdMO6iQlVlyyLGQj/jOcWMrgk5/yhwWQnZdLhwt9RUr7pq6l8dWbwmXH1bevG9qzqeO0pNNV5RxThrkDJaH8FUnwvDhywaaIaj7djeIuDFrtd9kCvWvhFYKQPFOFsTiVHwAAO1d8KjqnEhLfpc4yqmWFab9mYQ== 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:(13230031)(4636009)(39860400002)(376002)(396003)(346002)(136003)(1800799009)(82310400011)(451199024)(186009)(46966006)(36840700001)(40470700004)(82740400003)(81166007)(356005)(40460700003)(8676002)(4326008)(8936002)(54906003)(41300700001)(316002)(6666004)(36756003)(7696005)(70206006)(70586007)(86362001)(110136005)(40480700001)(47076005)(7416002)(26005)(478600001)(16526019)(336012)(36860700001)(1076003)(44832011)(83380400001)(966005)(2906002)(2616005)(426003)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2023 23:34:55.8163 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3a655e4e-fd50-4aa0-1429-08dba5c3e39a 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: SN1PEPF00026369.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5905 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 Requester 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 Reviewed-by: Dave Jiang --- 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 Fri Aug 25 23:32: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: 13366422 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 BDFEBC83F0B for ; Fri, 25 Aug 2023 23:36:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231268AbjHYXgP (ORCPT ); Fri, 25 Aug 2023 19:36:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231420AbjHYXgC (ORCPT ); Fri, 25 Aug 2023 19:36:02 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2062a.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5b::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3DA42D7F; Fri, 25 Aug 2023 16:35:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JV8h9/ukvTGNr5CqPxHuwo2YI+lu4tKb84OZcNuAk+JVlNNEY3km+KcMqmkkDhj+Dk7UXPS0rAUovdkdlPs/bmazk7M+dhfdzXUTUsG9qMdLLA3Y0qVIQO4aGqIGB+0qtjvv8CvcftloCoDS0Y9YbFBDr8/UyiHaUl6HAl6gyWhlXmgeW5mSlJczRX3pZT6UVm+08D2RLGPorKJBzF+w2OTJz83MT75REbZxyGSYs7WuH965nffDxFM558RqSEMYCdzFYt1JRaAvx1Kkq3sQosIq0BbUdh0p5tR+Bgfaadl0UWLY3lSqkX+bBX6k9IOiUzr4f4Bt56yN9TlrRPKXmA== 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=omEvIhe6j83LbuOyZ/SUqwoTimOun3G14ApcXP+8OxY=; b=dtGpw2Vfh+uvXg4PTI7qA2R3HrBSD2nM/LUEkYwVbCVvVmpCXiKFgadFpcSM5Idh1n4h7CnFccJdNcbFGIlO/or4qKu6KN5GqA0sgpbxgO44luhijSzM2xpTLJFS+MFKq4wOZhPEuKDCwXKVdjqV7xN3RzDRJxTRFGL6gepEzs+tY79dAKycqN7oXyXnJKVjxsEYvJ+rwy1rmqYQfqlB2DdM+VittFLeLLXNWbrtx3JZNKQWZBR8rqOxQtsdlW/TsSmeGWkHMg3Ny8AI1FD/89wNanKT/cylNf8sjVvYLI0NPlpMN1OADpArtNEWMZMsHSoJftgNbUWPXWUjWd79qA== 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=omEvIhe6j83LbuOyZ/SUqwoTimOun3G14ApcXP+8OxY=; b=QVOJGujMN8szMx6GGNd94walWK1Oj562P0HV3v/PcsT5CqH8apfPzfcKIhjxcjiRCS5g+KcofE729wsv1kcldFjJDAVlS7c0ym1PvmTfamoKcdPXUrP1bdYVfWspZkufrZueD/15204lWTguOKwmLusYr7txcN2VrFVQQSXuTLY= Received: from SA1P222CA0165.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:3c3::11) by PH7PR12MB8794.namprd12.prod.outlook.com (2603:10b6:510:27d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.30; Fri, 25 Aug 2023 23:35:06 +0000 Received: from SN1PEPF0002636E.namprd02.prod.outlook.com (2603:10b6:806:3c3:cafe::53) by SA1P222CA0165.outlook.office365.com (2603:10b6:806:3c3::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.30 via Frontend Transport; Fri, 25 Aug 2023 23:35: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 SN1PEPF0002636E.mail.protection.outlook.com (10.167.241.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.14 via Frontend Transport; Fri, 25 Aug 2023 23:35: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.27; Fri, 25 Aug 2023 18:35:05 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v9 14/15] PCI/AER: Unmask RCEC internal errors to enable RCH downstream port error handling Date: Fri, 25 Aug 2023 18:32:10 -0500 Message-ID: <20230825233211.3029825-15-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230825233211.3029825-1-terry.bowman@amd.com> References: <20230825233211.3029825-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: SN1PEPF0002636E:EE_|PH7PR12MB8794:EE_ X-MS-Office365-Filtering-Correlation-Id: d3f9a56a-dc18-4101-1173-08dba5c3ea02 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sfMoi6+eEf4Fe6UzzNtyuS367SjgGEbSenG6OkvA9wHVqDswcA+iVxlBDXeXrZnVOhs9eyWpgYB4LHM4yx85nA5JiOiaBRt/t/DCZe8qAzU6G4tDnU8GOcDyXu9yqEeCFYB49O9uCXVVzHYnBuLk82gh3CN2ZoXMFHrYBT6AeIarGDsUbQf68XxDZP4l3F8Cbmyp1EbUcM68vQ9jg/NPNwYmHcF3gB56yECUzOmGwII7740Qm7ZGbnK8f8s/jRkhmxkKOUXYcB1HCWYPwivhQANmm+/vC4opiLZlDx1d4oHYdl0dNHkN6b+tzUgeH2PNWB6PEB5NoZ7Srvooz/ae6+B45msn3C2ntnaFRGrkkR9e9zlXeUEjANKGutUA5rQfngDOA/J9esc/UDz8TGDixG0EuASt+vTljjfLxDps6W7wvlhhCnnfMyufrrN5F7pI96eKQ02NFV+l6+K2PSZ20V8d3P36V3jyin6xASxZxdf4APVK5N3CVYGlvYGr3mshJJMRTUZEbpUlwdUgONUFRYCLpQqZ4G/6tFhO2JRq8yz6XJeYC6FNzgPA1vk/bB+Ug/fdRwvgMMiCbkkp7wyN5wSAlMKYpygSB6FplX2gWxJ9TAi0mU2KNDRxPJurstKy+ejmiPYZD2l9NJLF35+Qk6yf7YoV/mImXuE42Kv0HZnzL7h25q4zuL15saiHg3B2/o8knjoozqCciWITSpECbOcJEDgiPMKjIJK5SR9G+Hr5m0e1yRd46WTyYN/dqngtzKil2YJmfJVzOPRsAIArcA== 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:(13230031)(4636009)(39860400002)(376002)(346002)(136003)(396003)(186009)(82310400011)(1800799009)(451199024)(46966006)(36840700001)(40470700004)(7696005)(40460700003)(6666004)(336012)(83380400001)(426003)(82740400003)(356005)(81166007)(86362001)(36860700001)(47076005)(36756003)(40480700001)(16526019)(26005)(2616005)(316002)(54906003)(2906002)(110136005)(70206006)(70586007)(41300700001)(8936002)(4326008)(8676002)(5660300002)(7416002)(44832011)(1076003)(478600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2023 23:35:06.5642 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d3f9a56a-dc18-4101-1173-08dba5c3ea02 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: SN1PEPF0002636E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB8794 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 Reviewed-by: Dave Jiang --- 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..916fbca95e53 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) +{ + bool *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) +{ + bool handles_cxl = false; + + 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; From patchwork Fri Aug 25 23:32: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: 13366424 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 BE98DC83F08 for ; Fri, 25 Aug 2023 23:37:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231241AbjHYXgr (ORCPT ); Fri, 25 Aug 2023 19:36:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231415AbjHYXgb (ORCPT ); Fri, 25 Aug 2023 19:36:31 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20627.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eab::627]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF4D62D48; Fri, 25 Aug 2023 16:35:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IwAZYPWE4JIxjOTnVacvIep08QzFryLWTu+z/3zxpJ85jZ+tIg/9trkfl53AwQpeeRL88puxL4jKHuV2x/5XO4ns424/uI1o9gu8mmgTUXqIkqxvyOR/e+Yrmplims5cg4205C71ZvusNAFuw2pTkgMzTsqNt4MQcw5aaGpZZKvvVyvzBPDroEMUqM0c4XjMCjjgB/rRPOoy6eewr0b1GlZ0qZrYmgu936uhC2brgLEfUB0N7C1bQqccXnlOaEb3aCH66UlcMWAYbor7ui+AgiSfsfplx904JNiYmBLcnfQpOiVTaI8Q9LUWst3W+r5Yuni1PHIqs19TWdpaZ4UpFQ== 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=HowVnlzW4JC8ruauWc5sqF4TOOU9RUL7T65pRePyA2I=; b=YdNd87bDTTCWcf0IrA1zCBJzBk3LKWrJGGLlMDIbfrasxyx16/YUaXVHyKJxIKUXCpZmB/eNFlMdsGLpnr+BODc3lMGFiKA6fklVdye84nKF5D6N2I8P7NCzfdxCFuU2un2+lsxaZS5IJIqGTJ5wEEgOyRI55oC5BJb4p3kCwhUQDbG6CvaHeSanya8dWixFrBpVgG0Z38rVzaShaPC9OReBN3ATO5vU6FS6NDPZ1fPZUo4rMRl1aLxVVns2Z4Yj+xOcwWSF54R/jpH5INR14diSqUdYCHemE4Q5TW1KvwvLFb9tyaDMb+D1TxP437Qd8h1rrKN+U0bW2zlZJbIcRg== 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=HowVnlzW4JC8ruauWc5sqF4TOOU9RUL7T65pRePyA2I=; b=zOWLBmw3tz0SSnALM7sQCGG43P+ez7YBV0zKYiuJliTwjeP/RT4Qw8/In/f4xTZ0uX+sE37gd8l6k8XbAZzawtc+A8RUFnPC+JnB0fZw0bgVSchpB1vUx5T8nH/PQbGBoGvPkwfZ8FtQAKR0qIv4u1mcU75e8g6RgowaZidCrog= Received: from SA1P222CA0152.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:3c3::20) by DS0PR12MB8197.namprd12.prod.outlook.com (2603:10b6:8:f1::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.30; Fri, 25 Aug 2023 23:35:18 +0000 Received: from SN1PEPF0002636E.namprd02.prod.outlook.com (2603:10b6:806:3c3:cafe::8) by SA1P222CA0152.outlook.office365.com (2603:10b6:806:3c3::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.34 via Frontend Transport; Fri, 25 Aug 2023 23:35:18 +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 SN1PEPF0002636E.mail.protection.outlook.com (10.167.241.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.14 via Frontend Transport; Fri, 25 Aug 2023 23:35:18 +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.27; Fri, 25 Aug 2023 18:35:16 -0500 From: Terry Bowman To: , , , , , , , CC: , , , Subject: [PATCH v9 15/15] cxl/core/regs: Rename phys_addr in cxl_map_component_regs() Date: Fri, 25 Aug 2023 18:32:11 -0500 Message-ID: <20230825233211.3029825-16-terry.bowman@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230825233211.3029825-1-terry.bowman@amd.com> References: <20230825233211.3029825-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: SN1PEPF0002636E:EE_|DS0PR12MB8197:EE_ X-MS-Office365-Filtering-Correlation-Id: 635bc7e7-47a0-4fb4-b2db-08dba5c3f0d5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nCeTfC1ymYbtPu9w4ocEdu7OD+LZ0kdHIvL5pt0elYZ4rscDVJmkMTj4HOR4mxXHgIIEwRzLW/dgdu3jCvTFqGtyRozR3WOun8/6GeqI4poV7b5t+xt3iiyjnEDNmVoH9q33OILDTqYcJbTG4eqaMquhCPLlyFzPRMofM5+CxT4cAgW1rRipzj0NqnyiZcP6MmxMNJnV4TgyvJc3SLumxqrdLcV1rhY+gIlMAKJoAnpb6pCqUTbgcpW0BVbX3s+EX0VNy2FX358Ei5uTbNUVk6Tt+/d91VUpNZnfX/BE2VFmtuA0XA7EEZKrE0YTrOmO2nYNaRIy4lYpUeigtl2L8yrQe4Rh0iVy8755YX0NAX8DGAHDLuOcag9N0xs9ufp7TElDmUOMBXOmx0+0OJBWoSwPSHREf9ofaOREBlE42mi352Ye0XOtJn6LSXKVtpOnl+pP1vkP75hs6FJXBUC8QC8xL/9o/u7TUVwdvqxXWNa8MCaWFvrI4Uq8wlHQow5tDfYq5J5V6K/2mLxMPg2IR68Lw3QO6JcwQ3C3A3AfnD8kqlZoMDDku+DDeRfHm/2BHv+fNLcRKXjEGoTHIYLaZFMv+5smXlP/mXngfXXVg5dn7m03Dh3CLXtMSAB3Pji3a2ephVYzSy4YhPZvRCXU3TdvvBTcJS7dtZL7gEl7+wABNEYje2Us4BWS5Sgdw/Krvuoh1K9G7EAViYFI/UjeXcIrE0WlR6suTA3I8smqtU+GJlf7d+uoYViyqC3ujd3kQ4t0UKnH0T69WW8t9b8Ruw== 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:(13230031)(4636009)(39860400002)(376002)(346002)(136003)(396003)(186009)(82310400011)(1800799009)(451199024)(46966006)(36840700001)(40470700004)(7696005)(40460700003)(6666004)(336012)(83380400001)(426003)(82740400003)(356005)(81166007)(86362001)(36860700001)(47076005)(36756003)(40480700001)(16526019)(26005)(2616005)(316002)(54906003)(2906002)(110136005)(70206006)(70586007)(41300700001)(8936002)(4326008)(8676002)(5660300002)(7416002)(44832011)(1076003)(478600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2023 23:35:18.0174 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 635bc7e7-47a0-4fb4-b2db-08dba5c3f0d5 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: SN1PEPF0002636E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8197 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Robert Richter Trivial change that renames variable phys_addr in cxl_map_component_regs() to shorten its length to keep the 80 char size limit for the line and also for consistency between the different paths. Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Reviewed-by: Dave Jiang Reviewed-by: Jonathan Cameron --- drivers/cxl/core/regs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/cxl/core/regs.c b/drivers/cxl/core/regs.c index 5cb78b76c757..f8f26fe80489 100644 --- a/drivers/cxl/core/regs.c +++ b/drivers/cxl/core/regs.c @@ -217,16 +217,16 @@ int cxl_map_component_regs(const struct cxl_register_map *map, for (i = 0; i < ARRAY_SIZE(mapinfo); i++) { struct mapinfo *mi = &mapinfo[i]; - resource_size_t phys_addr; + resource_size_t addr; resource_size_t length; if (!mi->rmap->valid) continue; if (!test_bit(mi->rmap->id, &map_mask)) continue; - phys_addr = map->resource + mi->rmap->offset; + addr = map->resource + mi->rmap->offset; length = mi->rmap->size; - *(mi->addr) = devm_cxl_iomap_block(dev, phys_addr, length); + *(mi->addr) = devm_cxl_iomap_block(dev, addr, length); if (!*(mi->addr)) return -ENOMEM; }