Commit fdcee305 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

Merge tag 'coresight-next-v5.17' of...


Merge tag 'coresight-next-v5.17' of gitolite.kernel.org:pub/scm/linux/kernel/git/coresight/linux into char-misc-next

Mathieu writes:

Coresight changes for v5.17

This pull request includes:

- A patch that uses devm_bitmap_zalloc() instead of the open-coded
equivalent.

- Work to make coresight complex configuration loadable via modules.

- Some coresight documentation updates.

Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>

* tag 'coresight-next-v5.17' of gitolite.kernel.org:pub/scm/linux/kernel/git/coresight/linux:
  coresight: core: Fix typo in a comment
  Documentation: coresight: Update coresight configuration docs
  coresight: configfs: Allow configfs to activate configuration
  coresight: syscfg: Example CoreSight configuration loadable module
  coresight: syscfg: Update load API for config loadable modules
  coresight: configuration: Update API to permit dynamic load/unload
  coresight: configuration: Update API to introduce load owner concept
  Documentation: coresight: Fix documentation issue
  coresight: Use devm_bitmap_zalloc when applicable
parents a4c1aaf9 efa56edd
Loading
Loading
Loading
Loading
+64 −14
Original line number Diff line number Diff line
@@ -155,14 +155,14 @@ follows::
    autofdo
    $ cd autofdo/
    $ ls
    description   preset1  preset3  preset5  preset7  preset9
    feature_refs  preset2  preset4  preset6  preset8
    description  feature_refs  preset1  preset3  preset5  preset7  preset9
    enable       preset        preset2  preset4  preset6  preset8
    $ cat description
    Setup ETMs with strobing for autofdo
    $ cat feature_refs
    strobing

Each preset declared has a preset<n> subdirectory declared. The values for
Each preset declared has a 'preset<n>' subdirectory declared. The values for
the preset can be examined::

    $ cat preset1/values
@@ -170,6 +170,9 @@ the preset can be examined::
    $ cat preset2/values
    strobing.window = 0x1388 strobing.period = 0x4

The 'enable' and 'preset' files allow the control of a configuration when
using CoreSight with sysfs.

The features referenced by the configuration can be examined in the features
directory::

@@ -211,19 +214,13 @@ 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.::
    cpu0  cpu2  events  nr_addr_filters		power  subsystem  uevent
    cpu1  cpu3  format  perf_event_mux_interval_ms	sinks  type

    $ ls configurations/
    autofdo
    $ cat configurations/autofdo
    0xa7c3dddd
The key directory here is 'events' - a generic perf directory which allows
selection on the perf command line. As with the sinks entries, this provides
a hash of the configuration name.

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::

@@ -242,3 +239,56 @@ A preset to override the current parameter values can also be selected::

When configurations are selected in this way, then the trace sink used is
automatically selected.

Using Configurations in sysfs
=============================

Coresight can be controlled using sysfs. When this is in use then a configuration
can be made active for the devices that are used in the sysfs session.

In a configuration there are 'enable' and 'preset' files.

To enable a configuration for use with sysfs::

    $ cd configurations/autofdo
    $ echo 1 > enable

This will then use any default parameter values in the features - which can be
adjusted as described above.

To use a preset<n> set of parameter values::

    $ echo 3 > preset

This will select preset3 for the configuration.
The valid values for preset are 0 - to deselect presets, and any value of
<n> where a preset<n> sub-directory is present.

Note that the active sysfs configuration is a global parameter, therefore
only a single configuration can be active for sysfs at any one time.
Attempting to enable a second configuration will result in an error.
Additionally, attempting to disable the configuration while in use will
also result in an error.

The use of the active configuration by sysfs is independent of the configuration
used in perf.


Creating and Loading Custom Configurations
==========================================

Custom configurations and / or features can be dynamically loaded into the
system by using a loadable module.

An example of a custom configuration is found in ./samples/coresight.

This creates a new configuration that uses the existing built in
strobing feature, but provides a different set of presets.

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.
+1 −0
Original line number Diff line number Diff line
@@ -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
+7 −2
Original line number Diff line number Diff line
@@ -24,8 +24,13 @@ static struct cscfg_config_desc *preload_cfgs[] = {
	NULL
};

static struct cscfg_load_owner_info preload_owner = {
	.type = CSCFG_OWNER_PRELOAD,
};

/* preload called on initialisation */
int cscfg_preload(void)
int cscfg_preload(void *owner_handle)
{
	return cscfg_load_config_sets(preload_cfgs, preload_feats);
	preload_owner.owner_handle = owner_handle;
	return cscfg_load_config_sets(preload_cfgs, preload_feats, &preload_owner);
}
+8 −1
Original line number Diff line number Diff line
@@ -97,6 +97,8 @@ struct cscfg_regval_desc {
 * @params_desc: array of parameters used.
 * @nr_regs:	 number of registers used.
 * @regs_desc:	 array of registers used.
 * @load_owner:	 handle to load owner for dynamic load and unload of features.
 * @fs_group:	 reference to configfs group for dynamic unload.
 */
struct cscfg_feature_desc {
	const char *name;
@@ -107,6 +109,8 @@ struct cscfg_feature_desc {
	struct cscfg_parameter_desc *params_desc;
	int nr_regs;
	struct cscfg_regval_desc *regs_desc;
	void *load_owner;
	struct config_group *fs_group;
};

/**
@@ -128,7 +132,8 @@ struct cscfg_feature_desc {
 * @presets:		Array of preset values.
 * @event_ea:		Extended attribute for perf event value
 * @active_cnt:		ref count for activate on this configuration.
 *
 * @load_owner:		handle to load owner for dynamic load and unload of configs.
 * @fs_group:		reference to configfs group for dynamic unload.
 */
struct cscfg_config_desc {
	const char *name;
@@ -141,6 +146,8 @@ struct cscfg_config_desc {
	const u64 *presets; /* nr_presets * nr_total_params */
	struct dev_ext_attribute *event_ea;
	atomic_t active_cnt;
	void *load_owner;
	struct config_group *fs_group;
};

/**
+1 −1
Original line number Diff line number Diff line
@@ -729,7 +729,7 @@ static inline void coresight_put_ref(struct coresight_device *csdev)
 * coresight_grab_device - Power up this device and any of the helper
 * devices connected to it for trace operation. Since the helper devices
 * don't appear on the trace path, they should be handled along with the
 * the master device.
 * master device.
 */
static int coresight_grab_device(struct coresight_device *csdev)
{
Loading