From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2443DC38A2D for ; Mon, 24 Oct 2022 10:32:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229817AbiJXKct (ORCPT ); Mon, 24 Oct 2022 06:32:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229634AbiJXKct (ORCPT ); Mon, 24 Oct 2022 06:32:49 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A599457212; Mon, 24 Oct 2022 03:32:46 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1EE022B; Mon, 24 Oct 2022 03:32:51 -0700 (PDT) Received: from [10.57.68.77] (unknown [10.57.68.77]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5CEC13F7B4; Mon, 24 Oct 2022 03:32:42 -0700 (PDT) Message-ID: Date: Mon, 24 Oct 2022 11:32:40 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: Re: [PATCH 5/9] coresight-tpdm: Add nodes to set trigger timestamp and type To: Tao Zhang , Mathieu Poirier , Alexander Shishkin , Konrad Dybcio , Mike Leach Cc: Jinlong Mao , Leo Yan , Greg Kroah-Hartman , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Tingwei Zhang , Yuanfang Zhang , Trilok Soni , Hao Zhang , linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org References: <1662626705-13097-1-git-send-email-quic_taozha@quicinc.com> <1662626705-13097-6-git-send-email-quic_taozha@quicinc.com> From: Suzuki K Poulose In-Reply-To: <1662626705-13097-6-git-send-email-quic_taozha@quicinc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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 > --- > 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