Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c75ae496 authored by Mitchel Humpherys's avatar Mitchel Humpherys Committed by Patrick Daly
Browse files

iommu: Create iommu debugfs directory from IOMMU code



Currently we're creating an "iommu" debugfs directory from the
iommu-debug code.  Other IOMMU modules might want to make use of this
same directory, so create it from the IOMMU framework code itself.

Change-Id: I679fdfc34ba5fcbd927dc5981438c6fabcfa3639
Signed-off-by: default avatarMitchel Humpherys <mitchelh@codeaurora.org>
Signed-off-by: default avatarPatrick Daly <pdaly@codeaurora.org>
parent a05b2528
Loading
Loading
Loading
Loading
+18 −16
Original line number Diff line number Diff line
@@ -23,8 +23,6 @@
#include <linux/module.h>
#include <linux/uaccess.h>

static struct dentry *debugfs_top_dir;

#ifdef CONFIG_IOMMU_DEBUG_TRACKING

static DEFINE_MUTEX(iommu_debug_attachments_lock);
@@ -156,7 +154,7 @@ static int iommu_debug_init_tracking(void)

	mutex_lock(&iommu_debug_attachments_lock);
	debugfs_attachments_dir = debugfs_create_dir("attachments",
						     debugfs_top_dir);
						     iommu_debugfs_top);
	if (!debugfs_attachments_dir) {
		pr_err("Couldn't create iommu/attachments debugfs directory\n");
		ret = -ENODEV;
@@ -171,8 +169,14 @@ static int iommu_debug_init_tracking(void)
	mutex_unlock(&iommu_debug_attachments_lock);
	return ret;
}

static void iommu_debug_destroy_tracking(void)
{
	debugfs_remove_recursive(debugfs_attachments_dir);
}
#else
static inline int iommu_debug_init_tracking(void) { return 0; }
static inline void iommu_debug_destroy_tracking(void) { }
#endif

#ifdef CONFIG_IOMMU_TESTS
@@ -752,7 +756,7 @@ static int snarf_iommu_devices(struct device *dev, void *ignored)
static int iommu_debug_init_tests(void)
{
	debugfs_tests_dir = debugfs_create_dir("tests",
					       debugfs_top_dir);
					       iommu_debugfs_top);
	if (!debugfs_tests_dir) {
		pr_err("Couldn't create iommu/tests debugfs directory\n");
		return -ENODEV;
@@ -761,33 +765,31 @@ static int iommu_debug_init_tests(void)
	return bus_for_each_dev(&platform_bus_type, NULL, NULL,
				snarf_iommu_devices);
}

static void iommu_debug_destroy_tests(void)
{
	debugfs_remove_recursive(debugfs_tests_dir);
}
#else
static inline int iommu_debug_init_tests(void) { return 0; }
static inline void iommu_debug_destroy_tests(void) { }
#endif

static int iommu_debug_init(void)
{
	debugfs_top_dir = debugfs_create_dir("iommu", NULL);
	if (!debugfs_top_dir) {
		pr_err("Couldn't create iommu debugfs directory\n");
		return -ENODEV;
	}

	if (iommu_debug_init_tracking())
		goto err;
		return -ENODEV;

	if (iommu_debug_init_tests())
		goto err;
		return -ENODEV;

	return 0;
err:
	debugfs_remove_recursive(debugfs_top_dir);
	return -ENODEV;
}

static void iommu_debug_exit(void)
{
	debugfs_remove_recursive(debugfs_top_dir);
	iommu_debug_destroy_tracking();
	iommu_debug_destroy_tests();
}

module_init(iommu_debug_init);
+9 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
#include <linux/err.h>
#include <linux/pci.h>
#include <linux/bitops.h>
#include <linux/debugfs.h>
#include <trace/events/iommu.h>

#include "iommu-debug.h"
@@ -1490,12 +1491,20 @@ void iommu_domain_window_disable(struct iommu_domain *domain, u32 wnd_nr)
}
EXPORT_SYMBOL_GPL(iommu_domain_window_disable);

struct dentry *iommu_debugfs_top;

static int __init iommu_init(void)
{
	iommu_group_kset = kset_create_and_add("iommu_groups",
					       NULL, kernel_kobj);
	BUG_ON(!iommu_group_kset);

	iommu_debugfs_top = debugfs_create_dir("iommu", NULL);
	if (!iommu_debugfs_top) {
		pr_err("Couldn't create iommu debugfs directory\n");
		return -ENODEV;
	}

	return 0;
}
core_initcall(iommu_init);
+2 −0
Original line number Diff line number Diff line
@@ -144,6 +144,8 @@ struct iommu_dm_region {
	int			prot;
};

extern struct dentry *iommu_debugfs_top;

#ifdef CONFIG_IOMMU_API

/**