WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

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

To: Ingo Molnar <mingo@xxxxxxx>
Subject: [Xen-devel] [PATCH 9/9] xen/swiotlb: update to new new dma_ops
From: Jeremy Fitzhardinge <jeremy@xxxxxxxx>
Date: Thu, 7 May 2009 17:17:22 -0700
Cc: FUJITA Tomonori <fujita.tomonori@xxxxxxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>, the arch/x86 maintainers <x86@xxxxxxxxxx>, Linux Kernel Mailing List <linux-kernel@xxxxxxxxxxxxxxx>, Jeremy Fitzhardinge <jeremy.fitzhardinge@xxxxxxxxxx>
Delivery-date: Thu, 07 May 2009 17:22:42 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1241741842-7966-1-git-send-email-jeremy@xxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <1241741842-7966-1-git-send-email-jeremy@xxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
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

<Prev in Thread] Current Thread [Next in Thread>