Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp197367rdb; Thu, 19 Oct 2023 01:24:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE/OfEPpf6iB176d+QF1oSAtPytO0xppaPDnNKiV3eP4sMaga/T3pVPV/uVNG8e0HKgWmbm X-Received: by 2002:a05:6808:10cf:b0:3ac:4ee2:337b with SMTP id s15-20020a05680810cf00b003ac4ee2337bmr1828464ois.51.1697703877885; Thu, 19 Oct 2023 01:24:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697703877; cv=none; d=google.com; s=arc-20160816; b=xbbZCMwFrVOHN6DUnv2DLksOIS86V5bK8eP8zEQrwJkzlNQS4e9sug7v5pZuHEKDuB HEIWefTu7VWvDKiSIThLH8POEDIQxR4B6yvmof3H1Xm7bUEaiLTGyPG5gibrqOG2A2J4 fGs7Yrg3GtgAKe3c1nYPvJpwg7iyo/8azY+lGPsR/4bKKMSdUIOHNBbfKe+hWsqPXxxP eIJw7/z4IRO2g/PSUxiwRrrh75hWVmKNjX2hGdncSiO5VSv7pSdJ3DRhpa5O50kDFKqy ej2kUALE6SuUS5miGFFk1+YBceMMsgP9q5DITmowfZlU6w8bp2AZ6swOHiONhIl7ykt9 kIeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=Lu+FeCyL3oCgR0FP+gkAe4hCPFiLBzzy7yX8rQh0MDk=; fh=W2LT7HmKr2pkMU4fSzm5hJaNpM2TKwXxmy4+vYRmjBM=; b=vzxwlXnR/qXmBUoGbbK4neKwOgRYJMRjC/htSG2ej5k0pV0w2I/I+0i8yeUoXSAXIx V6z0HCAZm4/FjNqIC8CHTVfSf0IoM9K43oFcZs1cPPTMm4pZV08Cvxz//2d79aMfZG68 DN9A7i5p5GscI5jLPjn6Y2xiroh0376bxhF05TaMgFzSNmH/9J7+1KBRDuWIxI1jKXcB xrswTkSvbMiad5PQO/NqUCPv1lausZYPOD1WmM5owJbvk4FYsNJxQCQ4PT9csz2wbRz1 J4yRsFJJlCtW0pn4JSD4Zht/hqMtZIVCUWdfsd/F+640mzxQZz8P/2XBdN1N5LL3hRUG oZSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=KWMlBGzA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id j12-20020a63fc0c000000b005afc5ea43fdsi3934887pgi.849.2023.10.19.01.24.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 01:24:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=KWMlBGzA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id DC80A8245A7E; Thu, 19 Oct 2023 01:24:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235321AbjJSIYR (ORCPT + 99 others); Thu, 19 Oct 2023 04:24:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235109AbjJSIYI (ORCPT ); Thu, 19 Oct 2023 04:24:08 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9E3B196 for ; Thu, 19 Oct 2023 01:24:05 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5a828bdcfbaso92333627b3.2 for ; Thu, 19 Oct 2023 01:24:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697703845; x=1698308645; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=Lu+FeCyL3oCgR0FP+gkAe4hCPFiLBzzy7yX8rQh0MDk=; b=KWMlBGzAEsg46eyBH395XpMNOG4zWRjOgLuLv2f+O28E4bLZ7UeUtPK/gzSwWg4oy6 yekOL3vFaP68khniqFLgEVn19MaqMrIc9CR5RFxbHi/WcyDOsTCExochl43yhC97Lf2B jKUXgbF5nXGjALb6dxL+rg9puRQcbpmGX0ZyacdShthgORcv+/tKGTHsoWmnNIxV8cB8 tjGbQk/9pfn1ZAyXMFW62AD+q4OEROoWQZhKBXr9N7PWNP7HrZtcD/37kJO+2U50ffmC sJ+XA2OVF2RcEg6RikjCBIPrkhWY6F8SCuK7GVf8Ss5gyKdb0mkzYNMw5H/8AfchiV6k 4gFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697703845; x=1698308645; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Lu+FeCyL3oCgR0FP+gkAe4hCPFiLBzzy7yX8rQh0MDk=; b=PYwBmFm3LoQeHOA8gNTTWxx1jkutxmghclKhWzMHgnoG03Io9rtbvBpqUMFwsk73W2 omvIp1LhhC9JdwwoEwhJIjnn+21njiWxKvrt3h8qXlyC1i5nfshvQOGDPdB6xKbkRIoi Y68P33TqN+u5xYYL/a3m/UkGHe57+phKqi090ppVYWoMD6xFHISx36g7MMkGQb56F3hb 5NQ2v4BACvRAwrdTjm+C0jpj3L8fjUej6JiDIfoE/r4zXoqrLB+gokzz1ekHgOcIv6qY 9UrfFokOt2ca98YnRc3JXajSdp4vfaKTe27EdF8/DjFPJtIWHItKkCU7IqvjSHPs4Iq6 ENow== X-Gm-Message-State: AOJu0Yzh8kp/mPkmyn2T7zQjm+6+wGFvz1nTBwu9fWcnOLWBp+gQyL6r zEVdwtCHYYHmTHD38hwaP/k6pzV7ggnH X-Received: from wnhuang-p920.tpe.corp.google.com ([2401:fa00:fc:200:8537:873c:b8ab:6b48]) (user=wnhuang job=sendgmr) by 2002:a05:6902:134a:b0:d9a:58e0:c7c7 with SMTP id g10-20020a056902134a00b00d9a58e0c7c7mr34535ybu.1.1697703845044; Thu, 19 Oct 2023 01:24:05 -0700 (PDT) Date: Thu, 19 Oct 2023 16:23:57 +0800 Mime-Version: 1.0 X-Mailer: git-send-email 2.42.0.655.g421f12c284-goog Message-ID: <20231019082357.1505047-1-wnhuang@google.com> Subject: [PATCH] coresight: etm4x: Allow configuring cycle count threshold From: Wei-Ning Huang To: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, suzuki.poulose@arm.com, james.clark@arm.com, leo.yan@linaro.org Cc: linux-kernel@vger.kernel.org, Wei-Ning Huang Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.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 (howler.vger.email [0.0.0.0]); Thu, 19 Oct 2023 01:24:35 -0700 (PDT) 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. 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 -- 2.42.0.655.g421f12c284-goog