From: Robin Murphy <robin.murphy@arm.com>
To: Qinxin Xia <xiaqinxin@huawei.com>, will@kernel.org, jpb@kernel.org
Cc: linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev,
wangzhou1@hisilicon.com, prime.zeng@hisilicon.com,
fanghao11@huawei.com, jonathan.cameron@huawei.com,
linuxarm@huawei.com
Subject: Re: [RFC PATCH 2/5] iommu/arm-smmu-v3: Add register display to debugfs
Date: Mon, 16 Mar 2026 15:19:53 +0000 [thread overview]
Message-ID: <68add41b-bafa-4884-be70-c03d6ce851eb@arm.com> (raw)
In-Reply-To: <20260313104351.3502293-3-xiaqinxin@huawei.com>
On 2026-03-13 10:43 am, Qinxin Xia wrote:
> 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 <xiaqinxin@huawei.com>
> ---
> .../arm/arm-smmu-v3/arm-smmu-v3-debugfs.c | 68 ++++++++++++++++++-
> 1 file changed, 67 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 542bd6047f26..f9bf955f3351 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
> @@ -12,11 +12,20 @@
> * - Capability reporting covering all major SMMU features and configuration
> * - Extensible architecture designed for adding future debug functionality
> * - Comprehensive error handling and resource cleanup
> + * - Display of control registers (CR0, CR1, CR2) with bitfield decoding
> + * - Command and Event queue pointer monitoring (PROD/CONS)
> + *
> + * Register Information Displayed:
> + * - CR0: SMMU global control with enable states and queue enables
> + * - CR1/CR2: Additional control and configuration registers
> + * - CMDQ_PROD/CONS: Command queue producer and consumer pointers
> + * - EVTQ_PROD/CONS: Event queue producer and consumer pointers
> *
> * Directory Structure:
> * /sys/kernel/debug/iommu/arm_smmu_v3/
> * └── smmu0/
> - * └── capabilities # SMMU feature capabilities and configuration
> + * ├── capabilities # SMMU feature capabilities and configuration
> + * └── registers # SMMU Key registers
> *
> * The capabilities file provides detailed information about:
> * - Architecture version and translation stage support (Stage1/Stage2)
> @@ -24,6 +33,11 @@
> * - Stream table size and command/event queue depths
> * - All feature bits from the SMMU device structure
> *
> + * The register display provides crucial visibility into:
> + * - SMMU operational state (enabled/disabled)
> + * - Queue operation and potential stalls
> + * - Configuration settings affecting all streams
> + *
> * Copyright (C) 2025 HiSilicon Limited.
> * Author: Qinxin Xia <xiaqinxin@huawei.com>
> */
> @@ -69,6 +83,54 @@ static int smmu_debugfs_capabilities_show(struct seq_file *seq, void *v)
> }
> DEFINE_SHOW_ATTRIBUTE(smmu_debugfs_capabilities);
>
> +/**
> + * smmu_debugfs_registers_show() - Display SMMU register values
> + * @seq: seq_file to write to
> + * @v: private data (SMMU device)
> + *
> + * Return: 0 on success, negative error code on failure
> + */
> +static int smmu_debugfs_registers_show(struct seq_file *seq, void *v)
> +{
> + 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 [%s%s%s]\n",
> + readl_relaxed(base + ARM_SMMU_CR0),
> + readl_relaxed(base + ARM_SMMU_CR0) & CR0_SMMUEN ?
> + "Enabled " : "Disabled ",
> + readl_relaxed(base + ARM_SMMU_CR0) & CR0_EVTQEN ?
> + "EventQ " : "",
> + readl_relaxed(base + ARM_SMMU_CR0) & CR0_CMDQEN ?
> + "CmdQ " : "");
There's really no point printing these extra strings, since if any of
those were *not* enabled then we'd have already failed probe and never
created the debugfs entry. And if anyone ever were to be trying to
change the driver behaviour at that level, I'd very much expect them to
be able to be able to read the bottom 4 bits of a CR0 value in hex anyway ;)
Thanks,
Robin.
> +
> + 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;
> +}
> +DEFINE_SHOW_ATTRIBUTE(smmu_debugfs_registers);
> +
> /**
> * arm_smmu_debugfs_setup() - Initialize debugfs for SMMU device
> * @smmu: SMMU device to setup debugfs for
> @@ -120,6 +182,10 @@ int arm_smmu_debugfs_setup(struct arm_smmu_device *smmu, phys_addr_t ioaddr)
> &smmu_debugfs_capabilities_fops))
> goto err_cleanup;
>
> + if (!debugfs_create_file("registers", 0444, smmu_dir, smmu,
> + &smmu_debugfs_registers_fops))
> + goto err_cleanup;
> +
> pr_info("SMMUv3 debugfs initialized for smmu%pa\n", &ioaddr);
> return 0;
>
next prev parent reply other threads:[~2026-03-16 15:20 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-13 10:43 [RFC PATCH 0/5] Add debugfs support for ARM SMMUv3 Qinxin Xia
2026-03-13 10:43 ` [RFC PATCH 1/5] iommu/arm-smmu-v3: Add basic debugfs framework Qinxin Xia
2026-03-13 19:58 ` Nicolin Chen
2026-03-16 15:14 ` Qinxin Xia
2026-03-13 10:43 ` [RFC PATCH 2/5] iommu/arm-smmu-v3: Add register display to debugfs Qinxin Xia
2026-03-13 20:20 ` Nicolin Chen
2026-03-16 15:22 ` Qinxin Xia
2026-03-16 15:19 ` Robin Murphy [this message]
2026-03-16 15:35 ` Qinxin Xia
2026-03-16 16:26 ` Robin Murphy
2026-03-17 1:44 ` Qinxin Xia
2026-03-13 10:43 ` [RFC PATCH 3/5] iommu/arm-smmu-v3: Add Stream Table Entry " Qinxin Xia
2026-03-13 20:19 ` Nicolin Chen
2026-03-16 15:43 ` Qinxin Xia
2026-03-13 10:43 ` [RFC PATCH 4/5] iommu/arm-smmu-v3: Add stream table directory structure " Qinxin Xia
2026-03-13 20:44 ` Nicolin Chen
2026-03-16 14:57 ` Qinxin Xia
2026-03-16 16:01 ` Robin Murphy
2026-03-17 2:04 ` Qinxin Xia
2026-03-13 10:43 ` [RFC PATCH 5/5] iommu/arm-smmu-v3: Add Context Descriptor display " Qinxin Xia
2026-03-13 21:04 ` Nicolin Chen
2026-03-16 15:12 ` Qinxin Xia
2026-03-16 15:42 ` Robin Murphy
2026-03-17 2:14 ` Qinxin Xia
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=68add41b-bafa-4884-be70-c03d6ce851eb@arm.com \
--to=robin.murphy@arm.com \
--cc=fanghao11@huawei.com \
--cc=iommu@lists.linux.dev \
--cc=jonathan.cameron@huawei.com \
--cc=jpb@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linuxarm@huawei.com \
--cc=prime.zeng@hisilicon.com \
--cc=wangzhou1@hisilicon.com \
--cc=will@kernel.org \
--cc=xiaqinxin@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox