ia64/xen-unstable

changeset 14163:a9d246105752

Accelerate IDE PIO on HVM/IA64 [3/3]

Add a bufferring mechanism for IDE PIO in a hypervisor.

Signed-off-by: Kouya Shimura <kouya@jp.fujitsu.com>
author kfraser@localhost.localdomain
date Tue Feb 27 15:34:55 2007 +0000 (2007-02-27)
parents e450a3b90aba
children e506c3fd03c9
files xen/arch/ia64/vmx/mmio.c xen/arch/ia64/vmx/vmx_init.c xen/include/asm-ia64/vmx_platform.h xen/include/public/arch-ia64.h
line diff
     1.1 --- a/xen/arch/ia64/vmx/mmio.c	Tue Feb 27 15:34:24 2007 +0000
     1.2 +++ b/xen/arch/ia64/vmx/mmio.c	Tue Feb 27 15:34:55 2007 +0000
     1.3 @@ -136,6 +136,56 @@ static void low_mmio_access(VCPU *vcpu, 
     1.4      }
     1.5      return;
     1.6  }
     1.7 +
     1.8 +int vmx_ide_pio_intercept(ioreq_t *p, u64 *val)
     1.9 +{
    1.10 +    struct buffered_piopage *pio_page =
    1.11 +        (void *)(current->domain->arch.hvm_domain.buffered_pio_va);
    1.12 +    struct pio_buffer *piobuf;
    1.13 +    uint32_t pointer, page_offset;
    1.14 +
    1.15 +    if (p->addr == 0x1F0)
    1.16 +	piobuf = &pio_page->pio[PIO_BUFFER_IDE_PRIMARY];
    1.17 +    else if (p->addr == 0x170)
    1.18 +	piobuf = &pio_page->pio[PIO_BUFFER_IDE_SECONDARY];
    1.19 +    else
    1.20 +	return 0;
    1.21 +
    1.22 +    if (p->size != 2 && p->size != 4)
    1.23 +        return 0;
    1.24 +
    1.25 +    pointer = piobuf->pointer;
    1.26 +    page_offset = piobuf->page_offset;
    1.27 +
    1.28 +    /* sanity check */
    1.29 +    if (page_offset + pointer < offsetof(struct buffered_piopage, buffer))
    1.30 +	return 0;
    1.31 +    if (page_offset + piobuf->data_end > PAGE_SIZE)
    1.32 +	return 0;
    1.33 +
    1.34 +    if (pointer + p->size < piobuf->data_end) {
    1.35 +        uint8_t *bufp = (uint8_t *)pio_page + page_offset + pointer;
    1.36 +        if (p->dir == IOREQ_WRITE) {
    1.37 +            if (likely(p->size == 4 && (((long)bufp & 3) == 0)))
    1.38 +                *(uint32_t *)bufp = *val;
    1.39 +            else
    1.40 +                memcpy(bufp, val, p->size);
    1.41 +        } else {
    1.42 +            if (likely(p->size == 4 && (((long)bufp & 3) == 0))) {
    1.43 +                *val = *(uint32_t *)bufp;
    1.44 +            } else {
    1.45 +                *val = 0;
    1.46 +                memcpy(val, bufp, p->size);
    1.47 +            }
    1.48 +        }
    1.49 +        piobuf->pointer += p->size;
    1.50 +        p->state = STATE_IORESP_READY;
    1.51 +        vmx_io_assist(current);
    1.52 +        return 1;
    1.53 +    }
    1.54 +    return 0;
    1.55 +}
    1.56 +
    1.57  #define TO_LEGACY_IO(pa)  (((pa)>>12<<2)|((pa)&0x3))
    1.58  
    1.59  static void legacy_io_access(VCPU *vcpu, u64 pa, u64 *val, size_t s, int dir)
    1.60 @@ -161,6 +211,9 @@ static void legacy_io_access(VCPU *vcpu,
    1.61  
    1.62      p->io_count++;
    1.63  
    1.64 +    if (vmx_ide_pio_intercept(p, val))
    1.65 +        return;
    1.66 +
    1.67      vmx_send_assist_req(v);
    1.68      if(dir==IOREQ_READ){ //read
    1.69          *val=p->data;
     2.1 --- a/xen/arch/ia64/vmx/vmx_init.c	Tue Feb 27 15:34:24 2007 +0000
     2.2 +++ b/xen/arch/ia64/vmx/vmx_init.c	Tue Feb 27 15:34:55 2007 +0000
     2.3 @@ -390,6 +390,8 @@ void vmx_setup_platform(struct domain *d
     2.4  	spin_lock_init(&d->arch.hvm_domain.buffered_io_lock);
     2.5  	d->arch.hvm_domain.buffered_io_va =
     2.6  		(unsigned long)__va(__gpa_to_mpa(d, BUFFER_IO_PAGE_START));
     2.7 +	d->arch.hvm_domain.buffered_pio_va =
     2.8 +		(unsigned long)__va(__gpa_to_mpa(d, BUFFER_PIO_PAGE_START));
     2.9  	/* TEMP */
    2.10  	d->arch.vmx_platform.pib_base = 0xfee00000UL;
    2.11  
     3.1 --- a/xen/include/asm-ia64/vmx_platform.h	Tue Feb 27 15:34:24 2007 +0000
     3.2 +++ b/xen/include/asm-ia64/vmx_platform.h	Tue Feb 27 15:34:55 2007 +0000
     3.3 @@ -24,8 +24,9 @@
     3.4  #include <asm/viosapic.h>
     3.5  struct mmio_list;
     3.6  typedef struct virtual_platform_def {
     3.7 -    unsigned long          buffered_io_va;
     3.8 -    spinlock_t             buffered_io_lock;
     3.9 +    unsigned long       buffered_io_va;
    3.10 +    spinlock_t          buffered_io_lock;
    3.11 +    unsigned long       buffered_pio_va;
    3.12      unsigned long       shared_page_va;
    3.13      unsigned long       pib_base;
    3.14      unsigned long       params[HVM_NR_PARAMS];
     4.1 --- a/xen/include/public/arch-ia64.h	Tue Feb 27 15:34:24 2007 +0000
     4.2 +++ b/xen/include/public/arch-ia64.h	Tue Feb 27 15:34:55 2007 +0000
     4.3 @@ -91,11 +91,14 @@ typedef unsigned long xen_ulong_t;
     4.4  #define IO_PAGE_SIZE  PAGE_SIZE
     4.5  
     4.6  #define STORE_PAGE_START (IO_PAGE_START + IO_PAGE_SIZE)
     4.7 -#define STORE_PAGE_SIZE	 PAGE_SIZE
     4.8 +#define STORE_PAGE_SIZE  PAGE_SIZE
     4.9  
    4.10 -#define BUFFER_IO_PAGE_START (STORE_PAGE_START+PAGE_SIZE)
    4.11 +#define BUFFER_IO_PAGE_START (STORE_PAGE_START+STORE_PAGE_SIZE)
    4.12  #define BUFFER_IO_PAGE_SIZE PAGE_SIZE
    4.13  
    4.14 +#define BUFFER_PIO_PAGE_START (BUFFER_IO_PAGE_START+BUFFER_IO_PAGE_SIZE)
    4.15 +#define BUFFER_PIO_PAGE_SIZE PAGE_SIZE
    4.16 +
    4.17  #define IO_SAPIC_START   0xfec00000UL
    4.18  #define IO_SAPIC_SIZE    0x100000
    4.19