@@ -1644,6 +1644,7 @@ static const struct iommu_ops arm_smmu_ops = {
.def_domain_type = arm_smmu_def_domain_type,
.owner = THIS_MODULE,
.default_domain_ops = &(const struct iommu_domain_ops) {
+ .report_iommu_fault_supported = true,
.attach_dev = arm_smmu_attach_dev,
.map_pages = arm_smmu_map_pages,
.unmap_pages = arm_smmu_unmap_pages,
@@ -598,6 +598,7 @@ static const struct iommu_ops qcom_iommu_ops = {
.device_group = generic_device_group,
.of_xlate = qcom_iommu_of_xlate,
.default_domain_ops = &(const struct iommu_domain_ops) {
+ .report_iommu_fault_supported = true,
.attach_dev = qcom_iommu_attach_dev,
.map_pages = qcom_iommu_map,
.unmap_pages = qcom_iommu_unmap,
@@ -2005,6 +2005,9 @@ EXPORT_SYMBOL_GPL(iommu_group_has_isolated_msi);
* This function should be used by IOMMU users which want to be notified
* whenever an IOMMU fault happens.
*
+ * This is a legacy API not supported by all drivers. New users should look
+ * to using domain->iopf_handler for the modern API.
+ *
* The fault handler itself should return 0 on success, and an appropriate
* error code otherwise.
*/
@@ -2012,7 +2015,8 @@ void iommu_set_fault_handler(struct iommu_domain *domain,
iommu_fault_handler_t handler,
void *token)
{
- if (WARN_ON(!domain || domain->cookie_type != IOMMU_COOKIE_NONE))
+ if (WARN_ON(!domain || domain->cookie_type != IOMMU_COOKIE_NONE ||
+ !domain->ops->report_iommu_fault_supported))
return;
domain->cookie_type = IOMMU_COOKIE_FAULT_HANDLER;
@@ -885,6 +885,7 @@ static const struct iommu_ops ipmmu_ops = {
? generic_device_group : generic_single_device_group,
.of_xlate = ipmmu_of_xlate,
.default_domain_ops = &(const struct iommu_domain_ops) {
+ .report_iommu_fault_supported = true,
.attach_dev = ipmmu_attach_device,
.map_pages = ipmmu_map,
.unmap_pages = ipmmu_unmap,
@@ -1019,6 +1019,7 @@ static const struct iommu_ops mtk_iommu_ops = {
.get_resv_regions = mtk_iommu_get_resv_regions,
.owner = THIS_MODULE,
.default_domain_ops = &(const struct iommu_domain_ops) {
+ .report_iommu_fault_supported = true,
.attach_dev = mtk_iommu_attach_device,
.map_pages = mtk_iommu_map,
.unmap_pages = mtk_iommu_unmap,
@@ -582,6 +582,7 @@ static const struct iommu_ops mtk_iommu_v1_ops = {
.device_group = generic_device_group,
.owner = THIS_MODULE,
.default_domain_ops = &(const struct iommu_domain_ops) {
+ .report_iommu_fault_supported = true,
.attach_dev = mtk_iommu_v1_attach_device,
.map_pages = mtk_iommu_v1_map,
.unmap_pages = mtk_iommu_v1_unmap,
@@ -1724,6 +1724,7 @@ static const struct iommu_ops omap_iommu_ops = {
.device_group = generic_single_device_group,
.of_xlate = omap_iommu_of_xlate,
.default_domain_ops = &(const struct iommu_domain_ops) {
+ .report_iommu_fault_supported = true,
.attach_dev = omap_iommu_attach_dev,
.map_pages = omap_iommu_map,
.unmap_pages = omap_iommu_unmap,
@@ -1174,6 +1174,7 @@ static const struct iommu_ops rk_iommu_ops = {
.device_group = generic_single_device_group,
.of_xlate = rk_iommu_of_xlate,
.default_domain_ops = &(const struct iommu_domain_ops) {
+ .report_iommu_fault_supported = true,
.attach_dev = rk_iommu_attach_device,
.map_pages = rk_iommu_map,
.unmap_pages = rk_iommu_unmap,
@@ -849,6 +849,7 @@ static const struct iommu_ops sun50i_iommu_ops = {
.of_xlate = sun50i_iommu_of_xlate,
.probe_device = sun50i_iommu_probe_device,
.default_domain_ops = &(const struct iommu_domain_ops) {
+ .report_iommu_fault_supported = true,
.attach_dev = sun50i_iommu_attach_device,
.flush_iotlb_all = sun50i_iommu_flush_iotlb_all,
.iotlb_sync_map = sun50i_iommu_iotlb_sync_map,
@@ -714,6 +714,8 @@ struct iommu_ops {
/**
* struct iommu_domain_ops - domain specific operations
+ * @report_iommu_fault_supported: True if the domain supports
+ * iommu_set_fault_handler()
* @attach_dev: attach an iommu domain to a device
* Return:
* * 0 - success
@@ -751,6 +753,7 @@ struct iommu_ops {
* @free: Release the domain after use.
*/
struct iommu_domain_ops {
+ bool report_iommu_fault_supported : 1;
int (*attach_dev)(struct iommu_domain *domain, struct device *dev);
int (*set_dev_pasid)(struct iommu_domain *domain, struct device *dev,
ioasid_t pasid, struct iommu_domain *old);