[PATCH v3 4/6] coresight: syscfg: Example CoreSight configuration loadable module

Mike Leach mike.leach at linaro.org
Mon Nov 29 04:24:06 PST 2021


Hi Mathieu,

On Fri, 26 Nov 2021 at 18:23, Mathieu Poirier
<mathieu.poirier at linaro.org> wrote:
>
> On Wed, Nov 24, 2021 at 08:00:36PM +0000, Mike Leach wrote:
> > 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 <mike.leach at linaro.org>
> > Reviewed-by: Mathieu Poirier <mathieu.poirier at linaro.org>
> > ---
> >  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 <mike.leach at linaro.org>
> > + */
> > +
> > +#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",
>
> Checkpatch is complaining the above should be "static const char * const ..."  I
> can't remember if we talked about this before - did we?
>

The first Complex config set had the same warning for the built in
autofdo config - which went upstream without issue.
The code is safe - the strings are only ever read, the array is not
altered  - so perhaps that is why it was permitted - or maybe it was
missed.

> Do you want me to make the modification?
>

When I first so the issue in the original patch series - I made the
suggested change and this had ripple effects of compile time warnings
- throwing away const.
If this is then corrected - the dynamic creation of configuration
descriptors from configfs input files (in the follow up patch set)
throws up errors
The only way round this I could see would be to have two versions of
the configuration descriptor - one that could be statically const
assigned in the code, and one that could be dynamically build from
file information.

Overall I am not convinced that there is a good fix for this
checkpatch warning  - and am not convinced that it is valid for this
usecase.

Regards

Mike

-- 
Mike Leach
Principal Engineer, ARM Ltd.
Manchester Design Centre. UK



More information about the linux-arm-kernel mailing list