FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu Kernel Team

 
 
LinkBack Thread Tools
 
Old 11-14-2008, 02:32 PM
Stefan Bader
 
Default UBUNTU: Xen: dma: avoid unnecessarily SWIOTLB bounce buffering

OriginalLocation: http://lists.xensource.com/archives/html/xen-changelog/2008-04/msg00008.html
Bug: #247148

Backported an upstream Xen patch which was tested to fix Dom0 software
RAID corruption issue.

On Xen kernels, BIOVEC_PHYS_MERGEABLE permits merging of disk IOs that
span multiple pages, provided that the pages are both
pseudophysically- AND machine-contiguous ---

(((bvec_to_phys((vec1)) + (vec1)->bv_len) ==
bvec_to_phys((vec2))) &&
((bvec_to_pseudophys((vec1)) + (vec1)->bv_len) ==
bvec_to_pseudophys((vec2))))

However, this best-effort merging of adjacent pages can occur in
regions of dom0 memory which just happen, by virtue of having been
initially set up that way, to be machine-contiguous. Such pages
which occur outside of a range created by xen_create_contiguous_
region won't be seen as contiguous by range_straddles_page_boundary(),
so the pci-dma-xen.c code for dma_map_sg() will send these regions
to the swiotlb for bounce buffering.

This patch adds a new check, check_pages_physically_contiguous(),
to the test for pages stradding page boundaries both in
swiotlb_map_sg() and dma_map_sg(), to capture these ranges and map
them directly via virt_to_bus() mapping rather than through the
swiotlb.

Signed-off-by: Stephen Tweedie <sct@xxxxxxxxxx>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
---
.../007-xen-dma-avoid-swiotlb-buffering.patch | 61 ++++++++++++++++++++
1 files changed, 61 insertions(+), 0 deletions(-)
create mode 100644 debian/binary-custom.d/xen/patchset/007-xen-dma-avoid-swiotlb-buffering.patch

diff --git a/debian/binary-custom.d/xen/patchset/007-xen-dma-avoid-swiotlb-buffering.patch b/debian/binary-custom.d/xen/patchset/007-xen-dma-avoid-swiotlb-buffering.patch
new file mode 100644
index 0000000..9156fbc
--- /dev/null
+++ b/debian/binary-custom.d/xen/patchset/007-xen-dma-avoid-swiotlb-buffering.patch
@@ -0,0 +1,61 @@
+diff -Nurp custom-source-xen/arch/x86/kernel/pci-dma_32-xen.c custom-source-xen.new/arch/x86/kernel/pci-dma_32-xen.c
+--- custom-source-xen/arch/x86/kernel/pci-dma_32-xen.c 2008-11-14 14:29:02.000000000 +0000
++++ custom-source-xen.new/arch/x86/kernel/pci-dma_32-xen.c 2008-11-14 14:23:09.000000000 +0000
+@@ -77,6 +77,39 @@ do {
+ }
+ } while (0)
+
++static int check_pages_physically_contiguous(unsigned long pfn,
++ unsigned int offset,
++ size_t length)
++{
++ unsigned long next_mfn;
++ int i;
++ int nr_pages;
++
++ next_mfn = pfn_to_mfn(pfn);
++ nr_pages = (offset + length + PAGE_SIZE-1) >> PAGE_SHIFT;
++
++ for (i = 1; i < nr_pages; i++) {
++ if (pfn_to_mfn(++pfn) != ++next_mfn)
++ return 0;
++ }
++ return 1;
++}
++
++int range_straddles_page_boundary(paddr_t p, size_t size)
++{
++ extern unsigned long *contiguous_bitmap;
++ unsigned long pfn = p >> PAGE_SHIFT;
++ unsigned int offset = p & ~PAGE_MASK;
++
++ if (offset + size <= PAGE_SIZE)
++ return 0;
++ if (test_bit(pfn, contiguous_bitmap))
++ return 0;
++ if (check_pages_physically_contiguous(pfn, offset, size))
++ return 0;
++ return 1;
++}
++
+ int
+ dma_map_sg(struct device *hwdev, struct scatterlist *sgl, int nents,
+ enum dma_data_direction direction)
+diff -Nurp custom-source-xen/include/asm-x86/mach-xen/asm/dma-mapping_32.h custom-source-xen.new/include/asm-x86/mach-xen/asm/dma-mapping_32.h
+--- custom-source-xen/include/asm-x86/mach-xen/asm/dma-mapping_32.h 2008-11-14 14:29:02.000000000 +0000
++++ custom-source-xen.new/include/asm-x86/mach-xen/asm/dma-mapping_32.h 2008-11-14 14:25:33.000000000 +0000
+@@ -22,13 +22,7 @@ address_needs_mapping(struct device *hwd
+ return (addr & ~mask) != 0;
+ }
+
+-static inline int
+-range_straddles_page_boundary(paddr_t p, size_t size)
+-{
+- extern unsigned long *contiguous_bitmap;
+- return ((((p & ~PAGE_MASK) + size) > PAGE_SIZE) &&
+- !test_bit(p >> PAGE_SHIFT, contiguous_bitmap));
+-}
++extern int range_straddles_page_boundary(paddr_t p, size_t size);
+
+ #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
+ #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
--
1.5.4.3


--------------050909060709070709090406
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

--
kernel-team mailing list
kernel-team@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/kernel-team

--------------050909060709070709090406--
 

Thread Tools




All times are GMT. The time now is 02:38 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org