amd_iommu_debugfs.c 805 B

123456789101112131415161718192021222324252627282930313233
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * AMD IOMMU driver
  4. *
  5. * Copyright (C) 2018 Advanced Micro Devices, Inc.
  6. *
  7. * Author: Gary R Hook <gary.hook@amd.com>
  8. */
  9. #include <linux/debugfs.h>
  10. #include <linux/iommu.h>
  11. #include <linux/pci.h>
  12. #include "amd_iommu_proto.h"
  13. #include "amd_iommu_types.h"
  14. static struct dentry *amd_iommu_debugfs;
  15. static DEFINE_MUTEX(amd_iommu_debugfs_lock);
  16. #define MAX_NAME_LEN 20
  17. void amd_iommu_debugfs_setup(struct amd_iommu *iommu)
  18. {
  19. char name[MAX_NAME_LEN + 1];
  20. mutex_lock(&amd_iommu_debugfs_lock);
  21. if (!amd_iommu_debugfs)
  22. amd_iommu_debugfs = debugfs_create_dir("amd",
  23. iommu_debugfs_dir);
  24. mutex_unlock(&amd_iommu_debugfs_lock);
  25. snprintf(name, MAX_NAME_LEN, "iommu%02d", iommu->index);
  26. iommu->debugfs = debugfs_create_dir(name, amd_iommu_debugfs);
  27. }