ia64/xen-unstable

changeset 177:bc7bbe93a3f2

bitkeeper revision 1.43 (3e4e61d8nVp2Sx8XMCpKhj4KfuEEVQ)

Partial fix to ensure that the IDE driver maps buffers into Xen
memoey before doing PIO cycles to them. The ATAPI case has not been
covered, and the mappings are short lived and conservative. Hopefully
this code path will not be used for bulk data transfer due to DMA.
author iap10@labyrinth.cl.cam.ac.uk
date Sat Feb 15 15:50:48 2003 +0000 (2003-02-15)
parents 36921c18576a
children 9c0353a9fa74
files xen-2.4.16/drivers/ide/ide-taskfile.c xen-2.4.16/drivers/ide/ide.c
line diff
     1.1 --- a/xen-2.4.16/drivers/ide/ide-taskfile.c	Sat Feb 15 14:40:07 2003 +0000
     1.2 +++ b/xen-2.4.16/drivers/ide/ide-taskfile.c	Sat Feb 15 15:50:48 2003 +0000
     1.3 @@ -27,6 +27,7 @@
     1.4  #include <xeno/hdreg.h>
     1.5  #include <xeno/ide.h>
     1.6  
     1.7 +#include <asm/domain_page.h>
     1.8  #include <asm/byteorder.h>
     1.9  #include <asm/irq.h>
    1.10  #include <asm/uaccess.h>
    1.11 @@ -82,10 +83,12 @@ static inline void task_vlb_sync (ide_io
    1.12  /*
    1.13   * This is used for most PIO data transfers *from* the IDE interface
    1.14   */
    1.15 -void ata_input_data (ide_drive_t *drive, void *buffer, unsigned int wcount)
    1.16 +void ata_input_data (ide_drive_t *drive, void *vbuffer, unsigned int wcount)
    1.17  {
    1.18  	byte io_32bit = drive->io_32bit;
    1.19  
    1.20 +        void *buffer = map_domain_mem(virt_to_phys(vbuffer));
    1.21 +
    1.22  	if (io_32bit) {
    1.23  #if SUPPORT_VLB_SYNC
    1.24  		if (io_32bit & 2) {
    1.25 @@ -110,15 +113,19 @@ void ata_input_data (ide_drive_t *drive,
    1.26  #endif /* SUPPORT_SLOW_DATA_PORTS */
    1.27  			insw(IDE_DATA_REG, buffer, wcount<<1);
    1.28  	}
    1.29 +
    1.30 +	unmap_domain_mem(buffer);
    1.31  }
    1.32  
    1.33  /*
    1.34   * This is used for most PIO data transfers *to* the IDE interface
    1.35   */
    1.36 -void ata_output_data (ide_drive_t *drive, void *buffer, unsigned int wcount)
    1.37 +void ata_output_data (ide_drive_t *drive, void *vbuffer, unsigned int wcount)
    1.38  {
    1.39  	byte io_32bit = drive->io_32bit;
    1.40  
    1.41 +        void *buffer = map_domain_mem(virt_to_phys(vbuffer));
    1.42 +
    1.43  	if (io_32bit) {
    1.44  #if SUPPORT_VLB_SYNC
    1.45  		if (io_32bit & 2) {
    1.46 @@ -143,6 +150,8 @@ void ata_output_data (ide_drive_t *drive
    1.47  #endif /* SUPPORT_SLOW_DATA_PORTS */
    1.48  			outsw(IDE_DATA_REG, buffer, wcount<<1);
    1.49  	}
    1.50 +
    1.51 +	unmap_domain_mem(buffer);
    1.52  }
    1.53  
    1.54  
     2.1 --- a/xen-2.4.16/drivers/ide/ide.c	Sat Feb 15 14:40:07 2003 +0000
     2.2 +++ b/xen-2.4.16/drivers/ide/ide.c	Sat Feb 15 15:50:48 2003 +0000
     2.3 @@ -149,6 +149,7 @@
     2.4  /*#include <xeno/completion.h>*/
     2.5  /*#include <xeno/reboot.h>*/
     2.6  
     2.7 +#include <asm/domain_page.h>
     2.8  #include <asm/byteorder.h>
     2.9  #include <asm/irq.h>
    2.10  #include <asm/uaccess.h>
    2.11 @@ -413,8 +414,9 @@ static inline void do_vlb_sync (ide_iore
    2.12  /*
    2.13   * This is used for most PIO data transfers *from* the IDE interface
    2.14   */
    2.15 -void ide_input_data (ide_drive_t *drive, void *buffer, unsigned int wcount)
    2.16 +void ide_input_data (ide_drive_t *drive, void *vbuffer, unsigned int wcount)
    2.17  {
    2.18 +        void *buffer;
    2.19  	byte io_32bit;
    2.20  
    2.21  	/* first check if this controller has defined a special function
    2.22 @@ -423,10 +425,17 @@ void ide_input_data (ide_drive_t *drive,
    2.23  
    2.24  	if(HWIF(drive)->ideproc) {
    2.25  		HWIF(drive)->ideproc(ideproc_ide_input_data,
    2.26 -				     drive, buffer, wcount);
    2.27 +				     drive, vbuffer, wcount);
    2.28  		return;
    2.29  	}
    2.30  
    2.31 +	/* We assume controllers own functions will make their own
    2.32 +         * arrangemnets for mapping/unmaping the destination mem if 
    2.33 +	 * required (or not if DMA) 
    2.34 +	 */
    2.35 +
    2.36 +	buffer = map_domain_mem(virt_to_phys(vbuffer));
    2.37 +
    2.38  	io_32bit = drive->io_32bit;
    2.39  
    2.40  	if (io_32bit) {
    2.41 @@ -453,21 +462,26 @@ void ide_input_data (ide_drive_t *drive,
    2.42  #endif /* SUPPORT_SLOW_DATA_PORTS */
    2.43  			insw(IDE_DATA_REG, buffer, wcount<<1);
    2.44  	}
    2.45 +
    2.46 +	 unmap_domain_mem(buffer);
    2.47  }
    2.48  
    2.49  /*
    2.50   * This is used for most PIO data transfers *to* the IDE interface
    2.51   */
    2.52 -void ide_output_data (ide_drive_t *drive, void *buffer, unsigned int wcount)
    2.53 +void ide_output_data (ide_drive_t *drive, void *vbuffer, unsigned int wcount)
    2.54  {
    2.55 +        void *buffer;
    2.56  	byte io_32bit;
    2.57  
    2.58  	if(HWIF(drive)->ideproc) {
    2.59  		HWIF(drive)->ideproc(ideproc_ide_output_data,
    2.60 -				     drive, buffer, wcount);
    2.61 +				     drive, vbuffer, wcount);
    2.62  		return;
    2.63  	}
    2.64  
    2.65 +	buffer = map_domain_mem(virt_to_phys(vbuffer));
    2.66 +
    2.67  	io_32bit = drive->io_32bit;
    2.68  
    2.69  	if (io_32bit) {
    2.70 @@ -494,6 +508,8 @@ void ide_output_data (ide_drive_t *drive
    2.71  #endif /* SUPPORT_SLOW_DATA_PORTS */
    2.72  			outsw(IDE_DATA_REG, buffer, wcount<<1);
    2.73  	}
    2.74 +
    2.75 +	unmap_domain_mem(buffer);
    2.76  }
    2.77  
    2.78  /*
    2.79 @@ -510,7 +526,7 @@ void atapi_input_bytes (ide_drive_t *dri
    2.80  				     drive, buffer, bytecount);
    2.81  		return;
    2.82  	}
    2.83 -
    2.84 +printk("XXXXX atapi_input_bytes called -- mapping is likely broken\n");
    2.85  	++bytecount;
    2.86  #if defined(CONFIG_ATARI) || defined(CONFIG_Q40)
    2.87  	if (MACH_IS_ATARI || MACH_IS_Q40) {
    2.88 @@ -532,6 +548,8 @@ void atapi_output_bytes (ide_drive_t *dr
    2.89  		return;
    2.90  	}
    2.91  
    2.92 +printk("XXXXX atapi_output_bytes called -- mapping is likely broken\n");
    2.93 +
    2.94  	++bytecount;
    2.95  #if defined(CONFIG_ATARI) || defined(CONFIG_Q40)
    2.96  	if (MACH_IS_ATARI || MACH_IS_Q40) {