diff options
author | Joerg Roedel <jroedel@suse.de> | 2015-03-26 08:43:09 -0400 |
---|---|---|
committer | Joerg Roedel <jroedel@suse.de> | 2015-03-31 09:32:02 -0400 |
commit | 8cf851e0945251766e8bf1f966a9aef80663ed63 (patch) | |
tree | c4b736ff29fb83de5e4872693fa897f47e03070a | |
parent | 00a77deb0f2f2c35cfeba183df98f92487d2e88b (diff) |
iommu/omap: Make use of domain_alloc and domain_free
Implement the new domain_alloc and domain_free call-backs
and remove the old domain_init/destroy ones.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
-rw-r--r-- | drivers/iommu/omap-iommu.c | 49 |
1 files changed, 29 insertions, 20 deletions
diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c index a4ba851825c2..a22c33d6a486 100644 --- a/drivers/iommu/omap-iommu.c +++ b/drivers/iommu/omap-iommu.c | |||
@@ -59,6 +59,7 @@ struct omap_iommu_domain { | |||
59 | struct omap_iommu *iommu_dev; | 59 | struct omap_iommu *iommu_dev; |
60 | struct device *dev; | 60 | struct device *dev; |
61 | spinlock_t lock; | 61 | spinlock_t lock; |
62 | struct iommu_domain domain; | ||
62 | }; | 63 | }; |
63 | 64 | ||
64 | #define MMU_LOCK_BASE_SHIFT 10 | 65 | #define MMU_LOCK_BASE_SHIFT 10 |
@@ -80,6 +81,15 @@ static struct platform_driver omap_iommu_driver; | |||
80 | static struct kmem_cache *iopte_cachep; | 81 | static struct kmem_cache *iopte_cachep; |
81 | 82 | ||
82 | /** | 83 | /** |
84 | * to_omap_domain - Get struct omap_iommu_domain from generic iommu_domain | ||
85 | * @dom: generic iommu domain handle | ||
86 | **/ | ||
87 | static struct omap_iommu_domain *to_omap_domain(struct iommu_domain *dom) | ||
88 | { | ||
89 | return container_of(dom, struct omap_iommu_domain, domain); | ||
90 | } | ||
91 | |||
92 | /** | ||
83 | * omap_iommu_save_ctx - Save registers for pm off-mode support | 93 | * omap_iommu_save_ctx - Save registers for pm off-mode support |
84 | * @dev: client device | 94 | * @dev: client device |
85 | **/ | 95 | **/ |
@@ -901,7 +911,7 @@ static irqreturn_t iommu_fault_handler(int irq, void *data) | |||
901 | u32 *iopgd, *iopte; | 911 | u32 *iopgd, *iopte; |
902 | struct omap_iommu *obj = data; | 912 | struct omap_iommu *obj = data; |
903 | struct iommu_domain *domain = obj->domain; | 913 | struct iommu_domain *domain = obj->domain; |
904 | struct omap_iommu_domain *omap_domain = domain->priv; | 914 | struct omap_iommu_domain *omap_domain = to_omap_domain(domain); |
905 | 915 | ||
906 | if (!omap_domain->iommu_dev) | 916 | if (!omap_domain->iommu_dev) |
907 | return IRQ_NONE; | 917 | return IRQ_NONE; |
@@ -1113,7 +1123,7 @@ static u32 iotlb_init_entry(struct iotlb_entry *e, u32 da, u32 pa, int pgsz) | |||
1113 | static int omap_iommu_map(struct iommu_domain *domain, unsigned long da, | 1123 | static int omap_iommu_map(struct iommu_domain *domain, unsigned long da, |
1114 | phys_addr_t pa, size_t bytes, int prot) | 1124 | phys_addr_t pa, size_t bytes, int prot) |
1115 | { | 1125 | { |
1116 | struct omap_iommu_domain *omap_domain = domain->priv; | 1126 | struct omap_iommu_domain *omap_domain = to_omap_domain(domain); |
1117 | struct omap_iommu *oiommu = omap_domain->iommu_dev; | 1127 | struct omap_iommu *oiommu = omap_domain->iommu_dev; |
1118 | struct device *dev = oiommu->dev; | 1128 | struct device *dev = oiommu->dev; |
1119 | struct iotlb_entry e; | 1129 | struct iotlb_entry e; |
@@ -1140,7 +1150,7 @@ static int omap_iommu_map(struct iommu_domain *domain, unsigned long da, | |||
1140 | static size_t omap_iommu_unmap(struct iommu_domain *domain, unsigned long da, | 1150 | static size_t omap_iommu_unmap(struct iommu_domain *domain, unsigned long da, |
1141 | size_t size) | 1151 | size_t size) |
1142 | { | 1152 | { |
1143 | struct omap_iommu_domain *omap_domain = domain->priv; | 1153 | struct omap_iommu_domain *omap_domain = to_omap_domain(domain); |
1144 | struct omap_iommu *oiommu = omap_domain->iommu_dev; | 1154 | struct omap_iommu *oiommu = omap_domain->iommu_dev; |
1145 | struct device *dev = oiommu->dev; | 1155 | struct device *dev = oiommu->dev; |
1146 | 1156 | ||
@@ -1152,7 +1162,7 @@ static size_t omap_iommu_unmap(struct iommu_domain *domain, unsigned long da, | |||
1152 | static int | 1162 | static int |
1153 | omap_iommu_attach_dev(struct iommu_domain *domain, struct device *dev) | 1163 | omap_iommu_attach_dev(struct iommu_domain *domain, struct device *dev) |
1154 | { | 1164 | { |
1155 | struct omap_iommu_domain *omap_domain = domain->priv; | 1165 | struct omap_iommu_domain *omap_domain = to_omap_domain(domain); |
1156 | struct omap_iommu *oiommu; | 1166 | struct omap_iommu *oiommu; |
1157 | struct omap_iommu_arch_data *arch_data = dev->archdata.iommu; | 1167 | struct omap_iommu_arch_data *arch_data = dev->archdata.iommu; |
1158 | int ret = 0; | 1168 | int ret = 0; |
@@ -1212,17 +1222,20 @@ static void _omap_iommu_detach_dev(struct omap_iommu_domain *omap_domain, | |||
1212 | static void omap_iommu_detach_dev(struct iommu_domain *domain, | 1222 | static void omap_iommu_detach_dev(struct iommu_domain *domain, |
1213 | struct device *dev) | 1223 | struct device *dev) |
1214 | { | 1224 | { |
1215 | struct omap_iommu_domain *omap_domain = domain->priv; | 1225 | struct omap_iommu_domain *omap_domain = to_omap_domain(domain); |
1216 | 1226 | ||
1217 | spin_lock(&omap_domain->lock); | 1227 | spin_lock(&omap_domain->lock); |
1218 | _omap_iommu_detach_dev(omap_domain, dev); | 1228 | _omap_iommu_detach_dev(omap_domain, dev); |
1219 | spin_unlock(&omap_domain->lock); | 1229 | spin_unlock(&omap_domain->lock); |
1220 | } | 1230 | } |
1221 | 1231 | ||
1222 | static int omap_iommu_domain_init(struct iommu_domain *domain) | 1232 | static struct iommu_domain *omap_iommu_domain_alloc(unsigned type) |
1223 | { | 1233 | { |
1224 | struct omap_iommu_domain *omap_domain; | 1234 | struct omap_iommu_domain *omap_domain; |
1225 | 1235 | ||
1236 | if (type != IOMMU_DOMAIN_UNMANAGED) | ||
1237 | return NULL; | ||
1238 | |||
1226 | omap_domain = kzalloc(sizeof(*omap_domain), GFP_KERNEL); | 1239 | omap_domain = kzalloc(sizeof(*omap_domain), GFP_KERNEL); |
1227 | if (!omap_domain) { | 1240 | if (!omap_domain) { |
1228 | pr_err("kzalloc failed\n"); | 1241 | pr_err("kzalloc failed\n"); |
@@ -1244,25 +1257,21 @@ static int omap_iommu_domain_init(struct iommu_domain *domain) | |||
1244 | clean_dcache_area(omap_domain->pgtable, IOPGD_TABLE_SIZE); | 1257 | clean_dcache_area(omap_domain->pgtable, IOPGD_TABLE_SIZE); |
1245 | spin_lock_init(&omap_domain->lock); | 1258 | spin_lock_init(&omap_domain->lock); |
1246 | 1259 | ||
1247 | domain->priv = omap_domain; | 1260 | omap_domain->domain.geometry.aperture_start = 0; |
1261 | omap_domain->domain.geometry.aperture_end = (1ULL << 32) - 1; | ||
1262 | omap_domain->domain.geometry.force_aperture = true; | ||
1248 | 1263 | ||
1249 | domain->geometry.aperture_start = 0; | 1264 | return &omap_domain->domain; |
1250 | domain->geometry.aperture_end = (1ULL << 32) - 1; | ||
1251 | domain->geometry.force_aperture = true; | ||
1252 | |||
1253 | return 0; | ||
1254 | 1265 | ||
1255 | fail_nomem: | 1266 | fail_nomem: |
1256 | kfree(omap_domain); | 1267 | kfree(omap_domain); |
1257 | out: | 1268 | out: |
1258 | return -ENOMEM; | 1269 | return NULL; |
1259 | } | 1270 | } |
1260 | 1271 | ||
1261 | static void omap_iommu_domain_destroy(struct iommu_domain *domain) | 1272 | static void omap_iommu_domain_free(struct iommu_domain *domain) |
1262 | { | 1273 | { |
1263 | struct omap_iommu_domain *omap_domain = domain->priv; | 1274 | struct omap_iommu_domain *omap_domain = to_omap_domain(domain); |
1264 | |||
1265 | domain->priv = NULL; | ||
1266 | 1275 | ||
1267 | /* | 1276 | /* |
1268 | * An iommu device is still attached | 1277 | * An iommu device is still attached |
@@ -1278,7 +1287,7 @@ static void omap_iommu_domain_destroy(struct iommu_domain *domain) | |||
1278 | static phys_addr_t omap_iommu_iova_to_phys(struct iommu_domain *domain, | 1287 | static phys_addr_t omap_iommu_iova_to_phys(struct iommu_domain *domain, |
1279 | dma_addr_t da) | 1288 | dma_addr_t da) |
1280 | { | 1289 | { |
1281 | struct omap_iommu_domain *omap_domain = domain->priv; | 1290 | struct omap_iommu_domain *omap_domain = to_omap_domain(domain); |
1282 | struct omap_iommu *oiommu = omap_domain->iommu_dev; | 1291 | struct omap_iommu *oiommu = omap_domain->iommu_dev; |
1283 | struct device *dev = oiommu->dev; | 1292 | struct device *dev = oiommu->dev; |
1284 | u32 *pgd, *pte; | 1293 | u32 *pgd, *pte; |
@@ -1358,8 +1367,8 @@ static void omap_iommu_remove_device(struct device *dev) | |||
1358 | } | 1367 | } |
1359 | 1368 | ||
1360 | static const struct iommu_ops omap_iommu_ops = { | 1369 | static const struct iommu_ops omap_iommu_ops = { |
1361 | .domain_init = omap_iommu_domain_init, | 1370 | .domain_alloc = omap_iommu_domain_alloc, |
1362 | .domain_destroy = omap_iommu_domain_destroy, | 1371 | .domain_free = omap_iommu_domain_free, |
1363 | .attach_dev = omap_iommu_attach_dev, | 1372 | .attach_dev = omap_iommu_attach_dev, |
1364 | .detach_dev = omap_iommu_detach_dev, | 1373 | .detach_dev = omap_iommu_detach_dev, |
1365 | .map = omap_iommu_map, | 1374 | .map = omap_iommu_map, |