OSDN Git Service

iommu/iommu-debug: Only uniquify directory names for dynamic domains
authorMitchel Humpherys <mitchelh@codeaurora.org>
Wed, 26 Aug 2015 18:52:57 +0000 (11:52 -0700)
committerDavid Keitel <dkeitel@codeaurora.org>
Tue, 22 Mar 2016 18:14:06 +0000 (11:14 -0700)
The subdirectories under "attach" currently get a UUID appended to their
name to ensure that there won't be any collisions when multiple domains
are attached to the same device.  This is only needed for dynamic
domains since those are the only types of domains that can be attached
to the same device concurrently.  Only do the uniquification for dynamic
domains since the resulting directory name is a bit messy with the UUID.

Change-Id: Ia86b192e5b9d6a63132228fa86549a2977ec74a4
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
drivers/iommu/iommu-debug.c

index f6f135c..8438581 100644 (file)
@@ -195,25 +195,38 @@ static const struct file_operations iommu_debug_attachment_reg_write_fops = {
 static int iommu_debug_attach_add_debugfs(
        struct iommu_debug_attachment *attach)
 {
-       uuid_le uuid;
-       char *attach_name;
+       const char *attach_name;
        struct device *dev = attach->dev;
        struct iommu_domain *domain = attach->domain;
+       int is_dynamic;
 
-       uuid_le_gen(&uuid);
-       attach_name = kasprintf(GFP_KERNEL, "%s-%pUl", dev_name(dev), uuid.b);
-       if (!attach_name)
-               return -ENOMEM;
+       if (iommu_domain_get_attr(domain, DOMAIN_ATTR_DYNAMIC, &is_dynamic))
+               is_dynamic = 0;
+
+       if (is_dynamic) {
+               uuid_le uuid;
+
+               uuid_le_gen(&uuid);
+               attach_name = kasprintf(GFP_KERNEL, "%s-%pUl", dev_name(dev),
+                                       uuid.b);
+               if (!attach_name)
+                       return -ENOMEM;
+       } else {
+               attach_name = dev_name(dev);
+       }
 
        attach->dentry = debugfs_create_dir(attach_name,
                                            debugfs_attachments_dir);
        if (!attach->dentry) {
                pr_err("Couldn't create iommu/attachments/%s debugfs directory for domain 0x%p\n",
                       attach_name, domain);
-               kfree(attach_name);
+               if (is_dynamic)
+                       kfree(attach_name);
                return -EIO;
        }
-       kfree(attach_name);
+
+       if (is_dynamic)
+               kfree(attach_name);
 
        if (!debugfs_create_file(
                    "info", S_IRUSR, attach->dentry, attach,