Index: ide-dma.c =================================================================== RCS file: /cvs/linux-mips/drivers/ide/ide-dma.c,v retrieving revision 1.1.1.2 retrieving revision 1.1.1.1 diff -u -r1.1.1.2 -r1.1.1.1 --- ide-dma.c 11 Sep 2002 17:57:14 -0000 1.1.1.2 +++ ide-dma.c 18 Jul 2002 17:34:48 -0000 1.1.1.1 @@ -252,53 +252,33 @@ { struct buffer_head *bh; struct scatterlist *sg = hwif->sg_table; - unsigned long lastdataend = ~0UL; int nents = 0; if (hwif->sg_dma_active) BUG(); - + if (rq->cmd == READ) hwif->sg_dma_direction = PCI_DMA_FROMDEVICE; else hwif->sg_dma_direction = PCI_DMA_TODEVICE; - bh = rq->bh; do { - struct scatterlist *sge; - - /* - * continue segment from before? - */ - if (bh_phys(bh) == lastdataend) { - sg[nents - 1].length += bh->b_size; - lastdataend += bh->b_size; - continue; - } + unsigned char *virt_addr = bh->b_data; + unsigned int size = bh->b_size; - /* - * start new segment - */ if (nents >= PRD_ENTRIES) return 0; - sge = &sg[nents]; - memset(sge, 0, sizeof(*sge)); - - if (bh->b_page) { - sge->page = bh->b_page; - sge->offset = bh_offset(bh); - } else { - if (((unsigned long) bh->b_data) < PAGE_SIZE) - BUG(); - - sge->address = bh->b_data; + while ((bh = bh->b_reqnext) != NULL) { + if ((virt_addr + size) != (unsigned char *) bh->b_data) + break; + size += bh->b_size; } - - sge->length = bh->b_size; - lastdataend = bh_phys(bh) + bh->b_size; + memset(&sg[nents], 0, sizeof(*sg)); + sg[nents].address = virt_addr; + sg[nents].length = size; nents++; - } while ((bh = bh->b_reqnext) != NULL); + } while (bh != NULL); return pci_map_sg(hwif->pci_dev, sg, nents, hwif->sg_dma_direction); }