aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-03-31 14:15:26 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-03-31 14:15:26 -0400
commit349d12a1fe57d49287a539909cf14f362634342d (patch)
tree632b6f33a0424db5507ac099aa7292daa7902f26 /drivers
parentd93bc4521c80e9d87767779814e88f6d725453d7 (diff)
ide-floppy: use ide_pio_bytes()
* Fix ide_init_sg_cmd() setup for non-fs requests. * Convert ide_pc_intr() to use ide_pio_bytes() for floppy media. * Remove no longer needed ide_io_buffers() and sg/sg_cnt fields from struct ide_atapi_pc. * Remove partial completions; kill idefloppy_update_buffers(), as a result. * Add some more debugging statements. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> Signed-off-by: Borislav Petkov <petkovbb@gmail.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ide/ide-atapi.c68
-rw-r--r--drivers/ide/ide-floppy.c24
2 files changed, 21 insertions, 71 deletions
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index 40f413b20bd8..100e6f94b4f0 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -71,49 +71,6 @@ int ide_check_atapi_device(ide_drive_t *drive, const char *s)
71} 71}
72EXPORT_SYMBOL_GPL(ide_check_atapi_device); 72EXPORT_SYMBOL_GPL(ide_check_atapi_device);
73 73
74/* PIO data transfer routine using the scatter gather table. */
75int ide_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
76 unsigned int bcount, int write)
77{
78 ide_hwif_t *hwif = drive->hwif;
79 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
80 xfer_func_t *xf = write ? tp_ops->output_data : tp_ops->input_data;
81 struct scatterlist *sg = pc->sg;
82 char *buf;
83 int count, done = 0;
84
85 while (bcount) {
86 count = min(sg->length - pc->b_count, bcount);
87
88 if (PageHighMem(sg_page(sg))) {
89 unsigned long flags;
90
91 local_irq_save(flags);
92 buf = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset;
93 xf(drive, NULL, buf + pc->b_count, count);
94 kunmap_atomic(buf - sg->offset, KM_IRQ0);
95 local_irq_restore(flags);
96 } else {
97 buf = sg_virt(sg);
98 xf(drive, NULL, buf + pc->b_count, count);
99 }
100
101 bcount -= count;
102 pc->b_count += count;
103 done += count;
104
105 if (pc->b_count == sg->length) {
106 if (!--pc->sg_cnt)
107 break;
108 pc->sg = sg = sg_next(sg);
109 pc->b_count = 0;
110 }
111 }
112
113 return done;
114}
115EXPORT_SYMBOL_GPL(ide_io_buffers);
116
117void ide_init_pc(struct ide_atapi_pc *pc) 74void ide_init_pc(struct ide_atapi_pc *pc)
118{ 75{
119 memset(pc, 0, sizeof(*pc)); 76 memset(pc, 0, sizeof(*pc));
@@ -353,6 +310,9 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
353 pc->xferred = pc->req_xfer; 310 pc->xferred = pc->req_xfer;
354 if (drive->pc_update_buffers) 311 if (drive->pc_update_buffers)
355 drive->pc_update_buffers(drive, pc); 312 drive->pc_update_buffers(drive, pc);
313
314 if (drive->media == ide_floppy)
315 ide_complete_rq(drive, 0, blk_rq_bytes(rq));
356 } 316 }
357 debug_log("%s: DMA finished\n", drive->name); 317 debug_log("%s: DMA finished\n", drive->name);
358 } 318 }
@@ -408,12 +368,19 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
408 rq->errors = 0; 368 rq->errors = 0;
409 ide_complete_rq(drive, 0, blk_rq_bytes(rq)); 369 ide_complete_rq(drive, 0, blk_rq_bytes(rq));
410 } else { 370 } else {
371 unsigned int done;
372
411 if (blk_fs_request(rq) == 0 && uptodate <= 0) { 373 if (blk_fs_request(rq) == 0 && uptodate <= 0) {
412 if (rq->errors == 0) 374 if (rq->errors == 0)
413 rq->errors = -EIO; 375 rq->errors = -EIO;
414 } 376 }
415 ide_complete_rq(drive, uptodate ? 0 : -EIO, 377
416 ide_rq_bytes(rq)); 378 if (drive->media == ide_tape)
379 done = ide_rq_bytes(rq); /* FIXME */
380 else
381 done = blk_rq_bytes(rq);
382
383 ide_complete_rq(drive, uptodate ? 0 : -EIO, done);
417 } 384 }
418 385
419 return ide_stopped; 386 return ide_stopped;
@@ -446,14 +413,11 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
446 413
447 xferfunc = write ? tp_ops->output_data : tp_ops->input_data; 414 xferfunc = write ? tp_ops->output_data : tp_ops->input_data;
448 415
449 if ((drive->media == ide_floppy && !pc->buf) || 416 if (drive->media == ide_floppy && pc->buf == NULL) {
450 (drive->media == ide_tape && pc->bh)) { 417 done = min_t(unsigned int, bcount, cmd->nleft);
418 ide_pio_bytes(drive, cmd, write, done);
419 } else if (drive->media == ide_tape && pc->bh) {
451 done = drive->pc_io_buffers(drive, pc, bcount, write); 420 done = drive->pc_io_buffers(drive, pc, bcount, write);
452
453 /* FIXME: don't do partial completions */
454 if (drive->media == ide_floppy)
455 ide_complete_rq(drive, 0,
456 done ? done : ide_rq_bytes(rq));
457 } else { 421 } else {
458 done = min_t(unsigned int, bcount, pc->req_xfer - pc->xferred); 422 done = min_t(unsigned int, bcount, pc->req_xfer - pc->xferred);
459 xferfunc(drive, NULL, pc->cur_pos, done); 423 xferfunc(drive, NULL, pc->cur_pos, done);
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 0faae3098295..2b4868d95f8b 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -61,16 +61,6 @@
61 */ 61 */
62#define IDEFLOPPY_PC_DELAY (HZ/20) /* default delay for ZIP 100 (50ms) */ 62#define IDEFLOPPY_PC_DELAY (HZ/20) /* default delay for ZIP 100 (50ms) */
63 63
64static void idefloppy_update_buffers(ide_drive_t *drive,
65 struct ide_atapi_pc *pc)
66{
67 struct request *rq = pc->rq;
68 struct bio *bio = rq->bio;
69
70 while ((bio = rq->bio) != NULL)
71 ide_complete_rq(drive, 0, ide_rq_bytes(rq));
72}
73
74static int ide_floppy_callback(ide_drive_t *drive, int dsc) 64static int ide_floppy_callback(ide_drive_t *drive, int dsc)
75{ 65{
76 struct ide_disk_obj *floppy = drive->driver_data; 66 struct ide_disk_obj *floppy = drive->driver_data;
@@ -213,7 +203,6 @@ static void idefloppy_create_rw_cmd(ide_drive_t *drive,
213 memcpy(rq->cmd, pc->c, 12); 203 memcpy(rq->cmd, pc->c, 12);
214 204
215 pc->rq = rq; 205 pc->rq = rq;
216 pc->b_count = 0;
217 if (rq->cmd_flags & REQ_RW) 206 if (rq->cmd_flags & REQ_RW)
218 pc->flags |= PC_FLAG_WRITING; 207 pc->flags |= PC_FLAG_WRITING;
219 pc->buf = NULL; 208 pc->buf = NULL;
@@ -227,7 +216,6 @@ static void idefloppy_blockpc_cmd(struct ide_disk_obj *floppy,
227 ide_init_pc(pc); 216 ide_init_pc(pc);
228 memcpy(pc->c, rq->cmd, sizeof(pc->c)); 217 memcpy(pc->c, rq->cmd, sizeof(pc->c));
229 pc->rq = rq; 218 pc->rq = rq;
230 pc->b_count = 0;
231 if (rq->data_len && rq_data_dir(rq) == WRITE) 219 if (rq->data_len && rq_data_dir(rq) == WRITE)
232 pc->flags |= PC_FLAG_WRITING; 220 pc->flags |= PC_FLAG_WRITING;
233 pc->buf = rq->data; 221 pc->buf = rq->data;
@@ -244,10 +232,11 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
244 struct request *rq, sector_t block) 232 struct request *rq, sector_t block)
245{ 233{
246 struct ide_disk_obj *floppy = drive->driver_data; 234 struct ide_disk_obj *floppy = drive->driver_data;
247 ide_hwif_t *hwif = drive->hwif;
248 struct ide_cmd cmd; 235 struct ide_cmd cmd;
249 struct ide_atapi_pc *pc; 236 struct ide_atapi_pc *pc;
250 237
238 ide_debug_log(IDE_DBG_FUNC, "enter, cmd: 0x%x\n", rq->cmd[0]);
239
251 if (drive->debug_mask & IDE_DBG_RQ) 240 if (drive->debug_mask & IDE_DBG_RQ)
252 blk_dump_rq_flags(rq, (rq->rq_disk 241 blk_dump_rq_flags(rq, (rq->rq_disk
253 ? rq->rq_disk->disk_name 242 ? rq->rq_disk->disk_name
@@ -294,13 +283,10 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
294 cmd.rq = rq; 283 cmd.rq = rq;
295 284
296 if (blk_fs_request(rq) || pc->req_xfer) { 285 if (blk_fs_request(rq) || pc->req_xfer) {
297 ide_init_sg_cmd(&cmd, rq->nr_sectors << 9); 286 ide_init_sg_cmd(&cmd, pc->req_xfer);
298 ide_map_sg(drive, &cmd); 287 ide_map_sg(drive, &cmd);
299 } 288 }
300 289
301 pc->sg = hwif->sg_table;
302 pc->sg_cnt = cmd.sg_nents;
303
304 pc->rq = rq; 290 pc->rq = rq;
305 291
306 return ide_floppy_issue_pc(drive, &cmd, pc); 292 return ide_floppy_issue_pc(drive, &cmd, pc);
@@ -388,6 +374,8 @@ static int ide_floppy_get_capacity(ide_drive_t *drive)
388 u8 pc_buf[256], header_len, desc_cnt; 374 u8 pc_buf[256], header_len, desc_cnt;
389 int i, rc = 1, blocks, length; 375 int i, rc = 1, blocks, length;
390 376
377 ide_debug_log(IDE_DBG_FUNC, "enter");
378
391 drive->bios_cyl = 0; 379 drive->bios_cyl = 0;
392 drive->bios_head = drive->bios_sect = 0; 380 drive->bios_head = drive->bios_sect = 0;
393 floppy->blocks = 0; 381 floppy->blocks = 0;
@@ -488,8 +476,6 @@ static void ide_floppy_setup(ide_drive_t *drive)
488 u16 *id = drive->id; 476 u16 *id = drive->id;
489 477
490 drive->pc_callback = ide_floppy_callback; 478 drive->pc_callback = ide_floppy_callback;
491 drive->pc_update_buffers = idefloppy_update_buffers;
492 drive->pc_io_buffers = ide_io_buffers;
493 479
494 /* 480 /*
495 * We used to check revisions here. At this point however I'm giving up. 481 * We used to check revisions here. At this point however I'm giving up.