From patchwork Sun Aug 25 14:25:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 2849316 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4A388BF546 for ; Sun, 25 Aug 2013 14:26:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1B8B9201F6 for ; Sun, 25 Aug 2013 14:26:31 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9BB86201F4 for ; Sun, 25 Aug 2013 14:26:29 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VDbGr-00021X-2S; Sun, 25 Aug 2013 14:26:25 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VDbGp-0004Jn-0b; Sun, 25 Aug 2013 14:26:23 +0000 Received: from mail-oa0-x234.google.com ([2607:f8b0:4003:c02::234]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VDbGj-0004Iw-IX for linux-arm-kernel@lists.infradead.org; Sun, 25 Aug 2013 14:26:18 +0000 Received: by mail-oa0-f52.google.com with SMTP id f4so2590490oah.39 for ; Sun, 25 Aug 2013 07:25:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=LX4QwP7NIqhxB49fmtDv0vdVv6rKUBd+kNv7pbD2o00=; b=BV8ZATtj2ck9hum7WUn/uZjM2SwTHMqWnZTH4+95e5YF4fKmaeg38OnSuGgo8vrnlE 3b1QjQQAN6YLYo8OPHntuTYx/fdp8GoDzN8uDHNIdZN0h6Yai7WKfdsE0xDU6IZeweIb PG7DtB2JE1WOyXJwf3o2GReW6WlD3KP34TWvADg9brCeve6+WQAqiXt/CZfh8gDsS15D N3jW3b+j19ITdU9ExZ5Sg0PzMEr0pI6rV6u4nGdly+nw+1QBNMVL5qETZ8bgoUhcBDff dwRmdHs+is1dSFv6ClygivGLNno7SOvoZEggULACpuzZ5lIGTWCJVDQdQPkFQQLB/cK8 PKmw== X-Received: by 10.182.104.130 with SMTP id ge2mr9687780obb.6.1377440756306; Sun, 25 Aug 2013 07:25:56 -0700 (PDT) Received: from rob-laptop.grandenetworks.net (65-36-73-129.dyn.grandenetworks.net. [65.36.73.129]) by mx.google.com with ESMTPSA id tz10sm9532348obc.10.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 25 Aug 2013 07:25:55 -0700 (PDT) From: Rob Herring To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v4] ARM: Add check for Cortex-A15 errata 798181 ECO Date: Sun, 25 Aug 2013 09:25:47 -0500 Message-Id: <1377440747-4564-1-git-send-email-robherring2@gmail.com> X-Mailer: git-send-email 1.8.1.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130825_102617_749562_4DF2FABB X-CRM114-Status: GOOD ( 18.18 ) X-Spam-Score: -1.8 (-) Cc: Russell King , Will Deacon , Rob Herring X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Rob Herring The work-around for A15 errata 798181 is not needed if appropriate ECO fixes have been applied to r3p2 and earlier core revisions. This can be checked by reading REVIDR register bits 4 and 9. If only bit 4 is set, then the IPI broadcast can be skipped. Signed-off-by: Rob Herring Reviewed-by: Will Deacon --- v4: - Move code from setup.c back to smp_tlb.c - Use IS_ENABLED macro v3: - Rebase to v3.11-rc5 due to commit 1f49856 (ARM: 7789/1: Do not run dummy_flush_tlb_a15_erratum() on non-Cortex-A15) - Move the revision checking out of line and use function ptrs. v2: - Determine the work-around needed and save in a static varible instead of re-reading the ID registers. arch/arm/include/asm/cputype.h | 1 + arch/arm/include/asm/tlbflush.h | 34 +++++++--------------------------- arch/arm/kernel/setup.c | 2 ++ arch/arm/kernel/smp_tlb.c | 39 +++++++++++++++++++++++++++++++++++++-- arch/arm/mm/context.c | 3 +-- 5 files changed, 48 insertions(+), 31 deletions(-) diff --git a/arch/arm/include/asm/cputype.h b/arch/arm/include/asm/cputype.h index 9672e97..acdde76 100644 --- a/arch/arm/include/asm/cputype.h +++ b/arch/arm/include/asm/cputype.h @@ -10,6 +10,7 @@ #define CPUID_TLBTYPE 3 #define CPUID_MPUIR 4 #define CPUID_MPIDR 5 +#define CPUID_REVIDR 6 #ifdef CONFIG_CPU_V7M #define CPUID_EXT_PFR0 0x40 diff --git a/arch/arm/include/asm/tlbflush.h b/arch/arm/include/asm/tlbflush.h index f467e9b..decff8d 100644 --- a/arch/arm/include/asm/tlbflush.h +++ b/arch/arm/include/asm/tlbflush.h @@ -443,36 +443,16 @@ static inline void local_flush_bp_all(void) isb(); } -#include -#ifdef CONFIG_ARM_ERRATA_798181 -static inline int erratum_a15_798181(void) -{ - unsigned int midr = read_cpuid_id(); - - /* Cortex-A15 r0p0..r3p2 affected */ - if ((midr & 0xff0ffff0) != 0x410fc0f0 || midr > 0x413fc0f2) - return 0; - return 1; -} - -static inline void dummy_flush_tlb_a15_erratum(void) -{ - /* - * Dummy TLBIMVAIS. Using the unmapped address 0 and ASID 0. - */ - asm("mcr p15, 0, %0, c8, c3, 1" : : "r" (0)); - dsb(); -} -#else -static inline int erratum_a15_798181(void) -{ - return 0; -} +extern void erratum_a15_798181_init(void); +extern bool (*erratum_a15_798181_handler)(void); -static inline void dummy_flush_tlb_a15_erratum(void) +static inline bool erratum_a15_798181(void) { + if (unlikely(IS_ENABLED(CONFIG_ARM_ERRATA_798181) && + erratum_a15_798181_handler)) + return erratum_a15_798181_handler(); + return false; } -#endif /* * flush_pmd_entry diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index afc2489..f3030e3 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -599,6 +599,8 @@ static void __init setup_processor(void) elf_hwcap &= ~(HWCAP_THUMB | HWCAP_IDIVT); #endif + erratum_a15_798181_init(); + feat_v6_fixup(); cacheid_init(); diff --git a/arch/arm/kernel/smp_tlb.c b/arch/arm/kernel/smp_tlb.c index c2edfff..1070621 100644 --- a/arch/arm/kernel/smp_tlb.c +++ b/arch/arm/kernel/smp_tlb.c @@ -70,6 +70,43 @@ static inline void ipi_flush_bp_all(void *ignored) local_flush_bp_all(); } +bool (*erratum_a15_798181_handler)(void); + +static bool erratum_a15_798181_partial(void) +{ + asm("mcr p15, 0, %0, c8, c3, 1" : : "r" (0)); + dsb(); + return false; +} + +static bool erratum_a15_798181_broadcast(void) +{ + asm("mcr p15, 0, %0, c8, c3, 1" : : "r" (0)); + dsb(); + return true; +} + +bool (*erratum_a15_798181_handler)(void); + +void erratum_a15_798181_init(void) +{ + unsigned int midr = read_cpuid_id(); + unsigned int revidr = read_cpuid(CPUID_REVIDR); + + if (!IS_ENABLED(CONFIG_ARM_ERRATA_798181)) + return; + + /* Cortex-A15 r0p0..r3p2 w/o ECO fix affected */ + if ((midr & 0xff0ffff0) != 0x410fc0f0 || midr > 0x413fc0f2 || + (revidr & 0x210) == 0x210) { + return; + } + if (revidr & 0x10) + erratum_a15_798181_handler = erratum_a15_798181_partial; + else + erratum_a15_798181_handler = erratum_a15_798181_broadcast; +} + static void ipi_flush_tlb_a15_erratum(void *arg) { dmb(); @@ -80,7 +117,6 @@ static void broadcast_tlb_a15_erratum(void) if (!erratum_a15_798181()) return; - dummy_flush_tlb_a15_erratum(); smp_call_function(ipi_flush_tlb_a15_erratum, NULL, 1); } @@ -92,7 +128,6 @@ static void broadcast_tlb_mm_a15_erratum(struct mm_struct *mm) if (!erratum_a15_798181()) return; - dummy_flush_tlb_a15_erratum(); this_cpu = get_cpu(); a15_erratum_get_cpumask(this_cpu, mm, &mask); smp_call_function_many(&mask, ipi_flush_tlb_a15_erratum, NULL, 1); diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c index 4a05444..28daa1c 100644 --- a/arch/arm/mm/context.c +++ b/arch/arm/mm/context.c @@ -245,8 +245,7 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk) if (cpumask_test_and_clear_cpu(cpu, &tlb_flush_pending)) { local_flush_bp_all(); local_flush_tlb_all(); - if (erratum_a15_798181()) - dummy_flush_tlb_a15_erratum(); + erratum_a15_798181(); } atomic64_set(&per_cpu(active_asids, cpu), asid);