Thread (15 messages) 15 messages, 4 authors, 2021-02-02

Re: [PATCH v4 5/7] iommu/io-pgtable: Allow io_pgtable_tlb ops optional

flat view

From: Robin Murphy <robin.murphy@arm.com>
Date: 2021-01-18 18:47:47
Also in: linux-iommu, linux-mediatek, lkml

On 2021-01-07 12:29, Yong Wu wrote:
This patch allows io_pgtable_tlb ops could be null since the IOMMU drivers
may use the tlb ops from iommu framework.
For the reasons I gave on v3,

Reviewed-by: Robin Murphy <robin.murphy@arm.com>
quoted hunk ↗ jump to hunk
Signed-off-by: Yong Wu <yong.wu@mediatek.com>
---
  include/linux/io-pgtable.h | 8 +++++---
  1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/include/linux/io-pgtable.h b/include/linux/io-pgtable.h
index ea727eb1a1a9..2a5686ca2ba3 100644
--- a/include/linux/io-pgtable.h
+++ b/include/linux/io-pgtable.h
@@ -214,14 +214,16 @@ struct io_pgtable_domain_attr {
  
  static inline void io_pgtable_tlb_flush_all(struct io_pgtable *iop)
  {
-	iop->cfg.tlb->tlb_flush_all(iop->cookie);
+	if (iop->cfg.tlb && iop->cfg.tlb->tlb_flush_all)
+		iop->cfg.tlb->tlb_flush_all(iop->cookie);
  }
  
  static inline void
  io_pgtable_tlb_flush_walk(struct io_pgtable *iop, unsigned long iova,
  			  size_t size, size_t granule)
  {
-	iop->cfg.tlb->tlb_flush_walk(iova, size, granule, iop->cookie);
+	if (iop->cfg.tlb && iop->cfg.tlb->tlb_flush_walk)
+		iop->cfg.tlb->tlb_flush_walk(iova, size, granule, iop->cookie);
  }
  
  static inline void
@@ -229,7 +231,7 @@ io_pgtable_tlb_add_page(struct io_pgtable *iop,
  			struct iommu_iotlb_gather * gather, unsigned long iova,
  			size_t granule)
  {
-	if (iop->cfg.tlb->tlb_add_page)
+	if (iop->cfg.tlb && iop->cfg.tlb->tlb_add_page)
  		iop->cfg.tlb->tlb_add_page(gather, iova, granule, iop->cookie);
  }
  
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help