From patchwork Mon Oct 9 18:28:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 115293 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2864871qgn; Mon, 9 Oct 2017 11:33:44 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCVjbS+TE3ksRMDpT+Xz1SoiZYLtsxUHtW5ZR0FIQ0nL5LQAMWjfs9xAvGH6PCoCZylrW6U X-Received: by 10.84.130.67 with SMTP id 61mr10005425plc.131.1507574024326; Mon, 09 Oct 2017 11:33:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507574024; cv=none; d=google.com; s=arc-20160816; b=ze5jTxYRPKmKBKLy2EJrLJ6Bky+KtTOVkBk79DyfVNERTv7aWVngJLMcAp93Wl+i0m X5OqRzIDVqNI0xTO1QjnTfdryK+jpV8cgP/HSDSf1tzBO/JeYThKREMRb+o0DLlGJhwT DdNsnMwRhzvG8a42N95UoXbdQggBEGC5S7tzbHIWeq2Ej7QpSyTrE6IL/HkU0mpB4QFD Lay887gs3yzq17xQVKlqdohq0EFb1lsKNtjT/sDhn28UVYLcwL2UaW4BUFVkqQ1KHQhI Su9mfGeqv5mdSgWIvPFL9ljZclqKrLKCaXpInmmr1nuGNrCbenXvk6J1M+xJA4On6wTF DGlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=DGU8g+qVvoZCf0N3KcgoHczOwnUzfrYXUg55RL+UoVY=; b=evBGj3/2J/lfK5dBCsmZU96tXVRpqqs8lkzZ7aXaO7yxKYYwKvdKOjcrGT7HfZSG0c soh1amEkellj8W2bJqLscVFuQUyoovc1yc/ablZ0jRQka3sAogj1zNhk3g5PzU4wb5SE L4YGlOHyGcB0PUzpjPWMdgyRPgMYcyCd+XsDQW4oLwgGqZ4HUU/NY7klGZCfnQIKLuXN aZRivKHIlzoS+ueZ51Ehq+Ns7jRunj24SgJfbOhyyyWZlLYUF9itru22olvslEk67M1p 8Igh/vFdomJ404rxhMzcU0U/HicNujeWLXfzmu6KOD2G2BpwVPyYwOmhM9W5+vXTazDY IMdQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f1si3318731pld.151.2017.10.09.11.33.44; Mon, 09 Oct 2017 11:33:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755419AbdJISdl (ORCPT + 26 others); Mon, 9 Oct 2017 14:33:41 -0400 Received: from foss.arm.com ([217.140.101.70]:33752 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755111AbdJISai (ORCPT ); Mon, 9 Oct 2017 14:30:38 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 827061596; Mon, 9 Oct 2017 11:30:38 -0700 (PDT) Received: from leverpostej.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8DC583F483; Mon, 9 Oct 2017 11:30:37 -0700 (PDT) From: Mark Rutland To: linux-kernel@vger.kernel.org Cc: Mark Rutland , Borislav Petkov , Thor Thayer Subject: [PATCH 02/13] EDAC, altera: kill off ACCESS_ONCE() Date: Mon, 9 Oct 2017 19:28:39 +0100 Message-Id: <1507573730-8083-3-git-send-email-mark.rutland@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507573730-8083-1-git-send-email-mark.rutland@arm.com> References: <1507573730-8083-1-git-send-email-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For several reasons, it is desirable to use {READ,WRITE}_ONCE() in preference to ACCESS_ONCE(), and new code is expected to use one of the former. So far, there's been no reason to change most existing uses of ACCESS_ONCE(), as these aren't currently harmful. However, for some features it is necessary to instrument reads and writes separately, which is not possible with ACCESS_ONCE(). This distinction is critical to correct operation. It's possible to transform the bulk of kernel code using the Coccinelle script below. However, this doesn't handle comments, leaving references to ACCESS_ONCE() instances which have been removed. As a preparatory step, this patch converts the Altera EDAC code and comments to use {READ,WRITE}_ONCE() consistently. ---- virtual patch @ depends on patch @ expression E1, E2; @@ - ACCESS_ONCE(E1) = E2 + WRITE_ONCE(E1, E2) @ depends on patch @ expression E; @@ - ACCESS_ONCE(E) + READ_ONCE(E) ---- Signed-off-by: Mark Rutland Cc: Borislav Petkov Cc: Thor Thayer --- drivers/edac/altera_edac.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) -- 1.9.1 Acked-by: Thor Thayer diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c index 346c498..11d6419 100644 --- a/drivers/edac/altera_edac.c +++ b/drivers/edac/altera_edac.c @@ -175,11 +175,11 @@ static ssize_t altr_sdr_mc_err_inject_write(struct file *file, /* * To trigger the error, we need to read the data back * (the data was written with errors above). - * The ACCESS_ONCE macros and printk are used to prevent the + * The READ_ONCE macros and printk are used to prevent the * the compiler optimizing these reads out. */ - reg = ACCESS_ONCE(ptemp[0]); - read_reg = ACCESS_ONCE(ptemp[1]); + reg = READ_ONCE(ptemp[0]); + read_reg = READ_ONCE(ptemp[1]); /* Force Read */ rmb(); @@ -618,7 +618,7 @@ static ssize_t altr_edac_device_trig(struct file *file, for (i = 0; i < (priv->trig_alloc_sz / sizeof(*ptemp)); i++) { /* Read data so we're in the correct state */ rmb(); - if (ACCESS_ONCE(ptemp[i])) + if (READ_ONCE(ptemp[i])) result = -1; /* Toggle Error bit (it is latched), leave ECC enabled */ writel(error_mask, (drvdata->base + priv->set_err_ofst)); @@ -635,7 +635,7 @@ static ssize_t altr_edac_device_trig(struct file *file, /* Read out written data. ECC error caused here */ for (i = 0; i < ALTR_TRIGGER_READ_WRD_CNT; i++) - if (ACCESS_ONCE(ptemp[i]) != i) + if (READ_ONCE(ptemp[i]) != i) edac_printk(KERN_ERR, EDAC_DEVICE, "Read doesn't match written data\n");