From patchwork Wed Sep 27 15:43:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 13401315 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 A5E00E82CA5 for ; Wed, 27 Sep 2023 15:47:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232786AbjI0Prh (ORCPT ); Wed, 27 Sep 2023 11:47:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232623AbjI0PrD (ORCPT ); Wed, 27 Sep 2023 11:47:03 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2051.outbound.protection.outlook.com [40.107.220.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93A73272AC; Wed, 27 Sep 2023 08:47:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fHFG5zG9Ed7ljN59dR6kEleRL8TFkhpHcjigA+qouqSypj0G/7OM7AYZzECqQezhIylcNX2dGWHF7CVT8UeWiVuzktDOC8QdKlMq5PEbNwJ2/95E6KZpsKQzFE0uZXOLCG0KYyp5eDmg/bjVTrdREwQZoJHe8pvybIH2FmuBP6QGRvh5jc2xt+AyV/Yj/dGIPaYFyOSu6rA50KvajyAdBGY1ZwvX5yDWzeYuRtCCwQXLD3xbyhBkqzKQXDVt1G8aGSLIRwtdn2DICbcLjA2o/YpHi2kAfP1auGcZxMtsSyGCHLJ3OYqeRCosY5rbgjA8IUxc9zrzOwXd6Iu13iLQPg== 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=q5MPyWFLNhfvR/GOMIMxU9fwv3SfGrCXxvoqrXrI+cc=; b=A7DUkPnRvDEjvVo9/qcrprgrStn0eoHkRqk4EkDZYov617TNCCxkyXspLmHHLd4fMBxVhWCBVm0KZfO5Jb7uCUzl/V9pzHfGIi7PubtTDrjN5oelNr7zq3HkGFU2nYPad8TGWWYAqJJNdUDIQeRTnVGPo1pHCnxKTyJmZv3j1aoNSh1OThItjdygpL8fp0N2BlD7i05OZwPk7Mh5u6OhigwBNRUQNS65/Kds35WGFtqrjdsjKyRaXlVeGa4nLdwv1zgp86x+uRPPJfAdrj5JoaI33V5p2TaT4zK809eTf4QqGvLvBviDMjsCzdIeAr/EvCl5BAt8Saw1YGxMU7l0Kw== 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=q5MPyWFLNhfvR/GOMIMxU9fwv3SfGrCXxvoqrXrI+cc=; b=mqco9s8S1PWn0nOnMOFnL/e21yPtecteX4nxtusWwj/ZAehwDRqSfl++rO6Sg9mir6i35Pb8+HOwp1W8TJSc9rScm/wFyNpEEFwts9gKuC7c9TLTNYRbmWD4k0IxFz6OX/zCvoy/BdwrXza9f9cg3Y33d1eUt/+JTbqMdeitz0I= Received: from BLAP220CA0018.NAMP220.PROD.OUTLOOK.COM (2603:10b6:208:32c::23) by DS0PR12MB8217.namprd12.prod.outlook.com (2603:10b6:8:f1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.21; Wed, 27 Sep 2023 15:47:00 +0000 Received: from BL02EPF0001A107.namprd05.prod.outlook.com (2603:10b6:208:32c:cafe::25) by BLAP220CA0018.outlook.office365.com (2603:10b6:208:32c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.35 via Frontend Transport; Wed, 27 Sep 2023 15:46: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 BL02EPF0001A107.mail.protection.outlook.com (10.167.241.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.14 via Frontend Transport; Wed, 27 Sep 2023 15:46:59 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Wed, 27 Sep 2023 10:46:55 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams , "Davidlohr Bueso" , Jonathan Cameron , Dave Jiang CC: , , Bjorn Helgaas , Terry Bowman , Robert Richter , Jonathan Cameron Subject: [PATCH v11 15/20] cxl/pci: Add RCH downstream port error logging Date: Wed, 27 Sep 2023 17:43:34 +0200 Message-ID: <20230927154339.1600738-16-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230927154339.1600738-1-rrichter@amd.com> References: <20230927154339.1600738-1-rrichter@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: BL02EPF0001A107:EE_|DS0PR12MB8217:EE_ X-MS-Office365-Filtering-Correlation-Id: a896039d-35df-4481-8917-08dbbf70fc4b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5H6UVL2WEdphpYmB9XDQl1oXLv2YZDSrNe95WmsTPAY93MCB7hqeTV8BcdPhl/S8Io/DqqcSx6Jrfw/xJC6pnY6pyClK04Fh/OTVMwbFCiQpX6+zBQmmfQ1stcLjxQ7jR3UVuvzskOAeRT6WteB9Ls+HuBK9PyK+nl30chLoauKzHAH8KEQXOfsym8NxvTeHSTvmsZA4LpRm6IyTgo16/dGIuGZZ6OwihY0w5Z/uYRznyobR9byMKVSUs/Q+ItfPTrGxVbyN0yAsqPWgBLJsqBFVGEO0DFRfv3qE8twT9Tad10t0d6ntzeejhhfMOQLYcOxTqW3/wWdQ9sy7I/FYI1Z4o8HiSqDQ6NFv96kKtZpbnUzIfNwvEozKZ2ySCAD92pK1HQDFCxOpcj45v2rCWYWzytp3cq4vWrZ/4vu/MwMEpdU0P8G9acNIBZuTc+QCgnCxkVZDQWVJBOQWhcy8QPTnkz1rQQcHS14p5X/13Yy9JOKL/1fmOcsGbFBQwlEnZsi7xyB5j3cWfQuSQNdR7XBgcJ2cAi6eisLk5bMqwH1EozGRRA1qPYD5OZoPMUQteIf/wr9jYRwneGJlOMlsRML1tUITeOi8MvX4ekDvE2V+vIirs2oCx1fYv3goZWvF2y3z25JsdmDnjnWnEB6j9X+klhq2bA8eZ7Zels1AYkcFdceu+tqIFQ1ZedDpjrPrhWSZi786KwDpszJ1NgJKUjuLBngnzlE3IlhCB9JXPE/8+P/ABtIuQMy79AY70CWFUlud5hvSq4z9VINQ2k5KYw== 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)(39860400002)(136003)(396003)(376002)(230922051799003)(451199024)(1800799009)(186009)(82310400011)(40470700004)(46966006)(36840700001)(2906002)(7416002)(8676002)(8936002)(4326008)(54906003)(41300700001)(316002)(70206006)(70586007)(110136005)(478600001)(6666004)(5660300002)(2616005)(26005)(1076003)(16526019)(336012)(426003)(40460700003)(83380400001)(47076005)(40480700001)(36860700001)(82740400003)(356005)(81166007)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2023 15:46:59.2795 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a896039d-35df-4481-8917-08dbbf70fc4b 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: BL02EPF0001A107.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8217 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Terry Bowman 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: Terry Bowman Signed-off-by: Robert Richter Reviewed-by: Jonathan Cameron Reviewed-by: Dave Jiang --- drivers/cxl/core/pci.c | 96 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index 2af7ad77b273..8d849c8bf8fb 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -777,12 +777,105 @@ void devm_cxl_setup_parent_dport(struct device *host, struct cxl_dport *dport) } EXPORT_SYMBOL_NS_GPL(devm_cxl_setup_parent_dport, 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); @@ -795,6 +888,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