]> err.no Git - linux-2.6/commitdiff
[PATCH] swiotlb: support syncing sub-ranges of mappings
authorJohn W. Linville <linville@tuxdriver.com>
Thu, 29 Sep 2005 21:44:23 +0000 (14:44 -0700)
committerTony Luck <tony.luck@intel.com>
Thu, 29 Sep 2005 21:44:23 +0000 (14:44 -0700)
This patch implements swiotlb_sync_single_range_for_{cpu,device}. This
is intended to support an x86_64 implementation of
dma_sync_single_range_for_{cpu,device}.

Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
include/asm-x86_64/swiotlb.h
lib/swiotlb.c

index 36293061f4ed6b1416aac1604417d73fbd157765..9b011dd8d19d0fbbb2e7bd24b877f82b5e1039e1 100644 (file)
@@ -15,6 +15,14 @@ extern void swiotlb_sync_single_for_cpu(struct device *hwdev,
 extern void swiotlb_sync_single_for_device(struct device *hwdev,
                                            dma_addr_t dev_addr,
                                            size_t size, int dir);
+extern void swiotlb_sync_single_range_for_cpu(struct device *hwdev,
+                                             dma_addr_t dev_addr,
+                                             unsigned long offset,
+                                             size_t size, int dir);
+extern void swiotlb_sync_single_range_for_device(struct device *hwdev,
+                                                dma_addr_t dev_addr,
+                                                unsigned long offset,
+                                                size_t size, int dir);
 extern void swiotlb_sync_sg_for_cpu(struct device *hwdev,
                                     struct scatterlist *sg, int nelems,
                                     int dir);
index 9719a14649e7cc851ef442f88b096383f43ab320..566791b3f583112bbcd1cd8410047b6349fe7017 100644 (file)
@@ -622,6 +622,37 @@ swiotlb_sync_single_for_device(struct device *hwdev, dma_addr_t dev_addr,
        swiotlb_sync_single(hwdev, dev_addr, size, dir);
 }
 
+/*
+ * Same as above, but for a sub-range of the mapping.
+ */
+static inline void
+swiotlb_sync_single_range(struct device *hwdev, dma_addr_t dev_addr,
+                         unsigned long offset, size_t size, int dir)
+{
+       char *dma_addr = phys_to_virt(dev_addr) + offset;
+
+       if (dir == DMA_NONE)
+               BUG();
+       if (dma_addr >= io_tlb_start && dma_addr < io_tlb_end)
+               sync_single(hwdev, dma_addr, size, dir);
+       else if (dir == DMA_FROM_DEVICE)
+               mark_clean(dma_addr, size);
+}
+
+void
+swiotlb_sync_single_range_for_cpu(struct device *hwdev, dma_addr_t dev_addr,
+                                 unsigned long offset, size_t size, int dir)
+{
+       swiotlb_sync_single_range(hwdev, dev_addr, offset, size, dir);
+}
+
+void
+swiotlb_sync_single_range_for_device(struct device *hwdev, dma_addr_t dev_addr,
+                                    unsigned long offset, size_t size, int dir)
+{
+       swiotlb_sync_single_range(hwdev, dev_addr, offset, size, dir);
+}
+
 /*
  * Map a set of buffers described by scatterlist in streaming mode for DMA.
  * This is the scatter-gather version of the above swiotlb_map_single
@@ -750,6 +781,8 @@ EXPORT_SYMBOL(swiotlb_map_sg);
 EXPORT_SYMBOL(swiotlb_unmap_sg);
 EXPORT_SYMBOL(swiotlb_sync_single_for_cpu);
 EXPORT_SYMBOL(swiotlb_sync_single_for_device);
+EXPORT_SYMBOL_GPL(swiotlb_sync_single_range_for_cpu);
+EXPORT_SYMBOL_GPL(swiotlb_sync_single_range_for_device);
 EXPORT_SYMBOL(swiotlb_sync_sg_for_cpu);
 EXPORT_SYMBOL(swiotlb_sync_sg_for_device);
 EXPORT_SYMBOL(swiotlb_dma_mapping_error);