Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp436644rwd; Thu, 1 Jun 2023 02:16:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4MxG5oZwZUQqO1VAgFwoLMAoa2tmZYRWg90r+88GtTJFbWy7SkqUIntQwAkQhqjJsr3loJ X-Received: by 2002:a17:902:d50d:b0:1b0:6a10:1ba0 with SMTP id b13-20020a170902d50d00b001b06a101ba0mr7837094plg.44.1685611003264; Thu, 01 Jun 2023 02:16:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685611003; cv=none; d=google.com; s=arc-20160816; b=lQ/qsi1xWtjGRuB8MjGpt0iUckRhayg1NaVelEJhvBHrN2IJT1riR8EOQNcZh5Jjcw 2KZbgne+fjWMhIuwDSeYyu73PPiKaAu/A1XlvQd2AcO+N2Te63xmp6WxKBhU3QqWtchk SJgEajd/P05HNgY8Zl/o79pBLoyxbFEj8zOeA/n3UeQRp3gP20o4ZzBhVQ8q66OfJKVq fTS8QVLTZ7j9HQZ7ayRnWlPfzUj4bKk3c0kBOK2xkfKOdesSt6EA0ukULob+LbJJbNIT atD+ieFBbia1RMqgGNcQAIEYzzHqrqvdteoTHe2LJN/CGSGXla089mxfJm8EBq7uKTQz ha1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=dOb6pZY4mwSYOP4TALbu5vI6gq3e+P4Et7bhvlm2njs=; b=kSHssHNd8l1vobHLppwuBvn5yHDTC6fhYSj3Wq02CPozW32KEQZQpL17EOE5VNKwOV vFe0Va1N6uym2eEESz68aeTOR2xwB8cyXKE/c54IaDe66EW8uIAFOzMFLDpdSpUOtwjG BRLGhlTqNRI6gQ+eekvPOWZLZtTQK6lCLDgAB4Dwil6+cXHASaHoenO6NsEeTl+kzShe m1NYUnp0Nf/nTutYwTXa56lFwR+iuWXyKQ8RJxaUoNeyc129oPWf/O6nPj7mWGbD3ySt aEMWd9EwfFtCUV3EU3yxSLdGJfDyRQKoTJ4zsvYx/PUILv4/4AzNPhOU51Ws8yHBG2Cd QSUg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h12-20020a170902748c00b001ac9ab8539csi2409865pll.77.2023.06.01.02.16.29; Thu, 01 Jun 2023 02:16:43 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232607AbjFAJGF (ORCPT + 99 others); Thu, 1 Jun 2023 05:06:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232476AbjFAJGC (ORCPT ); Thu, 1 Jun 2023 05:06:02 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BE7E21B8; Thu, 1 Jun 2023 02:05:42 -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 9323C169C; Thu, 1 Jun 2023 02:06:02 -0700 (PDT) Received: from [10.57.22.124] (unknown [10.57.22.124]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 901053F663; Thu, 1 Jun 2023 02:05:14 -0700 (PDT) Message-ID: Date: Thu, 1 Jun 2023 10:05:13 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.11.1 Subject: Re: [PATCH v4 05/11] coresight-tpdm: Add nodes to set trigger timestamp and type To: Tao Zhang , Mathieu Poirier , Alexander Shishkin , Konrad Dybcio , Mike Leach , Rob Herring , Krzysztof Kozlowski Cc: Jinlong Mao , Leo Yan , Greg Kroah-Hartman , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Tingwei Zhang , Yuanfang Zhang , Trilok Soni , Hao Zhang , linux-arm-msm@vger.kernel.org, andersson@kernel.org References: <1682586037-25973-1-git-send-email-quic_taozha@quicinc.com> <1682586037-25973-6-git-send-email-quic_taozha@quicinc.com> From: Suzuki K Poulose In-Reply-To: <1682586037-25973-6-git-send-email-quic_taozha@quicinc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org On 27/04/2023 10:00, 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 > --- > .../ABI/testing/sysfs-bus-coresight-devices-tpdm | 24 ++++++ > drivers/hwtracing/coresight/coresight-tpdm.c | 95 ++++++++++++++++++++++ > 2 files changed, 119 insertions(+) > > diff --git a/Documentation/ABI/testing/sysfs-bus-coresight-devices-tpdm b/Documentation/ABI/testing/sysfs-bus-coresight-devices-tpdm > index 686bdde..77e67f2 100644 > --- a/Documentation/ABI/testing/sysfs-bus-coresight-devices-tpdm > +++ b/Documentation/ABI/testing/sysfs-bus-coresight-devices-tpdm > @@ -21,3 +21,27 @@ Description: > > Accepts only one value - 1. > 1 : Reset the dataset of the tpdm > + > +What: /sys/bus/coresight/devices//dsb_trig_type > +Date: March 2023 > +KernelVersion 6.3 This would need updating. We are not sure if this can make it to 6.5, with dependency on James' series. Fix this with 6.5 here and we can take a shot. > +Contact: Jinlong Mao (QUIC) , Tao Zhang (QUIC) > +Description: > + (Write) Set the trigger type of DSB tpdm. Read the trigger > + type of DSB tpdm. > + > + Accepts only one of the 2 values - 0 or 1. > + 0 : Set the DSB trigger type to false > + 1 : Set the DSB trigger type to true > + > +What: /sys/bus/coresight/devices//dsb_trig_ts > +Date: March 2023 > +KernelVersion 6.3 Same here > +Contact: Jinlong Mao (QUIC) , Tao Zhang (QUIC) > +Description: > + (Write) Set the trigger timestamp of DSB tpdm. Read the > + trigger timestamp of DSB tpdm. > + > + Accepts only one of the 2 values - 0 or 1. > + 0 : Set the DSB trigger type to false > + 1 : Set the DSB trigger type to true > diff --git a/drivers/hwtracing/coresight/coresight-tpdm.c b/drivers/hwtracing/coresight/coresight-tpdm.c > index 2e64cfd..14f4352 100644 > --- a/drivers/hwtracing/coresight/coresight-tpdm.c > +++ b/drivers/hwtracing/coresight/coresight-tpdm.c > @@ -20,6 +20,19 @@ > > DEFINE_CORESIGHT_DEVLIST(tpdm_devs, "tpdm"); > > +static umode_t tpdm_dsb_is_visible(struct kobject *kobj, > + struct attribute *attr, int n) minor nit: alignment ? > +{ > + struct device *dev = kobj_to_dev(kobj); > + struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent); > + > + if (drvdata) > + if (drvdata && (drvdata->datasets & TPDM_PIDR0_DS_DSB)) > + return attr->mode; Duplicate check for drvdata ? if (drvdata && (drvdata->datasets & TPDM_PIDR0_DS_DSB)) return attr->mode; > + > + return 0; > +} > + > static void tpdm_reset_datasets(struct tpdm_drvdata *drvdata) > { > if (drvdata->datasets & TPDM_PIDR0_DS_DSB) { > @@ -239,8 +252,90 @@ 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); > +} > + > +/* > + * Trigger type (boolean): > + * false - Disable trigger type. > + * true - Enable trigger type. > + */ > +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 & ~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); > +} > + > +/* > + * Trigger timestamp (boolean): > + * false - Disable trigger timestamp. > + * true - Enable trigger timestamp. > + */ > +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 & ~1UL)) > + 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, > }; > Rest looks fine to me Suzuki