aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iommu
diff options
context:
space:
mode:
authorOhad Ben-Cohen <ohad@wizery.com>2011-10-10 18:18:33 -0400
committerOhad Ben-Cohen <ohad@wizery.com>2011-12-05 08:47:39 -0500
commitfabdbca8c991dfa0ea1ff26214ae7d18e5740cc3 (patch)
treeeb749033a25fd557e21756936ba83180fefdb8c8 /drivers/iommu
parentc8eaab3b74f1326c989e1db8d7c0c14981556e4e (diff)
iommu/omap: eliminate the public omap_find_iommu_device() method
Eliminate the public omap_find_iommu_device() method, and don't expect clients to provide the omap_iommu handle anymore. Instead, OMAP's iommu driver now utilizes dev_archdata's private iommu extension to be able to access the required iommu information. This way OMAP IOMMU users are now able to use the generic IOMMU API without having to call any omap-specific binding method. Update omap3isp appropriately. Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Tony Lindgren <tony@atomide.com> Cc: Hiroshi Doyu <hdoyu@nvidia.com>
Diffstat (limited to 'drivers/iommu')
-rw-r--r--drivers/iommu/omap-iommu.c58
-rw-r--r--drivers/iommu/omap-iovmm.c31
2 files changed, 46 insertions, 43 deletions
diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
index 8f32b2bf758..b7f863d72c0 100644
--- a/drivers/iommu/omap-iommu.c
+++ b/drivers/iommu/omap-iommu.c
@@ -86,20 +86,24 @@ EXPORT_SYMBOL_GPL(omap_uninstall_iommu_arch);
86 86
87/** 87/**
88 * omap_iommu_save_ctx - Save registers for pm off-mode support 88 * omap_iommu_save_ctx - Save registers for pm off-mode support
89 * @obj: target iommu 89 * @dev: client device
90 **/ 90 **/
91void omap_iommu_save_ctx(struct omap_iommu *obj) 91void omap_iommu_save_ctx(struct device *dev)
92{ 92{
93 struct omap_iommu *obj = dev_to_omap_iommu(dev);
94
93 arch_iommu->save_ctx(obj); 95 arch_iommu->save_ctx(obj);
94} 96}
95EXPORT_SYMBOL_GPL(omap_iommu_save_ctx); 97EXPORT_SYMBOL_GPL(omap_iommu_save_ctx);
96 98
97/** 99/**
98 * omap_iommu_restore_ctx - Restore registers for pm off-mode support 100 * omap_iommu_restore_ctx - Restore registers for pm off-mode support
99 * @obj: target iommu 101 * @dev: client device
100 **/ 102 **/
101void omap_iommu_restore_ctx(struct omap_iommu *obj) 103void omap_iommu_restore_ctx(struct device *dev)
102{ 104{
105 struct omap_iommu *obj = dev_to_omap_iommu(dev);
106
103 arch_iommu->restore_ctx(obj); 107 arch_iommu->restore_ctx(obj);
104} 108}
105EXPORT_SYMBOL_GPL(omap_iommu_restore_ctx); 109EXPORT_SYMBOL_GPL(omap_iommu_restore_ctx);
@@ -820,35 +824,23 @@ static int device_match_by_alias(struct device *dev, void *data)
820} 824}
821 825
822/** 826/**
823 * omap_find_iommu_device() - find an omap iommu device by name
824 * @name: name of the iommu device
825 *
826 * The generic iommu API requires the caller to provide the device
827 * he wishes to attach to a certain iommu domain.
828 *
829 * Drivers generally should not bother with this as it should just
830 * be taken care of by the DMA-API using dev_archdata.
831 *
832 * This function is provided as an interim solution until the latter
833 * materializes, and omap3isp is fully migrated to the DMA-API.
834 */
835struct device *omap_find_iommu_device(const char *name)
836{
837 return driver_find_device(&omap_iommu_driver.driver, NULL,
838 (void *)name,
839 device_match_by_alias);
840}
841EXPORT_SYMBOL_GPL(omap_find_iommu_device);
842
843/**
844 * omap_iommu_attach() - attach iommu device to an iommu domain 827 * omap_iommu_attach() - attach iommu device to an iommu domain
845 * @dev: target omap iommu device 828 * @name: name of target omap iommu device
846 * @iopgd: page table 829 * @iopgd: page table
847 **/ 830 **/
848static struct omap_iommu *omap_iommu_attach(struct device *dev, u32 *iopgd) 831static struct omap_iommu *omap_iommu_attach(const char *name, u32 *iopgd)
849{ 832{
850 int err = -ENOMEM; 833 int err = -ENOMEM;
851 struct omap_iommu *obj = to_iommu(dev); 834 struct device *dev;
835 struct omap_iommu *obj;
836
837 dev = driver_find_device(&omap_iommu_driver.driver, NULL,
838 (void *)name,
839 device_match_by_alias);
840 if (!dev)
841 return NULL;
842
843 obj = to_iommu(dev);
852 844
853 spin_lock(&obj->iommu_lock); 845 spin_lock(&obj->iommu_lock);
854 846
@@ -1069,6 +1061,7 @@ omap_iommu_attach_dev(struct iommu_domain *domain, struct device *dev)
1069{ 1061{
1070 struct omap_iommu_domain *omap_domain = domain->priv; 1062 struct omap_iommu_domain *omap_domain = domain->priv;
1071 struct omap_iommu *oiommu; 1063 struct omap_iommu *oiommu;
1064 struct omap_iommu_arch_data *arch_data = dev->archdata.iommu;
1072 int ret = 0; 1065 int ret = 0;
1073 1066
1074 spin_lock(&omap_domain->lock); 1067 spin_lock(&omap_domain->lock);
@@ -1081,14 +1074,14 @@ omap_iommu_attach_dev(struct iommu_domain *domain, struct device *dev)
1081 } 1074 }
1082 1075
1083 /* get a handle to and enable the omap iommu */ 1076 /* get a handle to and enable the omap iommu */
1084 oiommu = omap_iommu_attach(dev, omap_domain->pgtable); 1077 oiommu = omap_iommu_attach(arch_data->name, omap_domain->pgtable);
1085 if (IS_ERR(oiommu)) { 1078 if (IS_ERR(oiommu)) {
1086 ret = PTR_ERR(oiommu); 1079 ret = PTR_ERR(oiommu);
1087 dev_err(dev, "can't get omap iommu: %d\n", ret); 1080 dev_err(dev, "can't get omap iommu: %d\n", ret);
1088 goto out; 1081 goto out;
1089 } 1082 }
1090 1083
1091 omap_domain->iommu_dev = oiommu; 1084 omap_domain->iommu_dev = arch_data->iommu_dev = oiommu;
1092 oiommu->domain = domain; 1085 oiommu->domain = domain;
1093 1086
1094out: 1087out:
@@ -1100,7 +1093,8 @@ static void omap_iommu_detach_dev(struct iommu_domain *domain,
1100 struct device *dev) 1093 struct device *dev)
1101{ 1094{
1102 struct omap_iommu_domain *omap_domain = domain->priv; 1095 struct omap_iommu_domain *omap_domain = domain->priv;
1103 struct omap_iommu *oiommu = to_iommu(dev); 1096 struct omap_iommu_arch_data *arch_data = dev->archdata.iommu;
1097 struct omap_iommu *oiommu = dev_to_omap_iommu(dev);
1104 1098
1105 spin_lock(&omap_domain->lock); 1099 spin_lock(&omap_domain->lock);
1106 1100
@@ -1114,7 +1108,7 @@ static void omap_iommu_detach_dev(struct iommu_domain *domain,
1114 1108
1115 omap_iommu_detach(oiommu); 1109 omap_iommu_detach(oiommu);
1116 1110
1117 omap_domain->iommu_dev = NULL; 1111 omap_domain->iommu_dev = arch_data->iommu_dev = NULL;
1118 1112
1119out: 1113out:
1120 spin_unlock(&omap_domain->lock); 1114 spin_unlock(&omap_domain->lock);
diff --git a/drivers/iommu/omap-iovmm.c b/drivers/iommu/omap-iovmm.c
index 46be456fcc0..23655945e30 100644
--- a/drivers/iommu/omap-iovmm.c
+++ b/drivers/iommu/omap-iovmm.c
@@ -231,12 +231,14 @@ static struct iovm_struct *__find_iovm_area(struct omap_iommu *obj,
231 231
232/** 232/**
233 * omap_find_iovm_area - find iovma which includes @da 233 * omap_find_iovm_area - find iovma which includes @da
234 * @dev: client device
234 * @da: iommu device virtual address 235 * @da: iommu device virtual address
235 * 236 *
236 * Find the existing iovma starting at @da 237 * Find the existing iovma starting at @da
237 */ 238 */
238struct iovm_struct *omap_find_iovm_area(struct omap_iommu *obj, u32 da) 239struct iovm_struct *omap_find_iovm_area(struct device *dev, u32 da)
239{ 240{
241 struct omap_iommu *obj = dev_to_omap_iommu(dev);
240 struct iovm_struct *area; 242 struct iovm_struct *area;
241 243
242 mutex_lock(&obj->mmap_lock); 244 mutex_lock(&obj->mmap_lock);
@@ -343,14 +345,15 @@ static void free_iovm_area(struct omap_iommu *obj, struct iovm_struct *area)
343 345
344/** 346/**
345 * omap_da_to_va - convert (d) to (v) 347 * omap_da_to_va - convert (d) to (v)
346 * @obj: objective iommu 348 * @dev: client device
347 * @da: iommu device virtual address 349 * @da: iommu device virtual address
348 * @va: mpu virtual address 350 * @va: mpu virtual address
349 * 351 *
350 * Returns mpu virtual addr which corresponds to a given device virtual addr 352 * Returns mpu virtual addr which corresponds to a given device virtual addr
351 */ 353 */
352void *omap_da_to_va(struct omap_iommu *obj, u32 da) 354void *omap_da_to_va(struct device *dev, u32 da)
353{ 355{
356 struct omap_iommu *obj = dev_to_omap_iommu(dev);
354 void *va = NULL; 357 void *va = NULL;
355 struct iovm_struct *area; 358 struct iovm_struct *area;
356 359
@@ -582,16 +585,18 @@ __iommu_vmap(struct iommu_domain *domain, struct omap_iommu *obj,
582 585
583/** 586/**
584 * omap_iommu_vmap - (d)-(p)-(v) address mapper 587 * omap_iommu_vmap - (d)-(p)-(v) address mapper
585 * @obj: objective iommu 588 * @domain: iommu domain
589 * @dev: client device
586 * @sgt: address of scatter gather table 590 * @sgt: address of scatter gather table
587 * @flags: iovma and page property 591 * @flags: iovma and page property
588 * 592 *
589 * Creates 1-n-1 mapping with given @sgt and returns @da. 593 * Creates 1-n-1 mapping with given @sgt and returns @da.
590 * All @sgt element must be io page size aligned. 594 * All @sgt element must be io page size aligned.
591 */ 595 */
592u32 omap_iommu_vmap(struct iommu_domain *domain, struct omap_iommu *obj, u32 da, 596u32 omap_iommu_vmap(struct iommu_domain *domain, struct device *dev, u32 da,
593 const struct sg_table *sgt, u32 flags) 597 const struct sg_table *sgt, u32 flags)
594{ 598{
599 struct omap_iommu *obj = dev_to_omap_iommu(dev);
595 size_t bytes; 600 size_t bytes;
596 void *va = NULL; 601 void *va = NULL;
597 602
@@ -622,15 +627,17 @@ EXPORT_SYMBOL_GPL(omap_iommu_vmap);
622 627
623/** 628/**
624 * omap_iommu_vunmap - release virtual mapping obtained by 'omap_iommu_vmap()' 629 * omap_iommu_vunmap - release virtual mapping obtained by 'omap_iommu_vmap()'
625 * @obj: objective iommu 630 * @domain: iommu domain
631 * @dev: client device
626 * @da: iommu device virtual address 632 * @da: iommu device virtual address
627 * 633 *
628 * Free the iommu virtually contiguous memory area starting at 634 * Free the iommu virtually contiguous memory area starting at
629 * @da, which was returned by 'omap_iommu_vmap()'. 635 * @da, which was returned by 'omap_iommu_vmap()'.
630 */ 636 */
631struct sg_table * 637struct sg_table *
632omap_iommu_vunmap(struct iommu_domain *domain, struct omap_iommu *obj, u32 da) 638omap_iommu_vunmap(struct iommu_domain *domain, struct device *dev, u32 da)
633{ 639{
640 struct omap_iommu *obj = dev_to_omap_iommu(dev);
634 struct sg_table *sgt; 641 struct sg_table *sgt;
635 /* 642 /*
636 * 'sgt' is allocated before 'omap_iommu_vmalloc()' is called. 643 * 'sgt' is allocated before 'omap_iommu_vmalloc()' is called.
@@ -647,7 +654,7 @@ EXPORT_SYMBOL_GPL(omap_iommu_vunmap);
647 654
648/** 655/**
649 * omap_iommu_vmalloc - (d)-(p)-(v) address allocator and mapper 656 * omap_iommu_vmalloc - (d)-(p)-(v) address allocator and mapper
650 * @obj: objective iommu 657 * @dev: client device
651 * @da: contiguous iommu virtual memory 658 * @da: contiguous iommu virtual memory
652 * @bytes: allocation size 659 * @bytes: allocation size
653 * @flags: iovma and page property 660 * @flags: iovma and page property
@@ -656,9 +663,10 @@ EXPORT_SYMBOL_GPL(omap_iommu_vunmap);
656 * @da again, which might be adjusted if 'IOVMF_DA_FIXED' is not set. 663 * @da again, which might be adjusted if 'IOVMF_DA_FIXED' is not set.
657 */ 664 */
658u32 665u32
659omap_iommu_vmalloc(struct iommu_domain *domain, struct omap_iommu *obj, u32 da, 666omap_iommu_vmalloc(struct iommu_domain *domain, struct device *dev, u32 da,
660 size_t bytes, u32 flags) 667 size_t bytes, u32 flags)
661{ 668{
669 struct omap_iommu *obj = dev_to_omap_iommu(dev);
662 void *va; 670 void *va;
663 struct sg_table *sgt; 671 struct sg_table *sgt;
664 672
@@ -698,15 +706,16 @@ EXPORT_SYMBOL_GPL(omap_iommu_vmalloc);
698 706
699/** 707/**
700 * omap_iommu_vfree - release memory allocated by 'omap_iommu_vmalloc()' 708 * omap_iommu_vfree - release memory allocated by 'omap_iommu_vmalloc()'
701 * @obj: objective iommu 709 * @dev: client device
702 * @da: iommu device virtual address 710 * @da: iommu device virtual address
703 * 711 *
704 * Frees the iommu virtually continuous memory area starting at 712 * Frees the iommu virtually continuous memory area starting at
705 * @da, as obtained from 'omap_iommu_vmalloc()'. 713 * @da, as obtained from 'omap_iommu_vmalloc()'.
706 */ 714 */
707void omap_iommu_vfree(struct iommu_domain *domain, struct omap_iommu *obj, 715void omap_iommu_vfree(struct iommu_domain *domain, struct device *dev,
708 const u32 da) 716 const u32 da)
709{ 717{
718 struct omap_iommu *obj = dev_to_omap_iommu(dev);
710 struct sg_table *sgt; 719 struct sg_table *sgt;
711 720
712 sgt = unmap_vm_area(domain, obj, da, vfree, 721 sgt = unmap_vm_area(domain, obj, da, vfree,