diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c index b9b2232b6b83421e5c3bb95e709ceed3ca30b371..be4b66ccdd054ab9347116a8a49c3718715168a7 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -4081,6 +4081,22 @@ static int arm_smmu_device_domain_type(struct device *dev) } #endif +static int arm_smmu_device_get_config(struct device *dev, int type, void *data) +{ + switch (type) { + default: + return -EINVAL; + } +} + +static int arm_smmu_device_set_config(struct device *dev, int type, void *data) +{ + switch (type) { + default: + return -EINVAL; + } +} + static struct iommu_ops arm_smmu_ops = { .capable = arm_smmu_capable, .domain_alloc = arm_smmu_domain_alloc, @@ -4122,6 +4138,8 @@ static struct iommu_ops arm_smmu_ops = { #ifdef CONFIG_SMMU_BYPASS_DEV .def_domain_type = arm_smmu_device_domain_type, #endif + .dev_get_config = arm_smmu_device_get_config, + .dev_set_config = arm_smmu_device_set_config, .pgsize_bitmap = -1UL, /* Restricted during device attach */ }; diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 9adb9d2502ae591f3c1c78e1bd6c06b07eadc5a6..25b3b8386ca9df8499282d0647d9c8755c18e57f 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -3567,3 +3567,25 @@ u32 iommu_sva_get_pasid(struct iommu_sva *handle) return ops->sva_get_pasid(handle); } EXPORT_SYMBOL_GPL(iommu_sva_get_pasid); + +int iommu_dev_set_config(struct device *dev, int type, void *data) +{ + const struct iommu_ops *ops = dev->bus->iommu_ops; + + if (ops && ops->dev_set_config) + return ops->dev_set_config(dev, type, data); + + return -ENODEV; +} +EXPORT_SYMBOL_GPL(iommu_dev_set_config); + +int iommu_dev_get_config(struct device *dev, int type, void *data) +{ + const struct iommu_ops *ops = dev->bus->iommu_ops; + + if (ops && ops->dev_get_config) + return ops->dev_get_config(dev, type, data); + + return -ENODEV; +} +EXPORT_SYMBOL_GPL(iommu_dev_get_config); diff --git a/include/linux/iommu.h b/include/linux/iommu.h index d899e7a5f234ef663315a9281236ab7982439fbd..ed12f5cac0b44c029c28e792ce45c5da0445834f 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -348,6 +348,9 @@ struct iommu_ops { dma_addr_t giova, phys_addr_t gpa, size_t size); void (*unbind_guest_msi)(struct iommu_domain *domain, dma_addr_t giova); + int (*dev_get_config)(struct device *dev, int type, void *data); + int (*dev_set_config)(struct device *dev, int type, void *data); + unsigned long pgsize_bitmap; struct module *owner; }; @@ -584,6 +587,9 @@ extern int iommu_clear_dirty_log(struct iommu_domain *domain, unsigned long iova unsigned long base_iova, unsigned long bitmap_pgshift); +extern int iommu_dev_set_config(struct device *dev, int type, void *data); +extern int iommu_dev_get_config(struct device *dev, int type, void *data); + /* Window handling function prototypes */ extern int iommu_domain_window_enable(struct iommu_domain *domain, u32 wnd_nr, phys_addr_t offset, u64 size, @@ -1215,6 +1221,18 @@ int iommu_bind_guest_msi(struct iommu_domain *domain, static inline void iommu_unbind_guest_msi(struct iommu_domain *domain, dma_addr_t giova) {} +static inline +int iommu_dev_set_config(struct device *dev, int type, void *data) +{ + return -ENODEV; +} + +static inline +int iommmu_dev_get_config(struct device *dev, int type, void *data) +{ + return -ENODEV; +} + #endif /* CONFIG_IOMMU_API */ /**