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>
5 files changed