From patchwork Sun Oct 31 14:42:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12595163 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41FA0C433EF for ; Sun, 31 Oct 2021 14:44:14 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 036DD60EB1 for ; Sun, 31 Oct 2021 14:44:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 036DD60EB1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=oFqUFYi5MHkmGfdxvads0pbJDIcpxuoOQFvbZMqj/R0=; b=xNIglfFsfAHQE4 b3TjyY6NXSnuyHFKWfQQjp7I+RX5b+B5n/G56IRKcNlsl4pQL63y82TlGfVnet8Es90iyTZK1GC6c jzfkkfC94adhFgeHc7d0/DrSjCacZ4urVx1NF9+fBDpAMEtzwsFaJseA49pWfN92o4f/lRewYQcwU wCKGJF4acZs0L8v5oTKaqN3Sf3XZ4b/B1klRaqsDO2TspN9Nq/gbyln9t2OtZ0jSeczrh/qKDiegE z481NZxZes+na7ovsg7RK4XZxJJeJbG/Tyt8zQUeRQCrowJqTWImdE7wtlYdBMGeizZGeDNvsh+I4 NC0yScgjNmUUyvzCPkrw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mhC2t-00ECUF-SB; Sun, 31 Oct 2021 14:42:52 +0000 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mhC2g-00ECSJ-Ei for linux-arm-kernel@lists.infradead.org; Sun, 31 Oct 2021 14:42:40 +0000 Received: by mail-pg1-x52d.google.com with SMTP id b4so7767117pgh.10 for ; Sun, 31 Oct 2021 07:42:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uwHc5y/wIScBvEn6bCWIFA7yggj/JltDtCr4bDo6Y0g=; b=kj7gPQXHAooXNx1kSa8Aa7p+r94I7QxhXdyu33lPC/Ro8QQl2PAjMBw6EJFwSc9ZDJ UROzJT9KG0j5IY6GZcyWSXaN5LVytPfmgdlnsStHdnz8bbqTy/IsSHvidD2dc8b+2xE/ FvFLdXF8oXCx+AadCWeMM1dx9Atzch4CDKiaYFjW9PZ8pYv22SeRsyT6FFxfliCuQpqV SYDEC0q7KfwCezat2WunuF3CBnUaz6Pgk/apx6yEZ1vfv/c9Qr4q4tP2AMCdlMqIze4i w6AMvLZmAqyJeti7Z6ni9BW/3uvhq1JazTmgg/xT796xY6r7aFK0nDb+rVKrx8whAIBB QMnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uwHc5y/wIScBvEn6bCWIFA7yggj/JltDtCr4bDo6Y0g=; b=JqhXwbRwkKCl4RuNgeqnjHftsWd6s8p3P+ZeWULyGzx3UsX+VbAyooPjY1JfZm3tcU 59nk3QSesEQiYySpGfvZS2Oveo5pbSIuKToBaCHSWVePZ7z4aabFjJ7obh+AMYvjbowK PWzF4X0FQiGKnlEdbhkbgxQbZqQZGBiBInTmaxSQw+evIe+86+w6799tlgvhhYx4m20r qY1okw0R/GIDvuWx2Go3LCC0SrbTDQIBTS3bBbYmAM/RSND8x4lVTLkSJBbDfngsWdPT 8BhV3I+IUS08gryyizKCtmtTBMp+YQRzEsjDKvEVc7PUwzatZMrDf8yHuRsZF3I2YEFq dkyQ== X-Gm-Message-State: AOAM530FAIlYqPKQqGDc2FW93QXmfT4wJvWnMASUlYqASVg6s13eL72G MqLUGX3e2A3oiYR+1BgqUPe5NA== X-Google-Smtp-Source: ABdhPJwNPl2Jf3gP+mXfhnUBrTAL3ug8leeRXwOWQD5KRvFzBPQaQOP2zw7n1DP9rckK8qKD3qFG6A== X-Received: by 2002:a63:7506:: with SMTP id q6mr17315883pgc.349.1635691357679; Sun, 31 Oct 2021 07:42:37 -0700 (PDT) Received: from localhost ([134.195.101.46]) by smtp.gmail.com with ESMTPSA id e14sm9323996pga.76.2021.10.31.07.42.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Oct 2021 07:42:37 -0700 (PDT) From: Leo Yan To: Mathieu Poirier , Suzuki K Poulose , Mike Leach , Alexander Shishkin , James Clark , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH v1 1/4] coresight: etm4x: Add lock for reading virtual context ID comparator Date: Sun, 31 Oct 2021 22:42:11 +0800 Message-Id: <20211031144214.237879-2-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211031144214.237879-1-leo.yan@linaro.org> References: <20211031144214.237879-1-leo.yan@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211031_074238_675778_D89AA7B2 X-CRM114-Status: GOOD ( 11.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When read the virtual context ID comparator value via sysfs node, the driver firstly reads out the index, then reads the comparator value based on index. This patch adds the spinlock to protect the atomicity for up two steps. Signed-off-by: Leo Yan Reviewed-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-etm4x-sysfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c index a0640fa5c55b..e4c8c44d04ef 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c @@ -2111,7 +2111,9 @@ static ssize_t vmid_val_show(struct device *dev, struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent); struct etmv4_config *config = &drvdata->config; + spin_lock(&drvdata->spinlock); val = (unsigned long)config->vmid_val[config->vmid_idx]; + spin_unlock(&drvdata->spinlock); return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); }