Merge tag 'trace-v5.15-3' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt...
[linux-2.6-microblaze.git] / include / linux / swiotlb.h
index d1f3d95..b0cb2a9 100644 (file)
@@ -73,7 +73,8 @@ extern enum swiotlb_force swiotlb_force;
  *             range check to see if the memory was in fact allocated by this
  *             API.
  * @nslabs:    The number of IO TLB blocks (in groups of 64) between @start and
- *             @end. This is command line adjustable via setup_io_tlb_npages.
+ *             @end. For default swiotlb, this is command line adjustable via
+ *             setup_io_tlb_npages.
  * @used:      The number of used IO TLB block.
  * @list:      The free list describing the number of free entries available
  *             from each index.
@@ -84,6 +85,8 @@ extern enum swiotlb_force swiotlb_force;
  *             unmap calls.
  * @debugfs:   The dentry to debugfs.
  * @late_alloc:        %true if allocated using the page allocator
+ * @force_bounce: %true if swiotlb bouncing is forced
+ * @for_alloc:  %true if the pool is used for memory allocation
  */
 struct io_tlb_mem {
        phys_addr_t start;
@@ -94,13 +97,15 @@ struct io_tlb_mem {
        spinlock_t lock;
        struct dentry *debugfs;
        bool late_alloc;
+       bool force_bounce;
+       bool for_alloc;
        struct io_tlb_slot {
                phys_addr_t orig_addr;
                size_t alloc_size;
                unsigned int list;
-       } slots[];
+       } *slots;
 };
-extern struct io_tlb_mem *io_tlb_default_mem;
+extern struct io_tlb_mem io_tlb_default_mem;
 
 static inline bool is_swiotlb_buffer(struct device *dev, phys_addr_t paddr)
 {
@@ -109,10 +114,17 @@ static inline bool is_swiotlb_buffer(struct device *dev, phys_addr_t paddr)
        return mem && paddr >= mem->start && paddr < mem->end;
 }
 
+static inline bool is_swiotlb_force_bounce(struct device *dev)
+{
+       struct io_tlb_mem *mem = dev->dma_io_tlb_mem;
+
+       return mem && mem->force_bounce;
+}
+
 void __init swiotlb_exit(void);
 unsigned int swiotlb_max_segment(void);
 size_t swiotlb_max_mapping_size(struct device *dev);
-bool is_swiotlb_active(void);
+bool is_swiotlb_active(struct device *dev);
 void __init swiotlb_adjust_size(unsigned long size);
 #else
 #define swiotlb_force SWIOTLB_NO_FORCE
@@ -120,6 +132,10 @@ static inline bool is_swiotlb_buffer(struct device *dev, phys_addr_t paddr)
 {
        return false;
 }
+static inline bool is_swiotlb_force_bounce(struct device *dev)
+{
+       return false;
+}
 static inline void swiotlb_exit(void)
 {
 }
@@ -132,7 +148,7 @@ static inline size_t swiotlb_max_mapping_size(struct device *dev)
        return SIZE_MAX;
 }
 
-static inline bool is_swiotlb_active(void)
+static inline bool is_swiotlb_active(struct device *dev)
 {
        return false;
 }
@@ -145,4 +161,28 @@ static inline void swiotlb_adjust_size(unsigned long size)
 extern void swiotlb_print_info(void);
 extern void swiotlb_set_max_segment(unsigned int);
 
+#ifdef CONFIG_DMA_RESTRICTED_POOL
+struct page *swiotlb_alloc(struct device *dev, size_t size);
+bool swiotlb_free(struct device *dev, struct page *page, size_t size);
+
+static inline bool is_swiotlb_for_alloc(struct device *dev)
+{
+       return dev->dma_io_tlb_mem->for_alloc;
+}
+#else
+static inline struct page *swiotlb_alloc(struct device *dev, size_t size)
+{
+       return NULL;
+}
+static inline bool swiotlb_free(struct device *dev, struct page *page,
+                               size_t size)
+{
+       return false;
+}
+static inline bool is_swiotlb_for_alloc(struct device *dev)
+{
+       return false;
+}
+#endif /* CONFIG_DMA_RESTRICTED_POOL */
+
 #endif /* __LINUX_SWIOTLB_H */