From patchwork Mon Nov 23 18:33:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 57191 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1604302lbb; Mon, 23 Nov 2015 10:38:28 -0800 (PST) X-Received: by 10.66.170.238 with SMTP id ap14mr38092856pac.128.1448303908288; Mon, 23 Nov 2015 10:38:28 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rd8si21065009pab.25.2015.11.23.10.38.27; Mon, 23 Nov 2015 10:38:28 -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 S932124AbbKWSiZ (ORCPT + 28 others); Mon, 23 Nov 2015 13:38:25 -0500 Received: from mail-pa0-f43.google.com ([209.85.220.43]:34205 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755039AbbKWSe0 (ORCPT ); Mon, 23 Nov 2015 13:34:26 -0500 Received: by padhx2 with SMTP id hx2so198922854pad.1 for ; Mon, 23 Nov 2015 10:34:25 -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=uHRbQqYd4kXNoMEqw6VkpVB7VKIqrbybuJBgOltiKoa8q7mD6ximhbLiT+a3P3Bp2T JF6Y770TDZgJJ+VacMdQhTGCn1TkU3uaUxZGzYBHivTDWJSAkyUGOJv8Nb3f38mqLtWs b3NIolU63idQEU+uey750M6J0AUk53bdCSrkV9EhCIN8TSEGwKFWE6rvi+d8a4SHG+Hn +b9RB5CxfHq4dAGNZQG7hE/0rVjDo8lTkPUd3pPgC8t5CUSzEKEALdNHZyfg92epwZgJ e3B6UaGkPTPr5p9lkJ4Il9USGM02MZGmnYl+gNBMRPZppWTy1jaBIs/ki2D449E//47l jyVw== 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=dysa32czBNJCdpdIrF1uQ6+iyWRytZgYp2RfV4uczGSGf6KbNNArG3tTgUnDZyiXAD 1rx/3ZBaO4lk1Kx/CixTD5swAxttXabqshSn9/dbThjNXzsIVat+e5ErnYNAdwZ9tyXW WWnNawdiImsMga8FMhKFEUMgxe/KebXswf0gjUoV89WBQ4b8t7oP9uC5hr7MtGyRn8Uc Am2Uun3Ho4bziXuprcjSHCmtzzNT+YjUKmMKueT+mjvQqDSR1f8dc6qJDnLyiZb2w9xN bxBiDJFIYBYjiiMe1NQ04aHUf5dGDhyRic9IlaeSsdQ5103vxbLC3thVA0ZYb27A3lw7 iy9w== X-Gm-Message-State: ALoCoQlL+ke1drLWJxJm/SpMh45647Twg1ansp2F0d9Tpb4HxaFFlCVBZZlJq3NDPJHVlRWEq+Vj X-Received: by 10.66.63.37 with SMTP id d5mr37729206pas.103.1448303665816; Mon, 23 Nov 2015 10:34:25 -0800 (PST) Received: from t430.cg.shawcable.net ([184.64.168.246]) by smtp.gmail.com with ESMTPSA id r20sm10865186pfa.93.2015.11.23.10.34.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Nov 2015 10:34:25 -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: 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 Subject: [RESEND PATCH V4 17/26] coresight: etb10: moving to local atomic operations Date: Mon, 23 Nov 2015 11:33:09 -0700 Message-Id: <1448303598-11249-18-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1448303598-11249-1-git-send-email-mathieu.poirier@linaro.org> References: <1448303598-11249-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;