mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: mathieu.poirier@linaro.org
To: linus.walleij@linaro.org, will.deacon@arm.com,
	linux@arm.linux.org.uk, 00regkh@linuxfoundation.org
Cc: mathieu.poirier@linaro.org, pratikp@codeaurora.org,
	varshney@ti.com, Al.Grant@arm.com,
	jonas.svennebring@avagotech.com, james.king@linaro.org,
	panchaxari.prasannamurthy@linaro.org, kaixu.xia@linaro.org,
	marcin.jabrzyk@gmail.com, r.sengupta@samsung.com,
	robbelibobban@gmail.com, Tony.Armitstead@arm.com,
	daniel.thompson@linaro.org, patches@linaro.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 08/11 v4] coresight: adding documentation for coresight
Date: Wed, 20 Aug 2014 11:03:48 -0600	[thread overview]
Message-ID: <1408554231-24321-9-git-send-email-mathieu.poirier@linaro.org> (raw)
In-Reply-To: <1408554231-24321-1-git-send-email-mathieu.poirier@linaro.org>

From: Mathieu Poirier <mathieu.poirier@linaro.org>

Documentation for the coresight framework and drivers.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
 Documentation/trace/coresight.txt | 235 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 235 insertions(+)
 create mode 100644 Documentation/trace/coresight.txt

