From patchwork Mon Oct 23 21:07:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 116872 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5083925qgn; Mon, 23 Oct 2017 14:09:49 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SvjCmfJ0YBV32WZT0QC9WeHX3EKn8MTxxAS7Gt22DiDidbaZ1Bxy7KcgroX+3BYgaETjeV X-Received: by 10.98.65.27 with SMTP id o27mr14485749pfa.327.1508792989787; Mon, 23 Oct 2017 14:09:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508792989; cv=none; d=google.com; s=arc-20160816; b=kT83W0L6wgniO2p8TjRqcgr9N/OyOdBYJCVHAwoI0N5EG4FSF9mExmVbsVXeErT7Zx 6bw4GjavH6y7da+QLAUjM7RIqX+VZM+eEEcxKBmStDEf0Xh14XZZ+Xfe2MScPMOe+Imj lt4lKsYzn8lDosia5drK8uTGGpvfh2wyopa5lCzM+0evqXPuchKm7xia+K9jGGqLYGF6 GbsB2PlN+SyHqaSwWn8e7nV+ZzDJ6gC+qrbKhO0dPfyUdAg/3gfX5XckiVQZcynCvfF5 ZDDuLuBLLREwMWptZv3wbxTcmR7jnCS8lB4A717lhnjBSlc3lk/8gVfwmMyb8LIw0y3D 5EQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from:arc-authentication-results; bh=eI+gJ2rh0hQuF1xENBa3Bva0Dk9Kpt7lNT2rn8trvPI=; b=tVOyf6qa4O/wLEha8sxsww+wR3H3zTJDxi1TeQToWydzqPncj9AGpsk5nXeM6Gjrx4 KVfogQdTiWZGztC8vtp3j2N3/Hf7b3zJ76lA0nqEurljVDGJoxWmxkQ1VAY9EfXDyoE9 WIxXItwMHQj3s6ZpNWcxc4y+/PeXP4KYCsmQZlcK7HJzKluA5f33V63IF4ybpq+Oq64G M+RZiXywcE7vAobMNFHaGiCemKiVNaWTY2SAv7Rg/orEaxlov/Y4iOsYe0JbTS6cCfoP 9AOPcH3JoDmlZHSGvTPtGnnyDBc4uLF0QSqVHKP0UNaFKv6ZHWO4s5TbXQENF9oOq6MO KLDA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w134si5862725pfd.462.2017.10.23.14.09.49; Mon, 23 Oct 2017 14:09:49 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932221AbdJWVJs (ORCPT + 27 others); Mon, 23 Oct 2017 17:09:48 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:40300 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751632AbdJWVHn (ORCPT ); Mon, 23 Oct 2017 17:07:43 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v9NL7LxM124427 for ; Mon, 23 Oct 2017 17:07:42 -0400 Received: from e18.ny.us.ibm.com (e18.ny.us.ibm.com [129.33.205.208]) by mx0a-001b2d01.pphosted.com with ESMTP id 2dskcm4ttr-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 23 Oct 2017 17:07:42 -0400 Received: from localhost by e18.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 23 Oct 2017 17:07:40 -0400 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e18.ny.us.ibm.com (146.89.104.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 23 Oct 2017 17:07:36 -0400 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v9NL7YJg40894672; Mon, 23 Oct 2017 21:07:35 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 305B0B2054; Mon, 23 Oct 2017 17:04:50 -0400 (EDT) Received: from paulmck-ThinkPad-W541 (unknown [9.80.218.156]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP id 0D989B204E; Mon, 23 Oct 2017 17:04:50 -0400 (EDT) Received: by paulmck-ThinkPad-W541 (Postfix, from userid 1000) id B22A316C3582; Mon, 23 Oct 2017 14:07:33 -0700 (PDT) From: "Paul E. McKenney" To: mingo@kernel.org Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, will.deacon@arm.com, mark.rutland@arm.com, snitzer@redhat.com, thor.thayer@linux.intel.com, viro@zeniv.linux.org.uk, davem@davemloft.net, shuah@kernel.org, mpe@ellerman.id.au, tj@kernel.org, torvalds@linux-foundation.org, Mauro Carvalho Chehab , Sakari Ailus Subject: [PATCH 06/19] media: dvb_ringbuffer: Kill off ACCESS_ONCE() Date: Mon, 23 Oct 2017 14:07:16 -0700 X-Mailer: git-send-email 2.5.2 In-Reply-To: <20171023210408.GA2930@linux.vnet.ibm.com> References: <20171023210408.GA2930@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17102321-0044-0000-0000-000003A3C662 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007941; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000239; SDB=6.00935454; UDB=6.00471299; IPR=6.00715720; BA=6.00005656; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017676; XFM=3.00000015; UTC=2017-10-23 21:07:40 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17102321-0045-0000-0000-000007D2D15F Message-Id: <1508792849-3115-6-git-send-email-paulmck@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-10-23_11:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710230296 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mark Rutland 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(-) -- 2.5.2 diff --git a/drivers/media/dvb-core/dvb_ringbuffer.c b/drivers/media/dvb-core/dvb_ringbuffer.c index 2322af1b8742..53011629c9ad 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); }