From patchwork Mon Nov 30 02:14:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 57420 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1180790lbb; Sun, 29 Nov 2015 18:20:54 -0800 (PST) X-Received: by 10.66.251.193 with SMTP id zm1mr85947338pac.154.1448850045412; Sun, 29 Nov 2015 18:20:45 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o71si27535725pfa.113.2015.11.29.18.20.45; Sun, 29 Nov 2015 18:20:45 -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 S1753342AbbK3CUn (ORCPT + 28 others); Sun, 29 Nov 2015 21:20:43 -0500 Received: from mail-pa0-f49.google.com ([209.85.220.49]:34607 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753256AbbK3CRI (ORCPT ); Sun, 29 Nov 2015 21:17:08 -0500 Received: by padhx2 with SMTP id hx2so168029431pad.1 for ; Sun, 29 Nov 2015 18:17:07 -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=W167asw3SLMCXgi/hOMStEIOBYL2gm88vTeY4FKMVeaXSKxfXoT9r1HW/CC2dj5i8m 1+DXS8f4CbKJsD75jfe7ZbUZdr5Becet9fi3y4VjP3Xyby9yGNUBo3oLXpekYii+p+/O yggVMiKD9LWzLbnEqm8leYfjZSgnP3b4qALa77ljAytP6O/QxULqZthst1EXAoEtverh fomBQ3H0sSRy3KQBcWsl+QaCdZMpV7636DEA194KbNsKVnKPLWKYWkiBjwhUiAVFSHgA HikokYD9ATKRCifr1NJ3ckjNDrGGmQF9PkUgDyZZf6All9TMOakz9Rz4aXD3ULP6OUgX 9ZfA== 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=jz1+f/4YlFtCRESYo/4fTuF8nOy6BSUFSnNo89MKn3h2m5kDagwPek8af0gqhF5Aoq mSrXcIqZvMl4PQvvnMX115J43ueYIKkGpgc5FpqKnsU9kMI0PtMCMON7K7U8CINUwwBG oQPSdMEwGLprDR8K+2OAguJ1riM00PDxLhqMxnRq+3x177fUjHZh6p9m96Mj9cbxVMY7 yl4M9On/m3HMsvJv/FnQ8IUSabG/lD40d2oKRfVwE2OAb1WaJZ2bJyz48AwBwDKjYLeQ do1EnYsEdVJ7CcXRr0cA6MPSz5MnNrlEm1XzJkne7Cxvgd0a2ydhX9P9x+Y16mnnVvFR rCuQ== X-Gm-Message-State: ALoCoQlWjZdBjYP592OxQVgzlYO+u6fRb/h0bvoRsQOpTO1YLIUTYisvHC1PR+Y5vfxrolZHihSB X-Received: by 10.98.71.138 with SMTP id p10mr67381862pfi.61.1448849827101; Sun, 29 Nov 2015 18:17:07 -0800 (PST) Received: from t430.cg.shawcable.net ([184.64.168.246]) by smtp.gmail.com with ESMTPSA id n16sm47168818pfa.53.2015.11.29.18.17.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 29 Nov 2015 18:17:06 -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, pawel.moll@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 V5 16/26] coresight: etb10: moving to local atomic operations Date: Sun, 29 Nov 2015 19:14:37 -0700 Message-Id: <1448849687-5724-17-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1448849687-5724-1-git-send-email-mathieu.poirier@linaro.org> References: <1448849687-5724-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;