[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 9/9] xen/swiotlb: update to new new dma_ops



From: Jeremy Fitzhardinge <jeremy.fitzhardinge@xxxxxxxxxx>

Convert to use map_page/unmap_page rather than map_single, use enum
dma_data_direction.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@xxxxxxxxxx>
---
 drivers/pci/xen-iommu.c |   54 ++++++++++++++++++++---------------------------
 1 files changed, 23 insertions(+), 31 deletions(-)

diff --git a/drivers/pci/xen-iommu.c b/drivers/pci/xen-iommu.c
index 81338b2..41c276f 100644
--- a/drivers/pci/xen-iommu.c
+++ b/drivers/pci/xen-iommu.c
@@ -154,7 +154,9 @@ static inline dma_addr_t xen_dma_map_page(struct page *page)
 }
 
 static int xen_map_sg(struct device *hwdev, struct scatterlist *sg,
-                       int nents, int direction)
+                     int nents,
+                     enum dma_data_direction direction,
+                     struct dma_attrs *attrs)
 {
        struct scatterlist *s;
        struct page *page;
@@ -179,7 +181,9 @@ static int xen_map_sg(struct device *hwdev, struct 
scatterlist *sg,
 }
 
 static void xen_unmap_sg(struct device *hwdev, struct scatterlist *sg,
-                        int nents, int direction)
+                        int nents,
+                        enum dma_data_direction direction,
+                        struct dma_attrs *attrs)
 {
        struct scatterlist *s;
        struct page *page;
@@ -242,53 +246,41 @@ static void xen_free_coherent(struct device *dev, size_t 
size,
        free_pages((unsigned long)vaddr, order);
 }
 
-static dma_addr_t xen_swiotlb_map_single(struct device *dev, phys_addr_t paddr,
-                                        size_t size, int direction)
+static dma_addr_t xen_map_page(struct device *dev, struct page *page,
+                              unsigned long offset, size_t size,
+                              enum dma_data_direction direction,
+                              struct dma_attrs *attrs)
 {
        dma_addr_t dma;
-       BUG_ON(direction == DMA_NONE);
-
-       WARN_ON(size == 0);
-       dma = swiotlb_map_single(dev, phys_to_virt(paddr), size, direction);
-
-       flush_write_buffers();
-       return dma;
-}
-
-static dma_addr_t xen_map_single(struct device *dev, phys_addr_t paddr,
-                                       size_t size, int direction)
-{
-       struct page *page;
-       dma_addr_t dma;
 
        BUG_ON(direction == DMA_NONE);
 
        WARN_ON(size == 0);
-       page = pfn_to_page(PFN_DOWN(paddr));
 
-       dma = xen_dma_map_page(page) + offset_in_page(paddr);
+       dma = xen_dma_map_page(page) + offset;
 
        IOMMU_BUG_ON(address_needs_mapping(dev, dma));
-       IOMMU_BUG_ON(range_straddles_page_boundary(paddr, size));
        flush_write_buffers();
        return dma;
 }
 
-static void xen_unmap_single(struct device *dev, dma_addr_t dma_addr,
-                               size_t size, int direction)
+static void xen_unmap_page(struct device *dev, dma_addr_t dma_addr,
+                          size_t size,
+                          enum dma_data_direction direction,
+                          struct dma_attrs *attrs)
 {
        BUG_ON(direction == DMA_NONE);
        xen_dma_unmap_page(pfn_to_page(mfn_to_pfn(PFN_DOWN(dma_addr))));
 }
 
-static struct dma_mapping_ops xen_dma_ops = {
+static struct dma_map_ops xen_dma_ops = {
        .dma_supported = NULL,
 
        .alloc_coherent = xen_alloc_coherent,
        .free_coherent = xen_free_coherent,
 
-       .map_single = xen_map_single,
-       .unmap_single = xen_unmap_single,
+       .map_page = xen_map_page,
+       .unmap_page = xen_unmap_page,
 
        .map_sg = xen_map_sg,
        .unmap_sg = xen_unmap_sg,
@@ -298,17 +290,17 @@ static struct dma_mapping_ops xen_dma_ops = {
        .is_phys = 0,
 };
 
-static struct dma_mapping_ops xen_swiotlb_dma_ops = {
+static struct dma_map_ops xen_swiotlb_dma_ops = {
        .dma_supported = swiotlb_dma_supported,
 
        .alloc_coherent = xen_alloc_coherent,
        .free_coherent = xen_free_coherent,
 
-       .map_single = xen_swiotlb_map_single,   /* swiotlb_map_single has a 
different prototype */
-       .unmap_single = swiotlb_unmap_single,
+       .map_page = swiotlb_map_page,
+       .unmap_page = swiotlb_unmap_page,
 
-       .map_sg = swiotlb_map_sg,
-       .unmap_sg = swiotlb_unmap_sg,
+       .map_sg = swiotlb_map_sg_attrs,
+       .unmap_sg = swiotlb_unmap_sg_attrs,
 
        .mapping_error = swiotlb_dma_mapping_error,
 
-- 
1.6.0.6


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.