From patchwork Mon Oct 9 18:28:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 115292 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2864329qgn; Mon, 9 Oct 2017 11:33:07 -0700 (PDT) X-Google-Smtp-Source: AOwi7QChaBMW4jddUtep/QcIlzvl0DGR2oDQOEGgOdjiK/0sZUVH9kLztIfvQzMdRjaV3NsmWE94 X-Received: by 10.99.182.5 with SMTP id j5mr9644609pgf.71.1507573987419; Mon, 09 Oct 2017 11:33:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507573987; cv=none; d=google.com; s=arc-20160816; b=UQXMayCMSIuvJvDLriklmq2M7qrr+nOfjt1yDL9VwtP8FX1Edg3N0aj3UAAKxzkm81 az80/m92YkUOSAbdpdiuhHWltNM9EBYNi8m7DaONuvsvvNu0SCt7Pu8cc4gepCTWvpwY YVy4Q8z1+YenAJO3Xosb5SP+hqLYrywG54gkpt+EPOUvIzYc9f3FSmPPcwjzoXP4xV5L cgYPu9CGAJ5VXkYbRfvTyjTbK56XF7JR5RQOhQiK/X4S1UyvazZaGV/0RjgzBaKjQeHx uYQATv3opdvEv9eMza6LOpu27Z3QglbH1OviNBcSRLyBKJJ1yrQ1q9dSi+TxkMMu+OMQ lZGw== 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=4C7pszClGLwmFqurPVudYBjw91iyOSCKkWvSlXTmgaA=; b=EcSFPbIRBgWleDAdqTH460vC8ptQn1O8DAH7pOg+pNINy8NWCNAk4k1InIRJ4N5aSX lrlOG8OtKIHcx1kvlEH6iwsKvSsr3GvIAdgVvYcGQt2dqBnhw9/7JfFQp6T0aowJ1JMA 5V6dJYlSm6SZZtfoQpNRh6oSiYPXrFelSwuCvIdx3h2t3nUv8dhmPmkG3zxZ6Mpm54ou tksMwlHcESmX0veM3Bq0UKVnMMgm9BMnr/AyHmtJjx8F+0ZWZI7aPm5/yzQKu0/Yp8Jq BgYvE51eicO5JH+CE/J7Tj8N1EAa9AcnaD1ZIIGsdS5y/pSNV3yj8f1NT3zN4sMJBVpU 1lJA== 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.07; Mon, 09 Oct 2017 11:33:07 -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 S1755455AbdJISdF (ORCPT + 26 others); Mon, 9 Oct 2017 14:33:05 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:33788 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751050AbdJISau (ORCPT ); Mon, 9 Oct 2017 14:30:50 -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 2BF6D15BF; Mon, 9 Oct 2017 11:30:50 -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 37D553F483; Mon, 9 Oct 2017 11:30:49 -0700 (PDT) From: Mark Rutland To: linux-kernel@vger.kernel.org Cc: Mark Rutland , Mauro Carvalho Chehab , Sakari Ailus Subject: [PATCH 06/13] media: dvb_ringbuffer: kill off ACCESS_ONCE() Date: Mon, 9 Oct 2017 19:28:43 +0100 Message-Id: <1507573730-8083-7-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 DVB ringbuffer 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: Mauro Carvalho Chehab Cc: Sakari Ailus --- drivers/media/dvb-core/dvb_ringbuffer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 1.9.1 diff --git a/drivers/media/dvb-core/dvb_ringbuffer.c b/drivers/media/dvb-core/dvb_ringbuffer.c index 2322af1..5301162 100644 --- a/drivers/media/dvb-core/dvb_ringbuffer.c +++ b/drivers/media/dvb-core/dvb_ringbuffer.c @@ -66,12 +66,12 @@ ssize_t dvb_ringbuffer_free(struct dvb_ringbuffer *rbuf) { ssize_t free; - /* ACCESS_ONCE() to load read pointer on writer side + /* READ_ONCE() to load read pointer on writer side * this pairs with smp_store_release() in dvb_ringbuffer_read(), * dvb_ringbuffer_read_user(), dvb_ringbuffer_flush(), * or dvb_ringbuffer_reset() */ - free = ACCESS_ONCE(rbuf->pread) - rbuf->pwrite; + free = READ_ONCE(rbuf->pread) - rbuf->pwrite; if (free <= 0) free += rbuf->size; return free-1; @@ -143,7 +143,7 @@ ssize_t dvb_ringbuffer_read_user(struct dvb_ringbuffer *rbuf, u8 __user *buf, si todo -= split; /* smp_store_release() for read pointer update to ensure * that buf is not overwritten until read is complete, - * this pairs with ACCESS_ONCE() in dvb_ringbuffer_free() + * this pairs with READ_ONCE() in dvb_ringbuffer_free() */ smp_store_release(&rbuf->pread, 0); } @@ -168,7 +168,7 @@ void dvb_ringbuffer_read(struct dvb_ringbuffer *rbuf, u8 *buf, size_t len) todo -= split; /* smp_store_release() for read pointer update to ensure * that buf is not overwritten until read is complete, - * this pairs with ACCESS_ONCE() in dvb_ringbuffer_free() + * this pairs with READ_ONCE() in dvb_ringbuffer_free() */ smp_store_release(&rbuf->pread, 0); }