]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - include/linux/io-pgtable.h
iommu/io-pgtable-arm: Call ->tlb_flush_walk() and ->tlb_flush_leaf()
[linux.git] / include / linux / io-pgtable.h
index b5a450a3bb47a6f25beafa9510902af070f14dbd..0618aac59e747cf5697c305abb93386b571f8072 100644 (file)
@@ -17,19 +17,33 @@ enum io_pgtable_fmt {
 };
 
 /**
- * struct iommu_gather_ops - IOMMU callbacks for TLB and page table management.
+ * struct iommu_flush_ops - IOMMU callbacks for TLB and page table management.
  *
- * @tlb_flush_all: Synchronously invalidate the entire TLB context.
- * @tlb_add_flush: Queue up a TLB invalidation for a virtual address range.
- * @tlb_sync:      Ensure any queued TLB invalidation has taken effect, and
- *                 any corresponding page table updates are visible to the
- *                 IOMMU.
+ * @tlb_flush_all:  Synchronously invalidate the entire TLB context.
+ * @tlb_flush_walk: Synchronously invalidate all intermediate TLB state
+ *                  (sometimes referred to as the "walk cache") for a virtual
+ *                  address range.
+ * @tlb_flush_leaf: Synchronously invalidate all leaf TLB state for a virtual
+ *                  address range.
+ * @tlb_add_flush:  Optional callback to queue up leaf TLB invalidation for a
+ *                  virtual address range.  This function exists purely as an
+ *                  optimisation for IOMMUs that cannot batch TLB invalidation
+ *                  operations efficiently and are therefore better suited to
+ *                  issuing them early rather than deferring them until
+ *                  iommu_tlb_sync().
+ * @tlb_sync:       Ensure any queued TLB invalidation has taken effect, and
+ *                  any corresponding page table updates are visible to the
+ *                  IOMMU.
  *
  * Note that these can all be called in atomic context and must therefore
  * not block.
  */
-struct iommu_gather_ops {
+struct iommu_flush_ops {
        void (*tlb_flush_all)(void *cookie);
+       void (*tlb_flush_walk)(unsigned long iova, size_t size, size_t granule,
+                              void *cookie);
+       void (*tlb_flush_leaf)(unsigned long iova, size_t size, size_t granule,
+                              void *cookie);
        void (*tlb_add_flush)(unsigned long iova, size_t size, size_t granule,
                              bool leaf, void *cookie);
        void (*tlb_sync)(void *cookie);
@@ -84,7 +98,7 @@ struct io_pgtable_cfg {
        unsigned int                    ias;
        unsigned int                    oas;
        bool                            coherent_walk;
-       const struct iommu_gather_ops   *tlb;
+       const struct iommu_flush_ops    *tlb;
        struct device                   *iommu_dev;
 
        /* Low-level data specific to the table format */
@@ -184,6 +198,20 @@ static inline void io_pgtable_tlb_flush_all(struct io_pgtable *iop)
        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);
+}
+
+static inline void
+io_pgtable_tlb_flush_leaf(struct io_pgtable *iop, unsigned long iova,
+                         size_t size, size_t granule)
+{
+       iop->cfg.tlb->tlb_flush_leaf(iova, size, granule, iop->cookie);
+}
+
 static inline void io_pgtable_tlb_add_flush(struct io_pgtable *iop,
                unsigned long iova, size_t size, size_t granule, bool leaf)
 {