Greetings,
I have attached a small POC(patch file) i wrote for the kernel ETM API. Basically, i created a new mode called "CS_MODE_API",
and made a new module called "coresight-etm-api.c" that exposes these APIs:
- coresight_etm_create_session(cpu):
Create a coresight ETM session. In implementation terms, this simply means creating a path from an ETM source to a sink,
and enable the whole patch except the source.
- coresight_etm_destroy_session(cpu):
Destroy a coresight ETM session. In implementation terms, this simply means disabling a coresight path(except the source), and
freeing it.
- coresight_etm_play(session, config):
Start playing trace data. In implementation terms, this simply means enabling a source.
- coresight_etm_pause(session)
Stop playing trace data. In implementation terms, this simply means disabling a source.
- coresight_etm_alloc_buffer(size)
Allocate a trace buffer data. Only supported in TMC-ETR.
- coresight_etm_read(session)
Read trace data from the session's sink.
To make this change as small as possible(hopefully), the etm-api implementation takes an activated sink(that
is activated via sysfs) as the sink for the path. I didn't want to add a method of activating a sink from the API, just yet.
I don't deal with the "different TMC configuration" issues. If 2 kernel clients request the TMC for different configurations, i wouldn't know
about it just as the sysfs/perf modes don't know about it.
To allow kernel-clients to read trace data "on-the-fly", and to avoid the "prepare()->read()->unprepare()" way, i have implemented a double-buffer
in the CS_MODE_API. A read buffer and a write buffer. Whenever the read buffer is empty, a buffer swap occurs.
I'd appreciate an input, review, tips, hints, improvements. Please tell me if something is lacking in my explanation.
This is highly experimental(it does work though). Notice this patch file can be applied on the latest coresight "next" branch TIP
(as of the writing of this message).
Thanks, Mike.