Skip to content

Commit cc0e120

Browse files
digetxjoergroedel
authored andcommitted
iommu/tegra: gart: Don't detach devices from inactive domains
There could be unlimited number of allocated domains, but only one domain can be active at a time. Hence devices must be detached only from the active domain. 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 5dd82cd commit cc0e120

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/iommu/tegra-gart.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ static int gart_iommu_attach_dev(struct iommu_domain *domain,
171171
struct device *dev)
172172
{
173173
struct gart_domain *gart_domain = to_gart_domain(domain);
174-
struct gart_device *gart = gart_domain->gart;
174+
struct gart_device *gart = gart_handle;
175175
struct gart_client *client, *c;
176176
int err = 0;
177177

@@ -195,6 +195,7 @@ static int gart_iommu_attach_dev(struct iommu_domain *domain,
195195
goto fail;
196196
}
197197
gart->active_domain = domain;
198+
gart_domain->gart = gart;
198199
list_add(&client->list, &gart->client);
199200
spin_unlock(&gart->client_lock);
200201
dev_dbg(gart->dev, "Attached %s\n", dev_name(dev));
@@ -217,8 +218,10 @@ static void __gart_iommu_detach_dev(struct iommu_domain *domain,
217218
if (c->dev == dev) {
218219
list_del(&c->list);
219220
kfree(c);
220-
if (list_empty(&gart->client))
221+
if (list_empty(&gart->client)) {
221222
gart->active_domain = NULL;
223+
gart_domain->gart = NULL;
224+
}
222225
dev_dbg(gart->dev, "Detached %s\n", dev_name(dev));
223226
return;
224227
}
@@ -254,7 +257,6 @@ static struct iommu_domain *gart_iommu_domain_alloc(unsigned type)
254257
if (!gart_domain)
255258
return NULL;
256259

257-
gart_domain->gart = gart;
258260
gart_domain->domain.geometry.aperture_start = gart->iovmm_base;
259261
gart_domain->domain.geometry.aperture_end = gart->iovmm_base +
260262
gart->page_count * GART_PAGE_SIZE - 1;

0 commit comments

Comments
 (0)