summaryrefslogtreecommitdiff
path: root/drivers/iommu/iommu-debug.c
diff options
context:
space:
mode:
authorSusheel Khiani <skhiani@codeaurora.org>2015-08-25 17:25:42 +0530
committerJeevan Shriram <jshriram@codeaurora.org>2016-05-18 13:42:13 -0700
commit26f7b639c8cd8d8521067c1394e3530f5c7e6b6e (patch)
tree8d9d64469681e23ea05d4259ea20865f6d4f5dbc /drivers/iommu/iommu-debug.c
parent825bb2c97c2b10d7a3fb1fb7f909919586d55728 (diff)
iommu/iommu-debug: Maintain list of domains during alloc
Current list of domains in iommu-debug was only maintained during attach/detach calls. But for masters like graphics this won't account for all the domains, as it allocates multiple different domains but attaches only one domain at a time. Add support for maintaining list of unattached domains too by adding them to debug_attachments list during domain alloc but keeping dev as NULL. We would add entry in debugfs attachment directory only on actual attach call. Change-Id: Ifde043e5c39f356b4187a30cbdf020ee943618f1 Signed-off-by: Susheel Khiani <skhiani@codeaurora.org>
Diffstat (limited to 'drivers/iommu/iommu-debug.c')
-rw-r--r--drivers/iommu/iommu-debug.c81
1 files changed, 64 insertions, 17 deletions
diff --git a/drivers/iommu/iommu-debug.c b/drivers/iommu/iommu-debug.c
index 6772868d1c9b..edfc9aeac730 100644
--- a/drivers/iommu/iommu-debug.c
+++ b/drivers/iommu/iommu-debug.c
@@ -276,8 +276,7 @@ err_rmdir:
return -EIO;
}
-void iommu_debug_attach_device(struct iommu_domain *domain,
- struct device *dev)
+void iommu_debug_domain_add(struct iommu_domain *domain)
{
struct iommu_debug_attachment *attach;
@@ -288,23 +287,64 @@ void iommu_debug_attach_device(struct iommu_domain *domain,
goto out_unlock;
attach->domain = domain;
- attach->dev = dev;
-
- /*
- * we might not init until after other drivers start calling
- * iommu_attach_device. Only set up the debugfs nodes if we've
- * already init'd to avoid polluting the top-level debugfs
- * directory (by calling debugfs_create_dir with a NULL
- * parent). These will be flushed out later once we init.
- */
- if (debugfs_attachments_dir)
- iommu_debug_attach_add_debugfs(attach);
-
+ attach->dev = NULL;
list_add(&attach->list, &iommu_debug_attachments);
+
out_unlock:
mutex_unlock(&iommu_debug_attachments_lock);
}
+void iommu_debug_domain_remove(struct iommu_domain *domain)
+{
+ struct iommu_debug_attachment *it;
+
+ mutex_lock(&iommu_debug_attachments_lock);
+ list_for_each_entry(it, &iommu_debug_attachments, list)
+ if (it->domain == domain && it->dev == NULL)
+ break;
+
+ if (&it->list == &iommu_debug_attachments) {
+ WARN(1, "Couldn't find debug attachment for domain=0x%p",
+ domain);
+ } else {
+ list_del(&it->list);
+ kfree(it);
+ }
+ mutex_unlock(&iommu_debug_attachments_lock);
+}
+
+void iommu_debug_attach_device(struct iommu_domain *domain,
+ struct device *dev)
+{
+ struct iommu_debug_attachment *attach;
+
+ mutex_lock(&iommu_debug_attachments_lock);
+
+ list_for_each_entry(attach, &iommu_debug_attachments, list)
+ if (attach->domain == domain && attach->dev == NULL)
+ break;
+
+ if (&attach->list == &iommu_debug_attachments) {
+ WARN(1, "Couldn't find debug attachment for domain=0x%p dev=%s",
+ domain, dev_name(dev));
+ } else {
+ attach->dev = dev;
+
+ /*
+ * we might not init until after other drivers start calling
+ * iommu_attach_device. Only set up the debugfs nodes if we've
+ * already init'd to avoid polluting the top-level debugfs
+ * directory (by calling debugfs_create_dir with a NULL
+ * parent). These will be flushed out later once we init.
+ */
+
+ if (debugfs_attachments_dir)
+ iommu_debug_attach_add_debugfs(attach);
+ }
+
+ mutex_unlock(&iommu_debug_attachments_lock);
+}
+
void iommu_debug_detach_device(struct iommu_domain *domain,
struct device *dev)
{
@@ -319,9 +359,15 @@ void iommu_debug_detach_device(struct iommu_domain *domain,
WARN(1, "Couldn't find debug attachment for domain=0x%p dev=%s",
domain, dev_name(dev));
} else {
- list_del(&it->list);
+ /*
+ * Just remove debugfs entry and mark dev as NULL on
+ * iommu_detach call. We would remove the actual
+ * attachment entry from the list only on domain_free call.
+ * This is to ensure we keep track of unattached domains too.
+ */
+
debugfs_remove_recursive(it->dentry);
- kfree(it);
+ it->dev = NULL;
}
mutex_unlock(&iommu_debug_attachments_lock);
}
@@ -342,7 +388,8 @@ static int iommu_debug_init_tracking(void)
/* set up debugfs entries for attachments made during early boot */
list_for_each_entry(attach, &iommu_debug_attachments, list)
- iommu_debug_attach_add_debugfs(attach);
+ if (attach->dev)
+ iommu_debug_attach_add_debugfs(attach);
out_unlock:
mutex_unlock(&iommu_debug_attachments_lock);