From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 185342E6CA6 for ; Mon, 30 Mar 2026 14:56:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774882565; cv=none; b=Pu8YAbFDmKmbNJW4bS52LHz2CdAVR0e2uOv9g+tDAa3RcfK/wmA9r9wrts81yBatHUOm/AvlsQ16C3u9aclUASzQO+LX2eRCHFHFwE59fVrTirRubnyWYaqyM4P5aqzm8YNR5ypTqNLPr2MuOnYzxIyh+pqHs4sQxElctlBp0CQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774882565; c=relaxed/simple; bh=UOlclpkhEyLEY8MsGt68WKTQFjXBf/N4c3gTayEx6pA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=CQ95FFANzm2rSxs3QIWk2DM6iP0ee0P08K9HO8NoQEtTAukxgXb9ij/BK6vs0T5tBIGko0ySpiO5bch6E0lHclPS4fQRKWbhvruBbcXLPrSdAD+A+1aNAU5e2UjLqmRf1LXoTeK8Es9AEv5n3E8s6Qt0kWgDoDZbWq/s+IScWTo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=jlyOLzht; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="jlyOLzht" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4852c9b4158so36184205e9.0 for ; Mon, 30 Mar 2026 07:56:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1774882561; x=1775487361; 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=kkL2TAQ2zVx+xhdN+T+r4owbwTSWJg58fFnUOF+33ks=; b=jlyOLzht/a/ZffEw4Vw2X1sqP8qgMHsLVrOwGfM5qpynavPixc2PuOmbDc+4EFR7bL zMbagBxx7MNLIgulGefba0YPAJCb09/ph+eG3RCTadxNUp83d04jPJmDLdJkgW6R3Y9g MpIDdLo+lW7Czanmb9Ic8DbMp+Nq7OguNXeAp8EzKcli7he3yMFlFf0j5PTMM9GEwzV3 GCrOpWtX3A0/SEdbPnh5FnQ2QhwPUusXzmZkI+GaiB4vg5ZUX7H66MxqDEml8niJ5eqU 0vojw0iJ1gSvkFBesZiY4DRRIgkF53ahJxKcgGkzm+EW71XrT0LQN4wtOoX0UsD6uBOr cg2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774882561; x=1775487361; 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=kkL2TAQ2zVx+xhdN+T+r4owbwTSWJg58fFnUOF+33ks=; b=WUHFUvyi4M+GmaDmB6Gs5bCU2lsjIpAj2SgD0Kzkowml7P3w4DPNc8EHyGykCnVY1k nEzaUCgS+nyiCt2FAAnxT77ii8HioSnrbLlZIgDkHYLAlqsVwHiY71rH+66bpfMjSixP rxLoNPdP7ijQ2lhwZs+5OMq5v9cVSp8dyZ5v6QdvcsYb0+S53JEw2dton9pA2V111vGt L+p+xJIMR3KuPQ52HdlUx26ZbWCC5I3TRGtMPQuoMRE6ETEXDhxNHeXD9uGaszyPNSTh U7P3AgUnx3ZpiFsWxE986Lu4GES/gDfiwnYWNgQH597unbY/arGVKd9zmJmyPXAnht4z Ut3w== X-Forwarded-Encrypted: i=1; AJvYcCUGkZlR2fgkUUxmyHRIFzlN2TOU81U/tXikumw6WVQ/AQh4YJq5xK8mf3zjie2VxhJyIYSkh89amuZZa2Q=@vger.kernel.org X-Gm-Message-State: AOJu0Yykc2LC145OPjm3tmbQQqI02FAbKfqLtbdzFsbxeGMvY8meI6O/ 8Sbmgh93SJQIWvNbbBj9yo89A1SPpeGpdJXKzfd4REpXgVp39k5txAaHOVDYkYnKXyS9p2nzEYY flBxvh00= X-Gm-Gg: ATEYQzxbcCi1Fk4D9NS/R598uG0zB58E98uggK8jJ0RKQKN43YhH9ORzwjlZK/OXik5 guPvl5zormqWvKj4Oml8PjUEsQk8IdpnLROzgyF8brViCi1hFg8OrYkiW6XurYDfQCV7QAZ3AkZ asIHcGOdG4nXOa7BFdXVy1GhaCZEm9zVPvXMtnNJAdwWFJlJI0VKxgsyt4JKc6fVJOK8X/RHpz5 AjLxUZ1dHwEw5Qq02/qVdxRu+bQwr8g7Ka52JjXYBVScafcOJ/jlu6wTrS8eEVzIvWX05kiiUry b505ciriELAVCsM4xEdVlr4LFQl9xZ+bgSZyUlepshOjD9Qeukkz7NJfb5TgkhgRWWfEyFzVdAF IqVg5fJiSUMGpdHdRGkPrB9lOCmZqUNPIfb7+hZ3/+dNjOMe9bi6IozThUQuev7yjFmwy8aI9Km x3nSqJ19K/zMjauTgCzfU9tJFt851p X-Received: by 2002:a05:600c:c8f:b0:487:21c7:2885 with SMTP id 5b1f17b1804b1-48727d45a8emr218972355e9.5.1774882561306; Mon, 30 Mar 2026 07:56:01 -0700 (PDT) Received: from [192.168.1.3] ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43cf2471ee2sm18669382f8f.29.2026.03.30.07.56.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Mar 2026 07:56:00 -0700 (PDT) Message-ID: <95610981-ad68-4a31-a776-27894b7bca59@linaro.org> Date: Mon, 30 Mar 2026 15:55:59 +0100 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: Jie Gan , Suzuki K Poulose 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> Content-Language: en-US From: James Clark In-Reply-To: <20260325-add-traceid-show-for-tpdm-v3-1-0eb836d4ec30@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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. 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. > + 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,