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=-17.4 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,SPF_PASS,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 CB928C433B4 for ; Wed, 12 May 2021 21:21:15 +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 318F0611C9 for ; Wed, 12 May 2021 21:21:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 318F0611C9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org 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:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id: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=W+oDA5UU998viv9e/P5rG3lfxtac4ZUGnTn9hvktUJo=; b=MW0jr3/FyvHvoLFse11HitYULT 58PaR9ynci5NQRfEnauDMK76mFtnI1JQ8ITR/lNrCNP18XV9UM6YIaP9aGLPaeIZ6ttJCCBxXTysY FwtzTLQa7lt95bc3hREpEm0zOc5jyygOxtZKUBItzrLEZIyWjtipjA9RM4t2emYEmyO09QN8rxztw 3Ej3hgBnfDmMXwqVRm3yDLmJmwNc/aMieV9gn6naxsRKIN8fmRP7ljiBfBpsM2Y1WmtwOawqb83TT PRpPsBWgoA0CKe0vtyedNAY5Dw85R9hB+Pxy9Z0Hf4YNo7JVHBpKg/Q/rdnmENnFUjB5Ghnh7ujWp 8QfoL31g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lgwFY-0040XO-GW; Wed, 12 May 2021 21:18:36 +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 1lgwF6-0040Sh-Eh for linux-arm-kernel@desiato.infradead.org; Wed, 12 May 2021 21:18:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description; bh=WlYi+SHiGyL5WUEUZac2YTO9w6rW9DmdcDFUKtKvVSE=; b=Go4ehf99GinXchgopSHcKNIyGd FPinNFHdL2JfqLG66mHYA+xj3iFMcIhOrTeEHR80qJMMAxXuBNzRK4Cle+ZZX0cCM3Y9uEU/XJRZt lZcglduclXVjoDLFI6xmUsVYeOeI7AHXozVguKpOWTjA3J0MQzdAvkUsq9tsU/9mRLs3vmL1TNNd1 lalXtCXZ+KLALJkdxWgCMEEtrjizU52nIubJKifZDVqfAwCi6E786pQeimLYVPpwFuNqYuciSTHvL BWvBVkNGMif4mV2QwZITXDFe9y+8lP1UmCEP+r9gH7Lbtw/03ETuy2/rLcDmKvlu+SCz3/jlKhXcS UYUjdOiA==; Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgwF2-00Apep-Og for linux-arm-kernel@lists.infradead.org; Wed, 12 May 2021 21:18:07 +0000 Received: by mail-wr1-x42d.google.com with SMTP id l14so25020708wrx.5 for ; Wed, 12 May 2021 14:18:04 -0700 (PDT) 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; bh=WlYi+SHiGyL5WUEUZac2YTO9w6rW9DmdcDFUKtKvVSE=; b=FUsY0OsX/mgcdPw1YhxEy65vtbsSiiFiKciITa09rR+cECb25NvHg/KmKv3TS+HRGH kKHeILvdL8JvkrKXSqAaW98NjwrB8mmKCjxUQWj9mkcOndsmfE9P/xwpQhg82X+r7wFK w1aWVXK63qEOVJQq48YxuT/2JsjMS6h79W0bFqrs3YKoaYuKzFBEBQlsrT+Kq6mD3syO WuP9qH74D1dMLRRpdrexxU+Yef+kPhUDAzeGXP5xS/K99dSfdcd2sRBmLppLc08cvY9i j1CWPGAdXs/DNsnvDSNOq0SGGfJ+u0OPnoLZgNU4FF1c4I8srPeraIyA7/7tbXT6eiAO amdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WlYi+SHiGyL5WUEUZac2YTO9w6rW9DmdcDFUKtKvVSE=; b=n/FVZHB5IyKP4OQMZFnu72HMHxDSVIHiMFyK19Ver0TeOb3S2POQ9kjlp7EfP6W8vX 5riDs+iZj+6zFyPujUpQ6Gai5uKLUyM/YsS417ddsMoZCTNXHMN3WO8OvE0xpnBIhPds A/YWFz4iWAQtGt7RD4+ZG1jq4vyngE6p15Lhv5hw4xEXr9qikg2QwYl3we7MFu1Cg1eR WVbR8I3L1RTLGigtKhNN3+SFGGHiJSw2U6ITvgRdCks5F+5I0d3Jf13yALmTr0GRhNOr KJhRM9RLYF6xwIBbk/0gDwMP4+LPl1tJ6Vw5snoFHCDY4PopbzLhd/X25BoE4S45c/hr EJVQ== X-Gm-Message-State: AOAM531jYW3ngP9Y7tlAzctxFDNFAsRBoQnGcu5SaCpJadCmaMqu7L+R Dk20qtyhv8xUZ6+Ap5rnJlJl9A== X-Google-Smtp-Source: ABdhPJxZqoJxK5GkkEZhllbxMwmXlILS3aa6mGuBhnzz9lKzGDXMSIIDcyPtr/hWs5dRzphQJ1ZVKg== X-Received: by 2002:adf:f38c:: with SMTP id m12mr47021391wro.282.1620854283251; Wed, 12 May 2021 14:18:03 -0700 (PDT) Received: from linaro.org ([2a00:23c5:6809:2201:3d54:dc15:c65b:180c]) by smtp.gmail.com with ESMTPSA id e10sm908745wrw.20.2021.05.12.14.18.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 May 2021 14:18:03 -0700 (PDT) From: Mike Leach To: coresight@lists.linaro.org Cc: linux-arm-kernel@lists.infradead.org, mathieu.poirier@linaro.org, suzuki.poulose@arm.com, leo.yan@linaro.org, Mike Leach Subject: [RFC PATCH 3/8] coresight: syscfg: Example CoreSight configuration loadable module Date: Wed, 12 May 2021 22:17:47 +0100 Message-Id: <20210512211752.4103-4-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210512211752.4103-1-mike.leach@linaro.org> References: <20210512211752.4103-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210512_141804_826163_2D66C105 X-CRM114-Status: GOOD ( 22.26 ) 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: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org An example of creating a loadable module to add CoreSight configurations into a system. In the Kernel samples/coresight directory. Signed-off-by: Mike Leach --- MAINTAINERS | 1 + samples/Kconfig | 9 +++ samples/Makefile | 1 + samples/coresight/Makefile | 4 ++ samples/coresight/coresight-cfg-sample.c | 73 ++++++++++++++++++++++++ 5 files changed, 88 insertions(+) create mode 100644 samples/coresight/Makefile create mode 100644 samples/coresight/coresight-cfg-sample.c diff --git a/MAINTAINERS b/MAINTAINERS index bd7aff0c120f..9ff5f5e7dd06 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1789,6 +1789,7 @@ F: Documentation/trace/coresight/* F: drivers/hwtracing/coresight/* F: include/dt-bindings/arm/coresight-cti-dt.h F: include/linux/coresight* +F: samples/coresight/* F: tools/perf/arch/arm/util/auxtrace.c F: tools/perf/arch/arm/util/cs-etm.c F: tools/perf/arch/arm/util/cs-etm.h diff --git a/samples/Kconfig b/samples/Kconfig index b5a1a7aa7e23..0cd618e15571 100644 --- a/samples/Kconfig +++ b/samples/Kconfig @@ -223,4 +223,13 @@ config SAMPLE_WATCH_QUEUE Build example userspace program to use the new mount_notify(), sb_notify() syscalls and the KEYCTL_WATCH_KEY keyctl() function. +config SAMPLE_CORESIGHT_SYSCFG + tristate "Build example loadable module for CoreSight config" + depends on CORESIGHT && m + help + Build an example loadable module that adds new CoreSight features + and configuration using the CoreSight system configuration API. + This demonstrates how a user may create their own CoreSight + configurations and easily load them into the system at runtime. + endif # SAMPLES diff --git a/samples/Makefile b/samples/Makefile index 087e0988ccc5..6c96297001a8 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -30,3 +30,4 @@ obj-$(CONFIG_SAMPLE_INTEL_MEI) += mei/ subdir-$(CONFIG_SAMPLE_WATCHDOG) += watchdog subdir-$(CONFIG_SAMPLE_WATCH_QUEUE) += watch_queue obj-$(CONFIG_DEBUG_KMEMLEAK_TEST) += kmemleak/ +obj-$(CONFIG_SAMPLE_CORESIGHT_SYSCFG) += coresight/ diff --git a/samples/coresight/Makefile b/samples/coresight/Makefile new file mode 100644 index 000000000000..09126aabf43d --- /dev/null +++ b/samples/coresight/Makefile @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0-only + +obj-$(CONFIG_SAMPLE_CORESIGHT_SYSCFG) += coresight-cfg-sample.o +ccflags-y += -I$(src)/../../drivers/hwtracing/coresight diff --git a/samples/coresight/coresight-cfg-sample.c b/samples/coresight/coresight-cfg-sample.c new file mode 100644 index 000000000000..865c188fae34 --- /dev/null +++ b/samples/coresight/coresight-cfg-sample.c @@ -0,0 +1,73 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright(C) 2020 Linaro Limited. All rights reserved. + * Author: Mike Leach + */ + +#include "coresight-config.h" +#include "coresight-syscfg.h" + +/* create an alternate autofdo configuration */ + +/* we will provide 4 sets of preset parameter values */ +#define AFDO2_NR_PRESETS 4 +/* the total number of parameters in used features - strobing has 2 */ +#define AFDO2_NR_PARAM_SUM 2 + +static const char *afdo2_ref_names[] = { + "strobing", +}; + +/* + * set of presets leaves strobing window constant while varying period to allow + * experimentation with mark / space ratios for various workloads + */ +static u64 afdo2_presets[AFDO2_NR_PRESETS][AFDO2_NR_PARAM_SUM] = { + { 1000, 100 }, + { 1000, 1000 }, + { 1000, 5000 }, + { 1000, 10000 }, +}; + +struct cscfg_config_desc afdo2 = { + .name = "autofdo2", + .description = "Setup ETMs with strobing for autofdo\n" + "Supplied presets allow experimentation with mark-space ratio for various loads\n", + .nr_feat_refs = ARRAY_SIZE(afdo2_ref_names), + .feat_ref_names = afdo2_ref_names, + .nr_presets = AFDO2_NR_PRESETS, + .nr_total_params = AFDO2_NR_PARAM_SUM, + .presets = &afdo2_presets[0][0], +}; + +static struct cscfg_feature_desc *sample_feats[] = { + 0 +}; + +static struct cscfg_config_desc *sample_cfgs[] = { + &afdo2, + 0 +}; + +static struct cscfg_load_owner_info mod_owner = { + .type = CSCFG_OWNER_MODULE, + .owner_handle = THIS_MODULE, +}; + +/* module init and exit - just load and unload configs */ +static int __init cscfg_sample_init(void) +{ + return cscfg_load_config_sets(sample_cfgs, sample_feats, &mod_owner); +} + +static void __exit cscfg_sample_exit(void) +{ + cscfg_unload_config_sets(&mod_owner); +} + +module_init(cscfg_sample_init); +module_exit(cscfg_sample_exit); + +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Mike Leach "); +MODULE_DESCRIPTION("CoreSight Syscfg Example"); -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel