Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2178226rdd; Fri, 12 Jan 2024 01:31:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IG1nk0yQMHfLTVq//lIIfzFzX/XROKIZzHAfTXhxDq+/yRFFLZFGqClP/raBeR9xLvz/kht X-Received: by 2002:a17:906:2b0b:b0:a2a:fd7d:4aa6 with SMTP id a11-20020a1709062b0b00b00a2afd7d4aa6mr1044097ejg.56.1705051862482; Fri, 12 Jan 2024 01:31:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705051862; cv=none; d=google.com; s=arc-20160816; b=SbrIJCfLdspW39MQzPX4vlVS8qligpVS42l4ZIyxWmtLKi45vGdkbPwemaw8EHA7Y5 +drdTqY8haTFgwa1lAmQHisBRD2UZIAwD/Z4vaWmdFD/jQEpYLluctAJoeFFhCT6yjQs dBnm9WrD6uMBOCcMpw4tU5pI6ZuYqCpdmdRA4mxTggdsMbQQ0Yp5ATYyO4FVlGXhXe+A mbZNMNxSHndkNyvy9BhcNbOUd2nwR6djFCtOYoyh5Wj1v70JPIlREpQh7glslTEOhknD fqeJ9xHHnthyL8vm3KM2/mCJyYcIQ4vdxXfjlZRsYnP7DSv3ooDJNBgf6ESx15h2OUG+ UXyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=4EJpwh44AZKMkFc7d1X3AcYomOBxErqSSEaFMDPfuCM=; fh=mbscLyIbiqeKhAAvOgq1FD2y7FAkicSP1DMkcnlFuFE=; b=RNrqYjab0gZU4Pd3R/31EGIAsNsElFHL7ESciJKB+lASylxC0IfNKhoK9TFUIwfJ66 mNHxw14A0/mOMTZPhSOBxt3CLxcp08OS3fp1oUQ0XRYCiQuBYRf1e5YuIUJLYorcnl1d ejaeliZiKORzbl8jJfeKjUTI8gcu4ZZStF+migXsdpw+dlcFbGiHoKHgcvYFZmxsJYsQ 83dhMo95jDs+7PcHRU1kAe2I2uW8aDhNIikjfojJ6zGeV1EOGYeOFxB9Guh0R0wxp0yX 2ACdH45PewVKKeRRZqah6s1ri/rpIRiWSMQzGrwXMceRmoMKPcFXueQLA83clBo9ZK0z EeGQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-24484-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24484-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id i26-20020a170906251a00b00a2af3048ed1si1209813ejb.873.2024.01.12.01.31.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 01:31:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-24484-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-24484-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24484-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id ED2481F22356 for ; Fri, 12 Jan 2024 09:30:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C952F5732F; Fri, 12 Jan 2024 09:29:22 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 93B4B5EE68; Fri, 12 Jan 2024 09:29:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 EAFE01FB; Fri, 12 Jan 2024 01:30:04 -0800 (PST) Received: from [10.1.197.1] (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6D9833F64C; Fri, 12 Jan 2024 01:29:16 -0800 (PST) Message-ID: Date: Fri, 12 Jan 2024 09:29:15 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 6/8] coresight-tpdm: Add timestamp control register support for the CMB Content-Language: en-US To: Tao Zhang , Mathieu Poirier , Alexander Shishkin , Konrad Dybcio , Mike Leach , Rob Herring , Krzysztof Kozlowski Cc: Jinlong Mao , 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 , Song Chai , linux-arm-msm@vger.kernel.org, andersson@kernel.org References: <1700533494-19276-1-git-send-email-quic_taozha@quicinc.com> <1700533494-19276-7-git-send-email-quic_taozha@quicinc.com> <797eadf6-2708-47ad-a61f-88bb0d4fcf28@quicinc.com> <4ae81e28-1791-4128-860f-eb6a83ea3742@arm.com> <616eba43-678c-4bc9-be7e-7b766e8d7c29@quicinc.com> <3cb948f9-2c62-4078-a936-3d7531ed5a2b@quicinc.com> From: Suzuki K Poulose In-Reply-To: <3cb948f9-2c62-4078-a936-3d7531ed5a2b@quicinc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 12/01/2024 02:42, Tao Zhang wrote: > > On 1/8/2024 6:42 PM, Suzuki K Poulose wrote: >> On 05/01/2024 07:49, Tao Zhang wrote: >>> >>> On 12/30/2023 5:39 PM, Suzuki K Poulose wrote: >>>> On 25/12/2023 01:55, Tao Zhang wrote: >>>>> >>>>> On 12/20/2023 7:07 PM, Suzuki K Poulose wrote: >>>>>> On 20/12/2023 09:51, Tao Zhang wrote: >>>>>>> >>>>>>> On 12/19/2023 9:51 PM, Suzuki K Poulose wrote: >>>>>>>> On 19/12/2023 02:43, Tao Zhang wrote: >>>>>>>>> >>>>>>>>> On 12/18/2023 6:46 PM, Suzuki K Poulose wrote: >>>>>>>>>> On 21/11/2023 02:24, Tao Zhang wrote: .. >>>>>>>>>>>                     char *buf) >>>>>>>>>>>   { >>>>>>>>>>>       struct tpdm_drvdata *drvdata = >>>>>>>>>>> dev_get_drvdata(dev->parent); >>>>>>>>>>> +    ssize_t size = 0; >>>>>>>>>>>   -    return sysfs_emit(buf, "%u\n", >>>>>>>>>>> -             (unsigned int)drvdata->dsb->patt_ts); >>>>>>>>>>> +    if (tpdm_has_dsb_dataset(drvdata)) >>>>>>>>>>> +        size = sysfs_emit(buf, "%u\n", >>>>>>>>>>> +                 (unsigned int)drvdata->dsb->patt_ts); >>>>>>>>>>> + >>>>>>>>>>> +    if (tpdm_has_cmb_dataset(drvdata)) >>>>>>>>>>> +        size = sysfs_emit(buf, "%u\n", >>>>>>>>>>> +                 (unsigned int)drvdata->cmb->patt_ts); >>>>>>>>>> >>>>>>>>>> Why does this need to show two values ? This must only show >>>>>>>>>> ONE value. >>>>>>>>>> How you deduce that might be based on the availability of the >>>>>>>>>> feature >>>>>>>>>> set. Or store the TS value in the drvdata and use that instead >>>>>>>>>> for >>>>>>>>>> controlling CMB/DSB. >>>>>>>>> >>>>>>>>> Since both of CMB/DSB need to have "enable_ts" SysFs file, can >>>>>>>>> I separate them >>>>>>>> >>>>>>>> The question really is, do we need fine grained control. i.e., >>>>>>>> >>>>>>>> enable TS for DSB but not for CMB or vice versa. >>>>>>>> >>>>>>>> I am not an expert on the usage scenario of the same. So, if >>>>>>>> you/Qcomm >>>>>>>> thinks the users need separate, fine grained control for timestamp >>>>>>>> for the DSB and CMB, then yes, follow your recommendation below. >>>>>>>> i.e., tpdm.../dsb_patt/enable_ts >>>>>>>> >>>>>>>>> as "enable_dsb_ts" and "enable_cmb_ts"? The path will be like >>>>>>>>> below. >>>>>>>>> >>>>>>>>> tpdm0/dsb_patt/enable_dsb_ts >>>>>>>> >>>>>>>> You don't need enable_dsb_ts. It could be "enable_ts" >>>>>>>> >>>>>>>>> >>>>>>>>> tpdm1/cmb_patt/enable_cmb_ts >>>>>>>>> >>>>>>>>> Is this design appropriate? >>>>>>>> >>>>>>>> >>>>>>>> Otherwise, stick to single enable_ts : which enables the ts for >>>>>>>> both >>>>>>>> CMB/DSB. And it only ever show one value : 0 (TS is disabled for >>>>>>>> both >>>>>>>> CMB/DSB) 1 : TS enabled for both. >>>>>>> >>>>>>> We have a very special case, such as the TPDM supporting both CMB >>>>>>> and >>>>>>> >>>>>>> DSB datasets. Although this case is very rare, it still exists. >>>>>>> >>>>>>> Can I use the data bit to instruct whether timestamp is enabled >>>>>>> for CMB/DSB or not? For example, >>>>>>> >>>>>>> size = sysfs_emit(buf, "%u\n", >>>>>>>                  (unsigned int)(drvdata->dsb->patt_ts << 1 | >>>>>>> drvdata->cmb->patt_ts)); >>>>>>> >>>>>>> Thus, this value can instruct the following situations. >>>>>>> >>>>>>> 0 - TS is disabled for both CMB/DSB >>>>>>> >>>>>>> 1 - TS is enabled for CMB >>>>>>> >>>>>>> 2 - TS is enabled for DSB >>>>>>> >>>>>>> 3 - TS is enabled for both >>>>>>> >>>>>>> Is this approach acceptable? >>>>>>> >>>>>> >>>>>> No, please stick to separate controls for TS. Do not complicate >>>>>> the user interface. >>>>>> >>>>>> i.e., >>>>>> tpdm0/dsb_patt/enable_ts >>>>>> tpdm0/cmb_patt/enable_ts >>>>> >>>>> We need to be able to control/show dsb and cmb timestamp enablement >>>>> independently. >>>>> >>>>> Can we achieve this requirement if we use a sysfs file with the >>>>> same name? >>>> >>>> They are independent and in their respective directory (group) for >>>> CMB and DSB. What am I missing ? >>>> e.g., if you want to enable TS for DSB, you do : >>>> >>>> $ echo 1 > dsb_patt/enable_ts >>>> >>>> And that only works for DSB not for CMB. >>> >>> We have a special case that the TPDM supports both DSB and CMB >>> dataset. In this special case, when we >>> >>> issue this command to enable timestamp, it will call enable_ts_store >>> API, right? >>> >>>      if (tpdm_has_dsb_dataset(drvdata)) >>>          drvdata->dsb->patt_ts = !!val; >>> >>>      if (tpdm_has_cmb_dataset(drvdata)) >>>          drvdata->cmb->patt_ts = !!val; >> >> I don't understand. If they both are under different subgroups, why >> should they be conflicting ? Are you not able to distinguish them, when >>  you creat those attributes ? i.e., create two different "attributes" ? > > Yes, although some TPDMs can support both CMB dataset and DSB dataset, > we need to configure them separately > > in some scenarios. Based on your suggestion, I want to use the following > approach to implement it. > > See below. > >> >> See below. >> >>> Since this special TPDM supports both DSB and CMB dataset, both DSB >>> patt_ts and CMB patt_ts will be set >>> >>> in this case even if I only configure the file in the DSB directory, >>> right? >>> >>> This is the problem we have now. >>> >> >> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>>> + >>>>>>>>>>> +    return size; >>>>>>>>>>>   } >>>>>>>>>>>     /* >>>>>>>>>>> @@ -715,8 +755,13 @@ static ssize_t enable_ts_store(struct >>>>>>>>>>> device *dev, >>>>>>>>>>>           return -EINVAL; >>>>>>>>>>>         spin_lock(&drvdata->spinlock); >>>>>>>>>>> -    drvdata->dsb->patt_ts = !!val; >>>>>>>>>>> +    if (tpdm_has_dsb_dataset(drvdata)) >>>>>>>>>>> +        drvdata->dsb->patt_ts = !!val; >>>>>>>>>>> + >>>>>>>>>>> +    if (tpdm_has_cmb_dataset(drvdata)) >>>>>>>>>>> +        drvdata->cmb->patt_ts = !!val; >>>>>>>>>>>       spin_unlock(&drvdata->spinlock); >>>>>>>>>>> + >>>>>>>>>>>       return size; >>>>>>>>>>>   } >>>>>>>>>>>   static DEVICE_ATTR_RW(enable_ts); >> >> Do not overload the same for both DSB and CMB. Create one for each in >> DSB and CMB ? They could share the same show/store routines, but could >> be done with additional variable to indicate which attribute they are >> controlling. Like the other attributes, using dev_ext_attribute or such. > > New approach below, please help review to see if it is acceptable? > > #define tpdm_patt_enable_ts_rw(name, mem)                \ >     (&((struct tpdm_dataset_attribute[]) {            \ >        {                                \ >         __ATTR(name, 0644, enable_ts_show,        \ >         enable_ts_store),        \ >         mem,                            \ >        }                                \ >     })[0].attr.attr) > > > #define DSB_PATT_ENABLE_TS                    \ >         tpdm_patt_enable_ts_rw(enable_ts,        \ >         DSB_PATT) > > > #define CMB_PATT_ENABLE_TS                    \ >         tpdm_patt_enable_ts_rw(enable_ts,        \ >         CMB_PATT) > > > static ssize_t enable_ts_show(struct device *dev, >                   struct device_attribute *attr, >                   char *buf) > { >     struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent); >     struct tpdm_dataset_attribute *tpdm_attr = >         container_of(attr, struct tpdm_dataset_attribute, attr); >     ssize_t size = 0; > >     if (tpdm_attr->mem == DSB_PATT) { >         size = sysfs_emit(buf, "%u\n", >                  (unsigned int)drvdata->dsb->patt_ts); >     } else if (tpdm_attr->mem == CMB_PATT) { >         size = sysfs_emit(buf, "%u\n", >                 (unsigned int)drvdata->cmb->patt_ts); >     } else >         return -EINVAL; > >     return size; > } > > static ssize_t enable_ts_store(struct device *dev, >                    struct device_attribute *attr, >                    const char *buf, >                    size_t size) > { >     struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent); >     struct tpdm_dataset_attribute *tpdm_attr = >         container_of(attr, struct tpdm_dataset_attribute, attr); >     unsigned long val; > >     if ((kstrtoul(buf, 0, &val)) || (val & ~1UL)) >         return -EINVAL; > >     spin_lock(&drvdata->spinlock); >     if (tpdm_attr->mem == DSB_PATT) { >         drvdata->dsb->patt_ts = !!val; >     } else if (tpdm_attr->mem == CMB_PATT) { >         drvdata->cmb->patt_ts = !!val; >     } else >         return -EINVAL; >     spin_unlock(&drvdata->spinlock); > >     return size; > } > > Yes, that is what I had in mind. Thanks Suzuki > Best, > > Tao > >> >> >> Suzuki >>