Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7398298rwd; Tue, 6 Jun 2023 10:07:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Ju0vFiFaHDspS64NbJftoeLx3UwvrjTJ/XdBL/NvrGj9RQgmDVU30eu4ALVY61wrTOj1J X-Received: by 2002:a17:903:22c3:b0:1b0:3df1:c293 with SMTP id y3-20020a17090322c300b001b03df1c293mr2994550plg.45.1686071268106; Tue, 06 Jun 2023 10:07:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686071268; cv=none; d=google.com; s=arc-20160816; b=TJcZ18OtZEkaxMA0nojrjFhjZeMGVUMy2cHTODxWXd0hU//s3iv4pyxzo8RItHKB0g LknO7Vb2dcl2S9JH/gdLtqlRpAuDCil1UzoM0thIpS1+rC12qQ9VNi8J/CtSutWofNUf 7nnkLaHJ5ehQ4oS0FpNpVYqpqf8EKbkpNUay0e7Lm73Rh8V/kyzbXozGZXkA3MHbcICz RkW2V8uKMK1jKrn1ielZH/1rzm8nSgr99Na8hjbQMGoMptkhJqYqnlQxfGVokqfHVS4i 4AWDRNXxTSKeFPQhYHtADE9KkjDjmx5iKY/Kb5AR5B78vi4aIwl2O6IsmJMg69uQsNGj igWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=Xk9yB0lwhVDKHSg18qIhc5ZDEWbZLqqAkxY9Pt3XlzE=; b=enqViHO0OSAbVMkbuJ1WvyfdC652stxGnPdgyms86zSkO8pMJnFoR4kxkdgsN4gTRm a0lRqdsW06s5i/MSS7fzmPbyJA6n2uKuEpIKYm7nB0O5PqIjzTyFEznCCnfJVe88U8fl Gdp9M0ON1msKcEgAoSrd+ZHSJBI5VYMkBi/4p7Su0z7TSxrzE38j6NguQG1Vv3Nlf9in B46QqWLmOBn7tGc2NgudcgQjZjeKhUD12mQMABDOrhFxW5wk6660dQhlfTC9SeWJUxDi zXYV1fmgxEJ3lZKkFBR/uWI/uGAMltPUSZJhY4insb2NT6FXYIJrfZP/i1lxPLCFU8ja TwgA== 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s15-20020a170902b18f00b001ac4e2d2b58si1903436plr.112.2023.06.06.10.07.31; Tue, 06 Jun 2023 10:07:48 -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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237902AbjFFQql (ORCPT + 99 others); Tue, 6 Jun 2023 12:46:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233619AbjFFQqj (ORCPT ); Tue, 6 Jun 2023 12:46:39 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C8B3E62; Tue, 6 Jun 2023 09:46:38 -0700 (PDT) Received: from lhrpeml500005.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4QbGXL5b9Hz688hZ; Wed, 7 Jun 2023 00:44:18 +0800 (CST) Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 6 Jun 2023 17:46:35 +0100 Date: Tue, 6 Jun 2023 17:46:35 +0100 From: Jonathan Cameron To: Yicong Yang CC: , , , , , , , , , , Subject: Re: [PATCH v4 3/5] hwtracing: hisi_ptt: Export available filters through sysfs Message-ID: <20230606174635.0000078b@Huawei.com> In-Reply-To: <20230606142244.10939-4-yangyicong@huawei.com> References: <20230606142244.10939-1-yangyicong@huawei.com> <20230606142244.10939-4-yangyicong@huawei.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.227.76] X-ClientProxiedBy: lhrpeml100001.china.huawei.com (7.191.160.183) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, 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 Tue, 6 Jun 2023 22:22:42 +0800 Yicong Yang wrote: > From: Yicong Yang > > The PTT can only filter the traced TLP headers by the Root Ports or the > Requester ID of the Endpoint, which are located on the same PCIe core of > the PTT device. The filter value used is derived from the BDF number of > the supported Root Port or the Endpoint. It's not friendly enough for the > users since it requires the user to be familiar enough with the platform > and calculate the filter value manually. > > This patch export the available filters through sysfs. Each available > filters is presented as an individual file with the name of the BDF > number of the related PCIe device. The files are created under > $(PTT PMU dir)/available_root_port_filters and > $(PTT PMU dir)/available_requester_filters respectively. The filter > value can be known by reading the related file. > > Then the users can easily know the available filters for trace and get > the filter values without calculating. > > Signed-off-by: Yicong Yang Two minor tweaks suggested inline. With those tidied up Reviewed-by: Jonathan Cameron > --- > .../ABI/testing/sysfs-devices-hisi_ptt | 50 +++++ > Documentation/trace/hisi-ptt.rst | 6 + > drivers/hwtracing/ptt/hisi_ptt.c | 205 ++++++++++++++++++ > drivers/hwtracing/ptt/hisi_ptt.h | 14 ++ > 4 files changed, 275 insertions(+) > > diff --git a/Documentation/ABI/testing/sysfs-devices-hisi_ptt b/Documentation/ABI/testing/sysfs-devices-hisi_ptt > index 82de6d710266..10df63568df9 100644 > --- a/Documentation/ABI/testing/sysfs-devices-hisi_ptt > +++ b/Documentation/ABI/testing/sysfs-devices-hisi_ptt > @@ -59,3 +59,53 @@ Description: (RW) Control the allocated buffer watermark of outbound packets. > The available tune data is [0, 1, 2]. Writing a negative value > will return an error, and out of range values will be converted > to 2. The value indicates a probable level of the event. > + > +What: /sys/devices/hisi_ptt_/root_port_filters > +Date: May 2023 > +KernelVersion: 6.5 > +Contact: Yicong Yang > +Description: This directory contains the files providing the PCIe Root Port filters > + information used for PTT trace. Each file is named after the supported > + Root Port device name ::.. > + > + See the description of the "filter" in Documentation/trace/hisi-ptt.rst > + for more information. > + > +What: /sys/devices/hisi_ptt_/root_port_filters/multiselect > +Date: May 2023 > +KernelVersion: 6.5 > +Contact: Yicong Yang > +Description: (Read) Indicates if this kind of filter can be selected at the same > + time as others filters, or must be used on it's own. Call out meaning of 1 and 0 for these two cases. > + > +static int hisi_ptt_init_filter_attributes(struct hisi_ptt *hisi_ptt) > +{ > + struct hisi_ptt_filter_desc *filter; > + int ret; > + > + mutex_lock(&hisi_ptt->filter_lock); > + > + /* > + * Register the reset callback in the first stage. In reset we traverse > + * the filters list to remove the sysfs attributes so the callback alone the callback can be (alone got left and shouldn't have been. I wasn't clear in previous feedback) > + * can be called safely even without below filter attributes creation. > + */ > + ret = devm_add_action(&hisi_ptt->pdev->dev, > + hisi_ptt_remove_all_filter_attributes, > + hisi_ptt); > + if (ret) > + goto out; > + > + list_for_each_entry(filter, &hisi_ptt->port_filters, list) { > + ret = hisi_ptt_create_filter_attr(hisi_ptt, filter); > + if (ret) > + goto out; > + } > + > + list_for_each_entry(filter, &hisi_ptt->req_filters, list) { > + ret = hisi_ptt_create_filter_attr(hisi_ptt, filter); > + if (ret) > + goto out; > + } > + > + hisi_ptt->sysfs_inited = true; > +out: > + mutex_unlock(&hisi_ptt->filter_lock); > + return ret; > +}