Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1897037rwd; Fri, 2 Jun 2023 01:33:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7RbXpFVp4SNZTU+n/n9Udb4p3OnSrbfNah8+af+EOCDzOEx/sEZr6qQT5/NwXPyDmdybn3 X-Received: by 2002:a17:902:d4c1:b0:1a6:9762:6eed with SMTP id o1-20020a170902d4c100b001a697626eedmr1735752plg.22.1685694787883; Fri, 02 Jun 2023 01:33:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685694787; cv=none; d=google.com; s=arc-20160816; b=se14srp49iqMX9DECxApDlo+uPM7cIjmXgWP6CqBNG7n8m4U5PNVkVKW3eJ0ZhI4hl 88PcyRupNdawZUzJLk/cbV/bxPD+3ac5sYWOLIdPWAwX4aCFNxzaFxXns3DzDWQ9mCfF /Z1H2AxMdjwY47hyjbmB7/wHSnAgWbOfTjOOSygR2vZPSqHzkhNow51zuh0IEFp/ksH9 BNn9l+GdM6bcJcvS5jPcD9uMfrlSXIThjuzVVOMBxkGDAiyGCzXAckmAs1ZDN1Ofpcfo Fx3xISAcm387UCcumBc3l+EdpeX4T/R1NMSewuI/7W0ySDFR5Grh4vy1Jjb2I9TpKgNP ZTTQ== 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=qIpbAnwIYMkgqE4E4JNbwhTo6iKZlQqFAAy7CofVCe4=; b=GHVPh8xkVSR75ZA5fildNMOU3z/WYer6MTYbLAYGYdPMY7dtk8FX4DORSCscH2TBBr 6v97eZt4YH5qXeZwg2gVKaZN1Ru+GrIP9sTM59LzNvDG4ATnPtu/xg3BNylUt4mYddTU VZ1bIpN7KdGgVju6kWjU58B2nds8JjA3Uvf/blWsrPHiu9k1s+BV8PzQ2XS6Qfke0jW8 k0Fp/lAJ8E+vFNe0HIN1L1f0Rthq6oWrnaJ39N3Cq8YOb77mrr+UfC4ladOXevjuYPI2 p8YX2IQBiSRrWhmTXvqLBd1DzHcK5eWHv2E8Bu8JRVfCx9fFFmYiHzdD4G1im0LF6iEz j6mA== 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 p5-20020a170902bd0500b001b0191881efsi580359pls.37.2023.06.02.01.32.53; Fri, 02 Jun 2023 01:33:07 -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 S234108AbjFBI02 (ORCPT + 99 others); Fri, 2 Jun 2023 04:26:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234532AbjFBIZz (ORCPT ); Fri, 2 Jun 2023 04:25:55 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3459D1B6; Fri, 2 Jun 2023 01:25:30 -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 C91F41063; Fri, 2 Jun 2023 01:26:14 -0700 (PDT) Received: from [10.57.22.125] (unknown [10.57.22.125]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AA7D83F67D; Fri, 2 Jun 2023 01:25:26 -0700 (PDT) Message-ID: <222b86c9-2a6f-cb9f-8803-406a724614c7@arm.com> Date: Fri, 2 Jun 2023 09:25:25 +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 06/11] coresight-tpdm: Add node to set dsb programming mode 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-7-git-send-email-quic_taozha@quicinc.com> <4e413a50-001d-cfbf-99a4-7e612f44ed38@arm.com> <053da70b-3d01-a3e5-4703-4e5cf23831ed@quicinc.com> From: Suzuki K Poulose In-Reply-To: <053da70b-3d01-a3e5-4703-4e5cf23831ed@quicinc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 02/06/2023 03:58, Tao Zhang wrote: > > On 6/1/2023 5:23 PM, Suzuki K Poulose wrote: >> On 27/04/2023 10:00, Tao Zhang wrote: >>> Add node to set and show programming mode for TPDM DSB subunit. >>> Once the DSB programming mode is set, it will be written to the >>> register DSB_CR. >>> >>> Signed-off-by: Tao Zhang >>> --- >>>   .../ABI/testing/sysfs-bus-coresight-devices-tpdm   | 15 ++++++ >>>   drivers/hwtracing/coresight/coresight-tpdm.c       | 62 >>> ++++++++++++++++++++++ >>>   drivers/hwtracing/coresight/coresight-tpdm.h       | 16 ++++++ >>>   3 files changed, 93 insertions(+) >>> >>> diff --git >>> a/Documentation/ABI/testing/sysfs-bus-coresight-devices-tpdm >>> b/Documentation/ABI/testing/sysfs-bus-coresight-devices-tpdm >>> index 77e67f2..348e167 100644 >>> --- a/Documentation/ABI/testing/sysfs-bus-coresight-devices-tpdm >>> +++ b/Documentation/ABI/testing/sysfs-bus-coresight-devices-tpdm >>> @@ -45,3 +45,18 @@ Description: >>>           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_mode >>> +Date:        March 2023 >>> +KernelVersion    6.3 >>> +Contact:    Jinlong Mao (QUIC) , Tao Zhang >>> (QUIC) >>> +Description: >>> +        (Write) Set the mode of DSB tpdm. Read the mode of DSB >>> +        tpdm. >>> + >>> +        Accepts the value needs to be greater than 0. What data >>> +        bits do is listed below. >>> +        Bit[0:1] : Test mode control bit for choosing the inputs. >>> +        Bit[3] : Set to 0 for low performance mode. >>> +                 Set to 1 for high performance mode. >>> +        Bit[4:8] : Select byte lane for high performance mode. >>> diff --git a/drivers/hwtracing/coresight/coresight-tpdm.c >>> b/drivers/hwtracing/coresight/coresight-tpdm.c >>> index 14f4352..1bacaa5 100644 >>> --- a/drivers/hwtracing/coresight/coresight-tpdm.c >>> +++ b/drivers/hwtracing/coresight/coresight-tpdm.c >>> @@ -4,6 +4,7 @@ >>>    */ >>>     #include >>> +#include >>>   #include >>>   #include >>>   #include >>> @@ -43,6 +44,32 @@ static void tpdm_reset_datasets(struct >>> tpdm_drvdata *drvdata) >>>       } >>>   } >>>   +static void set_dsb_test_mode(struct tpdm_drvdata *drvdata, u32 *val) >>> +{ >>> +    u32 mode; >>> + >>> +    mode = TPDM_DSB_MODE_TEST(drvdata->dsb->mode); >>> +    *val &= ~TPDM_DSB_TEST_MODE; >>> +    *val |= FIELD_PREP(TPDM_DSB_TEST_MODE, mode); >>> +} >>> + >>> +static void set_dsb_hpsel_mode(struct tpdm_drvdata *drvdata, u32 *val) >>> +{ >>> +    u32 mode; >>> + >>> +    mode = TPDM_DSB_MODE_HPBYTESEL(drvdata->dsb->mode); >>> +    *val &= ~TPDM_DSB_HPSEL; >>> +    *val |= FIELD_PREP(TPDM_DSB_HPSEL, mode); >>> +} >>> + >>> +static void set_dsb_perf_mode(struct tpdm_drvdata *drvdata, u32 *val) >>> +{ >>> +    if (drvdata->dsb->mode & TPDM_DSB_MODE_PERF) >>> +        *val |= TPDM_DSB_CR_MODE; >>> +    else >>> +        *val &= ~TPDM_DSB_CR_MODE; >>> +} >>> + >>>   static void set_trigger_type(struct tpdm_drvdata *drvdata, u32 *val) >>>   { >>>       if (drvdata->dsb->trig_type) >>> @@ -64,6 +91,12 @@ static void tpdm_enable_dsb(struct tpdm_drvdata >>> *drvdata) >>>       writel_relaxed(val, drvdata->base + TPDM_DSB_TIER); >>>         val = readl_relaxed(drvdata->base + TPDM_DSB_CR); >>> +    /* Set the test accurate mode */ >>> +    set_dsb_test_mode(drvdata, &val); >>> +    /* Set the byte lane for high-performance mode */ >>> +    set_dsb_hpsel_mode(drvdata, &val); >>> +    /* Set the performance mode */ >>> +    set_dsb_perf_mode(drvdata, &val); >>>       /* Set trigger type */ >>>       set_trigger_type(drvdata, &val); >>>       /* Set the enable bit of DSB control register to 1 */ >>> @@ -252,6 +285,34 @@ static struct attribute_group tpdm_attr_grp = { >>>       .attrs = tpdm_attrs, >>>   }; >>>   +static ssize_t dsb_mode_show(struct device *dev, >>> +                  struct device_attribute *attr, >>> +                  char *buf) >>> +{ >>> +    struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent); >>> + >>> +    return sysfs_emit(buf, "%lx\n", >>> +             (unsigned long)drvdata->dsb->mode); >>> +} >>> + >>> +static ssize_t dsb_mode_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) >>> +        return -EINVAL; >>> + >>> +    spin_lock(&drvdata->spinlock); >>> +    drvdata->dsb->mode = val & TPDM_MODE_ALL; >>> +    spin_unlock(&drvdata->spinlock); >>> +    return size; >>> +} >>> +static DEVICE_ATTR_RW(dsb_mode); >>> + >>>   static ssize_t dsb_trig_type_show(struct device *dev, >>>                        struct device_attribute *attr, char *buf) >>>   { >>> @@ -323,6 +384,7 @@ static ssize_t dsb_trig_ts_store(struct device *dev, >>>   static DEVICE_ATTR_RW(dsb_trig_ts); >>>     static struct attribute *tpdm_dsb_attrs[] = { >>> +    &dev_attr_dsb_mode.attr, >>>       &dev_attr_dsb_trig_ts.attr, >>>       &dev_attr_dsb_trig_type.attr, >>>       NULL, >>> diff --git a/drivers/hwtracing/coresight/coresight-tpdm.h >>> b/drivers/hwtracing/coresight/coresight-tpdm.h >>> index 68f33bd..79df07e 100644 >>> --- a/drivers/hwtracing/coresight/coresight-tpdm.h >>> +++ b/drivers/hwtracing/coresight/coresight-tpdm.h >>> @@ -15,11 +15,25 @@ >>>     /* Enable bit for DSB subunit */ >>>   #define TPDM_DSB_CR_ENA        BIT(0) >>> +/* Enable bit for DSB subunit perfmance mode */ >>> +#define TPDM_DSB_CR_MODE        BIT(1) >>>   /* Enable bit for DSB subunit trigger type */ >>>   #define TPDM_DSB_CR_TRIG_TYPE        BIT(12) >>> + >>>   /* Enable bit for DSB subunit trigger timestamp */ >>>   #define TPDM_DSB_TIER_XTRIG_TSENAB        BIT(1) >>>   +/* DSB programming modes */ >>> +/* Test mode control bit*/ >>> +#define TPDM_DSB_MODE_TEST(val)    (val & GENMASK(1, 0)) >>> +/* Perforceman mode */ >> >> minor nit: typo ^^ > I will update this in the next patch series. >> >>> +#define TPDM_DSB_MODE_PERF        BIT(3) >>> +/* High performance mode */ >>> +#define TPDM_DSB_MODE_HPBYTESEL(val)    (val & GENMASK(8, 4)) >>> +#define TPDM_MODE_ALL            (0xFFFFFFF) >> >> GENMASK(27, 0) ? >> >> Also, why do we cover bits 27-0 ? > > The TPDM mode is only represented by [0:8]bits. > > Can I replace it with "#define TPDM_DSB_MODE(val)    (VAL & GENMASK(8, > 0))"? #define TPDM_DSB_MODE_MASK GENMASK(8, 0) ? Suzuki