diff -ur -X exclude /opt/kernel/linux-2.5.2-pre3/drivers/block/elevator.c linux/drivers/block/elevator.c --- /opt/kernel/linux-2.5.2-pre3/drivers/block/elevator.c Sat Dec 29 12:17:53 2001 +++ linux/drivers/block/elevator.c Sat Dec 29 13:02:45 2001 @@ -165,12 +165,13 @@ while ((entry = entry->prev) != &q->queue_head) { __rq = list_entry_rq(entry); + if (__rq->flags & (REQ_BARRIER | REQ_STARTED)) + break; + /* * simply "aging" of requests in queue */ if (__rq->elevator_sequence-- <= 0) - break; - if (__rq->flags & (REQ_BARRIER | REQ_STARTED)) break; if (!(__rq->flags & REQ_CMD)) continue; diff -ur -X exclude /opt/kernel/linux-2.5.2-pre3/drivers/block/ll_rw_blk.c linux/drivers/block/ll_rw_blk.c --- /opt/kernel/linux-2.5.2-pre3/drivers/block/ll_rw_blk.c Sat Dec 29 12:17:53 2001 +++ linux/drivers/block/ll_rw_blk.c Sat Dec 29 12:45:04 2001 @@ -881,7 +881,9 @@ BUG_ON(rw != READ && rw != WRITE); + spin_lock_irq(q->queue_lock); rq = get_request(q, rw); + spin_unlock_irq(q->queue_lock); if (!rq && (gfp_mask & __GFP_WAIT)) rq = get_request_wait(q, rw); @@ -1081,7 +1083,7 @@ { struct request *req, *freereq = NULL; int el_ret, latency = 0, rw, nr_sectors, cur_nr_sectors, barrier; - struct list_head *insert_here = &q->queue_head; + struct list_head *insert_here; elevator_t *elevator = &q->elevator; sector_t sector; @@ -1103,15 +1105,14 @@ barrier = test_bit(BIO_RW_BARRIER, &bio->bi_rw); spin_lock_irq(q->queue_lock); +again: + req = NULL; + insert_here = q->queue_head.prev; if (blk_queue_empty(q) || barrier) { blk_plug_device(q); goto get_rq; } - -again: - req = NULL; - insert_here = q->queue_head.prev; el_ret = elevator->elevator_merge_fn(q, &req, bio); switch (el_ret) { diff -ur -X exclude /opt/kernel/linux-2.5.2-pre3/drivers/cdrom/cdu31a.c linux/drivers/cdrom/cdu31a.c --- /opt/kernel/linux-2.5.2-pre3/drivers/cdrom/cdu31a.c Tue Nov 27 12:23:27 2001 +++ linux/drivers/cdrom/cdu31a.c Sat Dec 29 10:08:01 2001 @@ -237,6 +237,7 @@ static volatile unsigned short sony_cd_read_reg; static volatile unsigned short sony_cd_fifost_reg; +static spinlock_t cdu31a_lock = SPIN_LOCK_UNLOCKED; /* queue lock */ static int sony_spun_up = 0; /* Has the drive been spun up? */ @@ -1605,17 +1606,7 @@ scd_spinup(); } - /* I don't use INIT_REQUEST because it calls return, which would - return without unlocking the device. It shouldn't matter, - but just to be safe... */ - if (MAJOR(CURRENT->rq_dev) != MAJOR_NR) { - panic(DEVICE_NAME ": request list destroyed"); - } - if (CURRENT->bh) { - if (!buffer_locked(CURRENT->bh)) { - panic(DEVICE_NAME ": block not locked"); - } - } + INIT_REQUEST; block = CURRENT->sector; nblock = CURRENT->nr_sectors; @@ -1626,112 +1617,105 @@ goto cdu31a_request_startover; } - switch (CURRENT->cmd) { - case READ: - /* - * If the block address is invalid or the request goes beyond the end of - * the media, return an error. - */ -#if 0 - if ((block / 4) < sony_toc.start_track_lba) { - printk - ("CDU31A: Request before beginning of media\n"); - end_request(0); - goto cdu31a_request_startover; - } -#endif - if ((block / 4) >= sony_toc.lead_out_start_lba) { - printk - ("CDU31A: Request past end of media\n"); - end_request(0); - goto cdu31a_request_startover; - } - if (((block + nblock) / 4) >= - sony_toc.lead_out_start_lba) { - printk - ("CDU31A: Request past end of media\n"); - end_request(0); - goto cdu31a_request_startover; - } - - num_retries = 0; - - try_read_again: - while (handle_sony_cd_attention()); - - if (!sony_toc_read) { - printk("CDU31A: TOC not read\n"); - end_request(0); - goto cdu31a_request_startover; - } - - /* If no data is left to be read from the drive, start the - next request. */ - if (sony_blocks_left == 0) { - if (start_request - (block / 4, CDU31A_READAHEAD / 4, 0)) { - end_request(0); - goto cdu31a_request_startover; - } - } - /* If the requested block is not the next one waiting in - the driver, abort the current operation and start a - new one. */ - else if (block != sony_next_block) { -#if DEBUG - printk - ("CDU31A Warning: Read for block %d, expected %d\n", - block, sony_next_block); -#endif - abort_read(); - if (!sony_toc_read) { - printk("CDU31A: TOC not read\n"); + if(CURRENT->flags & REQ_CMD) { + switch (rq_data_dir(CURRENT)) { + case READ: + /* + * If the block address is invalid or the request goes beyond the end of + * the media, return an error. + */ + if ((block / 4) >= sony_toc.lead_out_start_lba) { + printk + ("CDU31A: Request past end of media\n"); end_request(0); goto cdu31a_request_startover; } - if (start_request - (block / 4, CDU31A_READAHEAD / 4, 0)) { + if (((block + nblock) / 4) >= + sony_toc.lead_out_start_lba) { printk - ("CDU31a: start request failed\n"); + ("CDU31A: Request past end of media\n"); end_request(0); goto cdu31a_request_startover; } - } - read_data_block(CURRENT->buffer, block, nblock, - res_reg, &res_size); - if (res_reg[0] == 0x20) { - if (num_retries > MAX_CDU31A_RETRIES) { + num_retries = 0; + + try_read_again: + while (handle_sony_cd_attention()); + + if (!sony_toc_read) { + printk("CDU31A: TOC not read\n"); end_request(0); goto cdu31a_request_startover; } - num_retries++; - if (res_reg[1] == SONY_NOT_SPIN_ERR) { - do_sony_cd_cmd(SONY_SPIN_UP_CMD, - NULL, 0, res_reg, - &res_size); - } else { + /* If no data is left to be read from the drive, start the + next request. */ + if (sony_blocks_left == 0) { + if (start_request + (block / 4, CDU31A_READAHEAD / 4, 0)) { + end_request(0); + goto cdu31a_request_startover; + } + } + /* If the requested block is not the next one waiting in + the driver, abort the current operation and start a + new one. */ + else if (block != sony_next_block) { +#if DEBUG printk - ("CDU31A: %s error for block %d, nblock %d\n", - translate_error(res_reg[1]), - block, nblock); + ("CDU31A Warning: Read for block %d, expected %d\n", + block, sony_next_block); +#endif + abort_read(); + if (!sony_toc_read) { + printk("CDU31A: TOC not read\n"); + end_request(0); + goto cdu31a_request_startover; + } + if (start_request + (block / 4, CDU31A_READAHEAD / 4, 0)) { + printk + ("CDU31a: start request failed\n"); + end_request(0); + goto cdu31a_request_startover; + } } - goto try_read_again; - } else { - end_request(1); - } - break; - case WRITE: - end_request(0); - break; + read_data_block(CURRENT->buffer, block, nblock, + res_reg, &res_size); + if (res_reg[0] == 0x20) { + if (num_retries > MAX_CDU31A_RETRIES) { + end_request(0); + goto cdu31a_request_startover; + } - default: - panic("CDU31A: Unknown cmd"); + num_retries++; + if (res_reg[1] == SONY_NOT_SPIN_ERR) { + do_sony_cd_cmd(SONY_SPIN_UP_CMD, + NULL, 0, res_reg, + &res_size); + } else { + printk + ("CDU31A: %s error for block %d, nblock %d\n", + translate_error(res_reg[1]), + block, nblock); + } + goto try_read_again; + } else { + end_request(1); + } + break; + + case WRITE: + end_request(0); + break; + + default: + panic("CDU31A: Unknown cmd"); + } } } - end_do_cdu31a_request: spin_lock_irq(&q->queue_lock); #if 0 @@ -3456,7 +3440,8 @@ strcmp("CD-ROM CDU31A", drive_config.product_id) == 0; blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), - DEVICE_REQUEST); + DEVICE_REQUEST, + &cdu31a_lock); read_ahead[MAJOR_NR] = CDU31A_READAHEAD; cdu31a_block_size = 1024; /* 1kB default block size */ /* use 'mount -o block=2048' */ diff -ur -X exclude /opt/kernel/linux-2.5.2-pre3/drivers/scsi/aha1542.c linux/drivers/scsi/aha1542.c --- /opt/kernel/linux-2.5.2-pre3/drivers/scsi/aha1542.c Fri Oct 12 18:35:53 2001 +++ linux/drivers/scsi/aha1542.c Sat Dec 29 10:08:01 2001 @@ -67,10 +67,10 @@ int nseg, int badseg) { - printk(KERN_CRIT "sgpnt[%d:%d] addr %p/0x%lx length %d\n", + printk(KERN_CRIT "sgpnt[%d:%d] page %p/0x%lx length %d\n", badseg, nseg, - sgpnt[badseg].address, - SCSI_PA(sgpnt[badseg].address), + page_address(sgpnt[badseg].page) + sgpnt[badseg].offset, + (unsigned long)page_to_bus(sgpnt[badseg].page) + sgpnt[badseg].offset, sgpnt[badseg].length); /* @@ -176,7 +176,7 @@ static void setup_mailboxes(int base_io, struct Scsi_Host *shpnt); static int aha1542_restart(struct Scsi_Host *shost); -static void aha1542_intr_handle(int irq, void *dev_id, struct pt_regs *regs); +static void aha1542_intr_handle(struct Scsi_Host *shost, void *dev_id, struct pt_regs *regs); static void do_aha1542_intr_handle(int irq, void *dev_id, struct pt_regs *regs); #define aha1542_intr_reset(base) outb(IRST, CONTROL(base)) @@ -419,30 +419,30 @@ static void do_aha1542_intr_handle(int irq, void *dev_id, struct pt_regs *regs) { unsigned long flags; + struct Scsi_Host *shost; + + shost = aha_host[irq - 9]; + if (!shost) + panic("Splunge!"); - spin_lock_irqsave(&io_request_lock, flags); - aha1542_intr_handle(irq, dev_id, regs); - spin_unlock_irqrestore(&io_request_lock, flags); + spin_lock_irqsave(&shost->host_lock, flags); + aha1542_intr_handle(shost, dev_id, regs); + spin_unlock_irqrestore(&shost->host_lock, flags); } /* A "high" level interrupt handler */ -static void aha1542_intr_handle(int irq, void *dev_id, struct pt_regs *regs) +static void aha1542_intr_handle(struct Scsi_Host *shost, void *dev_id, struct pt_regs *regs) { void (*my_done) (Scsi_Cmnd *) = NULL; int errstatus, mbi, mbo, mbistatus; int number_serviced; unsigned long flags; - struct Scsi_Host *shost; Scsi_Cmnd *SCtmp; int flag; int needs_restart; struct mailbox *mb; struct ccb *ccb; - shost = aha_host[irq - 9]; - if (!shost) - panic("Splunge!"); - mb = HOSTDATA(shost)->mb; ccb = HOSTDATA(shost)->ccb; @@ -542,7 +542,7 @@ } my_done = SCtmp->scsi_done; if (SCtmp->host_scribble) { - scsi_free(SCtmp->host_scribble, 512); + kfree(SCtmp->host_scribble); SCtmp->host_scribble = 0; } /* Fetch the sense data, and tuck it away, in the required slot. The @@ -703,18 +703,19 @@ #endif int i; ccb[mbo].op = 2; /* SCSI Initiator Command w/scatter-gather */ - SCpnt->host_scribble = (unsigned char *) scsi_malloc(512); + SCpnt->host_scribble = (unsigned char *) kmalloc(512, GFP_DMA); sgpnt = (struct scatterlist *) SCpnt->request_buffer; cptr = (struct chain *) SCpnt->host_scribble; if (cptr == NULL) panic("aha1542.c: unable to allocate DMA memory\n"); for (i = 0; i < SCpnt->use_sg; i++) { if (sgpnt[i].length == 0 || SCpnt->use_sg > 16 || - (((int) sgpnt[i].address) & 1) || (sgpnt[i].length & 1)) { + (((int) sgpnt[i].offset) & 1) || (sgpnt[i].length & 1)) { unsigned char *ptr; printk(KERN_CRIT "Bad segment list supplied to aha1542.c (%d, %d)\n", SCpnt->use_sg, i); for (i = 0; i < SCpnt->use_sg; i++) { - printk(KERN_CRIT "%d: %p %d\n", i, sgpnt[i].address, + printk(KERN_CRIT "%d: %p %d\n", i, + page_address(sgpnt[i].page) + sgpnt[i].offset, sgpnt[i].length); }; printk(KERN_CRIT "cptr %x: ", (unsigned int) cptr); @@ -723,8 +724,8 @@ printk("%02x ", ptr[i]); panic("Foooooooood fight!"); }; - any2scsi(cptr[i].dataptr, SCSI_PA(sgpnt[i].address)); - if (SCSI_PA(sgpnt[i].address + sgpnt[i].length - 1) > ISA_DMA_THRESHOLD) + any2scsi(cptr[i].dataptr, page_to_bus(sgpnt[i].page) + sgpnt[i].offset); + if (page_to_bus(sgpnt[i].page) + sgpnt[i].offset + sgpnt[i].length - 1 > ISA_DMA_THRESHOLD) BAD_SG_DMA(SCpnt, sgpnt, SCpnt->use_sg, i); any2scsi(cptr[i].datalen, sgpnt[i].length); }; @@ -1442,7 +1443,7 @@ Scsi_Cmnd *SCtmp; SCtmp = HOSTDATA(SCpnt->host)->SCint[i]; if (SCtmp->host_scribble) { - scsi_free(SCtmp->host_scribble, 512); + kfree(SCtmp->host_scribble); SCtmp->host_scribble = NULL; } HOSTDATA(SCpnt->host)->SCint[i] = NULL; @@ -1474,9 +1475,9 @@ * check for timeout, and if we are doing something like this * we are pretty desperate anyways. */ - spin_unlock_irq(&io_request_lock); + spin_unlock_irq(&SCpnt->host->host_lock); scsi_sleep(4 * HZ); - spin_lock_irq(&io_request_lock); + spin_lock_irq(&SCpnt->host->host_lock); WAIT(STATUS(SCpnt->host->io_port), STATMASK, INIT | IDLE, STST | DIAGF | INVDCMD | DF | CDF); @@ -1505,7 +1506,7 @@ continue; } if (SCtmp->host_scribble) { - scsi_free(SCtmp->host_scribble, 512); + kfree(SCtmp->host_scribble); SCtmp->host_scribble = NULL; } HOSTDATA(SCpnt->host)->SCint[i] = NULL; @@ -1538,9 +1539,9 @@ * check for timeout, and if we are doing something like this * we are pretty desperate anyways. */ - spin_unlock_irq(&io_request_lock); + spin_unlock_irq(&SCpnt->host->host_lock); scsi_sleep(4 * HZ); - spin_lock_irq(&io_request_lock); + spin_lock_irq(&SCpnt->host->host_lock); WAIT(STATUS(SCpnt->host->io_port), STATMASK, INIT | IDLE, STST | DIAGF | INVDCMD | DF | CDF); @@ -1574,7 +1575,7 @@ continue; } if (SCtmp->host_scribble) { - scsi_free(SCtmp->host_scribble, 512); + kfree(SCtmp->host_scribble); SCtmp->host_scribble = NULL; } HOSTDATA(SCpnt->host)->SCint[i] = NULL; @@ -1623,7 +1624,7 @@ if (mb[mbi].status) { printk(KERN_ERR "Lost interrupt discovered on irq %d - attempting to recover\n", SCpnt->host->irq); - aha1542_intr_handle(SCpnt->host->irq, NULL); + aha1542_intr_handle(SCpnt->host, NULL); return 0; } /* OK, no lost interrupt. Try looking to see how many pending commands @@ -1712,7 +1713,7 @@ SCtmp = HOSTDATA(SCpnt->host)->SCint[i]; SCtmp->result = DID_RESET << 16; if (SCtmp->host_scribble) { - scsi_free(SCtmp->host_scribble, 512); + kfree(SCtmp->host_scribble); SCtmp->host_scribble = NULL; } printk(KERN_WARNING "Sending DID_RESET for target %d\n", SCpnt->target); @@ -1758,7 +1759,7 @@ SCtmp = HOSTDATA(SCpnt->host)->SCint[i]; SCtmp->result = DID_RESET << 16; if (SCtmp->host_scribble) { - scsi_free(SCtmp->host_scribble, 512); + kfree(SCtmp->host_scribble); SCtmp->host_scribble = NULL; } printk(KERN_WARNING "Sending DID_RESET for target %d\n", SCpnt->target); diff -ur -X exclude /opt/kernel/linux-2.5.2-pre3/drivers/scsi/ide-scsi.c linux/drivers/scsi/ide-scsi.c --- /opt/kernel/linux-2.5.2-pre3/drivers/scsi/ide-scsi.c Sat Dec 29 12:17:53 2001 +++ linux/drivers/scsi/ide-scsi.c Sat Dec 29 10:14:32 2001 @@ -841,7 +841,7 @@ static Scsi_Host_Template idescsi_template = { module: THIS_MODULE, - name: "idescsi" + name: "idescsi", detect: idescsi_detect, release: idescsi_release, info: idescsi_info, diff -ur -X exclude /opt/kernel/linux-2.5.2-pre3/include/linux/blkdev.h linux/include/linux/blkdev.h --- /opt/kernel/linux-2.5.2-pre3/include/linux/blkdev.h Sat Dec 29 12:17:56 2001 +++ linux/include/linux/blkdev.h Sat Dec 29 10:10:56 2001 @@ -228,8 +228,8 @@ * BLK_BOUNCE_ANY : don't bounce anything * BLK_BOUNCE_ISA : bounce pages above ISA DMA boundary */ -#define BLK_BOUNCE_HIGH ((blk_max_low_pfn + 1) << PAGE_SHIFT) -#define BLK_BOUNCE_ANY ((blk_max_pfn + 1) << PAGE_SHIFT) +#define BLK_BOUNCE_HIGH (blk_max_low_pfn << PAGE_SHIFT) +#define BLK_BOUNCE_ANY (blk_max_pfn << PAGE_SHIFT) #define BLK_BOUNCE_ISA (ISA_DMA_THRESHOLD) extern int init_emergency_isa_pool(void);