Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp220877rdb; Thu, 19 Oct 2023 02:24:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHMLLlwzFXM5EljlvxcRztEdAF0VOrY5Z96MrRxuvmE1m9TLVn3e4T/6tq8FqNRb3sYmCRt X-Received: by 2002:a17:90a:558f:b0:27d:eaf:7142 with SMTP id c15-20020a17090a558f00b0027d0eaf7142mr1604626pji.20.1697707458504; Thu, 19 Oct 2023 02:24:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697707458; cv=none; d=google.com; s=arc-20160816; b=dux5oA68QZRoX7PpERBLcd/m6agRU54VS1ONuPAK+yn5D0xwyj7gCF4Z6znxl7+rol rbCzczveToM/MaWO4rq49VhRPMHhE655mNJYeQV+2/lZXR/OIa4GfT5z0FbxBlu2miCF Itc8iNpYeVroIQGu/iyTb/coxiOQgn8VogKIbnveCSgxQClY3cFpHDb2GKLOykkJ4Coy F43Dy0Gn6LGQf6qk5iq8s5ukhhnVk9OrJeNgZTSc2MmguGJ1VCNlUruNb3wR0p4vxkUF rhaW9esHE3F31jXCv+t1JzHz4U7aAaY9WYUi2EPnKSiV9UADjYh/pib8bDkuV1bwiPqc YO5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=3xhhhZX+lM0HYxTST3gBuDH+/0dRZ1/lURQG9HvC6b4=; fh=pIbt3w/KUXoX0iqOriCnlegh4J5+H8LNjgNMXAsN2do=; b=nQEtcEPnJtv9eVfk0/k7H35hj0eVBJdSwU2VfqmVlZj6/ND3eV6oCiF3GbVPen8Qml nLYO6Usjok+B+gtBZeSHM3YQ3Hv78cD2n+BAqzXnAfD8SiHGA3pzwzqQgC33NLUPpG7o x3PnogacqVjtqgQEA2zm4xqL0dq/13YQgj4b59CS07PwgGakCO3PbKBryFLWEbIbyl1x EgmtRWqUND24t2gmyYUgC9tmEiJyKQ+6JlaWcQzu7TmerJ5kRAv4bMGoUfjJMjD3HVxg ea9sVwTC1OB7R9y+x0FC09UwyypRTaNwW1bjIyD6GLs8yDYqcJgNFfOpLHZKUrOR+IxD feig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id i8-20020a17090a7e0800b002773363d105si1632829pjl.188.2023.10.19.02.24.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 02:24:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 4E474811C148; Thu, 19 Oct 2023 02:24:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232876AbjJSJXw (ORCPT + 99 others); Thu, 19 Oct 2023 05:23:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231984AbjJSJXv (ORCPT ); Thu, 19 Oct 2023 05:23:51 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6D52298 for ; Thu, 19 Oct 2023 02:23:49 -0700 (PDT) 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 3C7B22F4; Thu, 19 Oct 2023 02:24:30 -0700 (PDT) Received: from [10.57.3.68] (unknown [10.57.3.68]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 536A43F5A1; Thu, 19 Oct 2023 02:23:48 -0700 (PDT) Message-ID: Date: Thu, 19 Oct 2023 10:23:46 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH] coresight: etm4x: Allow configuring cycle count threshold To: Wei-Ning Huang , linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, james.clark@arm.com, leo.yan@linaro.org Cc: linux-kernel@vger.kernel.org References: <20231019082357.1505047-1-wnhuang@google.com> From: Suzuki K Poulose In-Reply-To: <20231019082357.1505047-1-wnhuang@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.1 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 19 Oct 2023 02:24:15 -0700 (PDT) On 19/10/2023 09:23, Wei-Ning Huang wrote: > Allow userspace to configure cycle count threshold through > perf_event_attr config. The last high 12-bit of config value is used to > store the cycle count threshold. > We have queued the support already in coreisght next tree, patches posted here [0] [0] - https://lore.kernel.org/r/20230921033631.1298723-1-anshuman.khandual@arm.com Suzuki > Signed-off-by: Wei-Ning Huang > --- > drivers/hwtracing/coresight/coresight-etm4x-core.c | 6 +++++- > include/linux/coresight-pmu.h | 14 ++++++++------ > tools/include/linux/coresight-pmu.h | 14 ++++++++------ > 3 files changed, 21 insertions(+), 13 deletions(-) > > diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c > index 77b0271ce6eb..155441668b4a 100644 > --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c > +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c > @@ -645,6 +645,7 @@ static int etm4_parse_event_config(struct coresight_device *csdev, > struct perf_event_attr *attr = &event->attr; > unsigned long cfg_hash; > int preset; > + u64 cyc_threadhold; > > /* Clear configuration from previous run */ > memset(config, 0, sizeof(struct etmv4_config)); > @@ -667,7 +668,10 @@ static int etm4_parse_event_config(struct coresight_device *csdev, > if (attr->config & BIT(ETM_OPT_CYCACC)) { > config->cfg |= TRCCONFIGR_CCI; > /* TRM: Must program this for cycacc to work */ > - config->ccctlr = ETM_CYC_THRESHOLD_DEFAULT; > + cyc_threshold = ((attr->config >> ETM_OPT_CYC_THRESHOLD_SHIFT) & > + ETM_OPT_CYC_THRESHOLD_MASK; > + config->ccctlr = cyc_threshold ? cyc_threshold : > + ETM_CYC_THRESHOLD_DEFAULT; > } > if (attr->config & BIT(ETM_OPT_TS)) { > /* > diff --git a/include/linux/coresight-pmu.h b/include/linux/coresight-pmu.h > index 51ac441a37c3..14f48658ff1c 100644 > --- a/include/linux/coresight-pmu.h > +++ b/include/linux/coresight-pmu.h > @@ -29,12 +29,14 @@ > * ETMv3.5/PTM doesn't define ETMCR config bits with prefix "ETM3_" and > * directly use below macros as config bits. > */ > -#define ETM_OPT_BRANCH_BROADCAST 8 > -#define ETM_OPT_CYCACC 12 > -#define ETM_OPT_CTXTID 14 > -#define ETM_OPT_CTXTID2 15 > -#define ETM_OPT_TS 28 > -#define ETM_OPT_RETSTK 29 > +#define ETM_OPT_BRANCH_BROADCAST 8 > +#define ETM_OPT_CYCACC 12 > +#define ETM_OPT_CTXTID 14 > +#define ETM_OPT_CTXTID2 15 > +#define ETM_OPT_TS 28 > +#define ETM_OPT_RETSTK 29 > +#define ETM_OPT_CYC_THRESHOLD_SHIFT 52 > +#define ETM_OPT_CYC_THRESHOLD_MASK 0xfff > > /* ETMv4 CONFIGR programming bits for the ETM OPTs */ > #define ETM4_CFG_BIT_BB 3 > diff --git a/tools/include/linux/coresight-pmu.h b/tools/include/linux/coresight-pmu.h > index 51ac441a37c3..14f48658ff1c 100644 > --- a/tools/include/linux/coresight-pmu.h > +++ b/tools/include/linux/coresight-pmu.h > @@ -29,12 +29,14 @@ > * ETMv3.5/PTM doesn't define ETMCR config bits with prefix "ETM3_" and > * directly use below macros as config bits. > */ > -#define ETM_OPT_BRANCH_BROADCAST 8 > -#define ETM_OPT_CYCACC 12 > -#define ETM_OPT_CTXTID 14 > -#define ETM_OPT_CTXTID2 15 > -#define ETM_OPT_TS 28 > -#define ETM_OPT_RETSTK 29 > +#define ETM_OPT_BRANCH_BROADCAST 8 > +#define ETM_OPT_CYCACC 12 > +#define ETM_OPT_CTXTID 14 > +#define ETM_OPT_CTXTID2 15 > +#define ETM_OPT_TS 28 > +#define ETM_OPT_RETSTK 29 > +#define ETM_OPT_CYC_THRESHOLD_SHIFT 52 > +#define ETM_OPT_CYC_THRESHOLD_MASK 0xfff > > /* ETMv4 CONFIGR programming bits for the ETM OPTs */ > #define ETM4_CFG_BIT_BB 3