From nobody Tue Feb 10 15:43:34 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A6F7C7EE23 for ; Fri, 12 May 2023 02:41:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239708AbjELClW (ORCPT ); Thu, 11 May 2023 22:41:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233568AbjELClU (ORCPT ); Thu, 11 May 2023 22:41:20 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88497559E; Thu, 11 May 2023 19:41:18 -0700 (PDT) Received: from dggpeml500002.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QHXxs1czyzLprV; Fri, 12 May 2023 10:38:25 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by dggpeml500002.china.huawei.com (7.185.36.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 12 May 2023 10:41:15 +0800 From: Junhao He To: , , , , CC: , , , , , , , , Subject: [PATCH] coresight: etm4x: fix trctraceid sysfs always invisible Date: Fri, 12 May 2023 10:39:33 +0800 Message-ID: <20230512023933.961-1-hejunhao3@huawei.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpeml500002.china.huawei.com (7.185.36.158) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The trctraceid sysfs interface is current in etm4x mgmt group. Each attr in the mgmt group will call the function is_visible() to check whether the register is implemented. However the trctraceid does not bound to any register. So the trctraceid sysfs will always be invisible. Move it to etmv4 group to fix that. Fixes: df4871204e5d ("coresight: etm4x: Update ETM4 driver to use Trace ID = API") Signed-off-by: Junhao He --- .../coresight/coresight-etm4x-sysfs.c | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c b/drivers/= hwtracing/coresight/coresight-etm4x-sysfs.c index 5e62aa40ecd0..0ea71de0f56b 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c @@ -2335,6 +2335,26 @@ static ssize_t ts_source_show(struct device *dev, } static DEVICE_ATTR_RO(ts_source); =20 +/* + * Trace ID allocated dynamically on enable - but also allocate on read + * in case sysfs or perf read before enable to ensure consistent metadata + * information for trace decode + */ +static ssize_t trctraceid_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + int trace_id; + struct etmv4_drvdata *drvdata =3D dev_get_drvdata(dev->parent); + + trace_id =3D etm4_read_alloc_trace_id(drvdata); + if (trace_id < 0) + return trace_id; + + return sysfs_emit(buf, "0x%x\n", trace_id); +} +static DEVICE_ATTR_RO(trctraceid); + static struct attribute *coresight_etmv4_attrs[] =3D { &dev_attr_nr_pe_cmp.attr, &dev_attr_nr_addr_cmp.attr, @@ -2390,29 +2410,10 @@ static struct attribute *coresight_etmv4_attrs[] = =3D { &dev_attr_vmid_masks.attr, &dev_attr_cpu.attr, &dev_attr_ts_source.attr, + &dev_attr_trctraceid.attr, NULL, }; =20 -/* - * Trace ID allocated dynamically on enable - but also allocate on read - * in case sysfs or perf read before enable to ensure consistent metadata - * information for trace decode - */ -static ssize_t trctraceid_show(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - int trace_id; - struct etmv4_drvdata *drvdata =3D dev_get_drvdata(dev->parent); - - trace_id =3D etm4_read_alloc_trace_id(drvdata); - if (trace_id < 0) - return trace_id; - - return sysfs_emit(buf, "0x%x\n", trace_id); -} -static DEVICE_ATTR_RO(trctraceid); - struct etmv4_reg { struct coresight_device *csdev; u32 offset; @@ -2549,7 +2550,6 @@ static struct attribute *coresight_etmv4_mgmt_attrs[]= =3D { coresight_etm4x_reg(trcpidr3, TRCPIDR3), coresight_etm4x_reg(trcoslsr, TRCOSLSR), coresight_etm4x_reg(trcconfig, TRCCONFIGR), - &dev_attr_trctraceid.attr, coresight_etm4x_reg(trcdevarch, TRCDEVARCH), NULL, }; --=20 2.33.0