hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/iommu/omap-iommu.c
....@@ -1,15 +1,12 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * omap iommu: tlb and pagetable primitives
34 *
45 * Copyright (C) 2008-2010 Nokia Corporation
5
- * Copyright (C) 2013-2017 Texas Instruments Incorporated - http://www.ti.com/
6
+ * Copyright (C) 2013-2017 Texas Instruments Incorporated - https://www.ti.com/
67 *
78 * Written by Hiroshi DOYU <Hiroshi.DOYU@nokia.com>,
89 * Paul Mundt and Toshihiro Kobayashi
9
- *
10
- * This program is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License version 2 as
12
- * published by the Free Software Foundation.
1310 */
1411
1512 #include <linux/dma-mapping.h>
....@@ -38,8 +35,7 @@
3835
3936 static const struct iommu_ops omap_iommu_ops;
4037
41
-#define to_iommu(dev) \
42
- ((struct omap_iommu *)platform_get_drvdata(to_platform_device(dev)))
38
+#define to_iommu(dev) ((struct omap_iommu *)dev_get_drvdata(dev))
4339
4440 /* bitmap of the page sizes currently supported */
4541 #define OMAP_IOMMU_PGSIZES (SZ_4K | SZ_64K | SZ_1M | SZ_16M)
....@@ -69,10 +65,13 @@
6965 /**
7066 * omap_iommu_save_ctx - Save registers for pm off-mode support
7167 * @dev: client device
68
+ *
69
+ * This should be treated as an deprecated API. It is preserved only
70
+ * to maintain existing functionality for OMAP3 ISP driver.
7271 **/
7372 void omap_iommu_save_ctx(struct device *dev)
7473 {
75
- struct omap_iommu_arch_data *arch_data = dev->archdata.iommu;
74
+ struct omap_iommu_arch_data *arch_data = dev_iommu_priv_get(dev);
7675 struct omap_iommu *obj;
7776 u32 *p;
7877 int i;
....@@ -96,10 +95,13 @@
9695 /**
9796 * omap_iommu_restore_ctx - Restore registers for pm off-mode support
9897 * @dev: client device
98
+ *
99
+ * This should be treated as an deprecated API. It is preserved only
100
+ * to maintain existing functionality for OMAP3 ISP driver.
99101 **/
100102 void omap_iommu_restore_ctx(struct device *dev)
101103 {
102
- struct omap_iommu_arch_data *arch_data = dev->archdata.iommu;
104
+ struct omap_iommu_arch_data *arch_data = dev_iommu_priv_get(dev);
103105 struct omap_iommu *obj;
104106 u32 *p;
105107 int i;
....@@ -154,7 +156,7 @@
154156 {
155157 u32 l, pa;
156158
157
- if (!obj->iopgd || !IS_ALIGNED((u32)obj->iopgd, SZ_16K))
159
+ if (!obj->iopgd || !IS_ALIGNED((unsigned long)obj->iopgd, SZ_16K))
158160 return -EINVAL;
159161
160162 pa = virt_to_phys(obj->iopgd);
....@@ -190,36 +192,18 @@
190192
191193 static int iommu_enable(struct omap_iommu *obj)
192194 {
193
- int err;
194
- struct platform_device *pdev = to_platform_device(obj->dev);
195
- struct iommu_platform_data *pdata = dev_get_platdata(&pdev->dev);
195
+ int ret;
196196
197
- if (pdata && pdata->deassert_reset) {
198
- err = pdata->deassert_reset(pdev, pdata->reset_name);
199
- if (err) {
200
- dev_err(obj->dev, "deassert_reset failed: %d\n", err);
201
- return err;
202
- }
203
- }
197
+ ret = pm_runtime_get_sync(obj->dev);
198
+ if (ret < 0)
199
+ pm_runtime_put_noidle(obj->dev);
204200
205
- pm_runtime_get_sync(obj->dev);
206
-
207
- err = omap2_iommu_enable(obj);
208
-
209
- return err;
201
+ return ret < 0 ? ret : 0;
210202 }
211203
212204 static void iommu_disable(struct omap_iommu *obj)
213205 {
214
- struct platform_device *pdev = to_platform_device(obj->dev);
215
- struct iommu_platform_data *pdata = dev_get_platdata(&pdev->dev);
216
-
217
- omap2_iommu_disable(obj);
218
-
219206 pm_runtime_put_sync(obj->dev);
220
-
221
- if (pdata && pdata->assert_reset)
222
- pdata->assert_reset(pdev, pdata->reset_name);
223207 }
224208
225209 /*
....@@ -439,7 +423,7 @@
439423 bytes = iopgsz_to_bytes(cr.cam & 3);
440424
441425 if ((start <= da) && (da < start + bytes)) {
442
- dev_dbg(obj->dev, "%s: %08x<=%08x(%x)\n",
426
+ dev_dbg(obj->dev, "%s: %08x<=%08x(%zx)\n",
443427 __func__, start, da, bytes);
444428 iotlb_load_cr(obj, &cr);
445429 iommu_write_reg(obj, 1, MMU_FLUSH_ENTRY);
....@@ -905,13 +889,217 @@
905889
906890 dma_unmap_single(obj->dev, obj->pd_dma, IOPGD_TABLE_SIZE,
907891 DMA_TO_DEVICE);
908
- iommu_disable(obj);
909892 obj->pd_dma = 0;
910893 obj->iopgd = NULL;
894
+ iommu_disable(obj);
911895
912896 spin_unlock(&obj->iommu_lock);
913897
914898 dev_dbg(obj->dev, "%s: %s\n", __func__, obj->name);
899
+}
900
+
901
+static void omap_iommu_save_tlb_entries(struct omap_iommu *obj)
902
+{
903
+ struct iotlb_lock lock;
904
+ struct cr_regs cr;
905
+ struct cr_regs *tmp;
906
+ int i;
907
+
908
+ /* check if there are any locked tlbs to save */
909
+ iotlb_lock_get(obj, &lock);
910
+ obj->num_cr_ctx = lock.base;
911
+ if (!obj->num_cr_ctx)
912
+ return;
913
+
914
+ tmp = obj->cr_ctx;
915
+ for_each_iotlb_cr(obj, obj->num_cr_ctx, i, cr)
916
+ * tmp++ = cr;
917
+}
918
+
919
+static void omap_iommu_restore_tlb_entries(struct omap_iommu *obj)
920
+{
921
+ struct iotlb_lock l;
922
+ struct cr_regs *tmp;
923
+ int i;
924
+
925
+ /* no locked tlbs to restore */
926
+ if (!obj->num_cr_ctx)
927
+ return;
928
+
929
+ l.base = 0;
930
+ tmp = obj->cr_ctx;
931
+ for (i = 0; i < obj->num_cr_ctx; i++, tmp++) {
932
+ l.vict = i;
933
+ iotlb_lock_set(obj, &l);
934
+ iotlb_load_cr(obj, tmp);
935
+ }
936
+ l.base = obj->num_cr_ctx;
937
+ l.vict = i;
938
+ iotlb_lock_set(obj, &l);
939
+}
940
+
941
+/**
942
+ * omap_iommu_domain_deactivate - deactivate attached iommu devices
943
+ * @domain: iommu domain attached to the target iommu device
944
+ *
945
+ * This API allows the client devices of IOMMU devices to suspend
946
+ * the IOMMUs they control at runtime, after they are idled and
947
+ * suspended all activity. System Suspend will leverage the PM
948
+ * driver late callbacks.
949
+ **/
950
+int omap_iommu_domain_deactivate(struct iommu_domain *domain)
951
+{
952
+ struct omap_iommu_domain *omap_domain = to_omap_domain(domain);
953
+ struct omap_iommu_device *iommu;
954
+ struct omap_iommu *oiommu;
955
+ int i;
956
+
957
+ if (!omap_domain->dev)
958
+ return 0;
959
+
960
+ iommu = omap_domain->iommus;
961
+ iommu += (omap_domain->num_iommus - 1);
962
+ for (i = 0; i < omap_domain->num_iommus; i++, iommu--) {
963
+ oiommu = iommu->iommu_dev;
964
+ pm_runtime_put_sync(oiommu->dev);
965
+ }
966
+
967
+ return 0;
968
+}
969
+EXPORT_SYMBOL_GPL(omap_iommu_domain_deactivate);
970
+
971
+/**
972
+ * omap_iommu_domain_activate - activate attached iommu devices
973
+ * @domain: iommu domain attached to the target iommu device
974
+ *
975
+ * This API allows the client devices of IOMMU devices to resume the
976
+ * IOMMUs they control at runtime, before they can resume operations.
977
+ * System Resume will leverage the PM driver late callbacks.
978
+ **/
979
+int omap_iommu_domain_activate(struct iommu_domain *domain)
980
+{
981
+ struct omap_iommu_domain *omap_domain = to_omap_domain(domain);
982
+ struct omap_iommu_device *iommu;
983
+ struct omap_iommu *oiommu;
984
+ int i;
985
+
986
+ if (!omap_domain->dev)
987
+ return 0;
988
+
989
+ iommu = omap_domain->iommus;
990
+ for (i = 0; i < omap_domain->num_iommus; i++, iommu++) {
991
+ oiommu = iommu->iommu_dev;
992
+ pm_runtime_get_sync(oiommu->dev);
993
+ }
994
+
995
+ return 0;
996
+}
997
+EXPORT_SYMBOL_GPL(omap_iommu_domain_activate);
998
+
999
+/**
1000
+ * omap_iommu_runtime_suspend - disable an iommu device
1001
+ * @dev: iommu device
1002
+ *
1003
+ * This function performs all that is necessary to disable an
1004
+ * IOMMU device, either during final detachment from a client
1005
+ * device, or during system/runtime suspend of the device. This
1006
+ * includes programming all the appropriate IOMMU registers, and
1007
+ * managing the associated omap_hwmod's state and the device's
1008
+ * reset line. This function also saves the context of any
1009
+ * locked TLBs if suspending.
1010
+ **/
1011
+static __maybe_unused int omap_iommu_runtime_suspend(struct device *dev)
1012
+{
1013
+ struct platform_device *pdev = to_platform_device(dev);
1014
+ struct iommu_platform_data *pdata = dev_get_platdata(dev);
1015
+ struct omap_iommu *obj = to_iommu(dev);
1016
+ int ret;
1017
+
1018
+ /* save the TLBs only during suspend, and not for power down */
1019
+ if (obj->domain && obj->iopgd)
1020
+ omap_iommu_save_tlb_entries(obj);
1021
+
1022
+ omap2_iommu_disable(obj);
1023
+
1024
+ if (pdata && pdata->device_idle)
1025
+ pdata->device_idle(pdev);
1026
+
1027
+ if (pdata && pdata->assert_reset)
1028
+ pdata->assert_reset(pdev, pdata->reset_name);
1029
+
1030
+ if (pdata && pdata->set_pwrdm_constraint) {
1031
+ ret = pdata->set_pwrdm_constraint(pdev, false, &obj->pwrst);
1032
+ if (ret) {
1033
+ dev_warn(obj->dev, "pwrdm_constraint failed to be reset, status = %d\n",
1034
+ ret);
1035
+ }
1036
+ }
1037
+
1038
+ return 0;
1039
+}
1040
+
1041
+/**
1042
+ * omap_iommu_runtime_resume - enable an iommu device
1043
+ * @dev: iommu device
1044
+ *
1045
+ * This function performs all that is necessary to enable an
1046
+ * IOMMU device, either during initial attachment to a client
1047
+ * device, or during system/runtime resume of the device. This
1048
+ * includes programming all the appropriate IOMMU registers, and
1049
+ * managing the associated omap_hwmod's state and the device's
1050
+ * reset line. The function also restores any locked TLBs if
1051
+ * resuming after a suspend.
1052
+ **/
1053
+static __maybe_unused int omap_iommu_runtime_resume(struct device *dev)
1054
+{
1055
+ struct platform_device *pdev = to_platform_device(dev);
1056
+ struct iommu_platform_data *pdata = dev_get_platdata(dev);
1057
+ struct omap_iommu *obj = to_iommu(dev);
1058
+ int ret = 0;
1059
+
1060
+ if (pdata && pdata->set_pwrdm_constraint) {
1061
+ ret = pdata->set_pwrdm_constraint(pdev, true, &obj->pwrst);
1062
+ if (ret) {
1063
+ dev_warn(obj->dev, "pwrdm_constraint failed to be set, status = %d\n",
1064
+ ret);
1065
+ }
1066
+ }
1067
+
1068
+ if (pdata && pdata->deassert_reset) {
1069
+ ret = pdata->deassert_reset(pdev, pdata->reset_name);
1070
+ if (ret) {
1071
+ dev_err(dev, "deassert_reset failed: %d\n", ret);
1072
+ return ret;
1073
+ }
1074
+ }
1075
+
1076
+ if (pdata && pdata->device_enable)
1077
+ pdata->device_enable(pdev);
1078
+
1079
+ /* restore the TLBs only during resume, and not for power up */
1080
+ if (obj->domain)
1081
+ omap_iommu_restore_tlb_entries(obj);
1082
+
1083
+ ret = omap2_iommu_enable(obj);
1084
+
1085
+ return ret;
1086
+}
1087
+
1088
+/**
1089
+ * omap_iommu_suspend_prepare - prepare() dev_pm_ops implementation
1090
+ * @dev: iommu device
1091
+ *
1092
+ * This function performs the necessary checks to determine if the IOMMU
1093
+ * device needs suspending or not. The function checks if the runtime_pm
1094
+ * status of the device is suspended, and returns 1 in that case. This
1095
+ * results in the PM core to skip invoking any of the Sleep PM callbacks
1096
+ * (suspend, suspend_late, resume, resume_early etc).
1097
+ */
1098
+static int omap_iommu_prepare(struct device *dev)
1099
+{
1100
+ if (pm_runtime_status_suspended(dev))
1101
+ return 1;
1102
+ return 0;
9151103 }
9161104
9171105 static bool omap_iommu_can_register(struct platform_device *pdev)
....@@ -988,6 +1176,15 @@
9881176 if (!obj)
9891177 return -ENOMEM;
9901178
1179
+ /*
1180
+ * self-manage the ordering dependencies between omap_device_enable/idle
1181
+ * and omap_device_assert/deassert_hardreset API
1182
+ */
1183
+ if (pdev->dev.pm_domain) {
1184
+ dev_dbg(&pdev->dev, "device pm_domain is being reset\n");
1185
+ pdev->dev.pm_domain = NULL;
1186
+ }
1187
+
9911188 obj->name = dev_name(&pdev->dev);
9921189 obj->nr_tlb_entries = 32;
9931190 err = of_property_read_u32(of, "ti,#tlb-entries", &obj->nr_tlb_entries);
....@@ -1000,6 +1197,11 @@
10001197
10011198 obj->dev = &pdev->dev;
10021199 obj->ctx = (void *)obj + sizeof(*obj);
1200
+ obj->cr_ctx = devm_kzalloc(&pdev->dev,
1201
+ sizeof(*obj->cr_ctx) * obj->nr_tlb_entries,
1202
+ GFP_KERNEL);
1203
+ if (!obj->cr_ctx)
1204
+ return -ENOMEM;
10031205
10041206 spin_lock_init(&obj->iommu_lock);
10051207 spin_lock_init(&obj->page_table_lock);
....@@ -1034,18 +1236,21 @@
10341236 goto out_group;
10351237
10361238 iommu_device_set_ops(&obj->iommu, &omap_iommu_ops);
1239
+ iommu_device_set_fwnode(&obj->iommu, &of->fwnode);
10371240
10381241 err = iommu_device_register(&obj->iommu);
10391242 if (err)
10401243 goto out_sysfs;
10411244 }
10421245
1043
- pm_runtime_irq_safe(obj->dev);
10441246 pm_runtime_enable(obj->dev);
10451247
10461248 omap_iommu_debugfs_add(obj);
10471249
10481250 dev_info(&pdev->dev, "%s registered\n", obj->name);
1251
+
1252
+ /* Re-probe bus to probe device attached to this IOMMU */
1253
+ bus_iommu_probe(&platform_bus_type);
10491254
10501255 return 0;
10511256
....@@ -1076,6 +1281,14 @@
10761281 return 0;
10771282 }
10781283
1284
+static const struct dev_pm_ops omap_iommu_pm_ops = {
1285
+ .prepare = omap_iommu_prepare,
1286
+ SET_LATE_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
1287
+ pm_runtime_force_resume)
1288
+ SET_RUNTIME_PM_OPS(omap_iommu_runtime_suspend,
1289
+ omap_iommu_runtime_resume, NULL)
1290
+};
1291
+
10791292 static const struct of_device_id omap_iommu_of_match[] = {
10801293 { .compatible = "ti,omap2-iommu" },
10811294 { .compatible = "ti,omap4-iommu" },
....@@ -1089,6 +1302,7 @@
10891302 .remove = omap_iommu_remove,
10901303 .driver = {
10911304 .name = "omap-iommu",
1305
+ .pm = &omap_iommu_pm_ops,
10921306 .of_match_table = of_match_ptr(omap_iommu_of_match),
10931307 },
10941308 };
....@@ -1109,7 +1323,7 @@
11091323 }
11101324
11111325 static int omap_iommu_map(struct iommu_domain *domain, unsigned long da,
1112
- phys_addr_t pa, size_t bytes, int prot)
1326
+ phys_addr_t pa, size_t bytes, int prot, gfp_t gfp)
11131327 {
11141328 struct omap_iommu_domain *omap_domain = to_omap_domain(domain);
11151329 struct device *dev = omap_domain->dev;
....@@ -1122,11 +1336,11 @@
11221336
11231337 omap_pgsz = bytes_to_iopgsz(bytes);
11241338 if (omap_pgsz < 0) {
1125
- dev_err(dev, "invalid size to map: %d\n", bytes);
1339
+ dev_err(dev, "invalid size to map: %zu\n", bytes);
11261340 return -EINVAL;
11271341 }
11281342
1129
- dev_dbg(dev, "mapping da 0x%lx to pa %pa size 0x%x\n", da, &pa, bytes);
1343
+ dev_dbg(dev, "mapping da 0x%lx to pa %pa size 0x%zx\n", da, &pa, bytes);
11301344
11311345 iotlb_init_entry(&e, da, pa, omap_pgsz);
11321346
....@@ -1153,7 +1367,7 @@
11531367 }
11541368
11551369 static size_t omap_iommu_unmap(struct iommu_domain *domain, unsigned long da,
1156
- size_t size)
1370
+ size_t size, struct iommu_iotlb_gather *gather)
11571371 {
11581372 struct omap_iommu_domain *omap_domain = to_omap_domain(domain);
11591373 struct device *dev = omap_domain->dev;
....@@ -1163,7 +1377,7 @@
11631377 size_t bytes = 0;
11641378 int i;
11651379
1166
- dev_dbg(dev, "unmapping da 0x%lx size %u\n", da, size);
1380
+ dev_dbg(dev, "unmapping da 0x%lx size %zu\n", da, size);
11671381
11681382 iommu = omap_domain->iommus;
11691383 for (i = 0; i < omap_domain->num_iommus; i++, iommu++) {
....@@ -1184,7 +1398,7 @@
11841398
11851399 static int omap_iommu_count(struct device *dev)
11861400 {
1187
- struct omap_iommu_arch_data *arch_data = dev->archdata.iommu;
1401
+ struct omap_iommu_arch_data *arch_data = dev_iommu_priv_get(dev);
11881402 int count = 0;
11891403
11901404 while (arch_data->iommu_dev) {
....@@ -1245,8 +1459,8 @@
12451459 static int
12461460 omap_iommu_attach_dev(struct iommu_domain *domain, struct device *dev)
12471461 {
1462
+ struct omap_iommu_arch_data *arch_data = dev_iommu_priv_get(dev);
12481463 struct omap_iommu_domain *omap_domain = to_omap_domain(domain);
1249
- struct omap_iommu_arch_data *arch_data = dev->archdata.iommu;
12501464 struct omap_iommu_device *iommu;
12511465 struct omap_iommu *oiommu;
12521466 int ret = 0;
....@@ -1310,7 +1524,7 @@
13101524 static void _omap_iommu_detach_dev(struct omap_iommu_domain *omap_domain,
13111525 struct device *dev)
13121526 {
1313
- struct omap_iommu_arch_data *arch_data = dev->archdata.iommu;
1527
+ struct omap_iommu_arch_data *arch_data = dev_iommu_priv_get(dev);
13141528 struct omap_iommu_device *iommu = omap_domain->iommus;
13151529 struct omap_iommu *oiommu;
13161530 int i;
....@@ -1427,24 +1641,22 @@
14271641 return ret;
14281642 }
14291643
1430
-static int omap_iommu_add_device(struct device *dev)
1644
+static struct iommu_device *omap_iommu_probe_device(struct device *dev)
14311645 {
14321646 struct omap_iommu_arch_data *arch_data, *tmp;
1433
- struct omap_iommu *oiommu;
1434
- struct iommu_group *group;
1435
- struct device_node *np;
14361647 struct platform_device *pdev;
1648
+ struct omap_iommu *oiommu;
1649
+ struct device_node *np;
14371650 int num_iommus, i;
1438
- int ret;
14391651
14401652 /*
1441
- * Allocate the archdata iommu structure for DT-based devices.
1653
+ * Allocate the per-device iommu structure for DT-based devices.
14421654 *
14431655 * TODO: Simplify this when removing non-DT support completely from the
14441656 * IOMMU users.
14451657 */
14461658 if (!dev->of_node)
1447
- return 0;
1659
+ return ERR_PTR(-ENODEV);
14481660
14491661 /*
14501662 * retrieve the count of IOMMU nodes using phandle size as element size
....@@ -1453,37 +1665,40 @@
14531665 num_iommus = of_property_count_elems_of_size(dev->of_node, "iommus",
14541666 sizeof(phandle));
14551667 if (num_iommus < 0)
1456
- return 0;
1668
+ return ERR_PTR(-ENODEV);
14571669
14581670 arch_data = kcalloc(num_iommus + 1, sizeof(*arch_data), GFP_KERNEL);
14591671 if (!arch_data)
1460
- return -ENOMEM;
1672
+ return ERR_PTR(-ENOMEM);
14611673
14621674 for (i = 0, tmp = arch_data; i < num_iommus; i++, tmp++) {
14631675 np = of_parse_phandle(dev->of_node, "iommus", i);
14641676 if (!np) {
14651677 kfree(arch_data);
1466
- return -EINVAL;
1678
+ return ERR_PTR(-EINVAL);
14671679 }
14681680
14691681 pdev = of_find_device_by_node(np);
1470
- if (WARN_ON(!pdev)) {
1682
+ if (!pdev) {
14711683 of_node_put(np);
14721684 kfree(arch_data);
1473
- return -EINVAL;
1685
+ return ERR_PTR(-ENODEV);
14741686 }
14751687
14761688 oiommu = platform_get_drvdata(pdev);
14771689 if (!oiommu) {
14781690 of_node_put(np);
14791691 kfree(arch_data);
1480
- return -EINVAL;
1692
+ return ERR_PTR(-EINVAL);
14811693 }
14821694
14831695 tmp->iommu_dev = oiommu;
1696
+ tmp->dev = &pdev->dev;
14841697
14851698 of_node_put(np);
14861699 }
1700
+
1701
+ dev_iommu_priv_set(dev, arch_data);
14871702
14881703 /*
14891704 * use the first IOMMU alone for the sysfs device linking.
....@@ -1491,49 +1706,29 @@
14911706 * maintained for both IOMMUs
14921707 */
14931708 oiommu = arch_data->iommu_dev;
1494
- ret = iommu_device_link(&oiommu->iommu, dev);
1495
- if (ret) {
1496
- kfree(arch_data);
1497
- return ret;
1498
- }
14991709
1500
- dev->archdata.iommu = arch_data;
1501
-
1502
- /*
1503
- * IOMMU group initialization calls into omap_iommu_device_group, which
1504
- * needs a valid dev->archdata.iommu pointer
1505
- */
1506
- group = iommu_group_get_for_dev(dev);
1507
- if (IS_ERR(group)) {
1508
- iommu_device_unlink(&oiommu->iommu, dev);
1509
- dev->archdata.iommu = NULL;
1510
- kfree(arch_data);
1511
- return PTR_ERR(group);
1512
- }
1513
- iommu_group_put(group);
1514
-
1515
- return 0;
1710
+ return &oiommu->iommu;
15161711 }
15171712
1518
-static void omap_iommu_remove_device(struct device *dev)
1713
+static void omap_iommu_release_device(struct device *dev)
15191714 {
1520
- struct omap_iommu_arch_data *arch_data = dev->archdata.iommu;
1715
+ struct omap_iommu_arch_data *arch_data = dev_iommu_priv_get(dev);
15211716
15221717 if (!dev->of_node || !arch_data)
15231718 return;
15241719
1525
- iommu_device_unlink(&arch_data->iommu_dev->iommu, dev);
1526
- iommu_group_remove_device(dev);
1527
-
1528
- dev->archdata.iommu = NULL;
1720
+ dev_iommu_priv_set(dev, NULL);
15291721 kfree(arch_data);
15301722
15311723 }
15321724
15331725 static struct iommu_group *omap_iommu_device_group(struct device *dev)
15341726 {
1535
- struct omap_iommu_arch_data *arch_data = dev->archdata.iommu;
1727
+ struct omap_iommu_arch_data *arch_data = dev_iommu_priv_get(dev);
15361728 struct iommu_group *group = ERR_PTR(-EINVAL);
1729
+
1730
+ if (!arch_data)
1731
+ return ERR_PTR(-ENODEV);
15371732
15381733 if (arch_data->iommu_dev)
15391734 group = iommu_group_ref_get(arch_data->iommu_dev->group);
....@@ -1549,8 +1744,8 @@
15491744 .map = omap_iommu_map,
15501745 .unmap = omap_iommu_unmap,
15511746 .iova_to_phys = omap_iommu_iova_to_phys,
1552
- .add_device = omap_iommu_add_device,
1553
- .remove_device = omap_iommu_remove_device,
1747
+ .probe_device = omap_iommu_probe_device,
1748
+ .release_device = omap_iommu_release_device,
15541749 .device_group = omap_iommu_device_group,
15551750 .pgsize_bitmap = OMAP_IOMMU_PGSIZES,
15561751 };
....@@ -1558,7 +1753,7 @@
15581753 static int __init omap_iommu_init(void)
15591754 {
15601755 struct kmem_cache *p;
1561
- const unsigned long flags = SLAB_HWCACHE_ALIGN;
1756
+ const slab_flags_t flags = SLAB_HWCACHE_ALIGN;
15621757 size_t align = 1 << 10; /* L2 pagetable alignement */
15631758 struct device_node *np;
15641759 int ret;