From patchwork Wed Apr 21 12:04:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Kiss X-Patchwork-Id: 12216051 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A83A3C433B4 for ; Wed, 21 Apr 2021 12:08:09 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 5E039613E0 for ; Wed, 21 Apr 2021 12:08:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5E039613E0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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=G1SrJW5eutIYYW3W1zvAfSOsgYiy7o4fgQE4E/YlxuI=; b=HDOp3cG7D+L4IRNRub2uJ+GlB sHNall8Zb5FW1VPC7hzqFI+JA73nWbd1IgICpJBxM/sN5BKi7Ls+I0typdwj27ExMtFeU9Q48U9UE c9klmkjZDit06G+fCE5drSgpwrDFVcZV2b6X3WiMudwNwCD2P0IBelLK0OzR0uXdOMpunajXDWDLN P8VUhW1tr/w8GaTftUg36K8n3peCTnFlRSBh1Ci5kSS1ud2vCae+02UqVma6oEBZU0pxU26FMyx+g g4G5xYdR0v6cC0Scr4WArSXRqQtyoMeGoDG9wLwWK49/br5iF9PMnw1UnAesTRKxyyGY3aaeUl0RC yUpwBFT2w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lZBc6-00ELsS-Hj; Wed, 21 Apr 2021 12:05:50 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZBbH-00ELnD-L1 for linux-arm-kernel@desiato.infradead.org; Wed, 21 Apr 2021 12:05:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=UuZJZ/rSA2GqmmAl4AA0D8Sm+Gfjwrq8e9EJJwxZWug=; b=441Ie6iDPmrbuXyhStjnsXnMVW fWC3sspWx+etGE3jUCAy/Q1Wt2OynCverFZmfXHxhpDDCTTm5RetPMnayzbtlPAt/B3+y9dSSaRUi o9CKW3ici2WqpcFhkLNNHgPiNaCDnMKoUFC/T2pOrFKOU4XCFnJwykkU00wJE8PFqGloGaf65jlDL rzKXiQw5/hQqrQviey3J1LUl28BgebUov1f1dN3Q3wpAgLHuy5vRTNwXLNX0kvvL719xy+FEKgBVj jX22ctZSKfk3FcDFzPG2FmkKOlTZsvdteOL9YRXooTb1CcPagT48gp6w1M5a3yIzc+Hs4ajGSAYCe OdcmXCuA==; Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lZBb9-00Cqzh-5j for linux-arm-kernel@lists.infradead.org; Wed, 21 Apr 2021 12:04:58 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 97DA313A1; Wed, 21 Apr 2021 05:04:48 -0700 (PDT) Received: from e120529.arm.com (unknown [10.37.12.3]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0C6A53F694; Wed, 21 Apr 2021 05:04:46 -0700 (PDT) From: Daniel Kiss To: mathieu.poirier@linaro.org, suzuki.poulose@arm.com, mike.leach@linaro.org, leo.yan@linaro.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org Cc: denik@google.com, Daniel Kiss , Branislav Rankov Subject: [PATCH 2/4] coresight: tmc-etr: Track perf handler. Date: Wed, 21 Apr 2021 14:04:11 +0200 Message-Id: <20210421120413.3110775-3-daniel.kiss@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210421120413.3110775-1-daniel.kiss@arm.com> References: <20210421120413.3110775-1-daniel.kiss@arm.com> MIME-Version: 1.0 X-ARM-No-Footer: FoSSMail X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210421_050451_278531_980BBE66 X-CRM114-Status: GOOD ( 12.94 ) 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 Keep track of the perf handler that is registred by the first tracer. This will be used by the update call from polling. Signed-off-by: Daniel Kiss Signed-off-by: Branislav Rankov --- drivers/hwtracing/coresight/coresight-tmc-etr.c | 8 ++++++++ drivers/hwtracing/coresight/coresight-tmc.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index dd19d1d1c3b38..bf9f6311d8663 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -1511,6 +1511,12 @@ tmc_update_etr_buffer(struct coresight_device *csdev, goto out; } + /* Serve only the tracer with the right handler */ + if (drvdata->perf_handle != handle) { + spin_unlock_irqrestore(&drvdata->spinlock, flags); + goto out; + } + if (WARN_ON(drvdata->perf_buf != etr_buf)) { lost = true; spin_unlock_irqrestore(&drvdata->spinlock, flags); @@ -1623,6 +1629,7 @@ static int tmc_enable_etr_sink_perf(struct coresight_device *csdev, void *data) drvdata->pid = pid; drvdata->mode = CS_MODE_PERF; drvdata->perf_buf = etr_perf->etr_buf; + drvdata->perf_handle = handle; atomic_inc(csdev->refcnt); } @@ -1670,6 +1677,7 @@ static int tmc_disable_etr_sink(struct coresight_device *csdev) drvdata->mode = CS_MODE_DISABLED; /* Reset perf specific data */ drvdata->perf_buf = NULL; + drvdata->perf_handle = NULL; spin_unlock_irqrestore(&drvdata->spinlock, flags); diff --git a/drivers/hwtracing/coresight/coresight-tmc.h b/drivers/hwtracing/coresight/coresight-tmc.h index b91ec7dde7bc9..81583ffb973dc 100644 --- a/drivers/hwtracing/coresight/coresight-tmc.h +++ b/drivers/hwtracing/coresight/coresight-tmc.h @@ -184,6 +184,7 @@ struct etr_buf { * @idr_mutex: Access serialisation for idr. * @sysfs_buf: SYSFS buffer for ETR. * @perf_buf: PERF buffer for ETR. + * @perf_handle: PERF handle for ETR. */ struct tmc_drvdata { void __iomem *base; @@ -207,6 +208,7 @@ struct tmc_drvdata { struct mutex idr_mutex; struct etr_buf *sysfs_buf; struct etr_buf *perf_buf; + struct perf_output_handle *perf_handle; }; struct etr_buf_operations {