From patchwork Fri Mar 3 00:19:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timur Tabi X-Patchwork-Id: 9601819 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 A73D460453 for ; Fri, 3 Mar 2017 00:19:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97E68285FD for ; Fri, 3 Mar 2017 00:19:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8CBC428631; Fri, 3 Mar 2017 00:19:47 +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=ham 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 F1331285FD for ; Fri, 3 Mar 2017 00:19:46 +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:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:Subject:To: From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=ks8AWtYBo0Ga99s7d4b0PjCJPFO2GC0abJkxTYxhSyI=; b=NY/NUwH7q+Vhbr 8Hd9dnng0tSIYt6rLNi6zn634roI2P7rDEIPZeIqtCFcMN1rRD8C40ELU5L2P/D1bLzw6z/DCgkxF QM6XFPI0+cK5AmAaiIV3jAO6qPR9q8IVDDFHUlIOjVKQzr3OW6zpE8pupUGjNW4PYLs8SnyU4fVTP 0f0PWUS4NnZuwXIICvvgh3z1z2D9kBmRh7fSEL4FmqKBICUgyptMpJ6A0QlfRWI7LZtmnn6JVSKv4 KX8kdlIehuckcbrnsvCw3TcI6UzMJ2tXHP1s05m3moNahuwdkBMg8yE9aU/B9cRIirG/uClW8K1nx DGwl9trC0Rbrk4qde2DQ==; 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 1cjawj-00055Q-DV; Fri, 03 Mar 2017 00:19:45 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cjawg-00054W-Lq for linux-arm-kernel@lists.infradead.org; Fri, 03 Mar 2017 00:19:44 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id D880960D92; Fri, 3 Mar 2017 00:19:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1488500361; bh=6KrjL7yuwFArCNCfZS813XXFFzDXWAuDK71QXtVwFWY=; h=From:To:Subject:Date:From; b=b240BgCHgs86J6TytV0KJftTw0dnSn73YY/G987PYKVOr/Aaf5P2NtGipjP2wV6aL MTN0dkDM42V1/wwKpkPR/bFEXoXGDbiiFxEUcz+/MLbbglTrNJSckKvEPRACW4iG4H R/a99aNCXcOtPg1hbPniZJgxC+5/6XoWUZ+ktQQo= Received: from timur-ubuntu.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: timur@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id E525060D92; Fri, 3 Mar 2017 00:19:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1488500361; bh=6KrjL7yuwFArCNCfZS813XXFFzDXWAuDK71QXtVwFWY=; h=From:To:Subject:Date:From; b=b240BgCHgs86J6TytV0KJftTw0dnSn73YY/G987PYKVOr/Aaf5P2NtGipjP2wV6aL MTN0dkDM42V1/wwKpkPR/bFEXoXGDbiiFxEUcz+/MLbbglTrNJSckKvEPRACW4iG4H R/a99aNCXcOtPg1hbPniZJgxC+5/6XoWUZ+ktQQo= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E525060D92 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=timur@codeaurora.org From: Timur Tabi To: Neil Leeder , Shanker Donthineni , agustinv@codeaurora.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] arm64: mm: Add workaround for Qualcomm Technologies Falkor erratum E1029 Date: Thu, 2 Mar 2017 18:19:15 -0600 Message-Id: <1488500355-7199-1-git-send-email-timur@codeaurora.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170302_161942_767295_12E083E4 X-CRM114-Status: GOOD ( 13.95 ) 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: , 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: Neil Leeder The Falkor core includes support for generating interrupt requests from CPU or L2 performance monitor events or cycle counter overflows, resulting in an IRQ or FIQ asynchronous interrupt request. In cases where the CPU performance monitor interrupt request is generated in close proximity to the instruction stream executing a WFI or WFE instruction, the Falkor core may hang prior to entering the wait state. The workaround for this condition is to add a config option and alternative_if processing in cpu_do_idle. For falkor v1 processors this will read PMINTENSET (PMU interrupt enabled register), clear all enabled interrupts by writing to PMINTENCLR, go into wfi as usual and then restore the PMU interrupts. For processors other than Falkor v1, these instructions are replaced by nops. Signed-off-by: Neil Leeder Signed-off-by: Shanker Donthineni --- arch/arm64/Kconfig | 8 ++++++++ arch/arm64/include/asm/cpucaps.h | 3 ++- arch/arm64/kernel/cpu_errata.c | 22 ++++++++++++++++++++++ arch/arm64/mm/proc.S | 24 +++++++++++++++++++++++- 4 files changed, 55 insertions(+), 2 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index a39029b..4168583 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -508,6 +508,14 @@ config QCOM_FALKOR_ERRATUM_1009 If unsure, say Y. +config QCOM_FALKOR_ERRATUM_E1029 + depends on PERF_EVENTS + bool "Falkor E1029: PMU interrupt during WFI may cause hang" + default y + help + Falkor CPU may hang if PMU interrupt occurs during WFI. + Turn off PMU interrupts during WFI in idle routine. + endmenu diff --git a/arch/arm64/include/asm/cpucaps.h b/arch/arm64/include/asm/cpucaps.h index fb78a5d..86f5042 100644 --- a/arch/arm64/include/asm/cpucaps.h +++ b/arch/arm64/include/asm/cpucaps.h @@ -37,7 +37,8 @@ #define ARM64_HAS_NO_FPSIMD 16 #define ARM64_WORKAROUND_REPEAT_TLBI 17 #define ARM64_WORKAROUND_QCOM_FALKOR_E1003 18 +#define ARM64_WORKAROUND_QCOM_FALKOR_E1029 19 -#define ARM64_NCAPS 19 +#define ARM64_NCAPS 20 #endif /* __ASM_CPUCAPS_H */ diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c index f6cc67e..3e9fdbf 100644 --- a/arch/arm64/kernel/cpu_errata.c +++ b/arch/arm64/kernel/cpu_errata.c @@ -20,6 +20,7 @@ #include #include #include +#include static bool __maybe_unused is_affected_midr_range(const struct arm64_cpu_capabilities *entry, int scope) @@ -46,6 +47,16 @@ static int cpu_enable_trap_ctr_access(void *__unused) return 0; } +#ifdef CONFIG_QCOM_FALKOR_ERRATUM_E1029 +static bool __maybe_unused +ckeck_falkor_erratum_e1029(const struct arm64_cpu_capabilities *e, int scope) +{ + bool in_hyp = is_hyp_mode_available(); + + return in_hyp ? is_affected_midr_range(e, scope) : false; +} +#endif + #define MIDR_RANGE(model, min, max) \ .def_scope = SCOPE_LOCAL_CPU, \ .matches = is_affected_midr_range, \ @@ -151,6 +162,17 @@ static int cpu_enable_trap_ctr_access(void *__unused) MIDR_CPU_VAR_REV(0, 0)), }, #endif +#ifdef CONFIG_QCOM_FALKOR_ERRATUM_E1029 + { + .desc = "Qualcomm Technologies Falkor erratum 1029", + .capability = ARM64_WORKAROUND_QCOM_FALKOR_E1029, + .def_scope = SCOPE_LOCAL_CPU, + .matches = ckeck_falkor_erratum_e1029, + .midr_model = MIDR_QCOM_FALKOR_V1, + .midr_range_min = 0x00, + .midr_range_max = 0x00 + }, +#endif { } }; diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S index 877d42f..04027f7 100644 --- a/arch/arm64/mm/proc.S +++ b/arch/arm64/mm/proc.S @@ -49,9 +49,31 @@ * Idle the processor (wait for interrupt). */ ENTRY(cpu_do_idle) - dsb sy // WFI may enter a low-power mode +#ifndef CONFIG_QCOM_FALKOR_ERRATUM_E1029 + dsb sy // WFI may enter a low-power mode wfi ret +#else +alternative_if_not ARM64_WORKAROUND_QCOM_FALKOR_E1029 + dsb sy // WFI may enter a low-power mode + wfi + ret + nop + nop + nop + nop + nop +alternative_else + mrs x2, pmintenset_el1 + msr pmintenclr_el1, x2 + isb + dsb sy // WFI may enter a low-power mode + wfi + msr pmintenset_el1, x2 + isb + ret +alternative_endif +#endif ENDPROC(cpu_do_idle) #ifdef CONFIG_CPU_PM