[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20181209202950.31486-17-digetx@gmail.com>
Date: Sun, 9 Dec 2018 23:29:45 +0300
From: Dmitry Osipenko <digetx@...il.com>
To: Thierry Reding <thierry.reding@...il.com>,
Jonathan Hunter <jonathanh@...dia.com>,
Joerg Roedel <joro@...tes.org>
Cc: Robin Murphy <robin.murphy@....com>,
iommu@...ts.linux-foundation.org, devicetree@...r.kernel.org,
linux-tegra@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH v6 16/21] 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@...il.com>
Acked-by: Thierry Reding <treding@...dia.com>
---
drivers/iommu/tegra-gart.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c
index bb5303b06845..1be595d15e7e 100644
--- a/drivers/iommu/tegra-gart.c
+++ b/drivers/iommu/tegra-gart.c
@@ -57,6 +57,7 @@ struct gart_device {
spinlock_t pte_lock; /* for pagetable */
struct list_head client;
spinlock_t client_lock; /* for client list */
+ struct iommu_domain *active_domain; /* current active domain */
struct device *dev;
struct iommu_device iommu; /* IOMMU Core handle */
@@ -186,6 +187,12 @@ static int gart_iommu_attach_dev(struct iommu_domain *domain,
goto fail;
}
}
+ if (gart->active_domain && gart->active_domain != domain) {
+ dev_err(gart->dev, "Only one domain can be active at a time\n");
+ err = -EINVAL;
+ goto fail;
+ }
+ gart->active_domain = domain;
list_add(&client->list, &gart->client);
spin_unlock(&gart->client_lock);
dev_dbg(gart->dev, "Attached %s\n", dev_name(dev));
@@ -208,6 +215,8 @@ static void __gart_iommu_detach_dev(struct iommu_domain *domain,
if (c->dev == dev) {
list_del(&c->list);
devm_kfree(gart->dev, c);
+ if (list_empty(&gart->client))
+ gart->active_domain = NULL;
dev_dbg(gart->dev, "Detached %s\n", dev_name(dev));
return;
}
--
2.19.1
Powered by blists - more mailing lists