Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1238388imu; Wed, 9 Jan 2019 14:17:20 -0800 (PST) X-Google-Smtp-Source: ALg8bN4T7mcdCkIlzuR3zk3CT2xYU2iC5H9zj7m5c2xsCZJng7lOKmp5wDZns3u2hJM+HIv31qXK X-Received: by 2002:a63:da45:: with SMTP id l5mr7101381pgj.111.1547072240148; Wed, 09 Jan 2019 14:17:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547072240; cv=none; d=google.com; s=arc-20160816; b=ZQEfjLWGBqtwBpWlKFqF+XpLlH3n6TUHl+3tzccrVqMjQAkpiCzlga7sY4VOELrpYF g8wFTTrcuFHxk7U//B3herY5xAajPo333I886JGNTZHfc/ShFrTUv1232m+irj6qbauJ BK8KH0IDyzIwMv0F/7Z2gxgUbYhauTJllncsMmzDMi57oawOnGloO3IOCLU/K4ik1cBM 1eAHHdaH6CCH7PZhjTj/ZmhRKdN1STCCFL2PyBgjitQlIKWPdv1T8FeIsJiw+5VoLp5a enDDflx5KS5HksHxeCTg+XaBHkCT3zPfQ8Eff0usdX5joEO0qK0aCsTTBatSYHIzdySc TOtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Q6DP2BmRrr4pfYlYlCnGunrzad5k8+WLSO7ADjQQvbY=; b=T5SPE2mkSBfb/+zWKM0SIHRzkskQUdpjSzsDcxTJcjjlmG9TCmij1e75K/YBA1baAN NNUnvDeKG2SK2UHL/WghZ5LuhxosqFymVrttfTbdUbEuYYVeA350bhPxpobIkeOvPfZo NXCfX4eL9QlXNRfPqkfnGWclxN9gtf154yt0DoXds8YL8x7nrieYvi93v9vwkh5wgN4k 81SeA2fxBJQ7M0g8VmHJtrv/3AKUroPOA7yMpGkIWwDb/HQHqX47bN/+KU7UD9RrZgjA FewU8WBMi7LADndquMaufHamF6Uh0/v3MGnVAxq0lg8Y1sGnHo4YUGdwomCJHxmNJA5r HIrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=H9LnA4gl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c81si14767266pfc.82.2019.01.09.14.17.04; Wed, 09 Jan 2019 14:17:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=H9LnA4gl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727550AbfAIWIx (ORCPT + 99 others); Wed, 9 Jan 2019 17:08:53 -0500 Received: from mail.skyhub.de ([5.9.137.197]:43856 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726599AbfAIWIw (ORCPT ); Wed, 9 Jan 2019 17:08:52 -0500 Received: from zn.tnic (p200300EC2BEA10006802B5941DDA3DDE.dip0.t-ipconnect.de [IPv6:2003:ec:2bea:1000:6802:b594:1dda:3dde]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 6DD361EC027A; Wed, 9 Jan 2019 23:08:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1547071731; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=Q6DP2BmRrr4pfYlYlCnGunrzad5k8+WLSO7ADjQQvbY=; b=H9LnA4glwBvAp8RP+VuP92TlAJ8hEbxfCQ9clKW5ZYFFIFLVR48+4RwFmGrheEkplVMVpW NNnBmbOUCOlDKqIGmB4zRBk85o41hVxME2GexyYhCixtUyNPvuwi9wqwLgdFc2/tVnJdOx GCHL1X3TL+GMRyDIzqM1gMEyrC26lgs= Date: Wed, 9 Jan 2019 23:08:43 +0100 From: Borislav Petkov To: "S, Shirish" Cc: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , "maintainer : X86 ARCHITECTURE" , Tony Luck , Vishal Verma , "open list : X86 ARCHITECTURE" Subject: Re: [PATCH 2/2] x86/mce/amd: Ensure quirks are applied in resume path as well Message-ID: <20190109220843.GK15665@zn.tnic> References: <1546857399-2926-1-git-send-email-shirish.s@amd.com> <1546857399-2926-3-git-send-email-shirish.s@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1546857399-2926-3-git-send-email-shirish.s@amd.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 07, 2019 at 10:37:24AM +0000, S, Shirish wrote: > This patch adds threshold quirk applicable for family 15 Same issue with "This patch" here. > in resume path as well, since mce_amd_feature_init() > does not have quirks applied when originating from mce_syscore_resume(), > resulting in the below message at every successful resume: > > "[Firmware Bug]: cpu 0, invalid threshold interrupt offset ..." > > Signed-off-by: Shirish S > --- > arch/x86/kernel/cpu/mce/amd.c | 34 ++++++++++++++++++++++++++++++++++ > 1 file changed, 34 insertions(+) > > diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c > index 89298c8..27cbf66 100644 > --- a/arch/x86/kernel/cpu/mce/amd.c > +++ b/arch/x86/kernel/cpu/mce/amd.c > @@ -545,6 +545,34 @@ prepare_threshold_block(unsigned int bank, unsigned int block, u32 addr, > return offset; > } > > +void disable_err_thresholding(struct cpuinfo_x86 *c) > +{ > + int i; > + u64 hwcr; > + bool need_toggle; > + u32 msrs[] = { > + 0x00000413, /* MC4_MISC0 */ > + 0xc0000408, /* MC4_MISC1 */ > + }; > + > + if (c->x86_model >= 0x10 && c->x86_model <= 0x7f) { You can save yourself an indentation level by reversing the logic here: if (c->x86 != 0x15) return; Also, I'm wondering if you simply can't do if (c->x86_model < 0x10) return; The assumption being that all the models - even after 0x7f - are highly unlikely to get MC4_MISC thresholding supported, all of a sudden. Might wanna run it by HW guys first though. > + rdmsrl(MSR_K7_HWCR, hwcr); > + > + /* McStatusWrEn has to be set */ > + need_toggle = !(hwcr & BIT(18)); > + > + if (need_toggle) > + wrmsrl(MSR_K7_HWCR, hwcr | BIT(18)); > + > + /* Clear CntP bit safely */ > + for (i = 0; i < ARRAY_SIZE(msrs); i++) > + msr_clear_bit(msrs[i], 62); > + > + /* restore old settings */ > + if (need_toggle) > + wrmsrl(MSR_K7_HWCR, hwcr); > + } So you copied the same code from __mcheck_cpu_apply_quirks(). No. In a first patch, you carve that CntP clearing code in a separate function disable_err_thresholding() like you've done before. Then, in a second patch, you call it from mce/amd.c and you move all the family/model checks inside the function so that you have a sole disable_err_thresholding(); calls where you need them. You don't have to pass in struct cpuinfo_x86 *c - you can use boot_cpu_data in the function. > +} > /* cpu init entry point, called from mce.c with preempt off */ > void mce_amd_feature_init(struct cpuinfo_x86 *c) > { > @@ -552,6 +580,12 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c) > unsigned int bank, block, cpu = smp_processor_id(); > int offset = -1; > > + /* Disable error thresholding bank in S3 resume path as well, What S3 resume path? That's the CPU init path. Also, kernel comments style is: /* * A sentence ending with a full-stop. * Another sentence. ... * More sentences. ... */ Good luck! :-) -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.