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

Commit f77aad03 authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "iommu: Modify default_domain treatment in attach/detach"

parents 63e6b38a fd330bd4
Loading
Loading
Loading
Loading
+8 −21
Original line number Diff line number Diff line
@@ -1450,9 +1450,6 @@ static int __iommu_attach_group(struct iommu_domain *domain,
{
	int ret;

	if (group->default_domain && group->domain != group->default_domain)
		return -EBUSY;

	ret = __iommu_group_for_each_dev(group, domain,
					 iommu_group_do_attach_device);
	if (ret == 0)
@@ -1482,30 +1479,20 @@ static int iommu_group_do_detach_device(struct device *dev, void *data)
	return 0;
}

/*
 * Although upstream implements detaching the default_domain as a noop,
 * the "SID switch" secure usecase require complete removal of SIDS/SMRS
 * from HLOS iommu registers.
 */
static void __iommu_detach_group(struct iommu_domain *domain,
				 struct iommu_group *group)
{
	int ret;

	if (!group->default_domain) {
	__iommu_group_for_each_dev(group, domain,
					   iommu_group_do_detach_device);
	group->domain = NULL;
	return;
}

	if (group->domain == group->default_domain)
		return;

	/* Detach by re-attaching to the default domain */
	ret = __iommu_group_for_each_dev(group, group->default_domain,
					 iommu_group_do_attach_device);
	if (ret != 0)
		WARN_ON(1);
	else
		group->domain = group->default_domain;
}

void iommu_detach_group(struct iommu_domain *domain, struct iommu_group *group)
{
	mutex_lock(&group->mutex);