From patchwork Fri Nov 22 21:05:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 3224231 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0ABA19F3AE for ; Fri, 22 Nov 2013 21:05:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 02D8420717 for ; Fri, 22 Nov 2013 21:05:57 +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 C204F20709 for ; Fri, 22 Nov 2013 21:05:55 +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 1VjxvC-0003Gl-O3; Fri, 22 Nov 2013 21:05:50 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VjxvA-00026B-AE; Fri, 22 Nov 2013 21:05:48 +0000 Received: from mail-ie0-x22f.google.com ([2607:f8b0:4001:c03::22f]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vjxv6-00025A-7o for linux-arm-kernel@lists.infradead.org; Fri, 22 Nov 2013 21:05:45 +0000 Received: by mail-ie0-f175.google.com with SMTP id x13so2983468ief.20 for ; Fri, 22 Nov 2013 13:05:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=tQOXmXpz3YDL2PCht7RwISsHiqUdt80hV+Zp+KUIb30=; b=MlUswes6hff6MY/WrL2XptVRWfWLTVeO978UqxOUMw5P3pdv9vgpqi+X3jWcSMBtrK iJxJGxPc1XJiJenrHOUq9MFxq0cv9XPJDPMFjCXw+7FvH1+BjP7uAIuDce1R3ndSzdjN hIoVKtC4c5HbWKYsCCzHrpDl5RfW/CiSpZESfOZ7bNar8EybGpu+8iTTMHuf5k4PhGbX jDu+asFVFnZ27ahFTJt5VKGKvEX9+Pn4sGv60gRyiuTLAYkWFfZ08bpgRFKyUfQaVD7Y vPdxHnYssPi5vBcK9GYmbjwlJC9gLc3S1rrvXgBlzBIlo5TBIkjpKbx3aHqPkV2fVVVC Rbjw== X-Received: by 10.42.82.196 with SMTP id e4mr2380626icl.58.1385154319505; Fri, 22 Nov 2013 13:05:19 -0800 (PST) Received: from rob-laptop.calxeda.com ([173.226.190.126]) by mx.google.com with ESMTPSA id f5sm11432183igc.4.2013.11.22.13.05.18 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 22 Nov 2013 13:05:18 -0800 (PST) From: Rob Herring To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2] arm64: enable EDAC on arm64 Date: Fri, 22 Nov 2013 15:05:08 -0600 Message-Id: <1385154308-31335-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-20131122_160544_368260_4C51DFD7 X-CRM114-Status: GOOD ( 14.45 ) X-Spam-Score: -1.8 (-) Cc: Catalin Marinas , 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=-4.6 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 Implement atomic_scrub and enable EDAC for arm64. Signed-off-by: Rob Herring Cc: Catalin Marinas Cc: Will Deacon --- v2: - Add loop for exclusive store success - Fix size to be 32-bits at a time. The framework gives no alignment guarantees. arch/arm64/Kconfig | 1 + arch/arm64/include/asm/edac.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 arch/arm64/include/asm/edac.h diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 88c8b6c1..109687a 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -11,6 +11,7 @@ config ARM64 select BUILDTIME_EXTABLE_SORT select CLONE_BACKWARDS select COMMON_CLK + select EDAC_SUPPORT select GENERIC_CLOCKEVENTS select GENERIC_IOMAP select GENERIC_IRQ_PROBE diff --git a/arch/arm64/include/asm/edac.h b/arch/arm64/include/asm/edac.h new file mode 100644 index 0000000..6d2d262 --- /dev/null +++ b/arch/arm64/include/asm/edac.h @@ -0,0 +1,43 @@ +/* + * Copyright 2013 Calxeda, Inc. + * Based on PPC version Copyright 2007 MontaVista Software, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ +#ifndef ASM_EDAC_H +#define ASM_EDAC_H +/* + * ECC atomic, DMA, SMP and interrupt safe scrub function. + * Implements the per arch atomic_scrub() that EDAC use for software + * ECC scrubbing. It reads memory and then writes back the original + * value, allowing the hardware to detect and correct memory errors. + */ +static inline void atomic_scrub(void *va, u32 size) +{ + unsigned int *virt_addr = va; + unsigned int i; + + for (i = 0; i < size / sizeof(*virt_addr); i++, virt_addr++) { + long result; + unsigned long tmp; + + asm volatile("// atomic_scrub\n" + "1: ldxr %w0, %2\n" + " stxr %w1, %w0, %2\n" + " cbnz %w1, 1b" + : "=&r" (result), "=&r" (tmp), "+Q" (*virt_addr) + : : "cc"); + } +} + +#endif