From nobody Wed Nov 27 14:20:45 2024 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 6DDBB433C9; Thu, 10 Oct 2024 07:39:52 +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=1728545994; cv=none; b=L1oJm399UaT/bUZVaunJejCeOsGBX75Q8hmOKk/cICxiLCd48GWGdyAt2Y4fyMnDcI8UvbgbqE8aDLCu3U61Neaeu56JB3WT80N96493uKRpn3cS4tpOMnl6Wf0L/A8sSOP6fXwQrDW+oQOPQ0/l/YmAMTtLklD0kPgMHVNu8wY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728545994; c=relaxed/simple; bh=sRYIv1gRpeLAr5ZgEzDO+E6/anGSS3qGlkFZavUs5rk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GrOgAnPS6eSiaZXOfDeuOCM1605F8SiC43UdRZqOdf8oy0j/wvL644447WcuE/6q5S5R2mLKNoxI8vorR1iS2LG80C1AuvnoLfAfogvK30KF4EAetL60971EVnUcyLHZjk4+ud1dP8gZGLckiryDF8eJfEZqpT1eLuM4bUEyX/w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=onoLFChd; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="onoLFChd" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49A1b4d7030283; Thu, 10 Oct 2024 07:39:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= I9/04b9/sWOWVTpl1YR14gpRJOEDbRR58oQhG90l1hw=; b=onoLFChdQBvlENIi XsdtXBfuXtKrd1ceaA0xulZZIRc7tQImL1W/PgpQzhK0ug69bLwc3oyWNWjsaNmK /oh3Y4gxq/Vgo/RCQe4P9DMwsp/Ajk82nBaehqH8pw0ini4l3BKDtbGIhSQUV+w1 nWyZT3Sv/kZTSlAWfEC85KSh4iY6fzP4D6zit+VD0IJ2XmjXrseEtaRdd4rZkWuY 2VW2o7MBdok2MImATNsksOqrggdTHun/BnZofprjaUrBUDeK++KWGIZCdGcm80OL NS/Ga86L/9RJSERQk6iFqbZgC/B9+qgtZXeMko0UKZeAd8mm8h7Dcbn1ulBNeROC 1ijKLQ== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 424x7ryny5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Oct 2024 07:39:36 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA01.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 49A7daCN028679 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Oct 2024 07:39:36 GMT Received: from 3b5b8f7e4007.qualcomm.com (10.49.16.6) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Thu, 10 Oct 2024 00:39:35 -0700 From: Songwei Chai To: Suzuki K Poulose , Mike Leach , James Clark , "Alexander Shishkin" , Andy Gross , Bjorn Andersson , Rob Herring , Krzysztof Kozlowski , Conor Dooley CC: Songwei Chai , , , , , Subject: [PATCH v2 6/7] coresight-tgu: add timer/counter functionality for TGU Date: Thu, 10 Oct 2024 15:39:14 +0800 Message-ID: <20241010073917.16023-7-quic_songchai@quicinc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241010073917.16023-1-quic_songchai@quicinc.com> References: <20241010073917.16023-1-quic_songchai@quicinc.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-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: c3R04vOE5okdqaCRQZa-psdVfLOdho3q X-Proofpoint-ORIG-GUID: c3R04vOE5okdqaCRQZa-psdVfLOdho3q 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 bulkscore=0 suspectscore=0 phishscore=0 mlxlogscore=999 spamscore=0 clxscore=1015 malwarescore=0 lowpriorityscore=0 priorityscore=1501 mlxscore=0 adultscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410100049 Content-Type: text/plain; charset="utf-8" Add counter and timer node for each step which could be programed if they are to be utilized in trigger event/sequence. Signed-off-by: Songwei Chai --- .../testing/sysfs-bus-coresight-devices-tgu | 14 +++ drivers/hwtracing/coresight/coresight-tgu.c | 95 ++++++++++++++++++- drivers/hwtracing/coresight/coresight-tgu.h | 47 ++++++++- 3 files changed, 154 insertions(+), 2 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-coresight-devices-tgu b/Do= cumentation/ABI/testing/sysfs-bus-coresight-devices-tgu index 8dce2b46b48a..e404e0d6f8f0 100644 --- a/Documentation/ABI/testing/sysfs-bus-coresight-devices-tgu +++ b/Documentation/ABI/testing/sysfs-bus-coresight-devices-tgu @@ -28,3 +28,17 @@ KernelVersion 6.10 Contact: Jinlong Mao (QUIC) , Sam Chai (Q= UIC) Description: (RW) Set/Get the next action with specific step for TGU. + +What: /sys/bus/coresight/devices//step[0:7]_timer/reg[= 0:1] +Date: August 2024 +KernelVersion 6.10 +Contact: Jinlong Mao (QUIC) , Sam Chai (Q= UIC) +Description: + (RW) Set/Get the timer value with specific step for TGU. + +What: /sys/bus/coresight/devices//step[0:7]_counter/re= g[0:1] +Date: August 2024 +KernelVersion 6.10 +Contact: Jinlong Mao (QUIC) , Sam Chai (Q= UIC) +Description: + (RW) Set/Get the counter value with specific step for TGU. diff --git a/drivers/hwtracing/coresight/coresight-tgu.c b/drivers/hwtracin= g/coresight/coresight-tgu.c index 860fab854b95..05456e23b852 100644 --- a/drivers/hwtracing/coresight/coresight-tgu.c +++ b/drivers/hwtracing/coresight/coresight-tgu.c @@ -37,6 +37,10 @@ static int calculate_array_location(struct tgu_drvdata *= drvdata, int step_index, case TGU_CONDITION_SELECT: ret =3D step_index * (drvdata->max_condition_select) + reg_index; break; + case TGU_COUNTER: + case TGU_TIMER: + ret =3D step_index * (drvdata->max_timer_counter) + reg_index; + break; default: break; } @@ -70,7 +74,16 @@ static ssize_t tgu_dataset_show(struct device *dev, drvdata->value_table->condition_select[calculate_array_location( drvdata, tgu_attr->step_index, tgu_attr->operation_index, tgu_attr->reg_num)]); - + case TGU_TIMER: + return sysfs_emit(buf, "0x%x\n", + drvdata->value_table->timer[calculate_array_location( + drvdata, tgu_attr->step_index, tgu_attr->operation_index, + tgu_attr->reg_num)]); + case TGU_COUNTER: + return sysfs_emit(buf, "0x%x\n", + drvdata->value_table->counter[calculate_array_location( + drvdata, tgu_attr->step_index, tgu_attr->operation_index, + tgu_attr->reg_num)]); } return -EINVAL; =20 @@ -113,6 +126,18 @@ static ssize_t tgu_dataset_store(struct device *dev, tgu_attr->reg_num)] =3D val; ret =3D size; break; + case TGU_TIMER: + tgu_drvdata->value_table->timer[calculate_array_location( + tgu_drvdata, tgu_attr->step_index, tgu_attr->operation_index, + tgu_attr->reg_num)] =3D val; + ret =3D size; + break; + case TGU_COUNTER: + tgu_drvdata->value_table->counter[calculate_array_location( + tgu_drvdata, tgu_attr->step_index, tgu_attr->operation_index, + tgu_attr->reg_num)] =3D val; + ret =3D size; + break; default: break; } @@ -153,6 +178,15 @@ static umode_t tgu_node_visible(struct kobject *kobjec= t, struct attribute *attr, drvdata->max_condition_select) ? attr->mode : 0; break; + case TGU_COUNTER: + case TGU_TIMER: + if (drvdata->max_timer_counter =3D=3D 0) + ret =3D SYSFS_GROUP_INVISIBLE; + else + ret =3D (tgu_attr->reg_num < + drvdata->max_timer_counter) ? + attr->mode : 0; + break; default: break; } @@ -200,6 +234,26 @@ static void tgu_write_all_hw_regs(struct tgu_drvdata *= drvdata) } } =20 + for (i =3D 0; i < drvdata->max_step; i++) { + for (j =3D 0; j < drvdata->max_timer_counter; j++) { + tgu_writel(drvdata, + drvdata->value_table->timer + [calculate_array_location(drvdata, i, + TGU_TIMER, j)], + TIMER0_COMPARE_STEP(i, j)); + } + } + + for (i =3D 0; i < drvdata->max_step; i++) { + for (j =3D 0; j < drvdata->max_timer_counter; j++) { + tgu_writel(drvdata, + drvdata->value_table->counter + [calculate_array_location(drvdata, i, + TGU_COUNTER, j)], + COUNTER0_COMPARE_STEP(i, j)); + } + } + /* Enable TGU to program the triggers */ tgu_writel(drvdata, 1, TGU_CONTROL); CS_LOCK(drvdata->base); @@ -358,6 +412,22 @@ static const struct attribute_group *tgu_attr_groups[]= =3D { CONDITION_SELECT_ATTRIBUTE_GROUP_INIT(5), CONDITION_SELECT_ATTRIBUTE_GROUP_INIT(6), CONDITION_SELECT_ATTRIBUTE_GROUP_INIT(7), + TIMER_ATTRIBUTE_GROUP_INIT(0), + TIMER_ATTRIBUTE_GROUP_INIT(1), + TIMER_ATTRIBUTE_GROUP_INIT(2), + TIMER_ATTRIBUTE_GROUP_INIT(3), + TIMER_ATTRIBUTE_GROUP_INIT(4), + TIMER_ATTRIBUTE_GROUP_INIT(5), + TIMER_ATTRIBUTE_GROUP_INIT(6), + TIMER_ATTRIBUTE_GROUP_INIT(7), + COUNTER_ATTRIBUTE_GROUP_INIT(0), + COUNTER_ATTRIBUTE_GROUP_INIT(1), + COUNTER_ATTRIBUTE_GROUP_INIT(2), + COUNTER_ATTRIBUTE_GROUP_INIT(3), + COUNTER_ATTRIBUTE_GROUP_INIT(4), + COUNTER_ATTRIBUTE_GROUP_INIT(5), + COUNTER_ATTRIBUTE_GROUP_INIT(6), + COUNTER_ATTRIBUTE_GROUP_INIT(7), NULL, }; =20 @@ -407,6 +477,11 @@ static int tgu_probe(struct amba_device *adev, const s= truct amba_id *id) if (ret) return -EINVAL; =20 + ret =3D of_property_read_u32(adev->dev.of_node, "tgu-timer-counters", + &drvdata->max_timer_counter); + if (ret) + return -EINVAL; + drvdata->max_condition_decode =3D drvdata->max_condition; /* select region has an additional 'default' register */ drvdata->max_condition_select =3D drvdata->max_condition + 1; @@ -443,6 +518,24 @@ static int tgu_probe(struct amba_device *adev, const s= truct amba_id *id) if (!drvdata->value_table->condition_select) return -ENOMEM; =20 + drvdata->value_table->timer =3D devm_kzalloc( + dev, + drvdata->max_step * drvdata->max_timer_counter * + sizeof(*(drvdata->value_table->timer)), + GFP_KERNEL); + + if (!drvdata->value_table->timer) + return -ENOMEM; + + drvdata->value_table->counter =3D devm_kzalloc( + dev, + drvdata->max_step * drvdata->max_timer_counter * + sizeof(*(drvdata->value_table->counter)), + GFP_KERNEL); + + if (!drvdata->value_table->counter) + return -ENOMEM; + drvdata->enable =3D false; desc.type =3D CORESIGHT_DEV_TYPE_HELPER; desc.pdata =3D adev->dev.platform_data; diff --git a/drivers/hwtracing/coresight/coresight-tgu.h b/drivers/hwtracin= g/coresight/coresight-tgu.h index 0d3b966dafc7..9fa23033b4af 100644 --- a/drivers/hwtracing/coresight/coresight-tgu.h +++ b/drivers/hwtracing/coresight/coresight-tgu.h @@ -52,6 +52,12 @@ #define CONDITION_SELECT_STEP(step, select) \ (0x0060 + 0x4 * select + 0x1D8 * step) =20 +#define TIMER0_COMPARE_STEP(step, timer) \ + (0x0040 + 0x4 * timer + 0x1D8 * step) + +#define COUNTER0_COMPARE_STEP(step, counter) \ + (0x0048 + 0x4 * counter + 0x1D8 * step) + #define tgu_dataset_ro(name, step_index, type, reg_num) \ (&((struct tgu_attribute[]){ { \ __ATTR(name, 0444, tgu_dataset_show, NULL), \ @@ -78,6 +84,12 @@ #define STEP_SELECT(step_index, reg_num) \ tgu_dataset_rw(reg##reg_num, step_index, TGU_CONDITION_SELECT, reg_num) =20 +#define STEP_TIMER(step_index, reg_num) \ + tgu_dataset_rw(reg##reg_num, step_index, TGU_TIMER, reg_num) + +#define STEP_COUNTER(step_index, reg_num) \ + tgu_dataset_rw(reg##reg_num, step_index, TGU_COUNTER, reg_num) + #define STEP_PRIORITY_LIST(step_index, priority) \ {STEP_PRIORITY(step_index, 0, priority), \ STEP_PRIORITY(step_index, 1, priority), \ @@ -117,6 +129,18 @@ NULL \ } =20 +#define STEP_TIMER_LIST(n) \ + {STEP_TIMER(n, 0), \ + STEP_TIMER(n, 1), \ + NULL \ + } + +#define STEP_COUNTER_LIST(n) \ + {STEP_COUNTER(n, 0), \ + STEP_COUNTER(n, 1), \ + NULL \ + } + #define PRIORITY_ATTRIBUTE_GROUP_INIT(step, priority)\ (&(const struct attribute_group){\ .attrs =3D (struct attribute*[])STEP_PRIORITY_LIST(step, priority),\ @@ -138,13 +162,29 @@ .name =3D "step" #step "_condition_select" \ }) =20 +#define TIMER_ATTRIBUTE_GROUP_INIT(step)\ + (&(const struct attribute_group){\ + .attrs =3D (struct attribute*[])STEP_TIMER_LIST(step),\ + .is_visible =3D tgu_node_visible,\ + .name =3D "step" #step "_timer" \ + }) + +#define COUNTER_ATTRIBUTE_GROUP_INIT(step)\ + (&(const struct attribute_group){\ + .attrs =3D (struct attribute*[])STEP_COUNTER_LIST(step),\ + .is_visible =3D tgu_node_visible,\ + .name =3D "step" #step "_counter" \ + }) + enum operation_index { TGU_PRIORITY0, TGU_PRIORITY1, TGU_PRIORITY2, TGU_PRIORITY3, TGU_CONDITION_DECODE, - TGU_CONDITION_SELECT + TGU_CONDITION_SELECT, + TGU_TIMER, + TGU_COUNTER }; =20 /* Maximum priority that TGU supports */ @@ -161,6 +201,8 @@ struct value_table { unsigned int *priority; unsigned int *condition_decode; unsigned int *condition_select; + unsigned int *timer; + unsigned int *counter; }; =20 /** @@ -176,6 +218,8 @@ struct value_table { * @max_condition: Maximum number of condition * @max_condition_decode: Maximum number of condition_decode * @max_condition_select: Maximum number of condition_select + * @max_timer_counter: Maximum number of timers and counters + * * This structure defines the data associated with a TGU device, including= its base * address, device pointers, clock, spinlock for synchronization, trigger = data pointers, * maximum limits for various trigger-related parameters, and enable statu= s. @@ -192,6 +236,7 @@ struct tgu_drvdata { int max_condition; int max_condition_decode; int max_condition_select; + int max_timer_counter; }; =20 #endif