From patchwork Thu Dec 3 21:04:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 57686 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp168228lbb; Thu, 3 Dec 2015 13:09:55 -0800 (PST) X-Received: by 10.67.2.73 with SMTP id bm9mr16322895pad.94.1449176995625; Thu, 03 Dec 2015 13:09:55 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wh2si14158170pac.170.2015.12.03.13.09.55; Thu, 03 Dec 2015 13:09:55 -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=neutral (body hash did not verify) header.i=@linaro-org.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754430AbbLCVFy (ORCPT + 28 others); Thu, 3 Dec 2015 16:05:54 -0500 Received: from mail-ig0-f174.google.com ([209.85.213.174]:34141 "EHLO mail-ig0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754380AbbLCVFt (ORCPT ); Thu, 3 Dec 2015 16:05:49 -0500 Received: by igvg19 with SMTP id g19so22262351igv.1 for ; Thu, 03 Dec 2015 13:05:49 -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=rlAfk2kTYSS9yyrY+Q71n3fNrpXd9ixx060DJBs5sw0=; b=rxsMIyg/VpFIxYjXE8KiyoPSy22QWJgqqTcspSzBdvDKo11cILat7/F63DL3F+ukDX vQWL4dTNGOhxzrohjh8CjGVp1/oJKTZyfR3/IKpKju5+mLw2+C8BEmGnyyYxF/Xmijuz vfALdAoOe3EC0KS8BZ/0G2g3Xm8nC22TcgUSNQhxigIwKnQn9t1QVg4qayxRd8kmEYpg NqvSnMD5oF7MGzrF041IVGaGhbFPPdbtAucDIpiba/dZrc5uwnrImWNqCogu9Htl17xa 0lBkdYEpxIjJ53+klpugUFqyQVVQ36i28sXN/meH4zI8IM9TPLdogo2zf5lEUZ1cSUhe IlFg== 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=CfusdItKiLIB5X4dC40QQsJodynRvgzoQUPN4hq6zhG+avhm+3FZqVEqhG8QQvpOVB khMR12nCSTqVeZIxQ+UC81uISsyRftVtQGVzHqs0cUuttgP9TXwjn2O+17Z1VFdt0b57 DXhd2ZYK3C2Az5XWl1CdarABSN3AcbPhwsPxKChnI1NOYmZnn4KHv4ncH4FjtiQ0igf0 jnh9PvaoHItFFLae47wdbHjVgNtRlImwj0f5dBuItmuXkCGpOEPpTw2cXDwLU5VI21ka KzFqHrxrJqkSRquh2ABTgRkuWfkr03SGzhAxl6gBqqJiPy/fyVEz39HzDphIRrLyhjZ3 lu6Q== X-Gm-Message-State: ALoCoQmImufJRUxzPziJv3mUCu+MqjNYaFd0o5aGbAFjnqA0LAtoLuWEGXH/tUTEnkAhRLDz007o X-Received: by 10.50.150.71 with SMTP id ug7mr714936igb.68.1449176749217; Thu, 03 Dec 2015 13:05:49 -0800 (PST) Received: from t430.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [184.64.168.246]) by smtp.gmail.com with ESMTPSA id d81sm3615433ioj.12.2015.12.03.13.05.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Dec 2015 13:05:48 -0800 (PST) From: Mathieu Poirier To: gregkh@linuxfoundation.org, alexander.shishkin@linux.intel.com Cc: zhang.chunyan@linaro.org, mike.leach@arm.com, tor@ti.com, al.grant@arm.com, fainelli@broadcom.com, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Mathieu Poirier Subject: [PATCH V6 16/26] coresight: etb10: moving to local atomic operations Date: Thu, 3 Dec 2015 14:04:52 -0700 Message-Id: <1449176702-13213-17-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1449176702-13213-1-git-send-email-mathieu.poirier@linaro.org> References: <1449176702-13213-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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ 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;