public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: Qinxin Xia <xiaqinxin@huawei•com>
To: <robin.murphy@arm•com>, <nicolinc@nvidia•com>, <will@kernel•org>,
	<jpb@kernel•org>
Cc: <linux-arm-kernel@lists•infradead.org>, <iommu@lists•linux.dev>,
	<xiaqinxin@huawei•com>, <wangzhou1@hisilicon•com>,
	<prime.zeng@hisilicon•com>, <fanghao11@huawei•com>,
	<jonathan.cameron@huawei•com>, <wuyifan50@huawei•com>,
	<linuxarm@huawei•com>
Subject: [RFC PATCH v2 0/5] Add debugfs support for ARM SMMUv3
Date: Sat, 28 Mar 2026 18:17:01 +0800	[thread overview]
Message-ID: <20260328101706.3448655-1-xiaqinxin@huawei.com> (raw)

Add a comprehensive debugfs framework to the ARM SMMUv3 driver,                                                                                                                                                                                                                                                       
providing visibility into internal hardware state for debugging
and performance analysis. The debugfs entries are organized under
/sys/kernel/debug/iommu/arm_smmu_v3/, with per-SMMU instance directories
and per-device stream table entries.
                 
Each SMMU instance provides:
- capabilities – static SMMU features and queue sizes.
- registers – SMMU key registers.
- stream_table/ – a directory per device with subdirectories per Stream ID. 
                 
Each Stream ID subdirectory contains:
- ste – the Stream Table Entry in decoded and raw format.
- cd – all valid Context Descriptors (Stage 1 translation tables) associated with the device.
- a symlink named with the device’s BDF/name pointing to its sysfs directory for easy navigation.
                 
/sys/kernel/debug/iommu/arm_smmu_v3/smmu0/stream_table/
└── <sid>/       
    ├─── ste  
    ├─── cd   
    └─── <dev_name>

Changes since V1:
  Address the comments from Nicolin:
  1.Fixed the incorrect comments and replaced 'kzalloc' with 'kzalloc_obj'
  2.'stream_table_create/stream_table_remove' is called in probe_device/release_device
  3.Reused some functions in the driver

  Address the comments from Robin:
  1.Remove unnecessary CR0*EN extra strings
  2.Remove the limit on ssid

  Address the comments from Robin and Nicolin:
  1.The directory structure has been changed
  2.Added lock protection for the ste_show and cd_show

  Others:
  1.'arm_smmu_debugfs_remove' is added to remove the corresponding debugfs when SMMU device is removed
  2.'arm_smmu_debugfs_remove_stream_table' is added to remove the corresponding stream_dir when device is removed
  3.Use scoped_guard for locks that include return
  4.Added 'open' and 'release' operations to prevent the device from being released during dump
  5.Merged 'stream_table_create' and 'ste_show' into one patch
  6.Some other clean code

- Link: https://lore.kernel.org/all/20260313104351.3502293-1-xiaqinxin@huawei.com/

Qinxin Xia (5):
  iommu/arm-smmu-v3: Add basic debugfs framework
  iommu/arm-smmu-v3: Add register display to debugfs
  iommu/arm-smmu-v3: Add Stream Table Entry display to debugfs
  iommu/arm-smmu-v3: Add device symlink in stream table debugfs
  iommu/arm-smmu-v3: Add Context Descriptor display to debugfs

 drivers/iommu/Kconfig                         |  11 +
 drivers/iommu/arm/arm-smmu-v3/Makefile        |   1 +
 .../arm/arm-smmu-v3/arm-smmu-v3-debugfs.c     | 571 ++++++++++++++++++
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c   |  33 +-
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h   |  32 +
 5 files changed, 646 insertions(+), 2 deletions(-)
 create mode 100644 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-debugfs.c

-- 
2.33.0



WARNING: multiple messages have this Message-ID (diff)
From: Qinxin Xia <xiaqinxin@huawei•com>
To: <robin.murphy@arm•com>, <nicolinc@nvidia•com>, <will@kernel•org>,
	<jpb@kernel•org>
Cc: <linux-arm-kernel@lists•infradead.org>, <iommu@lists•linux.dev>,
	<xiaqinxin@huawei•com>, <wangzhou1@hisilicon•com>,
	<prime.zeng@hisilicon•com>, <fanghao11@huawei•com>,
	<jonathan.cameron@huawei•com>, <wuyifan50@huawei•com>,
	<linuxarm@huawei•com>, <linux-kernel@vger•kernel.org>
