From patchwork Mon Apr 21 16:09:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 4025591 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 C37739F1F4 for ; Mon, 21 Apr 2014 16:13:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E9C4A201F7 for ; Mon, 21 Apr 2014 16:13:45 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 150C1201DC for ; Mon, 21 Apr 2014 16:13:45 +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 1WcGn9-00061C-7F; Mon, 21 Apr 2014 16:09:59 +0000 Received: from mail-oa0-f44.google.com ([209.85.219.44]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WcGn6-0005np-ES for linux-arm-kernel@lists.infradead.org; Mon, 21 Apr 2014 16:09:56 +0000 Received: by mail-oa0-f44.google.com with SMTP id n16so1682643oag.31 for ; Mon, 21 Apr 2014 09:09:32 -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=Ncpr18kHfR2I89uIWcC1HGNzBwkE1bL62BbGayIcklA=; b=RVaMvGhtd38vgIcwwsx+yhlTiDDR0cIQM3nrlHlRZ1960sTbXH63SJUnTEXrXcN+dB Bjo0w41yq3fA5uSmpSkfvLDTgi714tabYDdlWD+KZuXyjpzvIiCY7+nZppRr/Fa8uBz4 k0fAzhC3PzSR6EI4wIL/TUkzL9NM46J7OjdX+AlOPpnBppQ+jzgi6ha3PegbN6loA/Fr PKlD0f1DK25T4L0kiRYcVBwSwLllJoxCQFqsUnIT+s2VIEBzm4H9XQ/9PH8w+CON/G6c LgZarWDuufQPENDFemvHQjbszfzLWr7H7nf0+gVP9iYdW2n7YEUMp4u50hdTQ27J1rfe Dv4w== X-Received: by 10.182.27.133 with SMTP id t5mr1325646obg.65.1398096572071; Mon, 21 Apr 2014 09:09:32 -0700 (PDT) Received: from localhost.localdomain (72-48-77-163.dyn.grandenetworks.net. [72.48.77.163]) by mx.google.com with ESMTPSA id jr2sm5146160obb.8.2014.04.21.09.09.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 21 Apr 2014 09:09:31 -0700 (PDT) From: Rob Herring To: linux-arm-kernel@lists.infradead.org, Will Deacon , Catalin Marinas Subject: [PATCH v3] arm64: enable EDAC on arm64 Date: Mon, 21 Apr 2014 11:09:16 -0500 Message-Id: <1398096556-26799-1-git-send-email-robherring2@gmail.com> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140421_090956_534033_BAEC814D X-CRM114-Status: GOOD ( 15.13 ) X-Spam-Score: -0.6 (/) Cc: Rob Herring , rvaswani@codeaurora.org, Tomasz Nowicki 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=-2.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 --- v3: - Drop "cc" clobber annotation. 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 | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 arch/arm64/include/asm/edac.h diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index e6e4d37..4c1f857 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -14,6 +14,7 @@ config ARM64 select COMMON_CLK select CPU_PM if (SUSPEND || CPU_IDLE) select DCACHE_WORD_ACCESS + select EDAC_SUPPORT select GENERIC_CLOCKEVENTS select GENERIC_CLOCKEVENTS_BROADCAST if SMP select GENERIC_CPU_AUTOPROBE diff --git a/arch/arm64/include/asm/edac.h b/arch/arm64/include/asm/edac.h new file mode 100644 index 0000000..8a3d176 --- /dev/null +++ b/arch/arm64/include/asm/edac.h @@ -0,0 +1,38 @@ +/* + * 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. + */ +#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) : : ); + } +} +#endif