From patchwork Fri Feb 26 19:20:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 8441451 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9EC4C9F52D for ; Fri, 26 Feb 2016 19:22:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 878252039E for ; Fri, 26 Feb 2016 19:22:10 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7145D202B8 for ; Fri, 26 Feb 2016 19:22:09 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aZNxm-0000ZQ-L8; Fri, 26 Feb 2016 19:22:06 +0000 Received: from mail-pa0-x232.google.com ([2607:f8b0:400e:c03::232]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aZNxM-00008G-08 for linux-rockchip@lists.infradead.org; Fri, 26 Feb 2016 19:21:43 +0000 Received: by mail-pa0-x232.google.com with SMTP id ho8so57059030pac.2 for ; Fri, 26 Feb 2016 11:21:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=HRgj+PBd0THj/tRXThzMlBlMz+Vsh+g72AEk4yC3xAs=; b=Nk3k4H78Yu2lIs75Z5IQvGhTVDqXRqDBtb7INhAg6wCeBU3lnNKEyovH/bG1F0Fjkr jxqTsOBgChEj3qhw0aRXvWhOfQVEN730zfjczYwxgxm9uF8XYjS/w0AfMcDbYjLAezhH ukG2/hHWA7z6uvrIxOfK3PbwB+PncgKshslYg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=HRgj+PBd0THj/tRXThzMlBlMz+Vsh+g72AEk4yC3xAs=; b=axtmY+KGWd5S2lqxSuFGylBsFar8h4qoVY9ERf6943XImBh45fueMTBAW+FF7VbbgW oRKaqC4vbsSc0+LTmJ1l7VGfL+yzGV63sfBP227bw86/budjVLTh6/2Tbrt4Y6mtdGn0 ZQvQbIPPVDUIwu+4PsFnlG6Mss3y2n+qYEY0o9NsiNqoDlfQ6wwBnfZS9jqatQOmcZXD raltnyKwO3MUQldRnsXqjtmLDcpmtUAWAM16rOqTKd8b47IrFoEk/8lYBSkhTkOx+HVj 11KdP00td2vZ9bTwU/vY8V2D5Zeg3uhZoXDna6pXIjxeAq82J55IiKn2hnT8JUe5biuy qg0A== X-Gm-Message-State: AD7BkJJM9H1cZar3jCyQjbFkTMPVg4W51Fk5IQ6/hjFXBggrFkesMDviztp/voz+DfV/6w== X-Received: by 10.66.155.232 with SMTP id vz8mr4413508pab.53.1456514478551; Fri, 26 Feb 2016 11:21:18 -0800 (PST) Received: from tictac.mtv.corp.google.com ([172.22.65.76]) by smtp.gmail.com with ESMTPSA id cq4sm21094070pad.28.2016.02.26.11.21.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Feb 2016 11:21:17 -0800 (PST) From: Douglas Anderson To: Russell King , Will Deacon , Heiko Stuebner , Matthias Brugger Subject: [PATCH] ARM: errata: Workaround errata A12 818325/852422 A17 852423 Date: Fri, 26 Feb 2016 11:20:59 -0800 Message-Id: <1456514459-12176-1-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 2.7.0.rc3.207.g0ac5344 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160226_112140_346929_0F949EEA X-CRM114-Status: GOOD ( 16.59 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Huang Tao , nico@linaro.org, linux-kernel@vger.kernel.org, Anson.Huang@freescale.com, ard.biesheuvel@linaro.org, Douglas Anderson , Kever Yang , linux-rockchip@lists.infradead.org, chris.brandt@renesas.com, olof@lixom.net, linux-arm-kernel@lists.infradead.org, sebastian.hesselbarth@gmail.com MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, 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 There are several similar errata on Cortex A12 and A17 that all have the same workaround: setting bit[12] of the Feature Register. Technically the list of errata are: - A12 818325: Execution of an UNPREDICTABLE STR or STM instruction might deadlock. Fixed in r0p1. - A12 852422: Execution of a sequence of instructions might lead to either a data corruption or a CPU deadlock. Not fixed in any A12s yet. - A17 852423: Execution of a sequence of instructions might lead to either a data corruption or a CPU deadlock. Not fixed in any A17s yet. Since A12 got renamed to A17 it seems likely that there won't be any future Cortex-A12 cores, so we'll enable for all Cortex-A12. For Cortex-A17 I believe that all known revisions are affected and that all knows revisions means <= r1p2. Presumably if a new A17 was released it would have this problem fixed. Note that in folks previously expressed opposition to this change because: A) It was thought to only apply to r0p0 and there were no known r0p0 boards supported in mainline. B) It was argued that such a workaround beloned in firmware. Now that this same fix solves other errata on real boards (like rk3288) point A) is addressed. Point B) is impossible to address on boards like rk3288. On rk3288 the firmware doesn't stay resident in RAM and isn't involved at all in the suspend/resume process nor in the SMP bringup process. That means that the most the firmware could do would be to set the bit on "core 0" and this bit would be lost at suspend/resume time. It is true that we could write a "generic" solution that saved the boot-time "core 0" value of this register and applied it at SMP bringup / resume time. However, since this register (described as the "Feature Register" in errata) appears to be undocumented (as far as I can tell) and is only modified for these errata, that "generic" solution seems questionably cleaner. The generic solution also won't fix existing users that haven't happened to do a FW update. Note that in ARM64 presumably PSCI will be universal and fixes like this will end up in ATF. Hopefully we are nearing the end of this style of errata workaround. Signed-off-by: Douglas Anderson Signed-off-by: Huang Tao Signed-off-by: Kever Yang --- Note that I have only tested this on Rockchip rk3288 (A12). It seemed like a good idea to apply this to A17 as well but it would be nice to get some testing. Also: if all A17 boards use PSCI and the firmware has a fix for this then we can remove the A17 erratum from this patch. arch/arm/Kconfig | 26 ++++++++++++++++++++++++++ arch/arm/mm/proc-v7.S | 27 +++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 98de149b7715..40a6c15e7595 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1165,6 +1165,32 @@ config ARM_ERRATA_773022 loop buffer may deliver incorrect instructions. This workaround disables the loop buffer to avoid the erratum. +config ARM_ERRATA_818325_852422 + bool "ARM errata: A12: some seqs of opposed cond code instrs => deadlock or corruption" + depends on CPU_V7 + help + This option enables the workaround for: + - Cortex-A12 818325: Execution of an UNPREDICTABLE STR or STM + instruction might deadlock. Fixed in r0p1. + - Cortex-A12 852422: Execution of a sequence of instructions might + lead to either a data corruption or a CPU deadlock. Not fixed in + any Cortex-A12 cores yet. + This workaround for all both errata involves setting bit[12] of the + Feature Register. This bit disables an optimisation applied to a + sequence of 2 instructions that use opposing condition codes. + +config ARM_ERRATA_852423 + bool "ARM errata: A17: some seqs of opposed cond code instrs => deadlock or corruption" + depends on CPU_V7 + help + This option enables the workaround for: + - Cortex-A17 852423: Execution of a sequence of instructions might + lead to either a data corruption or a CPU deadlock. Not fixed in + any Cortex-A17 cores yet. + This is identical to Cortex-A12 erratum 852422. It is a separate + config option from the A12 erratum due to the way errata are checked + for and handled. + endmenu source "arch/arm/common/Kconfig" diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S index 0f8963a7e7d9..96d2972d4d93 100644 --- a/arch/arm/mm/proc-v7.S +++ b/arch/arm/mm/proc-v7.S @@ -353,6 +353,23 @@ __ca9_errata: #endif b __errata_finish +__ca12_errata: +#ifdef CONFIG_ARM_ERRATA_818325_852422 + mrc p15, 0, r10, c15, c0, 1 @ read diagnostic register + orr r10, r10, #1 << 12 @ set bit #12 + mcr p15, 0, r10, c15, c0, 1 @ write diagnostic register +#endif + b __errata_finish + +__ca17_errata: +#ifdef CONFIG_ARM_ERRATA_852423 + cmp r6, #0x12 @ only present up to r1p2 + mrcle p15, 0, r10, c15, c0, 1 @ read diagnostic register + orrle r10, r10, #1 << 12 @ set bit #12 + mcrle p15, 0, r10, c15, c0, 1 @ write diagnostic register +#endif + b __errata_finish + __ca15_errata: #ifdef CONFIG_ARM_ERRATA_773022 cmp r6, #0x4 @ only present up to r0p4 @@ -443,6 +460,16 @@ __v7_setup_cont: teq r0, r10 beq __ca9_errata + /* Cortex-A12 Errata */ + ldr r10, =0x00000c0d @ Cortex-A12 primary part number + teq r0, r10 + beq __ca12_errata + + /* Cortex-A17 Errata */ + ldr r10, =0x00000c0e @ Cortex-A17 primary part number + teq r0, r10 + beq __ca17_errata + /* Cortex-A15 Errata */ ldr r10, =0x00000c0f @ Cortex-A15 primary part number teq r0, r10