ia64/xen-unstable

changeset 200:c6670740ac0e

bitkeeper revision 1.61 (3e50c5d20NbtNJw3leevOGVVYDlrDA)

blkdev.h, ide-dma.c:
Upgrade ide-dma.c to Linux 2.4.20 level.
author kaf24@labyrinth.cl.cam.ac.uk
date Mon Feb 17 11:21:54 2003 +0000 (2003-02-17)
parents fa8759fd4b27
children 7e1893c8ae92
files xen-2.4.16/drivers/ide/ide-dma.c xen-2.4.16/include/xeno/blkdev.h
line diff
     1.1 --- a/xen-2.4.16/drivers/ide/ide-dma.c	Sun Feb 16 21:01:20 2003 +0000
     1.2 +++ b/xen-2.4.16/drivers/ide/ide-dma.c	Mon Feb 17 11:21:54 2003 +0000
     1.3 @@ -253,33 +253,53 @@ static int ide_build_sglist (ide_hwif_t 
     1.4  {
     1.5  	struct buffer_head *bh;
     1.6  	struct scatterlist *sg = hwif->sg_table;
     1.7 +	unsigned long lastdataend = ~0UL;
     1.8  	int nents = 0;
     1.9  
    1.10  	if (hwif->sg_dma_active)
    1.11  		BUG();
    1.12 -		
    1.13 +
    1.14  	if (rq->cmd == READ)
    1.15  		hwif->sg_dma_direction = PCI_DMA_FROMDEVICE;
    1.16  	else
    1.17  		hwif->sg_dma_direction = PCI_DMA_TODEVICE;
    1.18 +
    1.19  	bh = rq->bh;
    1.20  	do {
    1.21 -		unsigned char *virt_addr = bh->b_data;
    1.22 -		unsigned int size = bh->b_size;
    1.23 +		struct scatterlist *sge;
    1.24  
    1.25 +		/*
    1.26 +		 * continue segment from before?
    1.27 +		 */
    1.28 +		if (bh_phys(bh) == lastdataend) {
    1.29 +			sg[nents - 1].length += bh->b_size;
    1.30 +			lastdataend += bh->b_size;
    1.31 +			continue;
    1.32 +		}
    1.33 +
    1.34 +		/*
    1.35 +		 * start new segment
    1.36 +		 */
    1.37  		if (nents >= PRD_ENTRIES)
    1.38  			return 0;
    1.39  
    1.40 -		while ((bh = bh->b_reqnext) != NULL) {
    1.41 -			if ((virt_addr + size) != (unsigned char *) bh->b_data)
    1.42 -				break;
    1.43 -			size += bh->b_size;
    1.44 +		sge = &sg[nents];
    1.45 +		memset(sge, 0, sizeof(*sge));
    1.46 +
    1.47 +		if (bh->b_page) {
    1.48 +			sge->page = bh->b_page;
    1.49 +			sge->offset = bh_offset(bh);
    1.50 +		} else {
    1.51 +			if (((unsigned long) bh->b_data) < PAGE_SIZE)
    1.52 +				BUG();
    1.53 +
    1.54 +			sge->address = bh->b_data;
    1.55  		}
    1.56 -		memset(&sg[nents], 0, sizeof(*sg));
    1.57 -		sg[nents].address = virt_addr;
    1.58 -		sg[nents].length = size;
    1.59 +
    1.60 +		sge->length = bh->b_size;
    1.61 +		lastdataend = bh_phys(bh) + bh->b_size;
    1.62  		nents++;
    1.63 -	} while (bh != NULL);
    1.64 +	} while ((bh = bh->b_reqnext) != NULL);
    1.65  
    1.66  	return pci_map_sg(hwif->pci_dev, sg, nents, hwif->sg_dma_direction);
    1.67  }
    1.68 @@ -341,7 +361,7 @@ int ide_build_dmatable (ide_drive_t *dri
    1.69  		return 0;
    1.70  
    1.71  	sg = HWIF(drive)->sg_table;
    1.72 -	while (i && sg_dma_len(sg)) {
    1.73 +	while (i) {
    1.74  		u32 cur_addr;
    1.75  		u32 cur_len;
    1.76  
    1.77 @@ -355,36 +375,35 @@ int ide_build_dmatable (ide_drive_t *dri
    1.78  		 */
    1.79  
    1.80  		while (cur_len) {
    1.81 -			if (count++ >= PRD_ENTRIES) {
    1.82 -				printk("%s: DMA table too small\n", drive->name);
    1.83 -				goto use_pio_instead;
    1.84 -			} else {
    1.85 -				u32 xcount, bcount = 0x10000 - (cur_addr & 0xffff);
    1.86 +			u32 xcount, bcount = 0x10000 - (cur_addr & 0xffff);
    1.87 +			
    1.88 +			if (count++ >= PRD_ENTRIES)
    1.89 +				BUG();
    1.90  
    1.91 -				if (bcount > cur_len)
    1.92 -					bcount = cur_len;
    1.93 -				*table++ = cpu_to_le32(cur_addr);
    1.94 -				xcount = bcount & 0xffff;
    1.95 -				if (is_trm290_chipset)
    1.96 -					xcount = ((xcount >> 2) - 1) << 16;
    1.97 -				if (xcount == 0x0000) {
    1.98 -					/* 
    1.99 -					 * Most chipsets correctly interpret a length of 0x0000 as 64KB,
   1.100 -					 * but at least one (e.g. CS5530) misinterprets it as zero (!).
   1.101 -					 * So here we break the 64KB entry into two 32KB entries instead.
   1.102 -					 */
   1.103 -					if (count++ >= PRD_ENTRIES) {
   1.104 -						printk("%s: DMA table too small\n", drive->name);
   1.105 -						goto use_pio_instead;
   1.106 -					}
   1.107 -					*table++ = cpu_to_le32(0x8000);
   1.108 -					*table++ = cpu_to_le32(cur_addr + 0x8000);
   1.109 -					xcount = 0x8000;
   1.110 -				}
   1.111 -				*table++ = cpu_to_le32(xcount);
   1.112 -				cur_addr += bcount;
   1.113 -				cur_len -= bcount;
   1.114 +			if (bcount > cur_len)
   1.115 +				bcount = cur_len;
   1.116 +			*table++ = cpu_to_le32(cur_addr);
   1.117 +			xcount = bcount & 0xffff;
   1.118 +			if (is_trm290_chipset)
   1.119 +				xcount = ((xcount >> 2) - 1) << 16;
   1.120 +			if (xcount == 0x0000) {
   1.121 +				/* 
   1.122 +				 * Most chipsets correctly interpret a length
   1.123 +				 * of 0x0000 as 64KB, but at least one
   1.124 +				 * (e.g. CS5530) misinterprets it as zero (!).
   1.125 +				 * So here we break the 64KB entry into two
   1.126 +				 * 32KB entries instead.
   1.127 +				 */
   1.128 +				if (count++ >= PRD_ENTRIES)
   1.129 +					goto use_pio_instead;
   1.130 +
   1.131 +				*table++ = cpu_to_le32(0x8000);
   1.132 +				*table++ = cpu_to_le32(cur_addr + 0x8000);
   1.133 +				xcount = 0x8000;
   1.134  			}
   1.135 +			*table++ = cpu_to_le32(xcount);
   1.136 +			cur_addr += bcount;
   1.137 +			cur_len -= bcount;
   1.138  		}
   1.139  
   1.140  		sg++;
   1.141 @@ -585,6 +604,25 @@ static ide_startstop_t ide_dma_timeout_r
   1.142  }
   1.143  #endif /* CONFIG_BLK_DEV_IDEDMA_TIMEOUT */
   1.144  
   1.145 +#if 0
   1.146 +static inline void ide_toggle_bounce(ide_drive_t *drive, int on)
   1.147 +{
   1.148 +	dma64_addr_t addr = BLK_BOUNCE_HIGH;
   1.149 +
   1.150 +	if (HWIF(drive)->no_highio || HWIF(drive)->pci_dev == NULL)
   1.151 +		return;
   1.152 +
   1.153 +	if (on && drive->media == ide_disk) {
   1.154 +		if (!PCI_DMA_BUS_IS_PHYS)
   1.155 +			addr = BLK_BOUNCE_ANY;
   1.156 +		else
   1.157 +			addr = HWIF(drive)->pci_dev->dma_mask;
   1.158 +	}
   1.159 +
   1.160 +	blk_queue_bounce_limit(&drive->queue, addr);
   1.161 +}
   1.162 +#endif
   1.163 +
   1.164  /*
   1.165   * ide_dmaproc() initiates/aborts DMA read/write operations on a drive.
   1.166   *
   1.167 @@ -607,18 +645,20 @@ int ide_dmaproc (ide_dma_action_t func, 
   1.168  	ide_hwif_t *hwif		= HWIF(drive);
   1.169  	unsigned long dma_base		= hwif->dma_base;
   1.170  	byte unit			= (drive->select.b.unit & 0x01);
   1.171 -	unsigned int count, reading	= 0;
   1.172 +	unsigned int count, reading = 0/*, set_high = 1*/;
   1.173  	byte dma_stat;
   1.174  
   1.175  	switch (func) {
   1.176  		case ide_dma_off:
   1.177  			printk("%s: DMA disabled\n", drive->name);
   1.178  		case ide_dma_off_quietly:
   1.179 +                    /*set_high = 0;*/
   1.180  			outb(inb(dma_base+2) & ~(1<<(5+unit)), dma_base+2);
   1.181  		case ide_dma_on:
   1.182  			drive->using_dma = (func == ide_dma_on);
   1.183  			if (drive->using_dma)
   1.184  				outb(inb(dma_base+2)|(1<<(5+unit)), dma_base+2);
   1.185 +			/*ide_toggle_bounce(drive, set_high);*/
   1.186  			return 0;
   1.187  		case ide_dma_check:
   1.188  			return config_drive_for_dma (drive);
   1.189 @@ -760,8 +800,8 @@ void ide_setup_dma (ide_hwif_t *hwif, un
   1.190  	request_region(dma_base, num_ports, hwif->name);
   1.191  	hwif->dma_base = dma_base;
   1.192  	hwif->dmatable_cpu = pci_alloc_consistent(hwif->pci_dev,
   1.193 -						  PRD_ENTRIES * PRD_BYTES,
   1.194 -						  &hwif->dmatable_dma);
   1.195 +						    PRD_ENTRIES * PRD_BYTES,
   1.196 +						    &hwif->dmatable_dma);
   1.197  	if (hwif->dmatable_cpu == NULL)
   1.198  		goto dma_alloc_failure;
   1.199  
     2.1 --- a/xen-2.4.16/include/xeno/blkdev.h	Sun Feb 16 21:01:20 2003 +0000
     2.2 +++ b/xen-2.4.16/include/xeno/blkdev.h	Mon Feb 17 11:21:54 2003 +0000
     2.3 @@ -272,6 +272,8 @@ struct request_queue
     2.4  #endif
     2.5  };
     2.6  
     2.7 +#define bh_phys(bh)            (page_to_phys((bh)->b_page) + bh_offset((bh)))
     2.8 +
     2.9  struct blk_dev_struct {
    2.10  	/*
    2.11  	 * queue_proc has to be atomic