From patchwork Thu Jan 14 21:46:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 59793 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp154839lbb; Thu, 14 Jan 2016 13:52:12 -0800 (PST) X-Received: by 10.66.252.6 with SMTP id zo6mr9559631pac.154.1452808332657; Thu, 14 Jan 2016 13:52:12 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 7si6337606pfo.0.2016.01.14.13.52.12; Thu, 14 Jan 2016 13:52:12 -0800 (PST) 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; dkim=pass header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755969AbcANVu7 (ORCPT + 29 others); Thu, 14 Jan 2016 16:50:59 -0500 Received: from mail-pa0-f53.google.com ([209.85.220.53]:34952 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755023AbcANVrX (ORCPT ); Thu, 14 Jan 2016 16:47:23 -0500 Received: by mail-pa0-f53.google.com with SMTP id ho8so122359789pac.2 for ; Thu, 14 Jan 2016 13:47:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rlAfk2kTYSS9yyrY+Q71n3fNrpXd9ixx060DJBs5sw0=; b=UxB5f9lU2J5yGLsKBgPfEE9v5AHHtn7PpeenxQZ5PJQqtslpTaXdAFgononrfy+zUl lgR6/ZkCog5Rbp7HNTjTZz/ifnJSMkO3ghhA6ylSXDLJTiefgoEAlB8RvFvWlWhv7VPD 8YWngLPA2dTqWB9lnkDkio+KiNbmVd03v9ElE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rlAfk2kTYSS9yyrY+Q71n3fNrpXd9ixx060DJBs5sw0=; b=jcGf00ExERM9G9TwuC7H5ixNCVRSnHMmo07V/y+NK0kYBzs3pxRLFXs5+68ROBevSz gDajLnDTYxqE4cQOUhmgMEdTTtRKm+Ptl8JilQSkuTzAuRKGhWdlV6RBxZehRvpDvq/J DkcaOknRjVYwqdCy3yRpui/pu65Wj0wwz8efCpIiMWQFBkHwOT6vZpvUcmmvwnyBH65S jydo0+DKphMwF0tB0WSMXlWjahtdmi2SlbwuZBaLsX4qqTwl1MawkS1+CU4vjzzgDg92 1evwWIeBKT/+4i1NWiUlDGqeItFkCBsxF860BOsErVIsHOLSqiZOWZg/NCrskaukbz3W 1ZpA== X-Gm-Message-State: ALoCoQmiCbkLj7w/skAD00CGYkiaoCQvUBVmFK/aLBvBIWVEj75o5VylRm0M8MQSrCANGMtfWa2fqq6BCrS0o4CNJjh3CWBaPw== X-Received: by 10.66.144.37 with SMTP id sj5mr9552614pab.69.1452808043238; Thu, 14 Jan 2016 13:47:23 -0800 (PST) Received: from t430.cg.shawcable.net ([184.64.168.246]) by smtp.gmail.com with ESMTPSA id c87sm11383309pfj.41.2016.01.14.13.47.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Jan 2016 13:47:22 -0800 (PST) From: Mathieu Poirier To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: linux-doc@vger.kernel.org, zhang.chunyan@linaro.org, mike.leach@arm.com, tor@ti.com, al.grant@arm.com, rabin@rab.in, Mathieu Poirier Subject: [PATCH V8 14/23] coresight: etb10: moving to local atomic operations Date: Thu, 14 Jan 2016 14:46:08 -0700 Message-Id: <1452807977-8069-15-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1452807977-8069-1-git-send-email-mathieu.poirier@linaro.org> References: <1452807977-8069-1-git-send-email-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Moving to use local atomic operations to take advantage of the lockless implementation, something that will come handy when the ETB is accessed from the Perf subsystem. Also changing the name of the variable to something more meaningful. Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-etb10.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) -- 2.1.4 diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c index 1301edc44629..09e306361e4f 100644 --- a/drivers/hwtracing/coresight/coresight-etb10.c +++ b/drivers/hwtracing/coresight/coresight-etb10.c @@ -10,6 +10,7 @@ * GNU General Public License for more details. */ +#include #include #include #include @@ -71,7 +72,7 @@ * @csdev: component vitals needed by the framework. * @miscdev: specifics to handle "/dev/xyz.etb" entry. * @spinlock: only one at a time pls. - * @in_use: synchronise user space access to etb buffer. + * @reading: synchronise user space access to etb buffer. * @buf: area of memory where ETB buffer content gets sent. * @buffer_depth: size of @buf. * @enable: this ETB is being used. @@ -84,7 +85,7 @@ struct etb_drvdata { struct coresight_device *csdev; struct miscdevice miscdev; spinlock_t spinlock; - atomic_t in_use; + local_t reading; u8 *buf; u32 buffer_depth; bool enable; @@ -277,7 +278,7 @@ static int etb_open(struct inode *inode, struct file *file) struct etb_drvdata *drvdata = container_of(file->private_data, struct etb_drvdata, miscdev); - if (atomic_cmpxchg(&drvdata->in_use, 0, 1)) + if (local_cmpxchg(&drvdata->reading, 0, 1)) return -EBUSY; dev_dbg(drvdata->dev, "%s: successfully opened\n", __func__); @@ -313,7 +314,7 @@ static int etb_release(struct inode *inode, struct file *file) { struct etb_drvdata *drvdata = container_of(file->private_data, struct etb_drvdata, miscdev); - atomic_set(&drvdata->in_use, 0); + local_set(&drvdata->reading, 0); dev_dbg(drvdata->dev, "%s: released\n", __func__); return 0;