Skip to content

Commit 7d849b7

Browse files
digetxjoergroedel
authored andcommitted
iommu/tegra: gart: Allow only one active domain at a time
GART has a single address space that is shared by all devices, hence only one domain could be active at a time. Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Acked-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent 8e92491 commit 7d849b7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/iommu/tegra-gart.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ struct gart_device {
5757
spinlock_t pte_lock; /* for pagetable */
5858
struct list_head client;
5959
spinlock_t client_lock; /* for client list */
60+
struct iommu_domain *active_domain; /* current active domain */
6061
struct device *dev;
6162

6263
struct iommu_device iommu; /* IOMMU Core handle */
@@ -186,6 +187,12 @@ static int gart_iommu_attach_dev(struct iommu_domain *domain,
186187
goto fail;
187188
}
188189
}
190+
if (gart->active_domain && gart->active_domain != domain) {
191+
dev_err(gart->dev, "Only one domain can be active at a time\n");
192+
err = -EINVAL;
193+
goto fail;
194+
}
195+
gart->active_domain = domain;
189196
list_add(&client->list, &gart->client);
190197
spin_unlock(&gart->client_lock);
191198
dev_dbg(gart->dev, "Attached %s\n", dev_name(dev));
@@ -208,6 +215,8 @@ static void __gart_iommu_detach_dev(struct iommu_domain *domain,
208215
if (c->dev == dev) {
209216
list_del(&c->list);
210217
devm_kfree(gart->dev, c);
218+
if (list_empty(&gart->client))
219+
gart->active_domain = NULL;
211220
dev_dbg(gart->dev, "Detached %s\n", dev_name(dev));
212221
return;
213222
}

0 commit comments

Comments
 (0)