Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp66446pxj; Wed, 23 Jun 2021 15:52:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuh84KoPOeYhSRJhkchg6bXEV8FDLFfYz64WPe190ZfCyrhNkOM6rpgoXeFyJ4xDmEXYkX X-Received: by 2002:a17:907:2a85:: with SMTP id fl5mr2141246ejc.363.1624488762033; Wed, 23 Jun 2021 15:52:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624488762; cv=none; d=google.com; s=arc-20160816; b=Bwj78rpQ6MqLStBszoJvLg5NOs2gxVhfaSIbU5qV43kge46UsSBZY5tRh/CJ5iRydv 04fO6sWg44vRg77TgEYdd7x+ewMK+JLxbuG/fX8WvOZrrasc4fktxvmY/D5Xgx/3seQh KgVWXzfZTKntN5YlpgI7/X3qx0Tx50rHljaU2N+t5r9o02KOKLa8sSM0+jZmZeS5nEBb 6CZH5P1eSwLUnmPWFaOUAsacPR1eSecUT3iVu9SBYyTLcFVUpUerTALzoHHS4ZfpK1Vr vp7YXfN7jJKs/hpK2njvrzhaFlgVBASv2DjxuP5B37cwobhMULsMHKrqOmTF5qvhVBCD Se/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ojZcueDSPD/ERt4bOu86T2XmRZadicKtfCs4npiprqs=; b=KyJTG78aYvlqwp9ZPBouw0povWx/ZkB+DxzZQTlkab+RWdag3ORyzpFsl/APndO8Er y9d1P3onpXLSKSDBNEvkg+J01aRjeSV9WRnZhU3YnSa036g9wRQyjQS6cb/ki53aa5s7 eD8UHW1np3eoQreTrxcd8LrT++F456ZbQHv4/xWjm836esbZbo6BVai2XonetNIGvm0q yHgbc6kQ7N6pLUdo+KW7kbcFIz2HVcvlgOTJ8bgLz1vBKwrJQ7abF6jBvCg4Ps/Qed6/ ThJFR3glFhy06tttxChtvfHCuxB29PhJ5MlQ3TIZLArmDSKI7/cVK0BAjtfmo9VIDB/0 jcig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oC2ki8sM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id yc7si850078ejb.576.2021.06.23.15.52.17; Wed, 23 Jun 2021 15:52:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oC2ki8sM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229801AbhFWWxf (ORCPT + 99 others); Wed, 23 Jun 2021 18:53:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229688AbhFWWxd (ORCPT ); Wed, 23 Jun 2021 18:53:33 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B34D5C061574 for ; Wed, 23 Jun 2021 15:51:14 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id 69so1930502plc.5 for ; Wed, 23 Jun 2021 15:51:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ojZcueDSPD/ERt4bOu86T2XmRZadicKtfCs4npiprqs=; b=oC2ki8sMMsIWI+7fRxQmfT/VBHQBCn+286TDaS+3A3i2l/BZho7r7TZg8FgUpw8/sj MjuhW+2q2b8UdzUNovBjw+IBQxvi6GUEywBpircBIrpASBK4E8MoGzjHVQKOvzsnIy3s rcwvVMYRFLEsS2TaR/glFdQ0Z69hyYgQQBUL6PEhN0dIgpCRObchPZ+BL/67IcR04PPk 8LFNlilbx6dTv3jKGqH2Lws1CC0+eKHJZrtCzwhbMr2xMwrCN0dAHQR4jhQwZMDVfrRy anV9jE71OVAsIrW2ds+XOh2sJ33LOhTRp1fF75xutsq/GaITf2OI43N3nErnOzOli1le xIzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ojZcueDSPD/ERt4bOu86T2XmRZadicKtfCs4npiprqs=; b=UEd3m1KpGDu0u1/sIGv2YcAroBYMOk1p/8P+0k+9klQDXtF+vlwD3y97fZVZdEmN59 /4TJnmiUDD9EBiXV3IBLR2bXYp+ysfuKtKVkwoPIQFGmQeg9CCfnuGCScEuxkr6cCfJj YH31sMgDJLC1HluaeuHkLK4me6PKmctt3J9kaZijqA41ayTeuW3pck6h8M5LKQ/48mVE NajgoS2u1Z6AEmAnrmmLHI/UQmT3jr6KuCgRr5157sL4/KvTehV/c5ZhCV08MX0PZ747 soYhQ3oK0UM4Qccs8w0LhXyb3DEwWqDmJbrIAqKj33pXr4fTgIeH5fBiR1uOCyNnYTF9 7dPA== X-Gm-Message-State: AOAM532g31DoZQLa0WRGKg51BviMkFwePfrCdVahbojOF2iO5Ht55aHu UA+16D7eZW1+8Ktfo7L1ubuFcw== X-Received: by 2002:a17:902:8a83:b029:10f:45c4:b435 with SMTP id p3-20020a1709028a83b029010f45c4b435mr1489733plo.17.1624488674222; Wed, 23 Jun 2021 15:51:14 -0700 (PDT) Received: from p14s (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id z15sm141384pgu.71.2021.06.23.15.51.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Jun 2021 15:51:13 -0700 (PDT) Date: Wed, 23 Jun 2021 16:51:11 -0600 From: Mathieu Poirier To: Qi Liu Cc: alexander.shishkin@linux.intel.com, suzuki.poulose@arm.com, jonathan.zhouwen@huawei.com, f.fangjian@huawei.com, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linuxarm@huawei.com Subject: Re: [RFC PATCH 1/4] Documentation: tracing: Documentation for ultrasoc framework and drivers Message-ID: <20210623225111.GA1057775@p14s> References: <1623749684-65432-1-git-send-email-liuqi115@huawei.com> <1623749684-65432-2-git-send-email-liuqi115@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1623749684-65432-2-git-send-email-liuqi115@huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Tue, Jun 15, 2021 at 05:34:41PM +0800, Qi Liu wrote: > Ultrasoc trace module is a system level solution for both core tracing > and SoC tracing. This patch brings in a documentation for ultrasoc > framework and drivers. It simply introduces function of ultrasoc, a > typical Ultrasoc system, and a driver framework for ultrasoc. > > Signed-off-by: Jonathan Zhou > Signed-off-by: Qi Liu > --- > Documentation/trace/ultrasoc-trace.rst | 209 +++++++++++++++++++++++++++++++++ > 1 file changed, 209 insertions(+) > create mode 100644 Documentation/trace/ultrasoc-trace.rst > > diff --git a/Documentation/trace/ultrasoc-trace.rst b/Documentation/trace/ultrasoc-trace.rst > new file mode 100644 > index 0000000..36d2df2 > --- /dev/null > +++ b/Documentation/trace/ultrasoc-trace.rst > @@ -0,0 +1,209 @@ > +======================================================= > +Siemens Embedded Analytics - HW Assisted Tracing on SoC > +======================================================= > + :Author: Jonathan Zhou > + Qi Liu > + :Date: January 16th, 2021 > + > +Introduction > +------------ > + > +The Siemens Embedded Analytics Framework is system level solution for tracing > +of multiple type SoC, this document is concerned with trace module. This module > +has two main components: AXI Bus Communicator and System Memory Buffer. > + > +The AXI Communicator has upstream and downstream channels, the upstream channel > +is used to transmit user configuration, and downstream channel to carry response > +and trace data to the users. > + > +The System Memory Buffer provides a way to buffer and store messages in system > +memory. It provides a capability to store messages received on its input message > +interface to an area of system memory. > + > +A typical Siemens trace system would look like the following diagram: > + @@@@@@@@@@@@@ > + @ CPU @ > + @@@@@@@@@@@@@ > + ############# > + # Coresight # > + # ETM # > + ####### > + ### > + # > + | > + * > + ******************************* > + *** AMBA Advanced Trace Bus (ATB) *** > + ***************^*************** > + =============== | > + === FUNNEL ==<--- | > + ======= > + | > + * > + @@@@@@@ > + @ TRC @ > + @@@@@ > + @@@ > + @ > + | > + * > + ************************************** ******************* > + ************************ Message BUS *************************** > + ******************^************************^**************** > + | | > + @@@@@@@@@@@@@@@@@@ | @@@@@@@@@@@@ > + @ Message Engine @ | @ JTAG COM @ > + @@@@@@@@@@@@@@@@@@ | @@@@@@@@@@ > + | * |---> @@@@@@@@ > + | | @@@@@@ > + @@@@@@@ | @@@@@@@@@@@ | > + @ SMB @ | @ AXI COM @ JTAG > + @@@@@ |--> @@@@@@@@@ > + @@@--| @@@@@@@ > + @ | @@@@@ > + | | > + | | > + * * > + *************************************************************** > + **************************** AMBA AXI **************************** > + ***************************************************************** > + > +Acronyms > +--------------------------- > + > +Acronyms: > + > +AXI-COM: AXI Communicator > +SMB: System Memory Buffer > +TRC: Trace receiver > + > +Framework and implementation > +------------------------------ > + > +Siemens Embedded Analytics Framework is implemented as a platform device. The > +platform device provides a global point to configure the Embedded Analytics > +subsystem, and also provides a ``struct ultrasoc_com`` to manage AXI-COM and > +SMB. > + > +AXI-COM and SMB are implemented as platform devices, each SCCL has one AXI-COM > +device and one SMB device. AXI-COM and SMB can use the following API to register > +into Embedded Analytics framework: > +.. c:function:: struct ultrasoc_com *ultrasoc_register_com(struct device *root_dev, struct ultrasoc_com_descp *com_descp) > +.. c:function:: void ultrasoc_unregister_com(struct ultrasoc_com *com); > + > +As TRC receives data from coresight ETM device, SMB can use the following API > +to register into coresight framework as a sink device: > +.. c:function:: struct coresight_device *coresight_register(struct coresight_desc *desc); > +.. c:function:: void coresight_unregister(struct coresight_device *csdev); > + > +Then users can get trace data by this path: ETM->funnel->SMB->System Memory. > +More information about coresight framework can be found in > +Documention/trace/coresight/coresight.rst. > + > +If everything goes well, the relationship of Embedded Analytics devices will be > +described under the sysfs:: > + > + $# ls /sys/bus/platform/devices/ > + :00 :00 :00 > + $# ls /sys/bus/platform/devices/:00 > + com_mux firmware_node power :00 > + driver message subsystem :00 > + driver_override modalias uevent > + $# ls /sys/bus/coresight/devices/ > + etm0 etm14 etm2 etm25 etm30 etm8 funnel4 > + etm1 etm15 etm20 etm26 etm31 etm9 funnel5 > + etm10 etm16 etm21 etm27 etm4 funnel0 funnel6 > + etm11 etm17 etm22 etm28 etm5 funnel1 funnel7 > + etm12 etm18 etm23 etm29 etm6 funnel2 sink_smb0 > + etm13 etm19 etm24 etm3 etm7 funnel3 > + $# ls -l /sys/bus/coresight/devices/funnel0/connections/ > + in:0 -> ../../../../system/cpu/cpu0/ARMHC500:00/etm0 > + in:1 -> ../../../../system/cpu/cpu1/ARMHC500:01/etm1 > + in:2 -> ../../../../system/cpu/cpu2/ARMHC500:02/etm2 > + in:3 -> ../../../../system/cpu/cpu3/ARMHC500:03/etm3 > + nr_links > + out:0 -> ../../../HISI0391:00/HISI03A1:00/sink_smb0 > + $# ls -l /sys/bus/coresight/devices/sink_smb0/connections/ > + in:101 -> ../../../../ARMHC9FE:05/funnel5 > + in:114 -> ../../../../ARMHC9FE:07/funnel7 > + in:121 -> ../../../../ARMHC9FE:03/funnel3 > + in:39 -> ../../../../ARMHC9FE:00/funnel0 > + in:51 -> ../../../../ARMHC9FE:04/funnel4 > + in:61 -> ../../../../ARMHC9FE:06/funnel6 > + in:68 -> ../../../../ARMHC9FE:02/funnel2 > + in:89 -> ../../../../ARMHC9FE:01/funnel1 > + nr_links > + > +How to use the Embedded Analytics trace module > +----------------------------------------------- > + > +There are two ways to use the Embedded Analytics trace module: > + > +1. interacting directly with the devices using the sysFS interface. > +2. using the perf cmd line tools. > + > +1) Using the sysFS interface: > + > +Before trace collection can start, a coresight sink needs to be identified. > +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 sysfs:: I haven't looked at the rest of the patchset but unless you have changed that, only one sink will be selected by the framework when operating from sysfs. Regardless of the number of sinks that were enabled, the framework will pick the first one it finds. > + > + $# ls /sys/bus/coresight/devices/ > + etm0 etm14 etm2 etm25 etm30 etm8 funnel4 > + etm1 etm15 etm20 etm26 etm31 etm9 funnel5 > + etm10 etm16 etm21 etm27 etm4 funnel0 funnel6 > + etm11 etm17 etm22 etm28 etm5 funnel1 funnel7 > + etm12 etm18 etm23 etm29 etm6 funnel2 sink_smb0 > + etm13 etm19 etm24 etm3 etm7 funnel3 > + $# ls /sys/bus/coresight/devices/sink_smb0 > + connections enable_sink firmware_node power subsystem uevent > + $# echo 1 > /sys/bus/coresight/devices/sink_smb0/enable_sink > + $# cat /sys/bus/coresight/devices/sink_smb0/enable_sink > + 1 > + > +When start trace collection, etm devices corresponding to the enabled sink > +should be selected:: > + > + $# echo 1 > /sys/bus/coresight/devices/etm0/enable_source > + $# cat /sys/bus/coresight/devices/etm0/enable_source > + 1 > + $# cat /sys/bus/platform/devices/:00/com_status > + com-type : DOWN-ONLY > + service status : stopped > + interrupt status : 0x00000003 > + write point : 0x5437f400 <----- The write pointer is moving > + > +Trace collection is stopped the same way:: > + > + $# echo 0 > /sys/bus/coresight/devices/etm0/enable_source > + $# echo 0 > /sys/bus/coresight/devices/sink_smb0/enable_sink > + > +The content of the SMB buffer can be harvested directly from /dev:: > + > + $# dd if=/dev/sink_smb0 of=~/cstrace.bin > + 5233+0 records in > + 5233+0 records out > + 2679296 bytes (2.7 MB) copied, 0.0131708 s, 203 MB/s > + > + root:/sys/bus/coresight/devices# > + > +The file cstrace.bin can be decompressed using "ptm2human". > + > +2) Using perf framework: > + > +As SMB device has been registered with coresight framework, perf tool can be > +used to control Embedded Analytics trace collection, and the method is similar > +to using perf to do coresight trace collection. > + > +The only thing to note is, list of cpus should be correspond to the specified > +sink device. > + > +Example usage of perf:: > + > + $# ./perf list pmu > + cs_etm// [Kernel PMU event] > + $# ./perf record -e cs_etm/@sink_smb0/ -C 0 --per-thread sleep 2s > + [ perf record: Woken up 2 times to write data ] > + [ perf record: Captured and wrote 0.288 MB perf.data ] > + $# ./perf report After reading all this and without looking at the rest of the patchset it seems to me this work should go under drivers/hwtracing/coresight/. There is a lot of code to review and as such it will take me a fair amount of time to go through it all. Comments will be scattered over several days (weeks) - I will set you know when I am done. Thanks, Mathieu > -- > 2.7.4 >