Subject: [PATCH 0/5] Add debugfs support for ARM SMMUv3
Date: Wed, 20 May 2026 14:37:06 +0800	[thread overview]
Message-ID: <20260328101706.3448655-1-xiaqinxin@huawei.com> (raw)
Message-ID: <20260520063706.OZy2VlaLCfxiKwmjF7ONYoyIxuPlgKI2zqELkvCgREA@z> (raw)

Add a comprehensive debugfs framework to the ARM SMMUv3 driver,
providing visibility into internal hardware state for debugging
and performance analysis. The debugfs entries are organized under
/sys/kernel/debug/iommu/arm_smmu_v3/, with per-SMMU instance directories
and per-device stream table entries.

Each SMMU instance provides:
- capabilities – static SMMU features and queue sizes.
- registers – SMMU key registers.
- stream_table/ – a directory per device with subdirectories per Stream ID.

Each Stream ID subdirectory contains:
- ste – the Stream Table Entry in decoded and raw format.
- cd – all valid Context Descriptors (Stage 1 translation tables) associated with the device.
- a symlink named with the device's BDF/name pointing to its sysfs directory for easy navigation.

/sys/kernel/debug/iommu/arm_smmu_v3/smmu0/stream_table/
    ├── <sid>/
    │   ├── ste
    │   ├── cd
    │   └── <dev_name>

Changes since RFCv2:
  Address review comments from Nicolin Chen, kernel test robot, and Sashiko
  automated review:

  Build & kerneldoc fixes (patches 1-3):
   - Add missing @unused parameter description to kerneldoc comments to fix
     clang W=1 warnings reported by kernel test robot.
   - Fix commit message: "driver.This" -> "driver. This" (patch 1).

  Correctness fixes:
   - Fix integer overflow: 1 << sid_bits -> 1ULL << sid_bits with %llu format,
     preventing undefined behavior when SIDSIZE = 32 (patch 1).
   - Fix EVTQ register access: use smmu->page1 instead of smmu->base for
     EVTQ_PROD/EVTQ_CONS, which reside in register page 1 (patch 2).
   - Fix STE config bit test: use proper cfg comparison instead of bitwise AND
     on non-mask enumeration values, and extract S1ContextPtr from data[0]
     instead of data[1] (patch 3).

  Resource leak fixes (patches 1-5):
   - Fix device reference leak: call put_device() when single_open() fails in
     all open() callbacks (capabilities, registers, ste, cd).
   - Fix dentry reference leak: add missing dput() after debugfs_lookup() in
     stream table remove path (patch 3).
   - Move kobject_get_path() outside the per-stream loop to avoid repeated
     allocation (patch 4).

  Locking & concurrency fixes:
   - arm_smmu_debugfs_remove(): use scoped_guard() and move
     debugfs_remove_recursive() outside the lock to avoid blocking other SMMU
     instances on active VFS operations (patch 1).
   - smmu_debugfs_ste_show(): change scoped_guard to guard(mutex) since the
     entire function body is within the lock scope (patch 3).
   - smmu_debugfs_cd_show(): change manual mutex_lock/unlock to
     guard(mutex)(&arm_smmu_asid_lock) (patch 5).

  Error handling fixes:
   - Replace if (!debugfs_create_dir(...)) with IS_ERR() checks throughout,
     since debugfs_create_dir() returns ERR_PTR on failure, not NULL
     (patches 1, 3).
   - Add NULL check for smmu->debugfs before dereference in stream table
     create path (patch 3).
   - Add NULL check for kzalloc_obj() result (patch 3).

  Code style & cleanup:
   - Directory tree comment: use ├── for last entry to avoid churn on
     subsequent patches (patches 1-5).
   - Fix tab/space alignment in directory tree comments (patches 1, 2).
   - Reorder function parameters: @smmu first, @dev second (patch 3).
   - Fix return statement indentation (patch 3).
   - Move function declarations from #ifndef-static pattern to header file
     (patch 3).
   - Move char name[32] and snprintf() to function top for reuse by
     iommu_device_sysfs_add() regardless of CONFIG_ARM_SMMU_V3_DEBUGFS
     (patch 1).
   - Adopt non-tab-aligned style for new struct members (patches 1, 3).
   - Remove useless comments: "DebugFS Info" and "Reserved for future
     extensions" (patches 1, 3).
   - Remove spurious blank line (patch 3).

