direct-io.hg

changeset 6285:1872e09bfba3

merge?
author cl349@firebug.cl.cam.ac.uk
date Fri Aug 19 17:54:56 2005 +0000 (2005-08-19)
parents 631cc5dc3e8a d0f23c103453
children 5e8123554d15 f7dfaa2af90c
files linux-2.6-xen-sparse/arch/xen/i386/kernel/Makefile linux-2.6-xen-sparse/arch/xen/i386/kernel/head.S linux-2.6-xen-sparse/arch/xen/i386/kernel/init_task.c linux-2.6-xen-sparse/arch/xen/i386/kernel/ioport.c linux-2.6-xen-sparse/arch/xen/i386/kernel/process.c linux-2.6-xen-sparse/arch/xen/i386/kernel/swiotlb.c linux-2.6-xen-sparse/arch/xen/i386/mm/init.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/process.c linux-2.6-xen-sparse/drivers/xen/blkback/common.h linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c linux-2.6-xen-sparse/drivers/xen/blktap/blktap.h linux-2.6-xen-sparse/drivers/xen/netback/common.h linux-2.6-xen-sparse/drivers/xen/netback/netback.c linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h linux-2.6-xen-sparse/include/asm-xen/xenbus.h tools/debugger/libxendebug/xendebug.c tools/debugger/libxendebug/xendebug.h tools/debugger/pdb/linux-2.6-module/debug.c tools/debugger/pdb/linux-2.6-module/module.c tools/debugger/pdb/linux-2.6-module/pdb_debug.h tools/debugger/pdb/pdb_caml_domain.c tools/debugger/pdb/pdb_caml_process.c tools/debugger/pdb/pdb_caml_xcs.c tools/libxc/xc.h tools/libxc/xc_gnttab.c tools/python/xen/lowlevel/xu/xu.c tools/xentrace/xentrace.c xen/arch/x86/physdev.c xen/common/trace.c xen/include/public/arch-ia64.h xen/include/public/arch-x86_32.h xen/include/public/arch-x86_64.h xen/include/public/dom0_ops.h xen/include/public/grant_table.h xen/include/public/io/domain_controller.h xen/include/public/io/netif.h xen/include/public/physdev.h xen/include/public/xen.h
line diff
     6.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/swiotlb.c	Fri Aug 19 17:38:31 2005 +0000
     6.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/swiotlb.c	Fri Aug 19 17:54:56 2005 +0000
     6.3 @@ -43,20 +43,18 @@
     6.4  #define IO_TLB_SHIFT 11
     6.5  
     6.6  int swiotlb_force;
     6.7 +static char *iotlb_virt_start;
     6.8 +static unsigned long iotlb_nslabs;
     6.9  
    6.10  /*
    6.11   * Used to do a quick range check in swiotlb_unmap_single and
    6.12   * swiotlb_sync_single_*, to see if the memory was in fact allocated by this
    6.13   * API.
    6.14   */
    6.15 -static char *iotlb_virt_start, *iotlb_virt_end;
    6.16 -static dma_addr_t iotlb_bus_start, iotlb_bus_end;
    6.17 +static dma_addr_t iotlb_bus_start, iotlb_bus_mask;
    6.18  
    6.19 -/*
    6.20 - * The number of IO TLB blocks (in groups of 64) betweeen iotlb_virt_start and
    6.21 - * iotlb_virt_end.  This is command line adjustable via setup_io_tlb_npages.
    6.22 - */
    6.23 -static unsigned long iotlb_nslabs;
    6.24 +/* Does the given dma address reside within the swiotlb aperture? */
    6.25 +#define in_swiotlb_aperture(a) (!(((a) ^ iotlb_bus_start) & iotlb_bus_mask))
    6.26  
    6.27  /*
    6.28   * When the IOMMU overflows we return a fallback buffer. This sets the size.
    6.29 @@ -94,6 +92,9 @@ setup_io_tlb_npages(char *str)
    6.30  		iotlb_nslabs = simple_strtoul(str, &str, 0) <<
    6.31  			(20 - IO_TLB_SHIFT);
    6.32  		iotlb_nslabs = ALIGN(iotlb_nslabs, IO_TLB_SEGSIZE);
    6.33 +		/* Round up to power of two (xen_create_contiguous_region). */
    6.34 +		while (iotlb_nslabs & (iotlb_nslabs-1))
    6.35 +			iotlb_nslabs += iotlb_nslabs & ~(iotlb_nslabs-1);
    6.36  	}
    6.37  	if (*str == ',')
    6.38  		++str;
    6.39 @@ -120,6 +121,9 @@ swiotlb_init_with_default_size (size_t d
    6.40  	if (!iotlb_nslabs) {
    6.41  		iotlb_nslabs = (default_size >> IO_TLB_SHIFT);
    6.42  		iotlb_nslabs = ALIGN(iotlb_nslabs, IO_TLB_SEGSIZE);
    6.43 +		/* Round up to power of two (xen_create_contiguous_region). */
    6.44 +		while (iotlb_nslabs & (iotlb_nslabs-1))
    6.45 +			iotlb_nslabs += iotlb_nslabs & ~(iotlb_nslabs-1);
    6.46  	}
    6.47  
    6.48  	bytes = iotlb_nslabs * (1UL << IO_TLB_SHIFT);
    6.49 @@ -133,17 +137,12 @@ swiotlb_init_with_default_size (size_t d
    6.50  		      "Use dom0_mem Xen boot parameter to reserve\n"
    6.51  		      "some DMA memory (e.g., dom0_mem=-128M).\n");
    6.52  
    6.53 -	for (i = 0; i < iotlb_nslabs; i += IO_TLB_SEGSIZE)
    6.54 -		xen_create_contiguous_region(
    6.55 -			(unsigned long)iotlb_virt_start + (i << IO_TLB_SHIFT),
    6.56 -			get_order(IO_TLB_SEGSIZE << IO_TLB_SHIFT));
    6.57 -
    6.58 -	iotlb_virt_end = iotlb_virt_start + bytes;
    6.59 +	xen_create_contiguous_region(
    6.60 +		(unsigned long)iotlb_virt_start, get_order(bytes));
    6.61  
    6.62  	/*
    6.63  	 * Allocate and initialize the free list array.  This array is used
    6.64 -	 * to find contiguous free memory regions of size up to IO_TLB_SEGSIZE
    6.65 -	 * between iotlb_virt_start and iotlb_virt_end.
    6.66 +	 * to find contiguous free memory regions of size up to IO_TLB_SEGSIZE.
    6.67  	 */
    6.68  	io_tlb_list = alloc_bootmem(iotlb_nslabs * sizeof(int));
    6.69  	for (i = 0; i < iotlb_nslabs; i++)
    6.70 @@ -156,15 +155,19 @@ swiotlb_init_with_default_size (size_t d
    6.71  	 * Get the overflow emergency buffer
    6.72  	 */
    6.73  	io_tlb_overflow_buffer = alloc_bootmem_low(io_tlb_overflow);
    6.74 +
    6.75  	iotlb_bus_start = virt_to_bus(iotlb_virt_start);
    6.76 -	iotlb_bus_end   = iotlb_bus_start + bytes;
    6.77 +	iotlb_bus_mask  = ~(dma_addr_t)(bytes - 1);
    6.78 +
    6.79  	printk(KERN_INFO "Software IO TLB enabled: \n"
    6.80  	       " Aperture:     %lu megabytes\n"
    6.81  	       " Bus range:    0x%016lx - 0x%016lx\n"
    6.82  	       " Kernel range: 0x%016lx - 0x%016lx\n",
    6.83  	       bytes >> 20,
    6.84 -	       (unsigned long)iotlb_bus_start, (unsigned long)iotlb_bus_end,
    6.85 -	       (unsigned long)iotlb_virt_start, (unsigned long)iotlb_virt_end);
    6.86 +	       (unsigned long)iotlb_bus_start,
    6.87 +	       (unsigned long)iotlb_bus_start + bytes,
    6.88 +	       (unsigned long)iotlb_virt_start,
    6.89 +	       (unsigned long)iotlb_virt_start + bytes);
    6.90  }
    6.91  
    6.92  void
    6.93 @@ -444,7 +447,7 @@ swiotlb_unmap_single(struct device *hwde
    6.94  		     int dir)
    6.95  {
    6.96  	BUG_ON(dir == DMA_NONE);
    6.97 -	if ((dev_addr >= iotlb_bus_start) && (dev_addr < iotlb_bus_end))
    6.98 +	if (in_swiotlb_aperture(dev_addr))
    6.99  		unmap_single(hwdev, bus_to_virt(dev_addr), size, dir);
   6.100  }
   6.101  
   6.102 @@ -463,7 +466,7 @@ swiotlb_sync_single_for_cpu(struct devic
   6.103  			    size_t size, int dir)
   6.104  {
   6.105  	BUG_ON(dir == DMA_NONE);
   6.106 -	if ((dev_addr >= iotlb_bus_start) && (dev_addr < iotlb_bus_end))
   6.107 +	if (in_swiotlb_aperture(dev_addr))
   6.108  		sync_single(hwdev, bus_to_virt(dev_addr), size, dir);
   6.109  }
   6.110  
   6.111 @@ -472,7 +475,7 @@ swiotlb_sync_single_for_device(struct de
   6.112  			       size_t size, int dir)
   6.113  {
   6.114  	BUG_ON(dir == DMA_NONE);
   6.115 -	if ((dev_addr >= iotlb_bus_start) && (dev_addr < iotlb_bus_end))
   6.116 +	if (in_swiotlb_aperture(dev_addr))
   6.117  		sync_single(hwdev, bus_to_virt(dev_addr), size, dir);
   6.118  }
   6.119  
   6.120 @@ -610,7 +613,7 @@ swiotlb_unmap_page(struct device *hwdev,
   6.121  		   size_t size, enum dma_data_direction direction)
   6.122  {
   6.123  	BUG_ON(direction == DMA_NONE);
   6.124 -	if ((dma_address >= iotlb_bus_start) && (dma_address < iotlb_bus_end))
   6.125 +	if (in_swiotlb_aperture(dma_address))
   6.126  		unmap_single(hwdev, bus_to_virt(dma_address), size, direction);
   6.127  }
   6.128