Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp699407rdb; Sun, 3 Sep 2023 06:46:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHDAfHL1ttEkFRz+x3nzGIikUdp2vdFwrvgr1HGjl2391ha/lusOR8iNTdNuGKH07XsirvB X-Received: by 2002:a17:907:b1a:b0:9a1:c44d:4d37 with SMTP id h26-20020a1709070b1a00b009a1c44d4d37mr8101091ejl.19.1693748762077; Sun, 03 Sep 2023 06:46:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693748762; cv=none; d=google.com; s=arc-20160816; b=VQLpPBWFn0wdMpudJ3eJz90oaefXfCCps68X5I1XF9gWDp14DIslrK4KeoSHYAqUf3 d2wkOwk81MMU2WLbyPjLPYiFpt8tplZ1lYKJzZLsYCZNqRGhgy3eUl35WKzLaV4tiQkX qWAj8SCPF90ZLq0y6+MLIc4YAJmbKC+sZG30IGcjuBFB1FKAAaBtwsZPmTGlaybe5gH0 bjVTJ/MbUJxPhzgYsZl/xVjcDHp2M6ILiXb+0Xh84VnjBnsOUBAwFwd8K9vzW986JTK/ dEfDhlai3RpwAhfKu7/E4q92F2pwZsAHgmdQLyJ6EQA/NON399b2tdJ8Hs+Eob8YCgQa pqSQ== 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:references :cc:to:from:subject:user-agent:mime-version:date:message-id; bh=eNanyPgvBF1Bhf/MzX9AGUXZRuIGTYkBXcRHvNaBo8U=; fh=igPgRFDGt+ZnWuNHoB/jo4V9pFbxltHrDIBwAd666HM=; b=n8DRjMFaOZUnU9ycCPsOeFRxaKlFFn0FQVzUgCnHLWyuue7hjie4R+pV2iBju/4+fI +pJui8mCAS0OduhKlaS6qG+ItSjKErHHSZo+mFJmojcZr30Fm6vSS2mXR/iTLiZ8WBH8 OwCLFvuvcQj+MjadSYSkvUZFrL8/51y15HHYaD0jcrGAnjzDDsDemSEPJfA/Dg+CEWBI NqXx0wSYDDPlOpytRJRqfa6IIGWBAdCK8PEuGj16rbC0SWB2ppVi451rtYWchPNYLofP R2dD3fz9Klt8BxqcQMnzfKvleahJyF1MIY9BDcaehBq0HiLU9YnJUDy3hnCGpge+tuFI 2Gdg== 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 gz23-20020a170906f2d700b0098948181213si5100896ejb.399.2023.09.03.06.45.33; Sun, 03 Sep 2023 06:46:02 -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 S1349393AbjIAMWy (ORCPT + 99 others); Fri, 1 Sep 2023 08:22:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231340AbjIAMWw (ORCPT ); Fri, 1 Sep 2023 08:22:52 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id ED64FCFE for ; Fri, 1 Sep 2023 05:22:47 -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 2E428FEC; Fri, 1 Sep 2023 05:23:26 -0700 (PDT) Received: from [10.57.91.85] (unknown [10.57.91.85]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E8A653FBD2; Fri, 1 Sep 2023 05:22:45 -0700 (PDT) Message-ID: <134faf1d-d662-0e26-d9db-c98645ef6243@arm.com> Date: Fri, 1 Sep 2023 13:22:44 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: [PATCH V2] coresight: tmc: Make etr buffer mode user configurable from sysfs From: Suzuki K Poulose To: scclevenger@os.amperecomputing.com, Anshuman Khandual , linux-arm-kernel@lists.infradead.org Cc: Mike Leach , James Clark , Leo Yan , Alexander Shishkin , coresight@lists.linaro.org, linux-kernel@vger.kernel.org, Sudeep Holla References: <20230818082112.554638-1-anshuman.khandual@arm.com> <391951c3-7da9-3965-acf8-f3b31f822879@os.amperecomputing.com> <1b2a035c-489e-ace9-f851-c1ec157ff9fa@arm.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE 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 Hi Steve On 30/08/2023 17:04, Suzuki K Poulose wrote: > Cc: Sudeep > > Hi Steve > > On 28/08/2023 17:35, Steve Clevenger wrote: >> >> Hi Suzuki, >> >> On 8/27/2023 2:35 PM, Suzuki K Poulose wrote: >>> Hi Steve >>> >>> On 26/08/2023 01:14, Steve Clevenger wrote: >>>> >>>> Unfortunately, I tested with the original patch not [PATCH V2]. I've >>>> remedied this. My results below: >>>> >>>> [root@sut01sys-b212 linux]# cat >>>> /sys/devices/system/cpu/cpu123/ARMHC501\:23/tmc_etr35/buf_modes_available >>>> auto flat catu >>>> [root@sut01sys-b212 linux]# cat >>>> /sys/devices/system/cpu/cpu123/ARMHC501\:23/tmc_etr35/buf_mode_preferred >>>> auto >>>> [root@sut01sys-b212 linux]# echo "catu" > >>>> /sys/devices/system/cpu/cpu123/ARMHC501\:23/tmc_etr35/buf_mode_preferred >>>> [root@sut01sys-b212 linux]# cat >>>> /sys/devices/system/cpu/cpu123/ARMHC501\:23/tmc_etr35/buf_mode_preferred >>>> catu >>>> >>>> As with the V1 patch, auto defaults to catu. >>>> >>>> I expected to see tmc-sg (former default) as an available mode, but do >>>> not. As I recall, the buffer mode defaulted to ETR scatter-gather prior >>>> to this patch. Must this capability now be explicitly advertised? I've >>>> seen this done as "arm,scatter-gather" in device trees, but not used by >>>> Ampere. Perhaps someone can enlighten me. >>> >>> Yes, you must add that property to the TMC-ETR node (for both DT and >>> ACPI). In the past, almost all of the TMC-ETRs (except Juno board) >>> locked up the system while using the SG mode (due to the interconnect >>> issues, something to do with the transaction). Thus, we decided to >>> add a property explicitly enabling this for a given platform. >>> >>> When you mentioned, it was using TMC-ETR SG mode, how did you verify >>> this ? Please be aware that the table allocation code etc are shared >>> by both TMC-SG and CATU. >>> >> >> You might recall how this started. I had no way to test the CATU due to >> the order the ETR modes defaulted (Flat, ETR-SG, CATU). For test >> purposes, I programmatically swapped the ETR-SG/CATU order and could >> then verify CATU operation by the driver calling into CATU code. This > > So, were you using the DT based boot for the above runs ? > >> suggests Flat mode was bypassed, and the driver defaulted to ETR-SG >> prior to this hack. This didn't offer the user any control, hence my >> feature request. Note that most of the early Ampere self-hosted trace >> collection used ETR-SG. Now I can't select it. > > >> >> How is this property described in the ACPI? The "ACPI for CoreSight™ 1.1 >> Platform Design Document" (DEN0067) doesn't describe this. > > This is not specified in the ACPI platform design document. I can get > it fixed. Ideally we need a property describing that the scatter-gather > mode is safe to use. Looks like this is not straight forward copying of DT property. We are investigating this on our side and will get back to you. Suzuki > > DT uses "arm,scatter-gather" property [0] and this is what we now expect > in the ACPI based systems too. > > https://elixir.bootlin.com/linux/latest/source/Documentation/devicetree/bindings/arm/arm,coresight-tmc.yaml#:~:text=71-,72,-73 > > Does it sound fine ? > > Suzuki > >> >> Thanks, >> Steve >> >> >>> Kind regards >>> Suzuki >>> >>>> >>>> Steve C. >>>> >>>> On 8/23/2023 4:10 PM, Steve Clevenger wrote: >>>>> >>>>> Here's some quick feedback. My system shows two modes available; auto >>>>> catu >>>>> >>>>> etr_buf_mode_current is writable. I expected to see tmc-sg (former >>>>> default) listed in etr_buf_modes_available but it doesn't show up. >>>>> >>>>> Note that both the auto and catu etr_buf_mode_current settings default >>>>> to catu. My understanding is auto should revert to the default >>>>> behavior. >>>>> On my system the default was tmc-sg. >>>>> >>>>> More later. >>>>> >>>>> [root@sut01sys-b212 kernel]# cat >>>>> /sys/devices/system/cpu/cpu20/ARMHC501\:60/tmc_etr96/etr_buf_modes_available >>>>> >>>>> auto catu >>>>> [root@sut01sys-b212 kernel]# cat >>>>> /sys/devices/system/cpu/cpu20/ARMHC501\:60/tmc_etr96/etr_buf_mode_current >>>>> catu >>>>> [root@sut01sys-b212 kernel]# echo "catu" > >>>>> /sys/devices/system/cpu/cpu20/ARMHC501\:60/tmc_etr96/etr_buf_mode_current >>>>> [root@sut01sys-b212 kernel]# cat >>>>> /sys/devices/system/cpu/cpu20/ARMHC501\:60/tmc_etr96/etr_buf_mode_current >>>>> catu >>>>> >>>>> Steve C. >>>>> >>>>> >>>>> On 8/21/2023 12:40 PM, Steve Clevenger wrote: >>>>>> >>>>>> Hi Suzuki, >>>>>> >>>>>> I may be able to test it this week. You've already pointed me at the >>>>>> patch thread(s). The main holdup is I need to merge the 6.6 pending >>>>>> platform work in order to use the Ampere ACPI. I couldn't get these >>>>>> patches to apply directly to 6.4 last I tried. >>>>>> >>>>>> Steve C. >>>>>> >>>>>> On 8/18/2023 2:39 AM, Suzuki K Poulose wrote: >>>>>>> Cc: Steve >>>>>>> >>>>>>> Steve, >>>>>>> >>>>>>> Are you able to test this with CATU ? >>>>>>> >>>>>>> >>>>>>> On 18/08/2023 09:21, Anshuman Khandual wrote: >>>>>>>> Currently TMC-ETR automatically selects the buffer mode from all >>>>>>>> available >>>>>>>> methods in the following sequentially fallback manner - also in >>>>>>>> that >>>>>>>> order. >>>>>>>> >>>>>>>> 1. FLAT mode with or without IOMMU >>>>>>>> 2. TMC-ETR-SG (scatter gather) mode when available >>>>>>>> 3. CATU mode when available >>>>>>>> >>>>>>>> But this order might not be ideal for all situations. For >>>>>>>> example if >>>>>>>> there >>>>>>>> is a CATU connected to ETR, it may be better to use TMC-ETR scatter >>>>>>>> gather >>>>>>>> method, rather than CATU. But hard coding such order changes will >>>>>>>> prevent >>>>>>>> us from testing or using a particular mode. This change provides >>>>>>>> following >>>>>>>> new sysfs tunables for the user to control TMC-ETR buffer mode >>>>>>>> explicitly, >>>>>>>> if required. This adds following new sysfs files for buffer mode >>>>>>>> selection >>>>>>>> purpose explicitly in the user space. >>>>>>>> >>>>>>>> /sys/bus/coresight/devices/tmc_etr/buf_modes_available >>>>>>>> /sys/bus/coresight/devices/tmc_etr/buf_mode_preferred >>>>>>>> >>>>>>>> $ cat buf_modes_available >>>>>>>> auto flat tmc-sg catu    ------------------> Supported TMC-ETR >>>>>>>> buffer >>>>>>>> modes >>>>>>>> >>>>>>>> $ echo catu > buf_mode_preferred   -------> Explicit buffer mode >>>>>>>> request >>>>>>>> >>>>>>>> But explicit user request has to be within supported ETR buffer >>>>>>>> modes >>>>>>>> only. >>>>>>>> These sysfs interface files are exclussive to ETR, and hence these >>>>>>>> are >>>>>>>> not >>>>>>>> available for other TMC devices such as ETB or ETF etc. >>>>>>>> >>>>>>>> A new auto' mode (i.e ETR_MODE_AUTO) has been added to help >>>>>>>> fallback >>>>>>>> to the >>>>>>>> existing default behaviour, when user provided preferred buffer >>>>>>>> mode >>>>>>>> fails. >>>>>>>> ETR_MODE_FLAT and ETR_MODE_AUTO are always available as preferred >>>>>>>> modes. >>>>>>>> >>>>>>>> Cc: Suzuki K Poulose >>>>>>>> Cc: Mike Leach >>>>>>>> Cc: James Clark >>>>>>>> Cc: Leo Yan >>>>>>>> Cc: Alexander Shishkin >>>>>>>> Cc: coresight@lists.linaro.org >>>>>>>> Cc: linux-arm-kernel@lists.infradead.org >>>>>>>> Cc: linux-kernel@vger.kernel.org >>>>>>>> Signed-off-by: Anshuman Khandual >>>>>>>> --- >>>>>>>> This applies on v6.5-rc6 >>>>>>>> >>>>>>>> Changes in V2: >>>>>>>> >>>>>>>> - Renamed sysfs file etr_buf_modes_available as buf_modes_available >>>>>>>> - Renamed sysfs file buf_mode_current as buf_mode_preferred >>>>>>>> - Renamed etr_supports_flat_mode() as etr_can_use_flat_mode() >>>>>>>> - Renamed coresight_tmc_groups[] as coresight_etf_groups[] >>>>>>>> - Reused coresight_tmc_group[] for trigger_cntr and buffer_size >>>>>>>> - Fallback trying ETR_MODE_AUTO when user preferred mode fails >>>>>>>> - Moved ETR sysfs details into coresight-tmc-etr.c >>>>>>>> - Dropped etr_can_use_flat_mode() check while offering >>>>>>>> ETR_MODE_FLAT >>>>>>>> in sysfs >>>>>>>> - Moved struct etr_buf_hw inside coresight-tmc-etr.c >>>>>>>> - Moved get_etr_buf_hw() and etr_can_use_flat_mode() inside >>>>>>>> coresight-tmc-etr.c >>>>>>>> - Updated month in >>>>>>>> Documentation/ABI/testing/sysfs-bus-coresight-devices-tmc >>>>>>>> >>>>>>>> Changes in V1: >>>>>>>> >>>>>>>> https://lore.kernel.org/all/20230728084837.276551-1-anshuman.khandual@arm.com/ >>>>>>>> >>>>>>>>     .../testing/sysfs-bus-coresight-devices-tmc   |  16 +++ >>>>>>>>     .../hwtracing/coresight/coresight-tmc-core.c  |  15 ++- >>>>>>>>     .../hwtracing/coresight/coresight-tmc-etr.c   | 111 >>>>>>>> ++++++++++++++++-- >>>>>>>>     drivers/hwtracing/coresight/coresight-tmc.h   |   3 + >>>>>>>>     4 files changed, 131 insertions(+), 14 deletions(-) >>>>>>> >>>>>>> >>>>>>> Looks good to me. >>>>>>> >>>>>>> Suzuki >>>>>>> >>>>>>> >>> >