- Link: https://lore.kernel.org/all/20260328101706.3448655-1-xiaqinxin@huawei.com/

Qinxin Xia (5):
  iommu/arm-smmu-v3: Add basic debugfs framework
  iommu/arm-smmu-v3: Add register display to debugfs
  iommu/arm-smmu-v3: Add Stream Table Entry display to debugfs
  iommu/arm-smmu-v3: Add device symlink in stream table debugfs
  iommu/arm-smmu-v3: Add Context Descriptor display to debugfs

 drivers/iommu/Kconfig                              |  11 +
 drivers/iommu/arm/arm-smmu-v3/Makefile             |   1 +
 .../iommu/arm/arm-smmu-v3/arm-smmu-v3-debugfs.c    | 609 +++++++++++++++++++++
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c        |  27 +-
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h        |  30 +
 5 files changed, 675 insertions(+), 3 deletions(-)
 create mode 100644 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-debugfs.c

--
2.51.0


             reply	other threads:[~2026-03-28 10:17 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-28 10:17 Qinxin Xia [this message]
2026-03-28 10:17 ` [RFC PATCH v2 1/5] iommu/arm-smmu-v3: Add basic debugfs framework Qinxin Xia
2026-03-30 10:46   ` Nicolin Chen
2026-04-02  3:50     ` Qinxin Xia
2026-03-28 10:17 ` [RFC PATCH v2 2/5] iommu/arm-smmu-v3: Add register display to debugfs Qinxin Xia
2026-03-30 11:25   ` Nicolin Chen
2026-03-28 10:17 ` [RFC PATCH v2 3/5] iommu/arm-smmu-v3: Add Stream Table Entry " Qinxin Xia
2026-04-04  5:43   ` Nicolin Chen
2026-03-28 10:17 ` [RFC PATCH v2 4/5] iommu/arm-smmu-v3: Add device symlink in stream table debugfs Qinxin Xia
2026-03-28 10:17 ` [RFC PATCH v2 5/5] iommu/arm-smmu-v3: Add Context Descriptor display to debugfs Qinxin Xia
2026-05-20  6:37 ` [PATCH 0/5] Add debugfs support for ARM SMMUv3 Qinxin Xia
2026-05-20  6:37 ` [PATCH 1/5] iommu/arm-smmu-v3: Add basic debugfs framework Qinxin Xia
2026-05-27  0:41   ` Nicolin Chen
2026-05-20  6:37 ` [PATCH 2/5] iommu/arm-smmu-v3: Add register display to debugfs Qinxin Xia
2026-05-27  1:28   ` Nicolin Chen
2026-05-20  6:37 ` [PATCH 3/5] iommu/arm-smmu-v3: Add Stream Table Entry " Qinxin Xia
2026-05-27  2:18   ` Nicolin Chen
2026-05-27  2:43     ` Nicolin Chen
2026-05-20  6:37 ` [PATCH 4/5] iommu/arm-smmu-v3: Add device symlink in stream table debugfs Qinxin Xia
2026-05-20  6:37 ` [PATCH 5/5] iommu/arm-smmu-v3: Add Context Descriptor display to debugfs Qinxin Xia
2026-05-27  2:40   ` Nicolin Chen
2026-05-27  0:07 ` [PATCH 0/5] Add debugfs support for ARM SMMUv3 Nicolin Chen
  -- strict thread matches above, loose matches on Subject: below --
2026-03-28 10:09 [RFC PATCH v2 " Qinxin Xia
2026-03-28 10: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=20260328101706.3448655-1-xiaqinxin@huawei.com \
    --to=xiaqinxin@huawei$(echo .)com \
    --cc=fanghao11@huawei$(echo .)com \
    --cc=iommu@lists$(echo .)linux.dev \
    --cc=jonathan.cameron@huawei$(echo .)com \
    --cc=jpb@kernel$(echo .)org \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    --cc=linuxarm@huawei$(echo .)com \
    --cc=nicolinc@nvidia$(echo .)com \
    --cc=prime.zeng@hisilicon$(echo .)com \
    --cc=robin.murphy@arm$(echo .)com \
    --cc=wangzhou1@hisilicon$(echo .)com \
    --cc=will@kernel$(echo .)org \
    --cc=wuyifan50@huawei$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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