From patchwork Mon Sep 9 03:34:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jie Gan X-Patchwork-Id: 13795796 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 62491CE7AB0 for ; Mon, 9 Sep 2024 03:37:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=EXFs6WBCMRcwfj80q5hSN89/j1417LnNAoWQ2jx06Hg=; b=tTlZQvXzBTCrY68V/OFwptLub7 5DrMlebIxI+dlo33A1OIubfub4TQj1qtsNU3/ex45mPGU+uzM8KozN4TdpyuYo0dmm8ztZa3PLfm5 93JCOuKH+0yXhqKCGCKF3QxHHRMYFK/xRQQKXIGQ+DIDTf6RFG4eyWT6mkJIBnPnPihpxUmEpxT03 nwEsfRZWUOUsH/COeY1wyAJAddrwTsOQL3fzLSlgT1iK3d6RY9ByGN022QB9YV/mqgmM/LpHqpXem b0q/LncxlY1jUckZVErRbnvJeP08djpvfJp4ozcyzpuua0Cwk/5q3loYN1JKp9b2teoZ+YUqRlAEd Qcupdhaw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1snVDo-00000000Nin-3o88; Mon, 09 Sep 2024 03:37:48 +0000 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1snVBm-00000000NJO-1epE for linux-arm-kernel@lists.infradead.org; Mon, 09 Sep 2024 03:35:44 +0000 Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 488NjB5N015985; Mon, 9 Sep 2024 03:35:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=qcppdkim1; bh=EXFs6WBCMRcwfj80q5hSN8 9/j1417LnNAoWQ2jx06Hg=; b=TERqLrQsLOayWCmgHdewsEuF2B4fYq6qTsCQ8Y aabwO7kgRMbm7QU0tHeSqXqO/6d6Maq7vML8NElq7PFWV2fi1eCnSqzRPJvG44SF zqPXHGdigmBgjR2o0A5hKQKAAjCtCqvNycrNrD6CE8q61jzA7N6Cngm/qZz7j6sV 6ChVZ/sV3cN75WQ1PzoaFIX9zqEYW5/Yy98en1haVfKic7tHybO+TkYktZqLUIAr NmIIg5wVv5bf8r5VQJha6ILeSAoXPSQ2112p6oADH+B5MKw4EQ5kg9IzIm39cS8H f/eeJgB8IC2zK1Grl5rQmWROvSlrtIlislRgrk53Mqq1IiIQ== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 41gy72sjjc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Sep 2024 03:35:20 +0000 (GMT) Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA04.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 4893ZIe3003296 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 9 Sep 2024 03:35:19 GMT Received: from jiegan-gv.qualcomm.com (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Sun, 8 Sep 2024 20:35:13 -0700 From: Jie Gan To: Suzuki K Poulose , Mike Leach , James Clark , "Alexander Shishkin" , Maxime Coquelin , Alexandre Torgue , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bjorn Andersson , Konrad Dybcio CC: Jinlong Mao , , , , , Tingwei Zhang , Yuanfang Zhang , Tao Zhang , Song Chai , , Subject: [PATCH v5 0/5] Coresight: Add Coresight TMC Control Unit driver Date: Mon, 9 Sep 2024 11:34:53 +0800 Message-ID: <20240909033458.3118238-1-quic_jiegan@quicinc.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 33QDULXl2XCf78XiJ542j1G_X-yrs6Tz X-Proofpoint-GUID: 33QDULXl2XCf78XiJ542j1G_X-yrs6Tz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 spamscore=0 impostorscore=0 lowpriorityscore=0 clxscore=1015 bulkscore=0 malwarescore=0 adultscore=0 mlxlogscore=999 suspectscore=0 priorityscore=1501 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2408220000 definitions=main-2409090026 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240908_203542_582960_85140D91 X-CRM114-Status: GOOD ( 26.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The Coresight TMC Control Unit(CTCU) device hosts miscellaneous configuration registers to control various features related to TMC ETR device. The CTCU device works as a helper device physically connected to the TMC ETR device. --------------------------------------------------------- |ETR0| |ETR1| . \ / . . \ / . . \ / . . \ / . --------------------------------------------------- ETR0ATID0-ETR0ATID3 CTCU ETR1ATID0-ETR1ATID3 --------------------------------------------------- Each ETR has four ATID registers with 128 bits long in total. e.g. ETR0ATID0-ETR0ATID3 registers are used by ETR0 device. Based on the trace id which is programed in CTCU ATID register of specific ETR, trace data with that trace id can get into ETR's buffer while other trace data gets ignored. The number of CTCU ATID registers depends on the number of defined TMC ETR devices. For example, two TMC ETR devices need eight ATID registers. ETR0 with ETR0ATID0-ETR0ATID3 and ETR1 with ETR1ATID0-ETRATID3. The significant challenge in enabling the data filter function is how to collect the trace ID of the source device. The introduction of trace_id callback function addresses this challenge. The callback function collects trace ID of the device and return it back. The trace ID will be stored in the structure called cs_sink_data and transmitted to helper and sink devices. The cs_sink_data structure is created to address how to transmit parameters needs by coresight_enable_path/coresight_disbale_path functions. Here is an example of the struct cs_sink_data: struct cs_sink_data { struct perf_output_handle *handle; //used by perf mode struct coresight_device *sink; //used to retrieve atid_offset u32 traceid; //traceid needed by CTCU }; The atid_offset mentioned before is the offset to ATID register in CTCU device. Enabling the source device will configure one bit in the ATID register based on its trace ID. Disabling the source devices will reset the bit in the AITD register based on its trace ID. Useage: Enable: STM device with trace ID 5 and ETR0 is activated. Bitmap before the enablement: ETR0ATID0: 31..................543210 ========================== 0000000000000000000000...0 ========================== Bitmap after the enablement: 31..................543210 ========================== 0000000000000...0000100000 ========================== The bit 5 of the ETR0ATID0 register is configured to 1 when enabling the STM device. Disable: STM device with trace ID 5 and ETR0 is activated. Bitmap before the disablement: ETR0ATID0: 31................6543210 ========================= 000000000010111...0100000 ========================= Bitmap after the disablement ETR0ATID0: 31................6543210 ========================= 000000000010111...0000000 ========================= The bit 5 of the ETR0ATID0 register is reset to 0 when disabling the STM device. Previous discussion for V1: https://lore.kernel.org/lkml/20240618072726.3767974-1-quic_jiegan@quicinc.com/T/#t Changes in V2: 1. Rename the device to Coresight Control Unit. 2. Introduce the trace_id function pointer to address the challeng how to properly collect the trace ID of the device. 3. Introduce a new way to define the qcom,ccu-atid-offset property in device tree. 4. Disabling the filter function blocked on acquiring the ATID-offset, which will be addressed in a separate patch once it’s ready. Previous discussion for V2: https://lore.kernel.org/linux-arm-msm/20240705090049.1656986-1-quic_jiegan@quicinc.com/T/#t Changes in V3: 1. Rename the device to Coresight TMC Control Unit(CTCU). 2. Introduce a new way to define the platform related configs. The new structure, qcom_ctcu_config, is used to store configurations specific to a platform. Each platform should have its own qcom_ctcu_config structure. 3. In perf mode, the ETM devices allocate their trace IDs using the perf_sink_id_map. In sysfs mode, the ETM devices allocate their trace IDs using the id_map_default. 4. Considering the scenario where both ETR devices might be enabled simultaneously with multiple sources, retrieving and using trace IDs instead of id_map is more effective for the CTCU device in sysfs mode. For example, We can configure one ETR as sink for high throughput trace data like ETM and another ETR for low throughput trace data like STM. In this case, STM data won’t be flushed out by ETM data quickly. However, if we use id_map to manage the trace IDs, we need to create a separate id_map for each ETR device. Addtionally, We would need to iterate through the entire id_map for each configuration. 5. Add support for apb's clock name "apb". If the function fails to obtain the clock with the name "apb_pclk", it will attempt to acquire the clock with the name "apb". Previous discussion for V3: https://lore.kernel.org/linux-arm-kernel/20240812024141.2867655-1-quic_jiegan@quicinc.com/ Changes in V4: 1. Add TMC description in binding file. 2. Restrict the number of ports for the CTCU device to a range of 0 to 1 in the binding file, because the maximum number of CTCU devices is 2 for existing projects. Changes in V5: 1. Fix the format issue for description paragrah in dt binding file. 2. Previous discussion for why use "in-ports" property instead of "ports". Please help to comment this point if the platform driver must be fixed before submit this patch series. https://lore.kernel.org/linux-arm-msm/4b51d5a9-3706-4630-83c1-01b01354d9a4@arm.com/ Jie Gan (5): Coresight: Add support for new APB clock name Coresight: Add trace_id function to retrieving the trace ID dt-bindings: arm: Add Coresight TMC Control Unit hardware Coresight: Add Coresight TMC Control Unit driver arm64: dts: qcom: Add CTCU and ETR nodes for SA8775p .../bindings/arm/qcom,coresight-ctcu.yaml | 84 +++++ arch/arm64/boot/dts/qcom/sa8775p.dtsi | 160 ++++++++++ drivers/hwtracing/coresight/Kconfig | 8 + drivers/hwtracing/coresight/Makefile | 1 + drivers/hwtracing/coresight/coresight-core.c | 59 +++- drivers/hwtracing/coresight/coresight-ctcu.c | 292 ++++++++++++++++++ drivers/hwtracing/coresight/coresight-ctcu.h | 21 ++ drivers/hwtracing/coresight/coresight-etb10.c | 3 +- .../hwtracing/coresight/coresight-etm-perf.c | 37 ++- .../coresight/coresight-etm3x-core.c | 30 ++ .../coresight/coresight-etm4x-core.c | 29 ++ drivers/hwtracing/coresight/coresight-priv.h | 13 +- drivers/hwtracing/coresight/coresight-stm.c | 22 ++ drivers/hwtracing/coresight/coresight-sysfs.c | 24 +- .../hwtracing/coresight/coresight-tmc-etf.c | 3 +- .../hwtracing/coresight/coresight-tmc-etr.c | 6 +- drivers/hwtracing/coresight/coresight-tpda.c | 20 ++ drivers/hwtracing/coresight/coresight-trbe.c | 4 +- drivers/hwtracing/coresight/ultrasoc-smb.c | 3 +- include/linux/coresight.h | 16 +- 20 files changed, 807 insertions(+), 28 deletions(-) create mode 100644 Documentation/devicetree/bindings/arm/qcom,coresight-ctcu.yaml create mode 100644 drivers/hwtracing/coresight/coresight-ctcu.c create mode 100644 drivers/hwtracing/coresight/coresight-ctcu.h