IOMMU: Some more IOVA and core code tidy-up
Subsystems (2)
v2 cover IOMMU: Some more IOVA and core code tidy-up
Just some tidy-up to IOVA and core code.
Based on v5.11-rc2
Differences to v1:
- Add core IOMMU patches
John Garry (6):
iova: Make has_iova_flush_queue() private
iova: Delete copy_reserved_iova()
iova: Stop exporting some more functions
iommu: Stop exporting iommu_map_sg_atomic()
iommu: Delete iommu_domain_window_disable()
iommu: Delete iommu_dev_has_feature()
drivers/iommu/iommu.c | 21 --------------------- drivers/iommu/iova.c | 36 +----------------------------------- include/linux/iommu.h | 13 ------------- include/linux/iova.h | 12 ------------ 4 files changed, 1 insertion(+), 81 deletions(-)
Signature · 6 lines
2.26.2 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
PATCH v2 1/6 iova: Make has_iova_flush_queue() private
Function has_iova_flush_queue() has no users outside iova.c, so make it private.
--- drivers/iommu/iova.c | 2 +- include/linux/iova.h | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-)
drivers/iommu/iova.c +1 -1
@@ -55,7 +55,7 @@ init_iova_domain(struct iova_domain *iovad, unsigned long granule, }EXPORT_SYMBOL_GPL (init_iova_domain); -bool has_iova_flush_queue (struct iova_domain *iovad) +static bool has_iova_flush_queue (struct iova_domain *iovad) {return !!iovad->fq; }
include/linux/iova.h +0 -6
@@ -153,7 +153,6 @@ struct iova *reserve_iova(struct iova_domain *iovad, unsigned long pfn_lo,void copy_reserved_iova (struct iova_domain *from,struct iova_domain *to);void init_iova_domain (struct iova_domain *iovad,unsigned long granule,unsigned long start_pfn); -bool has_iova_flush_queue (struct iova_domain *iovad);int init_iova_flush_queue (struct iova_domain *iovad,iova_flush_cb flush_cb,iova_entry_dtor entry_dtor);struct iova *find_iova (struct iova_domain *iovad,unsigned long pfn);
@@ -223,11 +222,6 @@ static inline void init_iova_domain(struct iova_domain *iovad, { } -static inline bool has_iova_flush_queue (struct iova_domain *iovad) -{ -return false; -} -static inline int init_iova_flush_queue (struct iova_domain *iovad,iova_flush_cb flush_cb,iova_entry_dtor entry_dtor)
Signature · 6 lines
2.26.2 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
PATCH v2 2/6 iova: Delete copy_reserved_iova()
In reply to John GarrySince commit c588072bba6b ("iommu/vt-d: Convert intel iommu driver to the iommu ops"), function copy_reserved_iova() is not referenced, so delete it.
--- drivers/iommu/iova.c | 30 ------------------------------ include/linux/iova.h | 6 ------ 2 files changed, 36 deletions(-)
drivers/iommu/iova.c +0 -30
@@ -710,36 +710,6 @@ reserve_iova(struct iova_domain *iovad, }EXPORT_SYMBOL_GPL (reserve_iova); -/** -* copy_reserved_iova - copies the reserved between domains -* @from: - source doamin from where to copy -* @to: - destination domin where to copy -* This function copies reserved iova's from one doamin to -* other. -*/ -void -copy_reserved_iova (struct iova_domain *from,struct iova_domain *to) -{ -unsigned long flags; -struct rb_node *node; - -spin_lock_irqsave (&from->iova_rbtree_lock, flags); -for (node =rb_first (&from->rbroot); node; node =rb_next (node)) { - struct iova *iova = rb_entry(node, struct iova, node); -struct iova *new_iova; - -if (iova->pfn_lo ==IOVA_ANCHOR ) -continue ; - - new_iova =reserve_iova (to, iova->pfn_lo, iova->pfn_hi); -if (!new_iova) -pr_err ("Reserve iova range %lx@%lx failed\n" , - iova->pfn_lo, iova->pfn_lo); - } -spin_unlock_irqrestore (&from->iova_rbtree_lock, flags); -} -EXPORT_SYMBOL_GPL (copy_reserved_iova); -/* * Magazine caches for IOVA ranges. For an introduction to magazines, * see the USENIX 2001 paper "Magazines and Vmem: Extending the Slab
include/linux/iova.h +0 -6
@@ -150,7 +150,6 @@ unsigned long alloc_iova_fast(struct iova_domain *iovad, unsigned long size, unsigned long limit_pfn, bool flush_rcache);struct iova *reserve_iova (struct iova_domain *iovad,unsigned long pfn_lo,unsigned long pfn_hi); -void copy_reserved_iova (struct iova_domain *from,struct iova_domain *to);void init_iova_domain (struct iova_domain *iovad,unsigned long granule,unsigned long start_pfn); int init_iova_flush_queue(struct iova_domain *iovad,
@@ -211,11 +210,6 @@ static inline struct iova *reserve_iova(struct iova_domain *iovad,return NULL ; } -static inline void copy_reserved_iova (struct iova_domain *from, -struct iova_domain *to) -{ -} -static inline void init_iova_domain (struct iova_domain *iovad,unsigned long granule,unsigned long start_pfn)
Signature · 6 lines
2.26.2 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
PATCH v2 3/6 iova: Stop exporting some more functions
In reply to John GarryThe following functions are not referenced outside dma-iommu.c (and iova.c), which can only be built-in:
- init_iova_flush_queue()
- free_iova_fast()
- queue_iova()
- alloc_iova_fast()
So stop exporting them.
--- drivers/iommu/iova.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/iommu/iova.c +0 -4
@@ -112,7 +112,6 @@ int init_iova_flush_queue(struct iova_domain *iovad,return 0 ; } -EXPORT_SYMBOL_GPL (init_iova_flush_queue);static struct rb_node *__get_cached_rbnode (struct iova_domain *iovad,unsigned long limit_pfn)
@@ -451,7 +450,6 @@ alloc_iova_fast(struct iova_domain *iovad, unsigned long size,return new_iova->pfn_lo; } -EXPORT_SYMBOL_GPL (alloc_iova_fast);/** * free_iova_fast - free iova pfn range into rcache
@@ -469,7 +467,6 @@ free_iova_fast(struct iova_domain *iovad, unsigned long pfn, unsigned long size)free_iova (iovad, pfn); } -EXPORT_SYMBOL_GPL (free_iova_fast);#define fq_ring_for_each (i, fq) \ for ((i) = (fq)->head; (i) != (fq)->tail; (i) = ((i) + 1) % IOVA_FQ_SIZE)
@@ -598,7 +595,6 @@ void queue_iova(struct iova_domain *iovad,mod_timer (&iovad->fq_timer, jiffies +msecs_to_jiffies (IOVA_FQ_TIMEOUT )); } -EXPORT_SYMBOL_GPL (queue_iova);/** * put_iova_domain - destroys the iova doamin
Signature · 6 lines
2.26.2 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
PATCH v2 4/6 iommu: Stop exporting iommu_map_sg_atomic()
In reply to John GarryFunction iommu_map_sg_atomic() is only referenced in dma-iommu.c, which can only be built-in, so stop exporting.
--- drivers/iommu/iommu.c | 1 - 1 file changed, 1 deletion(-)
drivers/iommu/iommu.c +0 -1
@@ -2586,7 +2586,6 @@ size_t iommu_map_sg_atomic(struct iommu_domain *domain, unsigned long iova, {return __iommu_map_sg (domain, iova, sg, nents, prot,GFP_ATOMIC ); } -EXPORT_SYMBOL_GPL (iommu_map_sg_atomic);int iommu_domain_window_enable (struct iommu_domain *domain,u32 wnd_nr,phys_addr_t paddr,u64 size,int prot)
Signature · 6 lines
2.26.2 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
PATCH v2 5/6 iommu: Delete iommu_domain_window_disable()
In reply to John GarryFunction iommu_domain_window_disable() is not referenced in the tree, so delete it.
--- drivers/iommu/iommu.c | 9 --------- include/linux/iommu.h | 6 ------ 2 files changed, 15 deletions(-)
drivers/iommu/iommu.c +0 -9
@@ -2598,15 +2598,6 @@ int iommu_domain_window_enable(struct iommu_domain *domain, u32 wnd_nr, }EXPORT_SYMBOL_GPL (iommu_domain_window_enable); -void iommu_domain_window_disable (struct iommu_domain *domain,u32 wnd_nr) -{ -if (unlikely (domain->ops->domain_window_disable ==NULL )) -return ; - -return domain->ops->domain_window_disable (domain, wnd_nr); -} -EXPORT_SYMBOL_GPL (iommu_domain_window_disable); -/** * report_iommu_fault() - report about an IOMMU fault to the IOMMU framework * @domain: the iommu domain where the fault has happened
include/linux/iommu.h +0 -6
@@ -514,7 +514,6 @@ extern int iommu_domain_set_attr(struct iommu_domain *domain, enum iommu_attr,extern int iommu_domain_window_enable (struct iommu_domain *domain,u32 wnd_nr,phys_addr_t offset,u64 size,int prot); -extern void iommu_domain_window_disable (struct iommu_domain *domain,u32 wnd_nr);extern int report_iommu_fault (struct iommu_domain *domain,struct device *dev,unsigned long iova,int flags);
@@ -746,11 +745,6 @@ static inline int iommu_domain_window_enable(struct iommu_domain *domain,return -ENODEV ; } -static inline void iommu_domain_window_disable (struct iommu_domain *domain, -u32 wnd_nr) -{ -} -static inline phys_addr_t iommu_iova_to_phys (struct iommu_domain *domain,dma_addr_t iova) {return 0 ;
Signature · 6 lines
2.26.2 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
PATCH v2 6/6 iommu: Delete iommu_dev_has_feature()
In reply to John GarryFunction iommu_dev_has_feature() has never been referenced in the tree, and there does not appear to be anything coming soon to use it, so delete it.
--- drivers/iommu/iommu.c | 11 ----------- include/linux/iommu.h | 7 ------- 2 files changed, 18 deletions(-)
drivers/iommu/iommu.c +0 -11
@@ -2853,17 +2853,6 @@ EXPORT_SYMBOL_GPL(iommu_fwspec_add_ids);/* * Per device IOMMU features. */ -bool iommu_dev_has_feature (struct device *dev,enum iommu_dev_features feat) -{ -const struct iommu_ops *ops = dev->bus->iommu_ops; - -if (ops && ops->dev_has_feat) -return ops->dev_has_feat (dev, feat); - -return false; -} -EXPORT_SYMBOL_GPL (iommu_dev_has_feature); -int iommu_dev_enable_feature (struct device *dev,enum iommu_dev_features feat) {const struct iommu_ops *ops = dev->bus->iommu_ops;
include/linux/iommu.h +0 -7
@@ -626,7 +626,6 @@ static inline void dev_iommu_priv_set(struct device *dev, void *priv)int iommu_probe_device (struct device *dev);void iommu_release_device (struct device *dev); -bool iommu_dev_has_feature (struct device *dev,enum iommu_dev_features f);int iommu_dev_enable_feature (struct device *dev,enum iommu_dev_features f);int iommu_dev_disable_feature (struct device *dev,enum iommu_dev_features f);bool iommu_dev_feature_enabled (struct device *dev,enum iommu_dev_features f);
@@ -975,12 +974,6 @@ const struct iommu_ops *iommu_ops_from_fwnode(struct fwnode_handle *fwnode)return NULL ; } -static inline bool -iommu_dev_has_feature (struct device *dev,enum iommu_dev_features feat) -{ -return false; -} -static inline bool iommu_dev_feature_enabled (struct device *dev,enum iommu_dev_features feat) {
Signature · 6 lines
2.26.2 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v2 6/6] iommu: Delete iommu_dev_has_feature()
Quoted 3 lines · John Garry
Function
iommu_dev_has_feature()has never been referenced in the tree, and there does not appear to be anything coming soon to use it, so delete it.
It will be used by the device driver which want to support the aux- domain capability, for example, below series is under discussion.
The typical use case is
if (iommu_dev_has_feature(dev, IOMMU_DEV_FEAT_AUX)) {
rc = iommu_dev_enable_feature(dev, IOMMU_DEV_FEAT_AUX);
if (rc < 0) {
dev_warn(dev, "Failed to enable aux-domain:
%d\n", rc);
return rc;
}
}So please don't remove it.
Best regards,
baolu
Quoted 45 lines
Signed-off-by John Garry <[email protected]>--- drivers/iommu/iommu.c | 11 ----------- include/linux/iommu.h | 7 ------- 2 files changed, 18 deletions(-)drivers/iommu/iommu.c +0
-11@@ -2853,17 +2853,6 @@ EXPORT_SYMBOL_GPL(iommu_fwspec_add_ids);/* * Per device IOMMU features. */ -bool iommu_dev_has_feature (struct device *dev,enum iommu_dev_features feat) -{ -const struct iommu_ops *ops = dev->bus->iommu_ops; - -if (ops && ops->dev_has_feat) -return ops->dev_has_feat (dev, feat); - -return false; -} -EXPORT_SYMBOL_GPL (iommu_dev_has_feature); -int iommu_dev_enable_feature (struct device *dev,enum iommu_dev_features feat) {const struct iommu_ops *ops = dev->bus->iommu_ops;include/linux/iommu.h +0
-1@@ -626,7 +626,6 @@ static inline void dev_iommu_priv_set(struct device *dev, void *priv)int iommu_probe_device (struct device *dev);void iommu_release_device (struct device *dev); -bool iommu_dev_has_feature (struct device *dev,enum iommu_dev_features f);int iommu_dev_enable_feature (struct device *dev,enum iommu_dev_features f);int iommu_dev_disable_feature (struct device *dev,enum iommu_dev_features f);bool iommu_dev_feature_enabled (struct device *dev,enum iommu_dev_features f);@@ -975,12 +974,6 @@ const struct iommu_ops *iommu_ops_from_fwnode(struct fwnode_handle *fwnode)return NULL ; }
include/linux/iommu.h const struct iommu_ops *iommu_ops_from_fwnode(struct fwnode_handle *fwnode) · line 979
Quoted 10 lines
include/linux/iommu.h +0
-6-static inline bool -iommu_dev_has_feature (struct device *dev,enum iommu_dev_features feat) -{ -return false; -} -static inline bool iommu_dev_feature_enabled (struct device *dev,enum iommu_dev_features feat) {
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v2 6/6] iommu: Delete iommu_dev_has_feature()
Quoted 5 lines · Lu Baolu
Quoted 3 lines · John Garry
Function
iommu_dev_has_feature()has never been referenced in the tree, and there does not appear to be anything coming soon to use it, so delete it.
Hi baolu,
Quoted 5 lines
It will be used by the device driver which want to support the aux- domain capability, for example, below series is under discussion.
So I did check linux-iommu lore for recent references, above, but did not see this one - that really should have cc'ed linux-iommu list (which it didn't).
Quoted 12 lines
The typical use case is
if (
iommu_dev_has_feature(dev, IOMMU_DEV_FEAT_AUX)) { rc =iommu_dev_enable_feature(dev, IOMMU_DEV_FEAT_AUX); if (rc < 0) {
dev_warn(dev, "Failed to enable aux-domain:
%d\n", rc);
return rc;
}
}
Quoted 2 lines
So please don't remove it.
ok, fine. It also seems that this API has not had a user since it was introduced in v5.2.
Thanks,
John
Ps. I suppose a v3 series is not needed ATM - this patch can just be dropped.
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v2 6/6] iommu: Delete iommu_dev_has_feature()
In reply to Lu BaoluQuoted 11 lines · Lu Baolu
The typical use case is
if (iommu_dev_has_feature(dev, IOMMU_DEV_FEAT_AUX)) { rc = iommu_dev_enable_feature(dev, IOMMU_DEV_FEAT_AUX); if (rc < 0) { dev_warn(dev, "Failed to enable aux-domain: %d\n", rc); return rc; } }
Quoted 1 line
So please don't remove it.
This doesn't have an upstream user, and did not have for years! If new users show up they can add it back. Note that the above API with a separate has vs enable is horrible anyway - the right way is to just enable and fail it with a specific error code if not supported.
We have a general rule that APIs should only be introduced with their users, and this example just confirms the reasons of why that rule is in place once again.
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Quoted 15 lines · John Garry
Just some tidy-up to IOVA and core code.
Based on v5.11-rc2
Differences to v1:
- Add core IOMMU patchesJohn Garry (6):
iova: Makehas_iova_flush_queue()private
iova: Deletecopy_reserved_iova()
iova: Stop exporting some more functions
iommu: Stop exportingiommu_map_sg_atomic()
iommu: Deleteiommu_domain_window_disable()
iommu: Deleteiommu_dev_has_feature()
Quoted 5 lines
drivers/iommu/iommu.c | 21 --------------------- drivers/iommu/iova.c | 36 +----------------------------------- include/linux/iommu.h | 13 ------------- include/linux/iova.h | 12 ------------ 4 files changed, 1 insertion(+), 81 deletions(-)
For the series:
Will
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Joerg Roedel
maintainerQuoted 7 lines · John Garry
Just some tidy-up to IOVA and core code.
Based on v5.11-rc2
Differences to v1:
- Add core IOMMU patches
Quoted 7 lines
John Garry (6):
iova: Makehas_iova_flush_queue()private
iova: Deletecopy_reserved_iova()
iova: Stop exporting some more functions
iommu: Stop exportingiommu_map_sg_atomic()
iommu: Deleteiommu_domain_window_disable()
iommu: Deleteiommu_dev_has_feature()
Applied, thanks.
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu