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;