From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 624FBC25B08 for ; Wed, 17 Aug 2022 17:00:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/xPcb8EkW4kpmZFXOn0F4NXCtPva+mifKbm+EPiH1qk=; b=qslO7fDoPFG68l Ja28eUUK6zNXYA1LiGVvgqhkO7WKJjg5zGGF7cuyucsiD8WLCiZV/PHVOa0F6zhOGySv2H4QGKu+/ K6iNOL/gS/Gh/rU45vv00SBgPi8Cy5vN5SCbWYURQSEHgaXsPkRDx2WqaFsO4XsbDC+S9sihbMk4Y YK/Od8bnpCTs7or5Y4+e6VcXppyYpVvcJ11SqqaTjQBsbLl0InCdTEzmAlok+DiVWEAiQc8ZqLOLp 0dfxU0gUPhMp4uhZaZ5alCf/ro9urLnM8ModCt7kuvu0jpcdknjc0Rs1+VgiXJ96KT0U/6uFPgZ1/ rKyuw9K0Ngo2UtpdXRSQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oOMNt-0044TH-7h; Wed, 17 Aug 2022 16:59:13 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oOMNp-0044PW-HD for linux-arm-kernel@lists.infradead.org; Wed, 17 Aug 2022 16:59:11 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C4FA5B81E58; Wed, 17 Aug 2022 16:59:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61137C433D6; Wed, 17 Aug 2022 16:59:05 +0000 (UTC) Date: Wed, 17 Aug 2022 17:59:01 +0100 From: Catalin Marinas To: Ionela Voinescu Cc: Will Deacon , James Morse , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [RESEND PATCH v2] arm64: errata: add detection for AMEVCNTR01 incrementing incorrectly Message-ID: References: <20220817121551.21790-1-ionela.voinescu@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220817121551.21790-1-ionela.voinescu@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220817_095909_751103_D4401E67 X-CRM114-Status: GOOD ( 21.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Ionela, On Wed, Aug 17, 2022 at 01:15:51PM +0100, Ionela Voinescu wrote: > diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c > index 7e6289e709fc..810dd3c39882 100644 > --- a/arch/arm64/kernel/cpu_errata.c > +++ b/arch/arm64/kernel/cpu_errata.c > @@ -654,6 +654,16 @@ const struct arm64_cpu_capabilities arm64_errata[] = { > ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A510, 0, 0, 2) > }, > #endif > +#ifdef CONFIG_ARM64_ERRATUM_2457168 > + { > + .desc = "ARM erratum 2457168", > + .capability = ARM64_WORKAROUND_2457168, > + .type = ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE, > + > + /* Cortex-A510 r0p0-r1p1 */ > + CAP_MIDR_RANGE(MIDR_CORTEX_A510, 0, 0, 1, 1) > + }, > +#endif > #ifdef CONFIG_ARM64_ERRATUM_2038923 > { > .desc = "ARM erratum 2038923", > diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c > index 907401e4fffb..af4de817d712 100644 > --- a/arch/arm64/kernel/cpufeature.c > +++ b/arch/arm64/kernel/cpufeature.c > @@ -1870,7 +1870,10 @@ static void cpu_amu_enable(struct arm64_cpu_capabilities const *cap) > pr_info("detected CPU%d: Activity Monitors Unit (AMU)\n", > smp_processor_id()); > cpumask_set_cpu(smp_processor_id(), &amu_cpus); > - update_freq_counters_refs(); > + > + /* 0 reference values signal broken/disabled counters */ > + if (!this_cpu_has_cap(ARM64_WORKAROUND_2457168)) > + update_freq_counters_refs(); > } > } >From a CPU errata workaround, this part looks fine to me. > > diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c > index 869ffc4d4484..5d7efb15f7cf 100644 > --- a/arch/arm64/kernel/topology.c > +++ b/arch/arm64/kernel/topology.c > @@ -301,7 +301,8 @@ static void cpu_read_corecnt(void *val) > > static void cpu_read_constcnt(void *val) > { > - *(u64 *)val = read_constcnt(); > + *(u64 *)val = this_cpu_has_cap(ARM64_WORKAROUND_2457168) ? > + 0UL : read_constcnt(); > } > > static inline > @@ -328,7 +329,12 @@ int counters_read_on_cpu(int cpu, smp_call_func_t func, u64 *val) > */ > bool cpc_ffh_supported(void) > { > - return freq_counters_valid(get_cpu_with_amu_feat()); > + int cpu = get_cpu_with_amu_feat(); > + > + if ((cpu >= nr_cpu_ids) || !cpumask_test_cpu(cpu, cpu_present_mask)) > + return false; > + > + return true; > } So here we tell the core code that FFH is supported but always return 0 via cpc_read_ffh() if the const counter is requested. I assume the core code figures this out and doesn't use the value on the affected CPUs. I was hoping cpc_ffh_supported() would be per-CPU and the core code simply skips calling cpc_read() on the broken cores. Is the other register read by cpc_read_ffh() still useful without the const one? While the Kconfig entry describes the behaviour, I'd rather have a comment in cpc_ffh_supported() and maybe cpu_read_constcnt() on why we do these tricks. Thanks. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel