From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: Mike Leach <mike.leach@linaro.org>
Cc: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org,
suzuki.poulose@arm.com, leo.yan@linaro.org
Subject: Re: [PATCH v3 5/5] Documentation: coresight: docs for config load via configfs
Date: Thu, 26 May 2022 11:48:30 -0600 [thread overview]
Message-ID: <20220526174830.GB309576@p14s> (raw)
In-Reply-To: <20220414064457.12052-6-mike.leach@linaro.org>
On Thu, Apr 14, 2022 at 07:44:57AM +0100, Mike Leach wrote:
> Add documentation covering the configfs updates that allow
> binary configuration files to be loaded and unloaded via configfs,
> along with the demonstration programs in samples.
>
> Signed-off-by: Mike Leach <mike.leach@linaro.org>
> ---
> .../trace/coresight/coresight-config.rst | 166 +++++++++++++++++-
> 1 file changed, 160 insertions(+), 6 deletions(-)
>
> diff --git a/Documentation/trace/coresight/coresight-config.rst b/Documentation/trace/coresight/coresight-config.rst
> index 6d5ffa6f7347..9354cfcc04e3 100644
> --- a/Documentation/trace/coresight/coresight-config.rst
> +++ b/Documentation/trace/coresight/coresight-config.rst
> @@ -152,7 +152,7 @@ follows::
>
> $ cd configurations/
> $ ls
> - autofdo
> + autofdo last_load_status load unload
"last_load_status" has been removed.
> $ cd autofdo/
> $ ls
> description feature_refs preset1 preset3 preset5 preset7 preset9
> @@ -278,9 +278,16 @@ Creating and Loading Custom Configurations
> ==========================================
>
> Custom configurations and / or features can be dynamically loaded into the
> -system by using a loadable module.
> +system by using a loadable module, or by loading a binary configuration
> +file in configfs.
> +
> +Loaded configurations can use previously loaded features. The system will
> +ensure that it is not possible to unload a feature that is currently in
> +use, by enforcing the unload order as the strict reverse of the load order.
> +
>
> -An example of a custom configuration is found in ./samples/coresight.
> +Using a Loadable Module
> +-----------------------
>
> This creates a new configuration that uses the existing built in
> strobing feature, but provides a different set of presets.
> @@ -289,6 +296,153 @@ When the module is loaded, then the configuration appears in the configfs
> file system and is selectable in the same way as the built in configuration
> described above.
>
> -Configurations can use previously loaded features. The system will ensure
> -that it is not possible to unload a feature that is currently in use, by
> -enforcing the unload order as the strict reverse of the load order.
> +The file 'coresight-cfg-sample.c' contains the configuration and module
> +initialisation code needed to create the loadable module.
> +
> +This will be built alongside the kernel modules if select in KConfig.
> +
> +An example of a custom configuration module is found in './samples/coresight'.
> +
> +Using a Binary Configuration File
> +---------------------------------
> +
> +The './tools/coresight' directory contains example programs to generate and
> +read and print binary configuration files.
> +
> +Building the tools creates the 'coresight-cfg-file-gen' program that will
> +generate a configuration binary 'example1.cscfg' that can be loaded into the
> +system using configfs. The configuration declared in the source file
> +'coresight-cfg-example1.c' is named 'autofdo3' - the name that will be used
> +once loaded.
> +
> +The source files 'coresight-cfg-bufw.h' and 'coresight-cfg-bufw.c' provide a
> +standard function to convert a configuration declared in 'C' into the correct
> +binary buffer format. These files can be re-used to create new custom
> +configurations. Alternatively, addition examples can be added to the
> +'coresight-cfg-file-gen' program::
> +
> + $ ./coresight-cfg-file-gen
> + Coresight Configuration file Generator
> + Generating example1 example
> +
> +The program 'coresight-cfg-file-read' can read back and print a configuration
> +binary. This is built using the file reader from the driver code
> +(coresight-config-file.c), which is copied over into './tools/coresight' at
> +build time.::
> +
> + ./coresight-cfg-file-read example1.cscfg
> + CoreSight Configuration file reader
> +
> + Configuration name : autofdo3
> + Uses 1 features:-
> + Feature-1: strobing
> +
> + Provides 4 sets of preset values, 2 presets per set
> + set[0]: 0x7d0, 0x64,
> + set[1]: 0x7d0, 0x3e8,
> + set[2]: 0x7d0, 0x1388,
> + set[3]: 0x7d0, 0x2710,
> +
> + File contains no features
> +
> +There are additional attributes in the configurations directory - load and
> +unload that can be used to load and unload configuration binary files. To
> +load, 'cat' the binary config into the load attribute::
> +
> + $ ls /config/cs-syscfg/configurations/
> + autofdo load unload
> + $ cat example1.cscfg > /config/cs-syscfg/configurations/load
> + $ ls /config/cs-syscfg/configurations/
> + autofdo autofdo3 last_load_status load unload
Same
More comments tomorrow.
Thanks,
Mathieu
> +
> +To unload, use the same file in the unload attribute::
> +
> + $ cat example1.cscfg > /config/cs-syscfg/configurations/unload
> + ls /config/cs-syscfg/configurations/
> + autofdo load unload
> +
> +
> +
> +Binary Configuration File Format
> +--------------------------------
> +
> +The file format is defined in the source file **coresight-config-file.h**
> +
> +The source reader and generator examples produce a binary of this format.
> +
> +This arrangement is reproduced below:-
> +
> +Overall File structure
> +~~~~~~~~~~~~~~~~~~~~~~
> +
> +::
> +
> + [cscfg_file_header] // Mandatory
> + [CONFIG_ELEM] // Optional - one per file, if present, first element in file.
> + [FEATURE_ELEM]* // Optional - multiple, defined by cscfg_file_header.nr_features
> +
> +File is invalid if both [CONFIG_ELEM] and [FEATURE_ELEM] are omitted.
> +
> +A file that contains only [FEATURE_ELEM] may be loaded, and the features used
> +by subsequently loaded files with [CONFIG_ELEM] elements.
> +
> +Where [CONFIG_ELEM] is present, then **cscfg_file_header.nr_features** and
> +**CONFIG_ELEM.nr_feat_refs** must have the same value.
> +
> +CONFIG_ELEM element
> +~~~~~~~~~~~~~~~~~~~
> +
> +::
> +
> + [cscfg_file_elem_header] // header length value to end of feature strings.
> + [cscfg_file_elem_str] // name of the configuration.
> + [cscfg_file_elem_str] // description of configuration.
> + [u16 value](nr_presets) // number of defined presets.
> + [u32 value](nr_total_params) // total parameters defined by all used features.
> + [u16 value](nr_feat_refs) // number of features referenced by the configuration
> + [u64 values] * (nr_presets * nr_total_params) // the preset values.
> + [cscfg_file_elem_str] * (nr_feat_refs) // the features used in the configurations.
> +
> +FEATURE_ELEM element
> +~~~~~~~~~~~~~~~~~~~~
> +
> +::
> +
> + [cscfg_file_elem_header] // header length is total bytes to end of param structures.
> + [cscfg_file_elem_str] // feature name.
> + [cscfg_file_elem_str] // feature description.
> + [u32 value](match_flags) // flags to associate the feature with a device.
> + [u16 value](nr_regs) // number of registers.
> + [u16 value](nr_params) // number of parameters.
> + [cscfg_regval_desc struct] * (nr_regs) // register definitions
> + [PARAM_ELEM] * (nr_params) // parameters definitions
> +
> +PARAM_ELEM element
> +~~~~~~~~~~~~~~~~~~
> +
> +::
> +
> + [cscfg_file_elem_str] // parameter name.
> + [u64 value](param_value] // initial value.
> +
> +Additional definitions.
> +~~~~~~~~~~~~~~~~~~~~~~~
> +
> +The following structures are defined in **coresight-config-file.h**
> +
> + * **struct cscfg_file_header** : This structure contains an initial magic number, the total
> + length of the file, and the number of features in the file.
> + * **struct cscfg_file_elem_header**: This defines the total length and type of a CONFIG_ELEM
> + or a FEATURE_ELEM.
> + * **struct cscfg_file_elem_str**: This defines a string and its length.
> +
> +The magic number in cscfg_file_header is defined as two bitfields::
> +
> + [31:8] Fixed magic number to identify file type.
> + [7:0] Current file format version.
> +
> +The following defines determine the maximum overall file size and maximum individual
> +string size::
> +
> + CSCFG_FILE_MAXSIZE // maximum overall file size.
> + CSCFG_FILE_STR_MAXSIZE // maximum individual string size.
> --
> 2.17.1
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-05-26 17:49 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-14 6:44 [PATCH v3 0/5] coresight: syscfg: Extend configfs for config load Mike Leach
2022-04-14 6:44 ` [PATCH v3 1/5] coresight: configfs: Add in functionality for load via configfs Mike Leach
2022-05-11 17:58 ` Mathieu Poirier
2022-05-16 12:43 ` Mike Leach
2022-05-12 17:54 ` Mathieu Poirier
2022-05-25 17:38 ` Mathieu Poirier
2022-06-01 8:32 ` Mike Leach
2022-04-14 6:44 ` [PATCH v3 2/5] coresight: configfs: Add in binary attributes to load files Mike Leach
2022-05-25 18:00 ` Mathieu Poirier
2022-05-25 19:30 ` Mathieu Poirier
2022-06-01 8:33 ` Mike Leach
2022-04-14 6:44 ` [PATCH v3 3/5] coresight: configfs: Modify config files to allow userspace use Mike Leach
2022-05-25 19:57 ` Mathieu Poirier
2022-04-14 6:44 ` [PATCH v3 4/5] coresight: tools: Add config file write and reader tools Mike Leach
2022-05-26 17:46 ` Mathieu Poirier
2022-05-27 16:25 ` Mathieu Poirier
2022-06-01 10:56 ` Mike Leach
2022-06-01 16:10 ` Mathieu Poirier
2022-04-14 6:44 ` [PATCH v3 5/5] Documentation: coresight: docs for config load via configfs Mike Leach
2022-05-26 17:48 ` Mathieu Poirier [this message]
2022-05-10 15:39 ` [PATCH v3 0/5] coresight: syscfg: Extend configfs for config load Mathieu Poirier
2022-05-27 16:32 ` Mathieu Poirier
2022-06-01 8:30 ` Mike Leach
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220526174830.GB309576@p14s \
--to=mathieu.poirier@linaro.org \
--cc=coresight@lists.linaro.org \
--cc=leo.yan@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mike.leach@linaro.org \
--cc=suzuki.poulose@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox