diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/Documentation/Configure.help linux/Documentation/Configure.help --- /opt/kernel/linux-2.4.15-pre5/Documentation/Configure.help Fri Nov 16 08:11:20 2001 +++ linux/Documentation/Configure.help Fri Nov 16 08:22:07 2001 @@ -374,6 +374,12 @@ Select this if you have a 32-bit processor and more than 4 gigabytes of physical RAM. +HIGHMEM I/O support +CONFIG_HIGHIO + If you want to be able to do I/O to high memory pages, say Y. + Otherwise low memory pages are used as bounce buffers causing a + degrade in performance. + Normal PC floppy disk support CONFIG_BLK_DEV_FD If you want to use the floppy disk drive(s) of your PC under Linux, diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/arch/i386/config.in linux/arch/i386/config.in --- /opt/kernel/linux-2.4.15-pre5/arch/i386/config.in Fri Nov 16 08:11:20 2001 +++ linux/arch/i386/config.in Fri Nov 16 09:06:35 2001 @@ -167,6 +167,12 @@ define_bool CONFIG_X86_PAE y fi +if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then + if [ "$CONFIG_NOHIGHMEM" != "y"]; then + bool 'HIGHMEM I/O support (EXPERIMENTAL)' CONFIG_HIGHIO + fi +fi + bool 'Math emulation' CONFIG_MATH_EMULATION bool 'MTRR (Memory Type Range Register) support' CONFIG_MTRR bool 'Symmetric multi-processing support' CONFIG_SMP diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/arch/i386/kernel/setup.c linux/arch/i386/kernel/setup.c --- /opt/kernel/linux-2.4.15-pre5/arch/i386/kernel/setup.c Fri Nov 16 08:11:20 2001 +++ linux/arch/i386/kernel/setup.c Fri Nov 16 09:02:53 2001 @@ -161,6 +161,8 @@ static int disable_x86_serial_nr __initdata = 1; static int disable_x86_fxsr __initdata = 0; +extern int blk_nohighio; + int enable_acpi_smp_table; /* @@ -782,13 +784,17 @@ void __init setup_arch(char **cmdline_p) { unsigned long bootmap_size, low_mem_size; - unsigned long start_pfn, max_pfn, max_low_pfn; + unsigned long start_pfn, max_low_pfn; int i; #ifdef CONFIG_VISWS visws_get_board_type_and_rev(); #endif +#ifndef CONFIG_HIGHIO + blk_nohighio = 1; +#endif + ROOT_DEV = to_kdev_t(ORIG_ROOT_DEV); drive_info = DRIVE_INFO; screen_info = SCREEN_INFO; @@ -831,7 +837,20 @@ */ #define VMALLOC_RESERVE (unsigned long)(128 << 20) #define MAXMEM (unsigned long)(-PAGE_OFFSET-VMALLOC_RESERVE) +#if 1 #define MAXMEM_PFN PFN_DOWN(MAXMEM) +#else /* HIGHMEM emulation */ +#define ORDER_DOWN(x) ((x >> (MAX_ORDER-1)) << (MAX_ORDER-1)) +#define MAXMEM_PFN \ +({ \ + int __max_pfn; \ + if (max_pfn > PFN_DOWN(MAXMEM)) \ + __max_pfn = PFN_DOWN(MAXMEM); \ + else \ + __max_pfn = ORDER_DOWN(max_pfn / 2); \ + __max_pfn; \ +}) +#endif #define MAX_NONPAE_PFN (1 << 20) /* @@ -1066,6 +1085,14 @@ __setup("notsc", tsc_setup); #endif + +static int __init highio_setup(char *str) +{ + printk("i386: disabling HIGHMEM block I/O\n"); + blk_nohighio = 1; + return 1; +} +__setup("nohighio", highio_setup); static int __init get_model_name(struct cpuinfo_x86 *c) { diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/drivers/block/cciss.c linux/drivers/block/cciss.c --- /opt/kernel/linux-2.4.15-pre5/drivers/block/cciss.c Fri Nov 16 08:11:20 2001 +++ linux/drivers/block/cciss.c Mon Nov 12 11:56:19 2001 @@ -611,7 +611,7 @@ { buff = kmalloc(iocommand.buf_size, GFP_KERNEL); if( buff == NULL) - return -EFAULT; + return -ENOMEM; } if (iocommand.Request.Type.Direction == XFER_WRITE) { @@ -680,7 +680,7 @@ { kfree(buff); cmd_free(h, c, 0); - return( -EFAULT); + return( -EFAULT); } if (iocommand.Request.Type.Direction == XFER_READ) @@ -1125,20 +1125,22 @@ static inline void complete_command( CommandList_struct *cmd, int timeout) { int status = 1; - int i; + int i, ddir; u64bit temp64; if (timeout) status = 0; /* unmap the DMA mapping for all the scatter gather elements */ + if (cmd->Request.Type.Direction == XFER_READ) + ddir = PCI_DMA_FROMDEVICE; + else + ddir = PCI_DMA_TODEVICE; for(i=0; iHeader.SGList; i++) { temp64.val32.lower = cmd->SG[i].Addr.lower; temp64.val32.upper = cmd->SG[i].Addr.upper; - pci_unmap_single(hba[cmd->ctlr]->pdev, - temp64.val, cmd->SG[i].Len, - (cmd->Request.Type.Direction == XFER_READ) ? - PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE); + pci_unmap_page(hba[cmd->ctlr]->pdev, + temp64.val, cmd->SG[i].Len, ddir); } if(cmd->err_info->CommandStatus != 0) @@ -1215,7 +1217,6 @@ } } complete_buffers(cmd->rq->bh, status); - #ifdef CCISS_DEBUG printk("Done with %p\n", cmd->rq); #endif /* CCISS_DEBUG */ @@ -1236,7 +1237,7 @@ static int cpq_back_merge_fn(request_queue_t *q, struct request *rq, struct buffer_head *bh, int max_segments) { - if (rq->bhtail->b_data + rq->bhtail->b_size == bh->b_data) + if (BH_CONTIG(rq->bhtail, bh)) return 1; return cpq_new_segment(q, rq, max_segments); } @@ -1244,7 +1245,7 @@ static int cpq_front_merge_fn(request_queue_t *q, struct request *rq, struct buffer_head *bh, int max_segments) { - if (bh->b_data + bh->b_size == rq->bh->b_data) + if (BH_CONTIG(bh, rq->bh)) return 1; return cpq_new_segment(q, rq, max_segments); } @@ -1254,7 +1255,7 @@ { int total_segments = rq->nr_segments + nxt->nr_segments; - if (rq->bhtail->b_data + rq->bhtail->b_size == nxt->bh->b_data) + if (BH_CONTIG(rq->bhtail, nxt->bh)) total_segments--; if (total_segments > MAXSGENTRIES) @@ -1275,18 +1276,18 @@ ctlr_info_t *h= q->queuedata; CommandList_struct *c; int log_unit, start_blk, seg; - char *lastdataend; + unsigned long long lastdataend; struct buffer_head *bh; struct list_head *queue_head = &q->queue_head; struct request *creq; u64bit temp64; - struct my_sg tmp_sg[MAXSGENTRIES]; - int i; + struct scatterlist tmp_sg[MAXSGENTRIES]; + int i, ddir; if (q->plugged) goto startio; -queue_next: +next: if (list_empty(queue_head)) goto startio; @@ -1312,8 +1313,8 @@ spin_unlock_irq(&io_request_lock); c->cmd_type = CMD_RWREQ; - bh = creq->bh; c->rq = creq; + bh = creq->bh; /* fill in the request */ log_unit = MINOR(creq->rq_dev) >> NWD_SHIFT; @@ -1335,34 +1336,36 @@ printk(KERN_DEBUG "ciss: sector =%d nr_sectors=%d\n",(int) creq->sector, (int) creq->nr_sectors); #endif /* CCISS_DEBUG */ - seg = 0; - lastdataend = NULL; + seg = 0; + lastdataend = ~0ULL; while(bh) { - if (bh->b_data == lastdataend) + if (bh_phys(bh) == lastdataend) { // tack it on to the last segment - tmp_sg[seg-1].len +=bh->b_size; + tmp_sg[seg-1].length +=bh->b_size; lastdataend += bh->b_size; } else { if (seg == MAXSGENTRIES) BUG(); - tmp_sg[seg].len = bh->b_size; - tmp_sg[seg].start_addr = bh->b_data; - lastdataend = bh->b_data + bh->b_size; + tmp_sg[seg].page = bh->b_page; + tmp_sg[seg].length = bh->b_size; + tmp_sg[seg].offset = bh_offset(bh); + lastdataend = bh_phys(bh) + bh->b_size; seg++; } bh = bh->b_reqnext; } + /* get the DMA records for the setup */ - for (i=0; iSG[i].Len = tmp_sg[i].len; - temp64.val = (__u64) pci_map_single( h->pdev, - tmp_sg[i].start_addr, - tmp_sg[i].len, - (c->Request.Type.Direction == XFER_READ) ? - PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE); + if (c->Request.Type.Direction == XFER_READ) + ddir = PCI_DMA_FROMDEVICE; + else + ddir = PCI_DMA_TODEVICE; + for (i=0; iSG[i].Len = tmp_sg[i].length; + temp64.val = pci_map_page(h->pdev, tmp_sg[i].page, + tmp_sg[i].offset, tmp_sg[i].length, ddir); c->SG[i].Addr.lower = temp64.val32.lower; c->SG[i].Addr.upper = temp64.val32.upper; c->SG[i].Ext = 0; // we are not chaining @@ -1372,7 +1375,7 @@ h->maxSG = seg; #ifdef CCISS_DEBUG - printk(KERN_DEBUG "cciss: Submitting %d sectors in %d segments\n", creq->nr_sectors, seg); + printk(KERN_DEBUG "cciss: Submitting %d sectors in %d segments\n", sect, seg); #endif /* CCISS_DEBUG */ c->Header.SGList = c->Header.SGTotal = seg; @@ -1393,7 +1396,8 @@ if(h->Qdepth > h->maxQsinceinit) h->maxQsinceinit = h->Qdepth; - goto queue_next; + goto next; + startio: start_io(h); } @@ -1873,7 +1877,18 @@ sprintf(hba[i]->devname, "cciss%d", i); hba[i]->ctlr = i; hba[i]->pdev = pdev; - + + /* configure PCI DMA stuff */ + if (!pci_set_dma_mask(pdev, (u64) 0xffffffffffffffff)) + printk("cciss: using DAC cycles\n"); + else if (!pci_set_dma_mask(pdev, (u64) 0xffffffff)) + printk("cciss: not using DAC cycles\n"); + else { + printk("cciss: no suitable DMA available\n"); + free_hba(i); + return -ENODEV; + } + if( register_blkdev(MAJOR_NR+i, hba[i]->devname, &cciss_fops)) { printk(KERN_ERR "cciss: Unable to get major number " @@ -1941,9 +1956,10 @@ cciss_procinit(i); q = BLK_DEFAULT_QUEUE(MAJOR_NR + i); - q->queuedata = hba[i]; - blk_init_queue(q, do_cciss_request); - blk_queue_headactive(q, 0); + q->queuedata = hba[i]; + blk_init_queue(q, do_cciss_request); + blk_queue_bounce_limit(q, hba[i]->pdev->dma_mask); + blk_queue_headactive(q, 0); /* fill in the other Kernel structs */ blksize_size[MAJOR_NR+i] = hba[i]->blocksizes; diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/drivers/block/cciss.h linux/drivers/block/cciss.h --- /opt/kernel/linux-2.4.15-pre5/drivers/block/cciss.h Tue May 22 19:23:16 2001 +++ linux/drivers/block/cciss.h Fri Nov 16 08:32:00 2001 @@ -15,11 +15,6 @@ #define MAJOR_NR COMPAQ_CISS_MAJOR -struct my_sg { - int len; - char *start_addr; -}; - struct ctlr_info; typedef struct ctlr_info ctlr_info_t; diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/drivers/block/cpqarray.c linux/drivers/block/cpqarray.c --- /opt/kernel/linux-2.4.15-pre5/drivers/block/cpqarray.c Fri Nov 16 08:11:20 2001 +++ linux/drivers/block/cpqarray.c Mon Nov 12 11:55:57 2001 @@ -359,7 +359,7 @@ static int cpq_back_merge_fn(request_queue_t *q, struct request *rq, struct buffer_head *bh, int max_segments) { - if (rq->bhtail->b_data + rq->bhtail->b_size == bh->b_data) + if (BH_CONTIG(rq->bhtail, bh)) return 1; return cpq_new_segment(q, rq, max_segments); } @@ -367,7 +367,7 @@ static int cpq_front_merge_fn(request_queue_t *q, struct request *rq, struct buffer_head *bh, int max_segments) { - if (bh->b_data + bh->b_size == rq->bh->b_data) + if (BH_CONTIG(bh, rq->bh)) return 1; return cpq_new_segment(q, rq, max_segments); } @@ -377,7 +377,7 @@ { int total_segments = rq->nr_segments + nxt->nr_segments; - if (rq->bhtail->b_data + rq->bhtail->b_size == nxt->bh->b_data) + if (BH_CONTIG(rq->bhtail, nxt->bh)) total_segments--; if (total_segments > SG_MAX) @@ -524,6 +524,7 @@ q = BLK_DEFAULT_QUEUE(MAJOR_NR + i); q->queuedata = hba[i]; blk_init_queue(q, do_ida_request); + blk_queue_bounce_limit(q, hba[i]->pci_dev->dma_mask); blk_queue_headactive(q, 0); blksize_size[MAJOR_NR+i] = ida_blocksizes + (i*256); hardsect_size[MAJOR_NR+i] = ida_hardsizes + (i*256); @@ -911,17 +912,17 @@ { ctlr_info_t *h = q->queuedata; cmdlist_t *c; - char *lastdataend; + unsigned long lastdataend; struct list_head * queue_head = &q->queue_head; struct buffer_head *bh; struct request *creq; - struct my_sg tmp_sg[SG_MAX]; + struct scatterlist tmp_sg[SG_MAX]; int i, seg; if (q->plugged) goto startio; -queue_next: +next: if (list_empty(queue_head)) goto startio; @@ -961,17 +962,19 @@ printk("sector=%d, nr_sectors=%d\n", creq->sector, creq->nr_sectors); ); - seg = 0; lastdataend = NULL; + seg = 0; + lastdataend = ~0UL; while(bh) { - if (bh->b_data == lastdataend) { - tmp_sg[seg-1].size += bh->b_size; + if (bh_phys(bh) == lastdataend) { + tmp_sg[seg-1].length += bh->b_size; lastdataend += bh->b_size; } else { if (seg == SG_MAX) BUG(); - tmp_sg[seg].size = bh->b_size; - tmp_sg[seg].start_addr = bh->b_data; - lastdataend = bh->b_data + bh->b_size; + tmp_sg[seg].page = bh->b_page; + tmp_sg[seg].length = bh->b_size; + tmp_sg[seg].offset = bh_offset(bh); + lastdataend = bh_phys(bh) + bh->b_size; seg++; } bh = bh->b_reqnext; @@ -979,10 +982,10 @@ /* Now do all the DMA Mappings */ for( i=0; i < seg; i++) { - c->req.sg[i].size = tmp_sg[i].size; - c->req.sg[i].addr = (__u32) pci_map_single( - h->pci_dev, tmp_sg[i].start_addr, - tmp_sg[i].size, + c->req.sg[i].size = tmp_sg[i].length; + c->req.sg[i].addr = (__u32) pci_map_page( + h->pci_dev, tmp_sg[i].page, tmp_sg[i].offset, + tmp_sg[i].length, (creq->cmd == READ) ? PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE); } @@ -1000,7 +1003,7 @@ if (h->Qdepth > h->maxQsinceinit) h->maxQsinceinit = h->Qdepth; - goto queue_next; + goto next; startio: start_io(h); @@ -1076,17 +1079,14 @@ /* unmap the DMA mapping for all the scatter gather elements */ for(i=0; ireq.hdr.sg_cnt; i++) { - pci_unmap_single(hba[cmd->ctlr]->pci_dev, + pci_unmap_page(hba[cmd->ctlr]->pci_dev, cmd->req.sg[i].addr, cmd->req.sg[i].size, (cmd->req.hdr.cmd == IDA_READ) ? PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE); } complete_buffers(cmd->rq->bh, ok); - DBGPX(printk("Done with %p\n", cmd->rq);); end_that_request_last(cmd->rq); - - } /* diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/drivers/block/cpqarray.h linux/drivers/block/cpqarray.h --- /opt/kernel/linux-2.4.15-pre5/drivers/block/cpqarray.h Tue May 22 19:23:16 2001 +++ linux/drivers/block/cpqarray.h Fri Nov 16 08:41:42 2001 @@ -56,11 +56,6 @@ #ifdef __KERNEL__ -struct my_sg { - int size; - char *start_addr; -}; - struct ctlr_info; typedef struct ctlr_info ctlr_info_t; diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/drivers/block/elevator.c linux/drivers/block/elevator.c --- /opt/kernel/linux-2.4.15-pre5/drivers/block/elevator.c Fri Jul 20 05:59:41 2001 +++ linux/drivers/block/elevator.c Thu Oct 18 10:14:11 2001 @@ -110,7 +110,6 @@ break; } else if (__rq->sector - count == bh->b_rsector) { ret = ELEVATOR_FRONT_MERGE; - __rq->elevator_sequence -= count; *req = __rq; break; } diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/drivers/block/ll_rw_blk.c linux/drivers/block/ll_rw_blk.c --- /opt/kernel/linux-2.4.15-pre5/drivers/block/ll_rw_blk.c Tue Nov 13 08:53:03 2001 +++ linux/drivers/block/ll_rw_blk.c Fri Nov 16 09:13:30 2001 @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -123,6 +124,9 @@ */ static int queue_nr_requests, batch_requests; +unsigned long blk_max_low_pfn, blk_max_pfn; +int blk_nohighio = 0; + static inline int get_max_sectors(kdev_t dev) { if (!max_sectors[MAJOR(dev)]) @@ -244,6 +248,55 @@ q->make_request_fn = mfn; } +/** + * blk_queue_bounce_limit - set bounce buffer limit for queue + * @q: the request queue for the device + * @dma_addr: bus address limit + * + * Description: + * Different hardware can have different requirements as to what pages + * it can do I/O directly to. A low level driver can call + * blk_queue_bounce_limit to have lower memory pages allocated as bounce + * buffers for doing I/O to pages residing above @page. By default + * the block layer sets this to the highest numbered "low" memory page. + **/ +void blk_queue_bounce_limit(request_queue_t *q, u64 dma_addr) +{ + unsigned long bounce_pfn = dma_addr >> PAGE_SHIFT; + unsigned long mb = dma_addr >> 20; + static request_queue_t *old_q; + + /* + * keep this for debugging for now... + */ + if (dma_addr != BLK_BOUNCE_HIGH && q != old_q) { + old_q = q; + printk("blk: queue %p, ", q); + if (dma_addr == BLK_BOUNCE_ANY) + printk("no I/O memory limit\n"); + else + printk("I/O limit %luMb (mask 0x%Lx)\n", mb, (u64) dma_addr); + } + + q->bounce_pfn = bounce_pfn; +} + + +/* + * can we merge the two segments, or do we need to start a new one? + */ +inline int blk_seg_merge_ok(request_queue_t *q, struct buffer_head *bh, + struct buffer_head *nxt) +{ + if (!BH_CONTIG(bh, nxt)) + return 0; + + if (BH_PHYS_4G(bh, nxt)) + return 1; + + return 0; +} + static inline int ll_new_segment(request_queue_t *q, struct request *req, int max_segments) { if (req->nr_segments < max_segments) { @@ -256,16 +309,18 @@ static int ll_back_merge_fn(request_queue_t *q, struct request *req, struct buffer_head *bh, int max_segments) { - if (req->bhtail->b_data + req->bhtail->b_size == bh->b_data) + if (blk_seg_merge_ok(q, req->bhtail, bh)) return 1; + return ll_new_segment(q, req, max_segments); } static int ll_front_merge_fn(request_queue_t *q, struct request *req, struct buffer_head *bh, int max_segments) { - if (bh->b_data + bh->b_size == req->bh->b_data) + if (blk_seg_merge_ok(q, bh, req->bh)) return 1; + return ll_new_segment(q, req, max_segments); } @@ -274,7 +329,7 @@ { int total_segments = req->nr_segments + next->nr_segments; - if (req->bhtail->b_data + req->bhtail->b_size == next->bh->b_data) + if (blk_seg_merge_ok(q, req->bhtail, next->bh)) total_segments--; if (total_segments > max_segments) @@ -413,6 +468,8 @@ */ q->plug_device_fn = generic_plug_device; q->head_active = 1; + + blk_queue_bounce_limit(q, BLK_BOUNCE_HIGH); } #define blkdev_free_rq(list) list_entry((list)->next, struct request, queue); @@ -452,7 +509,7 @@ if (q->rq[rw].count < batch_requests) schedule(); spin_lock_irq(&io_request_lock); - rq = get_request(q,rw); + rq = get_request(q, rw); spin_unlock_irq(&io_request_lock); } while (rq == NULL); remove_wait_queue(&q->wait_for_request, &wait); @@ -664,9 +721,7 @@ * driver. Create a bounce buffer if the buffer data points into * high memory - keep the original buffer otherwise. */ -#if CONFIG_HIGHMEM - bh = create_bounce(rw, bh); -#endif + bh = blk_queue_bounce(q, rw, bh); /* look for a free request. */ /* @@ -711,8 +766,13 @@ elevator->elevator_merge_cleanup_fn(q, req, count); bh->b_reqnext = req->bh; req->bh = bh; + /* + * may not be valid, but queues not having bounce + * enabled for highmem pages must not look at + * ->buffer anyway + */ req->buffer = bh->b_data; - req->current_nr_sectors = count; + req->current_nr_sectors = req->hard_cur_sectors = count; req->sector = req->hard_sector = sector; req->nr_sectors = req->hard_nr_sectors += count; blk_started_io(count); @@ -762,7 +822,7 @@ req->errors = 0; req->hard_sector = req->sector = sector; req->hard_nr_sectors = req->nr_sectors = count; - req->current_nr_sectors = count; + req->current_nr_sectors = req->hard_cur_sectors = count; req->nr_segments = 1; /* Always 1 for a new request. */ req->nr_hw_segments = 1; /* Always 1 for a new request. */ req->buffer = bh->b_data; @@ -1067,6 +1127,7 @@ req->nr_sectors = req->hard_nr_sectors; req->current_nr_sectors = bh->b_size >> 9; + req->hard_cur_sectors = req->current_nr_sectors; if (req->nr_sectors < req->current_nr_sectors) { req->nr_sectors = req->current_nr_sectors; printk("end_request: buffer-list destroyed\n"); @@ -1115,14 +1176,19 @@ */ queue_nr_requests = 64; if (total_ram > MB(32)) - queue_nr_requests = 128; + queue_nr_requests = 256; /* * Batch frees according to queue length */ - batch_requests = queue_nr_requests/4; + if ((batch_requests = queue_nr_requests / 4) > 32) + batch_requests = 32; + printk("block: %d slots per queue, batch=%d\n", queue_nr_requests, batch_requests); + blk_max_low_pfn = max_low_pfn; + blk_max_pfn = max_pfn; + #ifdef CONFIG_AMIGA_Z2RAM z2_init(); #endif @@ -1241,3 +1307,8 @@ EXPORT_SYMBOL(generic_make_request); EXPORT_SYMBOL(blkdev_release_request); EXPORT_SYMBOL(generic_unplug_device); +EXPORT_SYMBOL(blk_queue_bounce_limit); +EXPORT_SYMBOL(blk_max_low_pfn); +EXPORT_SYMBOL(blk_max_pfn); +EXPORT_SYMBOL(blk_seg_merge_ok); +EXPORT_SYMBOL(blk_nohighio); diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/drivers/block/loop.c linux/drivers/block/loop.c --- /opt/kernel/linux-2.4.15-pre5/drivers/block/loop.c Fri Nov 16 08:11:20 2001 +++ linux/drivers/block/loop.c Mon Nov 12 11:56:19 2001 @@ -477,9 +477,7 @@ goto err; } -#if CONFIG_HIGHMEM - rbh = create_bounce(rw, rbh); -#endif + rbh = blk_queue_bounce(q, rw, rbh); /* * file backed, queue for loop_thread to handle diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/drivers/ide/amd74xx.c linux/drivers/ide/amd74xx.c --- /opt/kernel/linux-2.4.15-pre5/drivers/ide/amd74xx.c Mon Aug 13 23:56:19 2001 +++ linux/drivers/ide/amd74xx.c Fri Oct 19 15:04:04 2001 @@ -469,8 +469,10 @@ if (hwif->dma_base) { hwif->dmaproc = &amd74xx_dmaproc; - if (!noautodma) + if (!noautodma) { hwif->autodma = 1; + hwif->highmem = 1; + } } else { hwif->autodma = 0; hwif->drives[0].autotune = 1; diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/drivers/ide/hpt34x.c linux/drivers/ide/hpt34x.c --- /opt/kernel/linux-2.4.15-pre5/drivers/ide/hpt34x.c Sun May 20 02:43:06 2001 +++ linux/drivers/ide/hpt34x.c Thu Oct 18 10:14:11 2001 @@ -425,6 +425,7 @@ hwif->autodma = 0; hwif->dmaproc = &hpt34x_dmaproc; + hwif->highmem = 1; } else { hwif->drives[0].autotune = 1; hwif->drives[1].autotune = 1; diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/drivers/ide/hpt366.c linux/drivers/ide/hpt366.c --- /opt/kernel/linux-2.4.15-pre5/drivers/ide/hpt366.c Wed Aug 15 05:01:07 2001 +++ linux/drivers/ide/hpt366.c Thu Oct 18 10:14:11 2001 @@ -730,6 +730,7 @@ hwif->autodma = 1; else hwif->autodma = 0; + hwif->highmem = 1; } else { hwif->autodma = 0; hwif->drives[0].autotune = 1; diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/drivers/ide/ide-disk.c linux/drivers/ide/ide-disk.c --- /opt/kernel/linux-2.4.15-pre5/drivers/ide/ide-disk.c Mon Nov 5 09:50:49 2001 +++ linux/drivers/ide/ide-disk.c Thu Nov 1 13:02:59 2001 @@ -27,9 +27,10 @@ * Version 1.09 added increment of rq->sector in ide_multwrite * added UDMA 3/4 reporting * Version 1.10 request queue changes, Ultra DMA 100 + * Version 1.11 Highmem I/O support, Jens Axboe */ -#define IDEDISK_VERSION "1.10" +#define IDEDISK_VERSION "1.11" #undef REALLY_SLOW_IO /* most systems can safely undef this */ @@ -139,7 +140,9 @@ byte stat; int i; unsigned int msect, nsect; + unsigned long flags; struct request *rq; + char *to; /* new way for dealing with premature shared PCI interrupts */ if (!OK_STAT(stat=GET_STAT(),DATA_READY,BAD_R_STAT)) { @@ -150,8 +153,8 @@ ide_set_handler(drive, &read_intr, WAIT_CMD, NULL); return ide_started; } + msect = drive->mult_count; - read_next: rq = HWGROUP(drive)->rq; if (msect) { @@ -160,14 +163,15 @@ msect -= nsect; } else nsect = 1; - idedisk_input_data(drive, rq->buffer, nsect * SECTOR_WORDS); + to = ide_map_buffer(rq, &flags); + idedisk_input_data(drive, to, nsect * SECTOR_WORDS); #ifdef DEBUG printk("%s: read: sectors(%ld-%ld), buffer=0x%08lx, remaining=%ld\n", drive->name, rq->sector, rq->sector+nsect-1, (unsigned long) rq->buffer+(nsect<<9), rq->nr_sectors-nsect); #endif + ide_unmap_buffer(to, &flags); rq->sector += nsect; - rq->buffer += nsect<<9; rq->errors = 0; i = (rq->nr_sectors -= nsect); if (((long)(rq->current_nr_sectors -= nsect)) <= 0) @@ -201,14 +205,16 @@ #endif if ((rq->nr_sectors == 1) ^ ((stat & DRQ_STAT) != 0)) { rq->sector++; - rq->buffer += 512; rq->errors = 0; i = --rq->nr_sectors; --rq->current_nr_sectors; if (((long)rq->current_nr_sectors) <= 0) ide_end_request(1, hwgroup); if (i > 0) { - idedisk_output_data (drive, rq->buffer, SECTOR_WORDS); + unsigned long flags; + char *to = ide_map_buffer(rq, &flags); + idedisk_output_data (drive, to, SECTOR_WORDS); + ide_unmap_buffer(to, &flags); ide_set_handler (drive, &write_intr, WAIT_CMD, NULL); return ide_started; } @@ -238,14 +244,14 @@ do { char *buffer; int nsect = rq->current_nr_sectors; - + unsigned long flags; + if (nsect > mcount) nsect = mcount; mcount -= nsect; - buffer = rq->buffer; + buffer = ide_map_buffer(rq, &flags); rq->sector += nsect; - rq->buffer += nsect << 9; rq->nr_sectors -= nsect; rq->current_nr_sectors -= nsect; @@ -259,7 +265,7 @@ } else { rq->bh = bh; rq->current_nr_sectors = bh->b_size >> 9; - rq->buffer = bh->b_data; + rq->hard_cur_sectors = rq->current_nr_sectors; } } @@ -268,6 +274,7 @@ * re-entering us on the last transfer. */ idedisk_output_data(drive, buffer, nsect<<7); + ide_unmap_buffer(buffer, &flags); } while (mcount); return 0; @@ -452,8 +459,11 @@ return ide_stopped; } } else { + unsigned long flags; + char *buffer = ide_map_buffer(rq, &flags); ide_set_handler (drive, &write_intr, WAIT_CMD, NULL); - idedisk_output_data(drive, rq->buffer, SECTOR_WORDS); + idedisk_output_data(drive, buffer, SECTOR_WORDS); + ide_unmap_buffer(buffer, &flags); } return ide_started; } diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/drivers/ide/ide-dma.c linux/drivers/ide/ide-dma.c --- /opt/kernel/linux-2.4.15-pre5/drivers/ide/ide-dma.c Sun Sep 9 19:43:02 2001 +++ linux/drivers/ide/ide-dma.c Thu Nov 1 13:05:40 2001 @@ -251,33 +251,48 @@ { 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 { - unsigned char *virt_addr = bh->b_data; - unsigned int size = bh->b_size; + /* + * continue segment from before? + */ + if (bh_phys(bh) == lastdataend) { + sg[nents - 1].length += bh->b_size; + lastdataend += bh->b_size; + } else { + struct scatterlist *sge; + /* + * start new segment + */ + if (nents >= PRD_ENTRIES) + return 0; - if (nents >= PRD_ENTRIES) - return 0; + sge = &sg[nents]; + memset(sge, 0, sizeof(*sge)); + if ((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; + nents++; } - memset(&sg[nents], 0, sizeof(*sg)); - sg[nents].address = virt_addr; - sg[nents].length = size; - nents++; - } while (bh != NULL); + } while ((bh = bh->b_reqnext) != NULL); return pci_map_sg(hwif->pci_dev, sg, nents, hwif->sg_dma_direction); } @@ -305,7 +320,7 @@ return 0; sg = HWIF(drive)->sg_table; - while (i && sg_dma_len(sg)) { + while (i) { u32 cur_addr; u32 cur_len; @@ -319,36 +334,35 @@ */ while (cur_len) { - if (count++ >= PRD_ENTRIES) { - printk("%s: DMA table too small\n", drive->name); - goto use_pio_instead; - } else { - u32 xcount, bcount = 0x10000 - (cur_addr & 0xffff); - - if (bcount > cur_len) - bcount = cur_len; - *table++ = cpu_to_le32(cur_addr); - xcount = bcount & 0xffff; - if (is_trm290_chipset) - xcount = ((xcount >> 2) - 1) << 16; - if (xcount == 0x0000) { - /* - * Most chipsets correctly interpret a length of 0x0000 as 64KB, - * but at least one (e.g. CS5530) misinterprets it as zero (!). - * So here we break the 64KB entry into two 32KB entries instead. - */ - if (count++ >= PRD_ENTRIES) { - printk("%s: DMA table too small\n", drive->name); - goto use_pio_instead; - } - *table++ = cpu_to_le32(0x8000); - *table++ = cpu_to_le32(cur_addr + 0x8000); - xcount = 0x8000; - } - *table++ = cpu_to_le32(xcount); - cur_addr += bcount; - cur_len -= bcount; + u32 xcount, bcount = 0x10000 - (cur_addr & 0xffff); + + if (count++ >= PRD_ENTRIES) + BUG(); + + if (bcount > cur_len) + bcount = cur_len; + *table++ = cpu_to_le32(cur_addr); + xcount = bcount & 0xffff; + if (is_trm290_chipset) + xcount = ((xcount >> 2) - 1) << 16; + if (xcount == 0x0000) { + /* + * Most chipsets correctly interpret a length + * of 0x0000 as 64KB, but at least one + * (e.g. CS5530) misinterprets it as zero (!). + * So here we break the 64KB entry into two + * 32KB entries instead. + */ + if (count++ >= PRD_ENTRIES) + goto use_pio_instead; + + *table++ = cpu_to_le32(0x8000); + *table++ = cpu_to_le32(cur_addr + 0x8000); + xcount = 0x8000; } + *table++ = cpu_to_le32(xcount); + cur_addr += bcount; + cur_len -= bcount; } sg++; @@ -532,6 +546,20 @@ } #endif /* CONFIG_BLK_DEV_IDEDMA_TIMEOUT */ +static inline void ide_toggle_bounce(ide_drive_t *drive, int on) +{ + dma64_addr_t addr = BLK_BOUNCE_HIGH; + + if (on && drive->media == ide_disk && HWIF(drive)->highmem) { + if (!PCI_DMA_BUS_IS_PHYS) + addr = BLK_BOUNCE_ANY; + else + addr = HWIF(drive)->pci_dev->dma_mask; + } + + blk_queue_bounce_limit(&drive->queue, addr); +} + /* * ide_dmaproc() initiates/aborts DMA read/write operations on a drive. * @@ -554,18 +582,20 @@ ide_hwif_t *hwif = HWIF(drive); unsigned long dma_base = hwif->dma_base; byte unit = (drive->select.b.unit & 0x01); - unsigned int count, reading = 0; + unsigned int count, reading = 0, set_high = 1; byte dma_stat; switch (func) { case ide_dma_off: printk("%s: DMA disabled\n", drive->name); + set_high = 0; case ide_dma_off_quietly: outb(inb(dma_base+2) & ~(1<<(5+unit)), dma_base+2); case ide_dma_on: drive->using_dma = (func == ide_dma_on); if (drive->using_dma) outb(inb(dma_base+2)|(1<<(5+unit)), dma_base+2); + ide_toggle_bounce(drive, set_high); return 0; case ide_dma_check: return config_drive_for_dma (drive); @@ -696,8 +726,8 @@ request_region(dma_base, num_ports, hwif->name); hwif->dma_base = dma_base; hwif->dmatable_cpu = pci_alloc_consistent(hwif->pci_dev, - PRD_ENTRIES * PRD_BYTES, - &hwif->dmatable_dma); + PRD_ENTRIES * PRD_BYTES, + &hwif->dmatable_dma); if (hwif->dmatable_cpu == NULL) goto dma_alloc_failure; diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/drivers/ide/pdc202xx.c linux/drivers/ide/pdc202xx.c --- /opt/kernel/linux-2.4.15-pre5/drivers/ide/pdc202xx.c Fri Nov 16 08:11:20 2001 +++ linux/drivers/ide/pdc202xx.c Fri Nov 16 08:10:41 2001 @@ -893,6 +893,7 @@ #ifdef CONFIG_BLK_DEV_IDEDMA if (hwif->dma_base) { hwif->dmaproc = &pdc202xx_dmaproc; + hwif->highmem = 1; if (!noautodma) hwif->autodma = 1; } else { diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/drivers/ide/piix.c linux/drivers/ide/piix.c --- /opt/kernel/linux-2.4.15-pre5/drivers/ide/piix.c Tue Nov 13 08:53:03 2001 +++ linux/drivers/ide/piix.c Mon Oct 29 08:48:15 2001 @@ -523,6 +523,7 @@ if (!hwif->dma_base) return; + hwif->highmem = 1; #ifndef CONFIG_BLK_DEV_IDEDMA hwif->autodma = 0; #else /* CONFIG_BLK_DEV_IDEDMA */ diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/drivers/scsi/aic7xxx/aic7xxx_linux_host.h linux/drivers/scsi/aic7xxx/aic7xxx_linux_host.h --- /opt/kernel/linux-2.4.15-pre5/drivers/scsi/aic7xxx/aic7xxx_linux_host.h Tue Nov 13 08:53:03 2001 +++ linux/drivers/scsi/aic7xxx/aic7xxx_linux_host.h Mon Oct 29 08:48:15 2001 @@ -89,7 +89,8 @@ present: 0, /* number of 7xxx's present */\ unchecked_isa_dma: 0, /* no memory DMA restrictions */\ use_clustering: ENABLE_CLUSTERING, \ - use_new_eh_code: 1 \ + use_new_eh_code: 1, \ + can_dma_32: 1, \ } #endif /* _AIC7XXX_LINUX_HOST_H_ */ diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/drivers/scsi/aic7xxx/aic7xxx_linux_pci.c linux/drivers/scsi/aic7xxx/aic7xxx_linux_pci.c --- /opt/kernel/linux-2.4.15-pre5/drivers/scsi/aic7xxx/aic7xxx_linux_pci.c Fri Nov 16 08:11:21 2001 +++ linux/drivers/scsi/aic7xxx/aic7xxx_linux_pci.c Fri Nov 16 08:10:41 2001 @@ -158,7 +158,7 @@ if (sizeof(bus_addr_t) > 4 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,3) && ahc_linux_get_memsize() > 0x80000000 - && pci_set_dma_mask(pdev, 0x7FFFFFFFFFULL) == 0) { + && pci_set_dma_mask(pdev, 0xFFFFFFFFULL) == 0) { #else && ahc_linux_get_memsize() > 0x80000000) { diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/drivers/scsi/aic7xxx_old/aic7xxx.h linux/drivers/scsi/aic7xxx_old/aic7xxx.h --- /opt/kernel/linux-2.4.15-pre5/drivers/scsi/aic7xxx_old/aic7xxx.h Sun Mar 4 23:30:18 2001 +++ linux/drivers/scsi/aic7xxx_old/aic7xxx.h Fri Nov 16 09:11:03 2001 @@ -55,7 +55,8 @@ present: 0, /* number of 7xxx's present */\ unchecked_isa_dma: 0, /* no memory DMA restrictions */\ use_clustering: ENABLE_CLUSTERING, \ - use_new_eh_code: 0 \ + use_new_eh_code: 0, \ + can_dma_32: 1 \ } extern int aic7xxx_queue(Scsi_Cmnd *, void (*)(Scsi_Cmnd *)); diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/drivers/scsi/hosts.c linux/drivers/scsi/hosts.c --- /opt/kernel/linux-2.4.15-pre5/drivers/scsi/hosts.c Thu Jul 5 20:28:17 2001 +++ linux/drivers/scsi/hosts.c Fri Nov 16 09:28:55 2001 @@ -129,7 +129,7 @@ * once we are 100% sure that we want to use this host adapter - it is a * pain to reverse this, so we try to avoid it */ - +extern int blk_nohighio; struct Scsi_Host * scsi_register(Scsi_Host_Template * tpnt, int j){ struct Scsi_Host * retval, *shpnt, *o_shp; Scsi_Host_Name *shn, *shn2; @@ -235,6 +235,8 @@ retval->cmd_per_lun = tpnt->cmd_per_lun; retval->unchecked_isa_dma = tpnt->unchecked_isa_dma; retval->use_clustering = tpnt->use_clustering; + if (!blk_nohighio) + retval->can_dma_32 = tpnt->can_dma_32; retval->select_queue_depths = tpnt->select_queue_depths; retval->max_sectors = tpnt->max_sectors; diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/drivers/scsi/hosts.h linux/drivers/scsi/hosts.h --- /opt/kernel/linux-2.4.15-pre5/drivers/scsi/hosts.h Thu Oct 11 08:47:24 2001 +++ linux/drivers/scsi/hosts.h Fri Nov 16 08:32:11 2001 @@ -291,6 +291,8 @@ */ unsigned emulated:1; + unsigned can_dma_32:1; + /* * Name of proc directory */ @@ -390,6 +392,8 @@ unsigned in_recovery:1; unsigned unchecked_isa_dma:1; unsigned use_clustering:1; + unsigned can_dma_32:1; + /* * True if this host was loaded as a loadable module */ diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/drivers/scsi/ide-scsi.c linux/drivers/scsi/ide-scsi.c --- /opt/kernel/linux-2.4.15-pre5/drivers/scsi/ide-scsi.c Sun Sep 30 21:26:07 2001 +++ linux/drivers/scsi/ide-scsi.c Thu Oct 18 10:14:11 2001 @@ -695,7 +695,7 @@ int segments = pc->scsi_cmd->use_sg; struct scatterlist *sg = pc->scsi_cmd->request_buffer; - if (!drive->using_dma || !pc->request_transfer || pc->request_transfer % 1024) + if (!drive->using_dma || !pc->request_transfer || pc->request_transfer & 1023) return NULL; if (idescsi_set_direction(pc)) return NULL; @@ -706,12 +706,22 @@ printk ("ide-scsi: %s: building DMA table, %d segments, %dkB total\n", drive->name, segments, pc->request_transfer >> 10); #endif /* IDESCSI_DEBUG_LOG */ while (segments--) { - bh->b_data = sg->address; + if (sg->address) { + bh->b_page = virt_to_page(sg->address); + bh->b_data = (char *) ((unsigned long) sg->address & ~PAGE_MASK); + } else if (sg->page) { + bh->b_page = sg->page; + bh->b_data = (char *) sg->offset; + } + bh->b_size = sg->length; bh = bh->b_reqnext; sg++; } } else { + /* + * non-sg requests are guarenteed not to reside in highmem /jens + */ if ((first_bh = bh = idescsi_kmalloc_bh (1)) == NULL) return NULL; #if IDESCSI_DEBUG_LOG diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/drivers/scsi/qlogicfc.h linux/drivers/scsi/qlogicfc.h --- /opt/kernel/linux-2.4.15-pre5/drivers/scsi/qlogicfc.h Mon Nov 5 09:50:49 2001 +++ linux/drivers/scsi/qlogicfc.h Mon Oct 22 09:44:33 2001 @@ -95,7 +95,8 @@ cmd_per_lun: QLOGICFC_CMD_PER_LUN, \ present: 0, \ unchecked_isa_dma: 0, \ - use_clustering: ENABLE_CLUSTERING \ + use_clustering: ENABLE_CLUSTERING, \ + can_dma_32: 1 \ } #endif /* _QLOGICFC_H */ diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/drivers/scsi/scsi.c linux/drivers/scsi/scsi.c --- /opt/kernel/linux-2.4.15-pre5/drivers/scsi/scsi.c Fri Nov 16 08:11:21 2001 +++ linux/drivers/scsi/scsi.c Mon Nov 12 11:56:19 2001 @@ -186,10 +186,13 @@ * handler in the list - ultimately they call scsi_request_fn * to do the dirty deed. */ -void scsi_initialize_queue(Scsi_Device * SDpnt, struct Scsi_Host * SHpnt) { - blk_init_queue(&SDpnt->request_queue, scsi_request_fn); - blk_queue_headactive(&SDpnt->request_queue, 0); - SDpnt->request_queue.queuedata = (void *) SDpnt; +void scsi_initialize_queue(Scsi_Device * SDpnt, struct Scsi_Host * SHpnt) +{ + request_queue_t *q = &SDpnt->request_queue; + + blk_init_queue(q, scsi_request_fn); + blk_queue_headactive(q, 0); + q->queuedata = (void *) SDpnt; } #ifdef MODULE diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/drivers/scsi/scsi.h linux/drivers/scsi/scsi.h --- /opt/kernel/linux-2.4.15-pre5/drivers/scsi/scsi.h Fri Nov 16 08:11:21 2001 +++ linux/drivers/scsi/scsi.h Fri Nov 16 08:32:11 2001 @@ -386,15 +386,6 @@ #define ASKED_FOR_SENSE 0x20 #define SYNC_RESET 0x40 -#if defined(__mc68000__) || defined(CONFIG_APUS) -#include -#define CONTIGUOUS_BUFFERS(X,Y) \ - (virt_to_phys((X)->b_data+(X)->b_size-1)+1==virt_to_phys((Y)->b_data)) -#else -#define CONTIGUOUS_BUFFERS(X,Y) ((X->b_data+X->b_size) == Y->b_data) -#endif - - /* * This is the crap from the old error handling code. We have it in a special * place so that we can more easily delete it later on. @@ -633,7 +624,7 @@ struct scatterlist *buffer; /* which buffer */ int buffers_residual; /* how many buffers left */ - dma_addr_t dma_handle; + dma_addr_t dma_handle; volatile int Status; volatile int Message; diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/drivers/scsi/scsi_lib.c linux/drivers/scsi/scsi_lib.c --- /opt/kernel/linux-2.4.15-pre5/drivers/scsi/scsi_lib.c Mon Nov 5 09:50:49 2001 +++ linux/drivers/scsi/scsi_lib.c Tue Oct 23 09:05:43 2001 @@ -388,6 +388,7 @@ req->nr_sectors -= nsect; req->current_nr_sectors = bh->b_size >> 9; + req->hard_cur_sectors = req->current_nr_sectors; if (req->nr_sectors < req->current_nr_sectors) { req->nr_sectors = req->current_nr_sectors; printk("scsi_end_request: buffer-list destroyed\n"); @@ -410,7 +411,6 @@ q = &SCpnt->device->request_queue; - req->buffer = bh->b_data; /* * Bleah. Leftovers again. Stick the leftovers in * the front of the queue, and goose the queue again. @@ -489,6 +489,8 @@ */ static void scsi_release_buffers(Scsi_Cmnd * SCpnt) { + struct request *req = &SCpnt->request; + ASSERT_LOCK(&io_request_lock, 0); /* @@ -499,7 +501,7 @@ void **bbpnt; int i; - sgpnt = (struct scatterlist *) SCpnt->request_buffer; + sgpnt = (struct scatterlist *) req->buffer; bbpnt = SCpnt->bounce_buffers; if (bbpnt) { @@ -548,6 +550,7 @@ int result = SCpnt->result; int this_count = SCpnt->bufflen >> 9; request_queue_t *q = &SCpnt->device->request_queue; + struct request *req = &SCpnt->request; /* * We must do one of several things here: @@ -580,7 +583,7 @@ if (bbpnt) { for (i = 0; i < SCpnt->use_sg; i++) { if (bbpnt[i]) { - if (SCpnt->request.cmd == READ) { + if (req->cmd == READ) { memcpy(bbpnt[i], sgpnt[i].address, sgpnt[i].length); @@ -592,9 +595,11 @@ scsi_free(SCpnt->buffer, SCpnt->sglist_len); } else { if (SCpnt->buffer != SCpnt->request.buffer) { - if (SCpnt->request.cmd == READ) { - memcpy(SCpnt->request.buffer, SCpnt->buffer, - SCpnt->bufflen); + if (req->cmd == READ) { + unsigned long flags; + char *to = bh_kmap_irq(req->bh, &flags); + memcpy(to, SCpnt->buffer, SCpnt->bufflen); + bh_kunmap_irq(to, &flags); } scsi_free(SCpnt->buffer, SCpnt->bufflen); } @@ -619,7 +624,7 @@ good_sectors)); SCSI_LOG_HLCOMPLETE(1, printk("use_sg is %d\n ", SCpnt->use_sg)); - SCpnt->request.errors = 0; + req->errors = 0; /* * If multiple sectors are requested in one buffer, then * they will have been finished off by the first command. diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/drivers/scsi/scsi_merge.c linux/drivers/scsi/scsi_merge.c --- /opt/kernel/linux-2.4.15-pre5/drivers/scsi/scsi_merge.c Tue Nov 13 08:53:03 2001 +++ linux/drivers/scsi/scsi_merge.c Fri Nov 16 09:02:13 2001 @@ -6,6 +6,7 @@ * Based upon conversations with large numbers * of people at Linux Expo. * Support for dynamic DMA mapping: Jakub Jelinek (jakub@redhat.com). + * Support for highmem I/O: Jens Axboe */ /* @@ -48,7 +49,6 @@ #include #include - #define __KERNEL_SYSCALLS__ #include @@ -95,7 +95,7 @@ printk("Segment 0x%p, blocks %d, addr 0x%lx\n", bh, bh->b_size >> 9, - virt_to_phys(bh->b_data - 1)); + bh_phys(bh) - 1); } panic("Ththththaats all folks. Too dangerous to continue.\n"); } @@ -223,11 +223,10 @@ * DMA capable host, make sure that a segment doesn't span * the DMA threshold boundary. */ - if (dma_host && - virt_to_phys(bhnext->b_data) - 1 == ISA_DMA_THRESHOLD) { + if (dma_host && bh_phys(bhnext) - 1 == ISA_DMA_THRESHOLD) { ret++; reqsize = bhnext->b_size; - } else if (CONTIGUOUS_BUFFERS(bh, bhnext)) { + } else if (BH_CONTIG(bh, bhnext)) { /* * This one is OK. Let it go. */ @@ -241,8 +240,7 @@ * kind of screwed and we need to start * another segment. */ - if( dma_host - && virt_to_phys(bh->b_data) - 1 >= ISA_DMA_THRESHOLD + if( dma_host && bh_phys(bh) - 1 >= ISA_DMA_THRESHOLD && reqsize + bhnext->b_size > PAGE_SIZE ) { ret++; @@ -304,7 +302,7 @@ } #define MERGEABLE_BUFFERS(X,Y) \ -(((((long)(X)->b_data+(X)->b_size)|((long)(Y)->b_data)) & \ +(((((long)bh_phys((X))+(X)->b_size)|((long)bh_phys((Y)))) & \ (DMA_CHUNK_SIZE - 1)) == 0) #ifdef DMA_CHUNK_SIZE @@ -420,6 +418,9 @@ if ((req->nr_sectors + (bh->b_size >> 9)) > SHpnt->max_sectors) return 0; + if (!BH_PHYS_4G(req->bhtail, bh)) + return 0; + if (use_clustering) { /* * See if we can do this without creating another @@ -427,14 +428,11 @@ * DMA capable host, make sure that a segment doesn't span * the DMA threshold boundary. */ - if (dma_host && - virt_to_phys(req->bhtail->b_data) - 1 == ISA_DMA_THRESHOLD) { + if (dma_host && bh_phys(req->bhtail) - 1 == ISA_DMA_THRESHOLD) goto new_end_segment; - } - if (CONTIGUOUS_BUFFERS(req->bhtail, bh)) { + if (BH_CONTIG(req->bhtail, bh)) { #ifdef DMA_SEGMENT_SIZE_LIMITED - if( dma_host - && virt_to_phys(bh->b_data) - 1 >= ISA_DMA_THRESHOLD ) { + if (dma_host && bh_phys(bh) - 1 >= ISA_DMA_THRESHOLD) { segment_size = 0; count = __count_segments(req, use_clustering, dma_host, &segment_size); if( segment_size + bh->b_size > PAGE_SIZE ) { @@ -479,6 +477,9 @@ if ((req->nr_sectors + (bh->b_size >> 9)) > SHpnt->max_sectors) return 0; + if (!BH_PHYS_4G(bh, req->bh)) + return 0; + if (use_clustering) { /* * See if we can do this without creating another @@ -486,14 +487,12 @@ * DMA capable host, make sure that a segment doesn't span * the DMA threshold boundary. */ - if (dma_host && - virt_to_phys(bh->b_data) - 1 == ISA_DMA_THRESHOLD) { + if (dma_host && bh_phys(bh) - 1 == ISA_DMA_THRESHOLD) { goto new_start_segment; } - if (CONTIGUOUS_BUFFERS(bh, req->bh)) { + if (BH_CONTIG(bh, req->bh)) { #ifdef DMA_SEGMENT_SIZE_LIMITED - if( dma_host - && virt_to_phys(bh->b_data) - 1 >= ISA_DMA_THRESHOLD ) { + if (dma_host && bh_phys(bh) - 1 >= ISA_DMA_THRESHOLD) { segment_size = bh->b_size; count = __count_segments(req, use_clustering, dma_host, &segment_size); if( count != req->nr_segments ) { @@ -641,6 +640,9 @@ if ((req->nr_sectors + next->nr_sectors) > SHpnt->max_sectors) return 0; + if (!BH_PHYS_4G(req->bhtail, next->bh)) + return 0; + /* * The main question is whether the two segments at the boundaries * would be considered one or two. @@ -652,18 +654,15 @@ * DMA capable host, make sure that a segment doesn't span * the DMA threshold boundary. */ - if (dma_host && - virt_to_phys(req->bhtail->b_data) - 1 == ISA_DMA_THRESHOLD) { + if (dma_host && bh_phys(req->bhtail) - 1 == ISA_DMA_THRESHOLD) goto dont_combine; - } #ifdef DMA_SEGMENT_SIZE_LIMITED /* * We currently can only allocate scatter-gather bounce * buffers in chunks of PAGE_SIZE or less. */ - if (dma_host - && CONTIGUOUS_BUFFERS(req->bhtail, next->bh) - && virt_to_phys(req->bhtail->b_data) - 1 >= ISA_DMA_THRESHOLD ) + if (dma_host && BH_CONTIG(req->bhtail, next->bh) + && bh_phys(req->bhtail) - 1 >= ISA_DMA_THRESHOLD) { int segment_size = 0; int count = 0; @@ -675,7 +674,7 @@ } } #endif - if (CONTIGUOUS_BUFFERS(req->bhtail, next->bh)) { + if (BH_CONTIG(req->bhtail, next->bh)) { /* * This one is OK. Let it go. */ @@ -803,37 +802,13 @@ char * buff; int count; int i; - struct request * req; + struct request * req = &SCpnt->request; int sectors; struct scatterlist * sgpnt; int this_count; void ** bbpnt; /* - * FIXME(eric) - don't inline this - it doesn't depend on the - * integer flags. Come to think of it, I don't think this is even - * needed any more. Need to play with it and see if we hit the - * panic. If not, then don't bother. - */ - if (!SCpnt->request.bh) { - /* - * Case of page request (i.e. raw device), or unlinked buffer - * Typically used for swapping, but this isn't how we do - * swapping any more. - */ - panic("I believe this is dead code. If we hit this, I was wrong"); -#if 0 - SCpnt->request_bufflen = SCpnt->request.nr_sectors << 9; - SCpnt->request_buffer = SCpnt->request.buffer; - SCpnt->use_sg = 0; - /* - * FIXME(eric) - need to handle DMA here. - */ -#endif - return 1; - } - req = &SCpnt->request; - /* * First we need to know how many scatter gather segments are needed. */ if (!sg_count_valid) { @@ -848,21 +823,27 @@ * buffer. */ if (dma_host && scsi_dma_free_sectors <= 10) { - this_count = SCpnt->request.current_nr_sectors; + this_count = req->current_nr_sectors; goto single_segment; } /* - * Don't bother with scatter-gather if there is only one segment. - */ - if (count == 1) { - this_count = SCpnt->request.nr_sectors; + * we really want to use sg even for a single segment request, + * however some people just cannot be bothered to write decent + * driver code so we can't risk to break somebody making the + * assumption that sg requests will always contain at least 2 + * segments. if the driver is 32-bit dma safe, then use sg for + * 1 entry anyways. if not, don't rely on the driver handling this + * case. + */ + if (count == 1 && !SCpnt->host->can_dma_32) { + this_count = req->current_nr_sectors; goto single_segment; } - SCpnt->use_sg = count; - /* - * Allocate the actual scatter-gather table itself. + /* + * for sane drivers, use sg even for 1 entry request */ + SCpnt->use_sg = count; SCpnt->sglist_len = (SCpnt->use_sg * sizeof(struct scatterlist)); /* If we could potentially require ISA bounce buffers, allocate @@ -887,7 +868,7 @@ * simply write the first buffer all by itself. */ printk("Warning - running *really* short on DMA buffers\n"); - this_count = SCpnt->request.current_nr_sectors; + this_count = req->current_nr_sectors; goto single_segment; } /* @@ -907,13 +888,11 @@ SCpnt->bounce_buffers = bbpnt; - for (count = 0, bh = SCpnt->request.bh; - bh; bh = bh->b_reqnext) { + for (count = 0, bh = req->bh; bh; bh = bh->b_reqnext) { if (use_clustering && bhprev != NULL) { - if (dma_host && - virt_to_phys(bhprev->b_data) - 1 == ISA_DMA_THRESHOLD) { + if (dma_host && bh_phys(bhprev) - 1 == ISA_DMA_THRESHOLD) { /* Nothing - fall through */ - } else if (CONTIGUOUS_BUFFERS(bhprev, bh)) { + } else if (BH_CONTIG(bhprev, bh)) { /* * This one is OK. Let it go. Note that we * do not have the ability to allocate @@ -922,7 +901,7 @@ */ if( dma_host ) { #ifdef DMA_SEGMENT_SIZE_LIMITED - if( virt_to_phys(bh->b_data) - 1 < ISA_DMA_THRESHOLD + if (bh_phys(bh) - 1 < ISA_DMA_THRESHOLD || sgpnt[count - 1].length + bh->b_size <= PAGE_SIZE ) { sgpnt[count - 1].length += bh->b_size; bhprev = bh; @@ -941,13 +920,25 @@ } } } - count++; - sgpnt[count - 1].address = bh->b_data; - sgpnt[count - 1].page = NULL; - sgpnt[count - 1].length += bh->b_size; - if (!dma_host) { - SCpnt->request_bufflen += bh->b_size; + + if (SCpnt->host->can_dma_32) { + sgpnt[count].page = bh->b_page; + sgpnt[count].offset = bh_offset(bh); + sgpnt[count].address = NULL; + } else { + if (PageHighMem(bh->b_page)) + BUG(); + + sgpnt[count].page = NULL; + sgpnt[count].address = bh->b_data; } + + sgpnt[count].length = bh->b_size; + + if (!dma_host) + SCpnt->request_bufflen += bh->b_size; + + count++; bhprev = bh; } @@ -970,6 +961,10 @@ for (i = 0; i < count; i++) { sectors = (sgpnt[i].length >> 9); SCpnt->request_bufflen += sgpnt[i].length; + /* + * only done for dma_host, in which case .page is not + * set since it's guarenteed to be a low memory page + */ if (virt_to_phys(sgpnt[i].address) + sgpnt[i].length - 1 > ISA_DMA_THRESHOLD) { if( scsi_dma_free_sectors - sectors <= 10 ) { @@ -1005,7 +1000,7 @@ } break; } - if (SCpnt->request.cmd == WRITE) { + if (req->cmd == WRITE) { memcpy(sgpnt[i].address, bbpnt[i], sgpnt[i].length); } @@ -1050,8 +1045,7 @@ * single-block requests if we had hundreds of free sectors. */ if( scsi_dma_free_sectors > 30 ) { - for (this_count = 0, bh = SCpnt->request.bh; - bh; bh = bh->b_reqnext) { + for (this_count = 0, bh = req->bh; bh; bh = bh->b_reqnext) { if( scsi_dma_free_sectors - this_count < 30 || this_count == sectors ) { @@ -1064,7 +1058,7 @@ /* * Yow! Take the absolute minimum here. */ - this_count = SCpnt->request.current_nr_sectors; + this_count = req->current_nr_sectors; } /* @@ -1077,28 +1071,31 @@ * segment. Possibly the entire request, or possibly a small * chunk of the entire request. */ - bh = SCpnt->request.bh; - buff = SCpnt->request.buffer; + bh = req->bh; + buff = req->buffer = bh->b_data; - if (dma_host) { + if (dma_host || PageHighMem(bh->b_page)) { /* * Allocate a DMA bounce buffer. If the allocation fails, fall * back and allocate a really small one - enough to satisfy * the first buffer. */ - if (virt_to_phys(SCpnt->request.bh->b_data) - + (this_count << 9) - 1 > ISA_DMA_THRESHOLD) { + if (bh_phys(bh) + (this_count << 9) - 1 > ISA_DMA_THRESHOLD) { buff = (char *) scsi_malloc(this_count << 9); if (!buff) { printk("Warning - running low on DMA memory\n"); - this_count = SCpnt->request.current_nr_sectors; + this_count = req->current_nr_sectors; buff = (char *) scsi_malloc(this_count << 9); if (!buff) { dma_exhausted(SCpnt, 0); } } - if (SCpnt->request.cmd == WRITE) - memcpy(buff, (char *) SCpnt->request.buffer, this_count << 9); + if (req->cmd == WRITE) { + unsigned long flags; + char *buf = bh_kmap_irq(bh, &flags); + memcpy(buff, buf, this_count << 9); + bh_kunmap_irq(buf, &flags); + } } } SCpnt->request_bufflen = this_count << 9; @@ -1139,21 +1136,11 @@ */ void initialize_merge_fn(Scsi_Device * SDpnt) { - request_queue_t *q; - struct Scsi_Host *SHpnt; - SHpnt = SDpnt->host; - - q = &SDpnt->request_queue; + struct Scsi_Host *SHpnt = SDpnt->host; + request_queue_t *q = &SDpnt->request_queue; + dma64_addr_t bounce_limit; /* - * If the host has already selected a merge manager, then don't - * pick a new one. - */ -#if 0 - if (q->back_merge_fn && q->front_merge_fn) - return; -#endif - /* * If this host has an unlimited tablesize, then don't bother with a * merge manager. The whole point of the operation is to make sure * that requests don't grow too large, and this host isn't picky. @@ -1185,4 +1172,20 @@ q->merge_requests_fn = scsi_merge_requests_fn_dc; SDpnt->scsi_init_io_fn = scsi_init_io_vdc; } + + /* + * now enable highmem I/O, if appropriate + */ + bounce_limit = BLK_BOUNCE_HIGH; + if (SHpnt->can_dma_32 && (SDpnt->type == TYPE_DISK)) { + if (!PCI_DMA_BUS_IS_PHYS) + /* Platforms with virtual-DMA translation + * hardware have no practical limit. + */ + bounce_limit = BLK_BOUNCE_ANY; + else + bounce_limit = SHpnt->pci_dev->dma_mask; + } + + blk_queue_bounce_limit(q, bounce_limit); } diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/drivers/scsi/sym53c8xx.h linux/drivers/scsi/sym53c8xx.h --- /opt/kernel/linux-2.4.15-pre5/drivers/scsi/sym53c8xx.h Thu Oct 11 08:48:01 2001 +++ linux/drivers/scsi/sym53c8xx.h Sun Nov 4 12:59:01 2001 @@ -97,7 +97,8 @@ sg_tablesize: SCSI_NCR_SG_TABLESIZE, \ cmd_per_lun: SCSI_NCR_CMD_PER_LUN, \ max_sectors: MAX_SEGMENTS*8, \ - use_clustering: DISABLE_CLUSTERING} + use_clustering: DISABLE_CLUSTERING, \ + can_dma_32: 1} #else diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/drivers/scsi/sym53c8xx_2/sym53c8xx.h linux/drivers/scsi/sym53c8xx_2/sym53c8xx.h --- /opt/kernel/linux-2.4.15-pre5/drivers/scsi/sym53c8xx_2/sym53c8xx.h Fri Nov 16 08:11:21 2001 +++ linux/drivers/scsi/sym53c8xx_2/sym53c8xx.h Fri Nov 16 09:28:37 2001 @@ -119,7 +119,8 @@ this_id: 7, \ sg_tablesize: 0, \ cmd_per_lun: 0, \ - use_clustering: DISABLE_CLUSTERING} + use_clustering: DISABLE_CLUSTERING, \ + can_dma_32: 1} #endif /* defined(HOSTS_C) || defined(MODULE) */ diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/drivers/scsi/sym53c8xx_2/sym_glue.c linux/drivers/scsi/sym53c8xx_2/sym_glue.c --- /opt/kernel/linux-2.4.15-pre5/drivers/scsi/sym53c8xx_2/sym_glue.c Fri Nov 16 08:11:21 2001 +++ linux/drivers/scsi/sym53c8xx_2/sym_glue.c Fri Nov 16 09:28:44 2001 @@ -2140,6 +2140,7 @@ instance->max_cmd_len = 16; #endif instance->select_queue_depths = sym53c8xx_select_queue_depths; + instance->can_dma_32 = 1; SYM_UNLOCK_HCB(np, flags); diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/fs/buffer.c linux/fs/buffer.c --- /opt/kernel/linux-2.4.15-pre5/fs/buffer.c Fri Nov 16 08:11:22 2001 +++ linux/fs/buffer.c Fri Nov 16 08:10:41 2001 @@ -1260,16 +1260,14 @@ void set_bh_page (struct buffer_head *bh, struct page *page, unsigned long offset) { - bh->b_page = page; if (offset >= PAGE_SIZE) BUG(); - if (PageHighMem(page)) - /* - * This catches illegal uses and preserves the offset: - */ - bh->b_data = (char *)(0 + offset); - else - bh->b_data = page_address(page) + offset; + + /* + * page_address will return NULL anyways for highmem pages + */ + bh->b_data = page_address(page) + offset; + bh->b_page = page; } EXPORT_SYMBOL(set_bh_page); diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/include/asm-alpha/io.h linux/include/asm-alpha/io.h --- /opt/kernel/linux-2.4.15-pre5/include/asm-alpha/io.h Fri Nov 16 08:11:22 2001 +++ linux/include/asm-alpha/io.h Mon Nov 12 11:56:20 2001 @@ -60,6 +60,8 @@ return (void *) (address + IDENT_ADDR); } +#define page_to_phys(page) (((page) - (page)->zone->zone_mem_map) << PAGE_SHIFT) + /* * Change addresses as seen by the kernel (virtual) to addresses as * seen by a device (bus), and vice versa. diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/include/asm-i386/kmap_types.h linux/include/asm-i386/kmap_types.h --- /opt/kernel/linux-2.4.15-pre5/include/asm-i386/kmap_types.h Mon Sep 17 22:16:30 2001 +++ linux/include/asm-i386/kmap_types.h Thu Oct 18 10:14:11 2001 @@ -7,6 +7,7 @@ KM_SKB_DATA_SOFTIRQ, KM_USER0, KM_USER1, + KM_BH_IRQ, KM_TYPE_NR }; diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/include/asm-i386/scatterlist.h linux/include/asm-i386/scatterlist.h --- /opt/kernel/linux-2.4.15-pre5/include/asm-i386/scatterlist.h Mon Nov 5 09:50:49 2001 +++ linux/include/asm-i386/scatterlist.h Thu Oct 18 10:14:11 2001 @@ -1,6 +1,24 @@ #ifndef _I386_SCATTERLIST_H #define _I386_SCATTERLIST_H +/* + * Drivers must set either ->address or (preferred) ->page and ->offset + * to indicate where data must be transferred to/from. + * + * Using ->page is recommended since it handles highmem data as well as + * low mem. ->address is restricted to data which has a virtual mapping, and + * it will go away in the future. Updating to ->page can be automated very + * easily -- something like + * + * sg->address = some_ptr; + * + * can be rewritten as + * + * sg->page = virt_to_page(some_ptr); + * sg->offset = (unsigned long) some_ptr & ~PAGE_MASK; + * + * and that's it. There's no excuse for not highmem enabling YOUR driver. /jens + */ struct scatterlist { char * address; /* Location data is to be transferred to, NULL for * highmem page */ diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/include/asm-parisc/pgtable.h linux/include/asm-parisc/pgtable.h --- /opt/kernel/linux-2.4.15-pre5/include/asm-parisc/pgtable.h Fri Nov 16 08:11:22 2001 +++ linux/include/asm-parisc/pgtable.h Mon Nov 12 11:56:20 2001 @@ -275,7 +275,7 @@ * Permanent address of a page. Obviously must never be * called on a highmem page. */ -#define page_address(page) ({ if (!(page)->virtual) BUG(); (page)->virtual; }) +#define page_address(page) ((page)->virtual) #define __page_address(page) ({ if (PageHighMem(page)) BUG(); PAGE_OFFSET + (((page) - mem_map) << PAGE_SHIFT); }) #define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT)) #define pte_page(x) (mem_map+pte_pagenr(x)) diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/include/asm-ppc/kmap_types.h linux/include/asm-ppc/kmap_types.h --- /opt/kernel/linux-2.4.15-pre5/include/asm-ppc/kmap_types.h Mon Sep 17 22:16:30 2001 +++ linux/include/asm-ppc/kmap_types.h Wed Oct 31 12:12:24 2001 @@ -11,6 +11,7 @@ KM_SKB_DATA_SOFTIRQ, KM_USER0, KM_USER1, + KM_BH_IRQ, KM_TYPE_NR }; diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/include/asm-sparc/kmap_types.h linux/include/asm-sparc/kmap_types.h --- /opt/kernel/linux-2.4.15-pre5/include/asm-sparc/kmap_types.h Mon Sep 17 22:16:30 2001 +++ linux/include/asm-sparc/kmap_types.h Wed Oct 31 12:13:11 2001 @@ -7,6 +7,7 @@ KM_SKB_DATA_SOFTIRQ, KM_USER0, KM_USER1, + KM_BH_IRQ, KM_TYPE_NR }; diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/include/linux/blkdev.h linux/include/linux/blkdev.h --- /opt/kernel/linux-2.4.15-pre5/include/linux/blkdev.h Tue Nov 13 08:53:04 2001 +++ linux/include/linux/blkdev.h Fri Nov 16 08:40:50 2001 @@ -7,6 +7,8 @@ #include #include +#include + struct request_queue; typedef struct request_queue request_queue_t; struct elevator_s; @@ -35,7 +37,7 @@ unsigned long hard_sector, hard_nr_sectors; unsigned int nr_segments; unsigned int nr_hw_segments; - unsigned long current_nr_sectors; + unsigned long current_nr_sectors, hard_cur_sectors; void * special; char * buffer; struct completion * waiting; @@ -112,6 +114,8 @@ */ char head_active; + unsigned long bounce_pfn; + /* * Is meant to protect the queue in the future instead of * io_request_lock @@ -124,6 +128,34 @@ wait_queue_head_t wait_for_request; }; +extern unsigned long blk_max_low_pfn, blk_max_pfn; + +#define BLK_BOUNCE_HIGH (blk_max_low_pfn << PAGE_SHIFT) +#define BLK_BOUNCE_ANY (blk_max_pfn << PAGE_SHIFT) + +extern void blk_queue_bounce_limit(request_queue_t *, u64); + +#ifdef CONFIG_HIGHMEM +extern struct buffer_head *create_bounce(int, struct buffer_head *); +extern inline struct buffer_head *blk_queue_bounce(request_queue_t *q, int rw, + struct buffer_head *bh) +{ + struct page *page = bh->b_page; + + if (page - page->zone->zone_mem_map <= q->bounce_pfn) + return bh; + + return create_bounce(rw, bh); +} +#else +#define blk_queue_bounce(q, rw, bh) (bh) +#endif + +#define bh_phys(bh) (page_to_phys((bh)->b_page) + bh_offset((bh))) + +#define BH_CONTIG(b1, b2) (bh_phys((b1)) + (b1)->b_size == bh_phys((b2))) +#define BH_PHYS_4G(b1, b2) ((bh_phys((b1)) | 0xffffffff) == ((bh_phys((b2)) + (b2)->b_size - 1) | 0xffffffff)) + struct blk_dev_struct { /* * queue_proc has to be atomic @@ -162,6 +194,8 @@ extern void blk_queue_headactive(request_queue_t *, int); extern void blk_queue_make_request(request_queue_t *, make_request_fn *); extern void generic_unplug_device(void *); +extern inline int blk_seg_merge_ok(request_queue_t *, struct buffer_head *, + struct buffer_head *); extern int * blk_size[MAX_BLKDEV]; diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/include/linux/bootmem.h linux/include/linux/bootmem.h --- /opt/kernel/linux-2.4.15-pre5/include/linux/bootmem.h Thu Oct 11 08:46:36 2001 +++ linux/include/linux/bootmem.h Fri Nov 16 08:31:33 2001 @@ -16,6 +16,7 @@ extern unsigned long max_low_pfn; extern unsigned long min_low_pfn; +extern unsigned long max_pfn; /* * node_bootmem_map is a map pointer - the bits represent all physical diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/include/linux/highmem.h linux/include/linux/highmem.h --- /opt/kernel/linux-2.4.15-pre5/include/linux/highmem.h Thu Oct 11 08:44:34 2001 +++ linux/include/linux/highmem.h Fri Nov 16 08:31:33 2001 @@ -13,8 +13,7 @@ /* declarations for linux/mm/highmem.c */ unsigned int nr_free_highpages(void); -extern struct buffer_head * create_bounce(int rw, struct buffer_head * bh_orig); - +extern struct buffer_head *create_bounce(int rw, struct buffer_head * bh_orig); static inline char *bh_kmap(struct buffer_head *bh) { @@ -26,6 +25,42 @@ kunmap(bh->b_page); } +/* + * remember to add offset! and never ever reenable interrupts between a + * bh_kmap_irq and bh_kunmap_irq!! + */ +static inline char *bh_kmap_irq(struct buffer_head *bh, unsigned long *flags) +{ + unsigned long addr; + + __save_flags(*flags); + + /* + * could be low + */ + if (!PageHighMem(bh->b_page)) + return bh->b_data; + + /* + * it's a highmem page + */ + __cli(); + addr = (unsigned long) kmap_atomic(bh->b_page, KM_BH_IRQ); + + if (addr & ~PAGE_MASK) + BUG(); + + return (char *) addr + bh_offset(bh); +} + +static inline void bh_kunmap_irq(char *buffer, unsigned long *flags) +{ + unsigned long ptr = (unsigned long) buffer & PAGE_MASK; + + kunmap_atomic((void *) ptr, KM_BH_IRQ); + __restore_flags(*flags); +} + #else /* CONFIG_HIGHMEM */ static inline unsigned int nr_free_highpages(void) { return 0; } @@ -37,8 +72,10 @@ #define kmap_atomic(page,idx) kmap(page) #define kunmap_atomic(page,idx) kunmap(page) -#define bh_kmap(bh) ((bh)->b_data) -#define bh_kunmap(bh) do { } while (0) +#define bh_kmap(bh) ((bh)->b_data) +#define bh_kunmap(bh) do { } while (0) +#define bh_kmap_irq(bh, flags) ((bh)->b_data) +#define bh_kunmap_irq(bh, flags) do { *(flags) = 0; } while (0) #endif /* CONFIG_HIGHMEM */ diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/include/linux/ide.h linux/include/linux/ide.h --- /opt/kernel/linux-2.4.15-pre5/include/linux/ide.h Thu Oct 11 08:47:07 2001 +++ linux/include/linux/ide.h Fri Nov 16 08:41:05 2001 @@ -507,6 +507,7 @@ unsigned reset : 1; /* reset after probe */ unsigned autodma : 1; /* automatically try to enable DMA at boot */ unsigned udma_four : 1; /* 1=ATA-66 capable, 0=default */ + unsigned highmem : 1; /* can do full 32-bit dma */ byte channel; /* for dual-port chips: 0=primary, 1=secondary */ #ifdef CONFIG_BLK_DEV_IDEPCI struct pci_dev *pci_dev; /* for pci chipsets */ @@ -812,6 +813,21 @@ ide_preempt, /* insert rq in front of current request */ ide_end /* insert rq at end of list, but don't wait for it */ } ide_action_t; + +/* + * temporarily mapping a (possible) highmem bio + */ +#define ide_rq_offset(rq) (((rq)->hard_cur_sectors - (rq)->current_nr_sectors) << 9) + +extern inline void *ide_map_buffer(struct request *rq, unsigned long *flags) +{ + return bh_kmap_irq(rq->bh, flags) + ide_rq_offset(rq); +} + +extern inline void ide_unmap_buffer(char *buffer, unsigned long *flags) +{ + bh_kunmap_irq(buffer, flags); +} /* * This function issues a special IDE device request diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/kernel/ksyms.c linux/kernel/ksyms.c --- /opt/kernel/linux-2.4.15-pre5/kernel/ksyms.c Tue Nov 13 08:53:04 2001 +++ linux/kernel/ksyms.c Mon Nov 12 11:53:50 2001 @@ -121,6 +121,8 @@ EXPORT_SYMBOL(kunmap_high); EXPORT_SYMBOL(highmem_start_page); EXPORT_SYMBOL(create_bounce); +EXPORT_SYMBOL(kmap_prot); +EXPORT_SYMBOL(kmap_pte); #endif /* filesystem internal functions */ diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.15-pre5/mm/bootmem.c linux/mm/bootmem.c --- /opt/kernel/linux-2.4.15-pre5/mm/bootmem.c Tue Sep 18 23:10:43 2001 +++ linux/mm/bootmem.c Wed Oct 31 09:04:25 2001 @@ -25,6 +25,7 @@ */ unsigned long max_low_pfn; unsigned long min_low_pfn; +unsigned long max_pfn; /* return the number of _pages_ that will be allocated for the boot bitmap */ unsigned long __init bootmem_bootmap_pages (unsigned long pages)