diff --git a/Documentation/trace/coresight.txt b/Documentation/trace/coresight.txt
new file mode 100644
index 0000000..a88e2aa
--- /dev/null
+++ b/Documentation/trace/coresight.txt
@@ -0,0 +1,235 @@
+		Coresight - HW Assisted Tracing on ARM
+		======================================
+
+   Author:   Mathieu Poirier <mathieu.poirier@linaro.org>
+   Date:     August 15th 2014
+
+Introduction
+------------
+
+Coresight is an umbrella of technologies allowing for the debugging of ARM
+based SoC.  It includes solutions for JTAG and HW assisted tracing.  This
+document is concerned with the latter.
+
+HW assisted tracing is becoming increasingly useful when dealing with systems
+that have many SoCs and other components like GPU and DMA engines.  ARM has
+developed an HW assisted tracing solution by means of different components, each
+being added to a design at systhesis time to cater to specific tracing needs.
+Compoments are generally categorised as source, link and sinks and are
+discovered using the AMBA bus.
+
+"Sources" generate a compressed stream representing the processor instruction
+path based on tracing scenarios as configured by users.  From there the stream
+flows through the coresight system (via ATB bus) using links that are connecting
+the emanating source to a sink(s).  Sinks serve as endpoints to the coresight
+implementation, either storing the compressed stream in a memory buffer or
+creating an interface to the outside world where data can be transfered to a
+host without fear of filling up the onboard coresight memory buffer.
+
+
+Acronyms and Classification
+---------------------------
+
+Acronyms:
+
+PTM:     Program Trace Macrocell
+ETM:     Embedded Trace Macrocell
+STM:     System trace Macrocell
+ETB:     Embedded Trace Buffer
+ITM:     Instrumentation Trace Macrocell
+TPIU:    Trace Port Interface Unit
+TMC-ETR: Trace Memory Controller, configured as Embedded Trace Router
+TMC-ETF: Trace Memory Controller, configured as Embedded Trace FIFO
+CTI:     Cross Trigger Interface
+
+Classification:
+
+Source:
+   ETMv3.x ETMv4, PTMv1.0, PTMv1.1, STM, STM500, ITM
+Link:
+   Funnel, replicator (intelligent or not), TMC-ETR
+Sinks:
+   ETBv1.0, ETB1.1, TPIU, TMC-ETF
+Misc:
+   CTI
+
+
+Device Tree Bindings
+----------------------
+
+See Documentation/devicetree/bindings/arm/coresight.txt for details.
+
+As of this writing drivers for ITM, STMs and CTIs are not provided but are
+expected to be added as the solution matures.
+
+
+Framework and implementation
+----------------------------
+
+The coresight framework provides a central point to represent, configure and
+manage coresight devices on a platform.  Any coresight compliant device can
+register with the framework for as long as they use the right APIs:
+
+struct coresight_device *coresight_register(struct coresight_desc *desc);
+void coresight_unregister(struct coresight_device *csdev);
+
+Both functions are taking a "struct coresight_device *csdev" and register or
+unregister the device with the core framework.  If everything goes well
+the new devices will show up under /sys/kernel/debug/coresight/, as showns
+here for a TC2 platform:
+
+root@linaro-developer:~# ls /sys/kernel/debug/coresight/
+00000000.replicator  20030000.tpiu    2201c000.ptm  2203c000.etm  2203e000.etm
+20010000.etb         20040000.funnel  2201d000.ptm  2203d000.etm
+root@linaro-developer:~#
+
+The functions take a "struct coresight_device", which looks like this:
+
+struct coresight_desc {
+        enum coresight_dev_type type;
+        struct coresight_dev_subtype subtype;
+        const struct coresight_ops *ops;
+        struct coresight_platform_data *pdata;
+        struct device *dev;
+        const struct coresight_ops_entry **debugfs_ops;
+        struct module *owner;
+};
+
+
+The "coresight_dev_type" identifies what the device is, i.e, source link or
+sink while the "coresight_dev_subtype" will characterise that type further.
+
+The "struct coresight_ops" is mandatory and will tell the framework how to
+perform base operations related to the components, each component having
+a different set of requirement.  For that "struct coresight_ops_sink",
+"struct coresight_ops_link" and "struct coresight_ops_source" have been
+provided.
+
+The next field, "struct coresight_platform_data *pdata" is acquired by calling
+"of_get_coresight_platform_data()", as part of the driver's _probe routine and
+"struct device *dev" gets the device reference embedded in the "amba_device":
+
+static int etm_probe(struct amba_device *adev, const struct amba_id *id)
+{
+ ...
+ ...
+ drvdata->dev = &adev->dev;
+ ...
+}
+
+Specific class of device (source, link, or sink) have generic operations
+that can be performed on them (see "struct coresight_ops").  The
+"**debugfs_ops" is a list of debugfs entries pertaining to operations
+specific to that component only.  "Implementation defined" customisations are
+expected to be accessed and controlled using those entries.
+
+Last but not least, "struct module *owner" is expected to be set to reflect
+the information carried in "THIS_MODULE".
+
+How to use
+----------
+
+Before trace collection can start, a coresight sink needs to be identify.
+There is no limit on the amount of sinks (nor sources) that can be enabled at
+any given moment.  As a generic operation, all device pertaining to the sink
+class will have an "active" entry in debugfs:
+
+root@linaro-developer:/sys/kernel/debug/coresight# ls
+00000000.replicator  20030000.tpiu    2201c000.ptm  2203c000.etm  2203e000.etm
+20010000.etb         20040000.funnel  2201d000.ptm  2203d000.etm
+root@linaro-developer:/sys/kernel/debug/coresight# ls 20010000.etb
+active  status  trigger_cntr
+root@linaro-developer:/sys/kernel/debug/coresight# echo 1 > 20010000.etb/active
+root@linaro-developer:/sys/kernel/debug/coresight# cat 20010000.etb/active
+1
+root@linaro-developer:/sys/kernel/debug/coresight#
+
+At boot time the current etm3x driver will configure the first address
+comparator with "_stext" and "_etext", essentially tracing any instruction
+that falls within that range.  As such "enabling" a source will immediately
+trigger a trace capture:
+
+root@linaro-developer:/sys/kernel/debug/coresight# echo 1 > 2201c000.ptm/enable
+root@linaro-developer:/sys/kernel/debug/coresight# cat 2201c000.ptm/enable
+1
+root@linaro-developer:/sys/kernel/debug/coresight# cat 20010000.etb/status
+Depth:          0x2000
+Status:         0x1
+RAM read ptr:   0x0
+RAM wrt ptr:    0x19d3   <----- The write pointer is moving
+Trigger cnt:    0x0
+Control:        0x1
+Flush status:   0x0
+Flush ctrl:     0x2001
+root@linaro-developer:/sys/kernel/debug/coresight#
+
+Trace collection is stopped the same way:
+
+root@linaro-developer:/sys/kernel/debug/coresight# echo 0 > 2201c000.ptm/enable
+root@linaro-developer:/sys/kernel/debug/coresight#
+
+The content of the ETB buffer can be harvested directly from /dev:
+
+root@linaro-developer:/sys/kernel/debug/coresight# dd if=/dev/20010000.etb \
+of=~/cstrace.bin
+
+64+0 records in
+64+0 records out
+32768 bytes (33 kB) copied, 0.00125258 s, 26.2 MB/s
+root@linaro-developer:/sys/kernel/debug/coresight#
+
+The file cstrace.bin can be decompressed using "ptm2human", DS-5 or Trace32.
+
+Following is a DS-5 output of an experimental loop that increments a variable up
+to a certain value.  The example is simple and yet provides a glimpse of the
+wealth of possibilities that coresight provides.
+
+Info                                    Tracing enabled
+Instruction     106378866       0x8026B53C      E52DE004        false   PUSH     {lr}
+Instruction     0       0x8026B540      E24DD00C        false   SUB      sp,sp,#0xc
+Instruction     0       0x8026B544      E3A03000        false   MOV      r3,#0
+Instruction     0       0x8026B548      E58D3004        false   STR      r3,[sp,#4]
+Instruction     0       0x8026B54C      E59D3004        false   LDR      r3,[sp,#4]
+Instruction     0       0x8026B550      E3530004        false   CMP      r3,#4
+Instruction     0       0x8026B554      E2833001        false   ADD      r3,r3,#1
+Instruction     0       0x8026B558      E58D3004        false   STR      r3,[sp,#4]
+Instruction     0       0x8026B55C      DAFFFFFA        true    BLE      {pc}-0x10 ; 0x8026b54c
+Timestamp                                       Timestamp: 17106715833
+Instruction     319     0x8026B54C      E59D3004        false   LDR      r3,[sp,#4]
+Instruction     0       0x8026B550      E3530004        false   CMP      r3,#4
+Instruction     0       0x8026B554      E2833001        false   ADD      r3,r3,#1
+Instruction     0       0x8026B558      E58D3004        false   STR      r3,[sp,#4]
+Instruction     0       0x8026B55C      DAFFFFFA        true    BLE      {pc}-0x10 ; 0x8026b54c
+Instruction     9       0x8026B54C      E59D3004        false   LDR      r3,[sp,#4]
+Instruction     0       0x8026B550      E3530004        false   CMP      r3,#4
+Instruction     0       0x8026B554      E2833001        false   ADD      r3,r3,#1
+Instruction     0       0x8026B558      E58D3004        false   STR      r3,[sp,#4]
+Instruction     0       0x8026B55C      DAFFFFFA        true    BLE      {pc}-0x10 ; 0x8026b54c
+Instruction     7       0x8026B54C      E59D3004        false   LDR      r3,[sp,#4]
+Instruction     0       0x8026B550      E3530004        false   CMP      r3,#4
+Instruction     0       0x8026B554      E2833001        false   ADD      r3,r3,#1
+Instruction     0       0x8026B558      E58D3004        false   STR      r3,[sp,#4]
+Instruction     0       0x8026B55C      DAFFFFFA        true    BLE      {pc}-0x10 ; 0x8026b54c
+Instruction     7       0x8026B54C      E59D3004        false   LDR      r3,[sp,#4]
+Instruction     0       0x8026B550      E3530004        false   CMP      r3,#4
+Instruction     0       0x8026B554      E2833001        false   ADD      r3,r3,#1
+Instruction     0       0x8026B558      E58D3004        false   STR      r3,[sp,#4]
+Instruction     0       0x8026B55C      DAFFFFFA        true    BLE      {pc}-0x10 ; 0x8026b54c
+Instruction     10      0x8026B54C      E59D3004        false   LDR      r3,[sp,#4]
+Instruction     0       0x8026B550      E3530004        false   CMP      r3,#4
+Instruction     0       0x8026B554      E2833001        false   ADD      r3,r3,#1
+Instruction     0       0x8026B558      E58D3004        false   STR      r3,[sp,#4]
+Instruction     0       0x8026B55C      DAFFFFFA        true    BLE      {pc}-0x10 ; 0x8026b54c
+Instruction     6       0x8026B560      EE1D3F30        false   MRC      p15,#0x0,r3,c13,c0,#1
+Instruction     0       0x8026B564      E1A0100D        false   MOV      r1,sp
+Instruction     0       0x8026B568      E3C12D7F        false   BIC      r2,r1,#0x1fc0
+Instruction     0       0x8026B56C      E3C2203F        false   BIC      r2,r2,#0x3f
+Instruction     0       0x8026B570      E59D1004        false   LDR      r1,[sp,#4]
+Instruction     0       0x8026B574      E59F0010        false   LDR      r0,[pc,#16] ; [0x8026B58C] = 0x80550368
+Instruction     0       0x8026B578      E592200C        false   LDR      r2,[r2,#0xc]
+Instruction     0       0x8026B57C      E59221D0        false   LDR      r2,[r2,#0x1d0]
+Instruction     0       0x8026B580      EB07A4CF        true    BL       {pc}+0x1e9344 ; 0x804548c4
+Info                                    Tracing enabled
+Instruction     13570831        0x8026B584      E28DD00C        false   ADD      sp,sp,#0xc
+Instruction     0       0x8026B588      E8BD8000        true    LDM      sp!,{pc}
+Timestamp                                       Timestamp: 17107041535
-- 
1.9.1


  parent reply	other threads:[~2014-08-20 17:05 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-20 17:03 [PATCH 00/11 v4] Coresight framework and drivers mathieu.poirier
2014-08-20 17:03 ` [PATCH 01/11 v4] coresight: add CoreSight core layer framework mathieu.poirier
2014-08-25  8:24   ` Thomas Petazzoni
2014-08-25 13:53     ` Mathieu Poirier
2014-08-20 17:03 ` [PATCH 02/11 v4] coresight-tmc: add CoreSight TMC driver mathieu.poirier
2014-08-20 17:03 ` [PATCH 03/11 v4] coresight-tpiu: add CoreSight TPIU driver mathieu.poirier
2014-08-20 17:03 ` [PATCH 04/11 v4] coresight-etb: add CoreSight ETB driver mathieu.poirier
2014-08-20 17:03 ` [PATCH 05/11 v4] coresight-funnel: add CoreSight Funnel driver mathieu.poirier
2014-08-20 17:03 ` [PATCH 06/11 v4] coresight-replicator: add CoreSight Replicator driver mathieu.poirier
2014-08-20 17:03 ` [PATCH 07/11 v4] coresight-etm: add CoreSight ETM/PTM driver mathieu.poirier
2014-08-20 17:03 ` mathieu.poirier [this message]
2014-08-20 17:03 ` [PATCH 09/11 v4] coresight: adding support for beagle and beagleXM mathieu.poirier
2014-08-24 21:38   ` Marcin Jabrzyk
2014-08-25 14:02     ` Mathieu Poirier
2014-08-25 21:01       ` Marcin Jabrzyk
2014-08-20 17:03 ` [PATCH 10/11 v4] coresight: adding basic support for Vexpress TC2 mathieu.poirier
2014-08-20 17:03 ` [PATCH 11/11 v4] ARM: removing support for etb/etm in "arch/arm/kernel/" mathieu.poirier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1408554231-24321-9-git-send-email-mathieu.poirier@linaro.org \
    --to=mathieu.poirier@linaro.org \
    --cc=00regkh@linuxfoundation.org \
    --cc=Al.Grant@arm.com \
    --cc=Tony.Armitstead@arm.com \
    --cc=daniel.thompson@linaro.org \
    --cc=james.king@linaro.org \
    --cc=jonas.svennebring@avagotech.com \
    --cc=kaixu.xia@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=marcin.jabrzyk@gmail.com \
    --cc=panchaxari.prasannamurthy@linaro.org \
    --cc=patches@linaro.org \
    --cc=pratikp@codeaurora.org \
    --cc=r.sengupta@samsung.com \
    --cc=robbelibobban@gmail.com \
    --cc=varshney@ti.com \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®