[PATCH v2 00/12] coresight: Separate sysfs and Perf usage and some other cleanups

From: James Clark
Date: Mon Jan 29 2024 - 10:41:17 EST


Changes since V1:

* Clarify further "the selected sink" in _coresight_build_path()
* Move etm4x's mode to coresight device which was missing from V1
* Use explicit initialisers in coresight_dev_type
* Create functions for handling mode changes

I've been finding it quite difficult to reason about some of the state
and functions in coresight-core.c because they have generic names when
they are actually only relevant to the sysfs usage of Coresight rather
than usage through Perf. This is probably because sysfs came first and
Perf was added later. This has caused a couple of issues where these
things have been used in the wrong context, for example the first
commit is a fixup.

To fix this I've mainly just moved all of the sysfs stuff to the sysfs
file and removed the 'enable' state, which was just for sysfs. While
doing the refactor it became obvious that refcnt didn't need to be
atomic either, so that can be simplified along with some other comment
clarifications and simplifications.

Hopefully it's also a step towards to removing all of the duplicate
refcnt and mode tracking code from the individual devices. That tracking
pretty much always results in a one-shot enable/disable and fixes the
mode to either sysfs or Perf, and there is no reason that can't exist in
the core layer outside of the devices. I tried to finish that in this
set, but there turned out to be some complexities, so I cut it short at
a point where I can be sure that there are no behavioral changes.

James Clark (12):
coresight: Fix issue where a source device's helpers aren't disabled
coresight: Make language around "activated" sinks consistent
coresight: Remove ops callback checks
coresight: Move mode to struct coresight_device
coresight: Remove the 'enable' field.
coresight: Move all sysfs code to sysfs file
coresight: Remove atomic type from refcnt
coresight: Remove unused stubs
coresight: Add explicit member initializers to coresight_dev_type
coresight: Add helper for atomically taking the device
coresight: Add a helper for getting csdev->mode
coresight: Add helper for setting csdev->mode

drivers/hwtracing/coresight/coresight-core.c | 494 +-----------------
drivers/hwtracing/coresight/coresight-etb10.c | 29 +-
.../hwtracing/coresight/coresight-etm-perf.c | 2 +-
drivers/hwtracing/coresight/coresight-etm.h | 2 -
.../coresight/coresight-etm3x-core.c | 23 +-
.../coresight/coresight-etm3x-sysfs.c | 4 +-
.../coresight/coresight-etm4x-core.c | 26 +-
drivers/hwtracing/coresight/coresight-etm4x.h | 1 -
drivers/hwtracing/coresight/coresight-priv.h | 9 +-
drivers/hwtracing/coresight/coresight-stm.c | 30 +-
drivers/hwtracing/coresight/coresight-sysfs.c | 391 ++++++++++++++
.../hwtracing/coresight/coresight-tmc-core.c | 2 +-
.../hwtracing/coresight/coresight-tmc-etf.c | 46 +-
.../hwtracing/coresight/coresight-tmc-etr.c | 33 +-
drivers/hwtracing/coresight/coresight-tmc.h | 2 -
drivers/hwtracing/coresight/coresight-tpda.c | 13 +-
drivers/hwtracing/coresight/coresight-tpiu.c | 14 +-
drivers/hwtracing/coresight/ultrasoc-smb.c | 22 +-
drivers/hwtracing/coresight/ultrasoc-smb.h | 2 -
include/linux/coresight.h | 146 ++----
20 files changed, 606 insertions(+), 685 deletions(-)

--
2.34.1