Introduce Intel Trace Hub support
Subsystems (7)
Alexander Shishkin
maintainerv4 cover Introduce Intel Trace Hub support
Hi Greg and everybody,
Here's a patchset adding support for Intel Trace Hub (TH) [1] to the kernel. Full description follows the changelog. I took some time discussing matters with Mathieu wrt our common needs from the STM driver framework and also to fix things that I found in the process, so the changelog is a bit hefty. A lot of Intel Trace Hub driver fixes were contributed by Laurent Fert.
Changes since v3:
* Added Mathieu's reviewed-bys.
Changes since v2:
* STM framework changes:
- Addressed Greg KH's comments (struct device usage, attributes, etc etc),
- Started using STM device name in the policy name to make interface more logical,
- Tried to improve initcall ordering to accomodate coresight modules (we might need more work on that when the time comes),
- Fixed output assignment on unlinking,
- Refcounting and locking fixes in stm vs stm_source code,
- Added missing cleanup_srcu_struct() in exit call,
- Changed stm_data::ioctl() to a more specific set_options() callback, which is what the underlying driver actually wants,
- Allocated our ioctl commands "by the book" throught ioctl-number.txt,
- Made stm_data::link() callback return an error code in case the driver doesn't like something; handle this condition accordingly;
* STM console module got renamed to "stm_console";
* Intel TH: fixed resource printing;
* Intel TH/GTH:
- Added an output attribute to control maintenance packet
frequency: smcfreq,
- Undo master assignment on master disabling (Laurent),
- Disable global destination overriding (Laurent),
- Clear force capture done bit on trace disabling (Laurent),
- Fixed handling of masters above 256;
* Intel TH/MSU:
- Reworked block iteration in multiblock mode (Laurent),
- Use pgprot_noncached() for user mappings,
- Fixed window's page offset based on previous window's offset and size (Laurent),
- Fixed user_count when no buffer is allocated (Laurent),
- Reset hw headers in multiblock mode (Laurent);
* Intel TH/STH:
- Handle failure to register stm device.
Changes since v1:
* fixed Kconfig whitespaces and removed defaults per comments from Paul Bolle,
* addressed comments from Joe Perches.
Changes since v0:
* filter-branch'ed everything under drivers/hwtracing where Mathieu is also moving coresight drivers,
* added some more comments to the stm class code to address Mathieu's questions,
* fixed CONFIG_STM=m case, which failed to build in the previous version as pointed out by Paul Bolle,
* fixed a rather embarrassing memory leak in the error path of stm_char_policy_set_ioctl(),
* added ioctl() callback to struct stm_data so that downstream stm drivers can serve their own commands on top of the same file descriptor, as suggested by Mathieu.
Intel Trace Hub (TH) is a set of hardware blocks that produce, switch and output trace data from multiple hardware and software sources over several types of trace output ports encoded in System Trace Protocol (MIPI STPv2) and is intended to perform full system debugging.
The first part of this patchset introduces an abstraction for STM devices, or the devices that combine trace data from multiple trace sources into a STP trace stream. It provides a generic interface for software writers to send their trace data and also solves the problem of mapping STP master/channel asignments to trace sources between the system under tracing and the STP decoder on the debug host end. This part is also useful for the Coresight STM driver as it uses a similar interface and has the same channel mapping problem.
The remainder of the patchset is Intel TH support. The core part is platform independant and is called into by glue layers such as the pci driver that follows. The core provides a bus, on which Intel TH subdevices are allocated. Each subdevice has its own driver. Subdevices are divided into 3 types: sources, outputs and a switch (there's usually just one). The latter is the central component in this scheme of things and is required for other drivers to load and function. Other drivers, however, are optional. Sources are producers of trace data. Outputs are means of exporting the resulting STP trace to the debug host via trace ports or system memory.
All configuration is done via sysfs and doesn't require any specific userspace beyond a shell.
Currently supported Intel TH subdevices are Software Trace Hub (STH, source), Memory Storage Unit (MSU, output), Parallel Tracing Interface unit (PTI, output), Global Trace Hub (GTH, switch). Support for other subdevices can be added later.
Also this patchset adds MAINTAINERS entries for stm class and Intel TH code.
[1] https://software.intel.com/sites/default/files/managed/d3/3c/intel-th-developer-manual.pdf
Alexander Shishkin (11):
stm class: Introduce an abstraction for System Trace Module devices
MAINTAINERS: add an entry for System Trace Module device class stm class: dummy_stm: Add dummy driver for testing stm class stm class: stm_console: Add kernel-console-over-stm driver
intel_th: Add driver infrastructure for Intel(R) Trace Hub devices
intel_th: Add pci glue layer for Intel(R) Trace Hub
intel_th: Add Global Trace Hub driver
intel_th: Add Software Trace Hub driver
intel_th: Add Memory Storage Unit driver
intel_th: Add PTI output driver
MAINTAINERS: add an entry for Intel(R) Trace Hub
Documentation/ABI/testing/configfs-stp-policy | 48 + .../ABI/testing/sysfs-bus-intel_th-devices-gth | 49 + .../ABI/testing/sysfs-bus-intel_th-devices-msc | 33 + .../ABI/testing/sysfs-bus-intel_th-devices-pti | 24 + .../ABI/testing/sysfs-bus-intel_th-output-devices | 13 + Documentation/ABI/testing/sysfs-class-stm | 14 + Documentation/ABI/testing/sysfs-class-stm_source | 11 + Documentation/ioctl/ioctl-number.txt | 3 + Documentation/trace/intel_th.txt | 99 ++ Documentation/trace/stm.txt | 80 ++ MAINTAINERS | 14 + drivers/Kconfig | 4 + drivers/Makefile | 2 + drivers/hwtracing/intel_th/Kconfig | 72 + drivers/hwtracing/intel_th/Makefile | 18 + drivers/hwtracing/intel_th/core.c | 692 +++++++++ drivers/hwtracing/intel_th/debug.c | 36 + drivers/hwtracing/intel_th/debug.h | 34 + drivers/hwtracing/intel_th/gth.c | 706 +++++++++ drivers/hwtracing/intel_th/gth.h | 66 + drivers/hwtracing/intel_th/intel_th.h | 244 ++++ drivers/hwtracing/intel_th/msu.c | 1509 ++++++++++++++++++++ drivers/hwtracing/intel_th/msu.h | 116 ++ drivers/hwtracing/intel_th/pci.c | 86 ++ drivers/hwtracing/intel_th/pti.c | 252 ++++ drivers/hwtracing/intel_th/pti.h | 29 + drivers/hwtracing/intel_th/sth.c | 259 ++++ drivers/hwtracing/intel_th/sth.h | 42 + drivers/hwtracing/stm/Kconfig | 25 + drivers/hwtracing/stm/Makefile | 9 + drivers/hwtracing/stm/console.c | 80 ++ drivers/hwtracing/stm/core.c | 1029 +++++++++++++ drivers/hwtracing/stm/dummy_stm.c | 66 + drivers/hwtracing/stm/policy.c | 529 +++++++ drivers/hwtracing/stm/stm.h | 87 ++ include/linux/stm.h | 126 ++ include/uapi/linux/stm.h | 50 + 37 files changed, 6556 insertions(+) create mode 100644 Documentation/ABI/testing/configfs-stp-policy create mode 100644 Documentation/ABI/testing/sysfs-bus-intel_th-devices-gth create mode 100644 Documentation/ABI/testing/sysfs-bus-intel_th-devices-msc create mode 100644 Documentation/ABI/testing/sysfs-bus-intel_th-devices-pti create mode 100644 Documentation/ABI/testing/sysfs-bus-intel_th-output-devices create mode 100644 Documentation/ABI/testing/sysfs-class-stm create mode 100644 Documentation/ABI/testing/sysfs-class-stm_source create mode 100644 Documentation/trace/intel_th.txt create mode 100644 Documentation/trace/stm.txt create mode 100644 drivers/hwtracing/intel_th/Kconfig create mode 100644 drivers/hwtracing/intel_th/Makefile create mode 100644 drivers/hwtracing/intel_th/core.c create mode 100644 drivers/hwtracing/intel_th/debug.c create mode 100644 drivers/hwtracing/intel_th/debug.h create mode 100644 drivers/hwtracing/intel_th/gth.c create mode 100644 drivers/hwtracing/intel_th/gth.h create mode 100644 drivers/hwtracing/intel_th/intel_th.h create mode 100644 drivers/hwtracing/intel_th/msu.c create mode 100644 drivers/hwtracing/intel_th/msu.h create mode 100644 drivers/hwtracing/intel_th/pci.c create mode 100644 drivers/hwtracing/intel_th/pti.c create mode 100644 drivers/hwtracing/intel_th/pti.h create mode 100644 drivers/hwtracing/intel_th/sth.c create mode 100644 drivers/hwtracing/intel_th/sth.h create mode 100644 drivers/hwtracing/stm/Kconfig create mode 100644 drivers/hwtracing/stm/Makefile create mode 100644 drivers/hwtracing/stm/console.c create mode 100644 drivers/hwtracing/stm/core.c create mode 100644 drivers/hwtracing/stm/dummy_stm.c create mode 100644 drivers/hwtracing/stm/policy.c create mode 100644 drivers/hwtracing/stm/stm.h create mode 100644 include/linux/stm.h create mode 100644 include/uapi/linux/stm.h
Signature · 1 line
2.5.1
Alexander Shishkin
maintainerPATCH v4 1/11 stm class: Introduce an abstraction for System Trace Module devices
A System Trace Module (STM) is a device exporting data in System Trace Protocol (STP) format as defined by MIPI STP standards. Examples of such devices are Intel(R) Trace Hub and Coresight STM.
This abstraction provides a unified interface for software trace sources to send their data over an STM device to a debug host. In order to do that, such a trace source needs to be assigned a pair of master/channel identifiers that all the data from this source will be tagged with. The STP decoder on the debug host side will use these master/channel tags to distinguish different trace streams from one another inside one STP stream.
This abstraction provides a configfs-based policy management mechanism for dynamic allocation of these master/channel pairs based on trace source-supplied string identifier. It has the flexibility of being defined at runtime and at the same time (provided that the policy definition is aligned with the decoding end) consistency.
For userspace trace sources, this abstraction provides write()-based and mmap()-based (if the underlying stm device allows this) output mechanism.
For kernel-side trace sources, we provide "stm_source" device class that can be connected to an stm device at run time.
--- Documentation/ABI/testing/configfs-stp-policy | 48 + Documentation/ABI/testing/sysfs-class-stm | 14 + Documentation/ABI/testing/sysfs-class-stm_source | 11 + Documentation/ioctl/ioctl-number.txt | 3 + Documentation/trace/stm.txt | 80 ++ drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/hwtracing/stm/Kconfig | 8 + drivers/hwtracing/stm/Makefile | 3 + drivers/hwtracing/stm/core.c | 1029 ++++++++++++++++++++++ drivers/hwtracing/stm/policy.c | 529 +++++++++++ drivers/hwtracing/stm/stm.h | 87 ++ include/linux/stm.h | 126 +++ include/uapi/linux/stm.h | 50 ++ 14 files changed, 1991 insertions(+) create mode 100644 Documentation/ABI/testing/configfs-stp-policy create mode 100644 Documentation/ABI/testing/sysfs-class-stm create mode 100644 Documentation/ABI/testing/sysfs-class-stm_source create mode 100644 Documentation/trace/stm.txt create mode 100644 drivers/hwtracing/stm/Kconfig create mode 100644 drivers/hwtracing/stm/Makefile create mode 100644 drivers/hwtracing/stm/core.c create mode 100644 drivers/hwtracing/stm/policy.c create mode 100644 drivers/hwtracing/stm/stm.h create mode 100644 include/linux/stm.h create mode 100644 include/uapi/linux/stm.h
Documentation/ABI/testing/configfs-stp-policy new file +48 -0
@@ -0,0 +1,48 @@ +What: /config/stp-policy +Date: June 2015 +KernelVersion: 4.3 +Description: + This group contains policies mandating Master/Channel allocation + for software sources wishing to send trace data over an STM + device. + +What: /config/stp-policy/<device>.<policy> +Date: June 2015 +KernelVersion: 4.3 +Description: + This group is the root of a policy; its name is a concatenation + of an stm device name to which this policy applies and an + arbitrary string. If <device> part doesn't match an existing + stm device, mkdir will fail with ENODEV; if that device already + has a policy assigned to it, mkdir will fail with EBUSY. + +What: /config/stp-policy/<device>.<policy>/device +Date: June 2015 +KernelVersion: 4.3 +Description: + STM device to which this policy applies, read only. Same as the + <device> component of its parent directory. + +What: /config/stp-policy/<device>.<policy>/<node> +Date: June 2015 +KernelVersion: 4.3 +Description: + Policy node is a string identifier that software clients will + use to request a master/channel to be allocated and assigned to + them. + +What: /config/stp-policy/<device>.<policy>/<node>/masters +Date: June 2015 +KernelVersion: 4.3 +Description: + Range of masters from which to allocate for users of this node. + Write two numbers: the first master and the last master number. + +What: /config/stp-policy/<device>.<policy>/<node>/channels +Date: June 2015 +KernelVersion: 4.3 +Description: + Range of channels from which to allocate for users of this node. + Write two numbers: the first channel and the last channel + number. +
Documentation/ABI/testing/sysfs-class-stm new file +14 -0
@@ -0,0 +1,14 @@ +What: /sys/class/stm/<stm>/masters +Date: June 2015 +KernelVersion: 4.3 +Contact: Alexander Shishkin <alexander.shishkin-VuQAYsv1563Yd54FQh9/[email protected]> +Description: + Shows first and last available to software master numbers on + this STM device. + +What: /sys/class/stm/<stm>/channels +Date: June 2015 +KernelVersion: 4.3 +Contact: Alexander Shishkin <alexander.shishkin-VuQAYsv1563Yd54FQh9/[email protected]> +Description: + Shows the number of channels per master on this STM device.
Documentation/ABI/testing/sysfs-class-stm_source new file +11 -0
@@ -0,0 +1,11 @@ +What: /sys/class/stm_source/<stm_source>/stm_source_link +Date: June 2015 +KernelVersion: 4.3 +Contact: Alexander Shishkin <alexander.shishkin-VuQAYsv1563Yd54FQh9/[email protected]> +Description: + stm_source device linkage to stm device, where its tracing data + is directed. Reads return an existing connection or "<none>" if + this stm_source is not connected to any stm device yet. + Write an existing (registered) stm device's name here to + connect that device. If a device is already connected to this + stm_source, it will first be disconnected.
Documentation/ioctl/ioctl-number.txt +3 -0
@@ -81,6 +81,9 @@ Code Seq#(hex) Include File Comments 0x22 all scsi/sg.h '#' 00-3F IEEE 1394 Subsystem Block for the entire subsystem '$' 00-0F linux/perf_counter.h, linux/perf_event.h +'%' 00-0F include/uapi/linux/stm.h + System Trace Module subsystem + <mailto:alexander.shishkin-VuQAYsv1563Yd54FQh9/[email protected]> '&' 00-07 drivers/firewire/nosy-user.h '1' 00-1F <linux/timepps.h> PPS kit from Ulrich Windl <ftp://ftp.de.kernel.org/pub/linux/daemons/ntp/PPS/>
Documentation/trace/stm.txt new file +80 -0
80 lines not on this page · raw message
drivers/Kconfig +2 -0
@@ -188,4 +188,6 @@ source "drivers/nvdimm/Kconfig" source "drivers/nvmem/Kconfig" +source "drivers/hwtracing/stm/Kconfig" + endmenu
drivers/Makefile +1 -0
@@ -165,5 +165,6 @@ obj-$(CONFIG_PERF_EVENTS) += perf/ obj-$(CONFIG_RAS) += ras/ obj-$(CONFIG_THUNDERBOLT) += thunderbolt/ obj-$(CONFIG_CORESIGHT) += hwtracing/coresight/ +obj-$(CONFIG_STM) += hwtracing/stm/ obj-$(CONFIG_ANDROID) += android/ obj-$(CONFIG_NVMEM) += nvmem/
drivers/hwtracing/stm/Kconfig new file +8 -0
@@ -0,0 +1,8 @@ +config STM + tristate "System Trace Module devices" + help + A System Trace Module (STM) is a device exporting data in System + Trace Protocol (STP) format as defined by MIPI STP standards. + Examples of such devices are Intel(R) Trace Hub and Coresight STM. + + Say Y here to enable System Trace Module device support.
drivers/hwtracing/stm/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +obj-$(CONFIG_STM) += stm_core.o + +stm_core-y := core.o policy.o
drivers/hwtracing/stm/core.c new file +1029 -0
1,029 lines not on this page · raw message
drivers/hwtracing/stm/policy.c new file +529 -0
529 lines not on this page · raw message
drivers/hwtracing/stm/stm.h new file +87 -0
87 lines not on this page · raw message
include/linux/stm.h new file +126 -0
126 lines not on this page · raw message
include/uapi/linux/stm.h new file +50 -0
50 lines not on this page · raw message
Signature · 1 line
2.5.1
Re: [PATCH v4 01/11] stm class: Introduce an abstraction for System Trace Module devices
Quoted 13 lines · Alexander Shishkin
drivers/hwtracing/stm/core.c new file +13
-0+static ssize_t stm_char_write (struct file *file,const char __user *buf, +size_t count,loff_t *ppos) +{ +struct stm_file *stmf = file->private_data; +struct stm_device *stm = stmf->stm; +char *kbuf; +int err; + +/* +* if no m/c have been assigned to this writer up to this +* point, use "default" policy entry +*/ +if (!stmf->output.nr_chans) {
drivers/hwtracing/stm/core.c line 423
Quoted 10 lines
drivers/hwtracing/stm/core.c new file +10
-0+ err =stm_file_assign (stmf,"default" ,1 ); +/* +* EBUSY means that somebody else just assigned this +* output, which is just fine for write() +*/ +if (err && err != -EBUSY ) +return err; + } + + kbuf =kmalloc (count +1 ,GFP_KERNEL );
This bit allows for user-controllable kmalloc() allocation lengths, including a possible overflow.
Thanks,
Sasha
Alexander Shishkin
maintainerPATCH v4 2/11 MAINTAINERS: add an entry for System Trace Module device class
In reply to Alexander ShishkinAdd myself as a maintainer for the stm class framework.
--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
@@ -9105,6 +9105,14 @@ S: Maintained F: include/linux/mmc/dw_mmc.h F: drivers/mmc/host/dw_mmc* +SYSTEM TRACE MODULE CLASS +M: Alexander Shishkin <[email protected]> +S: Maintained +F: Documentation/trace/stm.txt +F: drivers/hwtracing/stm/ +F: include/linux/stm.h +F: include/uapi/linux/stm.h + THUNDERBOLT DRIVER M: Andreas Noever <[email protected]> S: Maintained
Signature · 1 line
2.5.1
Alexander Shishkin
maintainerPATCH v4 3/11 stm class: dummy_stm: Add dummy driver for testing stm class
In reply to Alexander ShishkinThis is a simple module that pretends to be an stm device and discards all the data that comes in. Useful for testing stm class and its users.
--- drivers/hwtracing/stm/Kconfig | 8 +++++ drivers/hwtracing/stm/Makefile | 2 ++ drivers/hwtracing/stm/dummy_stm.c | 66 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 drivers/hwtracing/stm/dummy_stm.c
drivers/hwtracing/stm/Kconfig +8 -0
@@ -6,3 +6,11 @@ config STM Examples of such devices are Intel(R) Trace Hub and Coresight STM. Say Y here to enable System Trace Module device support. + +config STM_DUMMY + tristate "Dummy STM driver" + help + This is a simple dummy device that pretends to be an stm device + and discards your data. Use for stm class testing. + + If you don't know what this is, say N.
drivers/hwtracing/stm/Makefile +2 -0
@@ -1,3 +1,5 @@ obj-$(CONFIG_STM) += stm_core.o stm_core-y := core.o policy.o + +obj-$(CONFIG_STM_DUMMY) += dummy_stm.o
drivers/hwtracing/stm/dummy_stm.c new file +66 -0
66 lines not on this page · raw message
Signature · 1 line
2.5.1
Alexander Shishkin
maintainerPATCH v4 4/11 stm class: stm_console: Add kernel-console-over-stm driver
In reply to Alexander ShishkinThis is a simple stm_source class device driver (kernelspace stm trace source) that registers a console and sends kernel messages over STM devices.
--- drivers/hwtracing/stm/Kconfig | 9 +++++ drivers/hwtracing/stm/Makefile | 4 +++ drivers/hwtracing/stm/console.c | 80 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 drivers/hwtracing/stm/console.c
drivers/hwtracing/stm/Kconfig +9 -0
@@ -14,3 +14,12 @@ config STM_DUMMY and discards your data. Use for stm class testing. If you don't know what this is, say N. + +config STM_SOURCE_CONSOLE + tristate "Kernel console over STM devices" + help + This is a kernel space trace source that sends kernel log + messages to trace hosts over STM devices. + + If you want to send kernel console messages over STM devices, + say Y.
drivers/hwtracing/stm/Makefile +4 -0
@@ -3,3 +3,7 @@ obj-$(CONFIG_STM) += stm_core.o stm_core-y := core.o policy.o obj-$(CONFIG_STM_DUMMY) += dummy_stm.o + +obj-$(CONFIG_STM_SOURCE_CONSOLE) += stm_console.o + +stm_console-y := console.o
drivers/hwtracing/stm/console.c new file +80 -0
80 lines not on this page · raw message
Signature · 1 line
2.5.1
Alexander Shishkin
maintainerPATCH v4 5/11 intel_th: Add driver infrastructure for Intel(R) Trace Hub devices
In reply to Alexander ShishkinIntel(R) Trace Hub (TH) is a set of hardware blocks (subdevices) that produce, switch and output trace data from multiple hardware and software sources over several types of trace output ports encoded in System Trace Protocol (MIPI STPv2) and is intended to perform full system debugging.
For these subdevices, we create a bus, where they can be discovered and configured by userspace software.
This patch creates this bus infrastructure, three types of devices (source, output, switch), resource allocation, some callback mechanisms to facilitate communication between the subdevices' drivers and some common sysfs attributes.
--- .../ABI/testing/sysfs-bus-intel_th-output-devices | 13 + Documentation/trace/intel_th.txt | 99 +++ drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/hwtracing/intel_th/Kconfig | 24 + drivers/hwtracing/intel_th/Makefile | 3 + drivers/hwtracing/intel_th/core.c | 692 +++++++++++++++++++++ drivers/hwtracing/intel_th/debug.c | 36 ++ drivers/hwtracing/intel_th/debug.h | 34 + drivers/hwtracing/intel_th/intel_th.h | 244 ++++++++ 10 files changed, 1148 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-intel_th-output-devices create mode 100644 Documentation/trace/intel_th.txt create mode 100644 drivers/hwtracing/intel_th/Kconfig create mode 100644 drivers/hwtracing/intel_th/Makefile create mode 100644 drivers/hwtracing/intel_th/core.c create mode 100644 drivers/hwtracing/intel_th/debug.c create mode 100644 drivers/hwtracing/intel_th/debug.h create mode 100644 drivers/hwtracing/intel_th/intel_th.h
Documentation/ABI/testing/sysfs-bus-intel_th-output-devices new file +13 -0
@@ -0,0 +1,13 @@ +What: /sys/bus/intel_th/devices/<intel_th_id>-<device><id>/active +Date: June 2015 +KernelVersion: 4.3 +Contact: Alexander Shishkin <[email protected]> +Description: (RW) Writes of 1 or 0 enable or disable trace output to this + output device. Reads return current status. + +What: /sys/bus/intel_th/devices/<intel_th_id>-msc<msc-id>/port +Date: June 2015 +KernelVersion: 4.3 +Contact: Alexander Shishkin <[email protected]> +Description: (RO) Port number, corresponding to this output device on the + switch (GTH).
Documentation/trace/intel_th.txt new file +99 -0
99 lines not on this page · raw message
drivers/Kconfig +2 -0
@@ -190,4 +190,6 @@ source "drivers/nvmem/Kconfig" source "drivers/hwtracing/stm/Kconfig" +source "drivers/hwtracing/intel_th/Kconfig" + endmenu
drivers/Makefile +1 -0
@@ -165,6 +165,7 @@ obj-$(CONFIG_PERF_EVENTS) += perf/ obj-$(CONFIG_RAS) += ras/ obj-$(CONFIG_THUNDERBOLT) += thunderbolt/ obj-$(CONFIG_CORESIGHT) += hwtracing/coresight/ +obj-y += hwtracing/intel_th/ obj-$(CONFIG_STM) += hwtracing/stm/ obj-$(CONFIG_ANDROID) += android/ obj-$(CONFIG_NVMEM) += nvmem/
drivers/hwtracing/intel_th/Kconfig new file +24 -0
@@ -0,0 +1,24 @@ +config INTEL_TH + tristate "Intel(R) Trace Hub controller" + help + Intel(R) Trace Hub (TH) is a set of hardware blocks (subdevices) that + produce, switch and output trace data from multiple hardware and + software sources over several types of trace output ports encoded + in System Trace Protocol (MIPI STPv2) and is intended to perform + full system debugging. + + This option enables intel_th bus and common code used by TH + subdevices to interact with each other and hardware and for + platform glue layers to drive Intel TH devices. + + Say Y here to enable Intel(R) Trace Hub controller support. + +if INTEL_TH + +config INTEL_TH_DEBUG + bool "Intel(R) Trace Hub debugging" + depends on DEBUG_FS + help + Say Y here to enable debugging. + +endif
drivers/hwtracing/intel_th/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +obj-$(CONFIG_INTEL_TH) += intel_th.o +intel_th-y := core.o +intel_th-$(CONFIG_INTEL_TH_DEBUG) += debug.o
drivers/hwtracing/intel_th/core.c new file +692 -0
692 lines not on this page · raw message
drivers/hwtracing/intel_th/debug.c new file +36 -0
@@ -0,0 +1,36 @@ +/* +* Intel(R) Trace Hub driver debugging +* +* Copyright (C) 2014-2015 Intel Corporation. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +*/ + +#include <linux/types.h> +#include <linux/device.h> +#include <linux/debugfs.h> + +#include "intel_th.h" +#include "debug.h" + +struct dentry *intel_th_dbg; + +void intel_th_debug_init (void ) +{ + intel_th_dbg =debugfs_create_dir ("intel_th" ,NULL ); +if (IS_ERR (intel_th_dbg)) + intel_th_dbg =NULL ; +} + +void intel_th_debug_done (void ) +{ +debugfs_remove (intel_th_dbg); + intel_th_dbg =NULL ; +}
drivers/hwtracing/intel_th/debug.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* Intel(R) Trace Hub driver debugging +* +* Copyright (C) 2014-2015 Intel Corporation. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +*/ + +#ifndef __INTEL_TH_DEBUG_H__ +#define __INTEL_TH_DEBUG_H__ + +#ifdef CONFIG_INTEL_TH_DEBUG +extern struct dentry *intel_th_dbg; + +void intel_th_debug_init (void ); +void intel_th_debug_done (void ); +#else +static inline void intel_th_debug_init (void ) +{ +} + +static inline void intel_th_debug_done (void ) +{ +} +#endif + +#endif /* __INTEL_TH_DEBUG_H__ */
drivers/hwtracing/intel_th/intel_th.h new file +244 -0
244 lines not on this page · raw message
Signature · 1 line
2.5.1
Alexander Shishkin
maintainerPATCH v4 6/11 intel_th: Add pci glue layer for Intel(R) Trace Hub
In reply to Alexander ShishkinThis patch adds basic support for PCI-based Intel TH devices. It requests 2 bars (configuration registers for the subdevices and STH channel MMIO region) and calls into Intel TH core code to create the bus with subdevices etc.
--- drivers/hwtracing/intel_th/Kconfig | 9 ++++ drivers/hwtracing/intel_th/Makefile | 3 ++ drivers/hwtracing/intel_th/pci.c | 86 +++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 drivers/hwtracing/intel_th/pci.c
drivers/hwtracing/intel_th/Kconfig +9 -0
@@ -15,6 +15,15 @@ config INTEL_TH if INTEL_TH +config INTEL_TH_PCI + tristate "Intel(R) Trace Hub PCI controller" + depends on PCI + help + Intel(R) Trace Hub may exist as a PCI device. This option enables + support glue layer for PCI-based Intel TH. + + Say Y here to enable PCI Intel TH support. + config INTEL_TH_DEBUG bool "Intel(R) Trace Hub debugging" depends on DEBUG_FS
drivers/hwtracing/intel_th/Makefile +3 -0
@@ -1,3 +1,6 @@ obj-$(CONFIG_INTEL_TH) += intel_th.o intel_th-y := core.o intel_th-$(CONFIG_INTEL_TH_DEBUG) += debug.o + +obj-$(CONFIG_INTEL_TH_PCI) += intel_th_pci.o +intel_th_pci-y := pci.o
drivers/hwtracing/intel_th/pci.c new file +86 -0
86 lines not on this page · raw message
Signature · 1 line
2.5.1
Alexander Shishkin
maintainerPATCH v4 7/11 intel_th: Add Global Trace Hub driver
In reply to Alexander ShishkinGlobal Trace Hub (GTH) is the central component of Intel TH architecture; it carries out switching between the trace sources and trace outputs, can enable/disable tracing, perform STP encoding, internal buffering, control backpressure from outputs to sources and so on.
This property is also reflected in the software model; GTH (switch) driver is required for the other subdevices to probe, because it matches trace output devices against its output ports and configures them accordingly.
It also implements an interface for output ports to request trace enabling or disabling and a few other useful things.
For userspace, it provides an attribute group "masters", which allows configuration of per-master trace output destinations for up to master 255 and "256+" meaning "masters 256 and above". It also provides an attribute group to discover and configure some of the parameters of its output ports, called "outputs". Via these the user can set up data retention policy for an individual output port or check if it is in reset state.
--- .../ABI/testing/sysfs-bus-intel_th-devices-gth | 49 ++ drivers/hwtracing/intel_th/Kconfig | 10 + drivers/hwtracing/intel_th/Makefile | 3 + drivers/hwtracing/intel_th/gth.c | 706 +++++++++++++++++++++ drivers/hwtracing/intel_th/gth.h | 66 ++ 5 files changed, 834 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-intel_th-devices-gth create mode 100644 drivers/hwtracing/intel_th/gth.c create mode 100644 drivers/hwtracing/intel_th/gth.h
Documentation/ABI/testing/sysfs-bus-intel_th-devices-gth new file +49 -0
@@ -0,0 +1,49 @@ +What: /sys/bus/intel_th/devices/<intel_th_id>-gth/masters/* +Date: June 2015 +KernelVersion: 4.3 +Contact: Alexander Shishkin <[email protected]> +Description: (RW) Configure output ports for STP masters. Writing -1 + disables a master; any + +What: /sys/bus/intel_th/devices/<intel_th_id>-gth/outputs/[0-7]_port +Date: June 2015 +KernelVersion: 4.3 +Contact: Alexander Shishkin <[email protected]> +Description: (RO) Output port type: + 0: not present, + 1: MSU (Memory Storage Unit) + 2: CTP (Common Trace Port) + 4: PTI (MIPI PTI). + +What: /sys/bus/intel_th/devices/<intel_th_id>-gth/outputs/[0-7]_drop +Date: June 2015 +KernelVersion: 4.3 +Contact: Alexander Shishkin <[email protected]> +Description: (RW) Data retention policy setting: keep (0) or drop (1) + incoming data while output port is in reset. + +What: /sys/bus/intel_th/devices/<intel_th_id>-gth/outputs/[0-7]_null +Date: June 2015 +KernelVersion: 4.3 +Contact: Alexander Shishkin <[email protected]> +Description: (RW) STP NULL packet generation: enabled (1) or disabled (0). + +What: /sys/bus/intel_th/devices/<intel_th_id>-gth/outputs/[0-7]_flush +Date: June 2015 +KernelVersion: 4.3 +Contact: Alexander Shishkin <[email protected]> +Description: (RW) Force flush data from byte packing buffer for the output + port. + +What: /sys/bus/intel_th/devices/<intel_th_id>-gth/outputs/[0-7]_reset +Date: June 2015 +KernelVersion: 4.3 +Contact: Alexander Shishkin <[email protected]> +Description: (RO) Output port is in reset (1). + +What: /sys/bus/intel_th/devices/<intel_th_id>-gth/outputs/[0-7]_smcfreq +Date: June 2015 +KernelVersion: 4.3 +Contact: Alexander Shishkin <[email protected]> +Description: (RW) STP sync packet frequency for the port. Specifies the + number of clocks between mainenance packets.
drivers/hwtracing/intel_th/Kconfig +10 -0
@@ -24,6 +24,16 @@ config INTEL_TH_PCI Say Y here to enable PCI Intel TH support. +config INTEL_TH_GTH + tristate "Intel(R) Trace Hub Global Trace Hub" + help + Global Trace Hub (GTH) is the central component of the + Intel TH infrastructure and acts as a switch for source + and output devices. This driver is required for other + Intel TH subdevices to initialize. + + Say Y here to enable GTH subdevice of Intel(R) Trace Hub. + config INTEL_TH_DEBUG bool "Intel(R) Trace Hub debugging" depends on DEBUG_FS
drivers/hwtracing/intel_th/Makefile +3 -0
@@ -4,3 +4,6 @@ intel_th-$(CONFIG_INTEL_TH_DEBUG) += debug.o obj-$(CONFIG_INTEL_TH_PCI) += intel_th_pci.o intel_th_pci-y := pci.o + +obj-$(CONFIG_INTEL_TH_GTH) += intel_th_gth.o +intel_th_gth-y := gth.o
drivers/hwtracing/intel_th/gth.c new file +706 -0
706 lines not on this page · raw message
drivers/hwtracing/intel_th/gth.h new file +66 -0
66 lines not on this page · raw message
Signature · 1 line
2.5.1
Alexander Shishkin
maintainerPATCH v4 8/11 intel_th: Add Software Trace Hub driver
In reply to Alexander ShishkinSoftware Trace Hub (STH) is a trace source device in the Intel TH architecture, it generates data that then goes through the switch into one or several output ports.
STH collects data from software sources using the stm device class abstraction.
--- drivers/hwtracing/intel_th/Kconfig | 10 ++ drivers/hwtracing/intel_th/Makefile | 3 + drivers/hwtracing/intel_th/sth.c | 259 ++++++++++++++++++++++++++++++++++++ drivers/hwtracing/intel_th/sth.h | 42 ++++++ 4 files changed, 314 insertions(+) create mode 100644 drivers/hwtracing/intel_th/sth.c create mode 100644 drivers/hwtracing/intel_th/sth.h
drivers/hwtracing/intel_th/Kconfig +10 -0
@@ -34,6 +34,16 @@ config INTEL_TH_GTH Say Y here to enable GTH subdevice of Intel(R) Trace Hub. +config INTEL_TH_STH + tristate "Intel(R) Trace Hub Software Trace Hub support" + depends on STM + help + Software Trace Hub (STH) enables trace data from software + trace sources to be sent out via Intel(R) Trace Hub. It + uses stm class device to interface with its sources. + + Say Y here to enable STH subdevice of Intel(R) Trace Hub. + config INTEL_TH_DEBUG bool "Intel(R) Trace Hub debugging" depends on DEBUG_FS
drivers/hwtracing/intel_th/Makefile +3 -0
@@ -7,3 +7,6 @@ intel_th_pci-y := pci.o obj-$(CONFIG_INTEL_TH_GTH) += intel_th_gth.o intel_th_gth-y := gth.o + +obj-$(CONFIG_INTEL_TH_STH) += intel_th_sth.o +intel_th_sth-y := sth.o
drivers/hwtracing/intel_th/sth.c new file +259 -0
259 lines not on this page · raw message
drivers/hwtracing/intel_th/sth.h new file +42 -0
42 lines not on this page · raw message
Signature · 1 line
2.5.1
Alexander Shishkin
maintainerPATCH v4 9/11 intel_th: Add Memory Storage Unit driver
In reply to Alexander ShishkinMemory Storage Unit (MSU) is a trace output device that collects trace data to system memory. It consists of 2 independent Memory Storage Controllers (MSCs).
This driver provides userspace interfaces to configure in-memory tracing parameters, such as contiguous (high-order allocation) buffer or multiblock (scatter list) buffer mode, wrapping (data overwrite) and number and sizes of windows in multiblock mode. Userspace can read the buffers via mmap()ing or read()ing of the corresponding device node.
--- .../ABI/testing/sysfs-bus-intel_th-devices-msc | 33 + drivers/hwtracing/intel_th/Kconfig | 10 + drivers/hwtracing/intel_th/Makefile | 3 + drivers/hwtracing/intel_th/msu.c | 1509 ++++++++++++++++++++ drivers/hwtracing/intel_th/msu.h | 116 ++ 5 files changed, 1671 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-intel_th-devices-msc create mode 100644 drivers/hwtracing/intel_th/msu.c create mode 100644 drivers/hwtracing/intel_th/msu.h
Documentation/ABI/testing/sysfs-bus-intel_th-devices-msc new file +33 -0
@@ -0,0 +1,33 @@ +What: /sys/bus/intel_th/devices/<intel_th_id>-msc<msc-id>/wrap +Date: June 2015 +KernelVersion: 4.3 +Contact: Alexander Shishkin <[email protected]> +Description: (RW) Configure MSC buffer wrapping. 1 == wrapping enabled. + +What: /sys/bus/intel_th/devices/<intel_th_id>-msc<msc-id>/mode +Date: June 2015 +KernelVersion: 4.3 +Contact: Alexander Shishkin <[email protected]> +Description: (RW) Configure MSC operating mode: + - "single", for contiguous buffer mode (high-order alloc); + - "multi", for multiblock mode; + - "ExI", for DCI handler mode; + - "debug", for debug mode. + If operating mode changes, existing buffer is deallocated, + provided there are no active users and tracing is not enabled, + otherwise the write will fail. + +What: /sys/bus/intel_th/devices/<intel_th_id>-msc<msc-id>/nr_pages +Date: June 2015 +KernelVersion: 4.3 +Contact: Alexander Shishkin <[email protected]> +Description: (RW) Configure MSC buffer size for "single" or "multi" modes. + In single mode, this is a single number of pages, has to be + power of 2. In multiblock mode, this is a comma-separated list + of numbers of pages for each window to be allocated. Number of + windows is not limited. + Writing to this file deallocates existing buffer (provided + there are no active users and tracing is not enabled) and then + allocates a new one. + +
drivers/hwtracing/intel_th/Kconfig +10 -0
@@ -44,6 +44,16 @@ config INTEL_TH_STH Say Y here to enable STH subdevice of Intel(R) Trace Hub. +config INTEL_TH_MSU + tristate "Intel(R) Trace Hub Memory Storage Unit" + help + Memory Storage Unit (MSU) trace output device enables + storing STP traces to system memory. It supports single + and multiblock modes of operation and provides read() + and mmap() access to the collected data. + + Say Y here to enable MSU output device for Intel TH. + config INTEL_TH_DEBUG bool "Intel(R) Trace Hub debugging" depends on DEBUG_FS
drivers/hwtracing/intel_th/Makefile +3 -0
@@ -10,3 +10,6 @@ intel_th_gth-y := gth.o obj-$(CONFIG_INTEL_TH_STH) += intel_th_sth.o intel_th_sth-y := sth.o + +obj-$(CONFIG_INTEL_TH_MSU) += intel_th_msu.o +intel_th_msu-y := msu.o
drivers/hwtracing/intel_th/msu.c new file +1509 -0
1,509 lines not on this page · raw message
drivers/hwtracing/intel_th/msu.h new file +116 -0
116 lines not on this page · raw message
Signature · 1 line
2.5.1
Alexander Shishkin
maintainerPATCH v4 10/11 intel_th: Add PTI output driver
In reply to Alexander ShishkinParallel Trace Interface (PTI) unit is a trace output device that sends data over a PTI port.
The driver provides interfaces to configure bus width, bus clock divider and mode. Tracing is enabled via output device's "active" attribute.
--- .../ABI/testing/sysfs-bus-intel_th-devices-pti | 24 ++ drivers/hwtracing/intel_th/Kconfig | 9 + drivers/hwtracing/intel_th/Makefile | 3 + drivers/hwtracing/intel_th/pti.c | 252 +++++++++++++++++++++ drivers/hwtracing/intel_th/pti.h | 29 +++ 5 files changed, 317 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-intel_th-devices-pti create mode 100644 drivers/hwtracing/intel_th/pti.c create mode 100644 drivers/hwtracing/intel_th/pti.h
Documentation/ABI/testing/sysfs-bus-intel_th-devices-pti new file +24 -0
@@ -0,0 +1,24 @@ +What: /sys/bus/intel_th/devices/<intel_th_id>-pti/mode +Date: June 2015 +KernelVersion: 4.3 +Contact: Alexander Shishkin <[email protected]> +Description: (RW) Configure PTI output width. Currently supported values + are 4, 8, 12, 16. + +What: /sys/bus/intel_th/devices/<intel_th_id>-pti/freerunning_clock +Date: June 2015 +KernelVersion: 4.3 +Contact: Alexander Shishkin <[email protected]> +Description: (RW) 0: PTI trace clock acts as a strobe which only toggles + when there is trace data to send. 1: PTI trace clock is a + free-running clock. + +What: /sys/bus/intel_th/devices/<intel_th_id>-pti/clock_divider +Date: June 2015 +KernelVersion: 4.3 +Contact: Alexander Shishkin <[email protected]> +Description: (RW) Configure PTI port clock divider: + - 0: Intel TH clock rate, + - 1: 1/2 Intel TH clock rate, + - 2: 1/4 Intel TH clock rate, + - 3: 1/8 Intel TH clock rate.
drivers/hwtracing/intel_th/Kconfig +9 -0
@@ -54,6 +54,15 @@ config INTEL_TH_MSU Say Y here to enable MSU output device for Intel TH. +config INTEL_TH_PTI + tristate "Intel(R) Trace Hub PTI output" + help + Parallel Trace Interface unit (PTI) is a trace output device + of Intel TH architecture that facilitates STP trace output via + a PTI port. + + Say Y to enable PTI output of Intel TH data. + config INTEL_TH_DEBUG bool "Intel(R) Trace Hub debugging" depends on DEBUG_FS
drivers/hwtracing/intel_th/Makefile +3 -0
@@ -13,3 +13,6 @@ intel_th_sth-y := sth.o obj-$(CONFIG_INTEL_TH_MSU) += intel_th_msu.o intel_th_msu-y := msu.o + +obj-$(CONFIG_INTEL_TH_PTI) += intel_th_pti.o +intel_th_pti-y := pti.o
drivers/hwtracing/intel_th/pti.c new file +252 -0
252 lines not on this page · raw message
drivers/hwtracing/intel_th/pti.h new file +29 -0
@@ -0,0 +1,29 @@ +/* +* Intel(R) Trace Hub PTI output data structures +* +* Copyright (C) 2014-2015 Intel Corporation. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +*/ + +#ifndef __INTEL_TH_STH_H__ +#define __INTEL_TH_STH_H__ + +enum { +REG_PTI_CTL =0x1c00 , +}; + +#define PTI_EN BIT(0) +#define PTI_FCEN BIT(1) +#define PTI_MODE 0xf0 +#define PTI_CLKDIV 0x000f0000 +#define PTI_PATGENMODE 0x00f00000 + +#endif /* __INTEL_TH_STH_H__ */
Signature · 1 line
2.5.1
Alexander Shishkin
maintainerPATCH v4 11/11 MAINTAINERS: add an entry for Intel(R) Trace Hub
In reply to Alexander ShishkinAdd myself as a maintainer for the Intel(R) Trace Hub framework and drivers.
--- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+)
MAINTAINERS +6 -0
@@ -5510,6 +5510,12 @@ F: Documentation/networking/README.ipw2100 F: Documentation/networking/README.ipw2200 F: drivers/net/wireless/ipw2x00/ +INTEL(R) TRACE HUB +M: Alexander Shishkin <[email protected]> +S: Supported +F: Documentation/trace/intel_th.txt +F: drivers/hwtracing/intel_th/ + INTEL(R) TRUSTED EXECUTION TECHNOLOGY (TXT) M: Richard L Maliszewski <[email protected]> M: Gang Wei <[email protected]>
Signature · 1 line
2.5.1