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

Commit 09137117 authored by Mitchel Humpherys's avatar Mitchel Humpherys
Browse files

iommu/iommu-debug: Only uniquify directory names for dynamic domains



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: default avatarMitchel Humpherys <mitchelh@codeaurora.org>
parent 23c04962
Loading
Loading
Loading
Loading
+21 −8
Original line number Diff line number Diff line
@@ -195,24 +195,37 @@ 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;

	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);
		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);
		if (is_dynamic)
			kfree(attach_name);
		return -EIO;
	}

	if (is_dynamic)
		kfree(attach_name);

	if (!debugfs_create_file(