From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 78BC43EDAB1 for ; Tue, 31 Mar 2026 09:48:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774950517; cv=none; b=cWjmUhULt0itXz26O5lHXsk6YgTR+bqeXXVkewz7h6aUTcP7Qx9a+U/MeJ0kbfJIKk15JuvwKhUG+q9rfyOUpjEG0q1PBKL7Gtg2GevKWhnBfT2sEa1wzH7Itro/4JzyD/5oCqEkh8EWg7wJycd3A2Th1E5sc1wf93TjfqNj74U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774950517; c=relaxed/simple; bh=79i4zicZ7wuWiubAB5i5+1vYca90PNmpLmL5ssL9hTU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=LgrqJaND0tc2aoRlieDFcTLpc5Bn7Pq14BwZQl066PRYX1rLQmzpQjxSnAOBPZjdqo2ixm73+8wb8Ye8xnqTa63fQ5wkSY0Sp4kcNT4C0mYHcZ0ua+SE+JBxrmPq9WcSA7EtThycapd6FpIMixpOWNfWcXGw28mzwT+4/d6pe1g= 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=Yy9RwJZ+; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=E1uT7vX2; arc=none smtp.client-ip=205.220.180.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="Yy9RwJZ+"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="E1uT7vX2" Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62V8AvMg058081 for ; Tue, 31 Mar 2026 09:48:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= +LT4R8ehoNuZhHtNgCHaEc8Dpry90A7nvziF3tMLDZM=; b=Yy9RwJZ++LVQ3BAf ElXOVnlKF31eLoCa7hYw+F43agLKeFJoSqTtbzh8LWa6+/ytK3HeBg4ptnfMZlYZ AoO3bvDeGXZdfAUE0FOxGNNrIVbcs4W+7hg0Otd7thj8adNwB9h0E0GK/Hs7jEVC mjapKcqDmR0NNAPmhjc4w6mTHRB86RQoH4L+dGXX51xU2SEq1Afsu0dud6JaTISd 9cewxM4Pmq7g4Qpf6yk2masFuYIENRgYypiEgB2J0IxqQRdkBz++yi/hloP6UF5Y a5juLNYNGMhgu3DgRKKRgb98LtQyfBXMqauLU2r6TixmDXElmnUFPUGgxdzwSVGd M+O0Rw== Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4d8ahkre50-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 31 Mar 2026 09:48:34 +0000 (GMT) Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-35845fcf0f5so7200440a91.0 for ; Tue, 31 Mar 2026 02:48:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1774950513; x=1775555313; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=+LT4R8ehoNuZhHtNgCHaEc8Dpry90A7nvziF3tMLDZM=; b=E1uT7vX2HQRGo5R8sveULHhAeA2PfvaYoYVChtITs07Mcxp63mBPSd4Z2pZUbgkEpr EDoxBHCghy8nhFcj3Ghj/NuN6hNwrLOVXQBIXulArEdp+/l00EaBXAj/CzLxm7wMyFJU KtXQtSMBQVa3cH9oOTTDiXJ713lYk3tXQN9cDmqeO6umnqWri3wcgMxFNTgrxnNxg//1 OOFdPnoXYz+Ndl0y6s7rDs8oWYeqvbF1xXf+jPOF82tkjZokIPt9WKCM2SDJ0d3cBRAa P77ZOb5Mnx0RZrTtRWW3Prn+dsKDP+FS8Xw7UzLG9900GOUulIT7ZZRDmu/CpTDJt2pF x79A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774950513; x=1775555313; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+LT4R8ehoNuZhHtNgCHaEc8Dpry90A7nvziF3tMLDZM=; b=YtnHdBdJ4TB/ih38lWEo3VvAEl9gZ8yvFQ2bBd6ccbpMYYJe/o4lWzkCmgN6SjbQr1 Fk/Od09Qv/i28R42UPkJzDJEXYc8oYAP/GtZf2VkdZdVv5Az78q4qERLFCVrkTOmx/Ze LEp3VWJb0M+Nzb+ODyJm1Kb6vTJiwkUIVSAMkdUaz1kHi8jfJzQdN6XofSznlximUoWb rBsb4tI0DtjtSPdv1Zdk39BpEs53vJIt30c4WG786+I3J3lhPtrqPrjOyJD+A8J2bqBW f3Nvq0Jm9o7megri4KwZVX1v9GaC3KEyfStPIry+QOJeLAV/fXsO2RECMhfpFi0TdhbI lxsQ== X-Forwarded-Encrypted: i=1; AJvYcCUjq+AY17Wy2c+alB07pqUHLqk9ITjuW+rFxX3v2epvflZlgG9XL3jF+XHWlJcPzYlr63B7WxMjV3kXSsQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yz3NXOqWSiBoU+JRPaDyWZq9OD/qTj5gQhaUsUyDOn6Bu8TpXTn 0wd0tw+FFYpcSvioZdh8z86MOwsGdxbGJH4CIWRBxhFBfdEysz00b5MbRf5q08uBIUy0amgvcCz BmnuYCDelNqID6oOOCLSrNi5yKMHVOAHQFW6MI6dZd81bJ4qsOnjim29EfVWxUc6/nYc= X-Gm-Gg: ATEYQzzy0utbZtIch0x+CfbZz/iG8DVAk5R59BaeQyPYvgy0F/DM/rSaCH/7/4dBApl ki3Um/Rka5FYhOVIY8OcavZw8bK9Trvd4kx1KmAu+GKEBk2+p49nOgJFD2wd/QXuvXkwNS3qnXH 0UriKpUcsckpsVubEwEm0BDzc4peC0exCtPKN64a9lm/CiIioMfq3EJQR6CPjnIpaB0ntWBoEov WcaK/1KIVX9cCJmFWay7tx41Fg5ixUPr8bVFLDpjzG7/jPd7tNQY+P5RIXP3ILRu3ykGDYrfZXU Mn0KQHXK0l/4jwEmbSkIcViwNBkOd+1cydP0AUgjWCidf88avuGOO1Om1tCm0njml7kFp5d+Zla uO28Uk0sMXh2mOOOaLMVxwHrlV9HY865RHyUkAWOJrZf43lKMSchg/am+2ycxs7keRpCqaK0gEJ FMJjiuRo71Na0= X-Received: by 2002:a17:90b:51c4:b0:35b:939c:e859 with SMTP id 98e67ed59e1d1-35db8f376c8mr2712614a91.12.1774950513236; Tue, 31 Mar 2026 02:48:33 -0700 (PDT) X-Received: by 2002:a17:90b:51c4:b0:35b:939c:e859 with SMTP id 98e67ed59e1d1-35db8f376c8mr2712588a91.12.1774950512679; Tue, 31 Mar 2026 02:48:32 -0700 (PDT) Received: from [10.133.33.252] (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35dbb8c6f70sm657261a91.6.2026.03.31.02.48.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 31 Mar 2026 02:48:32 -0700 (PDT) Message-ID: <6c8dec81-10f3-4ef9-a66e-3a86cfb058ba@oss.qualcomm.com> Date: Tue, 31 Mar 2026 17:48:27 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] coresight: tpdm: add traceid_show for checking traceid To: Suzuki K Poulose , James Clark Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mike Leach , Leo Yan , Alexander Shishkin , Tingwei Zhang References: <20260325-add-traceid-show-for-tpdm-v3-1-0eb836d4ec30@oss.qualcomm.com> <95610981-ad68-4a31-a776-27894b7bca59@linaro.org> <207b78e5-ed6b-4caf-b9ce-546cf33d6dfd@oss.qualcomm.com> <7abe93fa-3748-4077-b75a-d28296862654@linaro.org> <04214197-f521-47d6-88a1-94be1a8b1981@arm.com> Content-Language: en-US From: Jie Gan In-Reply-To: <04214197-f521-47d6-88a1-94be1a8b1981@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzMxMDA5MyBTYWx0ZWRfX5/cCgUsIEgCG qdkV1OZdv+kheOcTYx60glmnSvisnaLkeB+YVuX8T4/td6/mMp9U5ELE0KCuP8h21mBwhXRsJ+r QYvb4xVGyuxmqLzRFKN23vd+YBME5xCfH57bwZT5BHv3LAaw51e048IoYf1rw8Q388JaPVlEvkw 4tK+1L/z6sHWCOlfBDx6WOXzwOwxXF9rzForXDHnquviQIKclUk3oG6Vt2R0ZfgkXGs4j+tvw2d kkvnqittwTgawm2Dr0oV+LJzYMkvwqc3GHcUdlId3Ze0ZzsX+2LmdRKl9ZIC6SkfuLKKlw+e6rw S069coD0bt/5G91w+ssBACv9cVY7rQAkxPdaYKipd9eg7XvrXaFpgkqOIATrbQLiXrBWpkoZQRZ XbzZ49AxywkFT8HiK8yRi3AulvFRNHt4rdfhBX0sh3Q9o9vQ9CDWtj9eapHvPgol2mQgMBLhOKp Nw9q9VYF4L6KH4rPzJQ== X-Authority-Analysis: v=2.4 cv=K4wv3iWI c=1 sm=1 tr=0 ts=69cb9872 cx=c_pps a=UNFcQwm+pnOIJct1K4W+Mw==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=ZpdpYltYx_vBUK5n70dp:22 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=MRA6D28t3Z0tp2SgcUwA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=uKXjsCUrEbL0IQVhDsJ9:22 X-Proofpoint-ORIG-GUID: H6D5fi6xgmmFi2BD8WmW7Du6k7SSFnds X-Proofpoint-GUID: H6D5fi6xgmmFi2BD8WmW7Du6k7SSFnds X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-31_02,2026-03-28_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 clxscore=1015 bulkscore=0 priorityscore=1501 malwarescore=0 spamscore=0 adultscore=0 impostorscore=0 phishscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603310093 On 3/31/2026 5:42 PM, Suzuki K Poulose wrote: > On 31/03/2026 10:26, James Clark wrote: >> >> >> On 31/03/2026 4:18 am, Jie Gan wrote: >>> Hi James, >>> >>> On 3/31/2026 9:29 AM, Jie Gan wrote: >>>> >>>> Hi James, >>>> >>>> On 3/30/2026 10:55 PM, James Clark wrote: >>>>> >>>>> >>>>> On 25/03/2026 3:10 am, Jie Gan wrote: >>>>>> Save the trace ID in drvdata during TPDM enablement and expose it >>>>>> to userspace to support trace data parsing. >>>>>> >>>>>> The TPDM device’s trace ID corresponds to the trace ID allocated >>>>>> to the connected TPDA device. >>>>>> >>>>>> Signed-off-by: Jie Gan >>>>>> --- >>>>>> Changes in v3: >>>>>> 1. Only allow user to read the traceid while the TPDM device is >>>>>> enabled. >>>>>> - Link to v2: https://lore.kernel.org/r/20260316-add-traceid-show- >>>>>> for- tpdm-v2-1-1dec2a67e4ed@oss.qualcomm.com >>>>>> >>>>>> Changes in V2: >>>>>> 1. Use sysfs_emit instead of sprintf. >>>>>> Link to V1 - https://lore.kernel.org/all/20260306-add-traceid- >>>>>> show- for-tpdm-v1-1-0658a8edb972@oss.qualcomm.com/ >>>>>> --- >>>>>>   drivers/hwtracing/coresight/coresight-tpdm.c | 34 ++++++++++++++ >>>>>> + + + + +++++++++- >>>>>>   drivers/hwtracing/coresight/coresight-tpdm.h |  2 ++ >>>>>>   2 files changed, 35 insertions(+), 1 deletion(-) >>>>>> >>>>>> diff --git a/drivers/hwtracing/coresight/coresight-tpdm.c b/ >>>>>> drivers/ hwtracing/coresight/coresight-tpdm.c >>>>>> index da77bdaad0a4..c8339b973bfc 100644 >>>>>> --- a/drivers/hwtracing/coresight/coresight-tpdm.c >>>>>> +++ b/drivers/hwtracing/coresight/coresight-tpdm.c >>>>>> @@ -481,7 +481,7 @@ static void __tpdm_enable(struct tpdm_drvdata >>>>>> *drvdata) >>>>>>   static int tpdm_enable(struct coresight_device *csdev, struct >>>>>> perf_event *event, >>>>>>                  enum cs_mode mode, >>>>>> -               __maybe_unused struct coresight_path *path) >>>>>> +               struct coresight_path *path) >>>>>>   { >>>>>>       struct tpdm_drvdata *drvdata = dev_get_drvdata(csdev- >>>>>> >dev.parent); >>>>>> @@ -497,6 +497,7 @@ static int tpdm_enable(struct coresight_device >>>>>> *csdev, struct perf_event *event, >>>>>>       } >>>>>>       __tpdm_enable(drvdata); >>>>>> +    drvdata->traceid = path->trace_id; >>>>>>       drvdata->enable = true; >>>>>>       spin_unlock(&drvdata->spinlock); >>>>>> @@ -693,6 +694,29 @@ static struct attribute_group tpdm_attr_grp = { >>>>>>       .attrs = tpdm_attrs, >>>>>>   }; >>>>>> +static ssize_t traceid_show(struct device *dev, >>>>>> +                struct device_attribute *attr, char *buf) >>>>>> +{ >>>>>> +    unsigned long val; >>>>>> +    struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent); >>>>>> + >>>>>> +    if (coresight_get_mode(drvdata->csdev) == CS_MODE_DISABLED) >>>>>> +        return -EINVAL; >>>>>> + >>>>>> +    val = drvdata->traceid; >>>>> >>>>> You probably need to take the coresight_mutex here otherwise you >>>>> could still return an invalid or stale value despite checking the >>>>> mode. >>>>> >>>> >>>> Acked. I have missed this potential race condition. >>>> >>>>> There might also be some value in it returning the last used trace >>>>> ID even if the mode isn't enabled anymore. Because you can still >>>>> read out of the sink after disabling, so it makes more sense for a >>>>> script to read it at that point rather than when it's enabled. >>>>> Also, you probably don't want to be doing other things in your >>>>> script in the point between enabling and disabling. >>>> >>>> That's making sense. I shouldnt add such restriction for the read >>>> process. >>>> >>> >>> I missed one point in last message. >>> >>> Is that acceptable to export the coresight_mutex from the core module? >>> Currently, the coresight_mutex is used within the module only. >>> >>> Thanks, >>> Jie >>> >> >> If the plan is to only check for non-zero trace ID and not check the >> mode any more then you don't need to lock. Maybe lets see what Suzuki >> thinks about returning the last trace ID though as it was his idea to >> add -EINVAL. >> > > I think there is value in reading out the traceid that was used. Also, > I assume TPDM is always connected to a TPDA port and the traceID > wouldn't change, ever ? > Yes. > I am happy with the proposal > James also agrees this proposal in other thread. I will submit a new patch to address it. ABI document missed in this patch also, I will add it in the new patch. Thanks, Jie > Suzuki > >>>> Scenarios for reading: >>>> 1. device is enabled -> trace ID is valid >>>> 2. device is enabled then disabled -> trace ID is valid for the last >>>> trace event >>>> 3. device is never enabled -> invalid trace ID (value 0) >>>> >>>> we only need to check the validation of the trace ID. >>>> >>>> mutex_lock(&coresight_mutex); >>>> val = drvdata->traceid; >>>> mutex_unlock(&coresight_mutex); >>>> >>>> if (!val) >>>>      return -EINVAL; >>>> >>>> return sysfs_emit(buf, "%#lx\n", val); >>>> >>>> Thanks, >>>> Jie >>>> >>>>> >>>>>> +    return sysfs_emit(buf, "%#lx\n", val); >>>>>> +} >>>>>> +static DEVICE_ATTR_RO(traceid); >>>>>> + >>>>>> +static struct attribute *traceid_attrs[] = { >>>>>> +    &dev_attr_traceid.attr, >>>>>> +    NULL, >>>>>> +}; >>>>>> + >>>>>> +static struct attribute_group traceid_attr_grp = { >>>>>> +    .attrs = traceid_attrs, >>>>>> +}; >>>>>> + >>>>>>   static ssize_t dsb_mode_show(struct device *dev, >>>>>>                    struct device_attribute *attr, >>>>>>                    char *buf) >>>>>> @@ -1367,6 +1391,12 @@ static const struct attribute_group >>>>>> *tpdm_attr_grps[] = { >>>>>>       &tpdm_cmb_patt_grp, >>>>>>       &tpdm_cmb_msr_grp, >>>>>>       &tpdm_mcmb_attr_grp, >>>>>> +    &traceid_attr_grp, >>>>>> +    NULL, >>>>>> +}; >>>>>> + >>>>>> +static const struct attribute_group *static_tpdm_attr_grps[] = { >>>>>> +    &traceid_attr_grp, >>>>>>       NULL, >>>>>>   }; >>>>>> @@ -1425,6 +1455,8 @@ static int tpdm_probe(struct device *dev, >>>>>> struct resource *res) >>>>>>       desc.access = CSDEV_ACCESS_IOMEM(base); >>>>>>       if (res) >>>>>>           desc.groups = tpdm_attr_grps; >>>>>> +    else >>>>>> +        desc.groups = static_tpdm_attr_grps; >>>>>>       drvdata->csdev = coresight_register(&desc); >>>>>>       if (IS_ERR(drvdata->csdev)) >>>>>>           return PTR_ERR(drvdata->csdev); >>>>>> diff --git a/drivers/hwtracing/coresight/coresight-tpdm.h b/ >>>>>> drivers/ hwtracing/coresight/coresight-tpdm.h >>>>>> index 2867f3ab8186..11da64e1ade8 100644 >>>>>> --- a/drivers/hwtracing/coresight/coresight-tpdm.h >>>>>> +++ b/drivers/hwtracing/coresight/coresight-tpdm.h >>>>>> @@ -300,6 +300,7 @@ struct cmb_dataset { >>>>>>    * @cmb         Specifics associated to TPDM CMB. >>>>>>    * @dsb_msr_num Number of MSR supported by DSB TPDM >>>>>>    * @cmb_msr_num Number of MSR supported by CMB TPDM >>>>>> + * @traceid    Trace ID of the path. >>>>>>    */ >>>>>>   struct tpdm_drvdata { >>>>>> @@ -313,6 +314,7 @@ struct tpdm_drvdata { >>>>>>       struct cmb_dataset    *cmb; >>>>>>       u32            dsb_msr_num; >>>>>>       u32            cmb_msr_num; >>>>>> +    u8            traceid; >>>>>>   }; >>>>>>   /* Enumerate members of various datasets */ >>>>>> >>>>>> --- >>>>>> base-commit: b84a0ebe421ca56995ff78b66307667b62b3a900 >>>>>> change-id: 20260316-add-traceid-show-for-tpdm-88d040651f00 >>>>>> >>>>>> Best regards, >>>>> >>>> >>> >> >