提交 c0aec668 编写于 作者: R Robin Murphy 提交者: Joerg Roedel

iommu: Statically set module owner

It happens that the 3 drivers which first supported being modular are
also ones which play games with their pgsize_bitmap, so have non-const
iommu_ops where dynamically setting the owner manages to work out OK.
However, it's less than ideal to force that upon all drivers which want
to be modular - like the new sprd-iommu driver which now has a potential
bug in that regard - so let's just statically set the module owner and
let ops remain const wherever possible.
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Acked-by: NWill Deacon <will@kernel.org>
Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
Link: https://lore.kernel.org/r/31423b99ff609c3d4b291c701a7a7a810d9ce8dc.1617285386.git.robin.murphy@arm.comSigned-off-by: NJoerg Roedel <jroedel@suse.de>
上级 49d11527
...@@ -2674,6 +2674,7 @@ static struct iommu_ops arm_smmu_ops = { ...@@ -2674,6 +2674,7 @@ static struct iommu_ops arm_smmu_ops = {
.sva_unbind = arm_smmu_sva_unbind, .sva_unbind = arm_smmu_sva_unbind,
.sva_get_pasid = arm_smmu_sva_get_pasid, .sva_get_pasid = arm_smmu_sva_get_pasid,
.pgsize_bitmap = -1UL, /* Restricted during device attach */ .pgsize_bitmap = -1UL, /* Restricted during device attach */
.owner = THIS_MODULE,
}; };
/* Probing and initialisation functions */ /* Probing and initialisation functions */
......
...@@ -1577,6 +1577,7 @@ static struct iommu_ops arm_smmu_ops = { ...@@ -1577,6 +1577,7 @@ static struct iommu_ops arm_smmu_ops = {
.put_resv_regions = generic_iommu_put_resv_regions, .put_resv_regions = generic_iommu_put_resv_regions,
.def_domain_type = arm_smmu_def_domain_type, .def_domain_type = arm_smmu_def_domain_type,
.pgsize_bitmap = -1UL, /* Restricted during device attach */ .pgsize_bitmap = -1UL, /* Restricted during device attach */
.owner = THIS_MODULE,
}; };
static void arm_smmu_device_reset(struct arm_smmu_device *smmu) static void arm_smmu_device_reset(struct arm_smmu_device *smmu)
......
...@@ -436,6 +436,7 @@ static const struct iommu_ops sprd_iommu_ops = { ...@@ -436,6 +436,7 @@ static const struct iommu_ops sprd_iommu_ops = {
.device_group = sprd_iommu_device_group, .device_group = sprd_iommu_device_group,
.of_xlate = sprd_iommu_of_xlate, .of_xlate = sprd_iommu_of_xlate,
.pgsize_bitmap = ~0UL << SPRD_IOMMU_PAGE_SHIFT, .pgsize_bitmap = ~0UL << SPRD_IOMMU_PAGE_SHIFT,
.owner = THIS_MODULE,
}; };
static const struct of_device_id sprd_iommu_of_match[] = { static const struct of_device_id sprd_iommu_of_match[] = {
......
...@@ -945,6 +945,7 @@ static struct iommu_ops viommu_ops = { ...@@ -945,6 +945,7 @@ static struct iommu_ops viommu_ops = {
.get_resv_regions = viommu_get_resv_regions, .get_resv_regions = viommu_get_resv_regions,
.put_resv_regions = generic_iommu_put_resv_regions, .put_resv_regions = generic_iommu_put_resv_regions,
.of_xlate = viommu_of_xlate, .of_xlate = viommu_of_xlate,
.owner = THIS_MODULE,
}; };
static int viommu_init_vqs(struct viommu_dev *viommu) static int viommu_init_vqs(struct viommu_dev *viommu)
......
...@@ -361,19 +361,12 @@ int iommu_device_link(struct iommu_device *iommu, struct device *link); ...@@ -361,19 +361,12 @@ int iommu_device_link(struct iommu_device *iommu, struct device *link);
void iommu_device_unlink(struct iommu_device *iommu, struct device *link); void iommu_device_unlink(struct iommu_device *iommu, struct device *link);
int iommu_deferred_attach(struct device *dev, struct iommu_domain *domain); int iommu_deferred_attach(struct device *dev, struct iommu_domain *domain);
static inline void __iommu_device_set_ops(struct iommu_device *iommu, static inline void iommu_device_set_ops(struct iommu_device *iommu,
const struct iommu_ops *ops) const struct iommu_ops *ops)
{ {
iommu->ops = ops; iommu->ops = ops;
} }
#define iommu_device_set_ops(iommu, ops) \
do { \
struct iommu_ops *__ops = (struct iommu_ops *)(ops); \
__ops->owner = THIS_MODULE; \
__iommu_device_set_ops(iommu, __ops); \
} while (0)
static inline void iommu_device_set_fwnode(struct iommu_device *iommu, static inline void iommu_device_set_fwnode(struct iommu_device *iommu,
struct fwnode_handle *fwnode) struct fwnode_handle *fwnode)
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册