Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e5693ae8 authored by Mitchel Humpherys's avatar Mitchel Humpherys
Browse files

iommu: Add {enable,disable}_config_clocks ops



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: default avatarMitchel Humpherys <mitchelh@codeaurora.org>
parent 4592b26e
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -134,6 +134,8 @@ extern struct dentry *iommu_debugfs_top;
 * @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 {
@@ -180,6 +182,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);
@@ -340,6 +344,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 {};
@@ -580,6 +597,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 */