From mboxrd@z Thu Jan 1 00:00:00 1970 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=-15.3 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,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 A8A56C433E6 for ; Fri, 5 Mar 2021 13:42:36 +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 AB45A65009 for ; Fri, 5 Mar 2021 13:42:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AB45A65009 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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:Cc:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=NYd0/yo6vAF/Dqsr0DmHWlr53hbzBXCKMSaSaruQfoU=; b=GYEXwbaZNaxedMQbqa62GG13L oK7cVyKlsyKnbTkQ8q1D2JUEi56LYUR8dt7q8GIjs1D33evMJOVqXoCXBMjKUhV2KakitaKJa7+MZ PTq4lCSSBTHmJrvZGY44lanW+apPe8O9aAdoXib0HW9zTsgSWG9qbqSUoXWInOXs6CuLRf7aytJBD 4ocDgvBIg8JNIrO9CnTGpcxLdUjpLJZtwi34c7+j2Mv6csFQ3YRxDGYjpzv2O7BQm1cPmwsaD7450 6dfwJIGHSyktcWBTaL9N6/eNQoCxpJ2XMXMYj8u2RhC2Unr6Edjx0DNLiCGXBNo3i8WRXHJXyOvh8 kLPgHZkLg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lIAge-00F94f-K9; Fri, 05 Mar 2021 13:40:14 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lIAgY-00F93J-6O for linux-arm-kernel@desiato.infradead.org; Fri, 05 Mar 2021 13:40:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description; bh=KYSyE3/KDbqsjP0gqp+/LAQ89g4rtnf6DMG55Bll3Hs=; b=uOH5knxjnhD8jiT86/fo7pup/7 lhM+1ktKouM693Vi6McUcdYUMdaT0eAbggpJVYq4lzW1P8h0cwyeiT2jeEiWCExq+hKGZoFReMtTw bpIK2lzxKJ44EvrdoNnKJ3qzKulejVU3s1gKiCmMvCemNX485iwmWo1sDz6AVxQt4UWHbpBsZYBX4 fjI8+kZetqbYavIXyh3JyNebuKVCdIqDoqhfZ7xD9EEZF62V1iVH/LN8rAJXMXY2EN3yrfl/1IyYB WQp8MBwgO//BArM7NhRcemZfsY+QqEjZ/IzC2hRFkHjwrXP2DKBpTOV0Z/nEKirdmwd2kbQwQrx0J 2EUMFf1g==; Received: from foss.arm.com ([217.140.110.172]) by casper.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lIAfx-00Blhb-W9 for linux-arm-kernel@lists.infradead.org; Fri, 05 Mar 2021 13:39:54 +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 CB28931B; Fri, 5 Mar 2021 05:39:22 -0800 (PST) Received: from [10.57.51.235] (unknown [10.57.51.235]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 520F93F73B; Fri, 5 Mar 2021 05:39:20 -0800 (PST) Subject: Re: [PATCH v4 08/10] coresight: config: Add preloaded configurations To: Mike Leach , linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, mathieu.poirier@linaro.org, linux-doc@vger.kernel.org Cc: yabinc@google.com, corbet@lwn.net, leo.yan@linaro.org, alexander.shishkin@linux.intel.com, tingwei@codeaurora.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org References: <20210128170936.9222-1-mike.leach@linaro.org> <20210128170936.9222-9-mike.leach@linaro.org> From: Suzuki K Poulose Message-ID: Date: Fri, 5 Mar 2021 13:39:17 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210128170936.9222-9-mike.leach@linaro.org> Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210305_133934_291155_E5EC7A7E X-CRM114-Status: GOOD ( 29.74 ) 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: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 1/28/21 5:09 PM, Mike Leach wrote: > Preload set of configurations. > > This patch creates a small set of preloaded configurations and features > that are available immediately after coresight has been initialised. > > The current set provides a strobing feature for ETMv4, that creates a > periodic sampling of trace by switching trace generation on and off > using counters in the ETM. > > A configuration called "autofdo" is also provided that uses the 'strobing' > feature and provides a couple of preset values, selectable on the perf > command line. > > Signed-off-by: Mike Leach > --- > drivers/hwtracing/coresight/Makefile | 3 +- > .../hwtracing/coresight/coresight-cfg-afdo.c | 154 ++++++++++++++++++ > .../coresight/coresight-cfg-preload.c | 25 +++ > .../coresight/coresight-cfg-preload.h | 11 ++ > drivers/hwtracing/coresight/coresight-core.c | 6 + > .../hwtracing/coresight/coresight-syscfg.h | 1 + > 6 files changed, 199 insertions(+), 1 deletion(-) > create mode 100644 drivers/hwtracing/coresight/coresight-cfg-afdo.c > create mode 100644 drivers/hwtracing/coresight/coresight-cfg-preload.c > create mode 100644 drivers/hwtracing/coresight/coresight-cfg-preload.h > > diff --git a/drivers/hwtracing/coresight/Makefile b/drivers/hwtracing/coresight/Makefile > index ea544206204d..2707bfef1b76 100644 > --- a/drivers/hwtracing/coresight/Makefile > +++ b/drivers/hwtracing/coresight/Makefile > @@ -4,7 +4,8 @@ > # > obj-$(CONFIG_CORESIGHT) += coresight.o > coresight-y := coresight-core.o coresight-etm-perf.o coresight-platform.o \ > - coresight-sysfs.o coresight-syscfg.o coresight-config.o > + coresight-sysfs.o coresight-syscfg.o coresight-config.o \ > + coresight-cfg-preload.o coresight-cfg-afdo.o > obj-$(CONFIG_CORESIGHT_LINK_AND_SINK_TMC) += coresight-tmc.o > coresight-tmc-y := coresight-tmc-core.o coresight-tmc-etf.o \ > coresight-tmc-etr.o > diff --git a/drivers/hwtracing/coresight/coresight-cfg-afdo.c b/drivers/hwtracing/coresight/coresight-cfg-afdo.c > new file mode 100644 > index 000000000000..ff69fb3f4434 > --- /dev/null > +++ b/drivers/hwtracing/coresight/coresight-cfg-afdo.c > @@ -0,0 +1,154 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright(C) 2020 Linaro Limited. All rights reserved. > + * Author: Mike Leach > + */ > + > +#include "coresight-config.h" > +#include "coresight-etm4x-cfg.h" > + > +/* preload configurations and features */ > + > +/* preload in features for ETMv4 */ > + > +/* strobe feature */ > +static struct cscfg_parameter_desc strobe_params[] = { > + { > + .name = "window", > + .value = 5000, > + }, > + { > + .name = "period", > + .value = 10000, > + }, > +}; > + > +static struct cscfg_regval_desc strobe_regs[] = { > + /* resource selectors */ > + { > + .type = CS_CFG_REG_TYPE_RESOURCE, > + .offset = TRCRSCTLRn(2), > + .hw_info = ETM4_CFG_RES_SEL, > + .val32 = 0x20001, > + }, > + { > + .type = CS_CFG_REG_TYPE_RESOURCE, > + .offset = TRCRSCTLRn(3), > + .hw_info = ETM4_CFG_RES_SEQ, > + .val32 = 0x20002, > + }, > + /* strobe window counter 0 - reload from param 0 */ > + { > + .type = CS_CFG_REG_TYPE_RESOURCE | CS_CFG_REG_TYPE_VAL_SAVE, > + .offset = TRCCNTVRn(0), > + .hw_info = ETM4_CFG_RES_CTR, > + }, > + { > + .type = CS_CFG_REG_TYPE_RESOURCE | CS_CFG_REG_TYPE_VAL_PARAM, > + .offset = TRCCNTRLDVRn(0), > + .hw_info = ETM4_CFG_RES_CTR, > + .val32 = 0, > + }, > + { > + .type = CS_CFG_REG_TYPE_RESOURCE, > + .offset = TRCCNTCTLRn(0), > + .hw_info = ETM4_CFG_RES_CTR, > + .val32 = 0x10001, > + }, > + /* strobe period counter 1 - reload from param 1 */ > + { > + .type = CS_CFG_REG_TYPE_RESOURCE | CS_CFG_REG_TYPE_VAL_SAVE, > + .offset = TRCCNTVRn(1), > + .hw_info = ETM4_CFG_RES_CTR, > + }, > + { > + .type = CS_CFG_REG_TYPE_RESOURCE | CS_CFG_REG_TYPE_VAL_PARAM, > + .offset = TRCCNTRLDVRn(1), > + .hw_info = ETM4_CFG_RES_CTR, > + .val32 = 1, > + }, > + { > + .type = CS_CFG_REG_TYPE_RESOURCE, > + .offset = TRCCNTCTLRn(1), > + .hw_info = ETM4_CFG_RES_CTR, > + .val32 = 0x8102, > + }, > + /* sequencer */ > + { > + .type = CS_CFG_REG_TYPE_RESOURCE, > + .offset = TRCSEQEVRn(0), > + .hw_info = ETM4_CFG_RES_SEQ, > + .val32 = 0x0081, > + }, > + { > + .type = CS_CFG_REG_TYPE_RESOURCE, > + .offset = TRCSEQEVRn(1), > + .hw_info = ETM4_CFG_RES_SEQ, > + .val32 = 0x0000, > + }, > + /* view-inst */ > + { > + .type = CS_CFG_REG_TYPE_STD | CS_CFG_REG_TYPE_VAL_MASK, > + .offset = TRCVICTLR, > + .val32 = 0x0003, > + .mask32 = 0x0003, > + }, > + /* end of regs */ > +}; > + > +struct cscfg_feature_desc strobe = { > + .name = "strobing", > + .brief = "Generate periodic trace capture windows.\n" > + "parameter \'window\': a number of CPU cycles (W)\n" > + "parameter \'period\': trace enabled for W cycles every period x W cycles\n", nit: Could we align the string as below: .brief = "Generate periodic trace capture windows.\n" "parameter \'window\': a number of CPU cycles (W)\n" "parameter \'period\': trace enabled for W cycles every period x W cycles\n", > + .match_flags = CS_CFG_MATCH_CLASS_SRC_ETM4, > + .nr_params = ARRAY_SIZE(strobe_params), > + .params = strobe_params, > + .nr_regs = ARRAY_SIZE(strobe_regs), > + .regs = strobe_regs, > +}; > + > +/* create an autofdo configuration */ > + > +/* we will provide 9 sets of preset parameter values */ > +#define AFDO_NR_PRESETS 9 > +/* the total number of parameters in used features */ > +#define AFDO_NR_PARAM_SUM ARRAY_SIZE(strobe_params) nit: alignment consistency. i.e 1 TAB vs 2 TABs (with AFDO_NR_PRESETS) minor nit : s/AFDO_NR_PARAM_SUM/AFDO_NR_TOTAL_PARAMS ? or even AFDO_NR_PARAMS > + > +#define AFDO_MATCH_STROBING (CS_CFG_MATCH_INST_ANY | CS_CFG_MATCH_CLASS_SRC_ETM4) > + > +static struct cscfg_config_feat_ref afdo_refs[] = { > + { > + .name = "strobing", > + .match = { > + .match_flags = AFDO_MATCH_STROBING, > + }, > + }, > +}; > + > +/* > + * set of presets leaves strobing window constant while varying period to allow > + * experimentation with mark / space ratios for various workloads > + */ > +static u64 afdo_presets[AFDO_NR_PRESETS][AFDO_NR_PARAM_SUM] = { > + { 5000, 2 }, > + { 5000, 4 }, > + { 5000, 8 }, > + { 5000, 16 }, > + { 5000, 64 }, > + { 5000, 128 }, > + { 5000, 512 }, > + { 5000, 1024 }, > + { 5000, 4096 }, > +}; > + > +struct cscfg_config_desc afdo = { > + .name = "autofdo", > + .brief = "Setup ETMs with strobing for autofdo\n" > + "Supplied presets allow experimentation with mark-space ratio for various loads\n", Same alignment comments as above > + .nr_refs = ARRAY_SIZE(afdo_refs), > + .refs = afdo_refs, > + .nr_presets = AFDO_NR_PRESETS, > + .nr_total_params = AFDO_NR_PARAM_SUM, > + .presets = &afdo_presets[0][0], > +}; > diff --git a/drivers/hwtracing/coresight/coresight-cfg-preload.c b/drivers/hwtracing/coresight/coresight-cfg-preload.c > new file mode 100644 > index 000000000000..c7ec5cbdd990 > --- /dev/null > +++ b/drivers/hwtracing/coresight/coresight-cfg-preload.c > @@ -0,0 +1,25 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright(C) 2020 Linaro Limited. All rights reserved. > + * Author: Mike Leach One line on the brief of the files purpose is helpful. > + */ > + > +#include "coresight-cfg-preload.h" > +#include "coresight-config.h" > +#include "coresight-syscfg.h" > + > +static struct cscfg_feature_desc *preload_feats[] = { > + &strobe, > + 0 > +}; > + > +static struct cscfg_config_desc *preload_cfgs[] = { > + &afdo, > + 0 > +}; > + > +/* preload called with mutex locked */ > +int cscfg_preload(void) > +{ > + return cscfg_load_config_sets(preload_cfgs, preload_feats); > +} > diff --git a/drivers/hwtracing/coresight/coresight-cfg-preload.h b/drivers/hwtracing/coresight/coresight-cfg-preload.h > new file mode 100644 > index 000000000000..fc4ac7faa93d > --- /dev/null > +++ b/drivers/hwtracing/coresight/coresight-cfg-preload.h > @@ -0,0 +1,11 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +/* > + * Copyright(C) 2020 Linaro Limited. All rights reserved. > + * Author: Mike Leach > + */ > + > +/* declare preloaded configurations and features */ > + > +/* from coresight-cfg-afdo.c */ > +extern struct cscfg_feature_desc strobe; > +extern struct cscfg_config_desc afdo; > diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c > index 6bd41de46648..633ddcffc6c7 100644 > --- a/drivers/hwtracing/coresight/coresight-core.c > +++ b/drivers/hwtracing/coresight/coresight-core.c > @@ -1744,9 +1744,15 @@ static int __init coresight_init(void) > > /* initialise the coresight syscfg API */ > ret = cscfg_init(); > + if (ret) > + goto exit_perf_close; > + > + /* preload builtin configurations */ > + ret = cscfg_preload(); > if (!ret) > return 0; Could this be folded into cscfg_init() ? Otherwise looks fine to me Suzuki _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel