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

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

iommu/iommu-debug: Make attachment directories unique



Currently, the device name for the SMMU context bank device is used as
the filename for the IOMMU debug info file.  This doesn't work in cases
where multiple domains can be attached to a single SMMU context bank
device (like dynamic domains).  Make these filenames unique by appending
a 16-byte uuid to the name.

Change-Id: Ie26ece773bfa2e8c75a329a8cb8461bcd598218e
Signed-off-by: default avatarMitchel Humpherys <mitchelh@codeaurora.org>
parent 35afb780
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -71,27 +71,36 @@ void iommu_debug_attach_device(struct iommu_domain *domain,
			       struct device *dev)
{
	struct iommu_debug_attachment *attach;
	char *attach_name;
	uuid_le uuid;

	mutex_lock(&iommu_debug_attachments_lock);

	uuid_le_gen(&uuid);
	attach_name = kasprintf(GFP_KERNEL, "%s-%pUl", dev_name(dev), uuid.b);
	if (!attach_name)
		goto unlock;

	attach = kmalloc(sizeof(*attach), GFP_KERNEL);
	if (!attach)
		goto unlock;
		goto free_attach_name;

	attach->domain = domain;
	attach->dev = dev;

	attach->dentry = debugfs_create_file(
		dev_name(dev), S_IRUSR, debugfs_attachments_dir, attach,
		attach_name, S_IRUSR, debugfs_attachments_dir, attach,
		&iommu_debug_attachment_fops);
	if (!attach->dentry) {
		pr_err("Couldn't create iommu/attachments/%s debugfs file for domain 0x%p\n",
		       dev_name(dev), domain);
		       attach_name, domain);
		kfree(attach);
		goto unlock;
		goto free_attach_name;
	}

	list_add(&attach->list, &iommu_debug_attachments);
free_attach_name:
	kfree(attach_name);
unlock:
	mutex_unlock(&iommu_debug_attachments_lock);
}