ia64/xen-unstable

changeset 8217:fad187cad5bd

Always initialise a swiotlb for domain0. Make it a small
aperture (2MB) for small systems (< 2GB).

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Sat Dec 03 19:09:19 2005 +0100 (2005-12-03)
parents fd7c4221fc56
children 00c349d5b40d
files linux-2.6-xen-sparse/arch/xen/i386/kernel/swiotlb.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/swiotlb.c	Sat Dec 03 17:59:37 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/swiotlb.c	Sat Dec 03 19:09:19 2005 +0100
     1.3 @@ -43,7 +43,7 @@
     1.4   */
     1.5  #define IO_TLB_SHIFT 11
     1.6  
     1.7 -int swiotlb_force;
     1.8 +static int swiotlb_force;
     1.9  static char *iotlb_virt_start;
    1.10  static unsigned long iotlb_nslabs;
    1.11  
    1.12 @@ -101,10 +101,13 @@ setup_io_tlb_npages(char *str)
    1.13  		++str;
    1.14  	/*
    1.15           * NB. 'force' enables the swiotlb, but doesn't force its use for
    1.16 -         * every DMA like it does on native Linux.
    1.17 +         * every DMA like it does on native Linux. 'off' forcibly disables
    1.18 +         * use of the swiotlb.
    1.19           */
    1.20  	if (!strcmp(str, "force"))
    1.21  		swiotlb_force = 1;
    1.22 +	else if (!strcmp(str, "off"))
    1.23 +		swiotlb_force = -1;
    1.24  	return 1;
    1.25  }
    1.26  __setup("swiotlb=", setup_io_tlb_npages);
    1.27 @@ -179,23 +182,21 @@ void
    1.28  swiotlb_init(void)
    1.29  {
    1.30  	long ram_end;
    1.31 -
    1.32 -	/* The user can forcibly enable swiotlb. */
    1.33 -	if (swiotlb_force)
    1.34 -		swiotlb = 1;
    1.35 +	size_t defsz = 64 * (1 << 20); /* 64MB default size */
    1.36  
    1.37 -	/*
    1.38 -         * Otherwise, enable for domain 0 if the machine has 'lots of memory',
    1.39 -         * which we take to mean more than 2GB.
    1.40 -         */
    1.41 -	if (xen_start_info->flags & SIF_INITDOMAIN) {
    1.42 +	if (swiotlb_force == 1) {
    1.43 +		swiotlb = 1;
    1.44 +	} else if ((swiotlb_force != -1) &&
    1.45 +		   (xen_start_info->flags & SIF_INITDOMAIN)) {
    1.46 +		/* Domain 0 always has a swiotlb. */
    1.47  		ram_end = HYPERVISOR_memory_op(XENMEM_maximum_ram_page, NULL);
    1.48 -		if (ram_end > 0x7ffff)
    1.49 -			swiotlb = 1;
    1.50 +		if (ram_end <= 0x7ffff)
    1.51 +			defsz = 2 * (1 << 20); /* 2MB on <2GB on systems. */
    1.52 +		swiotlb = 1;
    1.53  	}
    1.54  
    1.55  	if (swiotlb)
    1.56 -		swiotlb_init_with_default_size(64 * (1<<20));
    1.57 +		swiotlb_init_with_default_size(defsz);
    1.58  	else
    1.59  		printk(KERN_INFO "Software IO TLB disabled\n");
    1.60  }