Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2755788rdh; Wed, 27 Sep 2023 11:39:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHamcSQYxkbNVyzGLBSFmE6MqQZgLPIrxuDqkPDlnhcLflJoIlhGvVpM0tnftPoKO3NHkt6 X-Received: by 2002:a17:903:1c4:b0:1b8:8af0:416f with SMTP id e4-20020a17090301c400b001b88af0416fmr3211919plh.1.1695839962371; Wed, 27 Sep 2023 11:39:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1695839962; cv=pass; d=google.com; s=arc-20160816; b=mJfpgcUveQau7ZvW48KGlmzjpwqpgRlurOZNDCPYySeCRlyVuKe19klZ5ohZMgU5Z9 lOc8qqac91oIvX1tZtf4NPDNHVJcShg4bI34RUIPZxYAEa7ged8Wudgy5Q5zmJouMeQt xprO0J7RI3jxRImIEEvez3Qsb/ZaGFneRtMp/WrS7ODmVSRougcHdPIIE5EleKfkaNs8 3qMlaJ/igLOGJOwo0ZoV/bLndRP2DQvWADe9KprNDgwUv4hJrLTmzotCCap4hOY9DXyy EXg3lCXPngWFioHKjVCG6oEnQGy+oMAh4IjqMk+EcbKpnLzgC+wJx++CXb1YAqiezXfD E0JA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=q5MPyWFLNhfvR/GOMIMxU9fwv3SfGrCXxvoqrXrI+cc=; fh=8mQkxI/msGNGkxZc3km6VNrl0J/4T5ddSp1WxeodlBs=; b=tKwL7SMI5FdqZZR1q1Tnoz7Cx8F2GExJ6sp+voqH5DmiUF23sgNZ6jNy5Nj+EdXGet vgjJrNaPi5T9Joj3yfiixJzeMLQHq8X1kyXI/tIW5TeoQeb/yZyFgypkWpAnHiRUBAt8 P61VRUP9vQJ/eGPV3rGu/9IKbXANdqzi2piYqX6RLKCzs89Tl2fq72R+w67tp3B2xgD3 etyheguIXa3lbZDF+LG41VRr2r/50x8SIIhcEwCF2MrOBMDyu2ZBO3dTv/TwUj34Z1bv KG56320hFnoyWFjd0nfBEyByrR1RQdHRtnRwyR6dzTGaxFFv0heilOkvI+ergvxJ6EWA TyTA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=mqco9s8S; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id u15-20020a170903124f00b001bbcddd6e82si18332266plh.91.2023.09.27.11.39.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 11:39:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=mqco9s8S; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 3856F80A9AAC; Wed, 27 Sep 2023 08:47:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232520AbjI0Prn (ORCPT + 99 others); Wed, 27 Sep 2023 11:47:43 -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 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 27 Sep 2023 08:47:51 -0700 (PDT) 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 -- 2.30.2