forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/Documentation/trace/intel_th.rst
....@@ -1,3 +1,5 @@
1
+.. SPDX-License-Identifier: GPL-2.0
2
+
13 =======================
24 Intel(R) Trace Hub (TH)
35 =======================
....@@ -42,7 +44,8 @@
4244
4345 MSU can be configured to collect trace data into a system memory
4446 buffer, which can later on be read from its device nodes via read() or
45
-mmap() interface.
47
+mmap() interface and directed to a "software sink" driver that will
48
+consume the data and/or relay it further.
4649
4750 On the whole, Intel(R) Trace Hub does not require any special
4851 userspace software to function; everything can be configured, started
....@@ -55,7 +58,7 @@
5558
5659 For each Intel TH device in the system a bus of its own is
5760 created and assigned an id number that reflects the order in which TH
58
-devices were emumerated. All TH subdevices (devices on intel_th bus)
61
+devices were enumerated. All TH subdevices (devices on intel_th bus)
5962 begin with this id: 0-gth, 0-msc0, 0-msc1, 0-pti, 0-sth, which is
6063 followed by device's name and an optional index.
6164
....@@ -120,3 +123,28 @@
120123 will show up on the intel_th bus. Also, trace configuration and
121124 capture controlling attribute groups of the 'gth' device will not be
122125 exposed. The 'sth' device will operate as usual.
126
+
127
+Software Sinks
128
+--------------
129
+
130
+The Memory Storage Unit (MSU) driver provides an in-kernel API for
131
+drivers to register themselves as software sinks for the trace data.
132
+Such drivers can further export the data via other devices, such as
133
+USB device controllers or network cards.
134
+
135
+The API has two main parts::
136
+ - notifying the software sink that a particular window is full, and
137
+ "locking" that window, that is, making it unavailable for the trace
138
+ collection; when this happens, the MSU driver will automatically
139
+ switch to the next window in the buffer if it is unlocked, or stop
140
+ the trace capture if it's not;
141
+ - tracking the "locked" state of windows and providing a way for the
142
+ software sink driver to notify the MSU driver when a window is
143
+ unlocked and can be used again to collect trace data.
144
+
145
+An example sink driver, msu-sink illustrates the implementation of a
146
+software sink. Functionally, it simply unlocks windows as soon as they
147
+are full, keeping the MSU running in a circular buffer mode. Unlike the
148
+"multi" mode, it will fill out all the windows in the buffer as opposed
149
+to just the first one. It can be enabled by writing "sink" to the "mode"
150
+file (assuming msu-sink.ko is loaded).