From patchwork Thu Feb 13 16:45:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13973709 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2062.outbound.protection.outlook.com [40.107.244.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2357E28A2A5; Thu, 13 Feb 2025 16:46:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465190; cv=fail; b=gtC/QI1QyTX9ntwrmtL9XJAkkzTJ/rwnLut/gV0g5RNKWnrT3ohbgeRzvFZIqU/Ac+IA44b3D6H0jpOvjl/C/8WkmIEcDuZqWKH6LYaac1r7hNSlAlPlpuPjHAf40uonOLLw8kK5VnspOfomguczzY6amCstnaWkWPvKZ7qQWG4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465190; c=relaxed/simple; bh=pN7In7TvK/oDeNDHEbPpXd8fWzex+57Cmb474FXLAwE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=Tz4LXnlQww3AwPmeGkZ9pq+doJZP3XurWk/NU9hw1FDNEV0HmeTq5YZYqVPkEHb7gamKBuBdWbCEXiX+3lUKlRScvfo7QKVGbqKmMuT/jL1/GDujT1e2D2vxKE19GPa4GFyQ4k1b1FQWC1lFeDkqjJ/IqWOey8PsleuV86sHS+E= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=INbTrgbb; arc=fail smtp.client-ip=40.107.244.62 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="INbTrgbb" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=v1hEdx+Ldx+DHrNHVDcHJqb/L3VsZv5/XQHC9xELBcaIXPsv+8cidSo+F8ubyHNSH0QR1w9xXTSanqLVsitxaidvnryq5A4FwK4yZ3qkUjDTjTbvLU7Tv1BPEdauG/2+9clGqbSsrKHLp/OIH9VHLtk+05VYowGtZd8HWRvYJPAkvqOLBHjUpG7ONF0nbOh+rNafH/uZ1Bf6Zepj8a7yQ1iuf7clyDOh8DX6u0QWID3bV5rElpKGipvl3sKANXgfYko5wXRnbReRXRr29Sjq1oDJX1DaIc83nDBYFbqZAgER1sLF68OquNiwl/ER6q1hoIH/6YGLMr2VwHWfUWEGXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=usB9/ZYCkzsHjK4qJEt1FqoNAgdM/ku3NN2pctYP6v4=; b=eTLS7vbj+bC+B+QYegQqxoduv+WnGUqplDcCUV6y9PwZZ4QS52+/dRF/5z/iWml+RIpEzL64jfYS2D/mv6YzA3Tk+miQESj5qXulx29xqV+Tf7XGa/E+gynNJPD086z+RTiJJxD7Vw9UgBifw7uEvN7vTn4ge06PKYxaQMeY16DF9CL71bSO0k5YcRPDraYJ/33Mx270n/KECpDZTa1DdNuoUOy1EeI9LqJ97i4Q9slgdKp/ZfDQl34TztMiVI11CZJIiGOUZCaQr0/2DhGOGhSnSH+KyTVM40qA0Our3Nk6XkS8Y3Tt9om1lj4CFCxksp6V1ylTvLac3ArYTwwBlw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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 (0) 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=usB9/ZYCkzsHjK4qJEt1FqoNAgdM/ku3NN2pctYP6v4=; b=INbTrgbbmKnLaEYlHyfDnXtPeikVR3+0vsbV9stO8xt3AgOb4eY2LRD+a3pZKlas7Lb6C5iQ0TL5Xww2Z89aQBhpZJOAiJbsTUUqvgFvFmAGDA2ABDVl3fuBwcsIpMQYOMfop9vqLQydpBBQmRslJNPZ/Fm2h85IMbnyWPlD7ic= Received: from DM6PR11CA0003.namprd11.prod.outlook.com (2603:10b6:5:190::16) by IA1PR12MB8237.namprd12.prod.outlook.com (2603:10b6:208:3f3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8445.13; Thu, 13 Feb 2025 16:46:24 +0000 Received: from DS1PEPF0001709C.namprd05.prod.outlook.com (2603:10b6:5:190:cafe::60) by DM6PR11CA0003.outlook.office365.com (2603:10b6:5:190::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8445.16 via Frontend Transport; Thu, 13 Feb 2025 16:46:24 +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 DS1PEPF0001709C.mail.protection.outlook.com (10.167.18.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8445.10 via Frontend Transport; Thu, 13 Feb 2025 16:46:24 +0000 Received: from [127.0.1.1] (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.39; Thu, 13 Feb 2025 10:46:23 -0600 From: Yazen Ghannam Date: Thu, 13 Feb 2025 16:45:50 +0000 Subject: [PATCH v2 01/16] x86/mce: Don't remove sysfs if thresholding sysfs init fails Precedence: bulk X-Mailing-List: linux-edac@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20250213-wip-mca-updates-v2-1-3636547fe05f@amd.com> References: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> In-Reply-To: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> To: , Tony Luck CC: , , , Yazen Ghannam , X-Mailer: b4 0.15-dev-e27d6 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0001709C:EE_|IA1PR12MB8237:EE_ X-MS-Office365-Filtering-Correlation-Id: fd2c02d2-c16a-425e-9742-08dd4c4df3cc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?nQjNcDnl3gg+V93uDCbCyND0cK84gOS?= =?utf-8?q?zFnEwG99CvLDrXNQMmvVsZdfhNkfsJNw+Pg/2s2ffHGDdimjRtbdQxTmq3C1tqCTO?= =?utf-8?q?ZJKs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?WDAV1inB7Sfg89BmsdqdL8Gh3sAGt3gJ44Ru886KCfS4OiM1qGNXLAyJ0ZY+je7fZ?= =?utf-8?q?0CmNw+QNiWrdVVFFzkRnLXVnYIfKAeyWdL+c51jhB5elGhboS2HUYkR+JnxvYMpXf?= =?utf-8?q?SWsRQNkAKFxDxhJ5/xY4MO1LSnJKtg9EDENCAC09lXodpLFI2a3zGG6gwoqSI9r/v?= =?utf-8?q?nR8O84zgxSLNCcms+KgFzcqLMU6EClNFmDw5GYsdY8p9X440b62/R9aPncwdhmaCw?= =?utf-8?q?AiBoBB/Jk8Dt9Dz1DnsPFkq47q94LnNPajt0W/PfH+dM0Qr0N0mv6CVBzW+p0Ephx?= =?utf-8?q?9lWDLoFM93UAXp12kIwqclbsZK5UtyilfoS9JhzdFmW5QbADDiVu3ngv5ED+je+bh?= =?utf-8?q?9cfWARuZeyOvSuCiemvhtCVno5Jn0GEEs68uWy2sjeI28rx0cMBmEhYURxPTDhIyK?= =?utf-8?q?PHsNF4QhrxKsgJ3PNV5kSwlg8kNcg4Aiw6bj0eOa8GsEHBn8mnta2I=3D?= 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:(13230040)(36860700013)(376014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2025 16:46:24.1848 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fd2c02d2-c16a-425e-9742-08dd4c4df3cc 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: DS1PEPF0001709C.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8237 Currently, the MCE subsystem sysfs interface will be removed if the thresholding sysfs interface fails to be created. A common failure is due to new MCA bank types that are not recognized and don't have a short name set. The MCA thresholding feature is optional and should not break the common MCE sysfs interface. Also, new MCA bank types are occasionally introduced, and updates will be needed to recognize them. But likewise, this should not break the common sysfs interface. Keep the MCE sysfs interface regardless of the status of the thresholding sysfs interface. Signed-off-by: Yazen Ghannam Cc: stable@vger.kernel.org --- Notes: v1->v2: * New in v2. * Included stable tag but there's no specific commit for Fixes. arch/x86/kernel/cpu/mce/core.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 0dc00c9894c7..d39af20154c7 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -2801,15 +2801,9 @@ static int mce_cpu_dead(unsigned int cpu) static int mce_cpu_online(unsigned int cpu) { struct timer_list *t = this_cpu_ptr(&mce_timer); - int ret; mce_device_create(cpu); - - ret = mce_threshold_create_device(cpu); - if (ret) { - mce_device_remove(cpu); - return ret; - } + mce_threshold_create_device(cpu); mce_reenable_cpu(); mce_start_timer(t); return 0; From patchwork Thu Feb 13 16:45:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13973710 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2067.outbound.protection.outlook.com [40.107.94.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E15228A2B0; Thu, 13 Feb 2025 16:46:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.67 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465191; cv=fail; b=JiLhrqJSbmEgVxRx0lOowQCvkQjNG7pfZGE2weDo1xPVKA4ArCGUZylW/ILYelDLZ6jYx7Gg7aGkDH/n3s547FHF3vpm4LtmovM38O6SL3cIwcCN0uW4k5SWs63k35A81sJocfBv73xN3x2N9/MqdKUfz3RJLT4AIjGOXIU+O7k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465191; c=relaxed/simple; bh=yS1hz0+k2wyAVzW6DTMRL82hP6vaaS1ug8doKfOkouk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=Rf/NqXmeIqxL/PhaaNkf62uT2203QU51ppYz9mw3oPwqykx9My9eUVnj/N68LsXrfZ23mYz1lwvG7vfUxTr0t1v6EXNCJlbGmOSiyo9PzYmvYbEwsdkIKHk/Amrha/pzGrlhBl3kXJu+0NjOVOoFNNG6mumb3vBhNZ3rNzUI7L8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=Vw1qGOki; arc=fail smtp.client-ip=40.107.94.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Vw1qGOki" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pDmOANE6e79ZN169L0c57+LEoMpL2bG/6GFcA2uibF65nnEJa4JvIuw40FEHdtg/geu1YQUicAdqN0mUiBDwePvIHq8fRzGFDz08ytClIae4E6L9+yyPDxY4+6q930h02zcvvduQ1F1NfetxcpGUQogbSd8kF5Jcytd80XLNEwqwy4mr//nBI069+W7AditGoA3F51lI9fqhoidUJdXQLGWVg0yKVZx91O31+CONswl82udPlhDTi6dAawrCKvUVCJtN1ipqZCgvN9rBxjrNpyoZsYZrXwKGnlv1fJ2tnvqxYLqNT0ySHiNYDEG+Rww3o8hQNlehy/N3AsVtVNrKpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=1m5ghx+1OVbM54phDYM7xlX5Ot/IspF10VIn1XFMwNs=; b=m8QvDI/FLTpUV+0n1HXeJNQN1CXdrzRUI77L2IUnAIy2fyGFxh7mv/kPOCIRIJX+EWbzY1IwG8cCTpFFHOlxmb/zKSFlAGkQ966wlAIA26QXVUTcYmFiOrXwjphPw0Y2blwxl4EVt3FehAuRu7z6NQmK8lGh/FgSzrtRn8GjmDm/zzNpm3Xycg9y9yiVQoHOf5Y+TV3FpEaVM0I1FlrvAdTcyn6AandAjolp6eYdSgcjiLmmT1GURidj71bhDkqFyvp0trDbhLBmPMmI/LWknzJmOS47u+NbbLP2hj3igD/b/Hw8Unp0wOjX96IEbwDne7cioFkLAvFlobEnqlPWFg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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 (0) 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=1m5ghx+1OVbM54phDYM7xlX5Ot/IspF10VIn1XFMwNs=; b=Vw1qGOkix5FSq0OgWgCkil4tRMEyLnK01dXXzvalCy9gDt4PzTHi2OWRPxC55rDLzClYPRNsNv58Y6R+/zUxU/qN4Pqfb+OPanB9iNMsibEQTx0eBEdaXIj6/t6e/yT/0YG31cZrUE3QaLRSf3752b8n2rrNQWN37aCFVExn9A8= Received: from DM6PR11CA0017.namprd11.prod.outlook.com (2603:10b6:5:190::30) by MN0PR12MB5738.namprd12.prod.outlook.com (2603:10b6:208:371::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8422.18; Thu, 13 Feb 2025 16:46:26 +0000 Received: from DS1PEPF0001709C.namprd05.prod.outlook.com (2603:10b6:5:190:cafe::4d) by DM6PR11CA0017.outlook.office365.com (2603:10b6:5:190::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8445.14 via Frontend Transport; Thu, 13 Feb 2025 16:46: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 DS1PEPF0001709C.mail.protection.outlook.com (10.167.18.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8445.10 via Frontend Transport; Thu, 13 Feb 2025 16:46:25 +0000 Received: from [127.0.1.1] (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.39; Thu, 13 Feb 2025 10:46:23 -0600 From: Yazen Ghannam Date: Thu, 13 Feb 2025 16:45:51 +0000 Subject: [PATCH v2 02/16] x86/mce/amd: Remove return value for mce_threshold_create_device() Precedence: bulk X-Mailing-List: linux-edac@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20250213-wip-mca-updates-v2-2-3636547fe05f@amd.com> References: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> In-Reply-To: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> To: , Tony Luck CC: , , , Yazen Ghannam X-Mailer: b4 0.15-dev-e27d6 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0001709C:EE_|MN0PR12MB5738:EE_ X-MS-Office365-Filtering-Correlation-Id: 6627f000-8fb9-4f1e-9e7a-08dd4c4df4d7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?4MRmjL21atgEpqX93uW+oE26nNAGQs1?= =?utf-8?q?KzkUcSHsnGoNgWbJrPCuKrZRBM4NxmloIYawm6Q8XQjQlbCvCMqvJjrAmP6WT1d2U?= =?utf-8?q?WphfwnUGcUnd72+VYv01N/zoBtaF/nGEc+0oUL8nKQYBblw1ZDW2u4NBAT3JNnb+n?= =?utf-8?q?AyMqTw2U9Q0puI000O9y4RhUFOZlwgyGWVEQ559Ld0WnzxRadNRqJIR0MAkQJNjW7?= =?utf-8?q?Hzc1aBjb1Z3J+cJD9ktOjA52HQBBQWmQAltpxV8/R1zaFZaDz1WfKIL/q9Jyaf+Rl?= =?utf-8?q?yPXg8nSQlBu2yGhWCXRSQ4+bBbL8XhM0Z2XTiQsA+8xNPqLlsCHgbxV+21FPk9L6s?= =?utf-8?q?hBYz5xaDH+eMe2COvuUdi4D3n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KWemsj4mWbw7s3g1G2dl+3gOwNo3LSP90sJsuGs?= =?utf-8?q?yeGcsiPaFetF7H9hqkoAtfNKTCknudQ5YwJOhToNZXDMZF7y2rIkY4ooq/zPv5iKX?= =?utf-8?q?Fvxf1qL5KOglRZfgC3jR9OLJHaFvpzAI3CxReJcXSqjTxryyIX8FKyQg+7nWWJAA7?= =?utf-8?q?35/5A0CJXtoxvg5EyN4iWF1MbJfXckGiVhQNBbMda2sPcTwv1wBKy4=3D?= 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:(13230040)(1800799024)(376014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2025 16:46:25.9348 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6627f000-8fb9-4f1e-9e7a-08dd4c4df4d7 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: DS1PEPF0001709C.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5738 The return value is no longer checked, so set return type to 'void'. Also, move function declarations to internal.h, since this function is only used within the MCE subsystem. Signed-off-by: Yazen Ghannam --- Notes: v1->v2: * New in v2. arch/x86/include/asm/mce.h | 2 -- arch/x86/kernel/cpu/mce/amd.c | 16 +++++++--------- arch/x86/kernel/cpu/mce/internal.h | 2 ++ 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h index eb2db07ef39c..2701aca04aec 100644 --- a/arch/x86/include/asm/mce.h +++ b/arch/x86/include/asm/mce.h @@ -373,14 +373,12 @@ enum smca_bank_types { extern bool amd_mce_is_memory_error(struct mce *m); -extern int mce_threshold_create_device(unsigned int cpu); extern int mce_threshold_remove_device(unsigned int cpu); void mce_amd_feature_init(struct cpuinfo_x86 *c); enum smca_bank_types smca_get_bank_type(unsigned int cpu, unsigned int bank); #else -static inline int mce_threshold_create_device(unsigned int cpu) { return 0; }; static inline int mce_threshold_remove_device(unsigned int cpu) { return 0; }; static inline bool amd_mce_is_memory_error(struct mce *m) { return false; }; static inline void mce_amd_feature_init(struct cpuinfo_x86 *c) { } diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index 1075a90141da..4ea691006c3b 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -1318,36 +1318,34 @@ int mce_threshold_remove_device(unsigned int cpu) * thread running on @cpu. The callback is invoked on all CPUs which are * online when the callback is installed or during a real hotplug event. */ -int mce_threshold_create_device(unsigned int cpu) +void mce_threshold_create_device(unsigned int cpu) { unsigned int numbanks, bank; struct threshold_bank **bp; - int err; if (!mce_flags.amd_threshold) - return 0; + return; bp = this_cpu_read(threshold_banks); if (bp) - return 0; + return; numbanks = this_cpu_read(mce_num_banks); bp = kcalloc(numbanks, sizeof(*bp), GFP_KERNEL); if (!bp) - return -ENOMEM; + return; for (bank = 0; bank < numbanks; ++bank) { if (!(this_cpu_read(bank_map) & BIT_ULL(bank))) continue; - err = threshold_create_bank(bp, cpu, bank); - if (err) { + if (threshold_create_bank(bp, cpu, bank)) { __threshold_remove_device(bp); - return err; + return; } } this_cpu_write(threshold_banks, bp); if (thresholding_irq_en) mce_threshold_vector = amd_threshold_interrupt; - return 0; + return; } diff --git a/arch/x86/kernel/cpu/mce/internal.h b/arch/x86/kernel/cpu/mce/internal.h index 95a504ece43e..231ba8ca4a3e 100644 --- a/arch/x86/kernel/cpu/mce/internal.h +++ b/arch/x86/kernel/cpu/mce/internal.h @@ -265,6 +265,7 @@ void mce_prep_record_common(struct mce *m); void mce_prep_record_per_cpu(unsigned int cpu, struct mce *m); #ifdef CONFIG_X86_MCE_AMD +void mce_threshold_create_device(unsigned int cpu); extern bool amd_filter_mce(struct mce *m); bool amd_mce_usable_address(struct mce *m); @@ -293,6 +294,7 @@ static __always_inline void smca_extract_err_addr(struct mce *m) } #else +static inline void mce_threshold_create_device(unsigned int cpu) { } static inline bool amd_filter_mce(struct mce *m) { return false; } static inline bool amd_mce_usable_address(struct mce *m) { return false; } static inline void smca_extract_err_addr(struct mce *m) { } From patchwork Thu Feb 13 16:45:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13973711 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2048.outbound.protection.outlook.com [40.107.220.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6FE6128A2BA; Thu, 13 Feb 2025 16:46:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465192; cv=fail; b=rYjrnoSZTzKegtUHNrK6iYrlpXahc3bIbFwx0qLxtTjvfYzHRtFYRAkbLIfkcMkPfXLHZbYPanQhvUl6Gavmoq+3qhWriUFvl5oC37pVlfkpacMvC9VcyjfozUmWPcve/bfhpn+9xRfrLrKtTw2oaKMAhsxh0TmyKidIMIAP0Zc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465192; c=relaxed/simple; bh=OyB6R/SPNcRydbbvB9SpKXBlq4MA7R8ifeAoX/LZVU8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=qNyGJjG03E0WWv05dr8b+GlbaepzD2ajb2uyZF8iOrpv03CzJIdfdfeqGxJoKcYa+AC1rGO5bFOLLM4+JkDBVwsO0z3CDqjVl/mEKdHairLaeDuMrrWbHcRJbxYSuRbilGoOO2OZRmA5JVJSxQX0UPR/wI/J4zVXZ9CdJps9KcU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=j0E1HHyk; arc=fail smtp.client-ip=40.107.220.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="j0E1HHyk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cxg9kUXRioKEvY4HX0Dmm8JIzsVv4hCWaoEJOwoVoDEGD0ctTdUNZZBWKxxuttwL6u7KFqpADLRiESsgAmTfZqmSve4FKNUXG8Z0sFTPmIKKHwtkLK/hwA5sFTdESu0Yn4WWQub5LSBeTFJMlDM2DHw9lG+8bxBLTMIiTMIrEqRh44Yezcw5MgkdLMtY9mTDnbYeQYQrh/6BmOYD5Pho9HuhyiS7TSWiPQFVUXvL9vli/EDjXqYLxuHN2JglPjiJOa+jjkLA9IBiP6Ocr8SXJ99Qx6DmKPxSHfN9i7R8TokH8bgDvb4myHmcOiqCWFxJeBZWJbQF6Ayts9vX/WiaCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=eYjq4Yplv4Rp0LjLe+ZbUbPlID7+tQ9ewTvcbKpenz4=; b=N0OKWGXUU+k0UtfJw4lwtGUQlTTBoXGd5gc6yH/i85vpQOkwFZal87ayhgffdT9xZ/xogQFA49d9eKTnL2pVpL7iIYKyy80m++W1F/PGGl/Hx/6Cy6PMTtXhHN1LCRKHKEUeONtnKsLRE5IwRgNh9AXD5Fwy97dfVG2mW2bKwOI7D1OeNIVaE7U3OQ+si3g52Je/It8qc7Bo3N8H5IZe5dwiz7HaM95/6ccUWUpAVJIrWXT6qHwK/vew1JexpiLb/0KaIbMCcVW/pWteZR4GOPlIBJC4OUQh8TyU3g/A/mGmICBbxh5zUnawp426I0QFyj/+T/OrpOPh0E74aFzgdw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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 (0) 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=eYjq4Yplv4Rp0LjLe+ZbUbPlID7+tQ9ewTvcbKpenz4=; b=j0E1HHykIWq8kJzfokSimmpYVDcGA/ZEZ7P8FM5OQAmL1X8ThDgOvohrZZiO44k8JUoLDxzdHI+JuVYH5jiI80JMjx0BqcpEnNyn3WaeL+Ek+gR4iZsyOvfO74JmtmCkWYRfx54p7kuHU8dPbNen2507eev72yoVznznGmRNs1g= Received: from DM6PR11CA0019.namprd11.prod.outlook.com (2603:10b6:5:190::32) by DM3PR12MB9351.namprd12.prod.outlook.com (2603:10b6:8:1ac::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8445.11; Thu, 13 Feb 2025 16:46:26 +0000 Received: from DS1PEPF0001709C.namprd05.prod.outlook.com (2603:10b6:5:190:cafe::cf) by DM6PR11CA0019.outlook.office365.com (2603:10b6:5:190::32) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8445.14 via Frontend Transport; Thu, 13 Feb 2025 16:46: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 DS1PEPF0001709C.mail.protection.outlook.com (10.167.18.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8445.10 via Frontend Transport; Thu, 13 Feb 2025 16:46:26 +0000 Received: from [127.0.1.1] (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.39; Thu, 13 Feb 2025 10:46:24 -0600 From: Yazen Ghannam Date: Thu, 13 Feb 2025 16:45:52 +0000 Subject: [PATCH v2 03/16] x86/mce/amd: Remove smca_banks_map Precedence: bulk X-Mailing-List: linux-edac@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20250213-wip-mca-updates-v2-3-3636547fe05f@amd.com> References: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> In-Reply-To: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> To: , Tony Luck CC: , , , Yazen Ghannam X-Mailer: b4 0.15-dev-e27d6 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0001709C:EE_|DM3PR12MB9351:EE_ X-MS-Office365-Filtering-Correlation-Id: ad09244b-a369-4356-71b3-08dd4c4df54c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?0DsxxG3vTcogaol/qHX97j44UMsjCAz?= =?utf-8?q?lT9JqGhMxppuPNSBXs6QH8xKHSDzzAooN5FWfd5YmfYmhXl6ISJDq/mWby6Qb9j3y?= =?utf-8?q?1K509Mf7Mwtt6ICVGPQhRo9sOHF+sWZ35pP+ul7hGUiFPy5qLoG9IrnPG20SlX5gG?= =?utf-8?q?nvdZDbnseCgdEGuTeRDfuK3EeBvTd1VsTkf2B7Ol2Bu41QF97BU0UjrP2bWetmp9v?= =?utf-8?q?RbxX3Lh4u8ortzeDWj+gzq3CF3tZ7Luq7qiw1GQ82/PLtZH96ne8pH7jM/WLqGqDr?= =?utf-8?q?brLaYcFdVeCVQd5jzn3riz3jFt/FCiFGNoe1lm/4z7xhN2LGpW/60Tsg0uxRy8YTg?= =?utf-8?q?Fz7RbV+R+ndH1Kw/m5uSTy+RI7msixz9qYJHfisYD+Y2+EtU4r6KfPchF57eHL4LF?= =?utf-8?q?NM0+H2r8632KEG/69/KPodr+NheWKUlqk/TpK69YsgbCee9E3KPkDGn/Kh2KXaeKG?= =?utf-8?q?Z6BHcu/Pei+/FSglQ3khZiaQ3x1psPnIWge21dCzVbLuOeDVKdTVWRXagrClVVALZ?= =?utf-8?q?jeaIglpq7qmyER6C53zZYaEZ3L0H243uJqDQ76cfQF/Xh9ZVnqZbGlxgX8XvkXm5/?= =?utf-8?q?c2VYSUoPDpbgEDctcXHkgYPzfBJBjz6BCqhSvJTgxMPCBry+BalSOWtKOQcBxM26r?=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.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2025 16:46:26.7005 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ad09244b-a369-4356-71b3-08dd4c4df54c 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: DS1PEPF0001709C.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR12MB9351 The MCx_MISC0[BlkPtr] field was used on legacy systems to hold a register offset for the next MCx_MISC* register. In this way, an implementation-specific number of registers can be discovered at runtime. The MCAX/SMCA register space simplifies this by always including the MCx_MISC[1-4] registers. The MCx_MISC0[BlkPtr] field is used to indicate (true/false) whether any MCx_MISC[1-4] registers are present. But it does not indicate which ones nor how many. Therefore, all the registers are accessed and their bits are checked. AMD systems generally enforce a Read-as-Zero/Writes-Ignored policy for unused registers. Therefore, there is no harm to read an unused register. This is already done in practice for most of the MCx_MISC registers. Remove the smca_banks_map variable as it is effectively redundant. Signed-off-by: Yazen Ghannam --- Notes: v1->v2: * New in v2. arch/x86/kernel/cpu/mce/amd.c | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index 4ea691006c3b..f8ad40c5c887 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -252,9 +252,6 @@ static DEFINE_PER_CPU(struct threshold_bank **, threshold_banks); */ static DEFINE_PER_CPU(u64, bank_map); -/* Map of banks that have more than MCA_MISC0 available. */ -static DEFINE_PER_CPU(u64, smca_misc_banks_map); - static void amd_threshold_interrupt(void); static void amd_deferred_error_interrupt(void); @@ -264,28 +261,6 @@ static void default_deferred_error_interrupt(void) } void (*deferred_error_int_vector)(void) = default_deferred_error_interrupt; -static void smca_set_misc_banks_map(unsigned int bank, unsigned int cpu) -{ - u32 low, high; - - /* - * For SMCA enabled processors, BLKPTR field of the first MISC register - * (MCx_MISC0) indicates presence of additional MISC regs set (MISC1-4). - */ - if (rdmsr_safe(MSR_AMD64_SMCA_MCx_CONFIG(bank), &low, &high)) - return; - - if (!(low & MCI_CONFIG_MCAX)) - return; - - if (rdmsr_safe(MSR_AMD64_SMCA_MCx_MISC(bank), &low, &high)) - return; - - if (low & MASK_BLKPTR_LO) - per_cpu(smca_misc_banks_map, cpu) |= BIT_ULL(bank); - -} - static void smca_configure(unsigned int bank, unsigned int cpu) { u8 *bank_counts = this_cpu_ptr(smca_bank_counts); @@ -326,8 +301,6 @@ static void smca_configure(unsigned int bank, unsigned int cpu) wrmsr(smca_config, low, high); } - smca_set_misc_banks_map(bank, cpu); - if (rdmsr_safe(MSR_AMD64_SMCA_MCx_IPID(bank), &low, &high)) { pr_warn("Failed to read MCA_IPID for bank %d\n", bank); return; @@ -532,9 +505,6 @@ static u32 smca_get_block_address(unsigned int bank, unsigned int block, if (!block) return MSR_AMD64_SMCA_MCx_MISC(bank); - if (!(per_cpu(smca_misc_banks_map, cpu) & BIT_ULL(bank))) - return 0; - return MSR_AMD64_SMCA_MCx_MISCy(bank, block - 1); } From patchwork Thu Feb 13 16:45:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13973712 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2071.outbound.protection.outlook.com [40.107.236.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0E2628A2C3; Thu, 13 Feb 2025 16:46:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465192; cv=fail; b=aEHAolqCGaPlSji2En3D8oE4HNKOPySSKSfvG/96b6O8gkZyHoXRip6q8Z7JZ2fiVV2Ep0kpLKQunDcw7R/U2Gbmc23eNkl3SFICVljx3KJdFpYMC1uWcYrVtAjFUKm71vyArGVoF1Fz7sOAOnabGuXQv4FBELyooEVnE3nsxgc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465192; c=relaxed/simple; bh=I0wS9mLTzfC9jHClfhqphwtYE3X5ADwwzbit1+AvpcY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=Nh8Ve18ZpYeNV1+fvQvYhqxPdk6DmKEb2TzQ6Cq9oD36cRdPNE3RXiKuAct+UjpVlN7fwUhhNiu2exThjo4BAY42cJZvFfKlk9Mb6bxIg8x1kzbuGQYCub10y6b80rYV/ZQS4k/gvEMLTBGPIzUJfvyomJS1U1J3J3YdPF/igKg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=iR7Vv82O; arc=fail smtp.client-ip=40.107.236.71 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="iR7Vv82O" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=g8IuPxo8SCZKXKH8R2NDEN4T2Mzwz78pUOD3SD91CeovURQb+nBSgLxdaJEoJf43vVKxoUP+mN1DN7MBWJuNzlBrgS+UwHt+XlPgZoEIpWsCD8g00mc3lgG0CcBHCkzV8c87FIVxYNzx/pxSB2yE96+U2ZnN12n7+S/JgFlWWbJg9UJQgyNVEnpqZ7cAusqhzY/05ILVJTAzzQPXNSpIr1vj9zldsmHMVRfoXfvKM34kKE3Dh0ySaBKMdUYEpxXN4+4oLdvS3GVLODD96wiBYJ1cwVsgVgQn5FkwxqT8qUBsuAU6Yi6s7JYVQtnDqEjU8VI/xf6EXZSFjqDM81nMRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=j/MAulw+nx45Sd9u2XMpsglLZgoZxizyg8+kY6go08I=; b=DrB4IDvVU4/XnoyhCdPd6TmGPPziv3bBdYmwNOA+RUJnJcdJw/eUwxhVi6xpPYIW7FbXOuaex4Jl34V6N/nDfv91L2D+VL9zYQ3p9EYRiaVXzKyCUV+gQqJwSAk7RSAPbsdftN3gf8qyc9llq5+K/0rfbE+igCRz0C/woSWXR8GQhsL1vOYkn/Pm4gdj1uVhUB1xK0KmifOd4aQXBzbcx0YIgLnCSR7lTx0ZlM4jDMi+6H+LbPajZB8mkWyTc2euv6Kl0rCCnmR8+AlaaGFxsH11CqXwx156bQYRxGO5RpjO+xSLdO1UEkTUg+4mPmWN64q+5OSg7lpfqC8nrxvKrg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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 (0) 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=j/MAulw+nx45Sd9u2XMpsglLZgoZxizyg8+kY6go08I=; b=iR7Vv82OKvhp4Y3OrZ8O0xVY5AWCubSk10cxlsz3h6zSkhdc0PMjLgki+EIQ7HEt2jbWHJ/xhTOUF6LetTjf0O2fkNuAWHQrIu0qrsnhFxp0ZixDtRpM9bZIlimrZYtzWd2GXN2mvq5lhPQy55LT17HGmsvitcm1FzJaewwzGu8= Received: from DM6PR11CA0024.namprd11.prod.outlook.com (2603:10b6:5:190::37) by CH3PR12MB9078.namprd12.prod.outlook.com (2603:10b6:610:196::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8445.16; Thu, 13 Feb 2025 16:46:27 +0000 Received: from DS1PEPF0001709C.namprd05.prod.outlook.com (2603:10b6:5:190:cafe::4f) by DM6PR11CA0024.outlook.office365.com (2603:10b6:5:190::37) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8445.16 via Frontend Transport; Thu, 13 Feb 2025 16:46:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS1PEPF0001709C.mail.protection.outlook.com (10.167.18.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8445.10 via Frontend Transport; Thu, 13 Feb 2025 16:46:27 +0000 Received: from [127.0.1.1] (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.39; Thu, 13 Feb 2025 10:46:25 -0600 From: Yazen Ghannam Date: Thu, 13 Feb 2025 16:45:53 +0000 Subject: [PATCH v2 04/16] x86/mce/amd: Put list_head in threshold_bank Precedence: bulk X-Mailing-List: linux-edac@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20250213-wip-mca-updates-v2-4-3636547fe05f@amd.com> References: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> In-Reply-To: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> To: , Tony Luck CC: , , , Yazen Ghannam X-Mailer: b4 0.15-dev-e27d6 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0001709C:EE_|CH3PR12MB9078:EE_ X-MS-Office365-Filtering-Correlation-Id: 3621fbe7-7a50-455e-1f84-08dd4c4df59b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?n6dFdJLN+V3CJxmvAmnA9a1keqKZ8VS?= =?utf-8?q?rHjg0B3JqaBFdebEEeTKoWkXNMnWzk/6Hgi7ZsX+mKv815f/5SFfaYxRjEogtGwH8?= =?utf-8?q?w6W7w8bwjXKf62kc6IssHwQzq0vyd6J9wk4KcSWox3JPlpuFugOjQ5ZPpo+sXssE1?= =?utf-8?q?TFMpH8tSF1EQHp1OV2fTnpijL2n7hnHXKupmiSHRE8oLhOs65Ij036wTE4M2gALNH?= =?utf-8?q?VRJHw5cqKHPPIrqtmK99w1fexVV1bXM3yG3hpXnBy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ub1f1YLnCtzAj/CIfmX?= =?utf-8?q?+tG/Pllv8lfGeUQ+fjTUBTzcD1yMihcBlomTWKBHfYvmMnKJ5pTXs9Z7FO4A4arJC?= =?utf-8?q?lAZwhEJ/co4RsNqSz/sTKy1qX2bnupWhJiN2xpOATpWYE4trGlmCcYDj9eWtKTbDY?= =?utf-8?q?1EBSVz+4Ztpc4LRFaDuiJg3DjefAPZ/f9NtzxmqZNxl5FsG6pVVGfoem9nfEYOAZl?= =?utf-8?q?PMfrErktQUfMOLUWt7PClRcEWLup/tHDry2yfbigAvOlimf/Dt6E3zrrwY6skJDst?= =?utf-8?q?H7MhiIvp+55AjZ2VI2eDOAWXfPqf5vfwBmsQD2ohKbMsDm795M0oVY=3D?= 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:(13230040)(36860700013)(376014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2025 16:46:27.2161 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3621fbe7-7a50-455e-1f84-08dd4c4df59b 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: DS1PEPF0001709C.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9078 The threshold_bank structure is a container for one or more threshold_block structures. Currently, the container has a single pointer to the 'first' threshold_block structure which then has a linked list of the remaining threshold_block structures. This results in an extra level of indirection where the 'first' block is checked before iterating over the remaining blocks. Remove the indirection by including the head of the block list in the threshold_bank structure which already acts as a container for all the bank's thresholding blocks. Signed-off-by: Yazen Ghannam --- Notes: v1->v2: * New in v2. arch/x86/kernel/cpu/mce/amd.c | 43 ++++++++++++------------------------------- 1 file changed, 12 insertions(+), 31 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index f8ad40c5c887..df8984aac1c6 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -241,7 +241,8 @@ struct threshold_block { struct threshold_bank { struct kobject *kobj; - struct threshold_block *blocks; + /* List of threshold blocks within this MCA bank. */ + struct list_head miscj; }; static DEFINE_PER_CPU(struct threshold_bank **, threshold_banks); @@ -901,9 +902,9 @@ static void log_and_reset_block(struct threshold_block *block) */ static void amd_threshold_interrupt(void) { - struct threshold_block *first_block = NULL, *block = NULL, *tmp = NULL; - struct threshold_bank **bp = this_cpu_read(threshold_banks); + struct threshold_bank **bp = this_cpu_read(threshold_banks), *thr_bank; unsigned int bank, cpu = smp_processor_id(); + struct threshold_block *block, *tmp; /* * Validate that the threshold bank has been initialized already. The @@ -917,16 +918,11 @@ static void amd_threshold_interrupt(void) if (!(per_cpu(bank_map, cpu) & BIT_ULL(bank))) continue; - first_block = bp[bank]->blocks; - if (!first_block) + thr_bank = bp[bank]; + if (!thr_bank) continue; - /* - * The first block is also the head of the list. Check it first - * before iterating over the rest. - */ - log_and_reset_block(first_block); - list_for_each_entry_safe(block, tmp, &first_block->miscj, miscj) + list_for_each_entry_safe(block, tmp, &thr_bank->miscj, miscj) log_and_reset_block(block); } } @@ -1145,13 +1141,7 @@ static int allocate_threshold_blocks(unsigned int cpu, struct threshold_bank *tb default_attrs[2] = NULL; } - INIT_LIST_HEAD(&b->miscj); - - /* This is safe as @tb is not visible yet */ - if (tb->blocks) - list_add(&b->miscj, &tb->blocks->miscj); - else - tb->blocks = b; + list_add(&b->miscj, &tb->miscj); err = kobject_init_and_add(&b->kobj, &threshold_ktype, tb->kobj, get_name(cpu, bank, b)); if (err) @@ -1202,6 +1192,8 @@ static int threshold_create_bank(struct threshold_bank **bp, unsigned int cpu, goto out_free; } + INIT_LIST_HEAD(&b->miscj); + err = allocate_threshold_blocks(cpu, b, bank, 0, mca_msr_reg(bank, MCA_MISC)); if (err) goto out_kobj; @@ -1222,26 +1214,15 @@ static void threshold_block_release(struct kobject *kobj) kfree(to_block(kobj)); } -static void deallocate_threshold_blocks(struct threshold_bank *bank) +static void threshold_remove_bank(struct threshold_bank *bank) { struct threshold_block *pos, *tmp; - list_for_each_entry_safe(pos, tmp, &bank->blocks->miscj, miscj) { + list_for_each_entry_safe(pos, tmp, &bank->miscj, miscj) { list_del(&pos->miscj); kobject_put(&pos->kobj); } - kobject_put(&bank->blocks->kobj); -} - -static void threshold_remove_bank(struct threshold_bank *bank) -{ - if (!bank->blocks) - goto out_free; - - deallocate_threshold_blocks(bank); - -out_free: kobject_put(bank->kobj); kfree(bank); } From patchwork Thu Feb 13 16:45:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13973714 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2084.outbound.protection.outlook.com [40.107.237.84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35D3D23A9B1; Thu, 13 Feb 2025 16:46:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465196; cv=fail; b=IU/9ieY9a4Mzjp1YJu4qNJhAYI5XDUVyEck+b470+7UNeBD9U/XUXrz+/NcI82ko7I8rXKDZF/Zsg6hn6g1AYxwaKz0PBFnj+XVcUMS/GM+zPGcPX0RKZp0pUnnZq5kIN58vEWInSLH5ozcs2up9OStFLg/odeXVkDC8ZrZuEs4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465196; c=relaxed/simple; bh=chQVIuLXLKVQXkjYv5UchYWd3VH2HZHnyq3v2zX7zWE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=DpgZ3JrXabop7rrVSo3PkbWGXgxp9Cyd+ZD1PiQ+DFuqrlYfoHJY2f3v5NFtqbXPezzi8SuAooR3HN6lMHanuBZQl+x3ZHMP43kopHAWTvVtF6C2wbrpJI1bdlPOCCIuFrEhruQlikffW9GX2Xu4ePEDMsbWCpsCg+ZsTmM6On0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=wDH0+Ha3; arc=fail smtp.client-ip=40.107.237.84 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="wDH0+Ha3" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BaRyxS+TKV8yadYPN8cRiBluh+Ti/hp8n5HCpB/OB62PNY9+RflQt/mqxmKwO0otkjT1Su6HH9mNhUNHy6Tz+GQ8DDV4UjE0ob38jlWcDOTvuJ68Nxe1ZjpYzpsyLQTAXVib3eReTAPXW3y30T/zssdrBWo43fFvO1GD9lyMvaMQTjH9f5cahxIEOyStynU8qScEPgEazQH7zF46MeBV0EDTyR69Yr9wgnt+fg6RvfXkobOulLx52R3dUP01HUlGBacIZq+yhdptRhBHWA5cuYd3g5fORH+USS9ShA8zgG/FI+sq1xOD4ipzVADfDPBx5/cZns0Th+4ZmVy3cNXrWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Pf6VoZ2b6Kl6W+i1gUSGrMJuppy6CtGCYHrgan/miIE=; b=b4T1QTZyw9aIkpFuEnRJ2ynYFNkZpGEfT0vToBV/3yShpPH6a2FEHRxRtTsIdwhoF8PEg8/a02e7eelt6+NdYCa5HG/4QFGOHfmFCvKnrlndpNYpxtRvBz3d1xgiIX2WzAvTD+q1LVCGzWvH9Gs0DGA8tUOap+p+NvCv1nlBT53j30PTKRpMkJbMAz+8njgKPpRjWEUPQJtxtLBZYdmYy3yAeeWm6wKiiAXxxMWlzEvFU90npxR7G2iC/Mf/A31O6Xd3Dajh0Fbj8MpyQTDulxRmBplp6mo45eTrzJ4mLjVfyXjendMzq3lOZLTsxyMYLzBrdeEU+BCsHR55TXGZPA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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 (0) 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=Pf6VoZ2b6Kl6W+i1gUSGrMJuppy6CtGCYHrgan/miIE=; b=wDH0+Ha3qfR2ZGRDpWUWOf2Y//ZUTq7LHXJ6CFO66d1InJ4szGT1G8VQpA8tt303RSYnWF8BXwB/O+3/4O3HowflYlNB5r+56JKgUbv6d5cHtPw2mRUrMFK8bVOzb58xLoQ4XPfduPfLcS+VGMDsqKmuEroWlLLG0cM6FiOy9vk= Received: from DM6PR11CA0006.namprd11.prod.outlook.com (2603:10b6:5:190::19) by DS7PR12MB5767.namprd12.prod.outlook.com (2603:10b6:8:76::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8445.11; Thu, 13 Feb 2025 16:46:27 +0000 Received: from DS1PEPF0001709C.namprd05.prod.outlook.com (2603:10b6:5:190:cafe::36) by DM6PR11CA0006.outlook.office365.com (2603:10b6:5:190::19) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8445.14 via Frontend Transport; Thu, 13 Feb 2025 16:46:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS1PEPF0001709C.mail.protection.outlook.com (10.167.18.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8445.10 via Frontend Transport; Thu, 13 Feb 2025 16:46:27 +0000 Received: from [127.0.1.1] (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.39; Thu, 13 Feb 2025 10:46:25 -0600 From: Yazen Ghannam Date: Thu, 13 Feb 2025 16:45:54 +0000 Subject: [PATCH v2 05/16] x86/mce: Cleanup bank processing on init Precedence: bulk X-Mailing-List: linux-edac@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20250213-wip-mca-updates-v2-5-3636547fe05f@amd.com> References: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> In-Reply-To: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> To: , Tony Luck CC: , , , Yazen Ghannam X-Mailer: b4 0.15-dev-e27d6 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0001709C:EE_|DS7PR12MB5767:EE_ X-MS-Office365-Filtering-Correlation-Id: 8294c072-4657-4126-2f52-08dd4c4df5ec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|376014|13003099007; X-Microsoft-Antispam-Message-Info: =?utf-8?q?nuhA7N6RuSXEKxXT8c3iMzNk1FGMg6Y?= =?utf-8?q?WzrvK2W3c+qnzhrofNi40mFeiudPs25uhmL7pzgGuNnDlusIHqfXAHB40a75DrNOM?= =?utf-8?q?kCW8yfBDBwzFiW1K+DIJj6sQm748CUY9qbwD1xRpe005CAocFnspXLxFMgRfrwcD9?= =?utf-8?q?bZhvnktnhTgTWGYODwo2JMJYgOiq096iIQKwVYatHpf9j87TrMyXOATUaR8wZAPuB?= =?utf-8?q?K97BNFS/zKL1P+h9q6kg6YxN7x54HrPoX+3qJt0fQIqw4vVFLNSEQ5RwCATIK67xp?= =?utf-8?q?b4TCuDYAcAWgQClavpzVWR7DzcFVNwvlp+MtjcD/Z4qMQm5wDyfOT1ycyJljKguuQ?= =?utf-8?q?4JV02aFv63ZULOvYFFI7U9GRt1N1/rfZy0DZOgtqyhRMF+kB+i1O6ZcVazo5FHBiY?= =?utf-8?q?Yp7rOP96txt2P8/xYXpNioh8ksufC1Ogpbz+GUHwRvUJxj4J/Iym0zi7oigYE1Uqi?= =?utf-8?q?1Py2H47fqg1EWOaW+ZKUlndxKIxSrOsBv7HTP5RCxZT/CC7ZjS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pZSJiiisxNqpd2h8TFJyNQmV2UIq?= =?utf-8?q?GYaAHnW6NpmpWGI6U9bzVZZUnCGro3z3/GQ8LjmruAIJRuJY7/IIGg=3D?= 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:(13230040)(1800799024)(36860700013)(82310400026)(376014)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2025 16:46:27.7474 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8294c072-4657-4126-2f52-08dd4c4df5ec 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: DS1PEPF0001709C.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5767 From: Borislav Petkov Unify the bank preparation into __mcheck_cpu_init_clear_banks(), rename that function to what it does now - prepares banks. Do this so that generic and vendor banks init goes first so that settings done during that init can take effect before the first bank polling takes place. Move __mcheck_cpu_check_banks() into __mcheck_cpu_init_prepare_banks() as it already loops over the banks. Signed-off-by: Borislav Petkov Reviewed-by: Yazen Ghannam --- Notes: Link: https://lore.kernel.org/r/20221206173607.1185907-2-yazen.ghannam@amd.com v1->v2: * New in v2, but based on old patch (see link). * Kept old tags for reference. arch/x86/include/asm/mce.h | 3 +- arch/x86/kernel/cpu/mce/core.c | 63 ++++++++++++------------------------------ 2 files changed, 19 insertions(+), 47 deletions(-) diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h index 2701aca04aec..36ff81c1b3b1 100644 --- a/arch/x86/include/asm/mce.h +++ b/arch/x86/include/asm/mce.h @@ -290,8 +290,7 @@ DECLARE_PER_CPU(mce_banks_t, mce_poll_banks); enum mcp_flags { MCP_TIMESTAMP = BIT(0), /* log time stamp */ MCP_UC = BIT(1), /* log uncorrected errors */ - MCP_DONTLOG = BIT(2), /* only clear, don't log */ - MCP_QUEUE_LOG = BIT(3), /* only queue to genpool */ + MCP_QUEUE_LOG = BIT(2), /* only queue to genpool */ }; void machine_check_poll(enum mcp_flags flags, mce_banks_t *b); diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index d39af20154c7..d85bd861ecca 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -785,9 +785,6 @@ void machine_check_poll(enum mcp_flags flags, mce_banks_t *b) continue; log_it: - if (flags & MCP_DONTLOG) - goto clear_it; - mce_read_aux(&err, i); m->severity = mce_severity(m, NULL, NULL, false); /* @@ -1807,7 +1804,7 @@ static void __mcheck_cpu_mce_banks_init(void) /* * Init them all, __mcheck_cpu_apply_quirks() is going to apply * the required vendor quirks before - * __mcheck_cpu_init_clear_banks() does the final bank setup. + * __mcheck_cpu_init_prepare_banks() does the final bank setup. */ b->ctl = -1ULL; b->init = true; @@ -1846,21 +1843,8 @@ static void __mcheck_cpu_cap_init(void) static void __mcheck_cpu_init_generic(void) { - enum mcp_flags m_fl = 0; - mce_banks_t all_banks; u64 cap; - if (!mca_cfg.bootlog) - m_fl = MCP_DONTLOG; - - /* - * Log the machine checks left over from the previous reset. Log them - * only, do not start processing them. That will happen in mcheck_late_init() - * when all consumers have been registered on the notifier chain. - */ - bitmap_fill(all_banks, MAX_NR_BANKS); - machine_check_poll(MCP_UC | MCP_QUEUE_LOG | m_fl, &all_banks); - cr4_set_bits(X86_CR4_MCE); rdmsrl(MSR_IA32_MCG_CAP, cap); @@ -1868,36 +1852,23 @@ static void __mcheck_cpu_init_generic(void) wrmsr(MSR_IA32_MCG_CTL, 0xffffffff, 0xffffffff); } -static void __mcheck_cpu_init_clear_banks(void) +static void __mcheck_cpu_init_prepare_banks(void) { struct mce_bank *mce_banks = this_cpu_ptr(mce_banks_array); + u64 msrval; int i; - for (i = 0; i < this_cpu_read(mce_num_banks); i++) { - struct mce_bank *b = &mce_banks[i]; + /* + * Log the machine checks left over from the previous reset. Log them + * only, do not start processing them. That will happen in mcheck_late_init() + * when all consumers have been registered on the notifier chain. + */ + if (mca_cfg.bootlog) { + mce_banks_t all_banks; - if (!b->init) - continue; - wrmsrl(mca_msr_reg(i, MCA_CTL), b->ctl); - wrmsrl(mca_msr_reg(i, MCA_STATUS), 0); + bitmap_fill(all_banks, MAX_NR_BANKS); + machine_check_poll(MCP_UC | MCP_QUEUE_LOG, &all_banks); } -} - -/* - * Do a final check to see if there are any unused/RAZ banks. - * - * This must be done after the banks have been initialized and any quirks have - * been applied. - * - * Do not call this from any user-initiated flows, e.g. CPU hotplug or sysfs. - * Otherwise, a user who disables a bank will not be able to re-enable it - * without a system reboot. - */ -static void __mcheck_cpu_check_banks(void) -{ - struct mce_bank *mce_banks = this_cpu_ptr(mce_banks_array); - u64 msrval; - int i; for (i = 0; i < this_cpu_read(mce_num_banks); i++) { struct mce_bank *b = &mce_banks[i]; @@ -1905,6 +1876,9 @@ static void __mcheck_cpu_check_banks(void) if (!b->init) continue; + wrmsrl(mca_msr_reg(i, MCA_CTL), b->ctl); + wrmsrl(mca_msr_reg(i, MCA_STATUS), 0); + rdmsrl(mca_msr_reg(i, MCA_CTL), msrval); b->init = !!msrval; } @@ -2310,8 +2284,7 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c) __mcheck_cpu_init_early(c); __mcheck_cpu_init_generic(); __mcheck_cpu_init_vendor(c); - __mcheck_cpu_init_clear_banks(); - __mcheck_cpu_check_banks(); + __mcheck_cpu_init_prepare_banks(); __mcheck_cpu_setup_timer(); } @@ -2479,7 +2452,7 @@ static void mce_syscore_resume(void) { __mcheck_cpu_init_generic(); __mcheck_cpu_init_vendor(raw_cpu_ptr(&cpu_info)); - __mcheck_cpu_init_clear_banks(); + __mcheck_cpu_init_prepare_banks(); } static struct syscore_ops mce_syscore_ops = { @@ -2497,7 +2470,7 @@ static void mce_cpu_restart(void *data) if (!mce_available(raw_cpu_ptr(&cpu_info))) return; __mcheck_cpu_init_generic(); - __mcheck_cpu_init_clear_banks(); + __mcheck_cpu_init_prepare_banks(); __mcheck_cpu_init_timer(); } From patchwork Thu Feb 13 16:45:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13973713 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2052.outbound.protection.outlook.com [40.107.220.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DBCF628A2CF; Thu, 13 Feb 2025 16:46:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465193; cv=fail; b=POn1eBMbv+gUdIbTyAFLgL0RvlctWJzEyjyvT+ZXU0Z7iD3JYSk5zk7fecUwRmA/CO8hQ1K8YkP+FxESFQyeQpCy7veaFPFsWeVOZim7+tEJ9myZSiToYlFNQjoFzrwSJ/vgpYTxgKW7OkxyqLFbz46FrNOrBDiBNHirvYsN4YY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465193; c=relaxed/simple; bh=CbODem0pxySjbgKVz7f7ps89LEQVa6P2ejcztv2usRw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=HQqFqJABpOOUE088cSeZVZz6YxHbKA5q/OpqiloxzmzUS65XbvtLChxwbHwuK655/OY5IuCATXymEhjLzA2/QMMN6QjTRGKsGW20IDx8eLUQobkZrZrLbeColEpwIa6mXSu2CJb2QQ6JTl0SS0Cb0+0J4VJovaJhySBDAYZrhwA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=AESW2R9k; arc=fail smtp.client-ip=40.107.220.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="AESW2R9k" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=v6mNLrj5mWJWuY/ashlpuRGWB9BrANrkDJeEcwcdtNVPdOGQy0sVymNFuo0WTfN2qsaXDkIHFumthvAqh7lvbIQDzO5SqquxTiXzDDe2P9rurB+Zpbbs3qg0+9/u53noaF2LlFuLW7vDQ8iyDst78tDTU91lo1V9z+L5RiP/7aNNh8k+3ak/Njq3bhUdXjh5opZyqB6qyOzkcNt2AqlXqNn0kDguVGxzgWMLtUC/5mlvOmEJjkeMOc2H/+SggysNMk+rI9fYBN2DMqOcLUBfntsDOG7j3dEi9AAPN2wmX9oPY/sQFGNbA0OBDZJTrgqtreUnHzescvr2k5RBsjO0/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=gCw0tGefJPwiRqQfxwHTL8Bw6+qlfuBMsDzZIR1vM6g=; b=NqN2VWZt0qQf/IcknwKSWYUhcRX3OyPM7Cfi00SMoawWSiIaFed6h4jLt/UllHYhTdfWq+u9/omIEkGfskWGlCuIjWw9VzzJAaXfL0Cc3cqQoB8KDcuX9cD3XEGilIQKwzgTcq3sYKZ4vOzXqpA9fLBoZbzQSmeHT+ALnUnWM0HtXOTKqCZ2Ug7MLy9KAd79tVVB6RVDwk/63Sj6F8J8H4P/bA1OMjP7h3d51E+gBVzoDWRKYeR2dV7syTqu8yggIUYkBzbYgbNiZTNILTTAXvCvjpnbpK+ZJwgWZM0/ADiW2B7uVAAPdPgxgJtQve8Gr4i731PeteMRSVOEF1aGug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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 (0) 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=gCw0tGefJPwiRqQfxwHTL8Bw6+qlfuBMsDzZIR1vM6g=; b=AESW2R9kEpjHEyGpnInT8PlNg7FLG57AZ2/r8ujGvn0XXsrJxd38JK/Sd3TN4YG7iecFM3enkQE8nV55qYV4kpDZPGEH5WYinKBcdxDlMxAW4yBLb/eRmrtGNcqESfL7Mr0/ngmuYkrxVyPIvOQP/VztnHeaW4hZW9/OBceEVFw= Received: from DM6PR11CA0036.namprd11.prod.outlook.com (2603:10b6:5:190::49) by LV3PR12MB9186.namprd12.prod.outlook.com (2603:10b6:408:197::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8445.11; Thu, 13 Feb 2025 16:46:28 +0000 Received: from DS1PEPF0001709C.namprd05.prod.outlook.com (2603:10b6:5:190:cafe::82) by DM6PR11CA0036.outlook.office365.com (2603:10b6:5:190::49) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8445.17 via Frontend Transport; Thu, 13 Feb 2025 16:46:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS1PEPF0001709C.mail.protection.outlook.com (10.167.18.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8445.10 via Frontend Transport; Thu, 13 Feb 2025 16:46:28 +0000 Received: from [127.0.1.1] (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.39; Thu, 13 Feb 2025 10:46:26 -0600 From: Yazen Ghannam Date: Thu, 13 Feb 2025 16:45:55 +0000 Subject: [PATCH v2 06/16] x86/mce: Remove __mcheck_cpu_init_early() Precedence: bulk X-Mailing-List: linux-edac@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20250213-wip-mca-updates-v2-6-3636547fe05f@amd.com> References: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> In-Reply-To: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> To: , Tony Luck CC: , , , Yazen Ghannam X-Mailer: b4 0.15-dev-e27d6 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0001709C:EE_|LV3PR12MB9186:EE_ X-MS-Office365-Filtering-Correlation-Id: 732741e3-5b43-4340-8ec7-08dd4c4df62c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|82310400026|1800799024|13003099007; X-Microsoft-Antispam-Message-Info: =?utf-8?q?THnbpPGlnYMAkDGTodewAISJEUtSNi+?= =?utf-8?q?RevmT4rDkTshTDVGHn384I7GiMxlBF4zHMmkj3tftBq8dW2gkuso2qUxwdjUYBFle?= =?utf-8?q?uhZiiLhFipE3sdey5Zr/mcrjXsIhd3/LjWrgm0Wr4+Wo7zMw9em1mj7RyS1+Uo3qa?= =?utf-8?q?ctHpknSU0VeREkNEmH/lUnSYv7cFLvZco0ecu4NUMzgI2nVbK/iyGg1YbXSe4QbyU?= =?utf-8?q?HE1f+OvNjs+Kf0DT9bAyYW0lFKWkl7YbY6osls5MBpWHda5Nf56GiqJ/Vv6AZJ/w1?= =?utf-8?q?tE+ynMWBk79XF9izlH3UQDjzWCI19D++asw8ODlKhysl2hS0rGFg49NEscPNpU8Bn?= =?utf-8?q?R7YsLgQd99mNo8L4b82qKiL5M8I0w2bzSM2Z63g9OHKjVt+YPuc6iQKrxy4sSu1z8?= =?utf-8?q?FhqU0TtJjBauUsypGr2Y6JMqFwcJSauap3oH44EXi5LYzw9UNXG4+78rxYY7K47dj?= =?utf-8?q?ddXtMT3m1RRbBet3AVSMQVAuwX7RwZI2WwDOc6wOftA2dGlvD3fAe67W/IcTUcY+U?= =?utf-8?q?J6klwTalZtVyLPPUTtLPHQyaznVzeGrhl5Z3K0V83Lgn+WFHArkZ6gZjZOByyNLbL?= =?utf-8?q?wj6bUVN+YkqlR5jNwPtQ5LtjIzc5OfbU5nkf5IozobMZwDLT4DxE8QGlo1bYPC+ni?= =?utf-8?q?Qz+q9V4c6pJcq58LWK44OCHTi198j6qurC/mPumr133XCNsnkXSjEqwIlwi9a0PLK?= =?utf-8?q?1wRxqzRW0gYzWcuHxvHFIjE+8xXT1L0JD0U+dCZplwKC/KJHxtf5LI7mUyNcclE0D?= =?utf-8?q?sOSjhTVWBpTzpnurts3HcI4hpGLbTrgas8J+JAg8EuKwZJn7OzWe8TB2DZomOL3E1?= =?utf-8?q?L895kLp2cjH0HvM7YVA8y53hwcutyWnMZTtl9drGzm+1kPdw6eNAoLFvfFlg7uYRN?= =?utf-8?q?0GxrgVFInKOB3g6k3+cK2SdqMDmwGU5KhKDiuqwrZKnd6IKZV9h97FdhdF7lD2V2c?= =?utf-8?q?CWzEAVM8VfR4eUJzS2EdHWS6ceh/b+NlNCoKG6k/BPNWpcDLEbZVz4gEGYUhhXhn5?= =?utf-8?q?7ysMBp4G80/DQknQJL0TN61CGOPae1k8tccSyhf8fOUwPAK5dZxZ1LzcLHSNnQ+/l?= =?utf-8?q?vloHUbbqT5WKFd0foM3lzORCuAsblcGoRYIH6jKzxlNfX5JQeFwtFBxOgOc0TfS4i?= =?utf-8?q?fUsF1Ifi6DX90C15U4M++ZBuxTYTZTfWSWzudWWlIjo4YttaXIeL6mqaO0uNoqOuA?= =?utf-8?q?Jqz9rg5xanKZksFm7GxGLFbl45DIDEZ+K/bviW4IGSLahLpqs5TM4yEcApgkvxqrx?= =?utf-8?q?DrdIL9SWtmWWoCtZnQVtlw1pU7YdWBaCnfmHwu1QpmrUXjFYEKbilVadV6ZxWt0ya?= =?utf-8?q?LXwOg8N4t4AxRxt2aYt2ExYNpnWiJnNj522Ofpk/pJPZHFKWsxm+dQid4IimSJBR4?= =?utf-8?q?7L/DKJVu5Wr82nNNhIvPshEyI5qHgJuaiTLrWPXhCUmVWM7/1TzZyE=3D?= 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:(13230040)(36860700013)(376014)(82310400026)(1800799024)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2025 16:46:28.1692 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 732741e3-5b43-4340-8ec7-08dd4c4df62c 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: DS1PEPF0001709C.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9186 The __mcheck_cpu_init_early() function was introduced so that some vendor-specific features are detected before the first MCA polling event done in __mcheck_cpu_init_generic(). Currently, __mcheck_cpu_init_early() is only used on AMD-based systems and additional code will be needed to support various system configurations. However, the current and future vendor-specific code should be done during vendor init. This keeps all the vendor code in a common location and simplifies the generic init flow. Move all the __mcheck_cpu_init_early() code into mce_amd_feature_init(). Also, move __mcheck_cpu_init_generic() after __mcheck_cpu_init_prepare_banks() so that MCA is enabled after the first MCA polling event. Signed-off-by: Yazen Ghannam --- Notes: Link: https://lore.kernel.org/r/20221206173607.1185907-3-yazen.ghannam@amd.com v1->v2: * New in v2, but based on old patch (see link). * Changed cpu_has() to cpu_feature_enabled(). arch/x86/kernel/cpu/mce/amd.c | 4 ++++ arch/x86/kernel/cpu/mce/core.c | 20 +++----------------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index df8984aac1c6..302a310d0630 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -656,6 +656,10 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c) u32 low = 0, high = 0, address = 0; int offset = -1; + mce_flags.overflow_recov = cpu_feature_enabled(X86_FEATURE_OVERFLOW_RECOV); + mce_flags.succor = cpu_feature_enabled(X86_FEATURE_SUCCOR); + mce_flags.smca = cpu_feature_enabled(X86_FEATURE_SMCA); + mce_flags.amd_threshold = 1; for (bank = 0; bank < this_cpu_read(mce_num_banks); ++bank) { if (mce_flags.smca) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index d85bd861ecca..7fbf1c8291b8 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -2029,19 +2029,6 @@ static bool __mcheck_cpu_ancient_init(struct cpuinfo_x86 *c) return false; } -/* - * Init basic CPU features needed for early decoding of MCEs. - */ -static void __mcheck_cpu_init_early(struct cpuinfo_x86 *c) -{ - if (c->x86_vendor == X86_VENDOR_AMD || c->x86_vendor == X86_VENDOR_HYGON) { - mce_flags.overflow_recov = !!cpu_has(c, X86_FEATURE_OVERFLOW_RECOV); - mce_flags.succor = !!cpu_has(c, X86_FEATURE_SUCCOR); - mce_flags.smca = !!cpu_has(c, X86_FEATURE_SMCA); - mce_flags.amd_threshold = 1; - } -} - static void mce_centaur_feature_init(struct cpuinfo_x86 *c) { struct mca_config *cfg = &mca_cfg; @@ -2281,10 +2268,9 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c) mca_cfg.initialized = 1; - __mcheck_cpu_init_early(c); - __mcheck_cpu_init_generic(); __mcheck_cpu_init_vendor(c); __mcheck_cpu_init_prepare_banks(); + __mcheck_cpu_init_generic(); __mcheck_cpu_setup_timer(); } @@ -2450,9 +2436,9 @@ static void mce_syscore_shutdown(void) */ static void mce_syscore_resume(void) { - __mcheck_cpu_init_generic(); __mcheck_cpu_init_vendor(raw_cpu_ptr(&cpu_info)); __mcheck_cpu_init_prepare_banks(); + __mcheck_cpu_init_generic(); } static struct syscore_ops mce_syscore_ops = { @@ -2469,8 +2455,8 @@ static void mce_cpu_restart(void *data) { if (!mce_available(raw_cpu_ptr(&cpu_info))) return; - __mcheck_cpu_init_generic(); __mcheck_cpu_init_prepare_banks(); + __mcheck_cpu_init_generic(); __mcheck_cpu_init_timer(); } From patchwork Thu Feb 13 16:45:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13973716 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2063.outbound.protection.outlook.com [40.107.92.63]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A761B23A9BE; Thu, 13 Feb 2025 16:46:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465196; cv=fail; b=TatMY4ID0t4XE5h7OJgnhpHXZbcPw8gqhevW/HYapR2R14I/a2kVY3DtL9x4YrmOoY1pGyKwRs7hS7uRQ/GVyrrksl5rX0iv4lXU3Y0cwFnXkxMboFFqFpymsRekzAS9pFnb1YzOyIB78gGhMOlaszTk17VWHn9w0lEAxZWewlM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465196; c=relaxed/simple; bh=ZMaVJofeQCtIhbIJGCB9qyjH0gE/8f/LliKHFgEvrsk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=SUdK0RJL0xvEn79YmB2Z5mB8wihB72L2w8hhzOJl2AWX83lmH/1enDdDSvH2jU1CJKD/h5nuSlYuI2v5FeS4T4p7uEN9xjo8GGKAo7jRh46+RUoeBQKzUX4M7p3KMHQOVfpatW2A/pvmUe2ryvfev1OyYxsx9kYSGuFxLncWOeQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=pgtUBiWP; arc=fail smtp.client-ip=40.107.92.63 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="pgtUBiWP" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aJ7sBGEyNo2RJ6bNYgJxNgiBWgkC5PpDybkfRvUFSgDQHSsJdueyxZY7Ef5FOq2bw+9QInEMsjTlw163s3mWqocf1BB4CCEOWY5Ol4xfOhoVFnBH54rQCH/MQpnrPu9bxg6kkxPVEXzy4NiN7TjjTSVY4XjabclaNR9Dp+Zn13+QzrO0Y+xr72KLFPDTFcDT6LSdouV3XJTixyko2agtD/6MGVSbgQpuOBoFc71Trm21BmbTuqorJreGV0P2HwAWRjb4jRrFf8HMPfSVoEXDva4RjUKFRLKpqWoPAoP981DuAx3AWxkx+mzdlw76+3c0Zl2G4qbmaHmu2GMpEsIB2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=UqroFqd9iQ8bB0UgUzi7j9rf29ZggMOjHIKYPo07e8Y=; b=fJyiCZlwxDtVKyFxol42Bnd7Qst4KmHtS5VTfcOa08qmsYSMiKabVUMdf34BKT5noupGB20Am5It48+tWOMFIvat+/m0vuXHTamu/w26d/Qmd674QLP17D+oYZgB1ogwYRm7Ndnk1qRHn96nOMGytSab0nC7uYYtGMhI2Z6lzVudjmq8xRgpxbzQ2Xc1YYfEhNmdCiGdLP/juWyk/T/B274eCU/qy0Wj1EUjoI7fBaOsu8fRR8mBWRbfts7LogxcgI2O0s5d8hG6j1CZT534hdaw45Qh05wMMwY0M/sNBDl8XJGupijWJhg2WL6F+JeCbAKGwGKZIf5FtHFk/KCxYg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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 (0) 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=UqroFqd9iQ8bB0UgUzi7j9rf29ZggMOjHIKYPo07e8Y=; b=pgtUBiWPgMPWaKvXjmn0/3s+jGthkS1WmCQFmtIfWJMtB0T2r0xKTAGdMVk7IIV6du8AUjUjp+2fTk0dqR5G0hvGAf1Dc/7L5sHpHxeG91VdPo2hUyOe5o57VvuilLhmVpE1KCXC8jAofCQHN8d0ziGUjTpiI0HqSyFfvrI6CG4= Received: from DM6PR11CA0011.namprd11.prod.outlook.com (2603:10b6:5:190::24) by DS0PR12MB7995.namprd12.prod.outlook.com (2603:10b6:8:14e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8422.18; Thu, 13 Feb 2025 16:46:30 +0000 Received: from DS1PEPF0001709C.namprd05.prod.outlook.com (2603:10b6:5:190:cafe::cb) by DM6PR11CA0011.outlook.office365.com (2603:10b6:5:190::24) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8445.13 via Frontend Transport; Thu, 13 Feb 2025 16:46:29 +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 DS1PEPF0001709C.mail.protection.outlook.com (10.167.18.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8445.10 via Frontend Transport; Thu, 13 Feb 2025 16:46:28 +0000 Received: from [127.0.1.1] (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.39; Thu, 13 Feb 2025 10:46:26 -0600 From: Yazen Ghannam Date: Thu, 13 Feb 2025 16:45:56 +0000 Subject: [PATCH v2 07/16] x86/mce: Define BSP-only init Precedence: bulk X-Mailing-List: linux-edac@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20250213-wip-mca-updates-v2-7-3636547fe05f@amd.com> References: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> In-Reply-To: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> To: , Tony Luck CC: , , , Yazen Ghannam X-Mailer: b4 0.15-dev-e27d6 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0001709C:EE_|DS0PR12MB7995:EE_ X-MS-Office365-Filtering-Correlation-Id: f0079933-878e-433a-9d6c-08dd4c4df69c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Lz9+c7WAhse7N7lPE3nOkwmxJMX/ZrL?= =?utf-8?q?Nqp9c7q678sq3DP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ItmeFVX7poMcxKBUODocceRpeEp7PKvD7F8aUVZc4fu9fP98?= =?utf-8?q?CZ0e5oGNIKnqgMwXRwZda+JQv/dHj0wOFYBAcaBtdcSAh1OTLW1dk+yUnivgtTSrO?= =?utf-8?q?IlREiqXh96lvihXyJoO90m25Du0wnwkvyOhNujRuOGK173gZiH+zEnrL0IkyMd+n6?= =?utf-8?q?hOKrxNsan1HWgOWlBPF3qRR0QLrDKp/Q+stHyPmTtPXl+D40liZiHUIXtygbtFzi3?= =?utf-8?q?DwP8J61LZLsSjitXehDdNY+P9cNk/n8BJQ1650aSy/pbKlzc4c/AZRETKogkoQFWF?= =?utf-8?q?4HN0QpQK2nL7fL/8Xf8JxZ2EU6O41Rx9AqK8vT33j1A0ccsecYfP/B10a3XhNgxS6?= =?utf-8?q?iyK0rRs81+etV8hmhQ36mq8eH/1NKuCvm5ZpvHO2nAsBT/32r6R21ViF4j1uBhi+A?= =?utf-8?q?Rb9wgKvByjKds+5q4lBp0q5W9a1sl+Ml1+/MU7nN6CTwU8B1DqjiM6f0S6mjC75fd?= =?utf-8?q?TKDaDna9KtSXyaYuO8wy5sOX9gPwn1Xp4S4+r9c3TaB4ocUN5xKLxU=3D?= 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:(13230040)(376014)(36860700013)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2025 16:46:28.9036 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f0079933-878e-433a-9d6c-08dd4c4df69c 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: DS1PEPF0001709C.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7995 Currently, MCA initialization is executed identically on each CPU as they are brought online. However, a number of MCA initialization tasks only need to be done once. Define a function to collect all 'global' init tasks and call this from the BSP only. Start with CPU features. Signed-off-by: Yazen Ghannam --- Notes: Link: https://lore.kernel.org/r/Y6yQpWtlnFmL04h6@zn.tnic v1->v2: * New in v2. arch/x86/include/asm/mce.h | 2 ++ arch/x86/kernel/cpu/common.c | 1 + arch/x86/kernel/cpu/mce/amd.c | 3 --- arch/x86/kernel/cpu/mce/core.c | 29 ++++++++++++++++++++++------- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h index 36ff81c1b3b1..c98387364d6c 100644 --- a/arch/x86/include/asm/mce.h +++ b/arch/x86/include/asm/mce.h @@ -241,12 +241,14 @@ struct cper_ia_proc_ctx; #ifdef CONFIG_X86_MCE int mcheck_init(void); +void cpu_mca_init(struct cpuinfo_x86 *c); void mcheck_cpu_init(struct cpuinfo_x86 *c); void mcheck_cpu_clear(struct cpuinfo_x86 *c); int apei_smca_report_x86_error(struct cper_ia_proc_ctx *ctx_info, u64 lapic_id); #else static inline int mcheck_init(void) { return 0; } +static inline void cpu_mca_init(struct cpuinfo_x86 *c) {} static inline void mcheck_cpu_init(struct cpuinfo_x86 *c) {} static inline void mcheck_cpu_clear(struct cpuinfo_x86 *c) {} static inline int apei_smca_report_x86_error(struct cper_ia_proc_ctx *ctx_info, diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 76598a93a8fa..b14e2d98b45d 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1649,6 +1649,7 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c) setup_clear_cpu_cap(X86_FEATURE_LA57); detect_nopl(); + cpu_mca_init(c); } void __init init_cpu_devs(void) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index 302a310d0630..a4ef4ff1a7ff 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -656,9 +656,6 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c) u32 low = 0, high = 0, address = 0; int offset = -1; - mce_flags.overflow_recov = cpu_feature_enabled(X86_FEATURE_OVERFLOW_RECOV); - mce_flags.succor = cpu_feature_enabled(X86_FEATURE_SUCCOR); - mce_flags.smca = cpu_feature_enabled(X86_FEATURE_SMCA); mce_flags.amd_threshold = 1; for (bank = 0; bank < this_cpu_read(mce_num_banks); ++bank) { diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 7fbf1c8291b8..f13d3f7ca56e 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -1832,13 +1832,6 @@ static void __mcheck_cpu_cap_init(void) this_cpu_write(mce_num_banks, b); __mcheck_cpu_mce_banks_init(); - - /* Use accurate RIP reporting if available. */ - if ((cap & MCG_EXT_P) && MCG_EXT_CNT(cap) >= 9) - mca_cfg.rip_msr = MSR_IA32_MCG_EIP; - - if (cap & MCG_SER_P) - mca_cfg.ser = 1; } static void __mcheck_cpu_init_generic(void) @@ -2238,6 +2231,28 @@ DEFINE_IDTENTRY_RAW(exc_machine_check) } #endif +/* Called only on the boot CPU. */ +void cpu_mca_init(struct cpuinfo_x86 *c) +{ + u64 cap; + + if (!mce_available(c)) + return; + + mce_flags.overflow_recov = cpu_feature_enabled(X86_FEATURE_OVERFLOW_RECOV); + mce_flags.succor = cpu_feature_enabled(X86_FEATURE_SUCCOR); + mce_flags.smca = cpu_feature_enabled(X86_FEATURE_SMCA); + + rdmsrl(MSR_IA32_MCG_CAP, cap); + + /* Use accurate RIP reporting if available. */ + if ((cap & MCG_EXT_P) && MCG_EXT_CNT(cap) >= 9) + mca_cfg.rip_msr = MSR_IA32_MCG_EIP; + + if (cap & MCG_SER_P) + mca_cfg.ser = 1; +} + /* * Called for each booted CPU to set up machine checks. * Must be called with preempt off: From patchwork Thu Feb 13 16:45:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13973720 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2065.outbound.protection.outlook.com [40.107.92.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69D55245007; Thu, 13 Feb 2025 16:46:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465200; cv=fail; b=TT5JwcqKD4UU3WmTyC+hyEM8jP19XVsFPYZUL7f7505vSLVp5Yg2fBFNyONRBVjhWRvMDc87auapk8XBk8Iu9C1fYOWu311UDdsWdk+7P0DAfNasy1t3wVbOKVHJz28yjeH12zLzkwkVwH/1lyTszQW4aiZLzBHRanr5jGR7EqE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465200; c=relaxed/simple; bh=E8XewbvSwpflzFnxlIW6n3i0hzVm5R30KSj7KbhBB88=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=aQgBnEdzQszqrOyysT5IkPSodX3Bj+W9PwuYaVrlxUrjfLon21Hjukac7VVgejY1t6/Gi7HizR1WRJXc84MOuyp90U8oQwSHKnYT9sgbuW41UcXZgITXzQ57MVZSxuaXjU7yq2c33ZHh/mADa89BJDgfbaVR/WC3bFUgr+WFcOA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=rK76SorC; arc=fail smtp.client-ip=40.107.92.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="rK76SorC" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=w1JnrKVVrE8m4yjt433norUogL31Eyi2/AQGX5b3ZlGlKIn7xMLdIGshHR++yH5SCvq3vOPYR/6CoqHfrsyGNH/T9xCiBC720k7OvC8c3vVaXvaVF5JPhCWGrsTCWV3D13gRhrk8+97PfFDg71BlKk4nzz0vkSd7ZazSwx5BxzK61MFND1GIoHyXlbJ+VMXakMS8PUTwSFQEztIo2rocuzxf0wCZ0TwzF/5SWtXJ37SNy7Nh0bEZREbU2rOvhuUi/sYERZ7CD9ew7XeTuULKEtAafOwRfTyDHIX+raa/PDLvIfvlPWMC4lk6ew7faGCGcOYF4c5SChwDyuwvT3z+kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=u2KfDR94+kX7cHHfHeloLUENsMoJGqbXponq/BC4ZvQ=; b=gB7YrbQz7cr0kK5cOWUUypulGFl36kH7O4+LdSeDXszb9SnEhzsrMZkpG4/nXvjPZ5XnDDgDDs0loaIANg638M8R+UgYxrEBz0Fcz/Firpc5kYGc8kRbar0O3cIP2yxSzJgxXRafp5Tyinkzo78zkFftWCiPvJi7Xp5SPTeY7WvBKy3pLMgyVlKZol6xEaHa/IaDQa3uM15nY+q07CG57B80/UtqmfwsUVXZk8iYjxeo1CJTCuFOlH5GR2fnD+myMQwKY9ROgMwO5irjBkk0hhg8Bktha0d3lGPR2v+7pKisB4w/yaFZSidPeOXSqIxupOmbztpQuRdJwNvHodBwIQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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 (0) 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=u2KfDR94+kX7cHHfHeloLUENsMoJGqbXponq/BC4ZvQ=; b=rK76SorCLQuxsoNhfFNT3HCoXOpIk1G/HKGE8eKFbc9oE4cnbSucp9Ql6jgcOTq0LQ2Om4K6Fx6StyPpgM+I5Gbtdgc8ZnRLqfYa1o7NoKxCCqh8+rssusu93OSQN0OhJBg1Ien+xgYcimnABZZaAo4xF1q8OzbgzM5Re3M7Pb0= Received: from DM6PR11CA0031.namprd11.prod.outlook.com (2603:10b6:5:190::44) by MW4PR12MB7117.namprd12.prod.outlook.com (2603:10b6:303:221::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8422.18; Thu, 13 Feb 2025 16:46:30 +0000 Received: from DS1PEPF0001709C.namprd05.prod.outlook.com (2603:10b6:5:190:cafe::74) by DM6PR11CA0031.outlook.office365.com (2603:10b6:5:190::44) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8445.13 via Frontend Transport; Thu, 13 Feb 2025 16:46:30 +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 DS1PEPF0001709C.mail.protection.outlook.com (10.167.18.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8445.10 via Frontend Transport; Thu, 13 Feb 2025 16:46:30 +0000 Received: from [127.0.1.1] (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.39; Thu, 13 Feb 2025 10:46:27 -0600 From: Yazen Ghannam Date: Thu, 13 Feb 2025 16:45:57 +0000 Subject: [PATCH v2 08/16] x86/mce: Define BSP-only SMCA init Precedence: bulk X-Mailing-List: linux-edac@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20250213-wip-mca-updates-v2-8-3636547fe05f@amd.com> References: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> In-Reply-To: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> To: , Tony Luck CC: , , , Yazen Ghannam X-Mailer: b4 0.15-dev-e27d6 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0001709C:EE_|MW4PR12MB7117:EE_ X-MS-Office365-Filtering-Correlation-Id: 855552c7-ccfe-458b-1b4e-08dd4c4df79e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Ant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RMPm/eJm+oMYnG+1RgbJNhEUetzdLMuKELxlZ5k5xuFQr+uoO8lvp?= =?utf-8?q?VK2x/KCNJwNwlsgK5Ps6x70p57i0SI9lsLHZ0PWf7lxDH+4w3jrIEkjqnl7C03WUK?= =?utf-8?q?hV90f1TSEKKJ7wLHqIdsl2KqASwPF57QUtP9RBXnXsEGrRjbs6uBzReGrX+LrHs1M?= =?utf-8?q?OgRCUrMRcaOrHrh8mATBXCDeqmzni2+9gazp2/ajBjIdiaeJTcHD8ZSdjBAWosZnQ?= =?utf-8?q?oHTV3CdhSTZrpUdGTbpTHyIXHlljZrJkeE/kBFHVWTV13Ghs4F7cvt3KCY/taIoxl?= =?utf-8?q?/ddB8IPvAuG3CURxrpZJBXmwHBzQqaOKGasL5Uw3mcOwRNNd4t7IU1Z0jwwxd/0mr?= =?utf-8?q?7Q6L3Ut4N1IpFGZvGTLfpU/ng1PHuCWOD799ewhhGWj6HyO2LkHjJXk2p6iCk6YwJ?= =?utf-8?q?yeA9j2dEeZPFPbqqbHRBRLuDwLwPLEw3pP6UYGG7gLSPS4lIo71Sz6ymScqU/j8qe?= =?utf-8?q?WximTrWry/AbkdvAlqxnvOFSHMxjhSi1fzbase+WRzEUoK92oJKPGNk6BJDRb5cKS?= =?utf-8?q?hOpX8Pt392SDFrosLICV8+IAKedTVa40niljfph95C196H7TBQ5RkU=3D?= 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:(13230040)(1800799024)(376014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2025 16:46:30.5911 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 855552c7-ccfe-458b-1b4e-08dd4c4df79e 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: DS1PEPF0001709C.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7117 Currently on AMD systems, MCA interrupt handler functions are set during CPU init. However, the functions only need to be set once for the whole system. Assign the handlers only during BSP init. Do so only for SMCA systems to maintain the old behavior for legacy systems. Signed-off-by: Yazen Ghannam --- Notes: Link: https://lore.kernel.org/r/20240604154635.GTZl8222q7WAEVSJKH@fat_crate.local v1->v2: * New in v2. arch/x86/kernel/cpu/mce/amd.c | 6 ++++++ arch/x86/kernel/cpu/mce/core.c | 3 +++ arch/x86/kernel/cpu/mce/internal.h | 2 ++ 3 files changed, 11 insertions(+) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index a4ef4ff1a7ff..bf2b1dc5aaa9 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -687,6 +687,12 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c) deferred_error_interrupt_enable(c); } +void mce_smca_cpu_init(void) +{ + mce_threshold_vector = amd_threshold_interrupt; + deferred_error_int_vector = amd_deferred_error_interrupt; +} + /* * DRAM ECC errors are reported in the Northbridge (bank 4) with * Extended Error Code 8. diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index f13d3f7ca56e..402d7993eb96 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -2243,6 +2243,9 @@ void cpu_mca_init(struct cpuinfo_x86 *c) mce_flags.succor = cpu_feature_enabled(X86_FEATURE_SUCCOR); mce_flags.smca = cpu_feature_enabled(X86_FEATURE_SMCA); + if (mce_flags.smca) + mce_smca_cpu_init(); + rdmsrl(MSR_IA32_MCG_CAP, cap); /* Use accurate RIP reporting if available. */ diff --git a/arch/x86/kernel/cpu/mce/internal.h b/arch/x86/kernel/cpu/mce/internal.h index 231ba8ca4a3e..a4bae8c0cf4c 100644 --- a/arch/x86/kernel/cpu/mce/internal.h +++ b/arch/x86/kernel/cpu/mce/internal.h @@ -293,11 +293,13 @@ static __always_inline void smca_extract_err_addr(struct mce *m) m->addr &= GENMASK_ULL(55, lsb); } +void mce_smca_cpu_init(void); #else static inline void mce_threshold_create_device(unsigned int cpu) { } static inline bool amd_filter_mce(struct mce *m) { return false; } static inline bool amd_mce_usable_address(struct mce *m) { return false; } static inline void smca_extract_err_addr(struct mce *m) { } +static inline void mce_smca_cpu_init(void) {} #endif #ifdef CONFIG_X86_ANCIENT_MCE From patchwork Thu Feb 13 16:45:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13973718 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2067.outbound.protection.outlook.com [40.107.94.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 72AC9241691; Thu, 13 Feb 2025 16:46:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.67 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465198; cv=fail; b=q3qZEpj2VJqfvC0M5FELpaZEqx+eDV/7YXu3dGKpgf5e73TRBb918934P+XuDgvVesQTQlq8ikr2PlfqzJAfyYMVo5gG3UxJkdC74hPuHwAPzb1ql7qpBQGiEH58fIDB1C+n3rY3iMMey1E3eWger4CA1CQMDkGh9XVej9+Dq3M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465198; c=relaxed/simple; bh=dwMPZR/e1oafD83IGQMxP77WYCcZlxdZ+wTfmzcmCqU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=p3fVOEdhj5WpU1EikQgmIaBsFpivDEZ+G0uAfSEqRfMghfGtixDA/hZaOF71lH8AeBCKTjS/VJ0py8BwXj/PAhl09psV/Pts++ufSoSFgeHXzajRqwlpAjygqUo6qwV45iPNhnDcKC5FS+IuxpVMF278lLQO+fLtOg6xMHfAnlk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=UhatMGON; arc=fail smtp.client-ip=40.107.94.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="UhatMGON" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=akv3h1UXIp+bZB3tJB60lfRywqyLREKPVe6NJNzAd6A47BkiKA6OqM33BQicW1U5G+0Wi8Wnblp3fxfdINoiyurFJQziNiKwGON5SqbPv8qxge93Iao/Oht2kLu3OEiW9+bxRpPQNvSe3XClDarTqwTClM2EG+xr5p+pscrxuTZZ4iOIMbCdnIU9PbnmXm1WhaEoE7SdWZfwgeOFr0B9O5vV7uK+bp3zrclWkPy/v2DuVzeYiCp3g/dbr9v9NDZF6dXk2MJqoXGopXB7tJWyovcB0aib122LlXSKGCtnc9XvktrKbNTJuT/z3zpNlFZu26zJD+PKrkh/1jZTNzOUdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=JkcHfxe1npkgEfp57BEy1TQUo+Qi91ZjVAmpdDhMg+A=; b=JxR6g5O7WkH/kDRcNpoZ2ZQw9ehI46ojfXJwZjCVNoGsmSWYhlIG6BiV6M2e0gXrzfYzX3h4FbAQH6TbT/umuTqf8mKJYbys3Ls02cSmkWpXAvQnJb4bYHUhrm3VG4ZNLVnoV0ykWjux8GVG7UrC2zWRFLJ6/oxODHzH2k/9tDovgc5Dtd8kNPCME6XWODnbDPsbqmCbpuCkuz6vDbsRwT1kqAuraemZX93AXeha9N+nXd4nXF4J6z6qTVZ7rgjWRZa9vPhBOSq3tb4z4QQ/yKGQ4P+QYme8qQPmlXdwMHyGoWld7AQthC4Aav3AWP+v05xnuYSkiEpqEMyNHTrrEQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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 (0) 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=JkcHfxe1npkgEfp57BEy1TQUo+Qi91ZjVAmpdDhMg+A=; b=UhatMGONKoYpteCjI18xx94TshbdVOFhHuUfFBjekUGWXTKbhwJNxpLPkTX7XScIz4Dl9JOEm6eiFrg7qtaKud32M9/YaYoQoowEfaY7pLGc6UKUTGMRqZb63nyN54e3UE+98vokf1z9JTEJvClCJTC3o608cZFx/RiJUHj4sfU= Received: from DM6PR11CA0001.namprd11.prod.outlook.com (2603:10b6:5:190::14) by CH0PR12MB8531.namprd12.prod.outlook.com (2603:10b6:610:181::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8445.14; Thu, 13 Feb 2025 16:46:31 +0000 Received: from DS1PEPF0001709C.namprd05.prod.outlook.com (2603:10b6:5:190:cafe::d8) by DM6PR11CA0001.outlook.office365.com (2603:10b6:5:190::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8445.16 via Frontend Transport; Thu, 13 Feb 2025 16:46:31 +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 DS1PEPF0001709C.mail.protection.outlook.com (10.167.18.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8445.10 via Frontend Transport; Thu, 13 Feb 2025 16:46:31 +0000 Received: from [127.0.1.1] (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.39; Thu, 13 Feb 2025 10:46:28 -0600 From: Yazen Ghannam Date: Thu, 13 Feb 2025 16:45:58 +0000 Subject: [PATCH v2 09/16] x86/mce: Do 'UNKNOWN' vendor check early Precedence: bulk X-Mailing-List: linux-edac@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20250213-wip-mca-updates-v2-9-3636547fe05f@amd.com> References: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> In-Reply-To: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> To: , Tony Luck CC: , , , Yazen Ghannam X-Mailer: b4 0.15-dev-e27d6 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0001709C:EE_|CH0PR12MB8531:EE_ X-MS-Office365-Filtering-Correlation-Id: 5c0a8560-4bbc-4baf-b497-08dd4c4df7f8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?U3sPq9CqG78gk7Gn+56hCKSd5tSAwMn?= =?utf-8?q?QySZCVIcy1l+hbzVIWc1lx+D/wf1AEp+UHkgWkGAwOP6FsuzJPvBe79o8JAQ0w7Sx?= =?utf-8?q?ln6vsfdnBIAFcI7CXWRhEvaUbNkpEfMO+SvXLIBIRR5TSrvJRAbd5ylD3pl2Qu6KJ?= =?utf-8?q?xEN/VT4IpqIUXz0O2+MBnws7A4qmS0b2Bk7iRP4FweW8y5bzLUZY9ijMFmHRakGIY?= =?utf-8?q?xkXkdQj8YPdfZpMbb28cUuqvq1YIbOpec7bmaxQUX8Nb0gc9mcxKm0AAz6tpbuJ6b?= =?utf-8?q?462aNlPzwU2h1+Fb+ErAQCzzmbjqkfeYZOyGGH3j0y4TuJz6VeTnlaqSuIeXvVDcK?= =?utf-8?q?yIrT+Km58Reas0eYM+6/oNpIhW11+Df3YyKQe3sTLe2GxbVjro/5B0dte1zAMxhvy?= =?utf-8?q?huQytyQwOrZaoE9nSa8Y22RtHhGDUFVqPa0+dWYyiZAn5xWl45JUjhqQvtXIIm0GJ?= =?utf-8?q?8KMYLA+OOzSK6ErQt72zpSiDo18sAYFAn2wI16bfD8sfh7kXS/pf0w/gE9HG492RM?= =?utf-8?q?QIIjvFuYvEsyds3VywbnJ72hlnQhQSwQL/NB/SL4bNsn+6yIPKdyGpS9irlyROOo7?= =?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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:(13230040)(376014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2025 16:46:31.1692 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5c0a8560-4bbc-4baf-b497-08dd4c4df7f8 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: DS1PEPF0001709C.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB8531 The 'UNKNOWN' vendor check is handled as a quirk that is run on each online CPU. However, all CPUs are expected to have the same vendor. Move the 'UNKNOWN' vendor check to the BSP-only init so it is done early and once. Remove the unnecessary return value from the quirks check. Signed-off-by: Yazen Ghannam --- Notes: v1->v2: * New in v2. arch/x86/kernel/cpu/mce/core.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 402d7993eb96..38db802acde4 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -1974,14 +1974,11 @@ static void apply_quirks_zhaoxin(struct cpuinfo_x86 *c) } /* Add per CPU specific workarounds here */ -static bool __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c) +static void __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c) { struct mca_config *cfg = &mca_cfg; switch (c->x86_vendor) { - case X86_VENDOR_UNKNOWN: - pr_info("unknown CPU type - not enabling MCE support\n"); - return false; case X86_VENDOR_AMD: apply_quirks_amd(c); break; @@ -1997,8 +1994,6 @@ static bool __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c) cfg->monarch_timeout = 0; if (cfg->bootlog != 0) cfg->panic_timeout = 30; - - return true; } static bool __mcheck_cpu_ancient_init(struct cpuinfo_x86 *c) @@ -2239,6 +2234,12 @@ void cpu_mca_init(struct cpuinfo_x86 *c) if (!mce_available(c)) return; + if (c->x86_vendor == X86_VENDOR_UNKNOWN) { + mca_cfg.disabled = 1; + pr_info("unknown CPU type - not enabling MCE support\n"); + return; + } + mce_flags.overflow_recov = cpu_feature_enabled(X86_FEATURE_OVERFLOW_RECOV); mce_flags.succor = cpu_feature_enabled(X86_FEATURE_SUCCOR); mce_flags.smca = cpu_feature_enabled(X86_FEATURE_SMCA); @@ -2273,10 +2274,7 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c) __mcheck_cpu_cap_init(); - if (!__mcheck_cpu_apply_quirks(c)) { - mca_cfg.disabled = 1; - return; - } + __mcheck_cpu_apply_quirks(c); if (!mce_gen_pool_init()) { mca_cfg.disabled = 1; From patchwork Thu Feb 13 16:45:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13973715 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2072.outbound.protection.outlook.com [40.107.101.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4981823A9B5; Thu, 13 Feb 2025 16:46:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465196; cv=fail; b=cefKs4xZNgY5boBdNzQG9c8pEuFMsv9NvTmDRkk6TY5N1Kn/UC+RjJEocP8lx5IYPJPPSMjbGgCl6ZtnTTaoVUkF4pgL6IVPeGFIoIJmpE9EivYLY3mlR3Vj1a7Xe8LibLe9F1/nt6POD0MfzSFohhbcvfTrbQj/n0TNm4Fbsy8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465196; c=relaxed/simple; bh=1gMCTj6IcGdC5u8SPLnwaVsq9WL56JbIv6l4neqkN3A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=ndbN5dY3+uZiS+a6YENsOeyLiX27Vxi/5FjQoDm0NBUjyW3L4Lvr0sDm+irDsfe5rkDc9M6paNJkYaw6BW9r06eqVi8xnTyNnT4kwYxI3CYHjaadm4uaNO9EE1CoENetVgHaI5VaVxf2g+VCzG/4buLYddTQE/Q8H4f08Aj+Ua4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=AAUIv703; arc=fail smtp.client-ip=40.107.101.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="AAUIv703" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yx0FPIlb273Isx6PpqlsVgQVnEjiuGVCXBh4qBqKo3oEOJz1hHTpbA7+CPemBt7VYeuh1Lwv/wweem3csH9MNDgoqUHc74duhH+qLK9xqnGf+iGT4E51fTL9rDKs+XNnuxK4GtOFnCq2kprRdCfc87j3SwrdmMLl3S1wXg7/6vABPJoNKmarCqbHQxZqtV0A5DSYNP8yPtulmYnWE+ZFVXQElNzUrQBS4xcZpn1xrul6E/jL2IDbvOQceEQArnwrW3p2HemPF4Tge3V1c+XoJmGC805tNgJw9sntbCyJyau5iCauk0rFQax5UpUcbkhmcmGRFtn+ygzktNfxBvEBYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=GnWA2jzol4TJBg6ku9OA/4qUZhndXKKl31fScjqJlpo=; b=poL5NYhrLJwSZ/sCkwM0EMyYVC7XEbJtzC1DnrdOVQaeVpwn7lTJlroi3qFVKN5Z2zi/XtdY1ux4NjP5WPrICXCFZOyLfyJGd/NRXqJbBSdAmnWSp3zSfNo/b9uFl52bTQN4MGMQEMrEIv7Np5YJBL6x+aL5sReqYpfRRzdRrR6XyD5ZFqA646CQtSvxH20DdX1TdiHAQxq+Z7vGkF7/HRN32KhOuTg1jpqeL9Fk/PNPB/bAXLZJjvjiGNQpYAe54XTs21e1MDQfBmqtxQGYvRz12iUaD+OfXFGKNvLLBBvAMCIOVvqVO8+Xgl4nCjX7wid0IQ95lM3WmrWrsdrQFA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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 (0) 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=GnWA2jzol4TJBg6ku9OA/4qUZhndXKKl31fScjqJlpo=; b=AAUIv703xdRGk5W/G4yCuPkqxLvc+4L7G36AZBmZSGoSwCq61YoO+ZQarQqq/xU2emsFxa0DiOs5hqfhXgkNJiP3CpNa3L9GoH/9GdPuTRAxBjdWQo4Vvt7d0mo1zgn49kO9haPbgTOl6+qqPQFO22XBKJDkphIrOd9fnj9j6Sc= Received: from DM6PR11CA0011.namprd11.prod.outlook.com (2603:10b6:5:190::24) by IA1PR12MB6532.namprd12.prod.outlook.com (2603:10b6:208:3a3::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8445.15; Thu, 13 Feb 2025 16:46:31 +0000 Received: from DS1PEPF0001709C.namprd05.prod.outlook.com (2603:10b6:5:190:cafe::cb) by DM6PR11CA0011.outlook.office365.com (2603:10b6:5:190::24) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8445.13 via Frontend Transport; Thu, 13 Feb 2025 16:46:31 +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 DS1PEPF0001709C.mail.protection.outlook.com (10.167.18.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8445.10 via Frontend Transport; Thu, 13 Feb 2025 16:46:31 +0000 Received: from [127.0.1.1] (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.39; Thu, 13 Feb 2025 10:46:28 -0600 From: Yazen Ghannam Date: Thu, 13 Feb 2025 16:45:59 +0000 Subject: [PATCH v2 10/16] x86/mce: Separate global and per-CPU quirks Precedence: bulk X-Mailing-List: linux-edac@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20250213-wip-mca-updates-v2-10-3636547fe05f@amd.com> References: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> In-Reply-To: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> To: , Tony Luck CC: , , , Yazen Ghannam X-Mailer: b4 0.15-dev-e27d6 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0001709C:EE_|IA1PR12MB6532:EE_ X-MS-Office365-Filtering-Correlation-Id: 37101b65-6e8b-4645-d8d1-08dd4c4df83d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?q?WTkjmbhCPOIPtYwG9+5zP+IYSW05vay?= =?utf-8?q?SPHWmUJLVK8kzjckwneuP5hWNxE7gyWxsxl1sE9HkQmv4DwnKWQHDUypaCgXC6509?= =?utf-8?q?U8X+TZjQl+9Csp4Vloz7dKJGC+ZIeuOvEJMQVHzXBXCzudxQqOUqECqekZA9skamQ?= =?utf-8?q?XG/MWMsgfgW75LDOhw8dxxZ4yr2r5kySYw+AnZUx7H372J5SEINy1a7hbyBhq6nzw?= =?utf-8?q?2QB44Fmw1NouJh9DJ3Emv1cTvTKh9RLuBk0XN7hhsV78Wf6dyFINMQOtfIFpXTX2l?= =?utf-8?q?srMyWmNgX+UdNZtxYA/wO2YOi9BGKM52kwQO33rjiEFZ9Xk9a4jI/A0to8srowFyM?= =?utf-8?q?tABv3M7ifIQLgLNXD2ukej6YIYt66p1RC7gUEv2qjGZM9cg/IYfQfw6qOhy7jP6v3?= =?utf-8?q?dbuatMw+bKkQQBRGg0EJVIZxzlLLwYXRXGbsrvXyt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DLtKdJ931KieVnkdqgzIUqyxMu3?= =?utf-8?q?gggN/h0yM32TQYBWcNOdR1fone5+sNDmUQXaUSrN/pVcVb6fE8GpyF1ctvNnSOYLv?= =?utf-8?q?CnaXpYB2PIylRs5REN7kSKfZlcjzL9z8BAbShpD0OHeO2O6hl2ZoEY=3D?= 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:(13230040)(376014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2025 16:46:31.6380 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 37101b65-6e8b-4645-d8d1-08dd4c4df83d 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: DS1PEPF0001709C.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6532 Many quirks are global configuration settings and a handful apply to each CPU. Move the per-CPU quirks to vendor init to execute them on each online CPU. Set the global quirks during BSP-only init so they're only executed once and early. Signed-off-by: Yazen Ghannam --- Notes: v1->v2: * New in v2. arch/x86/kernel/cpu/mce/amd.c | 23 +++++++++++++++++++++++ arch/x86/kernel/cpu/mce/core.c | 36 ++---------------------------------- arch/x86/kernel/cpu/mce/intel.c | 15 +++++++++++++++ 3 files changed, 40 insertions(+), 34 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index bf2b1dc5aaa9..c6510415159f 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -649,6 +649,28 @@ static void disable_err_thresholding(struct cpuinfo_x86 *c, unsigned int bank) wrmsrl(MSR_K7_HWCR, hwcr); } +static void amd_apply_quirks(struct cpuinfo_x86 *c) +{ + struct mce_bank *mce_banks = this_cpu_ptr(mce_banks_array); + + /* This should be disabled by the BIOS, but isn't always */ + if (c->x86 == 15 && this_cpu_read(mce_num_banks) > 4) { + /* + * disable GART TBL walk error reporting, which + * trips off incorrectly with the IOMMU & 3ware + * & Cerberus: + */ + clear_bit(10, (unsigned long *)&mce_banks[4].ctl); + } + + /* + * Various K7s with broken bank 0 around. Always disable + * by default. + */ + if (c->x86 == 6 && this_cpu_read(mce_num_banks)) + mce_banks[0].ctl = 0; +} + /* cpu init entry point, called from mce.c with preempt off */ void mce_amd_feature_init(struct cpuinfo_x86 *c) { @@ -656,6 +678,7 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c) u32 low = 0, high = 0, address = 0; int offset = -1; + amd_apply_quirks(c); mce_flags.amd_threshold = 1; for (bank = 0; bank < this_cpu_read(mce_num_banks); ++bank) { diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 38db802acde4..1ea52f6259a4 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -1879,18 +1879,6 @@ static void __mcheck_cpu_init_prepare_banks(void) static void apply_quirks_amd(struct cpuinfo_x86 *c) { - struct mce_bank *mce_banks = this_cpu_ptr(mce_banks_array); - - /* This should be disabled by the BIOS, but isn't always */ - if (c->x86 == 15 && this_cpu_read(mce_num_banks) > 4) { - /* - * disable GART TBL walk error reporting, which - * trips off incorrectly with the IOMMU & 3ware - * & Cerberus: - */ - clear_bit(10, (unsigned long *)&mce_banks[4].ctl); - } - if (c->x86 < 0x11 && mca_cfg.bootlog < 0) { /* * Lots of broken BIOS around that don't clear them @@ -1899,13 +1887,6 @@ static void apply_quirks_amd(struct cpuinfo_x86 *c) mca_cfg.bootlog = 0; } - /* - * Various K7s with broken bank 0 around. Always disable - * by default. - */ - if (c->x86 == 6 && this_cpu_read(mce_num_banks)) - mce_banks[0].ctl = 0; - /* * overflow_recov is supported for F15h Models 00h-0fh * even though we don't have a CPUID bit for it. @@ -1919,23 +1900,10 @@ static void apply_quirks_amd(struct cpuinfo_x86 *c) static void apply_quirks_intel(struct cpuinfo_x86 *c) { - struct mce_bank *mce_banks = this_cpu_ptr(mce_banks_array); - /* Older CPUs (prior to family 6) don't need quirks. */ if (c->x86_vfm < INTEL_PENTIUM_PRO) return; - /* - * SDM documents that on family 6 bank 0 should not be written - * because it aliases to another special BIOS controlled - * register. - * But it's not aliased anymore on model 0x1a+ - * Don't ignore bank 0 completely because there could be a - * valid event later, merely don't write CTL0. - */ - if (c->x86_vfm < INTEL_NEHALEM_EP && this_cpu_read(mce_num_banks)) - mce_banks[0].init = false; - /* * All newer Intel systems support MCE broadcasting. Enable * synchronization with a one second timeout. @@ -2255,6 +2223,8 @@ void cpu_mca_init(struct cpuinfo_x86 *c) if (cap & MCG_SER_P) mca_cfg.ser = 1; + + __mcheck_cpu_apply_quirks(c); } /* @@ -2274,8 +2244,6 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c) __mcheck_cpu_cap_init(); - __mcheck_cpu_apply_quirks(c); - if (!mce_gen_pool_init()) { mca_cfg.disabled = 1; pr_emerg("Couldn't allocate MCE records pool!\n"); diff --git a/arch/x86/kernel/cpu/mce/intel.c b/arch/x86/kernel/cpu/mce/intel.c index f863df0ff42c..1a7aaee14991 100644 --- a/arch/x86/kernel/cpu/mce/intel.c +++ b/arch/x86/kernel/cpu/mce/intel.c @@ -468,8 +468,23 @@ static void intel_imc_init(struct cpuinfo_x86 *c) } } +static void intel_apply_quirks(struct cpuinfo_x86 *c) +{ + /* + * SDM documents that on family 6 bank 0 should not be written + * because it aliases to another special BIOS controlled + * register. + * But it's not aliased anymore on model 0x1a+ + * Don't ignore bank 0 completely because there could be a + * valid event later, merely don't write CTL0. + */ + if (c->x86_vfm < INTEL_NEHALEM_EP && this_cpu_read(mce_num_banks)) + this_cpu_ptr(mce_banks_array)[0].init = false; +} + void mce_intel_feature_init(struct cpuinfo_x86 *c) { + intel_apply_quirks(c); intel_init_cmci(); intel_init_lmce(); intel_imc_init(c); From patchwork Thu Feb 13 16:46:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13973717 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2087.outbound.protection.outlook.com [40.107.223.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC48824167A; Thu, 13 Feb 2025 16:46:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465197; cv=fail; b=NPccm1NsblQdLBi/9QxSIPZ+0KPraRkiyiLs7zsQ6/dV4aAXBbRAsYRt6gUNi6GTJMq2H9ZqAdcHa20Ftdo3GhyKpaQndcFVUTBgjPpOQ81oB1/FCCy987G3GY45y41WkmiJVoOkTXaDXLkMwr8sVy46irbuWsn6w+W2kzC5wMI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465197; c=relaxed/simple; bh=JbP71n3S9Shqg2TJB+J7jyPMEuxwUnk3AvjCZ/vZc4k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=crBF283Duqqh0ZqNI2HpNSgJSQRmQmxdmDmv+H0C+f+joOCup1WdYOieNitH0okbj+rFVf0j9GBYQ4d7zS4kJGUhM1NpRdiqE9qXR0wV0AE1heJDzinEo6TojeBP90VbNbSSjMdyaPjlsyHuNFNFjhSAK2xhJ5cNZdqbrNbRcYQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=Ud/VwPhc; arc=fail smtp.client-ip=40.107.223.87 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Ud/VwPhc" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KUj+Nd+M/vP5CeCW3US+n8cf06VR+1SjDF8hI2+ixB6+dgqVrFyOMK3JnlrZuEn1fDKjrcYhB6OFu+rvI3ozsbqtpsAmVa5bvCofgzASFNGPv268/jotQl5HvgJ4E/Jq1yip6M97X7CIHxjZbcRzOoBKzP1WbVHEjfwnVdlG7NZRDOgwWxxlxYitvqIgdTPcfe6CotDbGY+OLRYw7TfdOVyJES9xG0DZj+bMRYb2dqlMK8xPEbkIwMzVeUmio0UxlrFVcIHgwg4CB7jDTUPTX2FhPnRg5M+irYy/fqygJVBMpWwPewNGEXTJL6EQlZvOyVMriyzjCYdqQNKdXszQlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=My3mE0qKd1QNNNmBGBLGtywRlzLm+Yx6cSd2tHQUta8=; b=NU/F3uVCmX33/GBjY7LNOs6qsMXRdAaHyXh+GM04JaAPt4G6Tp4KYl0F2Z0Qh4QyWicHSuWPkEM5YCFOA9/q1Ys82w22DOTQ7R6kb+SMMMCa/gZJY3aeIAj99l/Zt5iqqUypi0NI+w6wV6Wc2LTCq8MTPOGqiO/ADvTymGWMaj6A88Td/wie49WfKjx7jF8HKRdqdk6FgVfP2PHapdGpOsz7Mqxg+sFHqVNU9JtUiQ2PHbWA3AYxu34m9i4LkzPk8xO1LHW9ixoFv9DpAZIX7yI+qmRLrhaj4MA34+AJZZxjgErM+zJ7t284oUV2jhFJFTepYlhnm79BtCPILje0PA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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 (0) 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=My3mE0qKd1QNNNmBGBLGtywRlzLm+Yx6cSd2tHQUta8=; b=Ud/VwPhcW1cnrWF5nYD7Hl9bZZ77FpC4jUOpKybLq1ssE4pi38SvTPhP1nNGivcTGbPckbmdWaqOH0Ez2TTZ4uezLsEZ76j4Bu0TtJHnja51Wd6AekZ3s4PvBeAT+m8QOf9OJn2EFiEi7hDroqtcF1AM95dLahmENI+W0Tls1XA= Received: from DM6PR11CA0011.namprd11.prod.outlook.com (2603:10b6:5:190::24) by BY5PR12MB4116.namprd12.prod.outlook.com (2603:10b6:a03:210::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8422.18; Thu, 13 Feb 2025 16:46:33 +0000 Received: from DS1PEPF0001709C.namprd05.prod.outlook.com (2603:10b6:5:190:cafe::cb) by DM6PR11CA0011.outlook.office365.com (2603:10b6:5:190::24) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8445.13 via Frontend Transport; Thu, 13 Feb 2025 16:46:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS1PEPF0001709C.mail.protection.outlook.com (10.167.18.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8445.10 via Frontend Transport; Thu, 13 Feb 2025 16:46:32 +0000 Received: from [127.0.1.1] (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.39; Thu, 13 Feb 2025 10:46:29 -0600 From: Yazen Ghannam Date: Thu, 13 Feb 2025 16:46:00 +0000 Subject: [PATCH v2 11/16] x86/mce: Move machine_check_poll() status checks to helper functions Precedence: bulk X-Mailing-List: linux-edac@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20250213-wip-mca-updates-v2-11-3636547fe05f@amd.com> References: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> In-Reply-To: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> To: , Tony Luck CC: , , , Yazen Ghannam X-Mailer: b4 0.15-dev-e27d6 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0001709C:EE_|BY5PR12MB4116:EE_ X-MS-Office365-Filtering-Correlation-Id: fc2bc03e-2809-4655-f8d3-08dd4c4df8df X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?q?pBJ0cQnKsHkYuXLPDzlUXARmEsv//lA?= =?utf-8?q?ftzig/zWZxri8XC5TeHJyZLP2lxqL5tlanH7KKYd7oqnAs5QWfPPcCXSByH5D6cae?= =?utf-8?q?FGGL7AlNVS1kEjnQML3afUWRQyCyiu7KE2G7V0NU+yZ7hjbOFHMAaMTOeJnBdN4rt?= =?utf-8?q?L7WOVcQJuxYlKPhcvpgrYjqZcBjoil3O21FWBxjQGfqJirAkLVQG6dY3W/GVpBmz4?= =?utf-8?q?WeSmJuDva5QLvIr71BXgzolVWO2yy8Tk9N0ixo9s4EC+vGrMO4uLuNDPaE4nT1lXm?= =?utf-8?q?pe+NFxjamBVKfD1SbjeC9q8sd9tT4b/XgyGnezUE2EiKDR+wuUVMffGu8jCV1+NNW?= =?utf-8?q?mK9ZIVeFwRbUDNxVZBQSSgG/SSVo/WD9htx6HEj56NVrDEsUsgj+My9OYuV/pMHQP?= =?utf-8?q?EH6xLSyFEeFHHT2V6GEnlsqDs17d/97xV1tKf0P+wG+ryE9mEfa6wR2ki/kmheGrg?= =?utf-8?q?chLxeOex0/KQAkwGV3uxVUMCxSTwRvEInzOu0yAxccyVIY6QbgODmaFfHxSabHhYQ?= =?utf-8?q?1AhJFeMM8vdxLuEnm95/2E/pHMJpk+jJZvR7f7tK/Sk8AulCec9SsTiXrNvX9LbO6?= =?utf-8?q?ilMovDimTu50gD5BxJhXB3jm/DQyXssy8zqD40W2NOct+C+xV3RTH1nxr+QQH85IA?= =?utf-8?q?p58aPCdnK48TC1zzGmpoMsbmSL1uLy8YVBlaCDMiEri1vkiA+fzMfmGxXrOIuQGiQ?= =?utf-8?q?RwAo+51rtmYTrerqTJhIWCjTX27yWBW23uoG3fq/+h9nCFumlQq0zrkx7wuX8peFg?= =?utf-8?q?Y1JecoWCRsv+rsq1U4/Pj65ff+L5bj9PXIjJe5Uo0joyJaqJVOmP6fNKD8gxiDutr?= =?utf-8?q?LXtGJONZiQc5L4+Xnz1cBqMZ6fmzM7dGW8WztwhJrOo6sh/HHPTkhK/Uge9anPSgq?= =?utf-8?q?VpH/VIcRi0rtoBI/gQII1gi8R1kJdpDYVj5qefLusOIhM1gfKTWs1lCAG8AuyN2zO?= =?utf-8?q?MWxyo5pCAValBTztwLAmwo36JGwSru9EJKKIXJneY2kgsFwprln4kIgcaY59Dw0sA?= =?utf-8?q?mB821bUYnpUT4ryt6uDfhkgAF99DLZNmhTbhLPTmoloSWT41g8Ea4PzRXgG7vFQsd?= =?utf-8?q?TzYdoPyWX7qbnrKumXd0Mt/90KWJN3sTnWs1w+463W3iajgs7KjPz/MfqTtBTF0oT?= =?utf-8?q?k8yQbpE6WRwdM2DAAR+huaq+6DhRpfGj3QsWMn4j5/vDez+jTnHSxhgLvhmNVvsNA?= =?utf-8?q?waP5JkR4+2N+UP9Py/BhjDlRzVYTSDkPDtu7ZrE5uCAzbccCojR7i38mHVJ++Nf9B?= =?utf-8?q?R6aeidzwpIRR+64yj5wFLvLyhBA87zIQsriCt0mVjxxeJXSH3G34ozFAdGXDQjvN1?= =?utf-8?q?Tn4hObEGsZnigzjq6HGPYMAaXSaZJAK7gvdTh8Dufbc3hAWnZGxrtEqABKYoTFxtp?= =?utf-8?q?KY0PPqM6gHbM+T+FR4g0L1osI83GwIbLGetkJ0raNCWBSqovjJwh5A=3D?= 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:(13230040)(82310400026)(36860700013)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2025 16:46:32.6536 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fc2bc03e-2809-4655-f8d3-08dd4c4df8df 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: DS1PEPF0001709C.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4116 There are a number of generic and vendor-specific status checks in machine_check_poll(). These are used to determine if an error should be skipped. Move these into helper functions. Future vendor-specific checks will be added to the helpers. Signed-off-by: Yazen Ghannam --- Notes: Link: https://lore.kernel.org/r/20240523155641.2805411-5-yazen.ghannam@amd.com v1->v2: * Change log_poll_error() to should_log_poll_error(). * Keep code comment. arch/x86/kernel/cpu/mce/core.c | 88 +++++++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 40 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 1ea52f6259a4..372e8b078dd5 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -692,6 +692,52 @@ static noinstr void mce_read_aux(struct mce_hw_err *err, int i) DEFINE_PER_CPU(unsigned, mce_poll_count); +/* + * Newer Intel systems that support software error + * recovery need to make additional checks. Other + * CPUs should skip over uncorrected errors, but log + * everything else. + */ +static bool ser_should_log_poll_error(struct mce *m) +{ + /* Log "not enabled" (speculative) errors */ + if (!(m->status & MCI_STATUS_EN)) + return true; + + /* + * Log UCNA (SDM: 15.6.3 "UCR Error Classification") + * UC == 1 && PCC == 0 && S == 0 + */ + if (!(m->status & MCI_STATUS_PCC) && !(m->status & MCI_STATUS_S)) + return true; + + return false; +} + +static bool should_log_poll_error(enum mcp_flags flags, struct mce_hw_err *err) +{ + struct mce *m = &err->m; + + /* If this entry is not valid, ignore it. */ + if (!(m->status & MCI_STATUS_VAL)) + return false; + + /* + * If we are logging everything (at CPU online) or this + * is a corrected error, then we must log it. + */ + if ((flags & MCP_UC) || !(m->status & MCI_STATUS_UC)) + return true; + + if (mca_cfg.ser) + return ser_should_log_poll_error(m); + + if (m->status & MCI_STATUS_UC) + return false; + + return true; +} + /* * Poll for corrected events or events that happened before reset. * Those are just logged through /dev/mcelog. @@ -743,48 +789,10 @@ void machine_check_poll(enum mcp_flags flags, mce_banks_t *b) if (!mca_cfg.cmci_disabled) mce_track_storm(m); - /* If this entry is not valid, ignore it */ - if (!(m->status & MCI_STATUS_VAL)) + /* Verify that the error should be logged based on hardware conditions. */ + if (!should_log_poll_error(flags, &err)) continue; - /* - * If we are logging everything (at CPU online) or this - * is a corrected error, then we must log it. - */ - if ((flags & MCP_UC) || !(m->status & MCI_STATUS_UC)) - goto log_it; - - /* - * Newer Intel systems that support software error - * recovery need to make additional checks. Other - * CPUs should skip over uncorrected errors, but log - * everything else. - */ - if (!mca_cfg.ser) { - if (m->status & MCI_STATUS_UC) - continue; - goto log_it; - } - - /* Log "not enabled" (speculative) errors */ - if (!(m->status & MCI_STATUS_EN)) - goto log_it; - - /* - * Log UCNA (SDM: 15.6.3 "UCR Error Classification") - * UC == 1 && PCC == 0 && S == 0 - */ - if (!(m->status & MCI_STATUS_PCC) && !(m->status & MCI_STATUS_S)) - goto log_it; - - /* - * Skip anything else. Presumption is that our read of this - * bank is racing with a machine check. Leave the log alone - * for do_machine_check() to deal with it. - */ - continue; - -log_it: mce_read_aux(&err, i); m->severity = mce_severity(m, NULL, NULL, false); /* From patchwork Thu Feb 13 16:46:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13973719 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2040.outbound.protection.outlook.com [40.107.93.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C762824292B; Thu, 13 Feb 2025 16:46:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465199; cv=fail; b=OgEq6L5ym6C3SwB4v46ck4b77On91w+49/XVoMm3hRkXePQbrihx1AUHjq+koQax1eJ3m/QP/uPnVXYvea6EYmPM8FRd1H5wgH4jFs4ocUx5ANoYhIjFWg7NSDI70OCRBGrQkkl0qgiM7rr8wPS8kjHhQkxZvxV67t9YkdFUNjU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465199; c=relaxed/simple; bh=Oc3sZTZcItnOf74w4ziaquJBycLuzeX6V7oIK6O5oPw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=j2JYOSEpzd6v+B/CEdFI/TGIJskwWGKMqheF0kt5+jC3/I/t0LjNywXWvmC2EDWLcJH4aW77uKK5exlCcmMZwMBN6X6jEGmId89xwPY8QtTrBBYKKAlZ7cHjeqqYRRIsWumbg/wflsuomRhlEgOBWh9VQBwNsbV/udYONUe5TBE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=V/VfGl5g; arc=fail smtp.client-ip=40.107.93.40 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="V/VfGl5g" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MGaR5K+s9M4EMuAaZu3RxbgwlWu5I3887NZCC3ampTXgEDU++q8JL4KmEOaD4FdshmWhK4iurFIEsqyrS66v00peejxkMv5ubI5+whQcIbvNuTXqkQKajz3v82T3JcGIRmnbcQe92GLpggoT6+ZTw78StSkNc5U3wPYcgnY9rTqRj5LhXGiPU6o5b/ehRwiaLvaIT2H8oWWPWy8swcEGRs89RnrPEckDhG9f0ed1JOXF0VmeUxDG95oAnGLfyjNxe9g7sgxKESJAqKuinJ39rU9mnjD8BWm/LPHDDhvgUc++iN9gmHGYkvq3cC/lV7fG4z/Life2vaHs/RmwNtyMuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=glv6YjE8HWaEgjLLluJ6j68SMqnWOWLpLxfYH75JTOI=; b=CHna2w9H7Xljt/IdXAFWJfWPTQ8GZEDTl+R6ezjWX7fD9OvKVVy1kFuBj9bcGEz+UBPNiFDxsbNkKvwgk8jWA8yHaiuEa9G0lYcdfn/C9Hg71pyYjduN2343UA9k4W5D62ycu5PCOCIic8oTWHKXKsFxcJpOXQ7nKLMHm2b5B9zXXfHi+93D0hKvmPvZdPdtab1gdIwzhr05lk7LJB5jdGzYFqibarDrt9kCNTyfQooFXcFA2DmcVIiUyfmoAZXn7HRrifa5dHrkGyKSzEUUjIBAUj6aJlo9ki/y7zjudM2rwr8g4k8recOuCElAoiM9/vg140ZRcutXfA/bno9U2Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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 (0) 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=glv6YjE8HWaEgjLLluJ6j68SMqnWOWLpLxfYH75JTOI=; b=V/VfGl5gszubycdpK8bjHM5Gx/9h769i4BzS/f8+LU/9OtUwMAQXU9t35mmzLCfw/Nj46bJSs+Fg/KIW33NKnqSLuBGdi6ssf5bhEGvO5MpSz1dxHr8LGAsLqjUAp1hGUeKM2+V7Ui+vV+UKMKZFWanVPps5xCFuXTRq8D0r8Ik= Received: from DM6PR11CA0030.namprd11.prod.outlook.com (2603:10b6:5:190::43) by CY5PR12MB6382.namprd12.prod.outlook.com (2603:10b6:930:3e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8422.14; Thu, 13 Feb 2025 16:46:33 +0000 Received: from DS1PEPF0001709C.namprd05.prod.outlook.com (2603:10b6:5:190:cafe::79) by DM6PR11CA0030.outlook.office365.com (2603:10b6:5:190::43) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8445.13 via Frontend Transport; Thu, 13 Feb 2025 16:46: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 DS1PEPF0001709C.mail.protection.outlook.com (10.167.18.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8445.10 via Frontend Transport; Thu, 13 Feb 2025 16:46:33 +0000 Received: from [127.0.1.1] (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.39; Thu, 13 Feb 2025 10:46:29 -0600 From: Yazen Ghannam Date: Thu, 13 Feb 2025 16:46:01 +0000 Subject: [PATCH v2 12/16] x86/mce: Unify AMD THR handler with MCA Polling Precedence: bulk X-Mailing-List: linux-edac@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20250213-wip-mca-updates-v2-12-3636547fe05f@amd.com> References: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> In-Reply-To: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> To: , Tony Luck CC: , , , Yazen Ghannam X-Mailer: b4 0.15-dev-e27d6 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0001709C:EE_|CY5PR12MB6382:EE_ X-MS-Office365-Filtering-Correlation-Id: 5d063631-947c-4cd4-418c-08dd4c4df96a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?HJAm2yJ15o38GTRNYMfG9Cr08hVhFCn?= =?utf-8?q?Z3FmWZ6gpixdFUJfHtrDlP0W6lFi6Y/til1CzoeiFCoiR+Oip96hjOmnAZIuT9XYi?= =?utf-8?q?6L9V9Uwr4hEB9MZoOhB3sMHrfm7aOj6oM7LGI8DJhyLxtJp0aI1MI12vUSyAE5Hpu?= =?utf-8?q?DZtbDTgglaWU0IKGNVkUFEpyw2sNXSdm2t3vJxKXifbcA4FTVu3qGOpLoCGI9GnaA?= =?utf-8?q?hx3AY2goVrKH1MZV8IjH6xb+cCkk/7d7szbAslYgDEXwVPnD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YBX4TPt?= =?utf-8?q?iqOt4Xcof3EPqXd6ETKA/7wdi4gj3Vf7Qd7tGF2XzdFS5J5Z5GQUDvpNsg/BmgmLD?= =?utf-8?q?crrpHcuH+2y2vHlbcRL0D0WnjIszJRWoe5xxluPfIQf9V5BBUmh43Dvyg4TGxJHqz?= =?utf-8?q?GwRMH5zrYF3gZbw8vc/3RJ5jhECyP7ToMi3PsFAKNvBrf7NgQcWFR4XEqZHMjCeLH?= =?utf-8?q?V7QfNDY2CiDAKg4N6Py46m3Pg1j/+bix3KqT7Ojr+pQwpe1keOam/qhUnKKxKftgc?= =?utf-8?q?zsdyALPIbYpAS/Yh/CFAY+Tut3+CamAFSnq+03Z6sCiWTZXER8uT4Q=3D?= 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:(13230040)(1800799024)(36860700013)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2025 16:46:33.6067 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5d063631-947c-4cd4-418c-08dd4c4df96a 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: DS1PEPF0001709C.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6382 AMD systems optionally support an MCA thresholding interrupt. The interrupt should be used as another signal to trigger MCA polling. This is similar to how the Intel Corrected Machine Check interrupt (CMCI) is handled. AMD MCA thresholding is managed using the MCA_MISC registers within an MCA bank. The OS will need to modify the hardware error count field in order to reset the threshold limit and rearm the interrupt. Management of the MCA_MISC register should be done as a follow up to the basic MCA polling flow. It should not be the main focus of the interrupt handler. Furthermore, future systems will have the ability to send an MCA thresholding interrupt to the OS even when the OS does not manage the feature, i.e. MCA_MISC registers are Read-as-Zero/Locked. Call the common MCA polling function when handling the MCA thresholding interrupt. This will allow the OS to find any valid errors whether or not the MCA thresholding feature is OS-managed. Also, this allows the common MCA polling options and kernel parameters to apply to AMD systems. Add a callback to the MCA polling function to check and reset any threshold blocks that have reached their threshold limit. Signed-off-by: Yazen Ghannam Reviewed-by: Qiuxu Zhuo --- Notes: Link: https://lore.kernel.org/r/20240523155641.2805411-7-yazen.ghannam@amd.com v1->v2: * Start collecting per-CPU items in a struct. * Keep and use mce_flags.amd_threshold. arch/x86/kernel/cpu/mce/amd.c | 49 ++++++++++++++++---------------------- arch/x86/kernel/cpu/mce/core.c | 3 +++ arch/x86/kernel/cpu/mce/internal.h | 2 ++ 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index c6510415159f..5e491dbdeecc 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -54,6 +54,12 @@ static bool thresholding_irq_en; +struct mce_amd_cpu_data { + mce_banks_t thr_intr_banks; +}; + +static DEFINE_PER_CPU_READ_MOSTLY(struct mce_amd_cpu_data, mce_amd_data); + static const char * const th_names[] = { "load_store", "insn_fetch", @@ -559,6 +565,7 @@ prepare_threshold_block(unsigned int bank, unsigned int block, u32 addr, if (!b.interrupt_capable) goto done; + __set_bit(bank, this_cpu_ptr(&mce_amd_data)->thr_intr_banks); b.interrupt_enable = 1; if (!mce_flags.smca) { @@ -898,12 +905,7 @@ static void amd_deferred_error_interrupt(void) log_error_deferred(bank); } -static void log_error_thresholding(unsigned int bank, u64 misc) -{ - _log_error_deferred(bank, misc); -} - -static void log_and_reset_block(struct threshold_block *block) +static void reset_block(struct threshold_block *block) { struct thresh_restart tr; u32 low = 0, high = 0; @@ -917,23 +919,14 @@ static void log_and_reset_block(struct threshold_block *block) if (!(high & MASK_OVERFLOW_HI)) return; - /* Log the MCE which caused the threshold event. */ - log_error_thresholding(block->bank, ((u64)high << 32) | low); - - /* Reset threshold block after logging error. */ memset(&tr, 0, sizeof(tr)); tr.b = block; threshold_restart_bank(&tr); } -/* - * Threshold interrupt handler will service THRESHOLD_APIC_VECTOR. The interrupt - * goes off when error_count reaches threshold_limit. - */ -static void amd_threshold_interrupt(void) +void amd_reset_thr_limit(unsigned int bank) { - struct threshold_bank **bp = this_cpu_read(threshold_banks), *thr_bank; - unsigned int bank, cpu = smp_processor_id(); + struct threshold_bank **bp = this_cpu_read(threshold_banks); struct threshold_block *block, *tmp; /* @@ -941,20 +934,20 @@ static void amd_threshold_interrupt(void) * handler is installed at boot time, but on a hotplug event the * interrupt might fire before the data has been initialized. */ - if (!bp) + if (!bp || !bp[bank]) return; - for (bank = 0; bank < this_cpu_read(mce_num_banks); ++bank) { - if (!(per_cpu(bank_map, cpu) & BIT_ULL(bank))) - continue; - - thr_bank = bp[bank]; - if (!thr_bank) - continue; + list_for_each_entry_safe(block, tmp, &bp[bank]->miscj, miscj) + reset_block(block); +} - list_for_each_entry_safe(block, tmp, &thr_bank->miscj, miscj) - log_and_reset_block(block); - } +/* + * Threshold interrupt handler will service THRESHOLD_APIC_VECTOR. The interrupt + * goes off when error_count reaches threshold_limit. + */ +static void amd_threshold_interrupt(void) +{ + machine_check_poll(MCP_TIMESTAMP, &this_cpu_ptr(&mce_amd_data)->thr_intr_banks); } /* diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 372e8b078dd5..b26eb576e413 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -809,6 +809,9 @@ void machine_check_poll(enum mcp_flags flags, mce_banks_t *b) mce_log(&err); clear_it: + if (mce_flags.amd_threshold) + amd_reset_thr_limit(i); + /* * Clear state for this bank. */ diff --git a/arch/x86/kernel/cpu/mce/internal.h b/arch/x86/kernel/cpu/mce/internal.h index a4bae8c0cf4c..fe519acfafcf 100644 --- a/arch/x86/kernel/cpu/mce/internal.h +++ b/arch/x86/kernel/cpu/mce/internal.h @@ -268,6 +268,7 @@ void mce_prep_record_per_cpu(unsigned int cpu, struct mce *m); void mce_threshold_create_device(unsigned int cpu); extern bool amd_filter_mce(struct mce *m); bool amd_mce_usable_address(struct mce *m); +void amd_reset_thr_limit(unsigned int bank); /* * If MCA_CONFIG[McaLsbInStatusSupported] is set, extract ErrAddr in bits @@ -298,6 +299,7 @@ void mce_smca_cpu_init(void); static inline void mce_threshold_create_device(unsigned int cpu) { } static inline bool amd_filter_mce(struct mce *m) { return false; } static inline bool amd_mce_usable_address(struct mce *m) { return false; } +static inline void amd_reset_thr_limit(unsigned int bank) { } static inline void smca_extract_err_addr(struct mce *m) { } static inline void mce_smca_cpu_init(void) {} #endif From patchwork Thu Feb 13 16:46:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13973722 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2089.outbound.protection.outlook.com [40.107.93.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7540A23A9B1; Thu, 13 Feb 2025 16:46:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.89 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465204; cv=fail; b=HN4YLnH67kB5766vwvoYBwJ+9GYPZfVQ4gj6CqwtF8SczS2fXK8EL/iquBSQriEnAUN3fnOiaVKsccHfJf+AnqgQAq8tbVfVPvzcaEOtbEL62LiCgk6htSTC6KSj4P/WXtJJ5BmyvpvbPZPhv1LVu3DRdMshfwoVquC5ZVjEE3k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465204; c=relaxed/simple; bh=pIGouNrBrgQE1IShgio3lOXTbc0eVeztt08HuGL4TfU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=Dvrg+i0vuYTdj/XFCrVQCtwrDkd63H+NoeDywuBBnwmGoDCJLH9jH+T1tXBndwv3gjrw4OZga+TwzE73PUSgWDZOAZ+M51zfCkntSZ/F2ikjqPehtSHkVT38IWYRVJDEzXUEFxrvQ5vCDfltencz/6G5RSqA8QPJQe4U75mDKAk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=koHpa8Mg; arc=fail smtp.client-ip=40.107.93.89 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="koHpa8Mg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=n6MHYnEj3Ynykw/fcTTaMcqEeVgfpuQgem9xrQzwXBOnauziJOG6S2CPfvydHPTdXo0e+p4l5Frh4p+WACyrbHWqRjC4OflbKiLFcBNRm424IC/6CfXNvt4x2JFoe704kP9CcJ7rjid8vl8Y6zb2J42BIN5Bv7HvRPfrmhGeY0D29+dZJ6a1Z+2iY21lCaxaJw1F7ELKL80UbUMRcqi8mTead+JepvhjXFgpKwMGBK4Vfme6muxeJvHgLIWrdDWB5Bi6jn2uyIqfhB/SEJBPR09Jf4MukMzNFdIunWh2w/wVCQacOz9mJB0mdojDe+fn7IJYOxo6GkiEMAhZsBIPjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=aL/eoI9gdvAHWIyFSQ63X8BBFGzAWEk43yIz3N+OEIo=; b=FSUiiSGFUCaIuAOgDayGl6laLysxlRoNMlIjIGoJnFgBbGI+xWhNK7Y2jobx5/oJfAyNKALC6a+SvIFcB6HEmVZA8aowmf/cBF9E1gRn2Gt/AP4nOGALtMtWxYsjekJArVLoWz8xQBkZmCSFVgAGkC1Zsv6CtYD1ndBCP3s6/8B0+QRDIX7BpbRItFdb+ash1qvmHHfL++D3SeRIUFQQcG+pQWHJZ4iW/dym9ZhgzkPkDQHaSvbFmaszQulnUt/5/wBKhg4t0RtzvyDhwA9y8KBkPK/EIYdX95rm4DIqLP3e25P8D/MbeoCT/TrbfCPXzx+2TBeTIKTFPiPBGZC/gw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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 (0) 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=aL/eoI9gdvAHWIyFSQ63X8BBFGzAWEk43yIz3N+OEIo=; b=koHpa8Mgx4FwFFyK1bIxVxSlZAup6NxldwHVs0Vv60auuXQQ+Vkkv8wV8enYXkmKp+VhN4NnecajvrC2MkJuibe2dqhZ94p/Zdavyq5zq31h1JVVDxIO8HqlUoC0IBtlKGimbtdkJsKAsKVxcITycXMXJHBZyf3+pWrLpBnHZCI= Received: from DM6PR11CA0021.namprd11.prod.outlook.com (2603:10b6:5:190::34) by PH8PR12MB7207.namprd12.prod.outlook.com (2603:10b6:510:225::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8445.14; Thu, 13 Feb 2025 16:46:36 +0000 Received: from DS1PEPF0001709C.namprd05.prod.outlook.com (2603:10b6:5:190:cafe::84) by DM6PR11CA0021.outlook.office365.com (2603:10b6:5:190::34) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8445.13 via Frontend Transport; Thu, 13 Feb 2025 16:46:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS1PEPF0001709C.mail.protection.outlook.com (10.167.18.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8445.10 via Frontend Transport; Thu, 13 Feb 2025 16:46:35 +0000 Received: from [127.0.1.1] (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.39; Thu, 13 Feb 2025 10:46:30 -0600 From: Yazen Ghannam Date: Thu, 13 Feb 2025 16:46:02 +0000 Subject: [PATCH v2 13/16] x86/mce: Unify AMD DFR handler with MCA Polling Precedence: bulk X-Mailing-List: linux-edac@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20250213-wip-mca-updates-v2-13-3636547fe05f@amd.com> References: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> In-Reply-To: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> To: , Tony Luck CC: , , , Yazen Ghannam X-Mailer: b4 0.15-dev-e27d6 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0001709C:EE_|PH8PR12MB7207:EE_ X-MS-Office365-Filtering-Correlation-Id: ac5bb5b7-8aec-4e77-375d-08dd4c4dfa43 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|1800799024|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?aoGKUdwm0rIWTOghv8y+n7VIrLYQ4e1?= =?utf-8?q?ysj0X3Ds5MMX3URBAaCyalDQ/Yj9InbxlOuGFK6e+oqHYvggS2e0Zg1wbAITxk0GH?= =?utf-8?q?m5rzNC2YCN+C5ajLeXk2uC0lYi17HQd+FfJpxF/9WvE6F3atOCPxQTWhGfNqajR72?= =?utf-8?q?ttThHt+WBEogkxVFXc/ln3AfnOpOZrOLLDhoIXZzzRRlqo6hh8o/jghUzUpM/hYNs?= =?utf-8?q?De/GepNdcH2lYeYErkvYFlaCrV3ZvDSn6Bz6ZXG7FG0Uy+vAr5PahD4hE2baqf/CH?= =?utf-8?q?RQdwUcq/5LRvUm4poURy+NYa6fIUahOVBMmKkTV1bUnCfVPUcn9AkvvBgWl7M3zFx?= =?utf-8?q?60D2Rw1kZrB691WDVjlIdUoYQQNAclh1ETx1+gVDRkEWhbJg4BEEPQ0E+zOJQDnQn?= =?utf-8?q?QzGd/dqdjG+OeHyeZxNMY8eznC/eUhGwsn5wimC6qL6wyJSGGFtt+X5dgTdaa98ex?= =?utf-8?q?BwmJlXpl262gJ51MFzpZfyTf+Li6D7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DA/VPsUh8A/ZitWeW?= =?utf-8?q?C8ohW+2wYN5RvuXcCLIoRRtxPd41d8PdLuJ6iCWK1ZXW+9Ac/9ch9s=3D?= 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:(13230040)(82310400026)(36860700013)(1800799024)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2025 16:46:35.0286 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ac5bb5b7-8aec-4e77-375d-08dd4c4dfa43 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: DS1PEPF0001709C.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7207 AMD systems optionally support a deferred error interrupt. The interrupt should be used as another signal to trigger MCA polling. This is similar to how other MCA interrupts are handled. Deferred errors do not require any special handling related to the interrupt, e.g. resetting or rearming the interrupt, etc. However, Scalable MCA systems include a pair of registers, MCA_DESTAT and MCA_DEADDR, that should be checked for valid errors. This check should be done whenever MCA registers are polled. Currently, the deferred error interrupt does this check, but the MCA polling function does not. Call the MCA polling function when handling the deferred error interrupt. This keeps all "polling" cases in a common function. Call the polling function only for banks that have the deferred error interrupt enabled. Add an SMCA status check helper. This will do the same status check and register clearing that the interrupt handler has done. And it extends the common polling flow to find AMD deferred errors. Remove old code whose functionality is already covered in the common MCA code. Signed-off-by: Yazen Ghannam --- Notes: Link: https://lore.kernel.org/r/20240523155641.2805411-8-yazen.ghannam@amd.com v1->v2: * Keep code comment. * Log directly from helper function rather than pass values. arch/x86/kernel/cpu/mce/amd.c | 103 ++--------------------------------------- arch/x86/kernel/cpu/mce/core.c | 58 +++++++++++++++++++++++ 2 files changed, 63 insertions(+), 98 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index 5e491dbdeecc..5f547f5b3de0 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -56,6 +56,7 @@ static bool thresholding_irq_en; struct mce_amd_cpu_data { mce_banks_t thr_intr_banks; + mce_banks_t dfr_intr_banks; }; static DEFINE_PER_CPU_READ_MOSTLY(struct mce_amd_cpu_data, mce_amd_data); @@ -300,8 +301,10 @@ static void smca_configure(unsigned int bank, unsigned int cpu) * APIC based interrupt. First, check that no interrupt has been * set. */ - if ((low & BIT(5)) && !((high >> 5) & 0x3)) + if ((low & BIT(5)) && !((high >> 5) & 0x3)) { + __set_bit(bank, this_cpu_ptr(&mce_amd_data)->dfr_intr_banks); high |= BIT(5); + } this_cpu_ptr(mce_banks_array)[bank].lsb_in_status = !!(low & BIT(8)); @@ -794,37 +797,6 @@ bool amd_mce_usable_address(struct mce *m) return false; } -static void __log_error(unsigned int bank, u64 status, u64 addr, u64 misc) -{ - struct mce_hw_err err; - struct mce *m = &err.m; - - mce_prep_record(&err); - - m->status = status; - m->misc = misc; - m->bank = bank; - m->tsc = rdtsc(); - - if (m->status & MCI_STATUS_ADDRV) { - m->addr = addr; - - smca_extract_err_addr(m); - } - - if (mce_flags.smca) { - rdmsrl(MSR_AMD64_SMCA_MCx_IPID(bank), m->ipid); - - if (m->status & MCI_STATUS_SYNDV) { - rdmsrl(MSR_AMD64_SMCA_MCx_SYND(bank), m->synd); - rdmsrl(MSR_AMD64_SMCA_MCx_SYND1(bank), err.vendor.amd.synd1); - rdmsrl(MSR_AMD64_SMCA_MCx_SYND2(bank), err.vendor.amd.synd2); - } - } - - mce_log(&err); -} - DEFINE_IDTENTRY_SYSVEC(sysvec_deferred_error) { trace_deferred_error_apic_entry(DEFERRED_ERROR_VECTOR); @@ -834,75 +806,10 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_deferred_error) apic_eoi(); } -/* - * Returns true if the logged error is deferred. False, otherwise. - */ -static inline bool -_log_error_bank(unsigned int bank, u32 msr_stat, u32 msr_addr, u64 misc) -{ - u64 status, addr = 0; - - rdmsrl(msr_stat, status); - if (!(status & MCI_STATUS_VAL)) - return false; - - if (status & MCI_STATUS_ADDRV) - rdmsrl(msr_addr, addr); - - __log_error(bank, status, addr, misc); - - wrmsrl(msr_stat, 0); - - return status & MCI_STATUS_DEFERRED; -} - -static bool _log_error_deferred(unsigned int bank, u32 misc) -{ - if (!_log_error_bank(bank, mca_msr_reg(bank, MCA_STATUS), - mca_msr_reg(bank, MCA_ADDR), misc)) - return false; - - /* - * Non-SMCA systems don't have MCA_DESTAT/MCA_DEADDR registers. - * Return true here to avoid accessing these registers. - */ - if (!mce_flags.smca) - return true; - - /* Clear MCA_DESTAT if the deferred error was logged from MCA_STATUS. */ - wrmsrl(MSR_AMD64_SMCA_MCx_DESTAT(bank), 0); - return true; -} - -/* - * We have three scenarios for checking for Deferred errors: - * - * 1) Non-SMCA systems check MCA_STATUS and log error if found. - * 2) SMCA systems check MCA_STATUS. If error is found then log it and also - * clear MCA_DESTAT. - * 3) SMCA systems check MCA_DESTAT, if error was not found in MCA_STATUS, and - * log it. - */ -static void log_error_deferred(unsigned int bank) -{ - if (_log_error_deferred(bank, 0)) - return; - - /* - * Only deferred errors are logged in MCA_DE{STAT,ADDR} so just check - * for a valid error. - */ - _log_error_bank(bank, MSR_AMD64_SMCA_MCx_DESTAT(bank), - MSR_AMD64_SMCA_MCx_DEADDR(bank), 0); -} - /* APIC interrupt handler for deferred errors */ static void amd_deferred_error_interrupt(void) { - unsigned int bank; - - for (bank = 0; bank < this_cpu_read(mce_num_banks); ++bank) - log_error_deferred(bank); + machine_check_poll(MCP_TIMESTAMP, &this_cpu_ptr(&mce_amd_data)->dfr_intr_banks); } static void reset_block(struct threshold_block *block) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index b26eb576e413..9502e8d3fee7 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -692,6 +692,61 @@ static noinstr void mce_read_aux(struct mce_hw_err *err, int i) DEFINE_PER_CPU(unsigned, mce_poll_count); +/* + * We have three scenarios for checking for Deferred errors: + * + * 1) Non-SMCA systems check MCA_STATUS and log error if found. + * 2) SMCA systems check MCA_STATUS. If error is found then log it and also + * clear MCA_DESTAT. + * 3) SMCA systems check MCA_DESTAT, if error was not found in MCA_STATUS, and + * log it. + */ +static bool smca_should_log_poll_error(enum mcp_flags flags, struct mce_hw_err *err) +{ + struct mce *m = &err->m; + + /* + * If this is a deferred error found in MCA_STATUS, then clear + * the redundant data from the MCA_DESTAT register. + */ + if (m->status & MCI_STATUS_VAL) { + if (m->status & MCI_STATUS_DEFERRED) + mce_wrmsrl(MSR_AMD64_SMCA_MCx_DESTAT(m->bank), 0); + + return true; + } + + /* + * If the MCA_DESTAT register has valid data, then use + * it as the status register. + */ + m->status = mce_rdmsrl(MSR_AMD64_SMCA_MCx_DESTAT(m->bank)); + + if (!(m->status & MCI_STATUS_VAL)) + return false; + + /* + * Gather all relevant data now and log the record before clearing + * the deferred status register. This avoids needing to go back to + * the polling function for these actions. + */ + mce_read_aux(err, m->bank); + + if (m->status & MCI_STATUS_ADDRV) + m->addr = mce_rdmsrl(MSR_AMD64_SMCA_MCx_DEADDR(m->bank)); + + smca_extract_err_addr(m); + m->severity = mce_severity(m, NULL, NULL, false); + + if (flags & MCP_QUEUE_LOG) + mce_gen_pool_add(err); + else + mce_log(err); + + mce_wrmsrl(MSR_AMD64_SMCA_MCx_DESTAT(m->bank), 0); + return false; +} + /* * Newer Intel systems that support software error * recovery need to make additional checks. Other @@ -718,6 +773,9 @@ static bool should_log_poll_error(enum mcp_flags flags, struct mce_hw_err *err) { struct mce *m = &err->m; + if (mce_flags.smca) + return smca_should_log_poll_error(flags, err); + /* If this entry is not valid, ignore it. */ if (!(m->status & MCI_STATUS_VAL)) return false; From patchwork Thu Feb 13 16:46:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13973723 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2085.outbound.protection.outlook.com [40.107.237.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BFB1C24A07F; Thu, 13 Feb 2025 16:46:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465206; cv=fail; b=A1igFubnPstzcn44IGnB2RJpQ05dKSWrJscMMthPVuv7W241/C5gGiNAMgg7XUTFScZ8AgdDDZjDutPYsQDbNM6vjhXxnyWXuFyTBNdDf0DOxqEcevmnMdU/Pag+orEYlmqJNsvRIVz5c6I06j+KzVNd5AMVTslm1sSjVY1ar8k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465206; c=relaxed/simple; bh=BhZZcLFoKQAdMkMmFELmW1N9G9LNSvTgVpjjpFjz69g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=SCOZQrFktJoQPsIjWleyrvntixx7LkznsvyTSpa5E8M/Ft4c4qIELrtyM3Q/ZSxqq6mDhC90Oq6GpEXDj9knZHK3t6cF+f2FhYedS+UyopuSTY0nUXjsfOorkq0dw1248292jfWjZiT8Gzm0EcLymhk7bAUe6H/AjInVKexBLGo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=WuMgT9nm; arc=fail smtp.client-ip=40.107.237.85 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="WuMgT9nm" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KSvMCTDd76a+TZ7eYnIFux2tYlzeaijP3UPeqzHe1mcPWjXpI/HaD6ObVN3vPXwMujvj4dQZmC+6eSgN8wcUgpKIVrXn7SUJoqda0xmqKLkvoK4RU+rJmBwu2yJ88OZkppjtDTHkALnkwbcVj5v83k5L95aGlR4PNaTHaovw50n2i9MLr9o6PuheUQoll+RYvoz18xg+4d78NW2UYiWf7RhyucDVMEr/1VUXaur9cjQ/TQrY4lCi180z2tjDssZJwzCFuHlnpXm7Qd8qWQfYDWiefoH+rcXZ3kBasZv0JGmH0tQSe58QrzQ8dESHm3tDwJMWSmATCvMqdPl/KEjSEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=EdQm7SIHcSe1uXMNVnAAU6u3V2g+InCXjQZGY7+mwu8=; b=ZbWa7Y32j7Mdb9LNn/Wt3Jt25T6p3w/J4xA74PlC8Qk4x7e5UyNJc1IAR2RxOrVjno4/g37bHvY9hZoZkhx6MwBFUH+OXn8RS+Uzewig7zvt/2HsSry8QrDfautWgHOnMmC39qTk6XCsqk71dYv80t+Y7Hvaw/A/U1cZHXe5ptNNgiAbrMAUdZxi/QO1B1eaKLGOuLvt8zM4cG+8iZyxLI36MAWtaIGq+CMKzU27nD+kUr71Lpw+hvtnAd/Af+fZJs6V6eAUHShW0vP4eH38OaJnG9OJ4/x3qporzGLGFx/rbr0uCwWp00IYePMkGP8gaoFN0hz61WC3MjecTS1dmw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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 (0) 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=EdQm7SIHcSe1uXMNVnAAU6u3V2g+InCXjQZGY7+mwu8=; b=WuMgT9nm6/a5OckZqGCsw4v84inN0f62pZ/XounSnUwGxf/5S7gM/Fj8o4Z+wupqpuvfQiehAuvr/GD8oFXOuL0fsjXu2LC8p/b7j9eBtkzoK3Xb7HklE6tWjghZXSFp9pAVMhlG+ESxwJscmV49Gt+AfydGmGMDqdFONSTstOg= Received: from DM6PR11CA0015.namprd11.prod.outlook.com (2603:10b6:5:190::28) by CH2PR12MB9519.namprd12.prod.outlook.com (2603:10b6:610:27c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8445.13; Thu, 13 Feb 2025 16:46:37 +0000 Received: from DS1PEPF0001709C.namprd05.prod.outlook.com (2603:10b6:5:190:cafe::b5) by DM6PR11CA0015.outlook.office365.com (2603:10b6:5:190::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8445.13 via Frontend Transport; Thu, 13 Feb 2025 16:46: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 DS1PEPF0001709C.mail.protection.outlook.com (10.167.18.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8445.10 via Frontend Transport; Thu, 13 Feb 2025 16:46:37 +0000 Received: from [127.0.1.1] (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.39; Thu, 13 Feb 2025 10:46:31 -0600 From: Yazen Ghannam Date: Thu, 13 Feb 2025 16:46:03 +0000 Subject: [PATCH v2 14/16] x86/mce/amd: Enable interrupt vectors once per-CPU on SMCA systems Precedence: bulk X-Mailing-List: linux-edac@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20250213-wip-mca-updates-v2-14-3636547fe05f@amd.com> References: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> In-Reply-To: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> To: , Tony Luck CC: , , , Yazen Ghannam X-Mailer: b4 0.15-dev-e27d6 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0001709C:EE_|CH2PR12MB9519:EE_ X-MS-Office365-Filtering-Correlation-Id: 1fbb56e8-b491-4421-773a-08dd4c4dfb87 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|82310400026|1800799024|13003099007; X-Microsoft-Antispam-Message-Info: =?utf-8?q?q5Xtj8T+B3I7WIeyrMbZX0HszcGSmRD?= =?utf-8?q?uC+TkUM5/TIw/w7MJOFbTpAaTsArd6qDi84IGWxWwXeKrsj+tccvpGs1JOpQHke5i?= =?utf-8?q?GehIb0ffscC0KARUDAbbugWy/Bv13vIn7VPb6vu6ON8U4p4D95ADR/NOtmTOLL8T2?= =?utf-8?q?34obTUdc+UJQ066gko5XCbBgZUnoN9d1EuBeDYL1YhLl25AB2LjCAF2hx/IwyIaWN?= =?utf-8?q?GdkszbDV/toFYoZYjK9bkUpJJauVcD8zQpfCU+C6xenY1EXVagheIwbkFgOoHUkKy?= =?utf-8?q?2Mmkq5DcdMMPYo3UAWE6VpQb4oF4R7W2B9vqjo6h8MdUKzGyZnom88WwuozaL8+mn?= =?utf-8?q?aze2ly+CqxVZpdxCq2ShfioqIgXlYLNMNVFppn0dJOhT/VVoj0ddEQsvGlkCW0a+M?= =?utf-8?q?TauNXtJcDseHLK+lxo6ooJjQG8NvamOfguuTqGul3/kLPoaieR6FEq4ubTa/ND46Z?= =?utf-8?q?t8dzEMrIlwPy9T2fIcHsnTZiJmL5Y6QORjN92G49lKgEb6hbyHn+sqYgh2bl+FB7z?= =?utf-8?q?JoP/i0Pg3m47FxN3v71P1G2e6tQQ8TbWgDYEJMUO9GfjWfMPEBvi33Helm37HUJUC?= =?utf-8?q?XOgJHgGnKTfNMVn1R6G540TR9yAnT2L0Hi2m+T9FPfBVlvSa/8B8P7tV4x9qieBUv?= =?utf-8?q?CwphGzpCA91iupZPo1mKvKyaOUymOZvSWCyuL0K4OTANryMrr4gIsvbzsrvpAi2MX?= =?utf-8?q?HZQy2zNMYzbPK9/XCy3VRkI0+JdA84cMqaqyQDj3nK6WbpsCBWe9RpLih1QylxQah?= =?utf-8?q?i4iXSufS0TRoKTljtgrjAf/m43ukNLRfcBYyfk8tC+4sJqhT4oGP8crNAlLyC2hnK?= =?utf-8?q?iaCNHA/O5zvy6OPyaGY6TFEDSlI7gNjSv4tjccTLsrG40rKN/Dr4xQcGtfosORYr/?= =?utf-8?q?jKyJ49UL/3I8ihpeGiElM3ZNvPLj3BmFT6TvDgQAqhmGrnLgZVmFmZKBwr5Cr5g0q?= =?utf-8?q?IzMtpt4L74PCurqCANKedfBSLq9cVd4REmPz6/94eSVQiQYs3dUxpwN+pCkdaLtCF?= =?utf-8?q?rsZEKur6dPv1qpS++dDV+sOcX6JTtffzTSpvTxQOeODCIz7pU9PFP0t4fu6nGxDKK?= =?utf-8?q?kJbHtOnLqc8edv3lTpJJtVzm3vmujsZWyHW8LBZz9e3DtKsW78ELP0uPaBnqkJmxk?= =?utf-8?q?gd4g9doQdXsUY1pwLXuJIpxlluH07xSorq9gXhUwn+ZPb8eTNN2+tQPSvY3eX6FNg?= =?utf-8?q?3J/7kGi/3i1WF5XDzh2b8UT5gF8XEOL4kt3fKTB0ZnQ8/JbjPB9rGnlT3hn0fU1Qy?= =?utf-8?q?4LZJizpeq7yydSCp998JiBB/p7VPKqJs+Xf4tzQoMMRpgUZDbiYTS24TVC7nspoYF?= =?utf-8?q?8Zw3K2dZBoECQaWLVER3tWaaKTvlkLsmYtudxQMnL445/rKP8lFg7GAOs7Fdl0yDO?= =?utf-8?q?ffy0a+yVCh3iie9bD+x1vB/FA6ZEJWVOO/bDZuh+yZzyF3embc9My4=3D?= 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:(13230040)(376014)(36860700013)(82310400026)(1800799024)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2025 16:46:37.1692 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1fbb56e8-b491-4421-773a-08dd4c4dfb87 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: DS1PEPF0001709C.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB9519 Scalable MCA systems have a per-CPU register that gives the APIC LVT offset for the thresholding and deferred error interrupts. Currently, this register is read once to set up the deferred error interrupt and then read again for each thresholding block. Furthermore, the APIC LVT registers are configured each time, but they only need to be configured once per-CPU. Move the APIC LVT setup to the early part of CPU init, so that the registers are set up once. Also, this ensures that the kernel is ready to service the interrupts before the individual error sources (each MCA bank) are enabled. Apply this change only to SMCA systems to avoid breaking any legacy behavior. The deferred error interrupt is technically advertised by the SUCCOR feature. However, this was first made available on SMCA systems. Therefore, only set up the deferred error interrupt on SMCA systems and simplify the code. Signed-off-by: Yazen Ghannam --- Notes: Link: https://lore.kernel.org/r/20240523155641.2805411-9-yazen.ghannam@amd.com v1->v2: * Use new per-CPU struct. * Don't set up interrupt vectors. arch/x86/kernel/cpu/mce/amd.c | 113 ++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 65 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index 5f547f5b3de0..75a48f484815 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -43,9 +43,6 @@ /* Deferred error settings */ #define MSR_CU_DEF_ERR 0xC0000410 #define MASK_DEF_LVTOFF 0x000000F0 -#define MASK_DEF_INT_TYPE 0x00000006 -#define DEF_LVT_OFF 0x2 -#define DEF_INT_TYPE_APIC 0x2 /* Scalable MCA: */ @@ -57,6 +54,8 @@ static bool thresholding_irq_en; struct mce_amd_cpu_data { mce_banks_t thr_intr_banks; mce_banks_t dfr_intr_banks; + bool thr_intr_en; + bool dfr_intr_en; }; static DEFINE_PER_CPU_READ_MOSTLY(struct mce_amd_cpu_data, mce_amd_data); @@ -271,6 +270,7 @@ void (*deferred_error_int_vector)(void) = default_deferred_error_interrupt; static void smca_configure(unsigned int bank, unsigned int cpu) { + struct mce_amd_cpu_data *data = this_cpu_ptr(&mce_amd_data); u8 *bank_counts = this_cpu_ptr(smca_bank_counts); const struct smca_hwid *s_hwid; unsigned int i, hwid_mcatype; @@ -301,8 +301,8 @@ static void smca_configure(unsigned int bank, unsigned int cpu) * APIC based interrupt. First, check that no interrupt has been * set. */ - if ((low & BIT(5)) && !((high >> 5) & 0x3)) { - __set_bit(bank, this_cpu_ptr(&mce_amd_data)->dfr_intr_banks); + if ((low & BIT(5)) && !((high >> 5) & 0x3) && data->dfr_intr_en) { + __set_bit(bank, data->dfr_intr_banks); high |= BIT(5); } @@ -378,6 +378,14 @@ static bool lvt_off_valid(struct threshold_block *b, int apic, u32 lo, u32 hi) { int msr = (hi & MASK_LVTOFF_HI) >> 20; + /* + * On SMCA CPUs, LVT offset is programmed at a different MSR, and + * the BIOS provides the value. The original field where LVT offset + * was set is reserved. Return early here: + */ + if (mce_flags.smca) + return false; + if (apic < 0) { pr_err(FW_BUG "cpu %d, failed to setup threshold interrupt " "for bank %d, block %d (MSR%08X=0x%x%08x)\n", b->cpu, @@ -386,14 +394,6 @@ static bool lvt_off_valid(struct threshold_block *b, int apic, u32 lo, u32 hi) } if (apic != msr) { - /* - * On SMCA CPUs, LVT offset is programmed at a different MSR, and - * the BIOS provides the value. The original field where LVT offset - * was set is reserved. Return early here: - */ - if (mce_flags.smca) - return false; - pr_err(FW_BUG "cpu %d, invalid threshold interrupt offset %d " "for bank %d, block %d (MSR%08X=0x%x%08x)\n", b->cpu, apic, b->bank, b->block, b->address, hi, lo); @@ -474,41 +474,6 @@ static int setup_APIC_mce_threshold(int reserved, int new) return reserved; } -static int setup_APIC_deferred_error(int reserved, int new) -{ - if (reserved < 0 && !setup_APIC_eilvt(new, DEFERRED_ERROR_VECTOR, - APIC_EILVT_MSG_FIX, 0)) - return new; - - return reserved; -} - -static void deferred_error_interrupt_enable(struct cpuinfo_x86 *c) -{ - u32 low = 0, high = 0; - int def_offset = -1, def_new; - - if (rdmsr_safe(MSR_CU_DEF_ERR, &low, &high)) - return; - - def_new = (low & MASK_DEF_LVTOFF) >> 4; - if (!(low & MASK_DEF_LVTOFF)) { - pr_err(FW_BUG "Your BIOS is not setting up LVT offset 0x2 for deferred error IRQs correctly.\n"); - def_new = DEF_LVT_OFF; - low = (low & ~MASK_DEF_LVTOFF) | (DEF_LVT_OFF << 4); - } - - def_offset = setup_APIC_deferred_error(def_offset, def_new); - if ((def_offset == def_new) && - (deferred_error_int_vector != amd_deferred_error_interrupt)) - deferred_error_int_vector = amd_deferred_error_interrupt; - - if (!mce_flags.smca) - low = (low & ~MASK_DEF_INT_TYPE) | DEF_INT_TYPE_APIC; - - wrmsr(MSR_CU_DEF_ERR, low, high); -} - static u32 smca_get_block_address(unsigned int bank, unsigned int block, unsigned int cpu) { @@ -551,7 +516,6 @@ prepare_threshold_block(unsigned int bank, unsigned int block, u32 addr, int offset, u32 misc_high) { unsigned int cpu = smp_processor_id(); - u32 smca_low, smca_high; struct threshold_block b; int new; @@ -571,18 +535,10 @@ prepare_threshold_block(unsigned int bank, unsigned int block, u32 addr, __set_bit(bank, this_cpu_ptr(&mce_amd_data)->thr_intr_banks); b.interrupt_enable = 1; - if (!mce_flags.smca) { - new = (misc_high & MASK_LVTOFF_HI) >> 20; - goto set_offset; - } - - /* Gather LVT offset for thresholding: */ - if (rdmsr_safe(MSR_CU_DEF_ERR, &smca_low, &smca_high)) - goto out; - - new = (smca_low & SMCA_THR_LVT_OFF) >> 12; + if (mce_flags.smca) + goto done; -set_offset: + new = (misc_high & MASK_LVTOFF_HI) >> 20; offset = setup_APIC_mce_threshold(offset, new); if (offset == new) thresholding_irq_en = true; @@ -590,7 +546,6 @@ prepare_threshold_block(unsigned int bank, unsigned int block, u32 addr, done: mce_threshold_block_init(&b, offset); -out: return offset; } @@ -659,6 +614,32 @@ static void disable_err_thresholding(struct cpuinfo_x86 *c, unsigned int bank) wrmsrl(MSR_K7_HWCR, hwcr); } +/* + * Enable the APIC LVT interrupt vectors once per-CPU. This should be done before hardware is + * ready to send interrupts. + * + * Individual error sources are enabled later during per-bank init. + */ +static void smca_enable_interrupt_vectors(void) +{ + struct mce_amd_cpu_data *data = this_cpu_ptr(&mce_amd_data); + u64 mca_intr_cfg, offset; + + if (!mce_flags.smca || !mce_flags.succor) + return; + + if (rdmsrl_safe(MSR_CU_DEF_ERR, &mca_intr_cfg)) + return; + + offset = (mca_intr_cfg & SMCA_THR_LVT_OFF) >> 12; + if (!setup_APIC_eilvt(offset, THRESHOLD_APIC_VECTOR, APIC_EILVT_MSG_FIX, 0)) + data->thr_intr_en = true; + + offset = (mca_intr_cfg & MASK_DEF_LVTOFF) >> 4; + if (!setup_APIC_eilvt(offset, DEFERRED_ERROR_VECTOR, APIC_EILVT_MSG_FIX, 0)) + data->dfr_intr_en = true; +} + static void amd_apply_quirks(struct cpuinfo_x86 *c) { struct mce_bank *mce_banks = this_cpu_ptr(mce_banks_array); @@ -690,11 +671,16 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c) amd_apply_quirks(c); mce_flags.amd_threshold = 1; + smca_enable_interrupt_vectors(); for (bank = 0; bank < this_cpu_read(mce_num_banks); ++bank) { - if (mce_flags.smca) + if (mce_flags.smca) { smca_configure(bank, cpu); + if (!this_cpu_ptr(&mce_amd_data)->thr_intr_en) + continue; + } + disable_err_thresholding(c, bank); for (block = 0; block < NR_BLOCKS; ++block) { @@ -715,9 +701,6 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c) offset = prepare_threshold_block(bank, block, address, offset, high); } } - - if (mce_flags.succor) - deferred_error_interrupt_enable(c); } void mce_smca_cpu_init(void) From patchwork Thu Feb 13 16:46:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13973721 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2066.outbound.protection.outlook.com [40.107.100.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6B6A245B05; Thu, 13 Feb 2025 16:46:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465203; cv=fail; b=ip9gsyxpms5IjlaRPuD3vM3GEul/JyeS/TZTnF3VBdC1XJkpztcM/oGszja+/yF9wxhdgYKg4t2iRILUjTOtD2voKPSURjb1YL7FiCpQ+iQOoHytPDigS0BYe9IkpFyKRT/j6KT4Y4mE6tJbpI+wc74ZBoUHCLymLWFP/twtrrM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465203; c=relaxed/simple; bh=Vw9NCVreTe5f7CSFCshLqlWZfNbu0ItFZAgIAi0Tgd0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=td7pn5CFTiJe/U1SfF/GfqddOGp17Jra0wHAch7A083NbXtVel+ZIVcK0UvwT36EsYi4eZGNUtfdgVNNmNvpJLZCKYkILCMgbqY4SMPAkbdiWVfOozSPDjRpr3pkIk6TZFyfhAiz5oRoVSjz9q7D5qEGrgZ4YjqZAUUl/w9JXFc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=2OVVCgm8; arc=fail smtp.client-ip=40.107.100.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="2OVVCgm8" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pB51tdo8FHlac2XD2NvuFlFpJKWSB5NZ//OVtDg1Udbl0inQZEAdzGSko0p3/EtcKVhev8f+7FFvKV0ajh1q5Ek+AgqQih7mzh5CFm3UXXS5iAWd8tBCOjkgR0gDTgUFEyyVTHpn+4tKQJiZAS863DhRlASocOfkouNX1SPWT+I8KIiTwtogvBU9WRwr5jTm+kEzZrWJ41hmH/zP1vHmzbZmCzuHr2qBFkFXInkGo+xRYk1VjRTuoyqVyswBJdEWHWJAJP0w4tp13x9eL0GzM/sloIetJqTUpXJmquE01GZoWrqbFf3/E2+9Of+utnS3Sq3PoCjQTnYTCMcP4U4lyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=jzOhbNyWBk7/sc36uNI8oAi1QRQV0PfIpBrbjKNwzCM=; b=tVq0pQSfA3pUrneVOuQ9xTExznxlO/+2Ne9BDGTQ6yf+7cU5sNwX2uuI2MnDq6fPyJTa9AlN066tYICIoi8P37cVvUXn3ulRa3jIlBk1cTaoJVxYqKOWdBPRzVTtMsgl8PHXgRbXsAbpj3les5TuK7yiR4pkfUniyfV7fyRb0B3oprMawNppaMeoG0Ob+cgHylfYUQ9uDEecmAgeuftJ7ofZMIbDGJ1H0Agr12Nz7wrx8Cvs+9ezfeezB1G+FJcf2cREZ57OHJilRFxPpEEqLRG4HI0u3Ljk+fqedkzpKnRvEh2Lfwbj3TGFxyUmUOap8qbVudKjpGaFYdI9hdVdDA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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 (0) 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=jzOhbNyWBk7/sc36uNI8oAi1QRQV0PfIpBrbjKNwzCM=; b=2OVVCgm8jdxZpq6MggojuvPP/zBiGcThPyZ+mVIb816adw0F8p7DIQSJuIPSTASF1k9jvoMRIW2oCsYL3L9/inqLKMXt+oQft5qo1mt1UeTwQ/ZxOAIyW8FE7OOVV/7rFmu66NG2gcSkSzm+CPv/mTsk7f7Hzcoy65IcVWr+GIw= Received: from DM6PR11CA0002.namprd11.prod.outlook.com (2603:10b6:5:190::15) by CH3PR12MB8712.namprd12.prod.outlook.com (2603:10b6:610:171::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8445.11; Thu, 13 Feb 2025 16:46:37 +0000 Received: from DS1PEPF0001709C.namprd05.prod.outlook.com (2603:10b6:5:190:cafe::43) by DM6PR11CA0002.outlook.office365.com (2603:10b6:5:190::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8445.14 via Frontend Transport; Thu, 13 Feb 2025 16:46: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 DS1PEPF0001709C.mail.protection.outlook.com (10.167.18.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8445.10 via Frontend Transport; Thu, 13 Feb 2025 16:46:37 +0000 Received: from [127.0.1.1] (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.39; Thu, 13 Feb 2025 10:46:31 -0600 From: Yazen Ghannam Date: Thu, 13 Feb 2025 16:46:04 +0000 Subject: [PATCH v2 15/16] x86/mce/amd: Support SMCA Corrected Error Interrupt Precedence: bulk X-Mailing-List: linux-edac@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20250213-wip-mca-updates-v2-15-3636547fe05f@amd.com> References: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> In-Reply-To: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> To: , Tony Luck CC: , , , Yazen Ghannam X-Mailer: b4 0.15-dev-e27d6 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0001709C:EE_|CH3PR12MB8712:EE_ X-MS-Office365-Filtering-Correlation-Id: 57dedf80-8d35-44a7-ae96-08dd4c4dfbdf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|82310400026|13003099007; X-Microsoft-Antispam-Message-Info: =?utf-8?q?XZBeyQMunl4Yw22DInzmqHOixzhoy7f?= =?utf-8?q?I85hqUEUXXwEtf9YYcdn/5COGNT0Ob+jgSgYAqo5NULaasbRWyAAx0iStHt5rRMSu?= =?utf-8?q?HRwc7QowUUF26aVReTM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ySqA6Ahm0A570Cdgv6TAtd27AsOyIOe8zB94yZNayoOp?= =?utf-8?q?a0/RSFAMDouTXaWsUOZXHTrSeidajzLxMXOcm+C4WFAAz49C6vJ2QAddI8kCL7Bva?= =?utf-8?q?6OtZ7zQqUnsU/uWdhGjo7IonxzIUzSR247VZINVMNj84c2IA2PavFvOVF2yWc420D?= =?utf-8?q?8jh6sIov1KlKn1sV4bnAprQ3c6te5hZIvyDgFnRtfyXXlz/RTEt+dtSOpmt5OT9eS?= =?utf-8?q?dC1u2JwyZ/3LNSKEPl1jCxwNHwsemVohgqZTU/syzVnsx1ub9CLs4H+WsMFaUuua8?= =?utf-8?q?FukPOqETpCEWDs7nVPnjDhqjr/KnEZQD2U28g5c2KIryhHUxzVTr7j15Wzrx9E5fL?= =?utf-8?q?pUorYTF8FvO9VySUisOGWR1pKdM3Q0IDmRCPdiJBXd/YDTDktdczY9pqOQvgl8yvu?= =?utf-8?q?f98idKFvlEcsZTT9DQI2EbMxONcTqlRigcrwL2k90AKIcJsoD7uEGQ=3D?= 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:(13230040)(1800799024)(36860700013)(376014)(82310400026)(13003099007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2025 16:46:37.7161 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 57dedf80-8d35-44a7-ae96-08dd4c4dfbdf 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: DS1PEPF0001709C.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8712 AMD systems optionally support MCA thresholding which provides the ability for hardware to send an interrupt when a set error threshold is reached. This feature counts errors of all severities, but it is commonly used to report correctable errors with an interrupt rather than polling. Scalable MCA systems allow the Platform to take control of this feature. In this case, the OS will not see the feature configuration and control bits in the MCA_MISC* registers. The OS will not receive the MCA thresholding interrupt, and it will need to poll for correctable errors. A "corrected error interrupt" will be available on Scalable MCA systems. This will be used in the same configuration where the Platform controls MCA thresholding. However, the Platform will now be able to send the MCA thresholding interrupt to the OS. Check for the feature bit in the MCA_CONFIG register and confirm that the MCA thresholding interrupt handler is already enabled. If successful, set the feature enable bit in the MCA_CONFIG register to indicate to the Platform that the OS is ready for the interrupt. Signed-off-by: Yazen Ghannam --- Notes: Link: https://lore.kernel.org/r/20240523155641.2805411-10-yazen.ghannam@amd.com v1->v2: * Use new per-CPU struct. arch/x86/kernel/cpu/mce/amd.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index 75a48f484815..404e0c38f9d8 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -306,6 +306,11 @@ static void smca_configure(unsigned int bank, unsigned int cpu) high |= BIT(5); } + if ((low & BIT(10)) && data->thr_intr_en) { + __set_bit(bank, data->thr_intr_banks); + high |= BIT(8); + } + this_cpu_ptr(mce_banks_array)[bank].lsb_in_status = !!(low & BIT(8)); wrmsr(smca_config, low, high); From patchwork Thu Feb 13 16:46:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yazen Ghannam X-Patchwork-Id: 13973724 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2072.outbound.protection.outlook.com [40.107.244.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 98E7F24A075; Thu, 13 Feb 2025 16:46:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465208; cv=fail; b=qgQGrCpaTqDIfAiTbD2pRlBXJ/D6q0CFP7XEyZDoy0nymlZ206D6d2wVZI5lAzE0Y8SU4LZMcZDSnKueBJI8gboInY7xNLeckZ6lLzTuYML0Ej896njPFJbyGRwLkbxuUgJNLEIeddl5jNLHmoxZvH1NPKvpE9wE27m767OL7vw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739465208; c=relaxed/simple; bh=ndg5gUCA7LezAA4vxZ/Hf95pHu1Exs2EVHhKZGuXdtk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=QIRh+B9XLmu1N/APX1fzj/vgMIBrBl62vZHOzFwZsq3jK3ZT5yyh7bM6mP7H7jZqQtPI8DmrTGQt6ULSyL6yZCs5kYMIzaXCLZXqz1M0fBq96yjHQptEFEHNinjWftJ4HXAl+EtmMuO5vnx2FLtQWR5u7v8uhT3WPjIlAipopGM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=uXOXgWYo; arc=fail smtp.client-ip=40.107.244.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="uXOXgWYo" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LiqY0G44jU/0qZrtnQYhcOUiPmJ+AJkTZ9EFz5ZMoCptIUXrRcPZe7vXE33688VPjKC7F2RRW9HL6OGvoYOh7mmIF0aQ/L8IYjKUodicvHDSwVUbmWnpZGsFeEXu/CtyD8jcRowNb75ioM2iwXOyfIoOCSmFqRjkVb8iVN45KxVUkwhNjqNRNQ+RhMLLD/wdCrg9iUaZXigRPtguX8dEZz+XW4+mLuX1RzsrDQl8yM3Xtqzzy23P6S+3mX4+u0ANBf4Bcgh9mJeoVK+BGWnUq7P+9drrRS4NRIsroIkqjUWWeZqi/JaIwYP1fcUUNQWiLKVE1JB7MH9eQeuoUdygbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=midfnS3OPp6vKmRVTdbEciTeZ8yexJcmmKNRM9NOnLA=; b=FuIz+KzUyTBmZAR4nELmxxruK24itytkwF1u8nGLtRVboG3O9grrot7+8mMoQlYtePLkQbCBBKGa0jTyhZsqpsNy+3qRNzkJmdkziZ+IxC/jamQIs/6+paftYZ6giBz7veqEBkM9B0FnrvFfewxJsXI00PoOXrUovu5Khf+YKK7X6f4lwtAuwySeAgsFvbGCyeZsIe5zIapiNajB4/33er4h3S48q8C1xxJU8hmT73y6ML7xE7Z66wFuRkMSPbbf282kRcI/zo6iDw7brfAQrYoC89oPaQLhPmw6k/EUeLOM2S5XT1e7grFbrxKN+OMZyBbtKksLCAvfJWbZigNBYQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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 (0) 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=midfnS3OPp6vKmRVTdbEciTeZ8yexJcmmKNRM9NOnLA=; b=uXOXgWYovmfNtxihCUWgBSbrsWWxMs7GKThOLrJWi/x1hRmhHwp9jAeJR1Y8yR3OziQrqvY4aMxD4iFLly15sMIMeRDICQQEKs7uG7Gm/dNO22KUrTtqcuvuhwMJzkPjbZ4ZRzPCZ8HZShEukP1rQiQYYLgyHxnFp8qVRXBFwK4= Received: from DM6PR11CA0027.namprd11.prod.outlook.com (2603:10b6:5:190::40) by IA1PR12MB6553.namprd12.prod.outlook.com (2603:10b6:208:3a3::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8422.23; Thu, 13 Feb 2025 16:46:38 +0000 Received: from DS1PEPF0001709C.namprd05.prod.outlook.com (2603:10b6:5:190:cafe::b1) by DM6PR11CA0027.outlook.office365.com (2603:10b6:5:190::40) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8445.16 via Frontend Transport; Thu, 13 Feb 2025 16:46:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS1PEPF0001709C.mail.protection.outlook.com (10.167.18.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8445.10 via Frontend Transport; Thu, 13 Feb 2025 16:46:37 +0000 Received: from [127.0.1.1] (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.39; Thu, 13 Feb 2025 10:46:32 -0600 From: Yazen Ghannam Date: Thu, 13 Feb 2025 16:46:05 +0000 Subject: [PATCH v2 16/16] x86/mce: Handle AMD threshold interrupt storms Precedence: bulk X-Mailing-List: linux-edac@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20250213-wip-mca-updates-v2-16-3636547fe05f@amd.com> References: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> In-Reply-To: <20250213-wip-mca-updates-v2-0-3636547fe05f@amd.com> To: , Tony Luck CC: , , , Yazen Ghannam X-Mailer: b4 0.15-dev-e27d6 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0001709C:EE_|IA1PR12MB6553:EE_ X-MS-Office365-Filtering-Correlation-Id: 360b5e74-89c1-44b5-2362-08dd4c4dfbf5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|1800799024|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?kHyozWjCvXBqdldpTLeaIseh4Ruoc/m?= =?utf-8?q?fXT7h1fqf8lQuX9lsiCa7nakLo6zel8d9zXODVuS+IX7E/5SnPFcD6dj65iEUEUNV?= =?utf-8?q?YSL4APFdpbuoFWdOvXoEq49pRXF7m5F301TEh52+ogbgggKzT4d4iY8AJIWwsB/ip?= =?utf-8?q?rYKrmAjAaZik5mGPhYosx+/3yp5VU6TEHafBqet1KKWk+U4b1HUmI4sB1AFq+P+0K?= =?utf-8?q?XJi3ZVfpTrpHXcRB5K4PfIFeoDxqtSZNDkx4p4l807R/JVS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moV5/vhv?= =?utf-8?q?sqSgAS2HSy5fvjmROGssifQPKZlDPm8X2lyyihhHJGGcJ+z0wzExymdClgQYjQtA2?= =?utf-8?q?cZ661Fq6igtXuwXZOkvdjC+ldbKkW4xVQ34tcOxhICpnzrnFWxB/JGSNs8HMCfBJV?= =?utf-8?q?37RwKz4RImqZB5l+kTLRk/aQzg8+kulGwEAL26kD2Xm347VdABEqaoD5NYDMIrMjI?= =?utf-8?q?pwNr3K5AlUvAQZC1XV1Sy9721nAQ5DbTXuwez3z5wUvgt8pfu7qdG5GrIqvqlI2XQ?= =?utf-8?q?/Zdt88l7DSzGRPt+e+JM9r2fl2ji6dHWCRCtci3hKYuTgUmbyRbN2M=3D?= 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:(13230040)(82310400026)(36860700013)(1800799024)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2025 16:46:37.8724 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 360b5e74-89c1-44b5-2362-08dd4c4dfbf5 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: DS1PEPF0001709C.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6553 From: Smita Koralahalli Extend the logic of handling CMCI storms to AMD threshold interrupts. Rely on the similar approach as of Intel's CMCI to mitigate storms per CPU and per bank. But, unlike CMCI, do not set thresholds and reduce interrupt rate on a storm. Rather, disable the interrupt on the corresponding CPU and bank. Re-enable back the interrupts if enough consecutive polls of the bank show no corrected errors (30, as programmed by Intel). Turning off the threshold interrupts would be a better solution on AMD systems as other error severities will still be handled even if the threshold interrupts are disabled. [Tony: Small tweak because mce_handle_storm() isn't a pointer now] [Yazen: Rebase and simplify] Signed-off-by: Smita Koralahalli Signed-off-by: Tony Luck Signed-off-by: Yazen Ghannam --- Notes: Link: https://lore.kernel.org/r/20230616182744.17632-4-tony.luck@intel.com v1->v2: * New in v2, but based on older patch. * Rebased on current set and simplified. * Kept old tags. arch/x86/kernel/cpu/mce/amd.c | 18 ++++++++++++++++++ arch/x86/kernel/cpu/mce/internal.h | 2 ++ arch/x86/kernel/cpu/mce/threshold.c | 3 +++ 3 files changed, 23 insertions(+) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index 404e0c38f9d8..a2d02f0c2153 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -1218,3 +1218,21 @@ void mce_threshold_create_device(unsigned int cpu) mce_threshold_vector = amd_threshold_interrupt; return; } + +void mce_amd_handle_storm(unsigned int bank, bool on) +{ + struct threshold_bank **thr_banks = this_cpu_read(threshold_banks); + struct threshold_block *block, *tmp; + struct thresh_restart tr; + + if (!thr_banks || !thr_banks[bank]) + return; + + memset(&tr, 0, sizeof(tr)); + + list_for_each_entry_safe(block, tmp, &thr_banks[bank]->miscj, miscj) { + tr.b = block; + tr.b->interrupt_enable = on; + threshold_restart_bank(&tr); + } +} diff --git a/arch/x86/kernel/cpu/mce/internal.h b/arch/x86/kernel/cpu/mce/internal.h index fe519acfafcf..9d771db2bcae 100644 --- a/arch/x86/kernel/cpu/mce/internal.h +++ b/arch/x86/kernel/cpu/mce/internal.h @@ -266,6 +266,7 @@ void mce_prep_record_per_cpu(unsigned int cpu, struct mce *m); #ifdef CONFIG_X86_MCE_AMD void mce_threshold_create_device(unsigned int cpu); +void mce_amd_handle_storm(unsigned int bank, bool on); extern bool amd_filter_mce(struct mce *m); bool amd_mce_usable_address(struct mce *m); void amd_reset_thr_limit(unsigned int bank); @@ -297,6 +298,7 @@ static __always_inline void smca_extract_err_addr(struct mce *m) void mce_smca_cpu_init(void); #else static inline void mce_threshold_create_device(unsigned int cpu) { } +static inline void mce_amd_handle_storm(unsigned int bank, bool on) { } static inline bool amd_filter_mce(struct mce *m) { return false; } static inline bool amd_mce_usable_address(struct mce *m) { return false; } static inline void amd_reset_thr_limit(unsigned int bank) { } diff --git a/arch/x86/kernel/cpu/mce/threshold.c b/arch/x86/kernel/cpu/mce/threshold.c index f4a007616468..45144598ec74 100644 --- a/arch/x86/kernel/cpu/mce/threshold.c +++ b/arch/x86/kernel/cpu/mce/threshold.c @@ -63,6 +63,9 @@ static void mce_handle_storm(unsigned int bank, bool on) case X86_VENDOR_INTEL: mce_intel_handle_storm(bank, on); break; + case X86_VENDOR_AMD: + mce_amd_handle_storm(bank, on); + break; } }