Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752856AbbEFRDS (ORCPT ); Wed, 6 May 2015 13:03:18 -0400 Received: from mail-bn1on0115.outbound.protection.outlook.com ([157.56.110.115]:63712 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752618AbbEFRBt (ORCPT ); Wed, 6 May 2015 13:01:49 -0400 Authentication-Results: spf=none (sender IP is 165.204.84.222) smtp.mailfrom=amd.com; alien8.de; dkim=none (message not signed) header.d=none; X-WSS-ID: 0NNXTYM-08-W6Y-02 X-M-MSG: From: Aravind Gopalakrishnan To: , , , , , , CC: , , , , , , , , , , , , , , , , , Subject: [PATCH V2 1/6] x86/MCE/AMD: Factor out logging mechanism Date: Wed, 6 May 2015 06:58:53 -0500 Message-ID: <1430913538-1415-2-git-send-email-Aravind.Gopalakrishnan@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1430913538-1415-1-git-send-email-Aravind.Gopalakrishnan@amd.com> References: <1430913538-1415-1-git-send-email-Aravind.Gopalakrishnan@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.222;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(428002)(199003)(189002)(87936001)(2201001)(47776003)(48376002)(5001770100001)(50466002)(53416004)(101416001)(2950100001)(77096005)(46102003)(86362001)(92566002)(189998001)(50226001)(19580405001)(19580395003)(106466001)(36756003)(76176999)(105586002)(50986999)(77156002)(62966003)(229853001);DIR:OUT;SFP:1102;SCL:1;SRVR:CO1PR02MB079;H:atltwp02.amd.com;FPR:;SPF:None;MLV:sfv;A:1;MX:1;LANG:en; X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CO1PR02MB079;UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CO1PR02MB110; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:CO1PR02MB079;BCL:0;PCL:0;RULEID:;SRVR:CO1PR02MB079; X-Forefront-PRVS: 0568F32D91 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2015 17:01:37.7398 (UTC) X-MS-Exchange-CrossTenant-Id: fde4dada-be84-483f-92cc-e026cbee8e96 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fde4dada-be84-483f-92cc-e026cbee8e96;Ip=[165.204.84.222];Helo=[atltwp02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR02MB079 X-OriginatorOrg: amd4.onmicrosoft.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2087 Lines: 82 Refactoring the code here to setup struct mce and call mce_log() to log the error. No functional change is introduced. Doing this so we can use it later to log error when deferred error interrupts happen. Suggested-by: Borislav Petkov Signed-off-by: Aravind Gopalakrishnan --- arch/x86/kernel/cpu/mcheck/mce_amd.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c index 55ad9b3..60ae315 100644 --- a/arch/x86/kernel/cpu/mcheck/mce_amd.c +++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c @@ -264,6 +264,24 @@ init: } } +static void __log_error(unsigned int bank, bool is_thr, u64 misc) +{ + struct mce m; + + mce_setup(&m); + rdmsrl(MSR_IA32_MCx_STATUS(bank), m.status); + if (!(m.status & MCI_STATUS_VAL)) + return; + + if (is_thr) + m.misc = misc; + + m.bank = bank; + mce_log(&m); + + wrmsrl(MSR_IA32_MCx_STATUS(bank), 0); +} + /* * APIC Interrupt Handler */ @@ -273,12 +291,12 @@ init: * the interrupt goes off when error_count reaches threshold_limit. * the handler will simply log mcelog w/ software defined bank number. */ + static void amd_threshold_interrupt(void) { u32 low = 0, high = 0, address = 0; int cpu = smp_processor_id(); unsigned int bank, block; - struct mce m; /* assume first bank caused it */ for (bank = 0; bank < mca_cfg.banks; ++bank) { @@ -321,15 +339,7 @@ static void amd_threshold_interrupt(void) return; log: - mce_setup(&m); - rdmsrl(MSR_IA32_MCx_STATUS(bank), m.status); - if (!(m.status & MCI_STATUS_VAL)) - return; - m.misc = ((u64)high << 32) | low; - m.bank = bank; - mce_log(&m); - - wrmsrl(MSR_IA32_MCx_STATUS(bank), 0); + __log_error(bank, true, ((u64)high << 32) | low); } /* -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/