Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp585620rwn; Thu, 15 Sep 2022 03:34:24 -0700 (PDT) X-Google-Smtp-Source: AA6agR7VfhYyX/Iwf3k4tTL0UNSBXTkmMpFLB+ShEYq2PDYjrbTW4DlTtEYZcttOvNAzkQfekDvN X-Received: by 2002:a63:2356:0:b0:434:4395:88f3 with SMTP id u22-20020a632356000000b00434439588f3mr35037401pgm.289.1663238064367; Thu, 15 Sep 2022 03:34:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663238064; cv=none; d=google.com; s=arc-20160816; b=mWNzxy2ENUfNTFgsXLfrIelDMy0ZXRgJJ8JEC4X1ik972IPp4yvl+3joqMCFY4YUBU qifm2zd8m6XbgGUNzOIWZFELdaDOGW+NdEthC7wSowSszst4KCi85G8ip14/NCWt2Ef+ 1oz0qiKpMGuop1/UTNFueJCJSfIM9uwr+RpY0f8zUecPFDurNLgpQxjNmq6CEajtVS0x O3M0P8VU7gMh949bAyrXaov1wTnJ4sPXMLuwKivi8gE6Tb3rcqBB+uAzsFe74GMTsxmD dOCx1tudYp3z4K+/bhmsTxgkZs167E7dAmKb3+Z9SA009iXHakLBh1lQqjp7X/B8/p5R whYQ== 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=IqG2BtNnMI2ZuLBaPi155O08Qs3EB56QGC+BxrUQtW0=; b=f475OmaeWXuI+802pLFVTw7rE47FUj7nqqg73EBzdb5HIUsQZEmZ4pLVzri2Xl+llV gXx/Ia6or+5bDffH/hmz9PXd9MItbybFnwf62ZHBQ2OPTlCJ4kAS0Y9RJQ9S/I7A0e/g wdE7OJfSm24hkzVJMv85AL0utELr8qddm+cVjoB/dQTbMn55RPNvQbldttt+pjRNRT4n VE6v9RxbWURgMXJEEFpdYF3hvihK0KXxu8PpVWO4Eacbz45TwecjAlY11iQuFSOWbp9c XVxHEY3H8ttuwhpGTmYfJWLHHj32PkpF4HejikTyLcwIGGAKT/HZjSaMB7+zp4UOugXp spFQ== 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 g13-20020a17090a300d00b002009c004d9fsi6796426pjb.75.2022.09.15.03.34.13; Thu, 15 Sep 2022 03:34:24 -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 S229972AbiIOKO0 (ORCPT + 99 others); Thu, 15 Sep 2022 06:14:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229701AbiIOKOY (ORCPT ); Thu, 15 Sep 2022 06:14:24 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D164183070; Thu, 15 Sep 2022 03:14:22 -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 C99431692; Thu, 15 Sep 2022 03:14:28 -0700 (PDT) Received: from [10.57.48.93] (unknown [10.57.48.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DECA23F73B; Thu, 15 Sep 2022 03:14:19 -0700 (PDT) Message-ID: Date: Thu, 15 Sep 2022 11:14:18 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Subject: Re: [PATCH 2/9] coresight-tpda: Add DSB dataset support To: Tao Zhang , Mathieu Poirier , Alexander Shishkin , Konrad Dybcio , Mike Leach Cc: Jinlong Mao , Leo Yan , Greg Kroah-Hartman , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Tingwei Zhang , Yuanfang Zhang , Trilok Soni , Hao Zhang , linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org References: <1662626705-13097-1-git-send-email-quic_taozha@quicinc.com> <1662626705-13097-3-git-send-email-quic_taozha@quicinc.com> From: Suzuki K Poulose In-Reply-To: <1662626705-13097-3-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=-8.7 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_HI,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 Tao On 08/09/2022 09:44, Tao Zhang wrote: > Read the DSB element size from the device tree. Set the register > bit that controls the DSB element size of the corresponding port. > > Signed-off-by: Tao Zhang > --- > drivers/hwtracing/coresight/coresight-tpda.c | 62 ++++++++++++++++++++++++++++ > drivers/hwtracing/coresight/coresight-tpda.h | 4 ++ > 2 files changed, 66 insertions(+) > > diff --git a/drivers/hwtracing/coresight/coresight-tpda.c b/drivers/hwtracing/coresight/coresight-tpda.c > index c8bbc75..76636a1 100644 > --- a/drivers/hwtracing/coresight/coresight-tpda.c > +++ b/drivers/hwtracing/coresight/coresight-tpda.c > @@ -37,6 +37,15 @@ static void tpda_enable_port(struct tpda_drvdata *drvdata, int port) > u32 val; > > val = readl_relaxed(drvdata->base + TPDA_Pn_CR(port)); > + /* > + * Configure aggregator port n DSB data set element size > + * Set the bit to 0 if the size is 32 > + * Set the bit to 1 if the size is 64 > + */ > + if (drvdata->dsb_esize[port] == 32) > + val &= ~TPDA_Pn_CR_DSBSIZE; > + else if (drvdata->dsb_esize[port] == 64) > + val |= TPDA_Pn_CR_DSBSIZE; > /* Enable the port */ > val |= TPDA_Pn_CR_ENA; > writel_relaxed(val, drvdata->base + TPDA_Pn_CR(port)); > @@ -105,6 +114,55 @@ static const struct coresight_ops tpda_cs_ops = { > .link_ops = &tpda_link_ops, > }; > > +static int tpda_parse_dsb(struct tpda_drvdata *drvdata) > +{ > + int len, port, i; > + const __be32 *prop; > + struct device_node *node = drvdata->dev->of_node; > + > + /* Read the size of DSB element */ > + prop = of_get_property(node, "qcom,dsb-elem-size", &len); > + if (prop) { > + len /= sizeof(__be32); > + /* > + * The read set of data is port and size, so the number of data > + * is a multiple of two. And the number of data will not exceed > + * two times that of the TPDA inpurts number. > + */ > + if (len < 2 || len >= (2 * TPDA_MAX_INPORTS) || len % 2 != 0) { > + dev_err(drvdata->dev, > + "Dataset DSB width entries are wrong\n"); > + return -EINVAL; > + } > + > + for (i = 0; i < len; i++) { Please could we be explicit here that we are dealing with 2 entries in an iteration. i.e, for (i = 0; i < len; i += 2) { > + port = be32_to_cpu(prop[i++]); port = be32_to_cpu(prop[i]); > + if (port >= TPDA_MAX_INPORTS) { > + dev_err(drvdata->dev, > + "Wrong port specified for DSB\n"); > + return -EINVAL; > + } > + /* Set DSB element size for corresponding port to dsb_esize*/ > + drvdata->dsb_esize[port] = be32_to_cpu(prop[i]); drvdata->dsb_esize[port] = be32_to_cpu(prop[i + 1]); > + } > + } > + > + return 0; > +} > + > +static int tpda_parse_of_data(struct tpda_drvdata *drvdata) > +{ > + int ret; > + > + ret = tpda_parse_dsb(drvdata); > + if (ret) { > + dev_err(drvdata->dev, "Fail to get DSB data set element size\n"); > + return -EINVAL; > + } > + > + return 0; > +} > + > static int tpda_init_default_data(struct tpda_drvdata *drvdata) > { > int atid; > @@ -148,6 +206,10 @@ static int tpda_probe(struct amba_device *adev, const struct amba_id *id) > > spin_lock_init(&drvdata->spinlock); > > + ret = tpda_parse_of_data(drvdata); > + if (ret) > + return ret; > + > ret = tpda_init_default_data(drvdata); > if (ret) > return ret; > diff --git a/drivers/hwtracing/coresight/coresight-tpda.h b/drivers/hwtracing/coresight/coresight-tpda.h > index 4beb332..ecc7869 100644 > --- a/drivers/hwtracing/coresight/coresight-tpda.h > +++ b/drivers/hwtracing/coresight/coresight-tpda.h > @@ -10,6 +10,8 @@ > #define TPDA_Pn_CR(n) (0x004 + (n * 4)) > /* Aggregator port enable bit */ > #define TPDA_Pn_CR_ENA BIT(0) > +/* Aggregator port DSB data set element size bit */ > +#define TPDA_Pn_CR_DSBSIZE BIT(8) > > #define TPDA_MAX_INPORTS 32 > > @@ -23,6 +25,7 @@ > * @csdev: component vitals needed by the framework. > * @spinlock: lock for the drvdata value. > * @enable: enable status of the component. > + * @dsb_esize DSB element size super minor nit: Missing ":", consistent with the other fields. > */ > struct tpda_drvdata { > void __iomem *base; > @@ -30,6 +33,7 @@ struct tpda_drvdata { > struct coresight_device *csdev; > spinlock_t spinlock; > u8 atid; > + u32 dsb_esize[TPDA_MAX_INPORTS]; > }; > > #endif /* _CORESIGHT_CORESIGHT_TPDA_H */ Suzuki