From patchwork Fri May 12 02:39:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hejunhao X-Patchwork-Id: 92932 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4816270vqo; Thu, 11 May 2023 20:10:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4uvbEGygmhkzfvtgHU7eSYBrjMIb6EK2CKYH8x3dW+wasYYJLDQVqnYE2C+dsQlvtXrrEv X-Received: by 2002:a05:6a00:1a0f:b0:648:b36c:fd96 with SMTP id g15-20020a056a001a0f00b00648b36cfd96mr8558835pfv.5.1683861020079; Thu, 11 May 2023 20:10:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683861020; cv=none; d=google.com; s=arc-20160816; b=bM2uc6+QBrlNgapbiBOxJC9yEAYU2hfIzOHhb3nTbXxnKZUnyjT7og9HJCv5mRPWfD se0vO3i6V5hB+RR6bzRVELq/P8e45Tu6MXXMs6tQTBhJaVgUACs+fQ0xho5r/FgbGcMB mP84oMd2euoLzGJ/DY7cg+SFOJnh2Sc9CZ+TXbwFqJ6j3Jn4os2J4wZ12eqFlhidGO3R yuLhWYFwgPtIp0u9wdfu+k2EW7JVZUrz8ycbngNFpOX1x8sQQOO16/PVofE1uFe1iEW7 4g7YR7U/vmF8eDhKgKgo4VeoxXGd19cqUAcKuM4s5ViBQAhC+8UoeTSxRS10N+f1rbxf excA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=F+90wTPDoJA70i6Hj7zRnMr6ovRXysqvbYjWW3YBFkA=; b=PvmpUHTe8M4lh8lSClm//Rs5/NueRSzv2IZ7dYUhKm3zDwgjY1MVaVfSkZqsZe9jSz k+WlyuYkutEGLJ0K4hCAcoJ7CY1ANbJjgaY6WPwLKq21GdHgS+IVywENt1TOeuJm+VQB 90iWUESn3Q6Y9kRE9J1EV343RG1nmscBEpctKXEPX/giLBv3IKXwGRKfwjsE6xFwAKxO iNCM62SJdRbg+Yx7BOPYedfu0lJGgEg5R3V14YtrAK4OILfXyj4FdDfIKWdpvx2lq1e/ YdZL+bc5SnYEk8WMNVZFvoWBNhNcCVdWyNXNo7FQWlZFvlphf0Vux/0PnA5nFScQD+mC S4ZQ== 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k7-20020a635607000000b0053009feb3c8si7771538pgb.431.2023.05.11.20.10.05; Thu, 11 May 2023 20:10:20 -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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239689AbjELClW (ORCPT + 99 others); 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 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 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765656253026493605?= X-GMAIL-MSGID: =?utf-8?q?1765656253026493605?= 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); +/* + * 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 = dev_get_drvdata(dev->parent); + + trace_id = 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[] = { &dev_attr_nr_pe_cmp.attr, &dev_attr_nr_addr_cmp.attr, @@ -2390,29 +2410,10 @@ static struct attribute *coresight_etmv4_attrs[] = { &dev_attr_vmid_masks.attr, &dev_attr_cpu.attr, &dev_attr_ts_source.attr, + &dev_attr_trctraceid.attr, NULL, }; -/* - * 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 = dev_get_drvdata(dev->parent); - - trace_id = 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[] = { 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, };