diff options
| author | Mitchel Humpherys <mitchelh@codeaurora.org> | 2015-07-09 16:59:02 -0700 |
|---|---|---|
| committer | David Keitel <dkeitel@codeaurora.org> | 2016-03-22 11:13:32 -0700 |
| commit | 1f9b32916b0859cda5ca40f785fbffd45b3e5a25 (patch) | |
| tree | a746d7080d3b4ef8846fd6c79eb225097011ecaf | |
| parent | 4b8b66bb588a8d6a290e61b4b54c7dd1246f84e6 (diff) | |
iommu: Add iommu_trigger_fault
It can be useful to trigger an IOMMU fault during development and
debugging. Add support to the IOMMU framework to do so.
Change-Id: I908c9f5b52c6abe937f031de546d290027ba64b5
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
| -rw-r--r-- | drivers/iommu/iommu.c | 15 | ||||
| -rw-r--r-- | include/linux/iommu.h | 7 |
2 files changed, 22 insertions, 0 deletions
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 9821a73c33a8..9959b48e6f18 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -886,6 +886,21 @@ void iommu_set_fault_handler(struct iommu_domain *domain, } EXPORT_SYMBOL_GPL(iommu_set_fault_handler); +/** + * iommu_trigger_fault() - trigger an IOMMU fault + * @domain: iommu domain + * + * Triggers a fault on the device to which this domain is attached. + * + * This function should only be used for debugging purposes, for obvious + * reasons. + */ +void iommu_trigger_fault(struct iommu_domain *domain) +{ + if (domain->ops->trigger_fault) + domain->ops->trigger_fault(domain); +} + struct iommu_domain *iommu_domain_alloc(struct bus_type *bus) { struct iommu_domain *domain; diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 2e5b071d82d0..520cc5b4dae1 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -116,6 +116,7 @@ enum iommu_attr { * @domain_get_attr: Query domain attributes * @domain_set_attr: Change domain attributes * @pgsize_bitmap: bitmap of supported page sizes + * @trigger_fault: trigger a fault on the device attached to an iommu domain */ struct iommu_ops { bool (*capable)(enum iommu_cap); @@ -150,6 +151,7 @@ struct iommu_ops { u32 (*domain_get_windows)(struct iommu_domain *domain); int (*dma_supported)(struct iommu_domain *domain, struct device *dev, u64 mask); + void (*trigger_fault)(struct iommu_domain *domain); unsigned long pgsize_bitmap; }; @@ -185,6 +187,7 @@ extern phys_addr_t iommu_iova_to_phys_hard(struct iommu_domain *domain, dma_addr_t iova); extern void iommu_set_fault_handler(struct iommu_domain *domain, iommu_fault_handler_t handler, void *token); +extern void iommu_trigger_fault(struct iommu_domain *domain); extern int iommu_attach_group(struct iommu_domain *domain, struct iommu_group *group); @@ -374,6 +377,10 @@ static inline void iommu_set_fault_handler(struct iommu_domain *domain, { } +static inline void iommu_trigger_fault(struct iommu_domain *domain) +{ +} + static inline int iommu_attach_group(struct iommu_domain *domain, struct iommu_group *group) { |
