Message ID | 1674114105-16651-6-git-send-email-quic_taozha@quicinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp194657wrn; Wed, 18 Jan 2023 23:45:52 -0800 (PST) X-Google-Smtp-Source: AMrXdXvan35iPKHOkqwPIYOQ/Q7weUEIuZhOm9E1v3NeZqrifVuINdUkGHfMV5rEoAxwMbYZnyUn X-Received: by 2002:a17:907:a804:b0:7a6:5b50:a32c with SMTP id vo4-20020a170907a80400b007a65b50a32cmr11823789ejc.12.1674114352489; Wed, 18 Jan 2023 23:45:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674114352; cv=none; d=google.com; s=arc-20160816; b=VXiEeQRWv+evEMsmsgMCC1yLxLDPY60wZP6Mk0C3RGl9VhHLWZBUZtQev9WuixqaUv cMbsgzu+su4Evg12+kovOFs3OLwu10qLCjEO6/SxOTtFYbv5/A1Rnju7n7Wif1T3ufNm 6Ta+fVojewJLDeFfJmgUHgaG15bgxjbIe5blYYU7Yqb02PEYexBk6LPFoluwhhlSd4HR xtOW8Qe3r9okhOG9h1X8w0gti6DInlaVuTP5HL1ixbMt+d/b5SgQ3jT2w7y3dbFNSoH1 DF6P8vAO/X6OxwtitYTsCbh9OZoaBtIRUQHiaPXWb80NeHOhl073syRSUZhBLNXBuY9s nKEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=k7LYnikwlSaLFWFXV5cNGEg+kRUy4NRHYcSCRF1ljFw=; b=KHuZSkagk3QyzJAV4hTc/HM+kWy861Y3LRDVUAV7gSpWa/wa/4bHMCb5ilPXENnyiY i41K5usdnT6+tfksxLjigV+FHudN6SLVK2PRsZKjGWhdW3CNLdhdl6Zoc91pXv7aNvbm cWTefcYKk6stUhGNbjz228l3nKaSFzFFbOp8FHTBI4k00Evp8OVdf/xfuG6e84WPS6qo sUTOHce12/CJ7ORLrCAqOMTH3ziNxDygLik/Aeoa7vB8tdgLQXRVLw4ZJBcwS8EM6DWv Fuk31asujZn05wLSK3jUF+5NXX+Xc+gtbYyFUyKTqIGAYOI5kTxloxcji0x/5P9YOdJs /yMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=DjDZ8P97; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg9-20020a170907a40900b008650ce2979asi27321822ejc.544.2023.01.18.23.45.28; Wed, 18 Jan 2023 23:45:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=DjDZ8P97; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230100AbjASHoV (ORCPT <rfc822;pfffrao@gmail.com> + 99 others); Thu, 19 Jan 2023 02:44:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230120AbjASHmx (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 19 Jan 2023 02:42:53 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AA7A6794C; Wed, 18 Jan 2023 23:42:48 -0800 (PST) Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30J5muHl001560; Thu, 19 Jan 2023 07:42:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=k7LYnikwlSaLFWFXV5cNGEg+kRUy4NRHYcSCRF1ljFw=; b=DjDZ8P97hcyRyz0Cn9ADhMMY+e2fVw87b/L8GNJZYFU1d5YFjyIPsoC6MAE3s8r6vBnJ LoFAsWaM1MyAZvb/iRVvc3XyutyX8athUM4BThiaxwvuOlBseqn2ANGWyMAycZ0GlNYY xH30w+ZM9otr/eUwVPAjPSQnPbv11d1xdVxDbBN1V915hEkJfejbFczh+UBLDFhMEant VRueJBXzK29LxP4luc8/ckDvJZRIIShTsJBkhbVV6dHMfLW11lopmQ7cdh/e47Xjb7iK jNjrhhDCsuhbSaFVCAmeWLBwgEpRWLXmc5+Xv4zlIm1B0eGIciL4L7w7IZt1aLxTqgkX CQ== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3n6vjbgp7m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 19 Jan 2023 07:42:34 +0000 Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 30J7gXqr029435 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 19 Jan 2023 07:42:33 GMT Received: from taozha-gv.qualcomm.com (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Wed, 18 Jan 2023 23:42:29 -0800 From: Tao Zhang <quic_taozha@quicinc.com> To: Mathieu Poirier <mathieu.poirier@linaro.org>, Suzuki K Poulose <suzuki.poulose@arm.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Konrad Dybcio <konradybcio@gmail.com>, Mike Leach <mike.leach@linaro.org>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org> CC: Tao Zhang <quic_taozha@quicinc.com>, Jinlong Mao <quic_jinlmao@quicinc.com>, Leo Yan <leo.yan@linaro.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, <coresight@lists.linaro.org>, <linux-arm-kernel@lists.infradead.org>, <linux-kernel@vger.kernel.org>, <devicetree@vger.kernel.org>, Tingwei Zhang <quic_tingweiz@quicinc.com>, Yuanfang Zhang <quic_yuanfang@quicinc.com>, Trilok Soni <quic_tsoni@quicinc.com>, Hao Zhang <quic_hazha@quicinc.com>, <linux-arm-msm@vger.kernel.org>, <bjorn.andersson@linaro.org>, Tao Zhang <taozha@qti.qualcomm.com> Subject: [PATCH v2 5/9] coresight-tpdm: Add nodes to set trigger timestamp and type Date: Thu, 19 Jan 2023 15:41:41 +0800 Message-ID: <1674114105-16651-6-git-send-email-quic_taozha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1674114105-16651-1-git-send-email-quic_taozha@quicinc.com> References: <1674114105-16651-1-git-send-email-quic_taozha@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 6S_FxHChmwfz2YBF7zC1RFKIKZBh-0FL X-Proofpoint-GUID: 6S_FxHChmwfz2YBF7zC1RFKIKZBh-0FL X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-18_05,2023-01-18_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 clxscore=1015 phishscore=0 malwarescore=0 mlxscore=0 spamscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301190062 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755436131432508500?= X-GMAIL-MSGID: =?utf-8?q?1755436131432508500?= |
Series |
Add support to configure TPDM DSB subunit
|
|
Commit Message
Tao Zhang
Jan. 19, 2023, 7:41 a.m. UTC
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: Tao Zhang <taozha@qti.qualcomm.com> --- drivers/hwtracing/coresight/coresight-tpdm.c | 97 ++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+)
Comments
On 19/01/2023 07:41, 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> > Signed-off-by: Tao Zhang <taozha@qti.qualcomm.com> > --- > drivers/hwtracing/coresight/coresight-tpdm.c | 97 ++++++++++++++++++++++++++++ > 1 file changed, 97 insertions(+) > > diff --git a/drivers/hwtracing/coresight/coresight-tpdm.c b/drivers/hwtracing/coresight/coresight-tpdm.c > index c29d667d..1dbb6c4 100644 > --- a/drivers/hwtracing/coresight/coresight-tpdm.c > +++ b/drivers/hwtracing/coresight/coresight-tpdm.c > @@ -20,6 +20,22 @@ > > DEFINE_CORESIGHT_DEVLIST(tpdm_devs, "tpdm"); > > +static umode_t tpdm_dsb_is_visible(struct kobject *kobj, > + struct attribute *attr, int n) > +{ > + struct device *dev = kobj_to_dev(kobj); > + struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent); > + > + if (drvdata) { > + if (drvdata->datasets & TPDM_PIDR0_DS_DSB) > + return attr->mode; > + else > + return 0; > + } if (drvdata && drvdata->dsb) return attr->mode; return 0; ? > + > + return 0; > +} > + > static void tpdm_enable_dsb(struct tpdm_drvdata *drvdata) > { > u32 val; > @@ -241,8 +257,89 @@ 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); > + > + return sysfs_emit(buf, "%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, 0, &val)) || val < 0 || val > 1) val < 0 check here doesn't help on an unsigned variable. may be (val & ~1UL) ? > + return -EINVAL; > + > + 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); > + > + return sysfs_emit(buf, "%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, 0, &val)) || val < 0 || val > 1) same here. > + return -EINVAL; > + > + 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, > + .is_visible = tpdm_dsb_is_visible, > +}; > + > static const struct attribute_group *tpdm_attr_grps[] = { > &tpdm_attr_grp, > + &tpdm_dsb_attr_grp, > NULL, > }; > Suzuki
On 19/01/2023 07:41, 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> > Signed-off-by: Tao Zhang <taozha@qti.qualcomm.com> > --- > drivers/hwtracing/coresight/coresight-tpdm.c | 97 ++++++++++++++++++++++++++++ > 1 file changed, 97 insertions(+) > > diff --git a/drivers/hwtracing/coresight/coresight-tpdm.c b/drivers/hwtracing/coresight/coresight-tpdm.c > index c29d667d..1dbb6c4 100644 > --- a/drivers/hwtracing/coresight/coresight-tpdm.c > +++ b/drivers/hwtracing/coresight/coresight-tpdm.c > @@ -20,6 +20,22 @@ > > +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, > + .is_visible = tpdm_dsb_is_visible, > +}; > + > static const struct attribute_group *tpdm_attr_grps[] = { > &tpdm_attr_grp, > + &tpdm_dsb_attr_grp, > NULL, > }; > Please also add documentation of the new sysfs handles under : Documentation/ABI/testing/sysfs-bus-coresight-devices-tpdm* Suzuki
Hi Suzuki, 在 2/28/2023 7:29 PM, Suzuki K Poulose 写道: > On 19/01/2023 07:41, 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> >> Signed-off-by: Tao Zhang <taozha@qti.qualcomm.com> >> --- >> drivers/hwtracing/coresight/coresight-tpdm.c | 97 >> ++++++++++++++++++++++++++++ >> 1 file changed, 97 insertions(+) >> >> diff --git a/drivers/hwtracing/coresight/coresight-tpdm.c >> b/drivers/hwtracing/coresight/coresight-tpdm.c >> index c29d667d..1dbb6c4 100644 >> --- a/drivers/hwtracing/coresight/coresight-tpdm.c >> +++ b/drivers/hwtracing/coresight/coresight-tpdm.c >> @@ -20,6 +20,22 @@ >> DEFINE_CORESIGHT_DEVLIST(tpdm_devs, "tpdm"); >> +static umode_t tpdm_dsb_is_visible(struct kobject *kobj, >> + struct attribute *attr, int n) >> +{ >> + struct device *dev = kobj_to_dev(kobj); >> + struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent); >> + >> + if (drvdata) { >> + if (drvdata->datasets & TPDM_PIDR0_DS_DSB) >> + return attr->mode; >> + else >> + return 0; >> + } > > if (drvdata && drvdata->dsb) > return attr->mode; > > return 0; > > ? Sure, I will update this in the next version of patch. > > >> + >> + return 0; >> +} >> + >> static void tpdm_enable_dsb(struct tpdm_drvdata *drvdata) >> { >> u32 val; >> @@ -241,8 +257,89 @@ 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); >> + >> + return sysfs_emit(buf, "%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, 0, &val)) || val < 0 || val > 1) > > val < 0 check here doesn't help on an unsigned variable. > > may be (val & ~1UL) ? Sure, I will update this in the next version of the patch. > >> + return -EINVAL; >> + >> + 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); >> + >> + return sysfs_emit(buf, "%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, 0, &val)) || val < 0 || val > 1) > > same here. > >> + return -EINVAL; >> + >> + 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, >> + .is_visible = tpdm_dsb_is_visible, >> +}; >> + >> static const struct attribute_group *tpdm_attr_grps[] = { >> &tpdm_attr_grp, >> + &tpdm_dsb_attr_grp, >> NULL, >> }; >> > > Suzuki > Best, Tao
Hi Suzuki, 在 2/28/2023 7:32 PM, Suzuki K Poulose 写道: > On 19/01/2023 07:41, 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> >> Signed-off-by: Tao Zhang <taozha@qti.qualcomm.com> >> --- >> drivers/hwtracing/coresight/coresight-tpdm.c | 97 >> ++++++++++++++++++++++++++++ >> 1 file changed, 97 insertions(+) >> >> diff --git a/drivers/hwtracing/coresight/coresight-tpdm.c >> b/drivers/hwtracing/coresight/coresight-tpdm.c >> index c29d667d..1dbb6c4 100644 >> --- a/drivers/hwtracing/coresight/coresight-tpdm.c >> +++ b/drivers/hwtracing/coresight/coresight-tpdm.c >> @@ -20,6 +20,22 @@ > > >> +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, >> + .is_visible = tpdm_dsb_is_visible, >> +}; >> + >> static const struct attribute_group *tpdm_attr_grps[] = { >> &tpdm_attr_grp, >> + &tpdm_dsb_attr_grp, >> NULL, >> }; > > > Please also add documentation of the new sysfs handles under : > > Documentation/ABI/testing/sysfs-bus-coresight-devices-tpdm* > Sure, I will add the descriptions of new sysfs in the next of patch series. > Suzuki > Best, Tao
diff --git a/drivers/hwtracing/coresight/coresight-tpdm.c b/drivers/hwtracing/coresight/coresight-tpdm.c index c29d667d..1dbb6c4 100644 --- a/drivers/hwtracing/coresight/coresight-tpdm.c +++ b/drivers/hwtracing/coresight/coresight-tpdm.c @@ -20,6 +20,22 @@ DEFINE_CORESIGHT_DEVLIST(tpdm_devs, "tpdm"); +static umode_t tpdm_dsb_is_visible(struct kobject *kobj, + struct attribute *attr, int n) +{ + struct device *dev = kobj_to_dev(kobj); + struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent); + + if (drvdata) { + if (drvdata->datasets & TPDM_PIDR0_DS_DSB) + return attr->mode; + else + return 0; + } + + return 0; +} + static void tpdm_enable_dsb(struct tpdm_drvdata *drvdata) { u32 val; @@ -241,8 +257,89 @@ 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); + + return sysfs_emit(buf, "%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, 0, &val)) || val < 0 || val > 1) + return -EINVAL; + + 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); + + return sysfs_emit(buf, "%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, 0, &val)) || val < 0 || val > 1) + return -EINVAL; + + 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, + .is_visible = tpdm_dsb_is_visible, +}; + static const struct attribute_group *tpdm_attr_grps[] = { &tpdm_attr_grp, + &tpdm_dsb_attr_grp, NULL, };