Skip to content

Commit c821b93

Browse files
Tao ZhangSuzuki K Poulose
authored andcommitted
coresight-tpdm: Add nodes to set trigger timestamp and type
The nodes are needed to set or show the trigger timestamp and trigger type. This change is to add these nodes to achieve these function. Signed-off-by: Tao Zhang <quic_taozha@quicinc.com> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Link: https://lore.kernel.org/r/1695882586-10306-8-git-send-email-quic_taozha@quicinc.com
1 parent 126f008 commit c821b93

2 files changed

Lines changed: 117 additions & 0 deletions

File tree

Documentation/ABI/testing/sysfs-bus-coresight-devices-tpdm

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,25 @@ Description:
2121

2222
Accepts only one value - 1.
2323
1 : Reset the dataset of the tpdm
24+
25+
What: /sys/bus/coresight/devices/<tpdm-name>/dsb_trig_type
26+
Date: March 2023
27+
KernelVersion 6.7
28+
Contact: Jinlong Mao (QUIC) <quic_jinlmao@quicinc.com>, Tao Zhang (QUIC) <quic_taozha@quicinc.com>
29+
Description:
30+
(RW) Set/Get the trigger type of the DSB for tpdm.
31+
32+
Accepts only one of the 2 values - 0 or 1.
33+
0 : Set the DSB trigger type to false
34+
1 : Set the DSB trigger type to true
35+
36+
What: /sys/bus/coresight/devices/<tpdm-name>/dsb_trig_ts
37+
Date: March 2023
38+
KernelVersion 6.7
39+
Contact: Jinlong Mao (QUIC) <quic_jinlmao@quicinc.com>, Tao Zhang (QUIC) <quic_taozha@quicinc.com>
40+
Description:
41+
(RW) Set/Get the trigger timestamp of the DSB for tpdm.
42+
43+
Accepts only one of the 2 values - 0 or 1.
44+
0 : Set the DSB trigger type to false
45+
1 : Set the DSB trigger type to true

drivers/hwtracing/coresight/coresight-tpdm.c

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ static bool tpdm_has_dsb_dataset(struct tpdm_drvdata *drvdata)
2525
return (drvdata->datasets & TPDM_PIDR0_DS_DSB);
2626
}
2727

28+
static umode_t tpdm_dsb_is_visible(struct kobject *kobj,
29+
struct attribute *attr, int n)
30+
{
31+
struct device *dev = kobj_to_dev(kobj);
32+
struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent);
33+
34+
if (drvdata && tpdm_has_dsb_dataset(drvdata))
35+
return attr->mode;
36+
37+
return 0;
38+
}
39+
2840
static void tpdm_reset_datasets(struct tpdm_drvdata *drvdata)
2941
{
3042
if (tpdm_has_dsb_dataset(drvdata)) {
@@ -232,8 +244,91 @@ static struct attribute_group tpdm_attr_grp = {
232244
.attrs = tpdm_attrs,
233245
};
234246

247+
static ssize_t dsb_trig_type_show(struct device *dev,
248+
struct device_attribute *attr, char *buf)
249+
{
250+
struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent);
251+
252+
return sysfs_emit(buf, "%u\n",
253+
(unsigned int)drvdata->dsb->trig_type);
254+
}
255+
256+
/*
257+
* Trigger type (boolean):
258+
* false - Disable trigger type.
259+
* true - Enable trigger type.
260+
*/
261+
static ssize_t dsb_trig_type_store(struct device *dev,
262+
struct device_attribute *attr,
263+
const char *buf,
264+
size_t size)
265+
{
266+
struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent);
267+
unsigned long val;
268+
269+
if ((kstrtoul(buf, 0, &val)) || (val & ~1UL))
270+
return -EINVAL;
271+
272+
spin_lock(&drvdata->spinlock);
273+
if (val)
274+
drvdata->dsb->trig_type = true;
275+
else
276+
drvdata->dsb->trig_type = false;
277+
spin_unlock(&drvdata->spinlock);
278+
return size;
279+
}
280+
static DEVICE_ATTR_RW(dsb_trig_type);
281+
282+
static ssize_t dsb_trig_ts_show(struct device *dev,
283+
struct device_attribute *attr,
284+
char *buf)
285+
{
286+
struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent);
287+
288+
return sysfs_emit(buf, "%u\n",
289+
(unsigned int)drvdata->dsb->trig_ts);
290+
}
291+
292+
/*
293+
* Trigger timestamp (boolean):
294+
* false - Disable trigger timestamp.
295+
* true - Enable trigger timestamp.
296+
*/
297+
static ssize_t dsb_trig_ts_store(struct device *dev,
298+
struct device_attribute *attr,
299+
const char *buf,
300+
size_t size)
301+
{
302+
struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent);
303+
unsigned long val;
304+
305+
if ((kstrtoul(buf, 0, &val)) || (val & ~1UL))
306+
return -EINVAL;
307+
308+
spin_lock(&drvdata->spinlock);
309+
if (val)
310+
drvdata->dsb->trig_ts = true;
311+
else
312+
drvdata->dsb->trig_ts = false;
313+
spin_unlock(&drvdata->spinlock);
314+
return size;
315+
}
316+
static DEVICE_ATTR_RW(dsb_trig_ts);
317+
318+
static struct attribute *tpdm_dsb_attrs[] = {
319+
&dev_attr_dsb_trig_ts.attr,
320+
&dev_attr_dsb_trig_type.attr,
321+
NULL,
322+
};
323+
324+
static struct attribute_group tpdm_dsb_attr_grp = {
325+
.attrs = tpdm_dsb_attrs,
326+
.is_visible = tpdm_dsb_is_visible,
327+
};
328+
235329
static const struct attribute_group *tpdm_attr_grps[] = {
236330
&tpdm_attr_grp,
331+
&tpdm_dsb_attr_grp,
237332
NULL,
238333
};
239334

0 commit comments

Comments
 (0)