Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1417878pxb; Wed, 6 Apr 2022 18:21:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeJpB4LMT6oV6Fe4H+nsg35pgFUGxH5rDfNGlJun0tfahD0KaNoTdkspbKB/u2y7yZzrry X-Received: by 2002:a17:90b:3851:b0:1c7:80f9:5306 with SMTP id nl17-20020a17090b385100b001c780f95306mr13007231pjb.207.1649294504680; Wed, 06 Apr 2022 18:21:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649294504; cv=none; d=google.com; s=arc-20160816; b=navZ7bAHgKy9G0FQreHUvBrlizCXu0XX296TogUlyw74XKt9hb6fg5JwhhMcF5WcTL ChNMBRNtAkTupr1QtH3TD8fAKosb/9awsFO15IT7GEwrBveOgU9wz8dMa5irxUIjiYQO BIvAuI+PZWm174ju32puq6zx3bKP2LjzUo/eTciu3hTFq+OGRORM6Vaos9lPhpu3N6kO EysumXDRgCAWMNye34SnIgLQKjoWdwNeahZxhYFaIvAiYtaK4CNIRbfqce0slDVpovk1 FDQ8x+TFBV/r93zaWCeaWAtq/niGWSscE2L2ZiyrhUI0JZRAStenaVF8DkmQ3bMSAqGG sUDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=j84CpHVIG/y7TGczuTof9jh0jI6v/h97q3G6wr3y2Jg=; b=YyOVNBk5KG4idhjARIyu508O2y7jKznMznCgOKfH6oPcxSPQk7joi1jitcPeqXl0f+ gSufocx9LawYGWiF/+gnaJV2yKxYmG3YckQLZg+j078EHoFkoL3VDztgBOccM38JODO3 UWsGW0Hz++lnlcUajAfdxL5QU4gi1eYLBvfJeBoBWYtNe6DoBfZgSkVjQo9+Siby/ue6 U/vweaKT5I3HbxFblzkHKysedLgKzoC512/5jShT3cHcXOraPUKXz7E4v14Bn+zoD+Ap +aE40SyVLhsHo//VCPpWUuYgZXN0LyczpiEgovVE2oXyrpj3mbUeLwCOu/ZwAuV5K0xY mpnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cETam1jJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j16-20020a056a00235000b004fafa481427si18438141pfj.91.2022.04.06.18.21.30; Wed, 06 Apr 2022 18:21:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cETam1jJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234307AbiDFUQ7 (ORCPT + 99 others); Wed, 6 Apr 2022 16:16:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234317AbiDFUPa (ORCPT ); Wed, 6 Apr 2022 16:15:30 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E4131B6089; Wed, 6 Apr 2022 11:27:20 -0700 (PDT) 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 C4E1EB8252B; Wed, 6 Apr 2022 18:27:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 319D0C385A1; Wed, 6 Apr 2022 18:27:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649269637; bh=6G22upvbXoxta8nk2RQbeDekiGmPjZ2D3Z7Cr5183MA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cETam1jJgbMpSVIgPvdbSpjUj/gHVQtBUyzvXkRCHVYvm9ZSAIBAcPSc6CZJVv1cB KwLE/PPSrd00DOUTbXvgIrDcOq9nTfE42+EmK8s976f6VlEThKWYkuDMvEWsgFCewD iYgjx6GPspOabBY1ngMJg1ap15q0bKRiLX3qbyb0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Gleixner , Marc Zyngier , James Morse Subject: [PATCH 4.9 15/43] arm64: arch_timer: Add erratum handler for CPU-specific capability Date: Wed, 6 Apr 2022 20:26:24 +0200 Message-Id: <20220406182437.127728140@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220406182436.675069715@linuxfoundation.org> References: <20220406182436.675069715@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marc Zyngier commit 0064030c6fd4ca6cfab42de037b2a89445beeead upstream. Should we ever have a workaround for an erratum that is detected using a capability and affecting a particular CPU, it'd be nice to have a way to probe them directly. Acked-by: Thomas Gleixner Signed-off-by: Marc Zyngier Signed-off-by: James Morse Signed-off-by: Greg Kroah-Hartman --- arch/arm64/include/asm/arch_timer.h | 1 + drivers/clocksource/arm_arch_timer.c | 28 ++++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) --- a/arch/arm64/include/asm/arch_timer.h +++ b/arch/arm64/include/asm/arch_timer.h @@ -39,6 +39,7 @@ extern struct static_key_false arch_time enum arch_timer_erratum_match_type { ate_match_dt, + ate_match_local_cap_id, }; struct arch_timer_erratum_workaround { --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c @@ -162,6 +162,13 @@ bool arch_timer_check_dt_erratum(const s return of_property_read_bool(np, wa->id); } +static +bool arch_timer_check_local_cap_erratum(const struct arch_timer_erratum_workaround *wa, + const void *arg) +{ + return this_cpu_has_cap((uintptr_t)wa->id); +} + static const struct arch_timer_erratum_workaround * arch_timer_iterate_errata(enum arch_timer_erratum_match_type type, ate_match_fn_t match_fn, @@ -192,14 +199,16 @@ static void arch_timer_check_ool_workaro { const struct arch_timer_erratum_workaround *wa; ate_match_fn_t match_fn = NULL; - - if (static_branch_unlikely(&arch_timer_read_ool_enabled)) - return; + bool local = false; switch (type) { case ate_match_dt: match_fn = arch_timer_check_dt_erratum; break; + case ate_match_local_cap_id: + match_fn = arch_timer_check_local_cap_erratum; + local = true; + break; default: WARN_ON(1); return; @@ -209,8 +218,17 @@ static void arch_timer_check_ool_workaro if (!wa) return; + if (needs_unstable_timer_counter_workaround()) { + if (wa != timer_unstable_counter_workaround) + pr_warn("Can't enable workaround for %s (clashes with %s\n)", + wa->desc, + timer_unstable_counter_workaround->desc); + return; + } + arch_timer_enable_workaround(wa); - pr_info("Enabling global workaround for %s\n", wa->desc); + pr_info("Enabling %s workaround for %s\n", + local ? "local" : "global", wa->desc); } #else @@ -470,6 +488,8 @@ static void __arch_timer_setup(unsigned BUG(); } + arch_timer_check_ool_workaround(ate_match_local_cap_id, NULL); + erratum_workaround_set_sne(clk); } else { clk->features |= CLOCK_EVT_FEAT_DYNIRQ;