iommu: Add debugging infrastructure
Currently, debugging IOMMU issues is done via manual instrumentation of
the code or via low-level techniques like using a JTAG debugger.
Introduce a set of library functions and debugfs files to facilitate
interactive debugging and testing.
This patch introduces the basic infrastructure as well an initial
debugfs for:
- viewing IOMMU attachments (domain->dev mappings created by
iommu_attach_device) and resulting attributes (like the base address
of the page tables)
- basic performance profiling
Example usage:
# cd /sys/kernel/debug/iommu/attachments
# cat b40000.qcom,kgsl-iommu:iommu_kgsl_cb2
Domain: 0xffffffc0cb983f00
PT_BASE_ADDR: virt=0xffffffc057eca000 phys=0x00000000d7eca000
# cd /sys/kernel/debug/iommu/tests
# cat soc:qcom,cam_smmu:msm_cam_smmu_cb1/profiling
size iommu_map iommu_unmap
4K 47 us 909 us
64K 97 us 594 us
2M 1536 us 605 us
12M 8737 us 1193 us
20M 26517 us 1121 us
size iommu_map_sg iommu_unmap
64K 31 us 656 us
2M 885 us 600 us
12M 2674 us 687 us
20M 4352 us 1096 us
Change-Id: I1c301eec6e64688831cad80ffd0380743f7f0df6
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
index 189ed9e..1932824 100644
--- a/drivers/iommu/Kconfig
+++ b/drivers/iommu/Kconfig
@@ -363,4 +363,34 @@
if unsure, say N here.
+menuconfig IOMMU_DEBUG
+ bool "IOMMU Profiling and Debugging"
+ help
+ Makes available some additional IOMMU profiling and debugging
+ options.
+
+if IOMMU_DEBUG
+
+config IOMMU_DEBUG_TRACKING
+ bool "Track key IOMMU events"
+ select IOMMU_API
+ help
+ Enables additional debug tracking in the IOMMU framework code.
+ Tracking information and tests can be accessed through various
+ debugfs files.
+
+ Say Y here if you need to debug IOMMU issues and are okay with
+ the performance penalty of the tracking.
+
+config IOMMU_TESTS
+ bool "Interactive IOMMU performance/functional tests"
+ select IOMMU_API
+ help
+ Enables a suite of IOMMU unit tests. The tests are runnable
+ through debugfs. Unlike the IOMMU_DEBUG_TRACKING option, the
+ impact of enabling this option to overal system performance
+ should be minimal.
+
+endif # IOMMU_DEBUG
+
endif # IOMMU_SUPPORT