From patchwork Thu Feb 18 00:51:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 8344431 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 945D6C0553 for ; Thu, 18 Feb 2016 01:01:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 095F120279 for ; Thu, 18 Feb 2016 01:00:56 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 869A82021A for ; Thu, 18 Feb 2016 01:00:50 +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 1aWCvt-0002ds-4e; Thu, 18 Feb 2016 00:59:01 +0000 Received: from mail-ob0-x236.google.com ([2607:f8b0:4003:c01::236]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aWCpl-0004ci-0V for linux-arm-kernel@lists.infradead.org; Thu, 18 Feb 2016 00:52:48 +0000 Received: by mail-ob0-x236.google.com with SMTP id wb13so43111816obb.1 for ; Wed, 17 Feb 2016 16:52:22 -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=jmB0sByZADXmLCUmcF+mG1fP5fgqFGFiQuczmzc/rsk=; b=D65J/UNVbJhBRtibDblmLPk6Um825I+hleiUsEL1W8ozx5/vIiJgtY4PdyC8dWcmVu rwgu6mLNWFMzNL6I5lrjS9OwyjuhXQU0aDGUmBukuTYW6lbgZc74aphqbprhVxrpLNaY 3R9EdEOYw9ZwcgDk9RHMHQGmG/e+13mmaKYhE= 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=jmB0sByZADXmLCUmcF+mG1fP5fgqFGFiQuczmzc/rsk=; b=kEiqlNz44cDQrft0G1QoX8lr3Q1/12R9amddNwY7OLMJIHJNtGA0St1Ezs0WztpiZQ 7iUvSGF9RYyHfhhWxcFCDFSStmCY3s5vGWk/2FQazhRP5uyLVPYxUFHzQlTftFQ6fzqj Hlk+3Bee1qxteSDA7iZ5JCGc6Tba/nDhoN4xGQoTG4hHXbLDwkhDzhmNZHYKWMWFlP/R i2wLzPnUjijJoJCAs4LZW9fxfZY09EhgCprBVmo8M7rg/hnPRl1MIooySvcv1Hrn1lXx RhhQsn6i47HgSCdwTfLWLTlW7j43Vdo27+hYi8iCOmy0QhQbUtjK4twFsXjxLlwnPKRd g4PQ== X-Gm-Message-State: AG10YORa1kVBWuQg4AR3jv3/9Rhy8FkSTCCTjVJ1heQjT8q+WseoU2RF7Nhn1/DKOaLeYk5+ X-Received: by 10.202.48.8 with SMTP id w8mr3596695oiw.90.1455756741619; Wed, 17 Feb 2016 16:52:21 -0800 (PST) Received: from t430.globalsuite.net (h58.159.185.173.static.ip.windstream.net. [173.185.159.58]) by smtp.gmail.com with ESMTPSA id gi5sm2357650obb.6.2016.02.17.16.52.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Feb 2016 16:52:21 -0800 (PST) From: Mathieu Poirier To: gregkh@linuxfoundation.org Subject: [PATCH 16/21] coresight: etb10: moving to local atomic operations Date: Wed, 17 Feb 2016 17:51:58 -0700 Message-Id: <1455756723-8456-17-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1455756723-8456-1-git-send-email-mathieu.poirier@linaro.org> References: <1455756723-8456-1-git-send-email-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160217_165241_328902_D50573E8 X-CRM114-Status: GOOD ( 14.01 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,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 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(-) diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c index 917562ecf82a..162c9ccc8c33 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;