diff options
Diffstat (limited to 'drivers')
88 files changed, 522 insertions, 646 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 68699b3e7998..bbaa545ea999 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -1410,7 +1410,7 @@ static void ata_qc_complete_internal(struct ata_queued_cmd *qc) | |||
1410 | */ | 1410 | */ |
1411 | unsigned ata_exec_internal_sg(struct ata_device *dev, | 1411 | unsigned ata_exec_internal_sg(struct ata_device *dev, |
1412 | struct ata_taskfile *tf, const u8 *cdb, | 1412 | struct ata_taskfile *tf, const u8 *cdb, |
1413 | int dma_dir, struct scatterlist *sg, | 1413 | int dma_dir, struct scatterlist *sgl, |
1414 | unsigned int n_elem, unsigned long timeout) | 1414 | unsigned int n_elem, unsigned long timeout) |
1415 | { | 1415 | { |
1416 | struct ata_link *link = dev->link; | 1416 | struct ata_link *link = dev->link; |
@@ -1472,11 +1472,12 @@ unsigned ata_exec_internal_sg(struct ata_device *dev, | |||
1472 | qc->dma_dir = dma_dir; | 1472 | qc->dma_dir = dma_dir; |
1473 | if (dma_dir != DMA_NONE) { | 1473 | if (dma_dir != DMA_NONE) { |
1474 | unsigned int i, buflen = 0; | 1474 | unsigned int i, buflen = 0; |
1475 | struct scatterlist *sg; | ||
1475 | 1476 | ||
1476 | for (i = 0; i < n_elem; i++) | 1477 | for_each_sg(sgl, sg, n_elem, i) |
1477 | buflen += sg[i].length; | 1478 | buflen += sg->length; |
1478 | 1479 | ||
1479 | ata_sg_init(qc, sg, n_elem); | 1480 | ata_sg_init(qc, sgl, n_elem); |
1480 | qc->nbytes = buflen; | 1481 | qc->nbytes = buflen; |
1481 | } | 1482 | } |
1482 | 1483 | ||
@@ -4292,7 +4293,7 @@ void ata_sg_clean(struct ata_queued_cmd *qc) | |||
4292 | if (qc->n_elem) | 4293 | if (qc->n_elem) |
4293 | dma_unmap_sg(ap->dev, sg, qc->n_elem, dir); | 4294 | dma_unmap_sg(ap->dev, sg, qc->n_elem, dir); |
4294 | /* restore last sg */ | 4295 | /* restore last sg */ |
4295 | sg[qc->orig_n_elem - 1].length += qc->pad_len; | 4296 | sg_last(sg, qc->orig_n_elem)->length += qc->pad_len; |
4296 | if (pad_buf) { | 4297 | if (pad_buf) { |
4297 | struct scatterlist *psg = &qc->pad_sgent; | 4298 | struct scatterlist *psg = &qc->pad_sgent; |
4298 | void *addr = kmap_atomic(psg->page, KM_IRQ0); | 4299 | void *addr = kmap_atomic(psg->page, KM_IRQ0); |
@@ -4547,6 +4548,7 @@ void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen) | |||
4547 | qc->orig_n_elem = 1; | 4548 | qc->orig_n_elem = 1; |
4548 | qc->buf_virt = buf; | 4549 | qc->buf_virt = buf; |
4549 | qc->nbytes = buflen; | 4550 | qc->nbytes = buflen; |
4551 | qc->cursg = qc->__sg; | ||
4550 | 4552 | ||
4551 | sg_init_one(&qc->sgent, buf, buflen); | 4553 | sg_init_one(&qc->sgent, buf, buflen); |
4552 | } | 4554 | } |
@@ -4572,6 +4574,7 @@ void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, | |||
4572 | qc->__sg = sg; | 4574 | qc->__sg = sg; |
4573 | qc->n_elem = n_elem; | 4575 | qc->n_elem = n_elem; |
4574 | qc->orig_n_elem = n_elem; | 4576 | qc->orig_n_elem = n_elem; |
4577 | qc->cursg = qc->__sg; | ||
4575 | } | 4578 | } |
4576 | 4579 | ||
4577 | /** | 4580 | /** |
@@ -4661,7 +4664,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc) | |||
4661 | { | 4664 | { |
4662 | struct ata_port *ap = qc->ap; | 4665 | struct ata_port *ap = qc->ap; |
4663 | struct scatterlist *sg = qc->__sg; | 4666 | struct scatterlist *sg = qc->__sg; |
4664 | struct scatterlist *lsg = &sg[qc->n_elem - 1]; | 4667 | struct scatterlist *lsg = sg_last(qc->__sg, qc->n_elem); |
4665 | int n_elem, pre_n_elem, dir, trim_sg = 0; | 4668 | int n_elem, pre_n_elem, dir, trim_sg = 0; |
4666 | 4669 | ||
4667 | VPRINTK("ENTER, ata%u\n", ap->print_id); | 4670 | VPRINTK("ENTER, ata%u\n", ap->print_id); |
@@ -4825,7 +4828,6 @@ void ata_data_xfer_noirq(struct ata_device *adev, unsigned char *buf, | |||
4825 | static void ata_pio_sector(struct ata_queued_cmd *qc) | 4828 | static void ata_pio_sector(struct ata_queued_cmd *qc) |
4826 | { | 4829 | { |
4827 | int do_write = (qc->tf.flags & ATA_TFLAG_WRITE); | 4830 | int do_write = (qc->tf.flags & ATA_TFLAG_WRITE); |
4828 | struct scatterlist *sg = qc->__sg; | ||
4829 | struct ata_port *ap = qc->ap; | 4831 | struct ata_port *ap = qc->ap; |
4830 | struct page *page; | 4832 | struct page *page; |
4831 | unsigned int offset; | 4833 | unsigned int offset; |
@@ -4834,8 +4836,8 @@ static void ata_pio_sector(struct ata_queued_cmd *qc) | |||
4834 | if (qc->curbytes == qc->nbytes - qc->sect_size) | 4836 | if (qc->curbytes == qc->nbytes - qc->sect_size) |
4835 | ap->hsm_task_state = HSM_ST_LAST; | 4837 | ap->hsm_task_state = HSM_ST_LAST; |
4836 | 4838 | ||
4837 | page = sg[qc->cursg].page; | 4839 | page = qc->cursg->page; |
4838 | offset = sg[qc->cursg].offset + qc->cursg_ofs; | 4840 | offset = qc->cursg->offset + qc->cursg_ofs; |
4839 | 4841 | ||
4840 | /* get the current page and offset */ | 4842 | /* get the current page and offset */ |
4841 | page = nth_page(page, (offset >> PAGE_SHIFT)); | 4843 | page = nth_page(page, (offset >> PAGE_SHIFT)); |
@@ -4863,8 +4865,8 @@ static void ata_pio_sector(struct ata_queued_cmd *qc) | |||
4863 | qc->curbytes += qc->sect_size; | 4865 | qc->curbytes += qc->sect_size; |
4864 | qc->cursg_ofs += qc->sect_size; | 4866 | qc->cursg_ofs += qc->sect_size; |
4865 | 4867 | ||
4866 | if (qc->cursg_ofs == (&sg[qc->cursg])->length) { | 4868 | if (qc->cursg_ofs == qc->cursg->length) { |
4867 | qc->cursg++; | 4869 | qc->cursg = sg_next(qc->cursg); |
4868 | qc->cursg_ofs = 0; | 4870 | qc->cursg_ofs = 0; |
4869 | } | 4871 | } |
4870 | } | 4872 | } |
@@ -4950,16 +4952,18 @@ static void __atapi_pio_bytes(struct ata_queued_cmd *qc, unsigned int bytes) | |||
4950 | { | 4952 | { |
4951 | int do_write = (qc->tf.flags & ATA_TFLAG_WRITE); | 4953 | int do_write = (qc->tf.flags & ATA_TFLAG_WRITE); |
4952 | struct scatterlist *sg = qc->__sg; | 4954 | struct scatterlist *sg = qc->__sg; |
4955 | struct scatterlist *lsg = sg_last(qc->__sg, qc->n_elem); | ||
4953 | struct ata_port *ap = qc->ap; | 4956 | struct ata_port *ap = qc->ap; |
4954 | struct page *page; | 4957 | struct page *page; |
4955 | unsigned char *buf; | 4958 | unsigned char *buf; |
4956 | unsigned int offset, count; | 4959 | unsigned int offset, count; |
4960 | int no_more_sg = 0; | ||
4957 | 4961 | ||
4958 | if (qc->curbytes + bytes >= qc->nbytes) | 4962 | if (qc->curbytes + bytes >= qc->nbytes) |
4959 | ap->hsm_task_state = HSM_ST_LAST; | 4963 | ap->hsm_task_state = HSM_ST_LAST; |
4960 | 4964 | ||
4961 | next_sg: | 4965 | next_sg: |
4962 | if (unlikely(qc->cursg >= qc->n_elem)) { | 4966 | if (unlikely(no_more_sg)) { |
4963 | /* | 4967 | /* |
4964 | * The end of qc->sg is reached and the device expects | 4968 | * The end of qc->sg is reached and the device expects |
4965 | * more data to transfer. In order not to overrun qc->sg | 4969 | * more data to transfer. In order not to overrun qc->sg |
@@ -4982,7 +4986,7 @@ next_sg: | |||
4982 | return; | 4986 | return; |
4983 | } | 4987 | } |
4984 | 4988 | ||
4985 | sg = &qc->__sg[qc->cursg]; | 4989 | sg = qc->cursg; |
4986 | 4990 | ||
4987 | page = sg->page; | 4991 | page = sg->page; |
4988 | offset = sg->offset + qc->cursg_ofs; | 4992 | offset = sg->offset + qc->cursg_ofs; |
@@ -5021,7 +5025,10 @@ next_sg: | |||
5021 | qc->cursg_ofs += count; | 5025 | qc->cursg_ofs += count; |
5022 | 5026 | ||
5023 | if (qc->cursg_ofs == sg->length) { | 5027 | if (qc->cursg_ofs == sg->length) { |
5024 | qc->cursg++; | 5028 | if (qc->cursg == lsg) |
5029 | no_more_sg = 1; | ||
5030 | |||
5031 | qc->cursg = sg_next(qc->cursg); | ||
5025 | qc->cursg_ofs = 0; | 5032 | qc->cursg_ofs = 0; |
5026 | } | 5033 | } |
5027 | 5034 | ||
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 5237a491622b..9fbb39cd0f58 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
@@ -801,8 +801,6 @@ int ata_scsi_slave_config(struct scsi_device *sdev) | |||
801 | 801 | ||
802 | ata_scsi_sdev_config(sdev); | 802 | ata_scsi_sdev_config(sdev); |
803 | 803 | ||
804 | blk_queue_max_phys_segments(sdev->request_queue, LIBATA_MAX_PRD); | ||
805 | |||
806 | sdev->manage_start_stop = 1; | 804 | sdev->manage_start_stop = 1; |
807 | 805 | ||
808 | if (dev) | 806 | if (dev) |
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 55c3237fb1bc..3fb7e8bc436d 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c | |||
@@ -1191,7 +1191,6 @@ static inline void complete_buffers(struct bio *bio, int status) | |||
1191 | { | 1191 | { |
1192 | while (bio) { | 1192 | while (bio) { |
1193 | struct bio *xbh = bio->bi_next; | 1193 | struct bio *xbh = bio->bi_next; |
1194 | int nr_sectors = bio_sectors(bio); | ||
1195 | 1194 | ||
1196 | bio->bi_next = NULL; | 1195 | bio->bi_next = NULL; |
1197 | bio_endio(bio, status ? 0 : -EIO); | 1196 | bio_endio(bio, status ? 0 : -EIO); |
@@ -2570,6 +2569,7 @@ static void do_cciss_request(struct request_queue *q) | |||
2570 | (int)creq->nr_sectors); | 2569 | (int)creq->nr_sectors); |
2571 | #endif /* CCISS_DEBUG */ | 2570 | #endif /* CCISS_DEBUG */ |
2572 | 2571 | ||
2572 | memset(tmp_sg, 0, sizeof(tmp_sg)); | ||
2573 | seg = blk_rq_map_sg(q, creq, tmp_sg); | 2573 | seg = blk_rq_map_sg(q, creq, tmp_sg); |
2574 | 2574 | ||
2575 | /* get the DMA records for the setup */ | 2575 | /* get the DMA records for the setup */ |
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c index 3853c9a38d6a..568603d3043e 100644 --- a/drivers/block/cpqarray.c +++ b/drivers/block/cpqarray.c | |||
@@ -981,9 +981,8 @@ static void start_io(ctlr_info_t *h) | |||
981 | static inline void complete_buffers(struct bio *bio, int ok) | 981 | static inline void complete_buffers(struct bio *bio, int ok) |
982 | { | 982 | { |
983 | struct bio *xbh; | 983 | struct bio *xbh; |
984 | while(bio) { | ||
985 | int nr_sectors = bio_sectors(bio); | ||
986 | 984 | ||
985 | while (bio) { | ||
987 | xbh = bio->bi_next; | 986 | xbh = bio->bi_next; |
988 | bio->bi_next = NULL; | 987 | bio->bi_next = NULL; |
989 | 988 | ||
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 540bf3676985..a8130a4ad6d4 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c | |||
@@ -1133,16 +1133,21 @@ static void pkt_gather_data(struct pktcdvd_device *pd, struct packet_data *pkt) | |||
1133 | * Schedule reads for missing parts of the packet. | 1133 | * Schedule reads for missing parts of the packet. |
1134 | */ | 1134 | */ |
1135 | for (f = 0; f < pkt->frames; f++) { | 1135 | for (f = 0; f < pkt->frames; f++) { |
1136 | struct bio_vec *vec; | ||
1137 | |||
1136 | int p, offset; | 1138 | int p, offset; |
1137 | if (written[f]) | 1139 | if (written[f]) |
1138 | continue; | 1140 | continue; |
1139 | bio = pkt->r_bios[f]; | 1141 | bio = pkt->r_bios[f]; |
1142 | vec = bio->bi_io_vec; | ||
1140 | bio_init(bio); | 1143 | bio_init(bio); |
1141 | bio->bi_max_vecs = 1; | 1144 | bio->bi_max_vecs = 1; |
1142 | bio->bi_sector = pkt->sector + f * (CD_FRAMESIZE >> 9); | 1145 | bio->bi_sector = pkt->sector + f * (CD_FRAMESIZE >> 9); |
1143 | bio->bi_bdev = pd->bdev; | 1146 | bio->bi_bdev = pd->bdev; |
1144 | bio->bi_end_io = pkt_end_io_read; | 1147 | bio->bi_end_io = pkt_end_io_read; |
1145 | bio->bi_private = pkt; | 1148 | bio->bi_private = pkt; |
1149 | bio->bi_io_vec = vec; | ||
1150 | bio->bi_destructor = pkt_bio_destructor; | ||
1146 | 1151 | ||
1147 | p = (f * CD_FRAMESIZE) / PAGE_SIZE; | 1152 | p = (f * CD_FRAMESIZE) / PAGE_SIZE; |
1148 | offset = (f * CD_FRAMESIZE) % PAGE_SIZE; | 1153 | offset = (f * CD_FRAMESIZE) % PAGE_SIZE; |
@@ -1439,6 +1444,8 @@ static void pkt_start_write(struct pktcdvd_device *pd, struct packet_data *pkt) | |||
1439 | pkt->w_bio->bi_bdev = pd->bdev; | 1444 | pkt->w_bio->bi_bdev = pd->bdev; |
1440 | pkt->w_bio->bi_end_io = pkt_end_io_packet_write; | 1445 | pkt->w_bio->bi_end_io = pkt_end_io_packet_write; |
1441 | pkt->w_bio->bi_private = pkt; | 1446 | pkt->w_bio->bi_private = pkt; |
1447 | pkt->w_bio->bi_io_vec = bvec; | ||
1448 | pkt->w_bio->bi_destructor = pkt_bio_destructor; | ||
1442 | for (f = 0; f < pkt->frames; f++) | 1449 | for (f = 0; f < pkt->frames; f++) |
1443 | if (!bio_add_page(pkt->w_bio, bvec[f].bv_page, CD_FRAMESIZE, bvec[f].bv_offset)) | 1450 | if (!bio_add_page(pkt->w_bio, bvec[f].bv_page, CD_FRAMESIZE, bvec[f].bv_offset)) |
1444 | BUG(); | 1451 | BUG(); |
diff --git a/drivers/block/ps3disk.c b/drivers/block/ps3disk.c index 06d0552cf49c..e354bfc070e1 100644 --- a/drivers/block/ps3disk.c +++ b/drivers/block/ps3disk.c | |||
@@ -414,26 +414,6 @@ static void ps3disk_prepare_flush(struct request_queue *q, struct request *req) | |||
414 | req->cmd_type = REQ_TYPE_FLUSH; | 414 | req->cmd_type = REQ_TYPE_FLUSH; |
415 | } | 415 | } |
416 | 416 | ||
417 | static int ps3disk_issue_flush(struct request_queue *q, struct gendisk *gendisk, | ||
418 | sector_t *sector) | ||
419 | { | ||
420 | struct ps3_storage_device *dev = q->queuedata; | ||
421 | struct request *req; | ||
422 | int res; | ||
423 | |||
424 | dev_dbg(&dev->sbd.core, "%s:%u\n", __func__, __LINE__); | ||
425 | |||
426 | req = blk_get_request(q, WRITE, __GFP_WAIT); | ||
427 | ps3disk_prepare_flush(q, req); | ||
428 | res = blk_execute_rq(q, gendisk, req, 0); | ||
429 | if (res) | ||
430 | dev_err(&dev->sbd.core, "%s:%u: flush request failed %d\n", | ||
431 | __func__, __LINE__, res); | ||
432 | blk_put_request(req); | ||
433 | return res; | ||
434 | } | ||
435 | |||
436 | |||
437 | static unsigned long ps3disk_mask; | 417 | static unsigned long ps3disk_mask; |
438 | 418 | ||
439 | static DEFINE_MUTEX(ps3disk_mask_mutex); | 419 | static DEFINE_MUTEX(ps3disk_mask_mutex); |
@@ -506,7 +486,6 @@ static int __devinit ps3disk_probe(struct ps3_system_bus_device *_dev) | |||
506 | blk_queue_dma_alignment(queue, dev->blk_size-1); | 486 | blk_queue_dma_alignment(queue, dev->blk_size-1); |
507 | blk_queue_hardsect_size(queue, dev->blk_size); | 487 | blk_queue_hardsect_size(queue, dev->blk_size); |
508 | 488 | ||
509 | blk_queue_issue_flush_fn(queue, ps3disk_issue_flush); | ||
510 | blk_queue_ordered(queue, QUEUE_ORDERED_DRAIN_FLUSH, | 489 | blk_queue_ordered(queue, QUEUE_ORDERED_DRAIN_FLUSH, |
511 | ps3disk_prepare_flush); | 490 | ps3disk_prepare_flush); |
512 | 491 | ||
diff --git a/drivers/ide/cris/ide-cris.c b/drivers/ide/cris/ide-cris.c index 2b4d2a0ae5c2..c306c9f534ab 100644 --- a/drivers/ide/cris/ide-cris.c +++ b/drivers/ide/cris/ide-cris.c | |||
@@ -939,7 +939,8 @@ static int cris_ide_build_dmatable (ide_drive_t *drive) | |||
939 | /* group sequential buffers into one large buffer */ | 939 | /* group sequential buffers into one large buffer */ |
940 | addr = page_to_phys(sg->page) + sg->offset; | 940 | addr = page_to_phys(sg->page) + sg->offset; |
941 | size = sg_dma_len(sg); | 941 | size = sg_dma_len(sg); |
942 | while (sg++, --i) { | 942 | while (--i) { |
943 | sg = sg_next(sg); | ||
943 | if ((addr + size) != page_to_phys(sg->page) + sg->offset) | 944 | if ((addr + size) != page_to_phys(sg->page) + sg->offset) |
944 | break; | 945 | break; |
945 | size += sg_dma_len(sg); | 946 | size += sg_dma_len(sg); |
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 4754769eda97..92177ca48b4d 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c | |||
@@ -716,32 +716,6 @@ static void idedisk_prepare_flush(struct request_queue *q, struct request *rq) | |||
716 | rq->buffer = rq->cmd; | 716 | rq->buffer = rq->cmd; |
717 | } | 717 | } |
718 | 718 | ||
719 | static int idedisk_issue_flush(struct request_queue *q, struct gendisk *disk, | ||
720 | sector_t *error_sector) | ||
721 | { | ||
722 | ide_drive_t *drive = q->queuedata; | ||
723 | struct request *rq; | ||
724 | int ret; | ||
725 | |||
726 | if (!drive->wcache) | ||
727 | return 0; | ||
728 | |||
729 | rq = blk_get_request(q, WRITE, __GFP_WAIT); | ||
730 | |||
731 | idedisk_prepare_flush(q, rq); | ||
732 | |||
733 | ret = blk_execute_rq(q, disk, rq, 0); | ||
734 | |||
735 | /* | ||
736 | * if we failed and caller wants error offset, get it | ||
737 | */ | ||
738 | if (ret && error_sector) | ||
739 | *error_sector = ide_get_error_location(drive, rq->cmd); | ||
740 | |||
741 | blk_put_request(rq); | ||
742 | return ret; | ||
743 | } | ||
744 | |||
745 | /* | 719 | /* |
746 | * This is tightly woven into the driver->do_special can not touch. | 720 | * This is tightly woven into the driver->do_special can not touch. |
747 | * DON'T do it again until a total personality rewrite is committed. | 721 | * DON'T do it again until a total personality rewrite is committed. |
@@ -781,7 +755,6 @@ static void update_ordered(ide_drive_t *drive) | |||
781 | struct hd_driveid *id = drive->id; | 755 | struct hd_driveid *id = drive->id; |
782 | unsigned ordered = QUEUE_ORDERED_NONE; | 756 | unsigned ordered = QUEUE_ORDERED_NONE; |
783 | prepare_flush_fn *prep_fn = NULL; | 757 | prepare_flush_fn *prep_fn = NULL; |
784 | issue_flush_fn *issue_fn = NULL; | ||
785 | 758 | ||
786 | if (drive->wcache) { | 759 | if (drive->wcache) { |
787 | unsigned long long capacity; | 760 | unsigned long long capacity; |
@@ -805,13 +778,11 @@ static void update_ordered(ide_drive_t *drive) | |||
805 | if (barrier) { | 778 | if (barrier) { |
806 | ordered = QUEUE_ORDERED_DRAIN_FLUSH; | 779 | ordered = QUEUE_ORDERED_DRAIN_FLUSH; |
807 | prep_fn = idedisk_prepare_flush; | 780 | prep_fn = idedisk_prepare_flush; |
808 | issue_fn = idedisk_issue_flush; | ||
809 | } | 781 | } |
810 | } else | 782 | } else |
811 | ordered = QUEUE_ORDERED_DRAIN; | 783 | ordered = QUEUE_ORDERED_DRAIN; |
812 | 784 | ||
813 | blk_queue_ordered(drive->queue, ordered, prep_fn); | 785 | blk_queue_ordered(drive->queue, ordered, prep_fn); |
814 | blk_queue_issue_flush_fn(drive->queue, issue_fn); | ||
815 | } | 786 | } |
816 | 787 | ||
817 | static int write_cache(ide_drive_t *drive, int arg) | 788 | static int write_cache(ide_drive_t *drive, int arg) |
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index b453211ee0fc..a4cbbbaccde9 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c | |||
@@ -280,7 +280,7 @@ int ide_build_dmatable (ide_drive_t *drive, struct request *rq) | |||
280 | } | 280 | } |
281 | } | 281 | } |
282 | 282 | ||
283 | sg++; | 283 | sg = sg_next(sg); |
284 | i--; | 284 | i--; |
285 | } | 285 | } |
286 | 286 | ||
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 4cece930114c..04273d3c147c 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c | |||
@@ -322,41 +322,6 @@ static void ide_complete_pm_request (ide_drive_t *drive, struct request *rq) | |||
322 | spin_unlock_irqrestore(&ide_lock, flags); | 322 | spin_unlock_irqrestore(&ide_lock, flags); |
323 | } | 323 | } |
324 | 324 | ||
325 | /* | ||
326 | * FIXME: probably move this somewhere else, name is bad too :) | ||
327 | */ | ||
328 | u64 ide_get_error_location(ide_drive_t *drive, char *args) | ||
329 | { | ||
330 | u32 high, low; | ||
331 | u8 hcyl, lcyl, sect; | ||
332 | u64 sector; | ||
333 | |||
334 | high = 0; | ||
335 | hcyl = args[5]; | ||
336 | lcyl = args[4]; | ||
337 | sect = args[3]; | ||
338 | |||
339 | if (ide_id_has_flush_cache_ext(drive->id)) { | ||
340 | low = (hcyl << 16) | (lcyl << 8) | sect; | ||
341 | HWIF(drive)->OUTB(drive->ctl|0x80, IDE_CONTROL_REG); | ||
342 | high = ide_read_24(drive); | ||
343 | } else { | ||
344 | u8 cur = HWIF(drive)->INB(IDE_SELECT_REG); | ||
345 | if (cur & 0x40) { | ||
346 | high = cur & 0xf; | ||
347 | low = (hcyl << 16) | (lcyl << 8) | sect; | ||
348 | } else { | ||
349 | low = hcyl * drive->head * drive->sect; | ||
350 | low += lcyl * drive->sect; | ||
351 | low += sect - 1; | ||
352 | } | ||
353 | } | ||
354 | |||
355 | sector = ((u64) high << 24) | low; | ||
356 | return sector; | ||
357 | } | ||
358 | EXPORT_SYMBOL(ide_get_error_location); | ||
359 | |||
360 | /** | 325 | /** |
361 | * ide_end_drive_cmd - end an explicit drive command | 326 | * ide_end_drive_cmd - end an explicit drive command |
362 | * @drive: command | 327 | * @drive: command |
@@ -881,7 +846,8 @@ void ide_init_sg_cmd(ide_drive_t *drive, struct request *rq) | |||
881 | ide_hwif_t *hwif = drive->hwif; | 846 | ide_hwif_t *hwif = drive->hwif; |
882 | 847 | ||
883 | hwif->nsect = hwif->nleft = rq->nr_sectors; | 848 | hwif->nsect = hwif->nleft = rq->nr_sectors; |
884 | hwif->cursg = hwif->cursg_ofs = 0; | 849 | hwif->cursg_ofs = 0; |
850 | hwif->cursg = NULL; | ||
885 | } | 851 | } |
886 | 852 | ||
887 | EXPORT_SYMBOL_GPL(ide_init_sg_cmd); | 853 | EXPORT_SYMBOL_GPL(ide_init_sg_cmd); |
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index d1011712601c..34b1fb65bc79 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
@@ -1349,7 +1349,7 @@ static int hwif_init(ide_hwif_t *hwif) | |||
1349 | if (!hwif->sg_max_nents) | 1349 | if (!hwif->sg_max_nents) |
1350 | hwif->sg_max_nents = PRD_ENTRIES; | 1350 | hwif->sg_max_nents = PRD_ENTRIES; |
1351 | 1351 | ||
1352 | hwif->sg_table = kmalloc(sizeof(struct scatterlist)*hwif->sg_max_nents, | 1352 | hwif->sg_table = kzalloc(sizeof(struct scatterlist)*hwif->sg_max_nents, |
1353 | GFP_KERNEL); | 1353 | GFP_KERNEL); |
1354 | if (!hwif->sg_table) { | 1354 | if (!hwif->sg_table) { |
1355 | printk(KERN_ERR "%s: unable to allocate SG table.\n", hwif->name); | 1355 | printk(KERN_ERR "%s: unable to allocate SG table.\n", hwif->name); |
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index aa06dafb74ac..2a3c8d498343 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #include <linux/hdreg.h> | 45 | #include <linux/hdreg.h> |
46 | #include <linux/ide.h> | 46 | #include <linux/ide.h> |
47 | #include <linux/bitops.h> | 47 | #include <linux/bitops.h> |
48 | #include <linux/scatterlist.h> | ||
48 | 49 | ||
49 | #include <asm/byteorder.h> | 50 | #include <asm/byteorder.h> |
50 | #include <asm/irq.h> | 51 | #include <asm/irq.h> |
@@ -263,6 +264,7 @@ static void ide_pio_sector(ide_drive_t *drive, unsigned int write) | |||
263 | { | 264 | { |
264 | ide_hwif_t *hwif = drive->hwif; | 265 | ide_hwif_t *hwif = drive->hwif; |
265 | struct scatterlist *sg = hwif->sg_table; | 266 | struct scatterlist *sg = hwif->sg_table; |
267 | struct scatterlist *cursg = hwif->cursg; | ||
266 | struct page *page; | 268 | struct page *page; |
267 | #ifdef CONFIG_HIGHMEM | 269 | #ifdef CONFIG_HIGHMEM |
268 | unsigned long flags; | 270 | unsigned long flags; |
@@ -270,8 +272,14 @@ static void ide_pio_sector(ide_drive_t *drive, unsigned int write) | |||
270 | unsigned int offset; | 272 | unsigned int offset; |
271 | u8 *buf; | 273 | u8 *buf; |
272 | 274 | ||
273 | page = sg[hwif->cursg].page; | 275 | cursg = hwif->cursg; |
274 | offset = sg[hwif->cursg].offset + hwif->cursg_ofs * SECTOR_SIZE; | 276 | if (!cursg) { |
277 | cursg = sg; | ||
278 | hwif->cursg = sg; | ||
279 | } | ||
280 | |||
281 | page = cursg->page; | ||
282 | offset = cursg->offset + hwif->cursg_ofs * SECTOR_SIZE; | ||
275 | 283 | ||
276 | /* get the current page and offset */ | 284 | /* get the current page and offset */ |
277 | page = nth_page(page, (offset >> PAGE_SHIFT)); | 285 | page = nth_page(page, (offset >> PAGE_SHIFT)); |
@@ -285,8 +293,8 @@ static void ide_pio_sector(ide_drive_t *drive, unsigned int write) | |||
285 | hwif->nleft--; | 293 | hwif->nleft--; |
286 | hwif->cursg_ofs++; | 294 | hwif->cursg_ofs++; |
287 | 295 | ||
288 | if ((hwif->cursg_ofs * SECTOR_SIZE) == sg[hwif->cursg].length) { | 296 | if ((hwif->cursg_ofs * SECTOR_SIZE) == cursg->length) { |
289 | hwif->cursg++; | 297 | hwif->cursg = sg_next(hwif->cursg); |
290 | hwif->cursg_ofs = 0; | 298 | hwif->cursg_ofs = 0; |
291 | } | 299 | } |
292 | 300 | ||
@@ -367,6 +375,8 @@ static ide_startstop_t task_error(ide_drive_t *drive, struct request *rq, | |||
367 | 375 | ||
368 | static void task_end_request(ide_drive_t *drive, struct request *rq, u8 stat) | 376 | static void task_end_request(ide_drive_t *drive, struct request *rq, u8 stat) |
369 | { | 377 | { |
378 | HWIF(drive)->cursg = NULL; | ||
379 | |||
370 | if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) { | 380 | if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) { |
371 | ide_task_t *task = rq->special; | 381 | ide_task_t *task = rq->special; |
372 | 382 | ||
diff --git a/drivers/ide/mips/au1xxx-ide.c b/drivers/ide/mips/au1xxx-ide.c index aebde49365d1..892d08f61dc0 100644 --- a/drivers/ide/mips/au1xxx-ide.c +++ b/drivers/ide/mips/au1xxx-ide.c | |||
@@ -296,7 +296,7 @@ static int auide_build_dmatable(ide_drive_t *drive) | |||
296 | cur_addr += tc; | 296 | cur_addr += tc; |
297 | cur_len -= tc; | 297 | cur_len -= tc; |
298 | } | 298 | } |
299 | sg++; | 299 | sg = sg_next(sg); |
300 | i--; | 300 | i--; |
301 | } | 301 | } |
302 | 302 | ||
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c index 85ffaaa39b1b..c74fef6bbc91 100644 --- a/drivers/ide/pci/sgiioc4.c +++ b/drivers/ide/pci/sgiioc4.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/mm.h> | 29 | #include <linux/mm.h> |
30 | #include <linux/ioport.h> | 30 | #include <linux/ioport.h> |
31 | #include <linux/blkdev.h> | 31 | #include <linux/blkdev.h> |
32 | #include <linux/scatterlist.h> | ||
32 | #include <linux/ioc4.h> | 33 | #include <linux/ioc4.h> |
33 | #include <asm/io.h> | 34 | #include <asm/io.h> |
34 | 35 | ||
@@ -537,7 +538,7 @@ sgiioc4_build_dma_table(ide_drive_t * drive, struct request *rq, int ddir) | |||
537 | } | 538 | } |
538 | } | 539 | } |
539 | 540 | ||
540 | sg++; | 541 | sg = sg_next(sg); |
541 | i--; | 542 | i--; |
542 | } | 543 | } |
543 | 544 | ||
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c index 7d8873839e21..9e86406bf44b 100644 --- a/drivers/ide/ppc/pmac.c +++ b/drivers/ide/ppc/pmac.c | |||
@@ -1539,7 +1539,7 @@ pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq) | |||
1539 | cur_len -= tc; | 1539 | cur_len -= tc; |
1540 | ++table; | 1540 | ++table; |
1541 | } | 1541 | } |
1542 | sg++; | 1542 | sg = sg_next(sg); |
1543 | i--; | 1543 | i--; |
1544 | } | 1544 | } |
1545 | 1545 | ||
diff --git a/drivers/infiniband/hw/ipath/ipath_dma.c b/drivers/infiniband/hw/ipath/ipath_dma.c index f87f003e3ef8..22709a4f8fc8 100644 --- a/drivers/infiniband/hw/ipath/ipath_dma.c +++ b/drivers/infiniband/hw/ipath/ipath_dma.c | |||
@@ -30,6 +30,7 @@ | |||
30 | * SOFTWARE. | 30 | * SOFTWARE. |
31 | */ | 31 | */ |
32 | 32 | ||
33 | #include <linux/scatterlist.h> | ||
33 | #include <rdma/ib_verbs.h> | 34 | #include <rdma/ib_verbs.h> |
34 | 35 | ||
35 | #include "ipath_verbs.h" | 36 | #include "ipath_verbs.h" |
@@ -96,17 +97,18 @@ static void ipath_dma_unmap_page(struct ib_device *dev, | |||
96 | BUG_ON(!valid_dma_direction(direction)); | 97 | BUG_ON(!valid_dma_direction(direction)); |
97 | } | 98 | } |
98 | 99 | ||
99 | static int ipath_map_sg(struct ib_device *dev, struct scatterlist *sg, int nents, | 100 | static int ipath_map_sg(struct ib_device *dev, struct scatterlist *sgl, |
100 | enum dma_data_direction direction) | 101 | int nents, enum dma_data_direction direction) |
101 | { | 102 | { |
103 | struct scatterlist *sg; | ||
102 | u64 addr; | 104 | u64 addr; |
103 | int i; | 105 | int i; |
104 | int ret = nents; | 106 | int ret = nents; |
105 | 107 | ||
106 | BUG_ON(!valid_dma_direction(direction)); | 108 | BUG_ON(!valid_dma_direction(direction)); |
107 | 109 | ||
108 | for (i = 0; i < nents; i++) { | 110 | for_each_sg(sgl, sg, nents, i) { |
109 | addr = (u64) page_address(sg[i].page); | 111 | addr = (u64) page_address(sg->page); |
110 | /* TODO: handle highmem pages */ | 112 | /* TODO: handle highmem pages */ |
111 | if (!addr) { | 113 | if (!addr) { |
112 | ret = 0; | 114 | ret = 0; |
diff --git a/drivers/infiniband/ulp/iser/iser_memory.c b/drivers/infiniband/ulp/iser/iser_memory.c index e05690e3592f..f3529b6f0a33 100644 --- a/drivers/infiniband/ulp/iser/iser_memory.c +++ b/drivers/infiniband/ulp/iser/iser_memory.c | |||
@@ -124,17 +124,19 @@ static int iser_start_rdma_unaligned_sg(struct iscsi_iser_cmd_task *iser_ctask, | |||
124 | 124 | ||
125 | if (cmd_dir == ISER_DIR_OUT) { | 125 | if (cmd_dir == ISER_DIR_OUT) { |
126 | /* copy the unaligned sg the buffer which is used for RDMA */ | 126 | /* copy the unaligned sg the buffer which is used for RDMA */ |
127 | struct scatterlist *sg = (struct scatterlist *)data->buf; | 127 | struct scatterlist *sgl = (struct scatterlist *)data->buf; |
128 | struct scatterlist *sg; | ||
128 | int i; | 129 | int i; |
129 | char *p, *from; | 130 | char *p, *from; |
130 | 131 | ||
131 | for (p = mem, i = 0; i < data->size; i++) { | 132 | p = mem; |
132 | from = kmap_atomic(sg[i].page, KM_USER0); | 133 | for_each_sg(sgl, sg, data->size, i) { |
134 | from = kmap_atomic(sg->page, KM_USER0); | ||
133 | memcpy(p, | 135 | memcpy(p, |
134 | from + sg[i].offset, | 136 | from + sg->offset, |
135 | sg[i].length); | 137 | sg->length); |
136 | kunmap_atomic(from, KM_USER0); | 138 | kunmap_atomic(from, KM_USER0); |
137 | p += sg[i].length; | 139 | p += sg->length; |
138 | } | 140 | } |
139 | } | 141 | } |
140 | 142 | ||
@@ -176,7 +178,7 @@ void iser_finalize_rdma_unaligned_sg(struct iscsi_iser_cmd_task *iser_ctask, | |||
176 | 178 | ||
177 | if (cmd_dir == ISER_DIR_IN) { | 179 | if (cmd_dir == ISER_DIR_IN) { |
178 | char *mem; | 180 | char *mem; |
179 | struct scatterlist *sg; | 181 | struct scatterlist *sgl, *sg; |
180 | unsigned char *p, *to; | 182 | unsigned char *p, *to; |
181 | unsigned int sg_size; | 183 | unsigned int sg_size; |
182 | int i; | 184 | int i; |
@@ -184,16 +186,17 @@ void iser_finalize_rdma_unaligned_sg(struct iscsi_iser_cmd_task *iser_ctask, | |||
184 | /* copy back read RDMA to unaligned sg */ | 186 | /* copy back read RDMA to unaligned sg */ |
185 | mem = mem_copy->copy_buf; | 187 | mem = mem_copy->copy_buf; |
186 | 188 | ||
187 | sg = (struct scatterlist *)iser_ctask->data[ISER_DIR_IN].buf; | 189 | sgl = (struct scatterlist *)iser_ctask->data[ISER_DIR_IN].buf; |
188 | sg_size = iser_ctask->data[ISER_DIR_IN].size; | 190 | sg_size = iser_ctask->data[ISER_DIR_IN].size; |
189 | 191 | ||
190 | for (p = mem, i = 0; i < sg_size; i++){ | 192 | p = mem; |
191 | to = kmap_atomic(sg[i].page, KM_SOFTIRQ0); | 193 | for_each_sg(sgl, sg, sg_size, i) { |
192 | memcpy(to + sg[i].offset, | 194 | to = kmap_atomic(sg->page, KM_SOFTIRQ0); |
195 | memcpy(to + sg->offset, | ||
193 | p, | 196 | p, |
194 | sg[i].length); | 197 | sg->length); |
195 | kunmap_atomic(to, KM_SOFTIRQ0); | 198 | kunmap_atomic(to, KM_SOFTIRQ0); |
196 | p += sg[i].length; | 199 | p += sg->length; |
197 | } | 200 | } |
198 | } | 201 | } |
199 | 202 | ||
@@ -224,7 +227,8 @@ static int iser_sg_to_page_vec(struct iser_data_buf *data, | |||
224 | struct iser_page_vec *page_vec, | 227 | struct iser_page_vec *page_vec, |
225 | struct ib_device *ibdev) | 228 | struct ib_device *ibdev) |
226 | { | 229 | { |
227 | struct scatterlist *sg = (struct scatterlist *)data->buf; | 230 | struct scatterlist *sgl = (struct scatterlist *)data->buf; |
231 | struct scatterlist *sg; | ||
228 | u64 first_addr, last_addr, page; | 232 | u64 first_addr, last_addr, page; |
229 | int end_aligned; | 233 | int end_aligned; |
230 | unsigned int cur_page = 0; | 234 | unsigned int cur_page = 0; |
@@ -232,24 +236,25 @@ static int iser_sg_to_page_vec(struct iser_data_buf *data, | |||
232 | int i; | 236 | int i; |
233 | 237 | ||
234 | /* compute the offset of first element */ | 238 | /* compute the offset of first element */ |
235 | page_vec->offset = (u64) sg[0].offset & ~MASK_4K; | 239 | page_vec->offset = (u64) sgl[0].offset & ~MASK_4K; |
236 | 240 | ||
237 | for (i = 0; i < data->dma_nents; i++) { | 241 | for_each_sg(sgl, sg, data->dma_nents, i) { |
238 | unsigned int dma_len = ib_sg_dma_len(ibdev, &sg[i]); | 242 | unsigned int dma_len = ib_sg_dma_len(ibdev, sg); |
239 | 243 | ||
240 | total_sz += dma_len; | 244 | total_sz += dma_len; |
241 | 245 | ||
242 | first_addr = ib_sg_dma_address(ibdev, &sg[i]); | 246 | first_addr = ib_sg_dma_address(ibdev, sg); |
243 | last_addr = first_addr + dma_len; | 247 | last_addr = first_addr + dma_len; |
244 | 248 | ||
245 | end_aligned = !(last_addr & ~MASK_4K); | 249 | end_aligned = !(last_addr & ~MASK_4K); |
246 | 250 | ||
247 | /* continue to collect page fragments till aligned or SG ends */ | 251 | /* continue to collect page fragments till aligned or SG ends */ |
248 | while (!end_aligned && (i + 1 < data->dma_nents)) { | 252 | while (!end_aligned && (i + 1 < data->dma_nents)) { |
253 | sg = sg_next(sg); | ||
249 | i++; | 254 | i++; |
250 | dma_len = ib_sg_dma_len(ibdev, &sg[i]); | 255 | dma_len = ib_sg_dma_len(ibdev, sg); |
251 | total_sz += dma_len; | 256 | total_sz += dma_len; |
252 | last_addr = ib_sg_dma_address(ibdev, &sg[i]) + dma_len; | 257 | last_addr = ib_sg_dma_address(ibdev, sg) + dma_len; |
253 | end_aligned = !(last_addr & ~MASK_4K); | 258 | end_aligned = !(last_addr & ~MASK_4K); |
254 | } | 259 | } |
255 | 260 | ||
@@ -284,25 +289,26 @@ static int iser_sg_to_page_vec(struct iser_data_buf *data, | |||
284 | static unsigned int iser_data_buf_aligned_len(struct iser_data_buf *data, | 289 | static unsigned int iser_data_buf_aligned_len(struct iser_data_buf *data, |
285 | struct ib_device *ibdev) | 290 | struct ib_device *ibdev) |
286 | { | 291 | { |
287 | struct scatterlist *sg; | 292 | struct scatterlist *sgl, *sg; |
288 | u64 end_addr, next_addr; | 293 | u64 end_addr, next_addr; |
289 | int i, cnt; | 294 | int i, cnt; |
290 | unsigned int ret_len = 0; | 295 | unsigned int ret_len = 0; |
291 | 296 | ||
292 | sg = (struct scatterlist *)data->buf; | 297 | sgl = (struct scatterlist *)data->buf; |
293 | 298 | ||
294 | for (cnt = 0, i = 0; i < data->dma_nents; i++, cnt++) { | 299 | cnt = 0; |
300 | for_each_sg(sgl, sg, data->dma_nents, i) { | ||
295 | /* iser_dbg("Checking sg iobuf [%d]: phys=0x%08lX " | 301 | /* iser_dbg("Checking sg iobuf [%d]: phys=0x%08lX " |
296 | "offset: %ld sz: %ld\n", i, | 302 | "offset: %ld sz: %ld\n", i, |
297 | (unsigned long)page_to_phys(sg[i].page), | 303 | (unsigned long)page_to_phys(sg->page), |
298 | (unsigned long)sg[i].offset, | 304 | (unsigned long)sg->offset, |
299 | (unsigned long)sg[i].length); */ | 305 | (unsigned long)sg->length); */ |
300 | end_addr = ib_sg_dma_address(ibdev, &sg[i]) + | 306 | end_addr = ib_sg_dma_address(ibdev, sg) + |
301 | ib_sg_dma_len(ibdev, &sg[i]); | 307 | ib_sg_dma_len(ibdev, sg); |
302 | /* iser_dbg("Checking sg iobuf end address " | 308 | /* iser_dbg("Checking sg iobuf end address " |
303 | "0x%08lX\n", end_addr); */ | 309 | "0x%08lX\n", end_addr); */ |
304 | if (i + 1 < data->dma_nents) { | 310 | if (i + 1 < data->dma_nents) { |
305 | next_addr = ib_sg_dma_address(ibdev, &sg[i+1]); | 311 | next_addr = ib_sg_dma_address(ibdev, sg_next(sg)); |
306 | /* are i, i+1 fragments of the same page? */ | 312 | /* are i, i+1 fragments of the same page? */ |
307 | if (end_addr == next_addr) | 313 | if (end_addr == next_addr) |
308 | continue; | 314 | continue; |
@@ -322,15 +328,16 @@ static unsigned int iser_data_buf_aligned_len(struct iser_data_buf *data, | |||
322 | static void iser_data_buf_dump(struct iser_data_buf *data, | 328 | static void iser_data_buf_dump(struct iser_data_buf *data, |
323 | struct ib_device *ibdev) | 329 | struct ib_device *ibdev) |
324 | { | 330 | { |
325 | struct scatterlist *sg = (struct scatterlist *)data->buf; | 331 | struct scatterlist *sgl = (struct scatterlist *)data->buf; |
332 | struct scatterlist *sg; | ||
326 | int i; | 333 | int i; |
327 | 334 | ||
328 | for (i = 0; i < data->dma_nents; i++) | 335 | for_each_sg(sgl, sg, data->dma_nents, i) |
329 | iser_err("sg[%d] dma_addr:0x%lX page:0x%p " | 336 | iser_err("sg[%d] dma_addr:0x%lX page:0x%p " |
330 | "off:0x%x sz:0x%x dma_len:0x%x\n", | 337 | "off:0x%x sz:0x%x dma_len:0x%x\n", |
331 | i, (unsigned long)ib_sg_dma_address(ibdev, &sg[i]), | 338 | i, (unsigned long)ib_sg_dma_address(ibdev, sg), |
332 | sg[i].page, sg[i].offset, | 339 | sg->page, sg->offset, |
333 | sg[i].length, ib_sg_dma_len(ibdev, &sg[i])); | 340 | sg->length, ib_sg_dma_len(ibdev, sg)); |
334 | } | 341 | } |
335 | 342 | ||
336 | static void iser_dump_page_vec(struct iser_page_vec *page_vec) | 343 | static void iser_dump_page_vec(struct iser_page_vec *page_vec) |
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 8216a6f75be5..64fee90bb68b 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c | |||
@@ -441,33 +441,12 @@ static struct bio *crypt_alloc_buffer(struct dm_crypt_io *io, unsigned size) | |||
441 | return clone; | 441 | return clone; |
442 | } | 442 | } |
443 | 443 | ||
444 | static void crypt_free_buffer_pages(struct crypt_config *cc, | 444 | static void crypt_free_buffer_pages(struct crypt_config *cc, struct bio *clone) |
445 | struct bio *clone, unsigned int bytes) | ||
446 | { | 445 | { |
447 | unsigned int i, start, end; | 446 | unsigned int i; |
448 | struct bio_vec *bv; | 447 | struct bio_vec *bv; |
449 | 448 | ||
450 | /* | 449 | for (i = 0; i < clone->bi_vcnt; i++) { |
451 | * This is ugly, but Jens Axboe thinks that using bi_idx in the | ||
452 | * endio function is too dangerous at the moment, so I calculate the | ||
453 | * correct position using bi_vcnt and bi_size. | ||
454 | * The bv_offset and bv_len fields might already be modified but we | ||
455 | * know that we always allocated whole pages. | ||
456 | * A fix to the bi_idx issue in the kernel is in the works, so | ||
457 | * we will hopefully be able to revert to the cleaner solution soon. | ||
458 | */ | ||
459 | i = clone->bi_vcnt - 1; | ||
460 | bv = bio_iovec_idx(clone, i); | ||
461 | end = (i << PAGE_SHIFT) + (bv->bv_offset + bv->bv_len) - clone->bi_size; | ||
462 | start = end - bytes; | ||
463 | |||
464 | start >>= PAGE_SHIFT; | ||
465 | if (!clone->bi_size) | ||
466 | end = clone->bi_vcnt; | ||
467 | else | ||
468 | end >>= PAGE_SHIFT; | ||
469 | |||
470 | for (i = start; i < end; i++) { | ||
471 | bv = bio_iovec_idx(clone, i); | 450 | bv = bio_iovec_idx(clone, i); |
472 | BUG_ON(!bv->bv_page); | 451 | BUG_ON(!bv->bv_page); |
473 | mempool_free(bv->bv_page, cc->page_pool); | 452 | mempool_free(bv->bv_page, cc->page_pool); |
@@ -519,7 +498,7 @@ static void crypt_endio(struct bio *clone, int error) | |||
519 | * free the processed pages | 498 | * free the processed pages |
520 | */ | 499 | */ |
521 | if (!read_io) { | 500 | if (!read_io) { |
522 | crypt_free_buffer_pages(cc, clone, clone->bi_size); | 501 | crypt_free_buffer_pages(cc, clone); |
523 | goto out; | 502 | goto out; |
524 | } | 503 | } |
525 | 504 | ||
@@ -608,7 +587,7 @@ static void process_write(struct dm_crypt_io *io) | |||
608 | ctx.idx_out = 0; | 587 | ctx.idx_out = 0; |
609 | 588 | ||
610 | if (unlikely(crypt_convert(cc, &ctx) < 0)) { | 589 | if (unlikely(crypt_convert(cc, &ctx) < 0)) { |
611 | crypt_free_buffer_pages(cc, clone, clone->bi_size); | 590 | crypt_free_buffer_pages(cc, clone); |
612 | bio_put(clone); | 591 | bio_put(clone); |
613 | dec_pending(io, -EIO); | 592 | dec_pending(io, -EIO); |
614 | return; | 593 | return; |
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 2bcde5798b5a..fbe477bb2c68 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c | |||
@@ -999,33 +999,6 @@ void dm_table_unplug_all(struct dm_table *t) | |||
999 | } | 999 | } |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | int dm_table_flush_all(struct dm_table *t) | ||
1003 | { | ||
1004 | struct list_head *d, *devices = dm_table_get_devices(t); | ||
1005 | int ret = 0; | ||
1006 | unsigned i; | ||
1007 | |||
1008 | for (i = 0; i < t->num_targets; i++) | ||
1009 | if (t->targets[i].type->flush) | ||
1010 | t->targets[i].type->flush(&t->targets[i]); | ||
1011 | |||
1012 | for (d = devices->next; d != devices; d = d->next) { | ||
1013 | struct dm_dev *dd = list_entry(d, struct dm_dev, list); | ||
1014 | struct request_queue *q = bdev_get_queue(dd->bdev); | ||
1015 | int err; | ||
1016 | |||
1017 | if (!q->issue_flush_fn) | ||
1018 | err = -EOPNOTSUPP; | ||
1019 | else | ||
1020 | err = q->issue_flush_fn(q, dd->bdev->bd_disk, NULL); | ||
1021 | |||
1022 | if (!ret) | ||
1023 | ret = err; | ||
1024 | } | ||
1025 | |||
1026 | return ret; | ||
1027 | } | ||
1028 | |||
1029 | struct mapped_device *dm_table_get_md(struct dm_table *t) | 1002 | struct mapped_device *dm_table_get_md(struct dm_table *t) |
1030 | { | 1003 | { |
1031 | dm_get(t->md); | 1004 | dm_get(t->md); |
@@ -1043,4 +1016,3 @@ EXPORT_SYMBOL(dm_table_get_md); | |||
1043 | EXPORT_SYMBOL(dm_table_put); | 1016 | EXPORT_SYMBOL(dm_table_put); |
1044 | EXPORT_SYMBOL(dm_table_get); | 1017 | EXPORT_SYMBOL(dm_table_get); |
1045 | EXPORT_SYMBOL(dm_table_unplug_all); | 1018 | EXPORT_SYMBOL(dm_table_unplug_all); |
1046 | EXPORT_SYMBOL(dm_table_flush_all); | ||
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 167765c47747..d837d37f6209 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c | |||
@@ -840,21 +840,6 @@ static int dm_request(struct request_queue *q, struct bio *bio) | |||
840 | return 0; | 840 | return 0; |
841 | } | 841 | } |
842 | 842 | ||
843 | static int dm_flush_all(struct request_queue *q, struct gendisk *disk, | ||
844 | sector_t *error_sector) | ||
845 | { | ||
846 | struct mapped_device *md = q->queuedata; | ||
847 | struct dm_table *map = dm_get_table(md); | ||
848 | int ret = -ENXIO; | ||
849 | |||
850 | if (map) { | ||
851 | ret = dm_table_flush_all(map); | ||
852 | dm_table_put(map); | ||
853 | } | ||
854 | |||
855 | return ret; | ||
856 | } | ||
857 | |||
858 | static void dm_unplug_all(struct request_queue *q) | 843 | static void dm_unplug_all(struct request_queue *q) |
859 | { | 844 | { |
860 | struct mapped_device *md = q->queuedata; | 845 | struct mapped_device *md = q->queuedata; |
@@ -1003,7 +988,6 @@ static struct mapped_device *alloc_dev(int minor) | |||
1003 | blk_queue_make_request(md->queue, dm_request); | 988 | blk_queue_make_request(md->queue, dm_request); |
1004 | blk_queue_bounce_limit(md->queue, BLK_BOUNCE_ANY); | 989 | blk_queue_bounce_limit(md->queue, BLK_BOUNCE_ANY); |
1005 | md->queue->unplug_fn = dm_unplug_all; | 990 | md->queue->unplug_fn = dm_unplug_all; |
1006 | md->queue->issue_flush_fn = dm_flush_all; | ||
1007 | 991 | ||
1008 | md->io_pool = mempool_create_slab_pool(MIN_IOS, _io_cache); | 992 | md->io_pool = mempool_create_slab_pool(MIN_IOS, _io_cache); |
1009 | if (!md->io_pool) | 993 | if (!md->io_pool) |
diff --git a/drivers/md/dm.h b/drivers/md/dm.h index 462ee652a890..4b3faa45277e 100644 --- a/drivers/md/dm.h +++ b/drivers/md/dm.h | |||
@@ -111,7 +111,6 @@ void dm_table_postsuspend_targets(struct dm_table *t); | |||
111 | int dm_table_resume_targets(struct dm_table *t); | 111 | int dm_table_resume_targets(struct dm_table *t); |
112 | int dm_table_any_congested(struct dm_table *t, int bdi_bits); | 112 | int dm_table_any_congested(struct dm_table *t, int bdi_bits); |
113 | void dm_table_unplug_all(struct dm_table *t); | 113 | void dm_table_unplug_all(struct dm_table *t); |
114 | int dm_table_flush_all(struct dm_table *t); | ||
115 | 114 | ||
116 | /*----------------------------------------------------------------- | 115 | /*----------------------------------------------------------------- |
117 | * A registry of target types. | 116 | * A registry of target types. |
diff --git a/drivers/md/linear.c b/drivers/md/linear.c index 550148770bb2..56a11f6c127b 100644 --- a/drivers/md/linear.c +++ b/drivers/md/linear.c | |||
@@ -92,25 +92,6 @@ static void linear_unplug(struct request_queue *q) | |||
92 | } | 92 | } |
93 | } | 93 | } |
94 | 94 | ||
95 | static int linear_issue_flush(struct request_queue *q, struct gendisk *disk, | ||
96 | sector_t *error_sector) | ||
97 | { | ||
98 | mddev_t *mddev = q->queuedata; | ||
99 | linear_conf_t *conf = mddev_to_conf(mddev); | ||
100 | int i, ret = 0; | ||
101 | |||
102 | for (i=0; i < mddev->raid_disks && ret == 0; i++) { | ||
103 | struct block_device *bdev = conf->disks[i].rdev->bdev; | ||
104 | struct request_queue *r_queue = bdev_get_queue(bdev); | ||
105 | |||
106 | if (!r_queue->issue_flush_fn) | ||
107 | ret = -EOPNOTSUPP; | ||
108 | else | ||
109 | ret = r_queue->issue_flush_fn(r_queue, bdev->bd_disk, error_sector); | ||
110 | } | ||
111 | return ret; | ||
112 | } | ||
113 | |||
114 | static int linear_congested(void *data, int bits) | 95 | static int linear_congested(void *data, int bits) |
115 | { | 96 | { |
116 | mddev_t *mddev = data; | 97 | mddev_t *mddev = data; |
@@ -279,7 +260,6 @@ static int linear_run (mddev_t *mddev) | |||
279 | 260 | ||
280 | blk_queue_merge_bvec(mddev->queue, linear_mergeable_bvec); | 261 | blk_queue_merge_bvec(mddev->queue, linear_mergeable_bvec); |
281 | mddev->queue->unplug_fn = linear_unplug; | 262 | mddev->queue->unplug_fn = linear_unplug; |
282 | mddev->queue->issue_flush_fn = linear_issue_flush; | ||
283 | mddev->queue->backing_dev_info.congested_fn = linear_congested; | 263 | mddev->queue->backing_dev_info.congested_fn = linear_congested; |
284 | mddev->queue->backing_dev_info.congested_data = mddev; | 264 | mddev->queue->backing_dev_info.congested_data = mddev; |
285 | return 0; | 265 | return 0; |
diff --git a/drivers/md/md.c b/drivers/md/md.c index acf1b81b47cb..0dc563d76b39 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -3463,7 +3463,6 @@ static int do_md_stop(mddev_t * mddev, int mode) | |||
3463 | mddev->pers->stop(mddev); | 3463 | mddev->pers->stop(mddev); |
3464 | mddev->queue->merge_bvec_fn = NULL; | 3464 | mddev->queue->merge_bvec_fn = NULL; |
3465 | mddev->queue->unplug_fn = NULL; | 3465 | mddev->queue->unplug_fn = NULL; |
3466 | mddev->queue->issue_flush_fn = NULL; | ||
3467 | mddev->queue->backing_dev_info.congested_fn = NULL; | 3466 | mddev->queue->backing_dev_info.congested_fn = NULL; |
3468 | if (mddev->pers->sync_request) | 3467 | if (mddev->pers->sync_request) |
3469 | sysfs_remove_group(&mddev->kobj, &md_redundancy_group); | 3468 | sysfs_remove_group(&mddev->kobj, &md_redundancy_group); |
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c index f2a63f394ad9..b35731cceac6 100644 --- a/drivers/md/multipath.c +++ b/drivers/md/multipath.c | |||
@@ -194,35 +194,6 @@ static void multipath_status (struct seq_file *seq, mddev_t *mddev) | |||
194 | seq_printf (seq, "]"); | 194 | seq_printf (seq, "]"); |
195 | } | 195 | } |
196 | 196 | ||
197 | static int multipath_issue_flush(struct request_queue *q, struct gendisk *disk, | ||
198 | sector_t *error_sector) | ||
199 | { | ||
200 | mddev_t *mddev = q->queuedata; | ||
201 | multipath_conf_t *conf = mddev_to_conf(mddev); | ||
202 | int i, ret = 0; | ||
203 | |||
204 | rcu_read_lock(); | ||
205 | for (i=0; i<mddev->raid_disks && ret == 0; i++) { | ||
206 | mdk_rdev_t *rdev = rcu_dereference(conf->multipaths[i].rdev); | ||
207 | if (rdev && !test_bit(Faulty, &rdev->flags)) { | ||
208 | struct block_device *bdev = rdev->bdev; | ||
209 | struct request_queue *r_queue = bdev_get_queue(bdev); | ||
210 | |||
211 | if (!r_queue->issue_flush_fn) | ||
212 | ret = -EOPNOTSUPP; | ||
213 | else { | ||
214 | atomic_inc(&rdev->nr_pending); | ||
215 | rcu_read_unlock(); | ||
216 | ret = r_queue->issue_flush_fn(r_queue, bdev->bd_disk, | ||
217 | error_sector); | ||
218 | rdev_dec_pending(rdev, mddev); | ||
219 | rcu_read_lock(); | ||
220 | } | ||
221 | } | ||
222 | } | ||
223 | rcu_read_unlock(); | ||
224 | return ret; | ||
225 | } | ||
226 | static int multipath_congested(void *data, int bits) | 197 | static int multipath_congested(void *data, int bits) |
227 | { | 198 | { |
228 | mddev_t *mddev = data; | 199 | mddev_t *mddev = data; |
@@ -527,7 +498,6 @@ static int multipath_run (mddev_t *mddev) | |||
527 | mddev->array_size = mddev->size; | 498 | mddev->array_size = mddev->size; |
528 | 499 | ||
529 | mddev->queue->unplug_fn = multipath_unplug; | 500 | mddev->queue->unplug_fn = multipath_unplug; |
530 | mddev->queue->issue_flush_fn = multipath_issue_flush; | ||
531 | mddev->queue->backing_dev_info.congested_fn = multipath_congested; | 501 | mddev->queue->backing_dev_info.congested_fn = multipath_congested; |
532 | mddev->queue->backing_dev_info.congested_data = mddev; | 502 | mddev->queue->backing_dev_info.congested_data = mddev; |
533 | 503 | ||
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index ef0da2d84959..e79e1a538d44 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c | |||
@@ -40,26 +40,6 @@ static void raid0_unplug(struct request_queue *q) | |||
40 | } | 40 | } |
41 | } | 41 | } |
42 | 42 | ||
43 | static int raid0_issue_flush(struct request_queue *q, struct gendisk *disk, | ||
44 | sector_t *error_sector) | ||
45 | { | ||
46 | mddev_t *mddev = q->queuedata; | ||
47 | raid0_conf_t *conf = mddev_to_conf(mddev); | ||
48 | mdk_rdev_t **devlist = conf->strip_zone[0].dev; | ||
49 | int i, ret = 0; | ||
50 | |||
51 | for (i=0; i<mddev->raid_disks && ret == 0; i++) { | ||
52 | struct block_device *bdev = devlist[i]->bdev; | ||
53 | struct request_queue *r_queue = bdev_get_queue(bdev); | ||
54 | |||
55 | if (!r_queue->issue_flush_fn) | ||
56 | ret = -EOPNOTSUPP; | ||
57 | else | ||
58 | ret = r_queue->issue_flush_fn(r_queue, bdev->bd_disk, error_sector); | ||
59 | } | ||
60 | return ret; | ||
61 | } | ||
62 | |||
63 | static int raid0_congested(void *data, int bits) | 43 | static int raid0_congested(void *data, int bits) |
64 | { | 44 | { |
65 | mddev_t *mddev = data; | 45 | mddev_t *mddev = data; |
@@ -250,7 +230,6 @@ static int create_strip_zones (mddev_t *mddev) | |||
250 | 230 | ||
251 | mddev->queue->unplug_fn = raid0_unplug; | 231 | mddev->queue->unplug_fn = raid0_unplug; |
252 | 232 | ||
253 | mddev->queue->issue_flush_fn = raid0_issue_flush; | ||
254 | mddev->queue->backing_dev_info.congested_fn = raid0_congested; | 233 | mddev->queue->backing_dev_info.congested_fn = raid0_congested; |
255 | mddev->queue->backing_dev_info.congested_data = mddev; | 234 | mddev->queue->backing_dev_info.congested_data = mddev; |
256 | 235 | ||
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 6d03bea6fa58..0bcefad82413 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -567,36 +567,6 @@ static void raid1_unplug(struct request_queue *q) | |||
567 | md_wakeup_thread(mddev->thread); | 567 | md_wakeup_thread(mddev->thread); |
568 | } | 568 | } |
569 | 569 | ||
570 | static int raid1_issue_flush(struct request_queue *q, struct gendisk *disk, | ||
571 | sector_t *error_sector) | ||
572 | { | ||
573 | mddev_t *mddev = q->queuedata; | ||
574 | conf_t *conf = mddev_to_conf(mddev); | ||
575 | int i, ret = 0; | ||
576 | |||
577 | rcu_read_lock(); | ||
578 | for (i=0; i<mddev->raid_disks && ret == 0; i++) { | ||
579 | mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev); | ||
580 | if (rdev && !test_bit(Faulty, &rdev->flags)) { | ||
581 | struct block_device *bdev = rdev->bdev; | ||
582 | struct request_queue *r_queue = bdev_get_queue(bdev); | ||
583 | |||
584 | if (!r_queue->issue_flush_fn) | ||
585 | ret = -EOPNOTSUPP; | ||
586 | else { | ||
587 | atomic_inc(&rdev->nr_pending); | ||
588 | rcu_read_unlock(); | ||
589 | ret = r_queue->issue_flush_fn(r_queue, bdev->bd_disk, | ||
590 | error_sector); | ||
591 | rdev_dec_pending(rdev, mddev); | ||
592 | rcu_read_lock(); | ||
593 | } | ||
594 | } | ||
595 | } | ||
596 | rcu_read_unlock(); | ||
597 | return ret; | ||
598 | } | ||
599 | |||
600 | static int raid1_congested(void *data, int bits) | 570 | static int raid1_congested(void *data, int bits) |
601 | { | 571 | { |
602 | mddev_t *mddev = data; | 572 | mddev_t *mddev = data; |
@@ -1997,7 +1967,6 @@ static int run(mddev_t *mddev) | |||
1997 | mddev->array_size = mddev->size; | 1967 | mddev->array_size = mddev->size; |
1998 | 1968 | ||
1999 | mddev->queue->unplug_fn = raid1_unplug; | 1969 | mddev->queue->unplug_fn = raid1_unplug; |
2000 | mddev->queue->issue_flush_fn = raid1_issue_flush; | ||
2001 | mddev->queue->backing_dev_info.congested_fn = raid1_congested; | 1970 | mddev->queue->backing_dev_info.congested_fn = raid1_congested; |
2002 | mddev->queue->backing_dev_info.congested_data = mddev; | 1971 | mddev->queue->backing_dev_info.congested_data = mddev; |
2003 | 1972 | ||
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 25a96c42bdb0..fc6607acb6e4 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c | |||
@@ -611,36 +611,6 @@ static void raid10_unplug(struct request_queue *q) | |||
611 | md_wakeup_thread(mddev->thread); | 611 | md_wakeup_thread(mddev->thread); |
612 | } | 612 | } |
613 | 613 | ||
614 | static int raid10_issue_flush(struct request_queue *q, struct gendisk *disk, | ||
615 | sector_t *error_sector) | ||
616 | { | ||
617 | mddev_t *mddev = q->queuedata; | ||
618 | conf_t *conf = mddev_to_conf(mddev); | ||
619 | int i, ret = 0; | ||
620 | |||
621 | rcu_read_lock(); | ||
622 | for (i=0; i<mddev->raid_disks && ret == 0; i++) { | ||
623 | mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev); | ||
624 | if (rdev && !test_bit(Faulty, &rdev->flags)) { | ||
625 | struct block_device *bdev = rdev->bdev; | ||
626 | struct request_queue *r_queue = bdev_get_queue(bdev); | ||
627 | |||
628 | if (!r_queue->issue_flush_fn) | ||
629 | ret = -EOPNOTSUPP; | ||
630 | else { | ||
631 | atomic_inc(&rdev->nr_pending); | ||
632 | rcu_read_unlock(); | ||
633 | ret = r_queue->issue_flush_fn(r_queue, bdev->bd_disk, | ||
634 | error_sector); | ||
635 | rdev_dec_pending(rdev, mddev); | ||
636 | rcu_read_lock(); | ||
637 | } | ||
638 | } | ||
639 | } | ||
640 | rcu_read_unlock(); | ||
641 | return ret; | ||
642 | } | ||
643 | |||
644 | static int raid10_congested(void *data, int bits) | 614 | static int raid10_congested(void *data, int bits) |
645 | { | 615 | { |
646 | mddev_t *mddev = data; | 616 | mddev_t *mddev = data; |
@@ -2118,7 +2088,6 @@ static int run(mddev_t *mddev) | |||
2118 | mddev->resync_max_sectors = size << conf->chunk_shift; | 2088 | mddev->resync_max_sectors = size << conf->chunk_shift; |
2119 | 2089 | ||
2120 | mddev->queue->unplug_fn = raid10_unplug; | 2090 | mddev->queue->unplug_fn = raid10_unplug; |
2121 | mddev->queue->issue_flush_fn = raid10_issue_flush; | ||
2122 | mddev->queue->backing_dev_info.congested_fn = raid10_congested; | 2091 | mddev->queue->backing_dev_info.congested_fn = raid10_congested; |
2123 | mddev->queue->backing_dev_info.congested_data = mddev; | 2092 | mddev->queue->backing_dev_info.congested_data = mddev; |
2124 | 2093 | ||
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index caaca9e178bc..8ee181a01f52 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -3204,36 +3204,6 @@ static void raid5_unplug_device(struct request_queue *q) | |||
3204 | unplug_slaves(mddev); | 3204 | unplug_slaves(mddev); |
3205 | } | 3205 | } |
3206 | 3206 | ||
3207 | static int raid5_issue_flush(struct request_queue *q, struct gendisk *disk, | ||
3208 | sector_t *error_sector) | ||
3209 | { | ||
3210 | mddev_t *mddev = q->queuedata; | ||
3211 | raid5_conf_t *conf = mddev_to_conf(mddev); | ||
3212 | int i, ret = 0; | ||
3213 | |||
3214 | rcu_read_lock(); | ||
3215 | for (i=0; i<mddev->raid_disks && ret == 0; i++) { | ||
3216 | mdk_rdev_t *rdev = rcu_dereference(conf->disks[i].rdev); | ||
3217 | if (rdev && !test_bit(Faulty, &rdev->flags)) { | ||
3218 | struct block_device *bdev = rdev->bdev; | ||
3219 | struct request_queue *r_queue = bdev_get_queue(bdev); | ||
3220 | |||
3221 | if (!r_queue->issue_flush_fn) | ||
3222 | ret = -EOPNOTSUPP; | ||
3223 | else { | ||
3224 | atomic_inc(&rdev->nr_pending); | ||
3225 | rcu_read_unlock(); | ||
3226 | ret = r_queue->issue_flush_fn(r_queue, bdev->bd_disk, | ||
3227 | error_sector); | ||
3228 | rdev_dec_pending(rdev, mddev); | ||
3229 | rcu_read_lock(); | ||
3230 | } | ||
3231 | } | ||
3232 | } | ||
3233 | rcu_read_unlock(); | ||
3234 | return ret; | ||
3235 | } | ||
3236 | |||
3237 | static int raid5_congested(void *data, int bits) | 3207 | static int raid5_congested(void *data, int bits) |
3238 | { | 3208 | { |
3239 | mddev_t *mddev = data; | 3209 | mddev_t *mddev = data; |
@@ -4263,7 +4233,6 @@ static int run(mddev_t *mddev) | |||
4263 | mdname(mddev)); | 4233 | mdname(mddev)); |
4264 | 4234 | ||
4265 | mddev->queue->unplug_fn = raid5_unplug_device; | 4235 | mddev->queue->unplug_fn = raid5_unplug_device; |
4266 | mddev->queue->issue_flush_fn = raid5_issue_flush; | ||
4267 | mddev->queue->backing_dev_info.congested_data = mddev; | 4236 | mddev->queue->backing_dev_info.congested_data = mddev; |
4268 | mddev->queue->backing_dev_info.congested_fn = raid5_congested; | 4237 | mddev->queue->backing_dev_info.congested_fn = raid5_congested; |
4269 | 4238 | ||
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c index 822a3aa4fae5..626bb3c9af2b 100644 --- a/drivers/message/fusion/mptscsih.c +++ b/drivers/message/fusion/mptscsih.c | |||
@@ -293,7 +293,7 @@ nextSGEset: | |||
293 | for (ii=0; ii < (numSgeThisFrame-1); ii++) { | 293 | for (ii=0; ii < (numSgeThisFrame-1); ii++) { |
294 | thisxfer = sg_dma_len(sg); | 294 | thisxfer = sg_dma_len(sg); |
295 | if (thisxfer == 0) { | 295 | if (thisxfer == 0) { |
296 | sg ++; /* Get next SG element from the OS */ | 296 | sg = sg_next(sg); /* Get next SG element from the OS */ |
297 | sg_done++; | 297 | sg_done++; |
298 | continue; | 298 | continue; |
299 | } | 299 | } |
@@ -301,7 +301,7 @@ nextSGEset: | |||
301 | v2 = sg_dma_address(sg); | 301 | v2 = sg_dma_address(sg); |
302 | mptscsih_add_sge(psge, sgflags | thisxfer, v2); | 302 | mptscsih_add_sge(psge, sgflags | thisxfer, v2); |
303 | 303 | ||
304 | sg++; /* Get next SG element from the OS */ | 304 | sg = sg_next(sg); /* Get next SG element from the OS */ |
305 | psge += (sizeof(u32) + sizeof(dma_addr_t)); | 305 | psge += (sizeof(u32) + sizeof(dma_addr_t)); |
306 | sgeOffset += (sizeof(u32) + sizeof(dma_addr_t)); | 306 | sgeOffset += (sizeof(u32) + sizeof(dma_addr_t)); |
307 | sg_done++; | 307 | sg_done++; |
@@ -322,7 +322,7 @@ nextSGEset: | |||
322 | v2 = sg_dma_address(sg); | 322 | v2 = sg_dma_address(sg); |
323 | mptscsih_add_sge(psge, sgflags | thisxfer, v2); | 323 | mptscsih_add_sge(psge, sgflags | thisxfer, v2); |
324 | /* | 324 | /* |
325 | sg++; | 325 | sg = sg_next(sg); |
326 | psge += (sizeof(u32) + sizeof(dma_addr_t)); | 326 | psge += (sizeof(u32) + sizeof(dma_addr_t)); |
327 | */ | 327 | */ |
328 | sgeOffset += (sizeof(u32) + sizeof(dma_addr_t)); | 328 | sgeOffset += (sizeof(u32) + sizeof(dma_addr_t)); |
diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c index 50b2c7334410..d602ba6d5417 100644 --- a/drivers/message/i2o/i2o_block.c +++ b/drivers/message/i2o/i2o_block.c | |||
@@ -149,29 +149,6 @@ static int i2o_block_device_flush(struct i2o_device *dev) | |||
149 | }; | 149 | }; |
150 | 150 | ||
151 | /** | 151 | /** |
152 | * i2o_block_issue_flush - device-flush interface for block-layer | ||
153 | * @queue: the request queue of the device which should be flushed | ||
154 | * @disk: gendisk | ||
155 | * @error_sector: error offset | ||
156 | * | ||
157 | * Helper function to provide flush functionality to block-layer. | ||
158 | * | ||
159 | * Returns 0 on success or negative error code on failure. | ||
160 | */ | ||
161 | |||
162 | static int i2o_block_issue_flush(struct request_queue * queue, struct gendisk *disk, | ||
163 | sector_t * error_sector) | ||
164 | { | ||
165 | struct i2o_block_device *i2o_blk_dev = queue->queuedata; | ||
166 | int rc = -ENODEV; | ||
167 | |||
168 | if (likely(i2o_blk_dev)) | ||
169 | rc = i2o_block_device_flush(i2o_blk_dev->i2o_dev); | ||
170 | |||
171 | return rc; | ||
172 | } | ||
173 | |||
174 | /** | ||
175 | * i2o_block_device_mount - Mount (load) the media of device dev | 152 | * i2o_block_device_mount - Mount (load) the media of device dev |
176 | * @dev: I2O device which should receive the mount request | 153 | * @dev: I2O device which should receive the mount request |
177 | * @media_id: Media Identifier | 154 | * @media_id: Media Identifier |
@@ -1009,7 +986,6 @@ static struct i2o_block_device *i2o_block_device_alloc(void) | |||
1009 | } | 986 | } |
1010 | 987 | ||
1011 | blk_queue_prep_rq(queue, i2o_block_prep_req_fn); | 988 | blk_queue_prep_rq(queue, i2o_block_prep_req_fn); |
1012 | blk_queue_issue_flush_fn(queue, i2o_block_issue_flush); | ||
1013 | 989 | ||
1014 | gd->major = I2O_MAJOR; | 990 | gd->major = I2O_MAJOR; |
1015 | gd->queue = queue; | 991 | gd->queue = queue; |
diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c index b0abc7d92805..a5d0354bbbda 100644 --- a/drivers/mmc/card/queue.c +++ b/drivers/mmc/card/queue.c | |||
@@ -153,14 +153,14 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock | |||
153 | blk_queue_max_hw_segments(mq->queue, bouncesz / 512); | 153 | blk_queue_max_hw_segments(mq->queue, bouncesz / 512); |
154 | blk_queue_max_segment_size(mq->queue, bouncesz); | 154 | blk_queue_max_segment_size(mq->queue, bouncesz); |
155 | 155 | ||
156 | mq->sg = kmalloc(sizeof(struct scatterlist), | 156 | mq->sg = kzalloc(sizeof(struct scatterlist), |
157 | GFP_KERNEL); | 157 | GFP_KERNEL); |
158 | if (!mq->sg) { | 158 | if (!mq->sg) { |
159 | ret = -ENOMEM; | 159 | ret = -ENOMEM; |
160 | goto cleanup_queue; | 160 | goto cleanup_queue; |
161 | } | 161 | } |
162 | 162 | ||
163 | mq->bounce_sg = kmalloc(sizeof(struct scatterlist) * | 163 | mq->bounce_sg = kzalloc(sizeof(struct scatterlist) * |
164 | bouncesz / 512, GFP_KERNEL); | 164 | bouncesz / 512, GFP_KERNEL); |
165 | if (!mq->bounce_sg) { | 165 | if (!mq->bounce_sg) { |
166 | ret = -ENOMEM; | 166 | ret = -ENOMEM; |
@@ -177,7 +177,7 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock | |||
177 | blk_queue_max_hw_segments(mq->queue, host->max_hw_segs); | 177 | blk_queue_max_hw_segments(mq->queue, host->max_hw_segs); |
178 | blk_queue_max_segment_size(mq->queue, host->max_seg_size); | 178 | blk_queue_max_segment_size(mq->queue, host->max_seg_size); |
179 | 179 | ||
180 | mq->sg = kmalloc(sizeof(struct scatterlist) * | 180 | mq->sg = kzalloc(sizeof(struct scatterlist) * |
181 | host->max_phys_segs, GFP_KERNEL); | 181 | host->max_phys_segs, GFP_KERNEL); |
182 | if (!mq->sg) { | 182 | if (!mq->sg) { |
183 | ret = -ENOMEM; | 183 | ret = -ENOMEM; |
diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h index 16e5563e0c65..57cac7008e0b 100644 --- a/drivers/s390/scsi/zfcp_def.h +++ b/drivers/s390/scsi/zfcp_def.h | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
35 | #include <linux/mempool.h> | 35 | #include <linux/mempool.h> |
36 | #include <linux/syscalls.h> | 36 | #include <linux/syscalls.h> |
37 | #include <linux/scatterlist.h> | ||
37 | #include <linux/ioctl.h> | 38 | #include <linux/ioctl.h> |
38 | #include <scsi/scsi.h> | 39 | #include <scsi/scsi.h> |
39 | #include <scsi/scsi_tcq.h> | 40 | #include <scsi/scsi_tcq.h> |
diff --git a/drivers/s390/scsi/zfcp_qdio.c b/drivers/s390/scsi/zfcp_qdio.c index 3f105fdcf239..51d92b196ee7 100644 --- a/drivers/s390/scsi/zfcp_qdio.c +++ b/drivers/s390/scsi/zfcp_qdio.c | |||
@@ -590,7 +590,7 @@ zfcp_qdio_sbals_from_segment(struct zfcp_fsf_req *fsf_req, unsigned long sbtype, | |||
590 | */ | 590 | */ |
591 | int | 591 | int |
592 | zfcp_qdio_sbals_from_sg(struct zfcp_fsf_req *fsf_req, unsigned long sbtype, | 592 | zfcp_qdio_sbals_from_sg(struct zfcp_fsf_req *fsf_req, unsigned long sbtype, |
593 | struct scatterlist *sg, int sg_count, int max_sbals) | 593 | struct scatterlist *sgl, int sg_count, int max_sbals) |
594 | { | 594 | { |
595 | int sg_index; | 595 | int sg_index; |
596 | struct scatterlist *sg_segment; | 596 | struct scatterlist *sg_segment; |
@@ -606,9 +606,7 @@ zfcp_qdio_sbals_from_sg(struct zfcp_fsf_req *fsf_req, unsigned long sbtype, | |||
606 | sbale->flags |= sbtype; | 606 | sbale->flags |= sbtype; |
607 | 607 | ||
608 | /* process all segements of scatter-gather list */ | 608 | /* process all segements of scatter-gather list */ |
609 | for (sg_index = 0, sg_segment = sg, bytes = 0; | 609 | for_each_sg(sgl, sg_segment, sg_count, sg_index) { |
610 | sg_index < sg_count; | ||
611 | sg_index++, sg_segment++) { | ||
612 | retval = zfcp_qdio_sbals_from_segment( | 610 | retval = zfcp_qdio_sbals_from_segment( |
613 | fsf_req, | 611 | fsf_req, |
614 | sbtype, | 612 | sbtype, |
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c index efd9d8d3a890..fb14014ee16e 100644 --- a/drivers/scsi/3w-9xxx.c +++ b/drivers/scsi/3w-9xxx.c | |||
@@ -1990,6 +1990,7 @@ static struct scsi_host_template driver_template = { | |||
1990 | .max_sectors = TW_MAX_SECTORS, | 1990 | .max_sectors = TW_MAX_SECTORS, |
1991 | .cmd_per_lun = TW_MAX_CMDS_PER_LUN, | 1991 | .cmd_per_lun = TW_MAX_CMDS_PER_LUN, |
1992 | .use_clustering = ENABLE_CLUSTERING, | 1992 | .use_clustering = ENABLE_CLUSTERING, |
1993 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
1993 | .shost_attrs = twa_host_attrs, | 1994 | .shost_attrs = twa_host_attrs, |
1994 | .emulated = 1 | 1995 | .emulated = 1 |
1995 | }; | 1996 | }; |
diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c index c7995fc216e8..a64153b96034 100644 --- a/drivers/scsi/3w-xxxx.c +++ b/drivers/scsi/3w-xxxx.c | |||
@@ -2261,6 +2261,7 @@ static struct scsi_host_template driver_template = { | |||
2261 | .max_sectors = TW_MAX_SECTORS, | 2261 | .max_sectors = TW_MAX_SECTORS, |
2262 | .cmd_per_lun = TW_MAX_CMDS_PER_LUN, | 2262 | .cmd_per_lun = TW_MAX_CMDS_PER_LUN, |
2263 | .use_clustering = ENABLE_CLUSTERING, | 2263 | .use_clustering = ENABLE_CLUSTERING, |
2264 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
2264 | .shost_attrs = tw_host_attrs, | 2265 | .shost_attrs = tw_host_attrs, |
2265 | .emulated = 1 | 2266 | .emulated = 1 |
2266 | }; | 2267 | }; |
diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c index 9b206176f717..49e1ffa4b2ff 100644 --- a/drivers/scsi/BusLogic.c +++ b/drivers/scsi/BusLogic.c | |||
@@ -3575,6 +3575,7 @@ static struct scsi_host_template Bus_Logic_template = { | |||
3575 | .unchecked_isa_dma = 1, | 3575 | .unchecked_isa_dma = 1, |
3576 | .max_sectors = 128, | 3576 | .max_sectors = 128, |
3577 | .use_clustering = ENABLE_CLUSTERING, | 3577 | .use_clustering = ENABLE_CLUSTERING, |
3578 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
3578 | }; | 3579 | }; |
3579 | 3580 | ||
3580 | /* | 3581 | /* |
diff --git a/drivers/scsi/NCR53c406a.c b/drivers/scsi/NCR53c406a.c index eda8c48f6be7..3168a1794849 100644 --- a/drivers/scsi/NCR53c406a.c +++ b/drivers/scsi/NCR53c406a.c | |||
@@ -1066,7 +1066,8 @@ static struct scsi_host_template driver_template = | |||
1066 | .sg_tablesize = 32 /*SG_ALL*/ /*SG_NONE*/, | 1066 | .sg_tablesize = 32 /*SG_ALL*/ /*SG_NONE*/, |
1067 | .cmd_per_lun = 1 /* commands per lun */, | 1067 | .cmd_per_lun = 1 /* commands per lun */, |
1068 | .unchecked_isa_dma = 1 /* unchecked_isa_dma */, | 1068 | .unchecked_isa_dma = 1 /* unchecked_isa_dma */, |
1069 | .use_clustering = ENABLE_CLUSTERING | 1069 | .use_clustering = ENABLE_CLUSTERING, |
1070 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
1070 | }; | 1071 | }; |
1071 | 1072 | ||
1072 | #include "scsi_module.c" | 1073 | #include "scsi_module.c" |
diff --git a/drivers/scsi/a100u2w.c b/drivers/scsi/a100u2w.c index f608d4a1d6da..d3a6d15fb77a 100644 --- a/drivers/scsi/a100u2w.c +++ b/drivers/scsi/a100u2w.c | |||
@@ -1071,6 +1071,7 @@ static struct scsi_host_template inia100_template = { | |||
1071 | .sg_tablesize = SG_ALL, | 1071 | .sg_tablesize = SG_ALL, |
1072 | .cmd_per_lun = 1, | 1072 | .cmd_per_lun = 1, |
1073 | .use_clustering = ENABLE_CLUSTERING, | 1073 | .use_clustering = ENABLE_CLUSTERING, |
1074 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
1074 | }; | 1075 | }; |
1075 | 1076 | ||
1076 | static int __devinit inia100_probe_one(struct pci_dev *pdev, | 1077 | static int __devinit inia100_probe_one(struct pci_dev *pdev, |
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index a7f42a17b5c7..038980be763d 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c | |||
@@ -944,6 +944,7 @@ static struct scsi_host_template aac_driver_template = { | |||
944 | .cmd_per_lun = AAC_NUM_IO_FIB, | 944 | .cmd_per_lun = AAC_NUM_IO_FIB, |
945 | #endif | 945 | #endif |
946 | .use_clustering = ENABLE_CLUSTERING, | 946 | .use_clustering = ENABLE_CLUSTERING, |
947 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
947 | .emulated = 1, | 948 | .emulated = 1, |
948 | }; | 949 | }; |
949 | 950 | ||
diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index cbbfbc9f3e0f..961a1882cb7e 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c | |||
@@ -61,15 +61,15 @@ static void BAD_DMA(void *address, unsigned int length) | |||
61 | } | 61 | } |
62 | 62 | ||
63 | static void BAD_SG_DMA(Scsi_Cmnd * SCpnt, | 63 | static void BAD_SG_DMA(Scsi_Cmnd * SCpnt, |
64 | struct scatterlist *sgpnt, | 64 | struct scatterlist *sgp, |
65 | int nseg, | 65 | int nseg, |
66 | int badseg) | 66 | int badseg) |
67 | { | 67 | { |
68 | printk(KERN_CRIT "sgpnt[%d:%d] page %p/0x%llx length %u\n", | 68 | printk(KERN_CRIT "sgpnt[%d:%d] page %p/0x%llx length %u\n", |
69 | badseg, nseg, | 69 | badseg, nseg, |
70 | page_address(sgpnt[badseg].page) + sgpnt[badseg].offset, | 70 | page_address(sgp->page) + sgp->offset, |
71 | (unsigned long long)SCSI_SG_PA(&sgpnt[badseg]), | 71 | (unsigned long long)SCSI_SG_PA(sgp), |
72 | sgpnt[badseg].length); | 72 | sgp->length); |
73 | 73 | ||
74 | /* | 74 | /* |
75 | * Not safe to continue. | 75 | * Not safe to continue. |
@@ -691,7 +691,7 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) | |||
691 | memcpy(ccb[mbo].cdb, cmd, ccb[mbo].cdblen); | 691 | memcpy(ccb[mbo].cdb, cmd, ccb[mbo].cdblen); |
692 | 692 | ||
693 | if (SCpnt->use_sg) { | 693 | if (SCpnt->use_sg) { |
694 | struct scatterlist *sgpnt; | 694 | struct scatterlist *sg; |
695 | struct chain *cptr; | 695 | struct chain *cptr; |
696 | #ifdef DEBUG | 696 | #ifdef DEBUG |
697 | unsigned char *ptr; | 697 | unsigned char *ptr; |
@@ -699,23 +699,21 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) | |||
699 | int i; | 699 | int i; |
700 | ccb[mbo].op = 2; /* SCSI Initiator Command w/scatter-gather */ | 700 | ccb[mbo].op = 2; /* SCSI Initiator Command w/scatter-gather */ |
701 | SCpnt->host_scribble = kmalloc(512, GFP_KERNEL | GFP_DMA); | 701 | SCpnt->host_scribble = kmalloc(512, GFP_KERNEL | GFP_DMA); |
702 | sgpnt = (struct scatterlist *) SCpnt->request_buffer; | ||
703 | cptr = (struct chain *) SCpnt->host_scribble; | 702 | cptr = (struct chain *) SCpnt->host_scribble; |
704 | if (cptr == NULL) { | 703 | if (cptr == NULL) { |
705 | /* free the claimed mailbox slot */ | 704 | /* free the claimed mailbox slot */ |
706 | HOSTDATA(SCpnt->device->host)->SCint[mbo] = NULL; | 705 | HOSTDATA(SCpnt->device->host)->SCint[mbo] = NULL; |
707 | return SCSI_MLQUEUE_HOST_BUSY; | 706 | return SCSI_MLQUEUE_HOST_BUSY; |
708 | } | 707 | } |
709 | for (i = 0; i < SCpnt->use_sg; i++) { | 708 | scsi_for_each_sg(SCpnt, sg, SCpnt->use_sg, i) { |
710 | if (sgpnt[i].length == 0 || SCpnt->use_sg > 16 || | 709 | if (sg->length == 0 || SCpnt->use_sg > 16 || |
711 | (((int) sgpnt[i].offset) & 1) || (sgpnt[i].length & 1)) { | 710 | (((int) sg->offset) & 1) || (sg->length & 1)) { |
712 | unsigned char *ptr; | 711 | unsigned char *ptr; |
713 | printk(KERN_CRIT "Bad segment list supplied to aha1542.c (%d, %d)\n", SCpnt->use_sg, i); | 712 | printk(KERN_CRIT "Bad segment list supplied to aha1542.c (%d, %d)\n", SCpnt->use_sg, i); |
714 | for (i = 0; i < SCpnt->use_sg; i++) { | 713 | scsi_for_each_sg(SCpnt, sg, SCpnt->use_sg, i) { |
715 | printk(KERN_CRIT "%d: %p %d\n", i, | 714 | printk(KERN_CRIT "%d: %p %d\n", i, |
716 | (page_address(sgpnt[i].page) + | 715 | (page_address(sg->page) + |
717 | sgpnt[i].offset), | 716 | sg->offset), sg->length); |
718 | sgpnt[i].length); | ||
719 | }; | 717 | }; |
720 | printk(KERN_CRIT "cptr %x: ", (unsigned int) cptr); | 718 | printk(KERN_CRIT "cptr %x: ", (unsigned int) cptr); |
721 | ptr = (unsigned char *) &cptr[i]; | 719 | ptr = (unsigned char *) &cptr[i]; |
@@ -723,10 +721,10 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) | |||
723 | printk("%02x ", ptr[i]); | 721 | printk("%02x ", ptr[i]); |
724 | panic("Foooooooood fight!"); | 722 | panic("Foooooooood fight!"); |
725 | }; | 723 | }; |
726 | any2scsi(cptr[i].dataptr, SCSI_SG_PA(&sgpnt[i])); | 724 | any2scsi(cptr[i].dataptr, SCSI_SG_PA(sg)); |
727 | if (SCSI_SG_PA(&sgpnt[i]) + sgpnt[i].length - 1 > ISA_DMA_THRESHOLD) | 725 | if (SCSI_SG_PA(sg) + sg->length - 1 > ISA_DMA_THRESHOLD) |
728 | BAD_SG_DMA(SCpnt, sgpnt, SCpnt->use_sg, i); | 726 | BAD_SG_DMA(SCpnt, sg, SCpnt->use_sg, i); |
729 | any2scsi(cptr[i].datalen, sgpnt[i].length); | 727 | any2scsi(cptr[i].datalen, sg->length); |
730 | }; | 728 | }; |
731 | any2scsi(ccb[mbo].datalen, SCpnt->use_sg * sizeof(struct chain)); | 729 | any2scsi(ccb[mbo].datalen, SCpnt->use_sg * sizeof(struct chain)); |
732 | any2scsi(ccb[mbo].dataptr, SCSI_BUF_PA(cptr)); | 730 | any2scsi(ccb[mbo].dataptr, SCSI_BUF_PA(cptr)); |
diff --git a/drivers/scsi/aha1740.c b/drivers/scsi/aha1740.c index e4a4f3a965d9..f6722fd46008 100644 --- a/drivers/scsi/aha1740.c +++ b/drivers/scsi/aha1740.c | |||
@@ -563,6 +563,7 @@ static struct scsi_host_template aha1740_template = { | |||
563 | .sg_tablesize = AHA1740_SCATTER, | 563 | .sg_tablesize = AHA1740_SCATTER, |
564 | .cmd_per_lun = AHA1740_CMDLUN, | 564 | .cmd_per_lun = AHA1740_CMDLUN, |
565 | .use_clustering = ENABLE_CLUSTERING, | 565 | .use_clustering = ENABLE_CLUSTERING, |
566 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
566 | .eh_abort_handler = aha1740_eh_abort_handler, | 567 | .eh_abort_handler = aha1740_eh_abort_handler, |
567 | }; | 568 | }; |
568 | 569 | ||
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c index a055a96e3ad3..42c0f14a262c 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c | |||
@@ -766,6 +766,7 @@ struct scsi_host_template aic79xx_driver_template = { | |||
766 | .max_sectors = 8192, | 766 | .max_sectors = 8192, |
767 | .cmd_per_lun = 2, | 767 | .cmd_per_lun = 2, |
768 | .use_clustering = ENABLE_CLUSTERING, | 768 | .use_clustering = ENABLE_CLUSTERING, |
769 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
769 | .slave_alloc = ahd_linux_slave_alloc, | 770 | .slave_alloc = ahd_linux_slave_alloc, |
770 | .slave_configure = ahd_linux_slave_configure, | 771 | .slave_configure = ahd_linux_slave_configure, |
771 | .target_alloc = ahd_linux_target_alloc, | 772 | .target_alloc = ahd_linux_target_alloc, |
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c index 2e9c38f2e8a6..7770befbf50c 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm.c +++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c | |||
@@ -747,6 +747,7 @@ struct scsi_host_template aic7xxx_driver_template = { | |||
747 | .max_sectors = 8192, | 747 | .max_sectors = 8192, |
748 | .cmd_per_lun = 2, | 748 | .cmd_per_lun = 2, |
749 | .use_clustering = ENABLE_CLUSTERING, | 749 | .use_clustering = ENABLE_CLUSTERING, |
750 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
750 | .slave_alloc = ahc_linux_slave_alloc, | 751 | .slave_alloc = ahc_linux_slave_alloc, |
751 | .slave_configure = ahc_linux_slave_configure, | 752 | .slave_configure = ahc_linux_slave_configure, |
752 | .target_alloc = ahc_linux_target_alloc, | 753 | .target_alloc = ahc_linux_target_alloc, |
diff --git a/drivers/scsi/aic7xxx_old.c b/drivers/scsi/aic7xxx_old.c index 1a71b0236c97..4025608d6964 100644 --- a/drivers/scsi/aic7xxx_old.c +++ b/drivers/scsi/aic7xxx_old.c | |||
@@ -11142,6 +11142,7 @@ static struct scsi_host_template driver_template = { | |||
11142 | .max_sectors = 2048, | 11142 | .max_sectors = 2048, |
11143 | .cmd_per_lun = 3, | 11143 | .cmd_per_lun = 3, |
11144 | .use_clustering = ENABLE_CLUSTERING, | 11144 | .use_clustering = ENABLE_CLUSTERING, |
11145 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
11145 | }; | 11146 | }; |
11146 | 11147 | ||
11147 | #include "scsi_module.c" | 11148 | #include "scsi_module.c" |
diff --git a/drivers/scsi/aic94xx/aic94xx_task.c b/drivers/scsi/aic94xx/aic94xx_task.c index f2b23e01401a..ee0a98bffcd4 100644 --- a/drivers/scsi/aic94xx/aic94xx_task.c +++ b/drivers/scsi/aic94xx/aic94xx_task.c | |||
@@ -94,7 +94,7 @@ static inline int asd_map_scatterlist(struct sas_task *task, | |||
94 | res = -ENOMEM; | 94 | res = -ENOMEM; |
95 | goto err_unmap; | 95 | goto err_unmap; |
96 | } | 96 | } |
97 | for (sc = task->scatter, i = 0; i < num_sg; i++, sc++) { | 97 | for_each_sg(task->scatter, sc, num_sg, i) { |
98 | struct sg_el *sg = | 98 | struct sg_el *sg = |
99 | &((struct sg_el *)ascb->sg_arr->vaddr)[i]; | 99 | &((struct sg_el *)ascb->sg_arr->vaddr)[i]; |
100 | sg->bus_addr = cpu_to_le64((u64)sg_dma_address(sc)); | 100 | sg->bus_addr = cpu_to_le64((u64)sg_dma_address(sc)); |
@@ -103,7 +103,7 @@ static inline int asd_map_scatterlist(struct sas_task *task, | |||
103 | sg->flags |= ASD_SG_EL_LIST_EOL; | 103 | sg->flags |= ASD_SG_EL_LIST_EOL; |
104 | } | 104 | } |
105 | 105 | ||
106 | for (sc = task->scatter, i = 0; i < 2; i++, sc++) { | 106 | for_each_sg(task->scatter, sc, 2, i) { |
107 | sg_arr[i].bus_addr = | 107 | sg_arr[i].bus_addr = |
108 | cpu_to_le64((u64)sg_dma_address(sc)); | 108 | cpu_to_le64((u64)sg_dma_address(sc)); |
109 | sg_arr[i].size = cpu_to_le32((u32)sg_dma_len(sc)); | 109 | sg_arr[i].size = cpu_to_le32((u32)sg_dma_len(sc)); |
@@ -115,7 +115,7 @@ static inline int asd_map_scatterlist(struct sas_task *task, | |||
115 | sg_arr[2].bus_addr=cpu_to_le64((u64)ascb->sg_arr->dma_handle); | 115 | sg_arr[2].bus_addr=cpu_to_le64((u64)ascb->sg_arr->dma_handle); |
116 | } else { | 116 | } else { |
117 | int i; | 117 | int i; |
118 | for (sc = task->scatter, i = 0; i < num_sg; i++, sc++) { | 118 | for_each_sg(task->scatter, sc, num_sg, i) { |
119 | sg_arr[i].bus_addr = | 119 | sg_arr[i].bus_addr = |
120 | cpu_to_le64((u64)sg_dma_address(sc)); | 120 | cpu_to_le64((u64)sg_dma_address(sc)); |
121 | sg_arr[i].size = cpu_to_le32((u32)sg_dma_len(sc)); | 121 | sg_arr[i].size = cpu_to_le32((u32)sg_dma_len(sc)); |
diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c index cfcf40159eab..f81777586b8f 100644 --- a/drivers/scsi/arcmsr/arcmsr_hba.c +++ b/drivers/scsi/arcmsr/arcmsr_hba.c | |||
@@ -122,6 +122,7 @@ static struct scsi_host_template arcmsr_scsi_host_template = { | |||
122 | .max_sectors = ARCMSR_MAX_XFER_SECTORS, | 122 | .max_sectors = ARCMSR_MAX_XFER_SECTORS, |
123 | .cmd_per_lun = ARCMSR_MAX_CMD_PERLUN, | 123 | .cmd_per_lun = ARCMSR_MAX_CMD_PERLUN, |
124 | .use_clustering = ENABLE_CLUSTERING, | 124 | .use_clustering = ENABLE_CLUSTERING, |
125 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
125 | .shost_attrs = arcmsr_host_attrs, | 126 | .shost_attrs = arcmsr_host_attrs, |
126 | }; | 127 | }; |
127 | #ifdef CONFIG_SCSI_ARCMSR_AER | 128 | #ifdef CONFIG_SCSI_ARCMSR_AER |
diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c index 1591824cf4b3..fd42d4789202 100644 --- a/drivers/scsi/dc395x.c +++ b/drivers/scsi/dc395x.c | |||
@@ -4765,6 +4765,7 @@ static struct scsi_host_template dc395x_driver_template = { | |||
4765 | .eh_bus_reset_handler = dc395x_eh_bus_reset, | 4765 | .eh_bus_reset_handler = dc395x_eh_bus_reset, |
4766 | .unchecked_isa_dma = 0, | 4766 | .unchecked_isa_dma = 0, |
4767 | .use_clustering = DISABLE_CLUSTERING, | 4767 | .use_clustering = DISABLE_CLUSTERING, |
4768 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
4768 | }; | 4769 | }; |
4769 | 4770 | ||
4770 | 4771 | ||
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c index bea9d659af15..8258506ba7d7 100644 --- a/drivers/scsi/dpt_i2o.c +++ b/drivers/scsi/dpt_i2o.c | |||
@@ -3295,6 +3295,7 @@ static struct scsi_host_template adpt_template = { | |||
3295 | .this_id = 7, | 3295 | .this_id = 7, |
3296 | .cmd_per_lun = 1, | 3296 | .cmd_per_lun = 1, |
3297 | .use_clustering = ENABLE_CLUSTERING, | 3297 | .use_clustering = ENABLE_CLUSTERING, |
3298 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
3298 | }; | 3299 | }; |
3299 | 3300 | ||
3300 | static s32 adpt_scsi_register(adpt_hba* pHba) | 3301 | static s32 adpt_scsi_register(adpt_hba* pHba) |
diff --git a/drivers/scsi/eata.c b/drivers/scsi/eata.c index ec2233114bc9..7ead5210de96 100644 --- a/drivers/scsi/eata.c +++ b/drivers/scsi/eata.c | |||
@@ -523,7 +523,8 @@ static struct scsi_host_template driver_template = { | |||
523 | .slave_configure = eata2x_slave_configure, | 523 | .slave_configure = eata2x_slave_configure, |
524 | .this_id = 7, | 524 | .this_id = 7, |
525 | .unchecked_isa_dma = 1, | 525 | .unchecked_isa_dma = 1, |
526 | .use_clustering = ENABLE_CLUSTERING | 526 | .use_clustering = ENABLE_CLUSTERING, |
527 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
527 | }; | 528 | }; |
528 | 529 | ||
529 | #if !defined(__BIG_ENDIAN_BITFIELD) && !defined(__LITTLE_ENDIAN_BITFIELD) | 530 | #if !defined(__BIG_ENDIAN_BITFIELD) && !defined(__LITTLE_ENDIAN_BITFIELD) |
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index adc9559cb6f4..112ab6abe62b 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c | |||
@@ -343,6 +343,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) | |||
343 | shost->use_clustering = sht->use_clustering; | 343 | shost->use_clustering = sht->use_clustering; |
344 | shost->ordered_tag = sht->ordered_tag; | 344 | shost->ordered_tag = sht->ordered_tag; |
345 | shost->active_mode = sht->supported_mode; | 345 | shost->active_mode = sht->supported_mode; |
346 | shost->use_sg_chaining = sht->use_sg_chaining; | ||
346 | 347 | ||
347 | if (sht->max_host_blocked) | 348 | if (sht->max_host_blocked) |
348 | shost->max_host_blocked = sht->max_host_blocked; | 349 | shost->max_host_blocked = sht->max_host_blocked; |
diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c index 8b384fa7f048..8515054cdf70 100644 --- a/drivers/scsi/hptiop.c +++ b/drivers/scsi/hptiop.c | |||
@@ -655,6 +655,7 @@ static struct scsi_host_template driver_template = { | |||
655 | .unchecked_isa_dma = 0, | 655 | .unchecked_isa_dma = 0, |
656 | .emulated = 0, | 656 | .emulated = 0, |
657 | .use_clustering = ENABLE_CLUSTERING, | 657 | .use_clustering = ENABLE_CLUSTERING, |
658 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
658 | .proc_name = driver_name, | 659 | .proc_name = driver_name, |
659 | .shost_attrs = hptiop_attrs, | 660 | .shost_attrs = hptiop_attrs, |
660 | .this_id = -1, | 661 | .this_id = -1, |
diff --git a/drivers/scsi/ibmmca.c b/drivers/scsi/ibmmca.c index 1a924e9b0271..714e6273a70d 100644 --- a/drivers/scsi/ibmmca.c +++ b/drivers/scsi/ibmmca.c | |||
@@ -1501,6 +1501,7 @@ static struct scsi_host_template ibmmca_driver_template = { | |||
1501 | .sg_tablesize = 16, | 1501 | .sg_tablesize = 16, |
1502 | .cmd_per_lun = 1, | 1502 | .cmd_per_lun = 1, |
1503 | .use_clustering = ENABLE_CLUSTERING, | 1503 | .use_clustering = ENABLE_CLUSTERING, |
1504 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
1504 | }; | 1505 | }; |
1505 | 1506 | ||
1506 | static int ibmmca_probe(struct device *dev) | 1507 | static int ibmmca_probe(struct device *dev) |
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c index cda0cc3d182f..22d91ee173c5 100644 --- a/drivers/scsi/ibmvscsi/ibmvscsi.c +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c | |||
@@ -1548,6 +1548,7 @@ static struct scsi_host_template driver_template = { | |||
1548 | .this_id = -1, | 1548 | .this_id = -1, |
1549 | .sg_tablesize = SG_ALL, | 1549 | .sg_tablesize = SG_ALL, |
1550 | .use_clustering = ENABLE_CLUSTERING, | 1550 | .use_clustering = ENABLE_CLUSTERING, |
1551 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
1551 | .shost_attrs = ibmvscsi_attrs, | 1552 | .shost_attrs = ibmvscsi_attrs, |
1552 | }; | 1553 | }; |
1553 | 1554 | ||
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c index d81bb076a15a..d297f64cd432 100644 --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c | |||
@@ -70,6 +70,7 @@ typedef struct idescsi_pc_s { | |||
70 | u8 *buffer; /* Data buffer */ | 70 | u8 *buffer; /* Data buffer */ |
71 | u8 *current_position; /* Pointer into the above buffer */ | 71 | u8 *current_position; /* Pointer into the above buffer */ |
72 | struct scatterlist *sg; /* Scatter gather table */ | 72 | struct scatterlist *sg; /* Scatter gather table */ |
73 | struct scatterlist *last_sg; /* Last sg element */ | ||
73 | int b_count; /* Bytes transferred from current entry */ | 74 | int b_count; /* Bytes transferred from current entry */ |
74 | struct scsi_cmnd *scsi_cmd; /* SCSI command */ | 75 | struct scsi_cmnd *scsi_cmd; /* SCSI command */ |
75 | void (*done)(struct scsi_cmnd *); /* Scsi completion routine */ | 76 | void (*done)(struct scsi_cmnd *); /* Scsi completion routine */ |
@@ -173,12 +174,6 @@ static void idescsi_input_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsigne | |||
173 | char *buf; | 174 | char *buf; |
174 | 175 | ||
175 | while (bcount) { | 176 | while (bcount) { |
176 | if (pc->sg - scsi_sglist(pc->scsi_cmd) > | ||
177 | scsi_sg_count(pc->scsi_cmd)) { | ||
178 | printk (KERN_ERR "ide-scsi: scatter gather table too small, discarding data\n"); | ||
179 | idescsi_discard_data (drive, bcount); | ||
180 | return; | ||
181 | } | ||
182 | count = min(pc->sg->length - pc->b_count, bcount); | 177 | count = min(pc->sg->length - pc->b_count, bcount); |
183 | if (PageHighMem(pc->sg->page)) { | 178 | if (PageHighMem(pc->sg->page)) { |
184 | unsigned long flags; | 179 | unsigned long flags; |
@@ -197,10 +192,17 @@ static void idescsi_input_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsigne | |||
197 | } | 192 | } |
198 | bcount -= count; pc->b_count += count; | 193 | bcount -= count; pc->b_count += count; |
199 | if (pc->b_count == pc->sg->length) { | 194 | if (pc->b_count == pc->sg->length) { |
200 | pc->sg++; | 195 | if (pc->sg == pc->last_sg) |
196 | break; | ||
197 | pc->sg = sg_next(pc->sg); | ||
201 | pc->b_count = 0; | 198 | pc->b_count = 0; |
202 | } | 199 | } |
203 | } | 200 | } |
201 | |||
202 | if (bcount) { | ||
203 | printk (KERN_ERR "ide-scsi: scatter gather table too small, discarding data\n"); | ||
204 | idescsi_discard_data (drive, bcount); | ||
205 | } | ||
204 | } | 206 | } |
205 | 207 | ||
206 | static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsigned int bcount) | 208 | static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsigned int bcount) |
@@ -209,12 +211,6 @@ static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsign | |||
209 | char *buf; | 211 | char *buf; |
210 | 212 | ||
211 | while (bcount) { | 213 | while (bcount) { |
212 | if (pc->sg - scsi_sglist(pc->scsi_cmd) > | ||
213 | scsi_sg_count(pc->scsi_cmd)) { | ||
214 | printk (KERN_ERR "ide-scsi: scatter gather table too small, padding with zeros\n"); | ||
215 | idescsi_output_zeros (drive, bcount); | ||
216 | return; | ||
217 | } | ||
218 | count = min(pc->sg->length - pc->b_count, bcount); | 214 | count = min(pc->sg->length - pc->b_count, bcount); |
219 | if (PageHighMem(pc->sg->page)) { | 215 | if (PageHighMem(pc->sg->page)) { |
220 | unsigned long flags; | 216 | unsigned long flags; |
@@ -233,10 +229,17 @@ static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsign | |||
233 | } | 229 | } |
234 | bcount -= count; pc->b_count += count; | 230 | bcount -= count; pc->b_count += count; |
235 | if (pc->b_count == pc->sg->length) { | 231 | if (pc->b_count == pc->sg->length) { |
236 | pc->sg++; | 232 | if (pc->sg == pc->last_sg) |
233 | break; | ||
234 | pc->sg = sg_next(pc->sg); | ||
237 | pc->b_count = 0; | 235 | pc->b_count = 0; |
238 | } | 236 | } |
239 | } | 237 | } |
238 | |||
239 | if (bcount) { | ||
240 | printk (KERN_ERR "ide-scsi: scatter gather table too small, padding with zeros\n"); | ||
241 | idescsi_output_zeros (drive, bcount); | ||
242 | } | ||
240 | } | 243 | } |
241 | 244 | ||
242 | static void hexdump(u8 *x, int len) | 245 | static void hexdump(u8 *x, int len) |
@@ -804,6 +807,7 @@ static int idescsi_queue (struct scsi_cmnd *cmd, | |||
804 | memcpy (pc->c, cmd->cmnd, cmd->cmd_len); | 807 | memcpy (pc->c, cmd->cmnd, cmd->cmd_len); |
805 | pc->buffer = NULL; | 808 | pc->buffer = NULL; |
806 | pc->sg = scsi_sglist(cmd); | 809 | pc->sg = scsi_sglist(cmd); |
810 | pc->last_sg = sg_last(pc->sg, cmd->use_sg); | ||
807 | pc->b_count = 0; | 811 | pc->b_count = 0; |
808 | pc->request_transfer = pc->buffer_size = scsi_bufflen(cmd); | 812 | pc->request_transfer = pc->buffer_size = scsi_bufflen(cmd); |
809 | pc->scsi_cmd = cmd; | 813 | pc->scsi_cmd = cmd; |
diff --git a/drivers/scsi/initio.c b/drivers/scsi/initio.c index d9dfb69ae031..22d40fd5845b 100644 --- a/drivers/scsi/initio.c +++ b/drivers/scsi/initio.c | |||
@@ -2831,6 +2831,7 @@ static struct scsi_host_template initio_template = { | |||
2831 | .sg_tablesize = SG_ALL, | 2831 | .sg_tablesize = SG_ALL, |
2832 | .cmd_per_lun = 1, | 2832 | .cmd_per_lun = 1, |
2833 | .use_clustering = ENABLE_CLUSTERING, | 2833 | .use_clustering = ENABLE_CLUSTERING, |
2834 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
2834 | }; | 2835 | }; |
2835 | 2836 | ||
2836 | static int initio_probe_one(struct pci_dev *pdev, | 2837 | static int initio_probe_one(struct pci_dev *pdev, |
diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c index 2ed099e2c20d..edaac2714c5a 100644 --- a/drivers/scsi/ips.c +++ b/drivers/scsi/ips.c | |||
@@ -3252,7 +3252,7 @@ ips_done(ips_ha_t * ha, ips_scb_t * scb) | |||
3252 | */ | 3252 | */ |
3253 | if ((scb->breakup) || (scb->sg_break)) { | 3253 | if ((scb->breakup) || (scb->sg_break)) { |
3254 | struct scatterlist *sg; | 3254 | struct scatterlist *sg; |
3255 | int sg_dma_index, ips_sg_index = 0; | 3255 | int i, sg_dma_index, ips_sg_index = 0; |
3256 | 3256 | ||
3257 | /* we had a data breakup */ | 3257 | /* we had a data breakup */ |
3258 | scb->data_len = 0; | 3258 | scb->data_len = 0; |
@@ -3261,20 +3261,22 @@ ips_done(ips_ha_t * ha, ips_scb_t * scb) | |||
3261 | 3261 | ||
3262 | /* Spin forward to last dma chunk */ | 3262 | /* Spin forward to last dma chunk */ |
3263 | sg_dma_index = scb->breakup; | 3263 | sg_dma_index = scb->breakup; |
3264 | for (i = 0; i < scb->breakup; i++) | ||
3265 | sg = sg_next(sg); | ||
3264 | 3266 | ||
3265 | /* Take care of possible partial on last chunk */ | 3267 | /* Take care of possible partial on last chunk */ |
3266 | ips_fill_scb_sg_single(ha, | 3268 | ips_fill_scb_sg_single(ha, |
3267 | sg_dma_address(&sg[sg_dma_index]), | 3269 | sg_dma_address(sg), |
3268 | scb, ips_sg_index++, | 3270 | scb, ips_sg_index++, |
3269 | sg_dma_len(&sg[sg_dma_index])); | 3271 | sg_dma_len(sg)); |
3270 | 3272 | ||
3271 | for (; sg_dma_index < scsi_sg_count(scb->scsi_cmd); | 3273 | for (; sg_dma_index < scsi_sg_count(scb->scsi_cmd); |
3272 | sg_dma_index++) { | 3274 | sg_dma_index++, sg = sg_next(sg)) { |
3273 | if (ips_fill_scb_sg_single | 3275 | if (ips_fill_scb_sg_single |
3274 | (ha, | 3276 | (ha, |
3275 | sg_dma_address(&sg[sg_dma_index]), | 3277 | sg_dma_address(sg), |
3276 | scb, ips_sg_index++, | 3278 | scb, ips_sg_index++, |
3277 | sg_dma_len(&sg[sg_dma_index])) < 0) | 3279 | sg_dma_len(sg)) < 0) |
3278 | break; | 3280 | break; |
3279 | } | 3281 | } |
3280 | 3282 | ||
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index cd674938ccd5..c0755565fae9 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c | |||
@@ -1438,6 +1438,7 @@ struct scsi_host_template lpfc_template = { | |||
1438 | .scan_finished = lpfc_scan_finished, | 1438 | .scan_finished = lpfc_scan_finished, |
1439 | .this_id = -1, | 1439 | .this_id = -1, |
1440 | .sg_tablesize = LPFC_SG_SEG_CNT, | 1440 | .sg_tablesize = LPFC_SG_SEG_CNT, |
1441 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
1441 | .cmd_per_lun = LPFC_CMD_PER_LUN, | 1442 | .cmd_per_lun = LPFC_CMD_PER_LUN, |
1442 | .use_clustering = ENABLE_CLUSTERING, | 1443 | .use_clustering = ENABLE_CLUSTERING, |
1443 | .shost_attrs = lpfc_hba_attrs, | 1444 | .shost_attrs = lpfc_hba_attrs, |
@@ -1460,6 +1461,7 @@ struct scsi_host_template lpfc_vport_template = { | |||
1460 | .sg_tablesize = LPFC_SG_SEG_CNT, | 1461 | .sg_tablesize = LPFC_SG_SEG_CNT, |
1461 | .cmd_per_lun = LPFC_CMD_PER_LUN, | 1462 | .cmd_per_lun = LPFC_CMD_PER_LUN, |
1462 | .use_clustering = ENABLE_CLUSTERING, | 1463 | .use_clustering = ENABLE_CLUSTERING, |
1464 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
1463 | .shost_attrs = lpfc_vport_attrs, | 1465 | .shost_attrs = lpfc_vport_attrs, |
1464 | .max_sectors = 0xFFFF, | 1466 | .max_sectors = 0xFFFF, |
1465 | }; | 1467 | }; |
diff --git a/drivers/scsi/mac53c94.c b/drivers/scsi/mac53c94.c index b12ad7c7c673..a035001f4438 100644 --- a/drivers/scsi/mac53c94.c +++ b/drivers/scsi/mac53c94.c | |||
@@ -402,6 +402,7 @@ static struct scsi_host_template mac53c94_template = { | |||
402 | .sg_tablesize = SG_ALL, | 402 | .sg_tablesize = SG_ALL, |
403 | .cmd_per_lun = 1, | 403 | .cmd_per_lun = 1, |
404 | .use_clustering = DISABLE_CLUSTERING, | 404 | .use_clustering = DISABLE_CLUSTERING, |
405 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
405 | }; | 406 | }; |
406 | 407 | ||
407 | static int mac53c94_probe(struct macio_dev *mdev, const struct of_device_id *match) | 408 | static int mac53c94_probe(struct macio_dev *mdev, const struct of_device_id *match) |
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index e7e11f282c8f..10d1aff9938a 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c | |||
@@ -4492,6 +4492,7 @@ static struct scsi_host_template megaraid_template = { | |||
4492 | .sg_tablesize = MAX_SGLIST, | 4492 | .sg_tablesize = MAX_SGLIST, |
4493 | .cmd_per_lun = DEF_CMD_PER_LUN, | 4493 | .cmd_per_lun = DEF_CMD_PER_LUN, |
4494 | .use_clustering = ENABLE_CLUSTERING, | 4494 | .use_clustering = ENABLE_CLUSTERING, |
4495 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
4495 | .eh_abort_handler = megaraid_abort, | 4496 | .eh_abort_handler = megaraid_abort, |
4496 | .eh_device_reset_handler = megaraid_reset, | 4497 | .eh_device_reset_handler = megaraid_reset, |
4497 | .eh_bus_reset_handler = megaraid_reset, | 4498 | .eh_bus_reset_handler = megaraid_reset, |
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c index c6a53dccc16a..e4e4c6a39ed6 100644 --- a/drivers/scsi/megaraid/megaraid_mbox.c +++ b/drivers/scsi/megaraid/megaraid_mbox.c | |||
@@ -361,6 +361,7 @@ static struct scsi_host_template megaraid_template_g = { | |||
361 | .eh_host_reset_handler = megaraid_reset_handler, | 361 | .eh_host_reset_handler = megaraid_reset_handler, |
362 | .change_queue_depth = megaraid_change_queue_depth, | 362 | .change_queue_depth = megaraid_change_queue_depth, |
363 | .use_clustering = ENABLE_CLUSTERING, | 363 | .use_clustering = ENABLE_CLUSTERING, |
364 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
364 | .sdev_attrs = megaraid_sdev_attrs, | 365 | .sdev_attrs = megaraid_sdev_attrs, |
365 | .shost_attrs = megaraid_shost_attrs, | 366 | .shost_attrs = megaraid_shost_attrs, |
366 | }; | 367 | }; |
diff --git a/drivers/scsi/megaraid/megaraid_sas.c b/drivers/scsi/megaraid/megaraid_sas.c index ebb948c016bb..e3c5c5282203 100644 --- a/drivers/scsi/megaraid/megaraid_sas.c +++ b/drivers/scsi/megaraid/megaraid_sas.c | |||
@@ -1110,6 +1110,7 @@ static struct scsi_host_template megasas_template = { | |||
1110 | .eh_timed_out = megasas_reset_timer, | 1110 | .eh_timed_out = megasas_reset_timer, |
1111 | .bios_param = megasas_bios_param, | 1111 | .bios_param = megasas_bios_param, |
1112 | .use_clustering = ENABLE_CLUSTERING, | 1112 | .use_clustering = ENABLE_CLUSTERING, |
1113 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
1113 | }; | 1114 | }; |
1114 | 1115 | ||
1115 | /** | 1116 | /** |
diff --git a/drivers/scsi/mesh.c b/drivers/scsi/mesh.c index 651d09b08f2a..7470ff39ab22 100644 --- a/drivers/scsi/mesh.c +++ b/drivers/scsi/mesh.c | |||
@@ -1843,6 +1843,7 @@ static struct scsi_host_template mesh_template = { | |||
1843 | .sg_tablesize = SG_ALL, | 1843 | .sg_tablesize = SG_ALL, |
1844 | .cmd_per_lun = 2, | 1844 | .cmd_per_lun = 2, |
1845 | .use_clustering = DISABLE_CLUSTERING, | 1845 | .use_clustering = DISABLE_CLUSTERING, |
1846 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
1846 | }; | 1847 | }; |
1847 | 1848 | ||
1848 | static int mesh_probe(struct macio_dev *mdev, const struct of_device_id *match) | 1849 | static int mesh_probe(struct macio_dev *mdev, const struct of_device_id *match) |
diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c index 7fed35372150..28161dc95e0d 100644 --- a/drivers/scsi/nsp32.c +++ b/drivers/scsi/nsp32.c | |||
@@ -281,6 +281,7 @@ static struct scsi_host_template nsp32_template = { | |||
281 | .cmd_per_lun = 1, | 281 | .cmd_per_lun = 1, |
282 | .this_id = NSP32_HOST_SCSIID, | 282 | .this_id = NSP32_HOST_SCSIID, |
283 | .use_clustering = DISABLE_CLUSTERING, | 283 | .use_clustering = DISABLE_CLUSTERING, |
284 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
284 | .eh_abort_handler = nsp32_eh_abort, | 285 | .eh_abort_handler = nsp32_eh_abort, |
285 | .eh_bus_reset_handler = nsp32_eh_bus_reset, | 286 | .eh_bus_reset_handler = nsp32_eh_bus_reset, |
286 | .eh_host_reset_handler = nsp32_eh_host_reset, | 287 | .eh_host_reset_handler = nsp32_eh_host_reset, |
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c index 961839ecfe86..190e2a7d7067 100644 --- a/drivers/scsi/pcmcia/sym53c500_cs.c +++ b/drivers/scsi/pcmcia/sym53c500_cs.c | |||
@@ -694,6 +694,7 @@ static struct scsi_host_template sym53c500_driver_template = { | |||
694 | .sg_tablesize = 32, | 694 | .sg_tablesize = 32, |
695 | .cmd_per_lun = 1, | 695 | .cmd_per_lun = 1, |
696 | .use_clustering = ENABLE_CLUSTERING, | 696 | .use_clustering = ENABLE_CLUSTERING, |
697 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
697 | .shost_attrs = SYM53C500_shost_attrs | 698 | .shost_attrs = SYM53C500_shost_attrs |
698 | }; | 699 | }; |
699 | 700 | ||
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c index fba8aa8a81b5..76089cf55f4e 100644 --- a/drivers/scsi/qla1280.c +++ b/drivers/scsi/qla1280.c | |||
@@ -2775,7 +2775,7 @@ qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) | |||
2775 | struct device_reg __iomem *reg = ha->iobase; | 2775 | struct device_reg __iomem *reg = ha->iobase; |
2776 | struct scsi_cmnd *cmd = sp->cmd; | 2776 | struct scsi_cmnd *cmd = sp->cmd; |
2777 | cmd_a64_entry_t *pkt; | 2777 | cmd_a64_entry_t *pkt; |
2778 | struct scatterlist *sg = NULL; | 2778 | struct scatterlist *sg = NULL, *s; |
2779 | __le32 *dword_ptr; | 2779 | __le32 *dword_ptr; |
2780 | dma_addr_t dma_handle; | 2780 | dma_addr_t dma_handle; |
2781 | int status = 0; | 2781 | int status = 0; |
@@ -2889,13 +2889,16 @@ qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) | |||
2889 | * Load data segments. | 2889 | * Load data segments. |
2890 | */ | 2890 | */ |
2891 | if (seg_cnt) { /* If data transfer. */ | 2891 | if (seg_cnt) { /* If data transfer. */ |
2892 | int remseg = seg_cnt; | ||
2892 | /* Setup packet address segment pointer. */ | 2893 | /* Setup packet address segment pointer. */ |
2893 | dword_ptr = (u32 *)&pkt->dseg_0_address; | 2894 | dword_ptr = (u32 *)&pkt->dseg_0_address; |
2894 | 2895 | ||
2895 | if (cmd->use_sg) { /* If scatter gather */ | 2896 | if (cmd->use_sg) { /* If scatter gather */ |
2896 | /* Load command entry data segments. */ | 2897 | /* Load command entry data segments. */ |
2897 | for (cnt = 0; cnt < 2 && seg_cnt; cnt++, seg_cnt--) { | 2898 | for_each_sg(sg, s, seg_cnt, cnt) { |
2898 | dma_handle = sg_dma_address(sg); | 2899 | if (cnt == 2) |
2900 | break; | ||
2901 | dma_handle = sg_dma_address(s); | ||
2899 | #if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2) | 2902 | #if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2) |
2900 | if (ha->flags.use_pci_vchannel) | 2903 | if (ha->flags.use_pci_vchannel) |
2901 | sn_pci_set_vchan(ha->pdev, | 2904 | sn_pci_set_vchan(ha->pdev, |
@@ -2906,12 +2909,12 @@ qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) | |||
2906 | cpu_to_le32(pci_dma_lo32(dma_handle)); | 2909 | cpu_to_le32(pci_dma_lo32(dma_handle)); |
2907 | *dword_ptr++ = | 2910 | *dword_ptr++ = |
2908 | cpu_to_le32(pci_dma_hi32(dma_handle)); | 2911 | cpu_to_le32(pci_dma_hi32(dma_handle)); |
2909 | *dword_ptr++ = cpu_to_le32(sg_dma_len(sg)); | 2912 | *dword_ptr++ = cpu_to_le32(sg_dma_len(s)); |
2910 | sg++; | ||
2911 | dprintk(3, "S/G Segment phys_addr=%x %x, len=0x%x\n", | 2913 | dprintk(3, "S/G Segment phys_addr=%x %x, len=0x%x\n", |
2912 | cpu_to_le32(pci_dma_hi32(dma_handle)), | 2914 | cpu_to_le32(pci_dma_hi32(dma_handle)), |
2913 | cpu_to_le32(pci_dma_lo32(dma_handle)), | 2915 | cpu_to_le32(pci_dma_lo32(dma_handle)), |
2914 | cpu_to_le32(sg_dma_len(sg))); | 2916 | cpu_to_le32(sg_dma_len(sg_next(s)))); |
2917 | remseg--; | ||
2915 | } | 2918 | } |
2916 | dprintk(5, "qla1280_64bit_start_scsi: Scatter/gather " | 2919 | dprintk(5, "qla1280_64bit_start_scsi: Scatter/gather " |
2917 | "command packet data - b %i, t %i, l %i \n", | 2920 | "command packet data - b %i, t %i, l %i \n", |
@@ -2926,7 +2929,9 @@ qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) | |||
2926 | dprintk(3, "S/G Building Continuation...seg_cnt=0x%x " | 2929 | dprintk(3, "S/G Building Continuation...seg_cnt=0x%x " |
2927 | "remains\n", seg_cnt); | 2930 | "remains\n", seg_cnt); |
2928 | 2931 | ||
2929 | while (seg_cnt > 0) { | 2932 | while (remseg > 0) { |
2933 | /* Update sg start */ | ||
2934 | sg = s; | ||
2930 | /* Adjust ring index. */ | 2935 | /* Adjust ring index. */ |
2931 | ha->req_ring_index++; | 2936 | ha->req_ring_index++; |
2932 | if (ha->req_ring_index == REQUEST_ENTRY_CNT) { | 2937 | if (ha->req_ring_index == REQUEST_ENTRY_CNT) { |
@@ -2952,9 +2957,10 @@ qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) | |||
2952 | (u32 *)&((struct cont_a64_entry *) pkt)->dseg_0_address; | 2957 | (u32 *)&((struct cont_a64_entry *) pkt)->dseg_0_address; |
2953 | 2958 | ||
2954 | /* Load continuation entry data segments. */ | 2959 | /* Load continuation entry data segments. */ |
2955 | for (cnt = 0; cnt < 5 && seg_cnt; | 2960 | for_each_sg(sg, s, remseg, cnt) { |
2956 | cnt++, seg_cnt--) { | 2961 | if (cnt == 5) |
2957 | dma_handle = sg_dma_address(sg); | 2962 | break; |
2963 | dma_handle = sg_dma_address(s); | ||
2958 | #if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2) | 2964 | #if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2) |
2959 | if (ha->flags.use_pci_vchannel) | 2965 | if (ha->flags.use_pci_vchannel) |
2960 | sn_pci_set_vchan(ha->pdev, | 2966 | sn_pci_set_vchan(ha->pdev, |
@@ -2966,13 +2972,13 @@ qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) | |||
2966 | *dword_ptr++ = | 2972 | *dword_ptr++ = |
2967 | cpu_to_le32(pci_dma_hi32(dma_handle)); | 2973 | cpu_to_le32(pci_dma_hi32(dma_handle)); |
2968 | *dword_ptr++ = | 2974 | *dword_ptr++ = |
2969 | cpu_to_le32(sg_dma_len(sg)); | 2975 | cpu_to_le32(sg_dma_len(s)); |
2970 | dprintk(3, "S/G Segment Cont. phys_addr=%x %x, len=0x%x\n", | 2976 | dprintk(3, "S/G Segment Cont. phys_addr=%x %x, len=0x%x\n", |
2971 | cpu_to_le32(pci_dma_hi32(dma_handle)), | 2977 | cpu_to_le32(pci_dma_hi32(dma_handle)), |
2972 | cpu_to_le32(pci_dma_lo32(dma_handle)), | 2978 | cpu_to_le32(pci_dma_lo32(dma_handle)), |
2973 | cpu_to_le32(sg_dma_len(sg))); | 2979 | cpu_to_le32(sg_dma_len(s))); |
2974 | sg++; | ||
2975 | } | 2980 | } |
2981 | remseg -= cnt; | ||
2976 | dprintk(5, "qla1280_64bit_start_scsi: " | 2982 | dprintk(5, "qla1280_64bit_start_scsi: " |
2977 | "continuation packet data - b %i, t " | 2983 | "continuation packet data - b %i, t " |
2978 | "%i, l %i \n", SCSI_BUS_32(cmd), | 2984 | "%i, l %i \n", SCSI_BUS_32(cmd), |
@@ -3062,7 +3068,7 @@ qla1280_32bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) | |||
3062 | struct device_reg __iomem *reg = ha->iobase; | 3068 | struct device_reg __iomem *reg = ha->iobase; |
3063 | struct scsi_cmnd *cmd = sp->cmd; | 3069 | struct scsi_cmnd *cmd = sp->cmd; |
3064 | struct cmd_entry *pkt; | 3070 | struct cmd_entry *pkt; |
3065 | struct scatterlist *sg = NULL; | 3071 | struct scatterlist *sg = NULL, *s; |
3066 | __le32 *dword_ptr; | 3072 | __le32 *dword_ptr; |
3067 | int status = 0; | 3073 | int status = 0; |
3068 | int cnt; | 3074 | int cnt; |
@@ -3188,6 +3194,7 @@ qla1280_32bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) | |||
3188 | * Load data segments. | 3194 | * Load data segments. |
3189 | */ | 3195 | */ |
3190 | if (seg_cnt) { | 3196 | if (seg_cnt) { |
3197 | int remseg = seg_cnt; | ||
3191 | /* Setup packet address segment pointer. */ | 3198 | /* Setup packet address segment pointer. */ |
3192 | dword_ptr = &pkt->dseg_0_address; | 3199 | dword_ptr = &pkt->dseg_0_address; |
3193 | 3200 | ||
@@ -3196,22 +3203,25 @@ qla1280_32bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) | |||
3196 | qla1280_dump_buffer(1, (char *)sg, 4 * 16); | 3203 | qla1280_dump_buffer(1, (char *)sg, 4 * 16); |
3197 | 3204 | ||
3198 | /* Load command entry data segments. */ | 3205 | /* Load command entry data segments. */ |
3199 | for (cnt = 0; cnt < 4 && seg_cnt; cnt++, seg_cnt--) { | 3206 | for_each_sg(sg, s, seg_cnt, cnt) { |
3207 | if (cnt == 4) | ||
3208 | break; | ||
3200 | *dword_ptr++ = | 3209 | *dword_ptr++ = |
3201 | cpu_to_le32(pci_dma_lo32(sg_dma_address(sg))); | 3210 | cpu_to_le32(pci_dma_lo32(sg_dma_address(s))); |
3202 | *dword_ptr++ = | 3211 | *dword_ptr++ = cpu_to_le32(sg_dma_len(s)); |
3203 | cpu_to_le32(sg_dma_len(sg)); | ||
3204 | dprintk(3, "S/G Segment phys_addr=0x%lx, len=0x%x\n", | 3212 | dprintk(3, "S/G Segment phys_addr=0x%lx, len=0x%x\n", |
3205 | (pci_dma_lo32(sg_dma_address(sg))), | 3213 | (pci_dma_lo32(sg_dma_address(s))), |
3206 | (sg_dma_len(sg))); | 3214 | (sg_dma_len(s))); |
3207 | sg++; | 3215 | remseg--; |
3208 | } | 3216 | } |
3209 | /* | 3217 | /* |
3210 | * Build continuation packets. | 3218 | * Build continuation packets. |
3211 | */ | 3219 | */ |
3212 | dprintk(3, "S/G Building Continuation" | 3220 | dprintk(3, "S/G Building Continuation" |
3213 | "...seg_cnt=0x%x remains\n", seg_cnt); | 3221 | "...seg_cnt=0x%x remains\n", seg_cnt); |
3214 | while (seg_cnt > 0) { | 3222 | while (remseg > 0) { |
3223 | /* Continue from end point */ | ||
3224 | sg = s; | ||
3215 | /* Adjust ring index. */ | 3225 | /* Adjust ring index. */ |
3216 | ha->req_ring_index++; | 3226 | ha->req_ring_index++; |
3217 | if (ha->req_ring_index == REQUEST_ENTRY_CNT) { | 3227 | if (ha->req_ring_index == REQUEST_ENTRY_CNT) { |
@@ -3239,19 +3249,20 @@ qla1280_32bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) | |||
3239 | &((struct cont_entry *) pkt)->dseg_0_address; | 3249 | &((struct cont_entry *) pkt)->dseg_0_address; |
3240 | 3250 | ||
3241 | /* Load continuation entry data segments. */ | 3251 | /* Load continuation entry data segments. */ |
3242 | for (cnt = 0; cnt < 7 && seg_cnt; | 3252 | for_each_sg(sg, s, remseg, cnt) { |
3243 | cnt++, seg_cnt--) { | 3253 | if (cnt == 7) |
3254 | break; | ||
3244 | *dword_ptr++ = | 3255 | *dword_ptr++ = |
3245 | cpu_to_le32(pci_dma_lo32(sg_dma_address(sg))); | 3256 | cpu_to_le32(pci_dma_lo32(sg_dma_address(s))); |
3246 | *dword_ptr++ = | 3257 | *dword_ptr++ = |
3247 | cpu_to_le32(sg_dma_len(sg)); | 3258 | cpu_to_le32(sg_dma_len(s)); |
3248 | dprintk(1, | 3259 | dprintk(1, |
3249 | "S/G Segment Cont. phys_addr=0x%x, " | 3260 | "S/G Segment Cont. phys_addr=0x%x, " |
3250 | "len=0x%x\n", | 3261 | "len=0x%x\n", |
3251 | cpu_to_le32(pci_dma_lo32(sg_dma_address(sg))), | 3262 | cpu_to_le32(pci_dma_lo32(sg_dma_address(s))), |
3252 | cpu_to_le32(sg_dma_len(sg))); | 3263 | cpu_to_le32(sg_dma_len(s))); |
3253 | sg++; | ||
3254 | } | 3264 | } |
3265 | remseg -= cnt; | ||
3255 | dprintk(5, "qla1280_32bit_start_scsi: " | 3266 | dprintk(5, "qla1280_32bit_start_scsi: " |
3256 | "continuation packet data - " | 3267 | "continuation packet data - " |
3257 | "scsi(%i:%i:%i)\n", SCSI_BUS_32(cmd), | 3268 | "scsi(%i:%i:%i)\n", SCSI_BUS_32(cmd), |
@@ -4248,6 +4259,7 @@ static struct scsi_host_template qla1280_driver_template = { | |||
4248 | .sg_tablesize = SG_ALL, | 4259 | .sg_tablesize = SG_ALL, |
4249 | .cmd_per_lun = 1, | 4260 | .cmd_per_lun = 1, |
4250 | .use_clustering = ENABLE_CLUSTERING, | 4261 | .use_clustering = ENABLE_CLUSTERING, |
4262 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
4251 | }; | 4263 | }; |
4252 | 4264 | ||
4253 | 4265 | ||
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index a6bb8d0ecf13..0351d380c2d7 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c | |||
@@ -132,6 +132,7 @@ struct scsi_host_template qla2x00_driver_template = { | |||
132 | .this_id = -1, | 132 | .this_id = -1, |
133 | .cmd_per_lun = 3, | 133 | .cmd_per_lun = 3, |
134 | .use_clustering = ENABLE_CLUSTERING, | 134 | .use_clustering = ENABLE_CLUSTERING, |
135 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
135 | .sg_tablesize = SG_ALL, | 136 | .sg_tablesize = SG_ALL, |
136 | 137 | ||
137 | /* | 138 | /* |
@@ -163,6 +164,7 @@ struct scsi_host_template qla24xx_driver_template = { | |||
163 | .this_id = -1, | 164 | .this_id = -1, |
164 | .cmd_per_lun = 3, | 165 | .cmd_per_lun = 3, |
165 | .use_clustering = ENABLE_CLUSTERING, | 166 | .use_clustering = ENABLE_CLUSTERING, |
167 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
166 | .sg_tablesize = SG_ALL, | 168 | .sg_tablesize = SG_ALL, |
167 | 169 | ||
168 | .max_sectors = 0xFFFF, | 170 | .max_sectors = 0xFFFF, |
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index b1d565c12c5b..03b68d4f3bd0 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c | |||
@@ -94,6 +94,7 @@ static struct scsi_host_template qla4xxx_driver_template = { | |||
94 | .this_id = -1, | 94 | .this_id = -1, |
95 | .cmd_per_lun = 3, | 95 | .cmd_per_lun = 3, |
96 | .use_clustering = ENABLE_CLUSTERING, | 96 | .use_clustering = ENABLE_CLUSTERING, |
97 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
97 | .sg_tablesize = SG_ALL, | 98 | .sg_tablesize = SG_ALL, |
98 | 99 | ||
99 | .max_sectors = 0xFFFF, | 100 | .max_sectors = 0xFFFF, |
diff --git a/drivers/scsi/qlogicfas.c b/drivers/scsi/qlogicfas.c index 1e874f1fb5c6..1769f965eedf 100644 --- a/drivers/scsi/qlogicfas.c +++ b/drivers/scsi/qlogicfas.c | |||
@@ -197,6 +197,7 @@ static struct scsi_host_template qlogicfas_driver_template = { | |||
197 | .sg_tablesize = SG_ALL, | 197 | .sg_tablesize = SG_ALL, |
198 | .cmd_per_lun = 1, | 198 | .cmd_per_lun = 1, |
199 | .use_clustering = DISABLE_CLUSTERING, | 199 | .use_clustering = DISABLE_CLUSTERING, |
200 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
200 | }; | 201 | }; |
201 | 202 | ||
202 | static __init int qlogicfas_init(void) | 203 | static __init int qlogicfas_init(void) |
diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c index e93f80316a19..7a2e7986b038 100644 --- a/drivers/scsi/qlogicpti.c +++ b/drivers/scsi/qlogicpti.c | |||
@@ -868,7 +868,7 @@ static inline int load_cmd(struct scsi_cmnd *Cmnd, struct Command_Entry *cmd, | |||
868 | struct qlogicpti *qpti, u_int in_ptr, u_int out_ptr) | 868 | struct qlogicpti *qpti, u_int in_ptr, u_int out_ptr) |
869 | { | 869 | { |
870 | struct dataseg *ds; | 870 | struct dataseg *ds; |
871 | struct scatterlist *sg; | 871 | struct scatterlist *sg, *s; |
872 | int i, n; | 872 | int i, n; |
873 | 873 | ||
874 | if (Cmnd->use_sg) { | 874 | if (Cmnd->use_sg) { |
@@ -884,11 +884,12 @@ static inline int load_cmd(struct scsi_cmnd *Cmnd, struct Command_Entry *cmd, | |||
884 | n = sg_count; | 884 | n = sg_count; |
885 | if (n > 4) | 885 | if (n > 4) |
886 | n = 4; | 886 | n = 4; |
887 | for (i = 0; i < n; i++, sg++) { | 887 | for_each_sg(sg, s, n, i) { |
888 | ds[i].d_base = sg_dma_address(sg); | 888 | ds[i].d_base = sg_dma_address(s); |
889 | ds[i].d_count = sg_dma_len(sg); | 889 | ds[i].d_count = sg_dma_len(s); |
890 | } | 890 | } |
891 | sg_count -= 4; | 891 | sg_count -= 4; |
892 | sg = s; | ||
892 | while (sg_count > 0) { | 893 | while (sg_count > 0) { |
893 | struct Continuation_Entry *cont; | 894 | struct Continuation_Entry *cont; |
894 | 895 | ||
@@ -907,9 +908,9 @@ static inline int load_cmd(struct scsi_cmnd *Cmnd, struct Command_Entry *cmd, | |||
907 | n = sg_count; | 908 | n = sg_count; |
908 | if (n > 7) | 909 | if (n > 7) |
909 | n = 7; | 910 | n = 7; |
910 | for (i = 0; i < n; i++, sg++) { | 911 | for_each_sg(sg, s, n, i) { |
911 | ds[i].d_base = sg_dma_address(sg); | 912 | ds[i].d_base = sg_dma_address(s); |
912 | ds[i].d_count = sg_dma_len(sg); | 913 | ds[i].d_count = sg_dma_len(s); |
913 | } | 914 | } |
914 | sg_count -= n; | 915 | sg_count -= n; |
915 | } | 916 | } |
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 4947dfe625a6..72ee4c9cfb1a 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/proc_fs.h> | 38 | #include <linux/proc_fs.h> |
39 | #include <linux/vmalloc.h> | 39 | #include <linux/vmalloc.h> |
40 | #include <linux/moduleparam.h> | 40 | #include <linux/moduleparam.h> |
41 | #include <linux/scatterlist.h> | ||
41 | 42 | ||
42 | #include <linux/blkdev.h> | 43 | #include <linux/blkdev.h> |
43 | #include "scsi.h" | 44 | #include "scsi.h" |
@@ -600,7 +601,7 @@ static int fill_from_dev_buffer(struct scsi_cmnd * scp, unsigned char * arr, | |||
600 | int k, req_len, act_len, len, active; | 601 | int k, req_len, act_len, len, active; |
601 | void * kaddr; | 602 | void * kaddr; |
602 | void * kaddr_off; | 603 | void * kaddr_off; |
603 | struct scatterlist * sgpnt; | 604 | struct scatterlist * sg; |
604 | 605 | ||
605 | if (0 == scp->request_bufflen) | 606 | if (0 == scp->request_bufflen) |
606 | return 0; | 607 | return 0; |
@@ -619,16 +620,16 @@ static int fill_from_dev_buffer(struct scsi_cmnd * scp, unsigned char * arr, | |||
619 | scp->resid = req_len - act_len; | 620 | scp->resid = req_len - act_len; |
620 | return 0; | 621 | return 0; |
621 | } | 622 | } |
622 | sgpnt = (struct scatterlist *)scp->request_buffer; | ||
623 | active = 1; | 623 | active = 1; |
624 | for (k = 0, req_len = 0, act_len = 0; k < scp->use_sg; ++k, ++sgpnt) { | 624 | req_len = act_len = 0; |
625 | scsi_for_each_sg(scp, sg, scp->use_sg, k) { | ||
625 | if (active) { | 626 | if (active) { |
626 | kaddr = (unsigned char *) | 627 | kaddr = (unsigned char *) |
627 | kmap_atomic(sgpnt->page, KM_USER0); | 628 | kmap_atomic(sg->page, KM_USER0); |
628 | if (NULL == kaddr) | 629 | if (NULL == kaddr) |
629 | return (DID_ERROR << 16); | 630 | return (DID_ERROR << 16); |
630 | kaddr_off = (unsigned char *)kaddr + sgpnt->offset; | 631 | kaddr_off = (unsigned char *)kaddr + sg->offset; |
631 | len = sgpnt->length; | 632 | len = sg->length; |
632 | if ((req_len + len) > arr_len) { | 633 | if ((req_len + len) > arr_len) { |
633 | active = 0; | 634 | active = 0; |
634 | len = arr_len - req_len; | 635 | len = arr_len - req_len; |
@@ -637,7 +638,7 @@ static int fill_from_dev_buffer(struct scsi_cmnd * scp, unsigned char * arr, | |||
637 | kunmap_atomic(kaddr, KM_USER0); | 638 | kunmap_atomic(kaddr, KM_USER0); |
638 | act_len += len; | 639 | act_len += len; |
639 | } | 640 | } |
640 | req_len += sgpnt->length; | 641 | req_len += sg->length; |
641 | } | 642 | } |
642 | if (scp->resid) | 643 | if (scp->resid) |
643 | scp->resid -= act_len; | 644 | scp->resid -= act_len; |
@@ -653,7 +654,7 @@ static int fetch_to_dev_buffer(struct scsi_cmnd * scp, unsigned char * arr, | |||
653 | int k, req_len, len, fin; | 654 | int k, req_len, len, fin; |
654 | void * kaddr; | 655 | void * kaddr; |
655 | void * kaddr_off; | 656 | void * kaddr_off; |
656 | struct scatterlist * sgpnt; | 657 | struct scatterlist * sg; |
657 | 658 | ||
658 | if (0 == scp->request_bufflen) | 659 | if (0 == scp->request_bufflen) |
659 | return 0; | 660 | return 0; |
@@ -668,13 +669,14 @@ static int fetch_to_dev_buffer(struct scsi_cmnd * scp, unsigned char * arr, | |||
668 | memcpy(arr, scp->request_buffer, len); | 669 | memcpy(arr, scp->request_buffer, len); |
669 | return len; | 670 | return len; |
670 | } | 671 | } |
671 | sgpnt = (struct scatterlist *)scp->request_buffer; | 672 | sg = scsi_sglist(scp); |
672 | for (k = 0, req_len = 0, fin = 0; k < scp->use_sg; ++k, ++sgpnt) { | 673 | req_len = fin = 0; |
673 | kaddr = (unsigned char *)kmap_atomic(sgpnt->page, KM_USER0); | 674 | for (k = 0; k < scp->use_sg; ++k, sg = sg_next(sg)) { |
675 | kaddr = (unsigned char *)kmap_atomic(sg->page, KM_USER0); | ||
674 | if (NULL == kaddr) | 676 | if (NULL == kaddr) |
675 | return -1; | 677 | return -1; |
676 | kaddr_off = (unsigned char *)kaddr + sgpnt->offset; | 678 | kaddr_off = (unsigned char *)kaddr + sg->offset; |
677 | len = sgpnt->length; | 679 | len = sg->length; |
678 | if ((req_len + len) > max_arr_len) { | 680 | if ((req_len + len) > max_arr_len) { |
679 | len = max_arr_len - req_len; | 681 | len = max_arr_len - req_len; |
680 | fin = 1; | 682 | fin = 1; |
@@ -683,7 +685,7 @@ static int fetch_to_dev_buffer(struct scsi_cmnd * scp, unsigned char * arr, | |||
683 | kunmap_atomic(kaddr, KM_USER0); | 685 | kunmap_atomic(kaddr, KM_USER0); |
684 | if (fin) | 686 | if (fin) |
685 | return req_len + len; | 687 | return req_len + len; |
686 | req_len += sgpnt->length; | 688 | req_len += sg->length; |
687 | } | 689 | } |
688 | return req_len; | 690 | return req_len; |
689 | } | 691 | } |
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 207f1aa08869..aac8a02cbe80 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/pci.h> | 17 | #include <linux/pci.h> |
18 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
19 | #include <linux/hardirq.h> | 19 | #include <linux/hardirq.h> |
20 | #include <linux/scatterlist.h> | ||
20 | 21 | ||
21 | #include <scsi/scsi.h> | 22 | #include <scsi/scsi.h> |
22 | #include <scsi/scsi_cmnd.h> | 23 | #include <scsi/scsi_cmnd.h> |
@@ -33,35 +34,34 @@ | |||
33 | #define SG_MEMPOOL_NR ARRAY_SIZE(scsi_sg_pools) | 34 | #define SG_MEMPOOL_NR ARRAY_SIZE(scsi_sg_pools) |
34 | #define SG_MEMPOOL_SIZE 2 | 35 | #define SG_MEMPOOL_SIZE 2 |
35 | 36 | ||
37 | /* | ||
38 | * The maximum number of SG segments that we will put inside a scatterlist | ||
39 | * (unless chaining is used). Should ideally fit inside a single page, to | ||
40 | * avoid a higher order allocation. | ||
41 | */ | ||
42 | #define SCSI_MAX_SG_SEGMENTS 128 | ||
43 | |||
36 | struct scsi_host_sg_pool { | 44 | struct scsi_host_sg_pool { |
37 | size_t size; | 45 | size_t size; |
38 | char *name; | 46 | char *name; |
39 | struct kmem_cache *slab; | 47 | struct kmem_cache *slab; |
40 | mempool_t *pool; | 48 | mempool_t *pool; |
41 | }; | 49 | }; |
42 | 50 | ||
43 | #if (SCSI_MAX_PHYS_SEGMENTS < 32) | 51 | #define SP(x) { x, "sgpool-" #x } |
44 | #error SCSI_MAX_PHYS_SEGMENTS is too small | ||
45 | #endif | ||
46 | |||
47 | #define SP(x) { x, "sgpool-" #x } | ||
48 | static struct scsi_host_sg_pool scsi_sg_pools[] = { | 52 | static struct scsi_host_sg_pool scsi_sg_pools[] = { |
49 | SP(8), | 53 | SP(8), |
50 | SP(16), | 54 | SP(16), |
55 | #if (SCSI_MAX_SG_SEGMENTS > 16) | ||
51 | SP(32), | 56 | SP(32), |
52 | #if (SCSI_MAX_PHYS_SEGMENTS > 32) | 57 | #if (SCSI_MAX_SG_SEGMENTS > 32) |
53 | SP(64), | 58 | SP(64), |
54 | #if (SCSI_MAX_PHYS_SEGMENTS > 64) | 59 | #if (SCSI_MAX_SG_SEGMENTS > 64) |
55 | SP(128), | 60 | SP(128), |
56 | #if (SCSI_MAX_PHYS_SEGMENTS > 128) | ||
57 | SP(256), | ||
58 | #if (SCSI_MAX_PHYS_SEGMENTS > 256) | ||
59 | #error SCSI_MAX_PHYS_SEGMENTS is too large | ||
60 | #endif | ||
61 | #endif | 61 | #endif |
62 | #endif | 62 | #endif |
63 | #endif | 63 | #endif |
64 | }; | 64 | }; |
65 | #undef SP | 65 | #undef SP |
66 | 66 | ||
67 | static void scsi_run_queue(struct request_queue *q); | 67 | static void scsi_run_queue(struct request_queue *q); |
@@ -289,14 +289,16 @@ static int scsi_req_map_sg(struct request *rq, struct scatterlist *sgl, | |||
289 | struct request_queue *q = rq->q; | 289 | struct request_queue *q = rq->q; |
290 | int nr_pages = (bufflen + sgl[0].offset + PAGE_SIZE - 1) >> PAGE_SHIFT; | 290 | int nr_pages = (bufflen + sgl[0].offset + PAGE_SIZE - 1) >> PAGE_SHIFT; |
291 | unsigned int data_len = bufflen, len, bytes, off; | 291 | unsigned int data_len = bufflen, len, bytes, off; |
292 | struct scatterlist *sg; | ||
292 | struct page *page; | 293 | struct page *page; |
293 | struct bio *bio = NULL; | 294 | struct bio *bio = NULL; |
294 | int i, err, nr_vecs = 0; | 295 | int i, err, nr_vecs = 0; |
295 | 296 | ||
296 | for (i = 0; i < nsegs; i++) { | 297 | for_each_sg(sgl, sg, nsegs, i) { |
297 | page = sgl[i].page; | 298 | page = sg->page; |
298 | off = sgl[i].offset; | 299 | off = sg->offset; |
299 | len = sgl[i].length; | 300 | len = sg->length; |
301 | data_len += len; | ||
300 | 302 | ||
301 | while (len > 0 && data_len > 0) { | 303 | while (len > 0 && data_len > 0) { |
302 | /* | 304 | /* |
@@ -695,56 +697,170 @@ static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int uptodate, | |||
695 | return NULL; | 697 | return NULL; |
696 | } | 698 | } |
697 | 699 | ||
698 | struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *cmd, gfp_t gfp_mask) | 700 | /* |
699 | { | 701 | * Like SCSI_MAX_SG_SEGMENTS, but for archs that have sg chaining. This limit |
700 | struct scsi_host_sg_pool *sgp; | 702 | * is totally arbitrary, a setting of 2048 will get you at least 8mb ios. |
701 | struct scatterlist *sgl; | 703 | */ |
704 | #define SCSI_MAX_SG_CHAIN_SEGMENTS 2048 | ||
702 | 705 | ||
703 | BUG_ON(!cmd->use_sg); | 706 | static inline unsigned int scsi_sgtable_index(unsigned short nents) |
707 | { | ||
708 | unsigned int index; | ||
704 | 709 | ||
705 | switch (cmd->use_sg) { | 710 | switch (nents) { |
706 | case 1 ... 8: | 711 | case 1 ... 8: |
707 | cmd->sglist_len = 0; | 712 | index = 0; |
708 | break; | 713 | break; |
709 | case 9 ... 16: | 714 | case 9 ... 16: |
710 | cmd->sglist_len = 1; | 715 | index = 1; |
711 | break; | 716 | break; |
717 | #if (SCSI_MAX_SG_SEGMENTS > 16) | ||
712 | case 17 ... 32: | 718 | case 17 ... 32: |
713 | cmd->sglist_len = 2; | 719 | index = 2; |
714 | break; | 720 | break; |
715 | #if (SCSI_MAX_PHYS_SEGMENTS > 32) | 721 | #if (SCSI_MAX_SG_SEGMENTS > 32) |
716 | case 33 ... 64: | 722 | case 33 ... 64: |
717 | cmd->sglist_len = 3; | 723 | index = 3; |
718 | break; | 724 | break; |
719 | #if (SCSI_MAX_PHYS_SEGMENTS > 64) | 725 | #if (SCSI_MAX_SG_SEGMENTS > 64) |
720 | case 65 ... 128: | 726 | case 65 ... 128: |
721 | cmd->sglist_len = 4; | 727 | index = 4; |
722 | break; | ||
723 | #if (SCSI_MAX_PHYS_SEGMENTS > 128) | ||
724 | case 129 ... 256: | ||
725 | cmd->sglist_len = 5; | ||
726 | break; | 728 | break; |
727 | #endif | 729 | #endif |
728 | #endif | 730 | #endif |
729 | #endif | 731 | #endif |
730 | default: | 732 | default: |
731 | return NULL; | 733 | printk(KERN_ERR "scsi: bad segment count=%d\n", nents); |
734 | BUG(); | ||
732 | } | 735 | } |
733 | 736 | ||
734 | sgp = scsi_sg_pools + cmd->sglist_len; | 737 | return index; |
735 | sgl = mempool_alloc(sgp->pool, gfp_mask); | 738 | } |
736 | return sgl; | 739 | |
740 | struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *cmd, gfp_t gfp_mask) | ||
741 | { | ||
742 | struct scsi_host_sg_pool *sgp; | ||
743 | struct scatterlist *sgl, *prev, *ret; | ||
744 | unsigned int index; | ||
745 | int this, left; | ||
746 | |||
747 | BUG_ON(!cmd->use_sg); | ||
748 | |||
749 | left = cmd->use_sg; | ||
750 | ret = prev = NULL; | ||
751 | do { | ||
752 | this = left; | ||
753 | if (this > SCSI_MAX_SG_SEGMENTS) { | ||
754 | this = SCSI_MAX_SG_SEGMENTS - 1; | ||
755 | index = SG_MEMPOOL_NR - 1; | ||
756 | } else | ||
757 | index = scsi_sgtable_index(this); | ||
758 | |||
759 | left -= this; | ||
760 | |||
761 | sgp = scsi_sg_pools + index; | ||
762 | |||
763 | sgl = mempool_alloc(sgp->pool, gfp_mask); | ||
764 | if (unlikely(!sgl)) | ||
765 | goto enomem; | ||
766 | |||
767 | memset(sgl, 0, sizeof(*sgl) * sgp->size); | ||
768 | |||
769 | /* | ||
770 | * first loop through, set initial index and return value | ||
771 | */ | ||
772 | if (!ret) | ||
773 | ret = sgl; | ||
774 | |||
775 | /* | ||
776 | * chain previous sglist, if any. we know the previous | ||
777 | * sglist must be the biggest one, or we would not have | ||
778 | * ended up doing another loop. | ||
779 | */ | ||
780 | if (prev) | ||
781 | sg_chain(prev, SCSI_MAX_SG_SEGMENTS, sgl); | ||
782 | |||
783 | /* | ||
784 | * don't allow subsequent mempool allocs to sleep, it would | ||
785 | * violate the mempool principle. | ||
786 | */ | ||
787 | gfp_mask &= ~__GFP_WAIT; | ||
788 | gfp_mask |= __GFP_HIGH; | ||
789 | prev = sgl; | ||
790 | } while (left); | ||
791 | |||
792 | /* | ||
793 | * ->use_sg may get modified after dma mapping has potentially | ||
794 | * shrunk the number of segments, so keep a copy of it for free. | ||
795 | */ | ||
796 | cmd->__use_sg = cmd->use_sg; | ||
797 | return ret; | ||
798 | enomem: | ||
799 | if (ret) { | ||
800 | /* | ||
801 | * Free entries chained off ret. Since we were trying to | ||
802 | * allocate another sglist, we know that all entries are of | ||
803 | * the max size. | ||
804 | */ | ||
805 | sgp = scsi_sg_pools + SG_MEMPOOL_NR - 1; | ||
806 | prev = ret; | ||
807 | ret = &ret[SCSI_MAX_SG_SEGMENTS - 1]; | ||
808 | |||
809 | while ((sgl = sg_chain_ptr(ret)) != NULL) { | ||
810 | ret = &sgl[SCSI_MAX_SG_SEGMENTS - 1]; | ||
811 | mempool_free(sgl, sgp->pool); | ||
812 | } | ||
813 | |||
814 | mempool_free(prev, sgp->pool); | ||
815 | } | ||
816 | return NULL; | ||
737 | } | 817 | } |
738 | 818 | ||
739 | EXPORT_SYMBOL(scsi_alloc_sgtable); | 819 | EXPORT_SYMBOL(scsi_alloc_sgtable); |
740 | 820 | ||
741 | void scsi_free_sgtable(struct scatterlist *sgl, int index) | 821 | void scsi_free_sgtable(struct scsi_cmnd *cmd) |
742 | { | 822 | { |
823 | struct scatterlist *sgl = cmd->request_buffer; | ||
743 | struct scsi_host_sg_pool *sgp; | 824 | struct scsi_host_sg_pool *sgp; |
744 | 825 | ||
745 | BUG_ON(index >= SG_MEMPOOL_NR); | 826 | /* |
827 | * if this is the biggest size sglist, check if we have | ||
828 | * chained parts we need to free | ||
829 | */ | ||
830 | if (cmd->__use_sg > SCSI_MAX_SG_SEGMENTS) { | ||
831 | unsigned short this, left; | ||
832 | struct scatterlist *next; | ||
833 | unsigned int index; | ||
834 | |||
835 | left = cmd->__use_sg - (SCSI_MAX_SG_SEGMENTS - 1); | ||
836 | next = sg_chain_ptr(&sgl[SCSI_MAX_SG_SEGMENTS - 1]); | ||
837 | while (left && next) { | ||
838 | sgl = next; | ||
839 | this = left; | ||
840 | if (this > SCSI_MAX_SG_SEGMENTS) { | ||
841 | this = SCSI_MAX_SG_SEGMENTS - 1; | ||
842 | index = SG_MEMPOOL_NR - 1; | ||
843 | } else | ||
844 | index = scsi_sgtable_index(this); | ||
845 | |||
846 | left -= this; | ||
847 | |||
848 | sgp = scsi_sg_pools + index; | ||
849 | |||
850 | if (left) | ||
851 | next = sg_chain_ptr(&sgl[sgp->size - 1]); | ||
852 | |||
853 | mempool_free(sgl, sgp->pool); | ||
854 | } | ||
855 | |||
856 | /* | ||
857 | * Restore original, will be freed below | ||
858 | */ | ||
859 | sgl = cmd->request_buffer; | ||
860 | sgp = scsi_sg_pools + SG_MEMPOOL_NR - 1; | ||
861 | } else | ||
862 | sgp = scsi_sg_pools + scsi_sgtable_index(cmd->__use_sg); | ||
746 | 863 | ||
747 | sgp = scsi_sg_pools + index; | ||
748 | mempool_free(sgl, sgp->pool); | 864 | mempool_free(sgl, sgp->pool); |
749 | } | 865 | } |
750 | 866 | ||
@@ -770,7 +886,7 @@ EXPORT_SYMBOL(scsi_free_sgtable); | |||
770 | static void scsi_release_buffers(struct scsi_cmnd *cmd) | 886 | static void scsi_release_buffers(struct scsi_cmnd *cmd) |
771 | { | 887 | { |
772 | if (cmd->use_sg) | 888 | if (cmd->use_sg) |
773 | scsi_free_sgtable(cmd->request_buffer, cmd->sglist_len); | 889 | scsi_free_sgtable(cmd); |
774 | 890 | ||
775 | /* | 891 | /* |
776 | * Zero these out. They now point to freed memory, and it is | 892 | * Zero these out. They now point to freed memory, and it is |
@@ -984,7 +1100,6 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) | |||
984 | static int scsi_init_io(struct scsi_cmnd *cmd) | 1100 | static int scsi_init_io(struct scsi_cmnd *cmd) |
985 | { | 1101 | { |
986 | struct request *req = cmd->request; | 1102 | struct request *req = cmd->request; |
987 | struct scatterlist *sgpnt; | ||
988 | int count; | 1103 | int count; |
989 | 1104 | ||
990 | /* | 1105 | /* |
@@ -997,14 +1112,13 @@ static int scsi_init_io(struct scsi_cmnd *cmd) | |||
997 | /* | 1112 | /* |
998 | * If sg table allocation fails, requeue request later. | 1113 | * If sg table allocation fails, requeue request later. |
999 | */ | 1114 | */ |
1000 | sgpnt = scsi_alloc_sgtable(cmd, GFP_ATOMIC); | 1115 | cmd->request_buffer = scsi_alloc_sgtable(cmd, GFP_ATOMIC); |
1001 | if (unlikely(!sgpnt)) { | 1116 | if (unlikely(!cmd->request_buffer)) { |
1002 | scsi_unprep_request(req); | 1117 | scsi_unprep_request(req); |
1003 | return BLKPREP_DEFER; | 1118 | return BLKPREP_DEFER; |
1004 | } | 1119 | } |
1005 | 1120 | ||
1006 | req->buffer = NULL; | 1121 | req->buffer = NULL; |
1007 | cmd->request_buffer = (char *) sgpnt; | ||
1008 | if (blk_pc_request(req)) | 1122 | if (blk_pc_request(req)) |
1009 | cmd->request_bufflen = req->data_len; | 1123 | cmd->request_bufflen = req->data_len; |
1010 | else | 1124 | else |
@@ -1529,8 +1643,25 @@ struct request_queue *__scsi_alloc_queue(struct Scsi_Host *shost, | |||
1529 | if (!q) | 1643 | if (!q) |
1530 | return NULL; | 1644 | return NULL; |
1531 | 1645 | ||
1646 | /* | ||
1647 | * this limit is imposed by hardware restrictions | ||
1648 | */ | ||
1532 | blk_queue_max_hw_segments(q, shost->sg_tablesize); | 1649 | blk_queue_max_hw_segments(q, shost->sg_tablesize); |
1533 | blk_queue_max_phys_segments(q, SCSI_MAX_PHYS_SEGMENTS); | 1650 | |
1651 | /* | ||
1652 | * In the future, sg chaining support will be mandatory and this | ||
1653 | * ifdef can then go away. Right now we don't have all archs | ||
1654 | * converted, so better keep it safe. | ||
1655 | */ | ||
1656 | #ifdef ARCH_HAS_SG_CHAIN | ||
1657 | if (shost->use_sg_chaining) | ||
1658 | blk_queue_max_phys_segments(q, SCSI_MAX_SG_CHAIN_SEGMENTS); | ||
1659 | else | ||
1660 | blk_queue_max_phys_segments(q, SCSI_MAX_SG_SEGMENTS); | ||
1661 | #else | ||
1662 | blk_queue_max_phys_segments(q, SCSI_MAX_SG_SEGMENTS); | ||
1663 | #endif | ||
1664 | |||
1534 | blk_queue_max_sectors(q, shost->max_sectors); | 1665 | blk_queue_max_sectors(q, shost->max_sectors); |
1535 | blk_queue_bounce_limit(q, scsi_calculate_bounce_limit(shost)); | 1666 | blk_queue_bounce_limit(q, scsi_calculate_bounce_limit(shost)); |
1536 | blk_queue_segment_boundary(q, shost->dma_boundary); | 1667 | blk_queue_segment_boundary(q, shost->dma_boundary); |
@@ -2193,18 +2324,19 @@ EXPORT_SYMBOL_GPL(scsi_target_unblock); | |||
2193 | * | 2324 | * |
2194 | * Returns virtual address of the start of the mapped page | 2325 | * Returns virtual address of the start of the mapped page |
2195 | */ | 2326 | */ |
2196 | void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count, | 2327 | void *scsi_kmap_atomic_sg(struct scatterlist *sgl, int sg_count, |
2197 | size_t *offset, size_t *len) | 2328 | size_t *offset, size_t *len) |
2198 | { | 2329 | { |
2199 | int i; | 2330 | int i; |
2200 | size_t sg_len = 0, len_complete = 0; | 2331 | size_t sg_len = 0, len_complete = 0; |
2332 | struct scatterlist *sg; | ||
2201 | struct page *page; | 2333 | struct page *page; |
2202 | 2334 | ||
2203 | WARN_ON(!irqs_disabled()); | 2335 | WARN_ON(!irqs_disabled()); |
2204 | 2336 | ||
2205 | for (i = 0; i < sg_count; i++) { | 2337 | for_each_sg(sgl, sg, sg_count, i) { |
2206 | len_complete = sg_len; /* Complete sg-entries */ | 2338 | len_complete = sg_len; /* Complete sg-entries */ |
2207 | sg_len += sg[i].length; | 2339 | sg_len += sg->length; |
2208 | if (sg_len > *offset) | 2340 | if (sg_len > *offset) |
2209 | break; | 2341 | break; |
2210 | } | 2342 | } |
@@ -2218,10 +2350,10 @@ void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count, | |||
2218 | } | 2350 | } |
2219 | 2351 | ||
2220 | /* Offset starting from the beginning of first page in this sg-entry */ | 2352 | /* Offset starting from the beginning of first page in this sg-entry */ |
2221 | *offset = *offset - len_complete + sg[i].offset; | 2353 | *offset = *offset - len_complete + sg->offset; |
2222 | 2354 | ||
2223 | /* Assumption: contiguous pages can be accessed as "page + i" */ | 2355 | /* Assumption: contiguous pages can be accessed as "page + i" */ |
2224 | page = nth_page(sg[i].page, (*offset >> PAGE_SHIFT)); | 2356 | page = nth_page(sg->page, (*offset >> PAGE_SHIFT)); |
2225 | *offset &= ~PAGE_MASK; | 2357 | *offset &= ~PAGE_MASK; |
2226 | 2358 | ||
2227 | /* Bytes in this sg-entry from *offset to the end of the page */ | 2359 | /* Bytes in this sg-entry from *offset to the end of the page */ |
diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c index 66c692ffa305..a91761c3645f 100644 --- a/drivers/scsi/scsi_tgt_lib.c +++ b/drivers/scsi/scsi_tgt_lib.c | |||
@@ -332,7 +332,7 @@ static void scsi_tgt_cmd_done(struct scsi_cmnd *cmd) | |||
332 | scsi_tgt_uspace_send_status(cmd, tcmd->itn_id, tcmd->tag); | 332 | scsi_tgt_uspace_send_status(cmd, tcmd->itn_id, tcmd->tag); |
333 | 333 | ||
334 | if (cmd->request_buffer) | 334 | if (cmd->request_buffer) |
335 | scsi_free_sgtable(cmd->request_buffer, cmd->sglist_len); | 335 | scsi_free_sgtable(cmd); |
336 | 336 | ||
337 | queue_work(scsi_tgtd, &tcmd->work); | 337 | queue_work(scsi_tgtd, &tcmd->work); |
338 | } | 338 | } |
@@ -373,7 +373,7 @@ static int scsi_tgt_init_cmd(struct scsi_cmnd *cmd, gfp_t gfp_mask) | |||
373 | } | 373 | } |
374 | 374 | ||
375 | eprintk("cmd %p cnt %d\n", cmd, cmd->use_sg); | 375 | eprintk("cmd %p cnt %d\n", cmd, cmd->use_sg); |
376 | scsi_free_sgtable(cmd->request_buffer, cmd->sglist_len); | 376 | scsi_free_sgtable(cmd); |
377 | return -EINVAL; | 377 | return -EINVAL; |
378 | } | 378 | } |
379 | 379 | ||
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 0a3a528212c2..69f542c4923c 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -826,27 +826,6 @@ static int sd_sync_cache(struct scsi_disk *sdkp) | |||
826 | return 0; | 826 | return 0; |
827 | } | 827 | } |
828 | 828 | ||
829 | static int sd_issue_flush(struct request_queue *q, struct gendisk *disk, | ||
830 | sector_t *error_sector) | ||
831 | { | ||
832 | int ret = 0; | ||
833 | struct scsi_device *sdp = q->queuedata; | ||
834 | struct scsi_disk *sdkp; | ||
835 | |||
836 | if (sdp->sdev_state != SDEV_RUNNING) | ||
837 | return -ENXIO; | ||
838 | |||
839 | sdkp = scsi_disk_get_from_dev(&sdp->sdev_gendev); | ||
840 | |||
841 | if (!sdkp) | ||
842 | return -ENODEV; | ||
843 | |||
844 | if (sdkp->WCE) | ||
845 | ret = sd_sync_cache(sdkp); | ||
846 | scsi_disk_put(sdkp); | ||
847 | return ret; | ||
848 | } | ||
849 | |||
850 | static void sd_prepare_flush(struct request_queue *q, struct request *rq) | 829 | static void sd_prepare_flush(struct request_queue *q, struct request *rq) |
851 | { | 830 | { |
852 | memset(rq->cmd, 0, sizeof(rq->cmd)); | 831 | memset(rq->cmd, 0, sizeof(rq->cmd)); |
@@ -1697,7 +1676,6 @@ static int sd_probe(struct device *dev) | |||
1697 | sd_revalidate_disk(gd); | 1676 | sd_revalidate_disk(gd); |
1698 | 1677 | ||
1699 | blk_queue_prep_rq(sdp->request_queue, sd_prep_fn); | 1678 | blk_queue_prep_rq(sdp->request_queue, sd_prep_fn); |
1700 | blk_queue_issue_flush_fn(sdp->request_queue, sd_issue_flush); | ||
1701 | 1679 | ||
1702 | gd->driverfs_dev = &sdp->sdev_gendev; | 1680 | gd->driverfs_dev = &sdp->sdev_gendev; |
1703 | gd->flags = GENHD_FL_DRIVERFS; | 1681 | gd->flags = GENHD_FL_DRIVERFS; |
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index f6f5fc7d0cee..7238b2dfc497 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -1165,7 +1165,7 @@ sg_vma_nopage(struct vm_area_struct *vma, unsigned long addr, int *type) | |||
1165 | sg = rsv_schp->buffer; | 1165 | sg = rsv_schp->buffer; |
1166 | sa = vma->vm_start; | 1166 | sa = vma->vm_start; |
1167 | for (k = 0; (k < rsv_schp->k_use_sg) && (sa < vma->vm_end); | 1167 | for (k = 0; (k < rsv_schp->k_use_sg) && (sa < vma->vm_end); |
1168 | ++k, ++sg) { | 1168 | ++k, sg = sg_next(sg)) { |
1169 | len = vma->vm_end - sa; | 1169 | len = vma->vm_end - sa; |
1170 | len = (len < sg->length) ? len : sg->length; | 1170 | len = (len < sg->length) ? len : sg->length; |
1171 | if (offset < len) { | 1171 | if (offset < len) { |
@@ -1209,7 +1209,7 @@ sg_mmap(struct file *filp, struct vm_area_struct *vma) | |||
1209 | sa = vma->vm_start; | 1209 | sa = vma->vm_start; |
1210 | sg = rsv_schp->buffer; | 1210 | sg = rsv_schp->buffer; |
1211 | for (k = 0; (k < rsv_schp->k_use_sg) && (sa < vma->vm_end); | 1211 | for (k = 0; (k < rsv_schp->k_use_sg) && (sa < vma->vm_end); |
1212 | ++k, ++sg) { | 1212 | ++k, sg = sg_next(sg)) { |
1213 | len = vma->vm_end - sa; | 1213 | len = vma->vm_end - sa; |
1214 | len = (len < sg->length) ? len : sg->length; | 1214 | len = (len < sg->length) ? len : sg->length; |
1215 | sa += len; | 1215 | sa += len; |
@@ -1840,7 +1840,7 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size) | |||
1840 | } | 1840 | } |
1841 | for (k = 0, sg = schp->buffer, rem_sz = blk_size; | 1841 | for (k = 0, sg = schp->buffer, rem_sz = blk_size; |
1842 | (rem_sz > 0) && (k < mx_sc_elems); | 1842 | (rem_sz > 0) && (k < mx_sc_elems); |
1843 | ++k, rem_sz -= ret_sz, ++sg) { | 1843 | ++k, rem_sz -= ret_sz, sg = sg_next(sg)) { |
1844 | 1844 | ||
1845 | num = (rem_sz > scatter_elem_sz_prev) ? | 1845 | num = (rem_sz > scatter_elem_sz_prev) ? |
1846 | scatter_elem_sz_prev : rem_sz; | 1846 | scatter_elem_sz_prev : rem_sz; |
@@ -1913,7 +1913,7 @@ sg_write_xfer(Sg_request * srp) | |||
1913 | if (res) | 1913 | if (res) |
1914 | return res; | 1914 | return res; |
1915 | 1915 | ||
1916 | for (; p; ++sg, ksglen = sg->length, | 1916 | for (; p; sg = sg_next(sg), ksglen = sg->length, |
1917 | p = page_address(sg->page)) { | 1917 | p = page_address(sg->page)) { |
1918 | if (usglen <= 0) | 1918 | if (usglen <= 0) |
1919 | break; | 1919 | break; |
@@ -1992,7 +1992,7 @@ sg_remove_scat(Sg_scatter_hold * schp) | |||
1992 | int k; | 1992 | int k; |
1993 | 1993 | ||
1994 | for (k = 0; (k < schp->k_use_sg) && sg->page; | 1994 | for (k = 0; (k < schp->k_use_sg) && sg->page; |
1995 | ++k, ++sg) { | 1995 | ++k, sg = sg_next(sg)) { |
1996 | SCSI_LOG_TIMEOUT(5, printk( | 1996 | SCSI_LOG_TIMEOUT(5, printk( |
1997 | "sg_remove_scat: k=%d, pg=0x%p, len=%d\n", | 1997 | "sg_remove_scat: k=%d, pg=0x%p, len=%d\n", |
1998 | k, sg->page, sg->length)); | 1998 | k, sg->page, sg->length)); |
@@ -2045,7 +2045,7 @@ sg_read_xfer(Sg_request * srp) | |||
2045 | if (res) | 2045 | if (res) |
2046 | return res; | 2046 | return res; |
2047 | 2047 | ||
2048 | for (; p; ++sg, ksglen = sg->length, | 2048 | for (; p; sg = sg_next(sg), ksglen = sg->length, |
2049 | p = page_address(sg->page)) { | 2049 | p = page_address(sg->page)) { |
2050 | if (usglen <= 0) | 2050 | if (usglen <= 0) |
2051 | break; | 2051 | break; |
@@ -2092,7 +2092,7 @@ sg_read_oxfer(Sg_request * srp, char __user *outp, int num_read_xfer) | |||
2092 | if ((!outp) || (num_read_xfer <= 0)) | 2092 | if ((!outp) || (num_read_xfer <= 0)) |
2093 | return 0; | 2093 | return 0; |
2094 | 2094 | ||
2095 | for (k = 0; (k < schp->k_use_sg) && sg->page; ++k, ++sg) { | 2095 | for (k = 0; (k < schp->k_use_sg) && sg->page; ++k, sg = sg_next(sg)) { |
2096 | num = sg->length; | 2096 | num = sg->length; |
2097 | if (num > num_read_xfer) { | 2097 | if (num > num_read_xfer) { |
2098 | if (__copy_to_user(outp, page_address(sg->page), | 2098 | if (__copy_to_user(outp, page_address(sg->page), |
@@ -2142,7 +2142,7 @@ sg_link_reserve(Sg_fd * sfp, Sg_request * srp, int size) | |||
2142 | SCSI_LOG_TIMEOUT(4, printk("sg_link_reserve: size=%d\n", size)); | 2142 | SCSI_LOG_TIMEOUT(4, printk("sg_link_reserve: size=%d\n", size)); |
2143 | rem = size; | 2143 | rem = size; |
2144 | 2144 | ||
2145 | for (k = 0; k < rsv_schp->k_use_sg; ++k, ++sg) { | 2145 | for (k = 0; k < rsv_schp->k_use_sg; ++k, sg = sg_next(sg)) { |
2146 | num = sg->length; | 2146 | num = sg->length; |
2147 | if (rem <= num) { | 2147 | if (rem <= num) { |
2148 | sfp->save_scat_len = num; | 2148 | sfp->save_scat_len = num; |
diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c index 72f6d8015358..e3fab3a6aed7 100644 --- a/drivers/scsi/stex.c +++ b/drivers/scsi/stex.c | |||
@@ -1123,6 +1123,7 @@ static struct scsi_host_template driver_template = { | |||
1123 | .this_id = -1, | 1123 | .this_id = -1, |
1124 | .sg_tablesize = ST_MAX_SG, | 1124 | .sg_tablesize = ST_MAX_SG, |
1125 | .cmd_per_lun = ST_CMD_PER_LUN, | 1125 | .cmd_per_lun = ST_CMD_PER_LUN, |
1126 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
1126 | }; | 1127 | }; |
1127 | 1128 | ||
1128 | static int stex_set_dma_mask(struct pci_dev * pdev) | 1129 | static int stex_set_dma_mask(struct pci_dev * pdev) |
diff --git a/drivers/scsi/sym53c416.c b/drivers/scsi/sym53c416.c index 92bfaeafe30d..8befab7e9839 100644 --- a/drivers/scsi/sym53c416.c +++ b/drivers/scsi/sym53c416.c | |||
@@ -854,5 +854,6 @@ static struct scsi_host_template driver_template = { | |||
854 | .cmd_per_lun = 1, | 854 | .cmd_per_lun = 1, |
855 | .unchecked_isa_dma = 1, | 855 | .unchecked_isa_dma = 1, |
856 | .use_clustering = ENABLE_CLUSTERING, | 856 | .use_clustering = ENABLE_CLUSTERING, |
857 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
857 | }; | 858 | }; |
858 | #include "scsi_module.c" | 859 | #include "scsi_module.c" |
diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index 3db22325ea2c..db03c4c8ec1e 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c | |||
@@ -1808,6 +1808,7 @@ static struct scsi_host_template sym2_template = { | |||
1808 | .eh_host_reset_handler = sym53c8xx_eh_host_reset_handler, | 1808 | .eh_host_reset_handler = sym53c8xx_eh_host_reset_handler, |
1809 | .this_id = 7, | 1809 | .this_id = 7, |
1810 | .use_clustering = ENABLE_CLUSTERING, | 1810 | .use_clustering = ENABLE_CLUSTERING, |
1811 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
1811 | .max_sectors = 0xFFFF, | 1812 | .max_sectors = 0xFFFF, |
1812 | #ifdef SYM_LINUX_PROC_INFO_SUPPORT | 1813 | #ifdef SYM_LINUX_PROC_INFO_SUPPORT |
1813 | .proc_info = sym53c8xx_proc_info, | 1814 | .proc_info = sym53c8xx_proc_info, |
diff --git a/drivers/scsi/u14-34f.c b/drivers/scsi/u14-34f.c index fc9f51818e8f..7edd6ceb13b2 100644 --- a/drivers/scsi/u14-34f.c +++ b/drivers/scsi/u14-34f.c | |||
@@ -450,7 +450,8 @@ static struct scsi_host_template driver_template = { | |||
450 | .slave_configure = u14_34f_slave_configure, | 450 | .slave_configure = u14_34f_slave_configure, |
451 | .this_id = 7, | 451 | .this_id = 7, |
452 | .unchecked_isa_dma = 1, | 452 | .unchecked_isa_dma = 1, |
453 | .use_clustering = ENABLE_CLUSTERING | 453 | .use_clustering = ENABLE_CLUSTERING, |
454 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
454 | }; | 455 | }; |
455 | 456 | ||
456 | #if !defined(__BIG_ENDIAN_BITFIELD) && !defined(__LITTLE_ENDIAN_BITFIELD) | 457 | #if !defined(__BIG_ENDIAN_BITFIELD) && !defined(__LITTLE_ENDIAN_BITFIELD) |
diff --git a/drivers/scsi/ultrastor.c b/drivers/scsi/ultrastor.c index c08235d5afc9..ea72bbeb8f9d 100644 --- a/drivers/scsi/ultrastor.c +++ b/drivers/scsi/ultrastor.c | |||
@@ -1197,5 +1197,6 @@ static struct scsi_host_template driver_template = { | |||
1197 | .cmd_per_lun = ULTRASTOR_MAX_CMDS_PER_LUN, | 1197 | .cmd_per_lun = ULTRASTOR_MAX_CMDS_PER_LUN, |
1198 | .unchecked_isa_dma = 1, | 1198 | .unchecked_isa_dma = 1, |
1199 | .use_clustering = ENABLE_CLUSTERING, | 1199 | .use_clustering = ENABLE_CLUSTERING, |
1200 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
1200 | }; | 1201 | }; |
1201 | #include "scsi_module.c" | 1202 | #include "scsi_module.c" |
diff --git a/drivers/scsi/wd7000.c b/drivers/scsi/wd7000.c index d6fd4259c56b..255c611e78b8 100644 --- a/drivers/scsi/wd7000.c +++ b/drivers/scsi/wd7000.c | |||
@@ -1671,6 +1671,7 @@ static struct scsi_host_template driver_template = { | |||
1671 | .cmd_per_lun = 1, | 1671 | .cmd_per_lun = 1, |
1672 | .unchecked_isa_dma = 1, | 1672 | .unchecked_isa_dma = 1, |
1673 | .use_clustering = ENABLE_CLUSTERING, | 1673 | .use_clustering = ENABLE_CLUSTERING, |
1674 | .use_sg_chaining = ENABLE_SG_CHAINING, | ||
1674 | }; | 1675 | }; |
1675 | 1676 | ||
1676 | #include "scsi_module.c" | 1677 | #include "scsi_module.c" |
diff --git a/drivers/usb/storage/alauda.c b/drivers/usb/storage/alauda.c index 4d3cbb12b713..8d3711a7ff06 100644 --- a/drivers/usb/storage/alauda.c +++ b/drivers/usb/storage/alauda.c | |||
@@ -798,12 +798,13 @@ static int alauda_read_data(struct us_data *us, unsigned long address, | |||
798 | { | 798 | { |
799 | unsigned char *buffer; | 799 | unsigned char *buffer; |
800 | u16 lba, max_lba; | 800 | u16 lba, max_lba; |
801 | unsigned int page, len, index, offset; | 801 | unsigned int page, len, offset; |
802 | unsigned int blockshift = MEDIA_INFO(us).blockshift; | 802 | unsigned int blockshift = MEDIA_INFO(us).blockshift; |
803 | unsigned int pageshift = MEDIA_INFO(us).pageshift; | 803 | unsigned int pageshift = MEDIA_INFO(us).pageshift; |
804 | unsigned int blocksize = MEDIA_INFO(us).blocksize; | 804 | unsigned int blocksize = MEDIA_INFO(us).blocksize; |
805 | unsigned int pagesize = MEDIA_INFO(us).pagesize; | 805 | unsigned int pagesize = MEDIA_INFO(us).pagesize; |
806 | unsigned int uzonesize = MEDIA_INFO(us).uzonesize; | 806 | unsigned int uzonesize = MEDIA_INFO(us).uzonesize; |
807 | struct scatterlist *sg; | ||
807 | int result; | 808 | int result; |
808 | 809 | ||
809 | /* | 810 | /* |
@@ -827,7 +828,8 @@ static int alauda_read_data(struct us_data *us, unsigned long address, | |||
827 | max_lba = MEDIA_INFO(us).capacity >> (blockshift + pageshift); | 828 | max_lba = MEDIA_INFO(us).capacity >> (blockshift + pageshift); |
828 | 829 | ||
829 | result = USB_STOR_TRANSPORT_GOOD; | 830 | result = USB_STOR_TRANSPORT_GOOD; |
830 | index = offset = 0; | 831 | offset = 0; |
832 | sg = NULL; | ||
831 | 833 | ||
832 | while (sectors > 0) { | 834 | while (sectors > 0) { |
833 | unsigned int zone = lba / uzonesize; /* integer division */ | 835 | unsigned int zone = lba / uzonesize; /* integer division */ |
@@ -873,7 +875,7 @@ static int alauda_read_data(struct us_data *us, unsigned long address, | |||
873 | 875 | ||
874 | /* Store the data in the transfer buffer */ | 876 | /* Store the data in the transfer buffer */ |
875 | usb_stor_access_xfer_buf(buffer, len, us->srb, | 877 | usb_stor_access_xfer_buf(buffer, len, us->srb, |
876 | &index, &offset, TO_XFER_BUF); | 878 | &sg, &offset, TO_XFER_BUF); |
877 | 879 | ||
878 | page = 0; | 880 | page = 0; |
879 | lba++; | 881 | lba++; |
@@ -891,11 +893,12 @@ static int alauda_write_data(struct us_data *us, unsigned long address, | |||
891 | unsigned int sectors) | 893 | unsigned int sectors) |
892 | { | 894 | { |
893 | unsigned char *buffer, *blockbuffer; | 895 | unsigned char *buffer, *blockbuffer; |
894 | unsigned int page, len, index, offset; | 896 | unsigned int page, len, offset; |
895 | unsigned int blockshift = MEDIA_INFO(us).blockshift; | 897 | unsigned int blockshift = MEDIA_INFO(us).blockshift; |
896 | unsigned int pageshift = MEDIA_INFO(us).pageshift; | 898 | unsigned int pageshift = MEDIA_INFO(us).pageshift; |
897 | unsigned int blocksize = MEDIA_INFO(us).blocksize; | 899 | unsigned int blocksize = MEDIA_INFO(us).blocksize; |
898 | unsigned int pagesize = MEDIA_INFO(us).pagesize; | 900 | unsigned int pagesize = MEDIA_INFO(us).pagesize; |
901 | struct scatterlist *sg; | ||
899 | u16 lba, max_lba; | 902 | u16 lba, max_lba; |
900 | int result; | 903 | int result; |
901 | 904 | ||
@@ -929,7 +932,8 @@ static int alauda_write_data(struct us_data *us, unsigned long address, | |||
929 | max_lba = MEDIA_INFO(us).capacity >> (pageshift + blockshift); | 932 | max_lba = MEDIA_INFO(us).capacity >> (pageshift + blockshift); |
930 | 933 | ||
931 | result = USB_STOR_TRANSPORT_GOOD; | 934 | result = USB_STOR_TRANSPORT_GOOD; |
932 | index = offset = 0; | 935 | offset = 0; |
936 | sg = NULL; | ||
933 | 937 | ||
934 | while (sectors > 0) { | 938 | while (sectors > 0) { |
935 | /* Write as many sectors as possible in this block */ | 939 | /* Write as many sectors as possible in this block */ |
@@ -946,7 +950,7 @@ static int alauda_write_data(struct us_data *us, unsigned long address, | |||
946 | 950 | ||
947 | /* Get the data from the transfer buffer */ | 951 | /* Get the data from the transfer buffer */ |
948 | usb_stor_access_xfer_buf(buffer, len, us->srb, | 952 | usb_stor_access_xfer_buf(buffer, len, us->srb, |
949 | &index, &offset, FROM_XFER_BUF); | 953 | &sg, &offset, FROM_XFER_BUF); |
950 | 954 | ||
951 | result = alauda_write_lba(us, lba, page, pages, buffer, | 955 | result = alauda_write_lba(us, lba, page, pages, buffer, |
952 | blockbuffer); | 956 | blockbuffer); |
diff --git a/drivers/usb/storage/datafab.c b/drivers/usb/storage/datafab.c index c87ad1bae1d6..579e9f52053a 100644 --- a/drivers/usb/storage/datafab.c +++ b/drivers/usb/storage/datafab.c | |||
@@ -98,7 +98,8 @@ static int datafab_read_data(struct us_data *us, | |||
98 | unsigned char thistime; | 98 | unsigned char thistime; |
99 | unsigned int totallen, alloclen; | 99 | unsigned int totallen, alloclen; |
100 | int len, result; | 100 | int len, result; |
101 | unsigned int sg_idx = 0, sg_offset = 0; | 101 | unsigned int sg_offset = 0; |
102 | struct scatterlist *sg = NULL; | ||
102 | 103 | ||
103 | // we're working in LBA mode. according to the ATA spec, | 104 | // we're working in LBA mode. according to the ATA spec, |
104 | // we can support up to 28-bit addressing. I don't know if Datafab | 105 | // we can support up to 28-bit addressing. I don't know if Datafab |
@@ -155,7 +156,7 @@ static int datafab_read_data(struct us_data *us, | |||
155 | 156 | ||
156 | // Store the data in the transfer buffer | 157 | // Store the data in the transfer buffer |
157 | usb_stor_access_xfer_buf(buffer, len, us->srb, | 158 | usb_stor_access_xfer_buf(buffer, len, us->srb, |
158 | &sg_idx, &sg_offset, TO_XFER_BUF); | 159 | &sg, &sg_offset, TO_XFER_BUF); |
159 | 160 | ||
160 | sector += thistime; | 161 | sector += thistime; |
161 | totallen -= len; | 162 | totallen -= len; |
@@ -181,7 +182,8 @@ static int datafab_write_data(struct us_data *us, | |||
181 | unsigned char thistime; | 182 | unsigned char thistime; |
182 | unsigned int totallen, alloclen; | 183 | unsigned int totallen, alloclen; |
183 | int len, result; | 184 | int len, result; |
184 | unsigned int sg_idx = 0, sg_offset = 0; | 185 | unsigned int sg_offset = 0; |
186 | struct scatterlist *sg = NULL; | ||
185 | 187 | ||
186 | // we're working in LBA mode. according to the ATA spec, | 188 | // we're working in LBA mode. according to the ATA spec, |
187 | // we can support up to 28-bit addressing. I don't know if Datafab | 189 | // we can support up to 28-bit addressing. I don't know if Datafab |
@@ -217,7 +219,7 @@ static int datafab_write_data(struct us_data *us, | |||
217 | 219 | ||
218 | // Get the data from the transfer buffer | 220 | // Get the data from the transfer buffer |
219 | usb_stor_access_xfer_buf(buffer, len, us->srb, | 221 | usb_stor_access_xfer_buf(buffer, len, us->srb, |
220 | &sg_idx, &sg_offset, FROM_XFER_BUF); | 222 | &sg, &sg_offset, FROM_XFER_BUF); |
221 | 223 | ||
222 | command[0] = 0; | 224 | command[0] = 0; |
223 | command[1] = thistime; | 225 | command[1] = thistime; |
diff --git a/drivers/usb/storage/jumpshot.c b/drivers/usb/storage/jumpshot.c index 003fcf545888..61097cbb1585 100644 --- a/drivers/usb/storage/jumpshot.c +++ b/drivers/usb/storage/jumpshot.c | |||
@@ -119,7 +119,8 @@ static int jumpshot_read_data(struct us_data *us, | |||
119 | unsigned char thistime; | 119 | unsigned char thistime; |
120 | unsigned int totallen, alloclen; | 120 | unsigned int totallen, alloclen; |
121 | int len, result; | 121 | int len, result; |
122 | unsigned int sg_idx = 0, sg_offset = 0; | 122 | unsigned int sg_offset = 0; |
123 | struct scatterlist *sg = NULL; | ||
123 | 124 | ||
124 | // we're working in LBA mode. according to the ATA spec, | 125 | // we're working in LBA mode. according to the ATA spec, |
125 | // we can support up to 28-bit addressing. I don't know if Jumpshot | 126 | // we can support up to 28-bit addressing. I don't know if Jumpshot |
@@ -170,7 +171,7 @@ static int jumpshot_read_data(struct us_data *us, | |||
170 | 171 | ||
171 | // Store the data in the transfer buffer | 172 | // Store the data in the transfer buffer |
172 | usb_stor_access_xfer_buf(buffer, len, us->srb, | 173 | usb_stor_access_xfer_buf(buffer, len, us->srb, |
173 | &sg_idx, &sg_offset, TO_XFER_BUF); | 174 | &sg, &sg_offset, TO_XFER_BUF); |
174 | 175 | ||
175 | sector += thistime; | 176 | sector += thistime; |
176 | totallen -= len; | 177 | totallen -= len; |
@@ -195,7 +196,8 @@ static int jumpshot_write_data(struct us_data *us, | |||
195 | unsigned char thistime; | 196 | unsigned char thistime; |
196 | unsigned int totallen, alloclen; | 197 | unsigned int totallen, alloclen; |
197 | int len, result, waitcount; | 198 | int len, result, waitcount; |
198 | unsigned int sg_idx = 0, sg_offset = 0; | 199 | unsigned int sg_offset = 0; |
200 | struct scatterlist *sg = NULL; | ||
199 | 201 | ||
200 | // we're working in LBA mode. according to the ATA spec, | 202 | // we're working in LBA mode. according to the ATA spec, |
201 | // we can support up to 28-bit addressing. I don't know if Jumpshot | 203 | // we can support up to 28-bit addressing. I don't know if Jumpshot |
@@ -225,7 +227,7 @@ static int jumpshot_write_data(struct us_data *us, | |||
225 | 227 | ||
226 | // Get the data from the transfer buffer | 228 | // Get the data from the transfer buffer |
227 | usb_stor_access_xfer_buf(buffer, len, us->srb, | 229 | usb_stor_access_xfer_buf(buffer, len, us->srb, |
228 | &sg_idx, &sg_offset, FROM_XFER_BUF); | 230 | &sg, &sg_offset, FROM_XFER_BUF); |
229 | 231 | ||
230 | command[0] = 0; | 232 | command[0] = 0; |
231 | command[1] = thistime; | 233 | command[1] = thistime; |
diff --git a/drivers/usb/storage/protocol.c b/drivers/usb/storage/protocol.c index 9ad30428d2dd..cc8f7c52c729 100644 --- a/drivers/usb/storage/protocol.c +++ b/drivers/usb/storage/protocol.c | |||
@@ -157,7 +157,7 @@ void usb_stor_transparent_scsi_command(struct scsi_cmnd *srb, | |||
157 | * pick up from where this one left off. */ | 157 | * pick up from where this one left off. */ |
158 | 158 | ||
159 | unsigned int usb_stor_access_xfer_buf(unsigned char *buffer, | 159 | unsigned int usb_stor_access_xfer_buf(unsigned char *buffer, |
160 | unsigned int buflen, struct scsi_cmnd *srb, unsigned int *index, | 160 | unsigned int buflen, struct scsi_cmnd *srb, struct scatterlist **sgptr, |
161 | unsigned int *offset, enum xfer_buf_dir dir) | 161 | unsigned int *offset, enum xfer_buf_dir dir) |
162 | { | 162 | { |
163 | unsigned int cnt; | 163 | unsigned int cnt; |
@@ -184,16 +184,17 @@ unsigned int usb_stor_access_xfer_buf(unsigned char *buffer, | |||
184 | * located in high memory -- then kmap() will map it to a temporary | 184 | * located in high memory -- then kmap() will map it to a temporary |
185 | * position in the kernel's virtual address space. */ | 185 | * position in the kernel's virtual address space. */ |
186 | } else { | 186 | } else { |
187 | struct scatterlist *sg = | 187 | struct scatterlist *sg = *sgptr; |
188 | (struct scatterlist *) srb->request_buffer | 188 | |
189 | + *index; | 189 | if (!sg) |
190 | sg = (struct scatterlist *) srb->request_buffer; | ||
190 | 191 | ||
191 | /* This loop handles a single s-g list entry, which may | 192 | /* This loop handles a single s-g list entry, which may |
192 | * include multiple pages. Find the initial page structure | 193 | * include multiple pages. Find the initial page structure |
193 | * and the starting offset within the page, and update | 194 | * and the starting offset within the page, and update |
194 | * the *offset and *index values for the next loop. */ | 195 | * the *offset and *index values for the next loop. */ |
195 | cnt = 0; | 196 | cnt = 0; |
196 | while (cnt < buflen && *index < srb->use_sg) { | 197 | while (cnt < buflen) { |
197 | struct page *page = sg->page + | 198 | struct page *page = sg->page + |
198 | ((sg->offset + *offset) >> PAGE_SHIFT); | 199 | ((sg->offset + *offset) >> PAGE_SHIFT); |
199 | unsigned int poff = | 200 | unsigned int poff = |
@@ -209,8 +210,7 @@ unsigned int usb_stor_access_xfer_buf(unsigned char *buffer, | |||
209 | 210 | ||
210 | /* Transfer continues to next s-g entry */ | 211 | /* Transfer continues to next s-g entry */ |
211 | *offset = 0; | 212 | *offset = 0; |
212 | ++*index; | 213 | sg = sg_next(sg); |
213 | ++sg; | ||
214 | } | 214 | } |
215 | 215 | ||
216 | /* Transfer the data for all the pages in this | 216 | /* Transfer the data for all the pages in this |
@@ -234,6 +234,7 @@ unsigned int usb_stor_access_xfer_buf(unsigned char *buffer, | |||
234 | sglen -= plen; | 234 | sglen -= plen; |
235 | } | 235 | } |
236 | } | 236 | } |
237 | *sgptr = sg; | ||
237 | } | 238 | } |
238 | 239 | ||
239 | /* Return the amount actually transferred */ | 240 | /* Return the amount actually transferred */ |
@@ -245,9 +246,10 @@ unsigned int usb_stor_access_xfer_buf(unsigned char *buffer, | |||
245 | void usb_stor_set_xfer_buf(unsigned char *buffer, | 246 | void usb_stor_set_xfer_buf(unsigned char *buffer, |
246 | unsigned int buflen, struct scsi_cmnd *srb) | 247 | unsigned int buflen, struct scsi_cmnd *srb) |
247 | { | 248 | { |
248 | unsigned int index = 0, offset = 0; | 249 | unsigned int offset = 0; |
250 | struct scatterlist *sg = NULL; | ||
249 | 251 | ||
250 | usb_stor_access_xfer_buf(buffer, buflen, srb, &index, &offset, | 252 | usb_stor_access_xfer_buf(buffer, buflen, srb, &sg, &offset, |
251 | TO_XFER_BUF); | 253 | TO_XFER_BUF); |
252 | if (buflen < srb->request_bufflen) | 254 | if (buflen < srb->request_bufflen) |
253 | srb->resid = srb->request_bufflen - buflen; | 255 | srb->resid = srb->request_bufflen - buflen; |
diff --git a/drivers/usb/storage/protocol.h b/drivers/usb/storage/protocol.h index 845bed4b8031..8737a36891ca 100644 --- a/drivers/usb/storage/protocol.h +++ b/drivers/usb/storage/protocol.h | |||
@@ -52,7 +52,7 @@ extern void usb_stor_transparent_scsi_command(struct scsi_cmnd*, | |||
52 | enum xfer_buf_dir {TO_XFER_BUF, FROM_XFER_BUF}; | 52 | enum xfer_buf_dir {TO_XFER_BUF, FROM_XFER_BUF}; |
53 | 53 | ||
54 | extern unsigned int usb_stor_access_xfer_buf(unsigned char *buffer, | 54 | extern unsigned int usb_stor_access_xfer_buf(unsigned char *buffer, |
55 | unsigned int buflen, struct scsi_cmnd *srb, unsigned int *index, | 55 | unsigned int buflen, struct scsi_cmnd *srb, struct scatterlist **, |
56 | unsigned int *offset, enum xfer_buf_dir dir); | 56 | unsigned int *offset, enum xfer_buf_dir dir); |
57 | 57 | ||
58 | extern void usb_stor_set_xfer_buf(unsigned char *buffer, | 58 | extern void usb_stor_set_xfer_buf(unsigned char *buffer, |
diff --git a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c index b2ed2a3e6fca..b12202c5da2d 100644 --- a/drivers/usb/storage/sddr09.c +++ b/drivers/usb/storage/sddr09.c | |||
@@ -705,7 +705,8 @@ sddr09_read_data(struct us_data *us, | |||
705 | unsigned char *buffer; | 705 | unsigned char *buffer; |
706 | unsigned int lba, maxlba, pba; | 706 | unsigned int lba, maxlba, pba; |
707 | unsigned int page, pages; | 707 | unsigned int page, pages; |
708 | unsigned int len, index, offset; | 708 | unsigned int len, offset; |
709 | struct scatterlist *sg; | ||
709 | int result; | 710 | int result; |
710 | 711 | ||
711 | // Figure out the initial LBA and page | 712 | // Figure out the initial LBA and page |
@@ -730,7 +731,8 @@ sddr09_read_data(struct us_data *us, | |||
730 | // contiguous LBA's. Another exercise left to the student. | 731 | // contiguous LBA's. Another exercise left to the student. |
731 | 732 | ||
732 | result = 0; | 733 | result = 0; |
733 | index = offset = 0; | 734 | offset = 0; |
735 | sg = NULL; | ||
734 | 736 | ||
735 | while (sectors > 0) { | 737 | while (sectors > 0) { |
736 | 738 | ||
@@ -777,7 +779,7 @@ sddr09_read_data(struct us_data *us, | |||
777 | 779 | ||
778 | // Store the data in the transfer buffer | 780 | // Store the data in the transfer buffer |
779 | usb_stor_access_xfer_buf(buffer, len, us->srb, | 781 | usb_stor_access_xfer_buf(buffer, len, us->srb, |
780 | &index, &offset, TO_XFER_BUF); | 782 | &sg, &offset, TO_XFER_BUF); |
781 | 783 | ||
782 | page = 0; | 784 | page = 0; |
783 | lba++; | 785 | lba++; |
@@ -931,7 +933,8 @@ sddr09_write_data(struct us_data *us, | |||
931 | unsigned int pagelen, blocklen; | 933 | unsigned int pagelen, blocklen; |
932 | unsigned char *blockbuffer; | 934 | unsigned char *blockbuffer; |
933 | unsigned char *buffer; | 935 | unsigned char *buffer; |
934 | unsigned int len, index, offset; | 936 | unsigned int len, offset; |
937 | struct scatterlist *sg; | ||
935 | int result; | 938 | int result; |
936 | 939 | ||
937 | // Figure out the initial LBA and page | 940 | // Figure out the initial LBA and page |
@@ -968,7 +971,8 @@ sddr09_write_data(struct us_data *us, | |||
968 | } | 971 | } |
969 | 972 | ||
970 | result = 0; | 973 | result = 0; |
971 | index = offset = 0; | 974 | offset = 0; |
975 | sg = NULL; | ||
972 | 976 | ||
973 | while (sectors > 0) { | 977 | while (sectors > 0) { |
974 | 978 | ||
@@ -987,7 +991,7 @@ sddr09_write_data(struct us_data *us, | |||
987 | 991 | ||
988 | // Get the data from the transfer buffer | 992 | // Get the data from the transfer buffer |
989 | usb_stor_access_xfer_buf(buffer, len, us->srb, | 993 | usb_stor_access_xfer_buf(buffer, len, us->srb, |
990 | &index, &offset, FROM_XFER_BUF); | 994 | &sg, &offset, FROM_XFER_BUF); |
991 | 995 | ||
992 | result = sddr09_write_lba(us, lba, page, pages, | 996 | result = sddr09_write_lba(us, lba, page, pages, |
993 | buffer, blockbuffer); | 997 | buffer, blockbuffer); |
diff --git a/drivers/usb/storage/sddr55.c b/drivers/usb/storage/sddr55.c index 0b1b5b59ca7b..d43a3415e12f 100644 --- a/drivers/usb/storage/sddr55.c +++ b/drivers/usb/storage/sddr55.c | |||
@@ -167,7 +167,8 @@ static int sddr55_read_data(struct us_data *us, | |||
167 | unsigned long address; | 167 | unsigned long address; |
168 | 168 | ||
169 | unsigned short pages; | 169 | unsigned short pages; |
170 | unsigned int len, index, offset; | 170 | unsigned int len, offset; |
171 | struct scatterlist *sg; | ||
171 | 172 | ||
172 | // Since we only read in one block at a time, we have to create | 173 | // Since we only read in one block at a time, we have to create |
173 | // a bounce buffer and move the data a piece at a time between the | 174 | // a bounce buffer and move the data a piece at a time between the |
@@ -178,7 +179,8 @@ static int sddr55_read_data(struct us_data *us, | |||
178 | buffer = kmalloc(len, GFP_NOIO); | 179 | buffer = kmalloc(len, GFP_NOIO); |
179 | if (buffer == NULL) | 180 | if (buffer == NULL) |
180 | return USB_STOR_TRANSPORT_ERROR; /* out of memory */ | 181 | return USB_STOR_TRANSPORT_ERROR; /* out of memory */ |
181 | index = offset = 0; | 182 | offset = 0; |
183 | sg = NULL; | ||
182 | 184 | ||
183 | while (sectors>0) { | 185 | while (sectors>0) { |
184 | 186 | ||
@@ -255,7 +257,7 @@ static int sddr55_read_data(struct us_data *us, | |||
255 | 257 | ||
256 | // Store the data in the transfer buffer | 258 | // Store the data in the transfer buffer |
257 | usb_stor_access_xfer_buf(buffer, len, us->srb, | 259 | usb_stor_access_xfer_buf(buffer, len, us->srb, |
258 | &index, &offset, TO_XFER_BUF); | 260 | &sg, &offset, TO_XFER_BUF); |
259 | 261 | ||
260 | page = 0; | 262 | page = 0; |
261 | lba++; | 263 | lba++; |
@@ -287,7 +289,8 @@ static int sddr55_write_data(struct us_data *us, | |||
287 | 289 | ||
288 | unsigned short pages; | 290 | unsigned short pages; |
289 | int i; | 291 | int i; |
290 | unsigned int len, index, offset; | 292 | unsigned int len, offset; |
293 | struct scatterlist *sg; | ||
291 | 294 | ||
292 | /* check if we are allowed to write */ | 295 | /* check if we are allowed to write */ |
293 | if (info->read_only || info->force_read_only) { | 296 | if (info->read_only || info->force_read_only) { |
@@ -304,7 +307,8 @@ static int sddr55_write_data(struct us_data *us, | |||
304 | buffer = kmalloc(len, GFP_NOIO); | 307 | buffer = kmalloc(len, GFP_NOIO); |
305 | if (buffer == NULL) | 308 | if (buffer == NULL) |
306 | return USB_STOR_TRANSPORT_ERROR; | 309 | return USB_STOR_TRANSPORT_ERROR; |
307 | index = offset = 0; | 310 | offset = 0; |
311 | sg = NULL; | ||
308 | 312 | ||
309 | while (sectors > 0) { | 313 | while (sectors > 0) { |
310 | 314 | ||
@@ -322,7 +326,7 @@ static int sddr55_write_data(struct us_data *us, | |||
322 | 326 | ||
323 | // Get the data from the transfer buffer | 327 | // Get the data from the transfer buffer |
324 | usb_stor_access_xfer_buf(buffer, len, us->srb, | 328 | usb_stor_access_xfer_buf(buffer, len, us->srb, |
325 | &index, &offset, FROM_XFER_BUF); | 329 | &sg, &offset, FROM_XFER_BUF); |
326 | 330 | ||
327 | US_DEBUGP("Write %02X pages, to PBA %04X" | 331 | US_DEBUGP("Write %02X pages, to PBA %04X" |
328 | " (LBA %04X) page %02X\n", | 332 | " (LBA %04X) page %02X\n", |
diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c index 17ca4d73577b..cb22a9ad1694 100644 --- a/drivers/usb/storage/shuttle_usbat.c +++ b/drivers/usb/storage/shuttle_usbat.c | |||
@@ -993,7 +993,8 @@ static int usbat_flash_read_data(struct us_data *us, | |||
993 | unsigned char thistime; | 993 | unsigned char thistime; |
994 | unsigned int totallen, alloclen; | 994 | unsigned int totallen, alloclen; |
995 | int len, result; | 995 | int len, result; |
996 | unsigned int sg_idx = 0, sg_offset = 0; | 996 | unsigned int sg_offset = 0; |
997 | struct scatterlist *sg = NULL; | ||
997 | 998 | ||
998 | result = usbat_flash_check_media(us, info); | 999 | result = usbat_flash_check_media(us, info); |
999 | if (result != USB_STOR_TRANSPORT_GOOD) | 1000 | if (result != USB_STOR_TRANSPORT_GOOD) |
@@ -1047,7 +1048,7 @@ static int usbat_flash_read_data(struct us_data *us, | |||
1047 | 1048 | ||
1048 | /* Store the data in the transfer buffer */ | 1049 | /* Store the data in the transfer buffer */ |
1049 | usb_stor_access_xfer_buf(buffer, len, us->srb, | 1050 | usb_stor_access_xfer_buf(buffer, len, us->srb, |
1050 | &sg_idx, &sg_offset, TO_XFER_BUF); | 1051 | &sg, &sg_offset, TO_XFER_BUF); |
1051 | 1052 | ||
1052 | sector += thistime; | 1053 | sector += thistime; |
1053 | totallen -= len; | 1054 | totallen -= len; |
@@ -1083,7 +1084,8 @@ static int usbat_flash_write_data(struct us_data *us, | |||
1083 | unsigned char thistime; | 1084 | unsigned char thistime; |
1084 | unsigned int totallen, alloclen; | 1085 | unsigned int totallen, alloclen; |
1085 | int len, result; | 1086 | int len, result; |
1086 | unsigned int sg_idx = 0, sg_offset = 0; | 1087 | unsigned int sg_offset = 0; |
1088 | struct scatterlist *sg = NULL; | ||
1087 | 1089 | ||
1088 | result = usbat_flash_check_media(us, info); | 1090 | result = usbat_flash_check_media(us, info); |
1089 | if (result != USB_STOR_TRANSPORT_GOOD) | 1091 | if (result != USB_STOR_TRANSPORT_GOOD) |
@@ -1122,7 +1124,7 @@ static int usbat_flash_write_data(struct us_data *us, | |||
1122 | 1124 | ||
1123 | /* Get the data from the transfer buffer */ | 1125 | /* Get the data from the transfer buffer */ |
1124 | usb_stor_access_xfer_buf(buffer, len, us->srb, | 1126 | usb_stor_access_xfer_buf(buffer, len, us->srb, |
1125 | &sg_idx, &sg_offset, FROM_XFER_BUF); | 1127 | &sg, &sg_offset, FROM_XFER_BUF); |
1126 | 1128 | ||
1127 | /* ATA command 0x30 (WRITE SECTORS) */ | 1129 | /* ATA command 0x30 (WRITE SECTORS) */ |
1128 | usbat_pack_ata_sector_cmd(command, thistime, sector, 0x30); | 1130 | usbat_pack_ata_sector_cmd(command, thistime, sector, 0x30); |
@@ -1162,8 +1164,8 @@ static int usbat_hp8200e_handle_read10(struct us_data *us, | |||
1162 | unsigned char *buffer; | 1164 | unsigned char *buffer; |
1163 | unsigned int len; | 1165 | unsigned int len; |
1164 | unsigned int sector; | 1166 | unsigned int sector; |
1165 | unsigned int sg_segment = 0; | ||
1166 | unsigned int sg_offset = 0; | 1167 | unsigned int sg_offset = 0; |
1168 | struct scatterlist *sg = NULL; | ||
1167 | 1169 | ||
1168 | US_DEBUGP("handle_read10: transfersize %d\n", | 1170 | US_DEBUGP("handle_read10: transfersize %d\n", |
1169 | srb->transfersize); | 1171 | srb->transfersize); |
@@ -1220,9 +1222,6 @@ static int usbat_hp8200e_handle_read10(struct us_data *us, | |||
1220 | sector |= short_pack(data[7+5], data[7+4]); | 1222 | sector |= short_pack(data[7+5], data[7+4]); |
1221 | transferred = 0; | 1223 | transferred = 0; |
1222 | 1224 | ||
1223 | sg_segment = 0; /* for keeping track of where we are in */ | ||
1224 | sg_offset = 0; /* the scatter/gather list */ | ||
1225 | |||
1226 | while (transferred != srb->request_bufflen) { | 1225 | while (transferred != srb->request_bufflen) { |
1227 | 1226 | ||
1228 | if (len > srb->request_bufflen - transferred) | 1227 | if (len > srb->request_bufflen - transferred) |
@@ -1255,7 +1254,7 @@ static int usbat_hp8200e_handle_read10(struct us_data *us, | |||
1255 | 1254 | ||
1256 | /* Store the data in the transfer buffer */ | 1255 | /* Store the data in the transfer buffer */ |
1257 | usb_stor_access_xfer_buf(buffer, len, srb, | 1256 | usb_stor_access_xfer_buf(buffer, len, srb, |
1258 | &sg_segment, &sg_offset, TO_XFER_BUF); | 1257 | &sg, &sg_offset, TO_XFER_BUF); |
1259 | 1258 | ||
1260 | /* Update the amount transferred and the sector number */ | 1259 | /* Update the amount transferred and the sector number */ |
1261 | 1260 | ||