diff options
| -rw-r--r-- | drivers/ide/ide-atapi.c | 63 | ||||
| -rw-r--r-- | drivers/ide/ide-floppy.c | 47 | ||||
| -rw-r--r-- | drivers/ide/ide-tape.c | 4 | ||||
| -rw-r--r-- | drivers/scsi/ide-scsi.c | 46 | ||||
| -rw-r--r-- | include/linux/ide.h | 4 |
5 files changed, 67 insertions, 97 deletions
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c index 61c52fb665ca..3d44b45650f6 100644 --- a/drivers/ide/ide-atapi.c +++ b/drivers/ide/ide-atapi.c | |||
| @@ -61,12 +61,62 @@ int ide_check_atapi_device(ide_drive_t *drive, const char *s) | |||
| 61 | } | 61 | } |
| 62 | EXPORT_SYMBOL_GPL(ide_check_atapi_device); | 62 | EXPORT_SYMBOL_GPL(ide_check_atapi_device); |
| 63 | 63 | ||
| 64 | /* PIO data transfer routine using the scatter gather table. */ | ||
| 65 | int ide_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, | ||
| 66 | unsigned int bcount, int write) | ||
| 67 | { | ||
| 68 | ide_hwif_t *hwif = drive->hwif; | ||
| 69 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | ||
| 70 | xfer_func_t *xf = write ? tp_ops->output_data : tp_ops->input_data; | ||
| 71 | struct scatterlist *sg = pc->sg; | ||
| 72 | char *buf; | ||
| 73 | int count, done = 0; | ||
| 74 | |||
| 75 | while (bcount) { | ||
| 76 | count = min(sg->length - pc->b_count, bcount); | ||
| 77 | |||
| 78 | if (PageHighMem(sg_page(sg))) { | ||
| 79 | unsigned long flags; | ||
| 80 | |||
| 81 | local_irq_save(flags); | ||
| 82 | buf = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset; | ||
| 83 | xf(drive, NULL, buf + pc->b_count, count); | ||
| 84 | kunmap_atomic(buf - sg->offset, KM_IRQ0); | ||
| 85 | local_irq_restore(flags); | ||
| 86 | } else { | ||
| 87 | buf = sg_virt(sg); | ||
| 88 | xf(drive, NULL, buf + pc->b_count, count); | ||
| 89 | } | ||
| 90 | |||
| 91 | bcount -= count; | ||
| 92 | pc->b_count += count; | ||
| 93 | done += count; | ||
| 94 | |||
| 95 | if (pc->b_count == sg->length) { | ||
| 96 | if (!--pc->sg_cnt) | ||
| 97 | break; | ||
| 98 | pc->sg = sg = sg_next(sg); | ||
| 99 | pc->b_count = 0; | ||
| 100 | } | ||
| 101 | } | ||
| 102 | |||
| 103 | if (bcount) { | ||
| 104 | printk(KERN_ERR "%s: %d leftover bytes, %s\n", drive->name, | ||
| 105 | bcount, write ? "padding with zeros" | ||
| 106 | : "discarding data"); | ||
| 107 | ide_pad_transfer(drive, write, bcount); | ||
| 108 | } | ||
| 109 | |||
| 110 | return done; | ||
| 111 | } | ||
| 112 | EXPORT_SYMBOL_GPL(ide_io_buffers); | ||
| 113 | |||
| 64 | /* TODO: unify the code thus making some arguments go away */ | 114 | /* TODO: unify the code thus making some arguments go away */ |
| 65 | ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, | 115 | ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, |
| 66 | ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry, | 116 | ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry, |
| 67 | void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *), | 117 | void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *), |
| 68 | void (*retry_pc)(ide_drive_t *), void (*dsc_handle)(ide_drive_t *), | 118 | void (*retry_pc)(ide_drive_t *), void (*dsc_handle)(ide_drive_t *), |
| 69 | void (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned, int)) | 119 | int (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned, int)) |
| 70 | { | 120 | { |
| 71 | ide_hwif_t *hwif = drive->hwif; | 121 | ide_hwif_t *hwif = drive->hwif; |
| 72 | struct request *rq = hwif->hwgroup->rq; | 122 | struct request *rq = hwif->hwgroup->rq; |
| @@ -219,9 +269,14 @@ cmd_finished: | |||
| 219 | 269 | ||
| 220 | if ((drive->media == ide_floppy && !scsi && !pc->buf) || | 270 | if ((drive->media == ide_floppy && !scsi && !pc->buf) || |
| 221 | (drive->media == ide_tape && !scsi && pc->bh) || | 271 | (drive->media == ide_tape && !scsi && pc->bh) || |
| 222 | (scsi && pc->sg)) | 272 | (scsi && pc->sg)) { |
| 223 | io_buffers(drive, pc, bcount, !!(pc->flags & PC_FLAG_WRITING)); | 273 | int done = io_buffers(drive, pc, bcount, |
| 224 | else | 274 | !!(pc->flags & PC_FLAG_WRITING)); |
| 275 | |||
| 276 | /* FIXME: don't do partial completions */ | ||
| 277 | if (drive->media == ide_floppy && !scsi) | ||
| 278 | ide_end_request(drive, 1, done >> 9); | ||
| 279 | } else | ||
| 225 | xferfunc(drive, NULL, pc->cur_pos, bcount); | 280 | xferfunc(drive, NULL, pc->cur_pos, bcount); |
| 226 | 281 | ||
| 227 | /* Update the current position */ | 282 | /* Update the current position */ |
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index a0a8ad3a3038..38dca45ffd11 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
| @@ -208,51 +208,6 @@ static int idefloppy_end_request(ide_drive_t *drive, int uptodate, int nsecs) | |||
| 208 | return 0; | 208 | return 0; |
| 209 | } | 209 | } |
| 210 | 210 | ||
| 211 | static void ide_floppy_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, | ||
| 212 | unsigned int bcount, int direction) | ||
| 213 | { | ||
| 214 | ide_hwif_t *hwif = drive->hwif; | ||
| 215 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | ||
| 216 | xfer_func_t *xf = direction ? tp_ops->output_data : tp_ops->input_data; | ||
| 217 | struct scatterlist *sg = pc->sg; | ||
| 218 | char *buf; | ||
| 219 | int count, done = 0; | ||
| 220 | |||
| 221 | while (bcount) { | ||
| 222 | count = min(sg->length - pc->b_count, bcount); | ||
| 223 | if (PageHighMem(sg_page(sg))) { | ||
| 224 | unsigned long flags; | ||
| 225 | |||
| 226 | local_irq_save(flags); | ||
| 227 | buf = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset; | ||
| 228 | xf(drive, NULL, buf + pc->b_count, count); | ||
| 229 | kunmap_atomic(buf - sg->offset, KM_IRQ0); | ||
| 230 | local_irq_restore(flags); | ||
| 231 | } else { | ||
| 232 | buf = sg_virt(sg); | ||
| 233 | xf(drive, NULL, buf + pc->b_count, count); | ||
| 234 | } | ||
| 235 | bcount -= count; | ||
| 236 | pc->b_count += count; | ||
| 237 | done += count; | ||
| 238 | |||
| 239 | if (pc->b_count == sg->length) { | ||
| 240 | if (!--pc->sg_cnt) | ||
| 241 | break; | ||
| 242 | pc->sg = sg = sg_next(sg); | ||
| 243 | pc->b_count = 0; | ||
| 244 | } | ||
| 245 | } | ||
| 246 | |||
| 247 | idefloppy_end_request(drive, 1, done >> 9); | ||
| 248 | |||
| 249 | if (bcount) { | ||
| 250 | printk(KERN_ERR "%s: leftover data in %s, bcount == %d\n", | ||
| 251 | drive->name, __func__, bcount); | ||
| 252 | ide_pad_transfer(drive, direction, bcount); | ||
| 253 | } | ||
| 254 | } | ||
| 255 | |||
| 256 | static void idefloppy_update_buffers(ide_drive_t *drive, | 211 | static void idefloppy_update_buffers(ide_drive_t *drive, |
| 257 | struct ide_atapi_pc *pc) | 212 | struct ide_atapi_pc *pc) |
| 258 | { | 213 | { |
| @@ -356,7 +311,7 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) | |||
| 356 | 311 | ||
| 357 | return ide_pc_intr(drive, floppy->pc, idefloppy_pc_intr, | 312 | return ide_pc_intr(drive, floppy->pc, idefloppy_pc_intr, |
| 358 | IDEFLOPPY_WAIT_CMD, NULL, idefloppy_update_buffers, | 313 | IDEFLOPPY_WAIT_CMD, NULL, idefloppy_update_buffers, |
| 359 | idefloppy_retry_pc, NULL, ide_floppy_io_buffers); | 314 | idefloppy_retry_pc, NULL, ide_io_buffers); |
| 360 | } | 315 | } |
| 361 | 316 | ||
| 362 | /* | 317 | /* |
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index ba05e03f482b..d4a9c471dd13 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
| @@ -693,13 +693,15 @@ static void ide_tape_handle_dsc(ide_drive_t *drive) | |||
| 693 | idetape_postpone_request(drive); | 693 | idetape_postpone_request(drive); |
| 694 | } | 694 | } |
| 695 | 695 | ||
| 696 | static void ide_tape_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, | 696 | static int ide_tape_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, |
| 697 | unsigned int bcount, int write) | 697 | unsigned int bcount, int write) |
| 698 | { | 698 | { |
| 699 | if (write) | 699 | if (write) |
| 700 | idetape_output_buffers(drive, pc, bcount); | 700 | idetape_output_buffers(drive, pc, bcount); |
| 701 | else | 701 | else |
| 702 | idetape_input_buffers(drive, pc, bcount); | 702 | idetape_input_buffers(drive, pc, bcount); |
| 703 | |||
| 704 | return bcount; | ||
| 703 | } | 705 | } |
| 704 | 706 | ||
| 705 | /* | 707 | /* |
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c index 26e8c3c49474..27c01e368977 100644 --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c | |||
| @@ -130,50 +130,6 @@ static inline idescsi_scsi_t *drive_to_idescsi(ide_drive_t *ide_drive) | |||
| 130 | return scsihost_to_idescsi(ide_drive->driver_data); | 130 | return scsihost_to_idescsi(ide_drive->driver_data); |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | /* | ||
| 134 | * PIO data transfer routine using the scatter gather table. | ||
| 135 | */ | ||
| 136 | static void ide_scsi_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, | ||
| 137 | unsigned int bcount, int write) | ||
| 138 | { | ||
| 139 | ide_hwif_t *hwif = drive->hwif; | ||
| 140 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | ||
| 141 | xfer_func_t *xf = write ? tp_ops->output_data : tp_ops->input_data; | ||
| 142 | struct scatterlist *sg = pc->sg; | ||
| 143 | char *buf; | ||
| 144 | int count; | ||
| 145 | |||
| 146 | while (bcount) { | ||
| 147 | count = min(sg->length - pc->b_count, bcount); | ||
| 148 | if (PageHighMem(sg_page(sg))) { | ||
| 149 | unsigned long flags; | ||
| 150 | |||
| 151 | local_irq_save(flags); | ||
| 152 | buf = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset; | ||
| 153 | xf(drive, NULL, buf + pc->b_count, count); | ||
| 154 | kunmap_atomic(buf - sg->offset, KM_IRQ0); | ||
| 155 | local_irq_restore(flags); | ||
| 156 | } else { | ||
| 157 | buf = sg_virt(sg); | ||
| 158 | xf(drive, NULL, buf + pc->b_count, count); | ||
| 159 | } | ||
| 160 | bcount -= count; pc->b_count += count; | ||
| 161 | if (pc->b_count == sg->length) { | ||
| 162 | if (!--pc->sg_cnt) | ||
| 163 | break; | ||
| 164 | pc->sg = sg = sg_next(sg); | ||
| 165 | pc->b_count = 0; | ||
| 166 | } | ||
| 167 | } | ||
| 168 | |||
| 169 | if (bcount) { | ||
| 170 | printk(KERN_ERR "%s: scatter gather table too small, %s\n", | ||
| 171 | drive->name, write ? "padding with zeros" | ||
| 172 | : "discarding data"); | ||
| 173 | ide_pad_transfer(drive, write, bcount); | ||
| 174 | } | ||
| 175 | } | ||
| 176 | |||
| 177 | static void ide_scsi_hex_dump(u8 *data, int len) | 133 | static void ide_scsi_hex_dump(u8 *data, int len) |
| 178 | { | 134 | { |
| 179 | print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1, data, len, 0); | 135 | print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1, data, len, 0); |
| @@ -343,7 +299,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) | |||
| 343 | 299 | ||
| 344 | return ide_pc_intr(drive, pc, idescsi_pc_intr, get_timeout(pc), | 300 | return ide_pc_intr(drive, pc, idescsi_pc_intr, get_timeout(pc), |
| 345 | idescsi_expiry, NULL, NULL, NULL, | 301 | idescsi_expiry, NULL, NULL, NULL, |
| 346 | ide_scsi_io_buffers); | 302 | ide_io_buffers); |
| 347 | } | 303 | } |
| 348 | 304 | ||
| 349 | static ide_startstop_t idescsi_transfer_pc(ide_drive_t *drive) | 305 | static ide_startstop_t idescsi_transfer_pc(ide_drive_t *drive) |
diff --git a/include/linux/ide.h b/include/linux/ide.h index e63ff63d1f0b..03dc2157a2b5 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h | |||
| @@ -1099,6 +1099,8 @@ void ide_tf_read(ide_drive_t *, ide_task_t *); | |||
| 1099 | void ide_input_data(ide_drive_t *, struct request *, void *, unsigned int); | 1099 | void ide_input_data(ide_drive_t *, struct request *, void *, unsigned int); |
| 1100 | void ide_output_data(ide_drive_t *, struct request *, void *, unsigned int); | 1100 | void ide_output_data(ide_drive_t *, struct request *, void *, unsigned int); |
| 1101 | 1101 | ||
| 1102 | int ide_io_buffers(ide_drive_t *, struct ide_atapi_pc *, unsigned int, int); | ||
| 1103 | |||
| 1102 | extern void SELECT_DRIVE(ide_drive_t *); | 1104 | extern void SELECT_DRIVE(ide_drive_t *); |
| 1103 | void SELECT_MASK(ide_drive_t *, int); | 1105 | void SELECT_MASK(ide_drive_t *, int); |
| 1104 | 1106 | ||
| @@ -1115,7 +1117,7 @@ ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
| 1115 | ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry, | 1117 | ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry, |
| 1116 | void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *), | 1118 | void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *), |
| 1117 | void (*retry_pc)(ide_drive_t *), void (*dsc_handle)(ide_drive_t *), | 1119 | void (*retry_pc)(ide_drive_t *), void (*dsc_handle)(ide_drive_t *), |
| 1118 | void (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned int, | 1120 | int (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned int, |
| 1119 | int)); | 1121 | int)); |
| 1120 | ide_startstop_t ide_transfer_pc(ide_drive_t *, struct ide_atapi_pc *, | 1122 | ide_startstop_t ide_transfer_pc(ide_drive_t *, struct ide_atapi_pc *, |
| 1121 | ide_handler_t *, unsigned int, ide_expiry_t *); | 1123 | ide_handler_t *, unsigned int, ide_expiry_t *); |
