From patchwork Wed Nov 24 20:00:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 12693581 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CF991C433F5 for ; Wed, 24 Nov 2021 20:03:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; 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=kH1sOPZEdPOV+Yt9myrTiZIazUgWdKEx0toh8sxDCeM=; b=pqRGS2elCXnE3N ruevl9fnzj+TWM+AtqbRJ/X+QbF8hWNcMZIra+lxYxfAsClTrJ3VaD/tV8wmqj4eT1DwipqAPOZ0J qNAk+HZprOGcn0xY6ZXLEJW3Fzt2DDu/a2cduCU1u/IaeKIT32+MSiAmn0KbyQPkXY4wI6ZgRRXty eJ6w/1fmkl3SgadcTyb2JsVNPyxkZ5c4tru9SaMifJracNBmh3rLJMINchUKBXUGWqI7jA6TrfA+A gFKcsl+mdE49OteJ6H1AeOLIxPwuWZft7f2y9wX+wKR3W6wgj9mmyWgyIKgupSoPofwF2IS+UXQ1+ sinJeTHimSqAIJWKOrzA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mpySU-005jgi-Ew; Wed, 24 Nov 2021 20:01:34 +0000 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mpyRk-005jRy-8V for linux-arm-kernel@lists.infradead.org; Wed, 24 Nov 2021 20:00:50 +0000 Received: by mail-wm1-x32b.google.com with SMTP id i12so3526992wmq.4 for ; Wed, 24 Nov 2021 12:00:48 -0800 (PST) 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=L2N9DBJFT/LaykMxZ955Vn/H9ClRdLTcBhWxF4YCVME=; b=bf86iwyaSIO5Oy3WqpZhDA/X7AH8iObYkZgmjD8jxfC8xBlrIDPBiVj+Hb6KU6SRYU idR3/AaH2on2qZBTnz5N//SO2bdoQBesXhkLiALIV8mop1UdMfI2LRCqlYXDcLEcwouU FfqQ+3ZO6Jyc4NXs03Sx0ReyeuZVo3banE1jpC84tZxKhLwwY8WrnthEsWiXgfRwNwvu paNADQz7Epr2Gx68E/c9FL8Lo6WKdF5dIue3qtgFnD2OuNfco+JUclwmkHtqWFyX8OAq axlEf32Ds1EnsDQiq8nSVv+rTIePnYdOmuBb6krpjIRSfunBLwp6jE757yq9KNhjbGGJ UMPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=L2N9DBJFT/LaykMxZ955Vn/H9ClRdLTcBhWxF4YCVME=; b=7V4oD06rHUVevv/L2ItWGCAsjR13WxZqsQft4w0cZm75nWeU1bFHK4vaGZlw2gjXRR 1jA2HBbHK6rNCfGaGc6Q1YHPBoaEy2Ukz6BMQ7GQjb7R76INgj2s5gAKSFZ4TvHwL0yw UziLihL/vhVXlI2dJQnyu10dpXBNkFhgpOnNEoA41Xdpgj9zDT+c5Yf3jQ8n6Qbem0EN qNgC6ctX2Y7oKSiLTXkfLLl2i1T2Dd2n4WDEpccYAZQPLSt0PIUOEE5fV7TorApZRcPj W+xdVkiPZ0kmfR/I9yhewZP9nAKcocogenhhcSQVPFPwr2seSh/PvHSwBESEgqYuAuVv qRoQ== X-Gm-Message-State: AOAM530HJN2Unx+xFl/qsFyO19ufl5KLIS+I5Mwr+ED1IlUfsfh7F7jJ nXo0iVMYCtpzFZWjtIYmvWZpRs6hNcYi/w== X-Google-Smtp-Source: ABdhPJxkBcNS+Mv7eef9juciXHrRh+5JRKO7H2WG7SKYgm92dlrysw3ziER6wZhwdNhfo2E6Lpl14Q== X-Received: by 2002:a7b:c452:: with SMTP id l18mr19222493wmi.46.1637784047000; Wed, 24 Nov 2021 12:00:47 -0800 (PST) Received: from linaro.org ([2a00:23c5:6809:2201:dd2e:a6e1:6adf:269c]) by smtp.gmail.com with ESMTPSA id c1sm729582wrt.14.2021.11.24.12.00.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Nov 2021 12:00:46 -0800 (PST) From: Mike Leach To: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org Cc: mathieu.poirier@linaro.org, suzuki.poulose@arm.com, leo.yan@linaro.org, Mike Leach Subject: [PATCH v3 4/6] coresight: syscfg: Example CoreSight configuration loadable module Date: Wed, 24 Nov 2021 20:00:36 +0000 Message-Id: <20211124200038.28662-5-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211124200038.28662-1-mike.leach@linaro.org> References: <20211124200038.28662-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211124_120048_373070_51633CFB X-CRM114-Status: GOOD ( 21.18 ) 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 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 Reviewed-by: Mathieu Poirier --- 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 7a2345ce8521..85242fdd3b8c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1890,6 +1890,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 bec3528aa2de..fe8b56d576ce 100644 --- a/samples/Kconfig +++ b/samples/Kconfig @@ -232,6 +232,15 @@ 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 config HAVE_SAMPLE_FTRACE_DIRECT diff --git a/samples/Makefile b/samples/Makefile index b7b98307c2b4..c148ada64beb 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -32,3 +32,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..b3fce4af2347 --- /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$(srctree)/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..25485c80b5e3 --- /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[] = { + NULL +}; + +static struct cscfg_config_desc *sample_cfgs[] = { + &afdo2, + NULL +}; + +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");