From patchwork Fri Oct 30 17:56:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 11870459 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.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,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 EDD0BC00A89 for ; Fri, 30 Oct 2020 17:59:27 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 1A89820724 for ; Fri, 30 Oct 2020 17:59:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="P8hg5/JE"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="QhIhc6BJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1A89820724 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=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=tIKj5P42EkvGCBtNjHjyD4VxG/vG5iVL+zoEHVX/3sk=; b=P8hg5/JEPdAJ/fAFEEkD9b7lan Bh16LYZA44sJpN9Bz00bt+jZn8ntvPbSLg4pig/R/rnj/IghSoI3quGPBH5mOe4KRGNQmL0/S3yss vFbo4G9vsAWFUPYPR7GpnSnC5Ec5ezeYEaPZCSbtQYpjsPwkM1PYi4y+r7ct/mjWwDUQvNfToc3WF vOwAnsJpug5BbPdrT0yVxBCcTqwPqSQVfzEF6yk5TzjovBp5NuPZ63542T6/vg04BizR4of266uCB VcFSoS9QDAL+EVXrvW5YNT6LHFq6Orpt2mkARm74kOmZG7/4NcMOVRUR8Uo31JJm9Mx/Nbl/YLLoq 4mohviRQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kYYfm-0004J3-B6; Fri, 30 Oct 2020 17:58:46 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kYYeD-0003mk-1F for linux-arm-kernel@lists.infradead.org; Fri, 30 Oct 2020 17:57:15 +0000 Received: by mail-wm1-x32d.google.com with SMTP id h22so3746133wmb.0 for ; Fri, 30 Oct 2020 10:57:08 -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=VoGovKEbbz2tGOPajOqOeaPAgxytepmpu53NKthUheI=; b=QhIhc6BJ9W+kE3BH45fjsnCC5vKgb3GXuEi30QfsdwtNZyJrjfZkZvVF6knbp0qiJF Qf+DpiHNsES8FgqZJ27hkkMzPEObNdV+LFS/jn/F6Gun64LvtKynL2g82nYVbLVgfvS9 eeL5QvlKHwBwo4rEl53LCBbXndtXM4fsEqGlA28IRinymlVH4HWgF6XHAMdiLOBMCFI2 2KfZHRl8KM1MQOBflmVGnP2LAuhlthl1DgEB/X+HdrRR67FGP70RvUEc8hjSUUzI7PAs OOckYF35+QKb7lbb/87CMJkHzQDG5SKtxv11gPHqvfvN73ICqrbUf/Z1f4Zp+tSXzTC2 RRhw== 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=VoGovKEbbz2tGOPajOqOeaPAgxytepmpu53NKthUheI=; b=dIJ+RiyMS1vFpjSQeQIil8dMzxNq9nsJAdsv6j5NhX8yun06yyPn0QTpSbrDS5WuBs x8TJwYAdGBOvOG3NyJCbm/Jf4nxvwZoaillG0H+IvRVBup0fuqMudiJAcLJ2ig+0a9ns SuwfrVZnjNKb/5Gd3CwX3AwLhO2zvwby2/K6J9HMrh0ddVVBkkcHgONcAIDsagphPAEE r/aYPouwiSCXsFOxyTXtOZNsdfAa7A/bvrOtPhYLXZq9oNuzdp3D8+AqXIR0htqOKJ0f Rt/fyj8gOMX7PHPKU/oXvKyqXM2HSP7OivWhTokHhiwdhsOeDZLty3gxrKknVIMk+VR8 ryGw== X-Gm-Message-State: AOAM531NzzudbVQMuAj/imAA71LPjrWy/ICoEL6d9FPZyOZik74WV1kh k+vzvfsL45HxsUQuqll4kdhTYvL8I4sEEQ== X-Google-Smtp-Source: ABdhPJxl19LagFzxGRcBuhMUWVuPx5MeeCYEALYaR3iylSGXI6z6U1WyZnJdhoaApApXn5JLQml+/A== X-Received: by 2002:a7b:cc09:: with SMTP id f9mr3960554wmh.93.1604080627121; Fri, 30 Oct 2020 10:57:07 -0700 (PDT) Received: from linaro.org ([2a00:23c5:6801:1801:4964:83f8:d2e7:f2c9]) by smtp.gmail.com with ESMTPSA id o129sm5615563wmb.25.2020.10.30.10.57.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2020 10:57:06 -0700 (PDT) From: Mike Leach To: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, mathieu.poirier@linaro.org Subject: [RFC PATCH v3 9/9] coresight: docs: Add documentation for CoreSight config. Date: Fri, 30 Oct 2020 17:56:55 +0000 Message-Id: <20201030175655.30126-10-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201030175655.30126-1-mike.leach@linaro.org> References: <20201030175655.30126-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201030_135709_217783_4D35C6AB X-CRM114-Status: GOOD ( 29.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yabinc@google.com, Mike Leach , suzuki.poulose@arm.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Adds documentation for the CoreSight System configuration manager. Signed-off-by: Mike Leach --- .../trace/coresight/coresight-config.rst | 230 ++++++++++++++++++ Documentation/trace/coresight/coresight.rst | 16 ++ 2 files changed, 246 insertions(+) create mode 100644 Documentation/trace/coresight/coresight-config.rst diff --git a/Documentation/trace/coresight/coresight-config.rst b/Documentation/trace/coresight/coresight-config.rst new file mode 100644 index 000000000000..8afcf18c090c --- /dev/null +++ b/Documentation/trace/coresight/coresight-config.rst @@ -0,0 +1,230 @@ +.. SPDX-License-Identifier: GPL-2.0 + +====================================== +CoreSight System Configuration Manager +====================================== + + :Author: Mike Leach + :Date: October 2020 + +Introduction +============ + +The CoreSight System Configuration manager is an API that allows the +programming of the CoreSight system with pre-defined configurations that +can then be easily enabled from sysfs or perf. + +Many CoreSight components can be programmed in complex ways - especially ETMs. +In addition, components can interact across the CoreSight system, often via +the cross trigger components such as CTI and CTM. These system settings can +be defined and enabled as named configurations. + + +Basic Concepts +============== + +This section introduces the basic concepts of a complex system configuration. + + +Features +-------- + +A feature is a named set of programming for a CoreSight device. The programming +is device dependent, and can be defined in terms of absolute register values, +resource usage and parameter values. + +The feature is defined using a descriptor. This descriptor is used to load onto +a matching device, either when the feature is loaded into the system, or when the +device is registered with the configuration manager. + +The load process involves interpreting the descriptor into a the set of register +accesses in the driver - the resource usage and parameter descriptions +translated into appropriate register accesses. This interpretation makes it easy +and efficient for the feature to be programmed onto the device when required. + +The feature will not be active on the device until the feature is enabled, and +the device itself is enabled. When the device is enabled then enabled features +will be programmed into the device hardware. + +A feature can be enabled either as part of a configuration being enabled on the +system, or individually on a device instance using the configfs API. + + +Parameter Value +~~~~~~~~~~~~~~~ + +A parameter value is a named value that may be set by the user prior to the +feature being enabled that can adjust the behaviour of the operation programmed +by the feature. + +For example, this could be a count value in a programmed operation that repeats +at a given rate. When the feature is enabled then the current value of the +parameter is used in programming the device. + +The feature descriptor defines a default value for a parameter, which is used +if the user does not supply a new value. + +Users can update parameter values using the configfs API for the CoreSight +system - which is described below. + +The current value of the parameter is loaded into the device when the feature +is enabled on that device. + + +Configurations +-------------- + +A configuration defines a set of features that are to be used in a trace +session where the configuration is selected. For any trace session only one +configuration may be selected. + +The features defined may be on any type of device that is registered +to support system configuration. A configuration may select features to be +enabled on a class of devices - i.e. any ETMv4, or specific devices, e.g. a +specific CTI on the system. + +As with the feature, a descriptor is used to define the configuration. +This will define the features that must be enabled as part of the configuration +as well as any preset values that can be used to override default parameter +values. + + +Preset Values +~~~~~~~~~~~~~ + +Preset values are easily selectable sets of parameter values for the features +that the configuration uses. The number of values in a single preset set, equals +the sum of parameter values in the features used by the configuration. + +e.g. a configuration consists of 3 features, one has 2 parameters, one has +a single parameter, and another has no parameters. A single preset set will +therefore have 3 values. + +Presets are optionally defined by the configuration, up to 15 can be defined. +If no preset is selected, then the parameter values defined in the feature +are used as normal. + + +Virtual Device +-------------- + +The CoreSight System Configuration manager also includes a virtual CoreSight +device. This provides the system with access to kernel objects and device +management to own elements such as the sysfs entries used to expose the +configurations into the cs_etm event in perf. + +This device 'system_cfg' appears on a custom bus - 'coresight-config' - +rather than the normal 'coresight' bus to avoid complications when the +coresight system is searching for real devices on the bus. + + +Viewing Configurations and Features +=================================== + +The set of configurations and features that are currently loaded into the +system can be viewed using the configfs API. + +Mount configfs as normal and the 'coresight-syscfg' subsystem will appear:: + + $ ls /config + coresight-syscfg stp-policy + +This has two sub-directories:: + + $ cd coresight-syscfg/ + $ ls + configurations features + +The system has the configuration 'autofdo' built in. It may be examined as +follows:: + + $ cd configurations/ + $ ls + autofdo + $ cd autofdo/ + $ ls + description nr_presets preset_values refs + $ cat description + Setup ETMs with strobing for autofdo + $ cat refs + references 1 features:- + strobing + $ cat nr_presets + 2 + $ cat preset_values + 2 presets, 2 parameters per preset + preset[1]: strobing.window = 0x2710 strobing.period = 0x1388 + preset[2]: strobing.window = 0x1388 strobing.period = 0x1388 + +The features referenced by the configuration can be examined in the features +directory:: + + $ cd ../../features/strobing/ + $ ls + description matches nr_params params + $ cat description + Generate periodic trace capture windows. + parameter 'window': a number of CPU cycles (W) + parameter 'period': trace enabled for W cycles every period x W cycles + $ cat matches + SRC_ETMV4 + $ cat nr_params + 2 + +Move to the params directory to examine and adjust parameters:: + + cd params + $ ls + period window + $ cd period + $ ls + value + $ cat value + 0x2710 + # echo 15000 > value + # cat value + 0x3a98 + +Parameters adjusted in this way are reflected in all device instances that have +loaded the feature. + + +Using Configurations in perf +============================ + +The configurations loaded into the CoreSight configuration management are +also declared in the perf 'cs_etm' event infrastructure so that they can +be selected when running trace under perf:: + + $ ls /sys/devices/cs_etm + configurations format perf_event_mux_interval_ms sinks type + events nr_addr_filters power + +Key directories here are 'configurations' - which lists the loaded +configurations, and 'events' - a generic perf directory which allows +selection on the perf command line.:: + + $ ls configurations/ + autofdo + $ cat configurations/autofdo + 0xa7c3dddd + +As with the sinks entries, this provides a hash of the configuration name. +The entry in the 'events' directory uses perfs built in syntax generator +to substitute the syntax for the name when evaluating the command:: + + $ ls events/ + autofdo + $ cat events/autofdo + configid=0xa7c3dddd + +The 'autofdo' configuration may be selected on the perf command line:: + + $ perf record -e cs_etm/autofdo/u --per-thread + +A preset to override the current parameter values can also be selected:: + + $ perf record -e cs_etm/autofdo,preset=1/u --per-thread + +When configurations are selected in this way, then the trace sink used is +automatically selected. diff --git a/Documentation/trace/coresight/coresight.rst b/Documentation/trace/coresight/coresight.rst index 0b73acb44efa..0122d9bebf35 100644 --- a/Documentation/trace/coresight/coresight.rst +++ b/Documentation/trace/coresight/coresight.rst @@ -587,6 +587,20 @@ A separate documentation file is provided to explain the use of these devices. (:doc:`coresight-ect`) [#fourth]_. +CoreSight System Configuration +------------------------------ + +CoreSight components can be complex devices with many programming options. +Furthermore, components can be programmed to interact with each other across the +complete system. + +A CoreSight System Configuration manager is provided to allow these complex programming +configurations to be selected and used easily from perf and sysfs. + +See the separate document for further information. +(:doc:`coresight-config`) [#fifth]_. + + .. [#first] Documentation/ABI/testing/sysfs-bus-coresight-devices-stm .. [#second] Documentation/trace/stm.rst @@ -594,3 +608,5 @@ A separate documentation file is provided to explain the use of these devices. .. [#third] https://github.com/Linaro/perf-opencsd .. [#fourth] Documentation/trace/coresight/coresight-ect.rst + +.. [#fifth] Documentation/trace/coresight/coresight-config.rst