Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp2899132rwb; Mon, 7 Aug 2023 05:27:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGVej+8J3MU//4aS3184LgMflvp6mBeW7k9KPs0cwQdRfZ9L/hXZXBomcThPHHkD+YHqfYB X-Received: by 2002:a05:6808:190d:b0:3a7:52b9:cbfe with SMTP id bf13-20020a056808190d00b003a752b9cbfemr9690708oib.32.1691411247365; Mon, 07 Aug 2023 05:27:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691411247; cv=none; d=google.com; s=arc-20160816; b=nDR/VNtH/nd+HuswlNUPsBJ3ZfhtOrGOVdFjn3IIXoGyQW6n2pqBsLRZfOLgYy8ZAB wAa9MUn7skT26R1w1esK7MZf7nVlBYcsxaH/X0BVfrIvtRRa1L7KQpriZV9efRtCMC2D L/SF7RYdacWfpcPoPyElDvmMc3tfFGsYdYtdja8sY2kzVARvUD5aYvvDj266aZqWRmRN ySkMMy+q6N/W0s8RCXI77L833gLEKBUBXcXBjR1Lx/KTtwSoHb2HzC1W2uRvhQpMfPha k6Genh0WxMaOYYON/WvhVTDn627aoKzfTbzq5RVMHAeaIj51oQcrtdoNQbL6AXM2eOVY b56w== 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=cKzd80XpgKlhvSp09vVsYNBQTV9NmOXZiOKWn7AGtpc=; fh=h6afWEGYE03/u4dCLqBwB9lbcI1lAvy4mmLmfnZ59aI=; b=Bp1O+3IDeFesyzL+n9icXL5JIbQ+q1+8eFI8zV6h7ooufMMr/HnwvinRvvJ9oCUAqh 7xdnwV1rQy9/PND0qqCmRx5IsQ38PGY8X/O1NRKEqEQg9gGnNK64zBR825JPnX830yg1 eh+Qx1e7HIY6NIlhcBma6ltwhhXcCcQbHOI6g0JqTvRyKOeqGEvTcW81/uyclT+qAMb9 pm/sm7X/VBBZdEmWIBXc1LIp8egtKU4aihYx59WBCbD8b+cxdDr/NXzKn9/dUfGadfCJ z/wJm0T1dfVpXEKy32Bx+Eng0pzSVy2RENUOI3Kh9r9HlByGvXZNh8GEkMU9+dyfcOIA lxzg== 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 bg26-20020a056a02011a00b00563eff1b064si5581061pgb.504.2023.08.07.05.27.15; Mon, 07 Aug 2023 05:27:27 -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 S233082AbjHGLje (ORCPT + 99 others); Mon, 7 Aug 2023 07:39:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233014AbjHGLjK (ORCPT ); Mon, 7 Aug 2023 07:39:10 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8AA5D5FF4; Mon, 7 Aug 2023 04:36:14 -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 E069CD75; Mon, 7 Aug 2023 04:36:02 -0700 (PDT) Received: from [10.57.90.63] (unknown [10.57.90.63]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1BBA53F59C; Mon, 7 Aug 2023 04:35:16 -0700 (PDT) Message-ID: Date: Mon, 7 Aug 2023 12:35:15 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v7 13/13] coresight-tpdm: Add nodes for dsb msr support 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: <1690269353-10829-1-git-send-email-quic_taozha@quicinc.com> <1690269353-10829-14-git-send-email-quic_taozha@quicinc.com> From: Suzuki K Poulose In-Reply-To: <1690269353-10829-14-git-send-email-quic_taozha@quicinc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.0 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 On 25/07/2023 08:15, Tao Zhang wrote: > Add the nodes for DSB subunit MSR(mux select register) support. > The TPDM MSR (mux select register) interface is an optional > interface and associated bank of registers per TPDM subunit. > The intent of mux select registers is to control muxing structures > driving the TPDM’s’ various subunit interfaces. > > Signed-off-by: Tao Zhang > --- > .../ABI/testing/sysfs-bus-coresight-devices-tpdm | 19 ++++- > drivers/hwtracing/coresight/coresight-tpdm.c | 98 ++++++++++++++++++++++ > drivers/hwtracing/coresight/coresight-tpdm.h | 7 ++ > 3 files changed, 123 insertions(+), 1 deletion(-) > > diff --git a/Documentation/ABI/testing/sysfs-bus-coresight-devices-tpdm b/Documentation/ABI/testing/sysfs-bus-coresight-devices-tpdm > index 74a0126..ee41a14 100644 > --- a/Documentation/ABI/testing/sysfs-bus-coresight-devices-tpdm > +++ b/Documentation/ABI/testing/sysfs-bus-coresight-devices-tpdm > @@ -185,4 +185,21 @@ Description: > > Accepts only one of the 2 values - 0 or 1. > 0 : Set the DSB pattern type to value. > - 1 : Set the DSB pattern type to toggle. > \ No newline at end of file > + 1 : Set the DSB pattern type to toggle. > + > +What: /sys/bus/coresight/devices//dsb_msr_idx > +Date: March 2023 > +KernelVersion 6.5 > +Contact: Jinlong Mao (QUIC) , Tao Zhang (QUIC) > +Description: > + Read/Write the index number of MSR(mux select register) on DSB > + TPDM. This index number should not be greater than the number > + of MSR supported by this DSB TPDM. How does a user find it ? Why don't we expose it ? Scratch all of that, you could create a register file per exising msr. dsb_msrs/msr0 ... msrN You may : 1. either dynamically add files as you find the number OR 2. If there is a hard limit, create that many files and control visibility based on the dynamic number. > + > +What: /sys/bus/coresight/devices//dsb_msr > +Date: March 2023 > +KernelVersion 6.5 > +Contact: Jinlong Mao (QUIC) , Tao Zhang (QUIC) > +Description: > + (Write) Set the MSR(mux select register) of DSB tpdm. Read > + the MSR(mux select register) of DSB tpdm. (RW) > \ No newline at end of file > diff --git a/drivers/hwtracing/coresight/coresight-tpdm.c b/drivers/hwtracing/coresight/coresight-tpdm.c > index f9e5a1d..be7776b 100644 > --- a/drivers/hwtracing/coresight/coresight-tpdm.c > +++ b/drivers/hwtracing/coresight/coresight-tpdm.c > @@ -90,6 +90,18 @@ static void set_dsb_tier(struct tpdm_drvdata *drvdata, u32 *val) > > } > > +static void set_dsb_msr(struct tpdm_drvdata *drvdata) > +{ > + int i; > + > + if (drvdata->dsb->msr_num == 0) > + return; > + > + for (i = 0; i < drvdata->dsb->msr_num; i++) > + writel_relaxed(drvdata->dsb->msr[i], > + drvdata->base + TPDM_DSB_MSR(i)); > +} > + > static void tpdm_enable_dsb(struct tpdm_drvdata *drvdata) > { > u32 val, i; > @@ -116,6 +128,8 @@ static void tpdm_enable_dsb(struct tpdm_drvdata *drvdata) > set_dsb_tier(drvdata, &val); > writel_relaxed(val, drvdata->base + TPDM_DSB_TIER); > > + set_dsb_msr(drvdata); > + > val = readl_relaxed(drvdata->base + TPDM_DSB_CR); > /* Set the test accurate mode */ > set_dsb_test_mode(drvdata, &val); > @@ -234,6 +248,14 @@ static int tpdm_datasets_setup(struct tpdm_drvdata *drvdata) > if (!drvdata->dsb) > return -ENOMEM; > } > + if (!of_property_read_u32(drvdata->dev->of_node, > + "qcom,dsb_msr_num", &drvdata->dsb->msr_num)) { > + drvdata->dsb->msr = devm_kzalloc(drvdata->dev, > + (drvdata->dsb->msr_num * sizeof(*drvdata->dsb->msr)), devm_kcalloc() ? > + GFP_KERNEL); > + if (!drvdata->dsb->msr) > + return -ENOMEM; > + } > } > > return 0; > @@ -830,6 +852,80 @@ static ssize_t dsb_trig_ts_store(struct device *dev, > } > static DEVICE_ATTR_RW(dsb_trig_ts); > > +static ssize_t dsb_msr_idx_show(struct device *dev, > + struct device_attribute *attr, > + char *buf) > +{ > + struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent); > + > + return sysfs_emit(buf, "%u\n", > + (unsigned int)drvdata->dsb->msr_idx); > + > +} > + > +static ssize_t dsb_msr_idx_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 index; > + > + if (kstrtoul(buf, 0, &index)) > + return -EINVAL; > + if (index >= drvdata->dsb->msr_num) > + return -EPERM; > + > + spin_lock(&drvdata->spinlock); > + drvdata->dsb->msr_idx = index; > + spin_unlock(&drvdata->spinlock); > + return size; > +} > +static DEVICE_ATTR_RW(dsb_msr_idx); > + > +static ssize_t dsb_msr_show(struct device *dev, > + struct device_attribute *attr, > + char *buf) > +{ > + struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent); > + unsigned int i; > + unsigned long bytes; > + ssize_t size = 0; > + > + if (drvdata->dsb->msr_num == 0) > + return -EINVAL; > + > + spin_lock(&drvdata->spinlock); > + for (i = 0; i < drvdata->dsb->msr_num; i++) { > + bytes = sysfs_emit_at(buf, size, > + "0x%x\n", drvdata->dsb->msr[i]); Single value per single file. Suzuki > + if (bytes <= 0) > + break; > + size += bytes; > + } > + spin_unlock(&drvdata->spinlock); > + > + return size; > +} > + > +static ssize_t dsb_msr_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)) > + return -EINVAL; > + > + spin_lock(&drvdata->spinlock); > + drvdata->dsb->msr[drvdata->dsb->msr_idx] = val; > + spin_unlock(&drvdata->spinlock); > + return size; > +} > +static DEVICE_ATTR_RW(dsb_msr); > + > static struct attribute *tpdm_dsb_attrs[] = { > &dev_attr_dsb_mode.attr, > &dev_attr_dsb_edge_ctrl_idx.attr, > @@ -845,6 +941,8 @@ static struct attribute *tpdm_dsb_attrs[] = { > &dev_attr_dsb_trig_patt_mask.attr, > &dev_attr_dsb_trig_ts.attr, > &dev_attr_dsb_trig_type.attr, > + &dev_attr_dsb_msr_idx.attr, > + &dev_attr_dsb_msr.attr, > NULL, > }; > > diff --git a/drivers/hwtracing/coresight/coresight-tpdm.h b/drivers/hwtracing/coresight/coresight-tpdm.h > index 7c52cf4..7b70db3 100644 > --- a/drivers/hwtracing/coresight/coresight-tpdm.h > +++ b/drivers/hwtracing/coresight/coresight-tpdm.h > @@ -18,6 +18,7 @@ > #define TPDM_DSB_XPMR(n) (0x7E8 + (n * 4)) > #define TPDM_DSB_EDCR(n) (0x808 + (n * 4)) > #define TPDM_DSB_EDCMR(n) (0x848 + (n * 4)) > +#define TPDM_DSB_MSR(n) (0x980 + (n * 4)) > > /* Enable bit for DSB subunit */ > #define TPDM_DSB_CR_ENA BIT(0) > @@ -100,6 +101,9 @@ > * @patt_mask: Save value for pattern mask > * @trig_patt: Save value for trigger pattern > * @trig_patt_mask: Save value for trigger pattern mask > + * @msr_num Number of MSR supported by DSB TPDM > + * @msr_idx Index number of the MSR > + * @msr Save value for MSR > * @patt_ts: Enable/Disable pattern timestamp > * @patt_type: Set pattern type > * @trig_ts: Enable/Disable trigger timestamp. > @@ -116,6 +120,9 @@ struct dsb_dataset { > u32 patt_mask[TPDM_DSB_MAX_PATT]; > u32 trig_patt[TPDM_DSB_MAX_PATT]; > u32 trig_patt_mask[TPDM_DSB_MAX_PATT]; > + u32 msr_num; > + u32 msr_idx; > + u32 *msr; > bool patt_ts; > bool patt_type; > bool trig_ts;