From nobody Tue Dec 16 22:37:47 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 795B52DEA77 for ; Wed, 3 Dec 2025 09:01:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764752519; cv=none; b=ZH4P/1HelIu3lMN2jSbvrF6rVPhlg85LzznJzvAC30jyUv8bJHEGws5Vdb8hl62N/XPMo/x88vMNzvY7QWXtkKch5NNtjLI6syxQyw89gHOdrWNVJZOYiyd0bmFicj22Jhk4ONZ4t4wWBw2pGeW0hTSCUJIphBsQ246nn6Cvf44= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764752519; c=relaxed/simple; bh=1BtOV/SJZWIFW6jxWiw7Sv1iyqhney4xGXyT6EzMMcc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=B8XmkQBtKxpDi373LG7mJuzwoSbu7qYduIuA+ljda4E5ZKPpSV1WGX02/Ud6D+zkTO9WJfHUfiC0T2R9jEIUHN+A1YQZJTO4kIVIWP4oukHPy089/2lEw3O07i+5WQC8+gw7uTCaJavftAI7tknsXl5MdBF60oJFbrwnSlCqEhU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=AEAk5hj1; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Ua25o1DB; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="AEAk5hj1"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Ua25o1DB" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5B38JdW6404430 for ; Wed, 3 Dec 2025 09:01:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=vAnZPRoPnmA r0OgnZky4GgITZgZg+aavJ0T05/kKawc=; b=AEAk5hj10MkZ9+sicBhh8B9h4l1 36lSLGMBnJHcvnVZhw99w/VOQ5JoNZ/cHlCLHJwSQ9+Il7tS7bKRFoAstGRRODzD CwVpi0hzf/m0je7iAztt5cIP10MXTX5jWwIAQYATMMIcyEgCe8WIhFNU0jNsPScT gzp8mRPF8TiLCnBsy1lD1q6ak+03Jno4GbMGGFt93j45kEJ3wCRzjF+uV8ZL0Vlp Z9yibJN7bjPAO35DTzV2VR0PX+hXEd4qjP4Fe3oqA7qi5J/EHejyNl4wK+F/VCer IzmhV4DfAb64PtbBeAV3kt3DNRKrKqvt2HeAPsH9/5SaPfH6pCWTAG68yeQ== Received: from mail-dy1-f198.google.com (mail-dy1-f198.google.com [74.125.82.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4at9fc9hh1-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 03 Dec 2025 09:01:56 +0000 (GMT) Received: by mail-dy1-f198.google.com with SMTP id 5a478bee46e88-2a45fea6efbso927987eec.0 for ; Wed, 03 Dec 2025 01:01:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1764752516; x=1765357316; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vAnZPRoPnmAr0OgnZky4GgITZgZg+aavJ0T05/kKawc=; b=Ua25o1DBo50rhm5FmYvuQitb4CxxYD/rOtIYQ5TV6guVij2fEibl0bbtrQes0Td7pI NkbJ7vKc+gMMWHupM+NDpOzQOik0aU/icf9HInYN9no1EKBefNSesA0M8AhbastZ5vUe BPeYI+MPCkHKr/lOHFmVk9OB3SjmA9Umt5aCgQwXep4Z1fkHfxFI3Z6L8IiLcknHAAcz 4AmiJPmLDSzv8DGR9nztgbl6HTqFZGqSIaQPBTGrGzndx0zAkTTuUXy+4Zrump2hrtrC xcAVae4PzVFUWefIApAa/7+mHk2qVS9TXLcZZ4JhCWQ6U4yD9nAGSkLyv5sD9Imh8Cc2 iPmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764752516; x=1765357316; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=vAnZPRoPnmAr0OgnZky4GgITZgZg+aavJ0T05/kKawc=; b=E8ckydVUSaUg2E52MynP0O7pib5qhkh34wllN6ONn9ZeJgRBeTqWoaIVtsNwpAsd1S CBcVi+bXQZUpGS8JcdkrNItZG8Wzvv8F0a0NVfOHIK0jLoAdfwoT2A/mg0GmPi3e0wKa fsW5GBkWBqr8rfeLyXBCmF8MNGdizNWru+gyDgRlOtaWdvh6F2eqcSMIV8tT1/a8CCK3 e4No9TxO8nisMw9/K7fTkDWUJfb990pvmqO/REjfbgzM8zWm2kzU1YVjv3s7JFwufvQj 3zbccLNi5Te/snIa+BhcrdhWvE5uMnMLcMLoRyOn14PKxUTd3qfxwkzGS1s7wNSrhGkM xQZA== X-Forwarded-Encrypted: i=1; AJvYcCU6qDYkRmoALfAIuN3/Jnhq2VGAO+PuOOKsRKnA8xXEXtOOnySFTnEXg35snW/hV1nv5Hp5T/PJfkf9E0k=@vger.kernel.org X-Gm-Message-State: AOJu0YzesEQlMwMSiUXVnbVvvPf1J9Dvtitic2U2pe9y3yz2qSkS+g11 2vwcRUWHUsI96wt2WYnWsEa/2U57fwLvPimJDNtfFNVBoG6ZKHiPrSOJpYzdLtoLVl4FjKkV+Vv UuWgtZNO5x9FOQdKmbo4ucP2Sbvldvdf+3JNnRlJwbDEQnN2Hb2M/GTAEk66JXL9zcfs= X-Gm-Gg: ASbGncvs4HMF0UGJzk7+cjWV4mYm4/ZPTgiYUempAr63hked19GDVGFMS2NR9WD043Q yQHD0SMu6G9A9ViBJx9+xcX+c49RSW2DDHgaoLi67lTzDG7geY9WsTb5w1Qbnxm7R83PbaHVUT3 1Dd7+fp2oatfyY6eNJJ71FW1TXK56Wo0Sq6lrtsnXDpAJ+zKigwq4C/hG3rUBpfUr7ZMjTTv9ep zfIFY44rO0OvWVOyIIvhwqHcv2l26cLkQjl+Wb9BMo1CWGIup82WrDpjL198meHBeZlXaU4PFJM IHY6Bh3ySgymDk+hIM8C3dA8ABo7cHlcfTvLueJQm7p9fv5O/syGka297ydg0pGoqVob+NK5xRJ Jfd5XzXj5o6P/WGSqgqnh4uHj2cdc013pqLLXZawIq1OtpQbMhf4xvekHjupGjRZU X-Received: by 2002:a05:7022:618f:b0:11b:82b8:40cd with SMTP id a92af1059eb24-11df0c463e5mr1170460c88.14.1764752515490; Wed, 03 Dec 2025 01:01:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IGSNRtAZGBTSJue+Ey8VONMYuwnZj4Kvoe/oRjlVagfklSEUJXSEiWRgsKNGcC6ntzC8e0u3g== X-Received: by 2002:a05:7022:618f:b0:11b:82b8:40cd with SMTP id a92af1059eb24-11df0c463e5mr1170428c88.14.1764752514936; Wed, 03 Dec 2025 01:01:54 -0800 (PST) Received: from hu-songchai-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-11dcb057cb0sm100001866c88.9.2025.12.03.01.01.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Dec 2025 01:01:54 -0800 (PST) From: Songwei Chai To: andersson@kernel.org, alexander.shishkin@linux.intel.com, kernel@oss.qualcomm.com, mike.leach@linaro.org, suzuki.poulose@arm.com, james.clark@arm.com, krzk+dt@kernel.org, conor+dt@kernel.org Cc: Songwei Chai , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, coresight@lists.linaro.org, devicetree@vger.kernel.org Subject: [PATCH v8 7/7] qcom-tgu: Add reset node to initialize Date: Wed, 3 Dec 2025 01:00:55 -0800 Message-Id: <20251203090055.2432719-8-songwei.chai@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251203090055.2432719-1-songwei.chai@oss.qualcomm.com> References: <20251203090055.2432719-1-songwei.chai@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjAzMDA3MCBTYWx0ZWRfX5hpzYFe6XYdW sA5x0406V7FMfxdDJxISK76AOgEhar7Oy0WNNpIFh/1JLKMEr6qNanK147Zt04RthKv+QC0IGLi W+gwEiyz4IiYit5bLF3B7tJwcJgB169APywdSWSJ+1rlp9cYOjgjXPXXF9bPQOkuw6ddZpB8QTq /xvRIZ/Z0Kls5RvtLTQFlPlYKZ0FsLZNuga/HFWFbZVKe3Q/quMp5oT+bpFA8A7JrRbK1FB3SgC +J2lHy88p1epB004B45hwjuNAj3fvNM8HWp7Q5jO3Y8Yct8qudRJsS+q4IIUBlwEzZEWdPilCYD 65sTOSDZoTZn34nczmpl+6/IEQSXoiuVp600pFj7lr8uK68oF5Fo86XjifykqNA+GD7vhGh7h67 viWs5wSJOUIOlUgDY7g/isJhVnZV2g== X-Authority-Analysis: v=2.4 cv=Qblrf8bv c=1 sm=1 tr=0 ts=692ffc84 cx=c_pps a=wEP8DlPgTf/vqF+yE6f9lg==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=wP3pNCr1ah4A:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=IgPCHI2mAnvcCQI4J_AA:9 a=bBxd6f-gb0O0v-kibOvt:22 X-Proofpoint-GUID: u35deG8xGU7nXZMCpUg8eMt0ikxoFv6V X-Proofpoint-ORIG-GUID: u35deG8xGU7nXZMCpUg8eMt0ikxoFv6V X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-02_01,2025-11-27_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 bulkscore=0 spamscore=0 lowpriorityscore=0 impostorscore=0 priorityscore=1501 adultscore=0 phishscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2512030070 Content-Type: text/plain; charset="utf-8" Add reset node to initialize the value of priority/condition_decode/condition_select/timer/counter nodes. Signed-off-by: Songwei Chai --- .../testing/sysfs-bus-coresight-devices-tgu | 7 ++ drivers/hwtracing/qcom/tgu.c | 75 +++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-coresight-devices-tgu b/Do= cumentation/ABI/testing/sysfs-bus-coresight-devices-tgu index 28d1743bd2fc..3029f342fc49 100644 --- a/Documentation/ABI/testing/sysfs-bus-coresight-devices-tgu +++ b/Documentation/ABI/testing/sysfs-bus-coresight-devices-tgu @@ -42,3 +42,10 @@ KernelVersion 6.18 Contact: Jinlong Mao , Songwei Chai Description: (RW) Set/Get the counter value with specific step for TGU. + +What: /sys/bus/coresight/devices//reset_tgu +Date: December 2025 +KernelVersion 6.18 +Contact: Jinlong Mao , Songwei Chai +Description: + (Write) Write 1 to reset the dataset for TGU. diff --git a/drivers/hwtracing/qcom/tgu.c b/drivers/hwtracing/qcom/tgu.c index 5db876c31a63..a164867c6b66 100644 --- a/drivers/hwtracing/qcom/tgu.c +++ b/drivers/hwtracing/qcom/tgu.c @@ -434,6 +434,80 @@ static ssize_t enable_tgu_store(struct device *dev, } static DEVICE_ATTR_RW(enable_tgu); =20 +/* reset_tgu_store - Reset Trace and Gating Unit (TGU) configuration. */ +static ssize_t reset_tgu_store(struct device *dev, + struct device_attribute *attr, const char *buf, + size_t size) +{ + unsigned long value; + struct tgu_drvdata *drvdata =3D dev_get_drvdata(dev->parent); + int i, j, ret; + + if (kstrtoul(buf, 0, &value) || value =3D=3D 0) + return -EINVAL; + + if (!drvdata->enable) { + ret =3D pm_runtime_get_sync(drvdata->dev); + if (ret < 0) { + pm_runtime_put(drvdata->dev); + return ret; + } + } + + spin_lock(&drvdata->lock); + CS_UNLOCK(drvdata->base); + + writel(0, drvdata->base + TGU_CONTROL); + + if (drvdata->value_table->priority) + memset(drvdata->value_table->priority, 0, + MAX_PRIORITY * drvdata->max_step * + drvdata->max_reg * sizeof(unsigned int)); + + if (drvdata->value_table->condition_decode) + memset(drvdata->value_table->condition_decode, 0, + drvdata->max_condition_decode * drvdata->max_step * + sizeof(unsigned int)); + + /* Initialize all condition registers to NOT(value=3D0x1000000) */ + for (i =3D 0; i < drvdata->max_step; i++) { + for (j =3D 0; j < drvdata->max_condition_decode; j++) { + drvdata->value_table + ->condition_decode[calculate_array_location( + drvdata, i, TGU_CONDITION_DECODE, j)] =3D + 0x1000000; + } + } + + if (drvdata->value_table->condition_select) + memset(drvdata->value_table->condition_select, 0, + drvdata->max_condition_select * drvdata->max_step * + sizeof(unsigned int)); + + if (drvdata->value_table->timer) + memset(drvdata->value_table->timer, 0, + (drvdata->max_step) * + (drvdata->max_timer) * + sizeof(unsigned int)); + + if (drvdata->value_table->counter) + memset(drvdata->value_table->counter, 0, + (drvdata->max_step) * + (drvdata->max_counter) * + sizeof(unsigned int)); + + dev_dbg(dev, "Coresight-TGU reset complete\n"); + + CS_LOCK(drvdata->base); + + drvdata->enable =3D false; + spin_unlock(&drvdata->lock); + pm_runtime_put(drvdata->dev); + + return size; +} +static DEVICE_ATTR_WO(reset_tgu); + static const struct coresight_ops_helper tgu_helper_ops =3D { .enable =3D tgu_enable, .disable =3D tgu_disable, @@ -445,6 +519,7 @@ static const struct coresight_ops tgu_ops =3D { =20 static struct attribute *tgu_common_attrs[] =3D { &dev_attr_enable_tgu.attr, + &dev_attr_reset_tgu.attr, NULL, }; =20 --=20 2.34.1