Received: from canpmsgout11.his.huawei.com (canpmsgout11.his.huawei.com [113.46.200.226]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 60E4737D136 for ; Sat, 28 Mar 2026 10:09:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.226 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774692602; cv=none; b=NjxqmYG7wJn+4QP7xXNPSlt1jI0QhqtJC4R4hw7oDXrIet1TctCyBwdKQhWY8m/c3TPbryx6/nlWlUfcqbr97y3tFCR0fpn9fIBAdLcaQP6KfBJAYdPeWLrJgvxxARQiiRz9ecKu2CSPgZE0RuSlRiEpcApsiWMUk7+o1C8rrDA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774692602; c=relaxed/simple; bh=tMpsqkWHwctUtjUBix8WOcZFBJl6RMPLX7Ts0aGzTnk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jJIIZMYYH4zAjr+xFyJre2c8Qhc525EjO5fRbBA75mWNiJ5e8omBc77Mo3isSLwDC3lItnjhqVhMfmbewrPah3SXT3a6wmtdpbuHIT022aC+mn/VE13L5A0dW3k8oJEYb5n1fgdIbaR/kSPQGo3uRehubHG/CMEY5hScEYlwWxw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=DoIa/Uji; arc=none smtp.client-ip=113.46.200.226 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="DoIa/Uji" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=wHU5+KqunB9+hNX5vubJwM9ZUSxN3Zdyf6nPKCwwUJg=; b=DoIa/UjiXs/6lsETax8Fox9fC9DPXWNqGUGrti5agC3zcwpU0NxaGnpM+NzMYEPGqMDaagYWh yyk9MoFkFBlqOub8Jot78omoKzJH9/i2/FLpF72ePGJZhFzaea7YaddjI5LKJWMiHzDhfvo7vdZ kjhGTaJl+ss7aeR0nhJQzmA= Received: from mail.maildlp.com (unknown [172.19.162.92]) by canpmsgout11.his.huawei.com (SkyGuard) with ESMTPS id 4fjY4f0LcdzKm5B; Sat, 28 Mar 2026 18:03:46 +0800 (CST) Received: from kwepemj200003.china.huawei.com (unknown [7.202.194.15]) by mail.maildlp.com (Postfix) with ESMTPS id 46ABE40562; Sat, 28 Mar 2026 18:09:55 +0800 (CST) Received: from localhost.huawei.com (10.90.31.46) by kwepemj200003.china.huawei.com (7.202.194.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Sat, 28 Mar 2026 18:09:54 +0800 From: Qinxin Xia To: , , , CC: , , , , , , , , Subject: [RFC PATCH v2 2/5] iommu/arm-smmu-v3: Add register display to debugfs Date: Sat, 28 Mar 2026 18:09:50 +0800 Message-ID: <20260328100953.3441915-3-xiaqinxin@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20260328100953.3441915-1-xiaqinxin@huawei.com> References: <20260328100953.3441915-1-xiaqinxin@huawei.com> Precedence: bulk X-Mailing-List: iommu@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="y" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To kwepemj200003.china.huawei.com (7.202.194.15) Add register display functionality to debugfs.This allows reading and displaying key SMMU register values including control registers and queue pointers. The registers file shows: - CR0, CR1, CR2 control registers - Command and Event queue pointers Signed-off-by: Qinxin Xia --- .../arm/arm-smmu-v3/arm-smmu-v3-debugfs.c | 78 ++++++++++++++++++- 1 file changed, 77 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-debugfs.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-debugfs.c index c764b28e5cfb..cfd296aebc9f 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-debugfs.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-debugfs.c @@ -5,13 +5,18 @@ * Directory Structure: * /sys/kernel/debug/iommu/arm_smmu_v3/ * └── smmu/ - * └── capabilities # SMMU feature capabilities and configuration + * ├── capabilities # SMMU feature capabilities and configuration + * └── registers # SMMU Key registers * * The capabilities file provides detailed information about: * - translation stage support (Stage1/Stage2) * - System coherency, ATS, and PRI feature availability * - Stream table size and command/event queue depths * + * The registers display provides crucial visibility into: + * - CR0, CR1, CR2 control registers + * - Command and Event queue pointers + * * Copyright (C) 2026 HiSilicon Limited. * Author: Qinxin Xia */ @@ -89,6 +94,74 @@ static const struct file_operations smmu_debugfs_capabilities_fops = { .release = smmu_debugfs_capabilities_release, }; +/** + * smmu_debugfs_registers_show() - Display SMMU register values + * @seq: seq_file to write to + * + * Errors are reported via seq_puts, the function always returns 0 + */ +static int smmu_debugfs_registers_show(struct seq_file *seq, void *unused) +{ + struct arm_smmu_device *smmu = seq->private; + void __iomem *base; + + if (!smmu || !smmu->base) { + seq_puts(seq, "SMMU not available\n"); + return 0; + } + + base = smmu->base; + + seq_puts(seq, "SMMUv3 Key Registers:\n"); + + /* 32-bit control registers */ + seq_printf(seq, "CR0: 0x%08x\n", readl_relaxed(base + ARM_SMMU_CR0)); + seq_printf(seq, "CR1: 0x%08x\n", readl_relaxed(base + ARM_SMMU_CR1)); + seq_printf(seq, "CR2: 0x%08x\n", readl_relaxed(base + ARM_SMMU_CR2)); + + /* 32-bit queue pointer registers */ + seq_printf(seq, "CMDQ_PROD: 0x%08x\n", + readl_relaxed(base + ARM_SMMU_CMDQ_PROD)); + seq_printf(seq, "CMDQ_CONS: 0x%08x\n", + readl_relaxed(base + ARM_SMMU_CMDQ_CONS)); + seq_printf(seq, "EVTQ_PROD: 0x%08x\n", + readl_relaxed(base + ARM_SMMU_EVTQ_PROD)); + seq_printf(seq, "EVTQ_CONS: 0x%08x\n", + readl_relaxed(base + ARM_SMMU_EVTQ_CONS)); + + return 0; +} + +static int smmu_debugfs_registers_open(struct inode *inode, struct file *file) +{ + struct arm_smmu_device *smmu = inode->i_private; + + if (!smmu || !get_device(smmu->dev)) + return -ENODEV; + + return single_open(file, smmu_debugfs_registers_show, smmu); +} + +static int smmu_debugfs_registers_release(struct inode *inode, struct file *file) +{ + struct seq_file *seq = file->private_data; + struct arm_smmu_device *smmu = seq->private; + + single_release(inode, file); + if (smmu) + put_device(smmu->dev); + + return 0; +} + +static const struct file_operations smmu_debugfs_registers_fops = { + .owner = THIS_MODULE, + .open = smmu_debugfs_registers_open, + .read = seq_read, + .llseek = seq_lseek, + .release = smmu_debugfs_registers_release, +}; + /** * arm_smmu_debugfs_setup() - Initialize debugfs for SMMU device * @smmu: SMMU device to setup debugfs for @@ -134,6 +207,9 @@ int arm_smmu_debugfs_setup(struct arm_smmu_device *smmu, const char *name) debugfs_create_file("capabilities", 0444, smmu_dir, smmu, &smmu_debugfs_capabilities_fops); + debugfs_create_file("registers", 0444, smmu_dir, smmu, + &smmu_debugfs_registers_fops); + dev_dbg(smmu->dev, "debugfs initialized for %s\n", name); return 0; } -- 2.33.0