From patchwork Fri Nov 13 18:45:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 7613781 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 331B6BF90C for ; Fri, 13 Nov 2015 18:52:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 49E9920698 for ; Fri, 13 Nov 2015 18:52:49 +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 686C520376 for ; Fri, 13 Nov 2015 18:52:48 +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 1ZxJQu-0002br-4h; Fri, 13 Nov 2015 18:50:48 +0000 Received: from mail-pa0-x22f.google.com ([2607:f8b0:400e:c03::22f]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZxJND-0006UG-9i for linux-arm-kernel@lists.infradead.org; Fri, 13 Nov 2015 18:47:05 +0000 Received: by padhx2 with SMTP id hx2so107756204pad.1 for ; Fri, 13 Nov 2015 10:46:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZveGRFUbK7wsnlmCbRWblmTSGPdv1ppgv9Wh1RwsYmo=; b=B58Celn2V2Cydwg3ZmZVN1aXtEs3oudrqHkI8MB7l22TbHf8YG8/S+HNT9RVdpVpr8 QF6IyHlpJ34R06z34Zlcd9VTeIYt1eH/R2Sa801+EfxwAMrQuRN3TrYSzK4YTF7B5LXK kuYNsN4hHFo0b5+WbFLV0TIZpVsQ7cD5+Fd2NvFzSU69waf4UqRdTfPOYHgOEnHMulvX ULFbqnMp49JqqZjSp0uLsCqTZN8SXDkYtWwgMi0njRC5xfnqkFnetKBfcHXzt8Hl38Jp cLmr+TPmGihlniK4+kTQDTVNbTAdHSa/1kWtEF5HQPgpatWtllVmf7bFCq/NviYoFqaw BEiA== 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=ZveGRFUbK7wsnlmCbRWblmTSGPdv1ppgv9Wh1RwsYmo=; b=ajvzvcKUlaXU8BuV00gFNY8GpVzK14vbTUhXQKf7utRBf3XaC7KM7EjVam7fo/MKo7 aVm42vNiGqSLvw1VhRa4TvHWb80pT0CK1fzaj9Q8+Tb7cayUeQCHQE2mYGGwAIufV6WN 6j2k6mwuquD4XQnfTH4WV3thpW0OM4ekl87Rq+KKOC1g57bcWY/Al0wuYm1jNN8PW/o0 MWBtlCH0C0g4iOwGDM2hGXZWHrMyL1VlFQgHgjL6u0W4RiUZgGdBK9S4RCq4L0sjL1eG mPUGGkNNQCsK/Kze3SYunwbyDMIQUV27fD4/ghSJW7SrIGo6lufVaG4IbCi2njiUsAJT sxCw== X-Gm-Message-State: ALoCoQlPlezEZH85nDspRWlCTmICLqOPFGfJWzPC8TxoR8ie+sNkKYcDWnXx4jOJFl8u0JgG7jJm X-Received: by 10.66.124.135 with SMTP id mi7mr34743101pab.102.1447440402863; Fri, 13 Nov 2015 10:46:42 -0800 (PST) Received: from t430.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [184.64.168.246]) by smtp.gmail.com with ESMTPSA id xi7sm21737967pbc.56.2015.11.13.10.46.41 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 13 Nov 2015 10:46:42 -0800 (PST) From: Mathieu Poirier To: gregkh@linuxfoundation.org, a.p.zijlstra@chello.nl, alexander.shishkin@linux.intel.com, acme@kernel.org, mingo@redhat.com, corbet@lwn.net, nicolas.pitre@linaro.org Subject: [PATCH V4 17/26] coresight: etb10: moving to local atomic operations Date: Fri, 13 Nov 2015 11:45:08 -0700 Message-Id: <1447440317-1977-18-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1447440317-1977-1-git-send-email-mathieu.poirier@linaro.org> References: <1447440317-1977-1-git-send-email-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151113_104659_679611_2AC48FD5 X-CRM114-Status: GOOD ( 13.91 ) X-Spam-Score: -2.6 (--) 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: al.grant@arm.com, mathieu.poirier@linaro.org, pawel.moll@arm.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, fainelli@broadcom.com, adrian.hunter@intel.com, tor@ti.com, mike.leach@arm.com, zhang.chunyan@linaro.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.4 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 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;