From patchwork Mon Dec 13 12:13:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12695888 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id C663BC433EF for ; Mon, 13 Dec 2021 12:15:32 +0000 (UTC) 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=6PqkztiJDxBqM18Gp+MfcuH5bJHKb7OZRKHfYdhPh9s=; b=s2kryCGpJZEDLM 1FxyvqC0rdAYj7HqoDEcQmux3O0MTMQ8hHV+FkXvlr6z/uA8U7zvQKhB5j6igIPhl4xyIbb7liIez jvDMEipgRmwKofh3Yb+9iHKJfUxVyozc9PB1RSwKlMyNa18xflSH6AM1h2PsEO2MuHiC0e2WL6a3u z5wO1axpqcaxO1yIBDTFuxxPdfdYK8sww3vwaMU7dY6ZVF4QxMHS99CyArD8/2XvTdEn0MlHivuSs zMtRNbFZsSYjoYlzxHSD9+f3u/MMBW29jny9ZS5nVnML1pUySo5D/qciWjyb8D3MO4ALK8T9TY/IT N3YE/UseXFilv5oFy5mw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mwkDV-009Qv2-4T; Mon, 13 Dec 2021 12:14:05 +0000 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mwkDI-009Qq1-3f for linux-arm-kernel@lists.infradead.org; Mon, 13 Dec 2021 12:13:53 +0000 Received: by mail-ed1-x535.google.com with SMTP id w1so51184331edc.6 for ; Mon, 13 Dec 2021 04:13:51 -0800 (PST) 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=JBlM0fJPQdFbfZELyfGYDQMeIzp3LQS6pQHkYWuX8+E=; b=dd7hlYP2Clq1AqRb//9vi2Gv0QEIpIvvfOc9+YtILUbE2SbzZJEQh9ItbAZFdJGYta QICI6sLf7SLo3L4q++xMdDcSwnQzgK2YiKmKuuC89NHt6+KWmQaotLkWJydNCot8tZrb 8yao4HIb8kRXQcll9l2Z9ah2lVvUAeUsLFt3pQCNL4scCAusbSM1MxuF3KAT+lKwIytR r1oWPyT9DyVR71GioIAtooIYhNCccMtLWfm4hqFVoMocfEw3BfKt1MOP74+VMWjGpluB 7b77azzx47p+L2DphzEiHlSrjBoztZNWS1BSz4g1vPtfY8vghI1nj0PbGSmEb+NZEPhj 9XOg== 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=JBlM0fJPQdFbfZELyfGYDQMeIzp3LQS6pQHkYWuX8+E=; b=rvpJl1bOnuaU1XEmaVJTZDmHH3p5PcJgfZzig/aEQ4FwfJjSQBMfV2dWobZtLMOBbZ 88gnTjcBpFJDJ/0Jax8GNoXHhllH0HFe9WgqAkMoAM0DHt0orv8O5jdAySgqvfOH2oLI fICggT4dqUcPXWUKXG+Kw6revtoBZHZnFqHHBG8HtvhjODPyRfF2nu6om4gYJ4NSSTx8 XaEdYwiOk0sozPGy2cwRyo28qCeEeEsCH364qxv2q5GPV831qgv2ONYpsvJsCkTOncCa SojfpI0126QhWVxsgJZwb+xhbP4L3WMHBqHezvy06iiJvG2uv9i0FkXpTlaHUB8wuGKz eozg== X-Gm-Message-State: AOAM530qEJUMTA0HAAswxrFNfaYdlchCknCwZ43Qw5B/+0qJPpZJcm+9 /QtSHUTn+emw7fpH8NkSYsiuYg== X-Google-Smtp-Source: ABdhPJwz5oYW29GAi3U4zyh+V9Z7lEcvYsoaWvpdN0+4MDNP19p4ZNmFHRg0zw6gTZu2cB7ZId4N4w== X-Received: by 2002:a17:906:9b8f:: with SMTP id dd15mr42691115ejc.480.1639397630513; Mon, 13 Dec 2021 04:13:50 -0800 (PST) Received: from localhost ([104.245.96.202]) by smtp.gmail.com with ESMTPSA id nd36sm5895826ejc.17.2021.12.13.04.13.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 04:13:50 -0800 (PST) From: Leo Yan To: Mathieu Poirier , Suzuki K Poulose , Mike Leach , Alexander Shishkin , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH v2 1/4] coresight: etm4x: Add lock for reading virtual context ID comparator Date: Mon, 13 Dec 2021 20:13:20 +0800 Message-Id: <20211213121323.1887180-2-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211213121323.1887180-1-leo.yan@linaro.org> References: <20211213121323.1887180-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-20211213_041352_174324_0EAC1411 X-CRM114-Status: GOOD ( 10.52 ) 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 Updates to the values and the index are protected via the spinlock. Ensure we use the same lock to read the value safely. 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 10ef2a29006e..2f3b4eef8261 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); }