Re: [PATCH 5/9] coresight-tpdm: Add nodes to set trigger timestamp and type

Suzuki K Poulose
2022-10-24T10:32:56Z

On 08/09/2022 09:45, Tao Zhang wrote:
> 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>
> ---
> drivers/hwtracing/coresight/coresight-tpdm.c | 90 ++++++++++++++++++++++++++++
> 1 file changed, 90 insertions(+)
>
> diff --git a/drivers/hwtracing/coresight/coresight-tpdm.c b/drivers/hwtracing/coresight/coresight-tpdm.c
> index 74cc653..fae9963 100644
> --- a/drivers/hwtracing/coresight/coresight-tpdm.c
> +++ b/drivers/hwtracing/coresight/coresight-tpdm.c
> @@ -232,8 +232,98 @@ static struct attribute_group tpdm_attr_grp = {
> .attrs = tpdm_attrs,
> };
>
> +static ssize_t dsb_trig_type_show(struct device *dev,
> + struct device_attribute *attr,
> + char *buf)
> +{
> + struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent);
> +
> + if (!(drvdata->datasets & TPDM_PIDR0_DS_DSB))
> + return -EPERM;
> +
> + return scnprintf(buf, PAGE_SIZE, "%u\n",
> + (unsigned int)drvdata->dsb->trig_type);
> +}
> +
> +/*
> + * value 0: set trigger type as enablement
> + * value 1: set trigger type as disablement
> + */
> +static ssize_t dsb_trig_type_store(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf,
> + size_t size)
> +{
> + struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent);
> + unsigned long val;
> +
> + if ((kstrtoul(buf, 16, &val)) || val < 0 || val > 1)
> + return -EINVAL;
> + if (!(drvdata->datasets & TPDM_PIDR0_DS_DSB))
> + return -EPERM;
> +
> + spin_lock(&drvdata->spinlock);
> + if (val)
> + drvdata->dsb->trig_type = true;
> + else
> + drvdata->dsb->trig_type = false;
> + spin_unlock(&drvdata->spinlock);
> + return size;
> +}
> +static DEVICE_ATTR_RW(dsb_trig_type);
> +
> +static ssize_t dsb_trig_ts_show(struct device *dev,
> + struct device_attribute *attr,
> + char *buf)
> +{
> + struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent);
> +
> + if (!(drvdata->datasets & TPDM_PIDR0_DS_DSB))
> + return -EPERM;
> +
> + return scnprintf(buf, PAGE_SIZE, "%u\n",
> + (unsigned int)drvdata->dsb->trig_ts);
> +}
> +
> +/*
> + * value 0: set trigger timestamp as enablement
> + * value 1: set trigger timestamp as disablement
> + */
> +static ssize_t dsb_trig_ts_store(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf,
> + size_t size)
> +{
> + struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent);
> + unsigned long val;
> +
> + if ((kstrtoul(buf, 16, &val)) || val < 0 || val > 1)
> + return -EINVAL;
> + if (!(drvdata->datasets & TPDM_PIDR0_DS_DSB))
> + return -EPERM;
> +
> + spin_lock(&drvdata->spinlock);
> + if (val)
> + drvdata->dsb->trig_ts = true;
> + else
> + drvdata->dsb->trig_ts = false;
> + spin_unlock(&drvdata->spinlock);
> + return size;
> +}
> +static DEVICE_ATTR_RW(dsb_trig_ts);
> +static struct attribute *tpdm_dsb_attrs[] = {
> + &dev_attr_dsb_trig_ts.attr,
> + &dev_attr_dsb_trig_type.attr,
> + NULL,
> +};
> +
> +static struct attribute_group tpdm_dsb_attr_grp = {
> + .attrs = tpdm_dsb_attrs,
> +};
> +

Please could we hide the "DSB" related knobs, if the
the Data sets are missing using is_visible() hook ?

Suzuki