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