From patchwork Sun Apr 16 20:26:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 9683157 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 68EFB60138 for ; Sun, 16 Apr 2017 20:29:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5568927B81 for ; Sun, 16 Apr 2017 20:29:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48F9A27CF3; Sun, 16 Apr 2017 20:29:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C9B3C27B81 for ; Sun, 16 Apr 2017 20:29:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=lG1cEqUGShP7I6Knp+T6cQUh8gCvLCjCG4/uw7/OdJQ=; b=Dmos8KIHewPatQs8+jTC2nCPOu 2qj11CehWzTe2pqPyWjhx66XQ99z9yPMedQUqAM2mkTw9fCamz5IaEen+w8FiB0xJgBzpeJP0kGue 6Vi8hAUA+fhxvnWIy8ThqZLdBY3B7KQAlW30u8nq/ochlfJnByLeSGKk3l3xMb1NFBLlt3ariT2bo h4meSAirGPRkZ10WWUWKFlGAiQdTQ4AeLT49fOctFV2llGebaf+3OQAbjK8FRXwjfXabERrVpsQ8q XoXweGNzy+k0ylH7wKqXAFet42BK9IIl6zQFaz+ZbCMZ+xkIgeBvtrtsteXJ+ftZC3a7x7iq4mwGh oFeO8V1g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1czqnt-0007um-0K; Sun, 16 Apr 2017 20:29:49 +0000 Received: from mail-wm0-x235.google.com ([2a00:1450:400c:c09::235]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1czqmY-0005uE-M7 for linux-arm-kernel@lists.infradead.org; Sun, 16 Apr 2017 20:28:32 +0000 Received: by mail-wm0-x235.google.com with SMTP id u2so22404276wmu.0 for ; Sun, 16 Apr 2017 13:28:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4QOm71Yr5SYXErKN5RRFrviUU7JnkhtxJ3hgHuyetr0=; b=bHt33ny7IMlU7iihTf7mp7W3vWtnWLwYRpuyfvLhdI/96X2kO0eSQGhvvuIrVvukT5 ZNd/6YJmMtgPWCzY45x/zRoY+6hJ7KupABSjl8NOjIWwlSA4ffl0XI0pcgaMpEccpbXd f3RB8JKORSBswBEVeb1eJWVLC2WCASJDKbV18= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4QOm71Yr5SYXErKN5RRFrviUU7JnkhtxJ3hgHuyetr0=; b=HkUxHg3qDIRkwORLsPb0qYJCEthxN1iN0/0ZoB1E2nJyI33k12FgLGs7bwzXx+oRYE XN2HmzdBcP3jtysjkaKUuwSAay3ThltewR+GaUdmAT+X5JsvgiUO6rIgNup5t0bDmG4o v8akJqHzSR0UisM9McOiNdRwfEfl44cAWD1iL2CU6KS2/WD0DMh95ETDLYH8OjGySu8W GMKnbfLITQW/SEoA0grZSILxvEPqltLRIFng9CsZj4a6KA/AiFuyaNWnuPuUA0ftMdRu isppRnYDAwwW1eNGf+Mqw6sULt0Ar+0i5sqXe6KQhh2vyZh/TX9uRZCZsPFGME86MwIo mphA== X-Gm-Message-State: AN3rC/5VSbfndK0st9kJLCxPdyC2D0rX61PAZoP+gQF2EWKvpJ/BhOf9 OXp9HtbgT2MrIkW4 X-Received: by 10.28.218.197 with SMTP id r188mr6373275wmg.0.1492374485290; Sun, 16 Apr 2017 13:28:05 -0700 (PDT) Received: from mai.lan ([2001:41d0:fe90:b800:20c0:6248:a385:db35]) by smtp.gmail.com with ESMTPSA id 81sm7732196wmj.9.2017.04.16.13.28.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 16 Apr 2017 13:28:04 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de Subject: [PATCH 07/29] arm64: arch_timer: Add erratum handler for CPU-specific capability Date: Sun, 16 Apr 2017 22:26:57 +0200 Message-Id: <1492374441-23336-7-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1492374441-23336-1-git-send-email-daniel.lezcano@linaro.org> References: <20170416202542.GV2078@mai> <1492374441-23336-1-git-send-email-daniel.lezcano@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170416_132827_293247_2205D4F3 X-CRM114-Status: GOOD ( 13.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Marc Zyngier , Catalin Marinas , Will Deacon , linux-kernel@vger.kernel.org, "moderated list:ARM ARCHITECTED TIMER DRIVER" MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marc Zyngier 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 --- arch/arm64/include/asm/arch_timer.h | 1 + drivers/clocksource/arm_arch_timer.c | 28 ++++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h index 5cd964e..1b0d7e9 100644 --- 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_timer_read_ool_enabled; enum arch_timer_erratum_match_type { ate_match_dt, + ate_match_local_cap_id, }; struct arch_timer_erratum_workaround { diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index 5c5c2af..532e47fa 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c @@ -214,6 +214,13 @@ bool arch_timer_check_dt_erratum(const struct arch_timer_erratum_workaround *wa, 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, @@ -244,14 +251,16 @@ static void arch_timer_check_ool_workaround(enum arch_timer_erratum_match_type t { 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; @@ -261,8 +270,17 @@ static void arch_timer_check_ool_workaround(enum arch_timer_erratum_match_type t 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 @@ -522,6 +540,8 @@ static void __arch_timer_setup(unsigned type, BUG(); } + arch_timer_check_ool_workaround(ate_match_local_cap_id, NULL); + erratum_workaround_set_sne(clk); } else { clk->features |= CLOCK_EVT_FEAT_DYNIRQ;