OSDN Git Service

iommu: Add {enable,disable}_config_clocks ops
authorMitchel Humpherys <mitchelh@codeaurora.org>
Tue, 15 Dec 2015 00:04:46 +0000 (16:04 -0800)
committerJeevan Shriram <jshriram@codeaurora.org>
Sat, 21 May 2016 02:23:57 +0000 (19:23 -0700)
There are certain use cases where it might be necessary to leave the
IOMMU's configuration clocks on.  This might happen in places where an
IOMMU's clocks might not be known.  A good example of this would be a
test library that needs to be able to do TLB invalidation from atomic
context.  It would need to enable clocks up front (outside of atomic
context) and leave them on for the duration of the test.

Add some ops for enabling and disabling configuration clocks.

CRs-Fixed: 997751
Change-Id: I95056952f60494fe5745f2183f9af8aab3a40315
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
include/linux/iommu.h

index a41f341..7b6ea78 100644 (file)
@@ -174,6 +174,8 @@ struct iommu_dm_region {
  * @reg_read: read an IOMMU register
  * @reg_write: write an IOMMU register
  * @tlbi_domain: Invalidate all TLBs covering an iommu domain
+ * @enable_config_clocks: Enable all config clocks for this domain's IOMMU
+ * @disable_config_clocks: Disable all config clocks for this domain's IOMMU
  * @priv: per-instance data private to the iommu driver
  */
 struct iommu_ops {
@@ -222,6 +224,8 @@ struct iommu_ops {
        void (*reg_write)(struct iommu_domain *domain, unsigned long val,
                          unsigned long offset);
        void (*tlbi_domain)(struct iommu_domain *domain);
+       int (*enable_config_clocks)(struct iommu_domain *domain);
+       void (*disable_config_clocks)(struct iommu_domain *domain);
 
 #ifdef CONFIG_OF_IOMMU
        int (*of_xlate)(struct device *dev, struct of_phandle_args *args);
@@ -390,6 +394,19 @@ static inline void iommu_tlbiall(struct iommu_domain *domain)
                domain->ops->tlbi_domain(domain);
 }
 
+static inline int iommu_enable_config_clocks(struct iommu_domain *domain)
+{
+       if (domain->ops->enable_config_clocks)
+               return domain->ops->enable_config_clocks(domain);
+       return 0;
+}
+
+static inline void iommu_disable_config_clocks(struct iommu_domain *domain)
+{
+       if (domain->ops->disable_config_clocks)
+               domain->ops->disable_config_clocks(domain);
+}
+
 #else /* CONFIG_IOMMU_API */
 
 struct iommu_ops {};
@@ -638,6 +655,15 @@ static inline void iommu_tlbiall(struct iommu_domain *domain)
 {
 }
 
+static inline int iommu_enable_config_clocks(struct iommu_domain *domain)
+{
+       return 0;
+}
+
+static inline void iommu_disable_config_clocks(struct iommu_domain *domain)
+{
+}
+
 #endif /* CONFIG_IOMMU_API */
 
 #endif /* __LINUX_IOMMU_H */