iommu/amd: Add debugfs support to dump IOMMU command buffer
authorDheeraj Kumar Srivastava <dheerajkumar.srivastava@amd.com>
Wed, 2 Jul 2025 09:38:00 +0000 (15:08 +0530)
committerWill Deacon <will@kernel.org>
Tue, 15 Jul 2025 10:41:52 +0000 (11:41 +0100)
commitfb3af1f4fefb78f9180446aae2834e11a6f7d134
treeafd23f512a926c80c7eb5620dd0c7eb9bcffcf90
parent4d9c5d5a1dc940e44084e5cab780e1646501b6c1
iommu/amd: Add debugfs support to dump IOMMU command buffer

IOMMU driver sends command to IOMMU hardware via command buffer. In cases
where IOMMU hardware fails to process commands in command buffer, dumping
it is a valuable input to debug the issue.

IOMMU hardware processes command buffer entry at offset equals to the head
pointer. Dumping just the entry at the head pointer may not always be
useful. The current head may not be pointing to the entry of the command
buffer which is causing the issue. IOMMU Hardware may have processed the
entry and updated the head pointer. So dumping the entire command buffer
gives a broad understanding of what hardware was/is doing. The command
buffer dump will have all entries from start to end of the command buffer.
Along with that, it will have a head and tail command buffer pointer
register dump to facilitate where the IOMMU driver and hardware are in
the command buffer for injecting and processing the entries respectively.

Command buffer is a per IOMMU data structure. So dumping on per IOMMU
basis.
eg.
-> To get command buffer dump for iommu<x> (say, iommu00)
   #cat /sys/kernel/debug/iommu/amd/iommu00/cmdbuf

Signed-off-by: Dheeraj Kumar Srivastava <dheerajkumar.srivastava@amd.com>
Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>
Link: https://lore.kernel.org/r/20250702093804.849-5-dheerajkumar.srivastava@amd.com
Signed-off-by: Will Deacon <will@kernel.org>
drivers/iommu/amd/amd_iommu_types.h
drivers/iommu/amd/debugfs.c
drivers/iommu/amd/iommu.c