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: 56546 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1214865lbb; Fri, 13 Nov 2015 10:49:52 -0800 (PST) X-Received: by 10.68.179.228 with SMTP id dj4mr34147586pbc.112.1447440592339; Fri, 13 Nov 2015 10:49:52 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id lf12si28927729pab.22.2015.11.13.10.49.51; Fri, 13 Nov 2015 10:49:52 -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 S1754648AbbKMStt (ORCPT + 28 others); Fri, 13 Nov 2015 13:49:49 -0500 Received: from mail-pa0-f47.google.com ([209.85.220.47]:36537 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754945AbbKMSqn (ORCPT ); Fri, 13 Nov 2015 13:46:43 -0500 Received: by pacdm15 with SMTP id dm15so107589371pac.3 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=fPNYc18Nbskd6BqLVawZQG82ZnicBY8W+YzFKtp12l/ssxiP/c8tvJz4/KDrgxV/OF Xu5R3HTXsWkSthujLIav67Zfg4p//ks3nM/eqYEs61OR9o/zri5uvKL+Dw2Qo1kYoI/V 3rfVUiyHvEqmlRv2HlhqjK+rZID4ndZ1XDvJchVLBx49RvY4T8vTTH1raLHhcD7vPK+v i/tzPepUsYK2hxB7j6ZrpTVfvTSkJcY0hwBej9RAImDikVmEJTPC9O+ROV8mFi2A/L6g lNjEZIfsJ93EcikCRzt3THPgVmXz9zeRtcAQ14kZMBLWNYzF3wSFXGj43BhV2U6Q9pIb tdQA== X-Gm-Message-State: ALoCoQkeK5P544oEVHhIsZwypLMyNyGlxMleBCALslsLjKG4SDdfS4pfFhuabgqNmyWJiDgkeHVV 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 Cc: adrian.hunter@intel.com, 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@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> 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(-) -- 1.9.1 -- 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;