ia64/linux-2.6.18-xen.hg

changeset 507:ec6e3e18ea31

[IA64] avoid unnecessarily SWIOTLB bounce buffering

x86 improved range_straddles_page_boundary() by the c/s 501:5486a234923d.
The same discussion applies to ia64. This patch is ia64 counter part of it.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Alex Williamson <alex.williamson@hp.com>
date Wed Apr 02 10:02:57 2008 -0600 (2008-04-02)
parents ad7ad9af265e
children dbe8a35dcaf7
files arch/ia64/xen/xen_dma.c include/asm-ia64/maddr.h
line diff
     1.1 --- a/arch/ia64/xen/xen_dma.c	Tue Apr 01 11:29:31 2008 -0600
     1.2 +++ b/arch/ia64/xen/xen_dma.c	Wed Apr 02 10:02:57 2008 -0600
     1.3 @@ -37,6 +37,41 @@ do {								\
     1.4  	}							\
     1.5  } while (0)
     1.6  
     1.7 +static int check_pages_physically_contiguous(unsigned long pfn, 
     1.8 +					     unsigned int offset,
     1.9 +					     size_t length)
    1.10 +{
    1.11 +	unsigned long next_bus;
    1.12 +	int i;
    1.13 +	int nr_pages;
    1.14 +
    1.15 +	next_bus = pfn_to_mfn_for_dma(pfn);
    1.16 +	nr_pages = (offset + length + PAGE_SIZE-1) >> PAGE_SHIFT;
    1.17 +
    1.18 +	for (i = 1; i < nr_pages; i++) {
    1.19 +		if (pfn_to_mfn_for_dma(++pfn) != ++next_bus) 
    1.20 +			return 0;
    1.21 +	}
    1.22 +	return 1;
    1.23 +}
    1.24 +
    1.25 +int range_straddles_page_boundary(paddr_t p, size_t size)
    1.26 +{
    1.27 +	extern unsigned long *contiguous_bitmap;
    1.28 +	unsigned long pfn = p >> PAGE_SHIFT;
    1.29 +	unsigned int offset = p & ~PAGE_MASK;
    1.30 +
    1.31 +	if (!is_running_on_xen())
    1.32 +		return 0;
    1.33 +
    1.34 +	if (offset + size <= PAGE_SIZE)
    1.35 +		return 0;
    1.36 +	if (test_bit(pfn, contiguous_bitmap))
    1.37 +		return 0;
    1.38 +	if (check_pages_physically_contiguous(pfn, offset, size))
    1.39 +		return 0;
    1.40 +	return 1;
    1.41 +}
    1.42  
    1.43  /*
    1.44   * This should be broken out of swiotlb and put in a common place
     2.1 --- a/include/asm-ia64/maddr.h	Tue Apr 01 11:29:31 2008 -0600
     2.2 +++ b/include/asm-ia64/maddr.h	Wed Apr 02 10:02:57 2008 -0600
     2.3 @@ -108,17 +108,7 @@ typedef unsigned long paddr_t;
     2.4  #endif
     2.5  
     2.6  #ifdef CONFIG_XEN
     2.7 -static inline int
     2.8 -range_straddles_page_boundary(paddr_t p, size_t size)
     2.9 -{
    2.10 -	extern unsigned long *contiguous_bitmap;
    2.11 -
    2.12 -	if (!is_running_on_xen())
    2.13 -		return 0;
    2.14 -
    2.15 -	return ((((p & ~PAGE_MASK) + size) > PAGE_SIZE) &&
    2.16 -	        !test_bit(p >> PAGE_SHIFT, contiguous_bitmap));
    2.17 -}
    2.18 +int range_straddles_page_boundary(paddr_t p, size_t size);
    2.19  #else
    2.20  #define range_straddles_page_boundary(addr, size)	(0)
    2.21  #endif