aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBorislav Petkov <petkovbb@googlemail.com>2009-04-18 18:00:42 -0400
committerJens Axboe <jens.axboe@oracle.com>2009-04-28 01:37:30 -0400
commit068753203e6cd085664a62e0fc0636e19b148a12 (patch)
treed3eec62f2ecd5524c89bb7c8d4f482e93a4cc196
parentc457ce874a0f3dfa3d5e9f2309789f6f34e24325 (diff)
ide-atapi: convert ide-{floppy,tape} to using preallocated sense buffer
Since we're issuing REQ_TYPE_SENSE now we need to allow those types of rqs in the ->do_request callbacks. As a future improvement, sense_len assignment might be unified across all ATAPI devices. Borislav to check with specs and test. As a result, get rid of ide_queue_pc_head() and drive->request_sense_rq. tj: * Init request sense ide_atapi_pc from sense request. In the longer timer, it would probably better to fold ide_create_request_sense_cmd() into its only current user - ide_floppy_get_format_progress(). * ide_retry_pc() no longer takes @disk. CC: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> CC: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Signed-off-by: Borislav Petkov <petkovbb@gmail.com> Signed-off-by: Tejun Heo <tj@kernel.org>
-rw-r--r--drivers/ide/ide-atapi.c48
-rw-r--r--drivers/ide/ide-floppy.c4
-rw-r--r--drivers/ide/ide-tape.c7
-rw-r--r--include/linux/ide.h3
4 files changed, 23 insertions, 39 deletions
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index c6e03485a63a..972c522516f8 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -80,34 +80,6 @@ void ide_init_pc(struct ide_atapi_pc *pc)
80EXPORT_SYMBOL_GPL(ide_init_pc); 80EXPORT_SYMBOL_GPL(ide_init_pc);
81 81
82/* 82/*
83 * Generate a new packet command request in front of the request queue, before
84 * the current request, so that it will be processed immediately, on the next
85 * pass through the driver.
86 */
87static void ide_queue_pc_head(ide_drive_t *drive, struct gendisk *disk,
88 struct ide_atapi_pc *pc, struct request *rq)
89{
90 blk_rq_init(NULL, rq);
91 rq->cmd_type = REQ_TYPE_SPECIAL;
92 rq->cmd_flags |= REQ_PREEMPT;
93 rq->special = (char *)pc;
94 rq->rq_disk = disk;
95
96 if (pc->req_xfer) {
97 rq->data = pc->buf;
98 rq->data_len = pc->req_xfer;
99 }
100
101 memcpy(rq->cmd, pc->c, 12);
102 if (drive->media == ide_tape)
103 rq->cmd[13] = REQ_IDETAPE_PC1;
104
105 drive->hwif->rq = NULL;
106
107 elv_add_request(drive->queue, rq, ELEVATOR_INSERT_FRONT, 0);
108}
109
110/*
111 * Add a special packet command request to the tail of the request queue, 83 * Add a special packet command request to the tail of the request queue,
112 * and wait for it to be serviced. 84 * and wait for it to be serviced.
113 */ 85 */
@@ -254,18 +226,26 @@ EXPORT_SYMBOL_GPL(ide_queue_sense_rq);
254 226
255/* 227/*
256 * Called when an error was detected during the last packet command. 228 * Called when an error was detected during the last packet command.
257 * We queue a request sense packet command in the head of the request list. 229 * We queue a request sense packet command at the head of the request
230 * queue.
258 */ 231 */
259void ide_retry_pc(ide_drive_t *drive, struct gendisk *disk) 232void ide_retry_pc(ide_drive_t *drive)
260{ 233{
261 struct request *rq = &drive->request_sense_rq; 234 struct request *sense_rq = &drive->sense_rq;
262 struct ide_atapi_pc *pc = &drive->request_sense_pc; 235 struct ide_atapi_pc *pc = &drive->request_sense_pc;
263 236
264 (void)ide_read_error(drive); 237 (void)ide_read_error(drive);
265 ide_create_request_sense_cmd(drive, pc); 238
239 /* init pc from sense_rq */
240 ide_init_pc(pc);
241 memcpy(pc->c, sense_rq->cmd, 12);
242 pc->buf = sense_rq->data;
243 pc->req_xfer = sense_rq->data_len;
244
266 if (drive->media == ide_tape) 245 if (drive->media == ide_tape)
267 set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags); 246 set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags);
268 ide_queue_pc_head(drive, disk, pc, rq); 247
248 ide_queue_sense_rq(drive, pc);
269} 249}
270EXPORT_SYMBOL_GPL(ide_retry_pc); 250EXPORT_SYMBOL_GPL(ide_retry_pc);
271 251
@@ -404,7 +384,7 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
404 debug_log("[cmd %x]: check condition\n", rq->cmd[0]); 384 debug_log("[cmd %x]: check condition\n", rq->cmd[0]);
405 385
406 /* Retry operation */ 386 /* Retry operation */
407 ide_retry_pc(drive, rq->rq_disk); 387 ide_retry_pc(drive);
408 388
409 /* queued, but not started */ 389 /* queued, but not started */
410 return ide_stopped; 390 return ide_stopped;
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 94600331a271..d3302cc891e4 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -263,7 +263,7 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
263 } 263 }
264 pc = &floppy->queued_pc; 264 pc = &floppy->queued_pc;
265 idefloppy_create_rw_cmd(drive, pc, rq, (unsigned long)block); 265 idefloppy_create_rw_cmd(drive, pc, rq, (unsigned long)block);
266 } else if (blk_special_request(rq)) { 266 } else if (blk_special_request(rq) || blk_sense_request(rq)) {
267 pc = (struct ide_atapi_pc *)rq->special; 267 pc = (struct ide_atapi_pc *)rq->special;
268 } else if (blk_pc_request(rq)) { 268 } else if (blk_pc_request(rq)) {
269 pc = &floppy->queued_pc; 269 pc = &floppy->queued_pc;
@@ -273,6 +273,8 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
273 goto out_end; 273 goto out_end;
274 } 274 }
275 275
276 ide_prep_sense(drive, rq);
277
276 memset(&cmd, 0, sizeof(cmd)); 278 memset(&cmd, 0, sizeof(cmd));
277 279
278 if (rq_data_dir(rq)) 280 if (rq_data_dir(rq))
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index aadf53cfac6f..8324dfa78a3f 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -695,7 +695,7 @@ static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive)
695 printk(KERN_ERR "ide-tape: %s: I/O error, ", 695 printk(KERN_ERR "ide-tape: %s: I/O error, ",
696 tape->name); 696 tape->name);
697 /* Retry operation */ 697 /* Retry operation */
698 ide_retry_pc(drive, tape->disk); 698 ide_retry_pc(drive);
699 return ide_stopped; 699 return ide_stopped;
700 } 700 }
701 pc->error = 0; 701 pc->error = 0;
@@ -752,7 +752,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
752 (unsigned long long)rq->sector, rq->nr_sectors, 752 (unsigned long long)rq->sector, rq->nr_sectors,
753 rq->current_nr_sectors); 753 rq->current_nr_sectors);
754 754
755 if (!blk_special_request(rq)) { 755 if (!(blk_special_request(rq) || blk_sense_request(rq))) {
756 /* We do not support buffer cache originated requests. */ 756 /* We do not support buffer cache originated requests. */
757 printk(KERN_NOTICE "ide-tape: %s: Unsupported request in " 757 printk(KERN_NOTICE "ide-tape: %s: Unsupported request in "
758 "request queue (%d)\n", drive->name, rq->cmd_type); 758 "request queue (%d)\n", drive->name, rq->cmd_type);
@@ -840,6 +840,9 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
840 BUG(); 840 BUG();
841 841
842out: 842out:
843 /* prepare sense request for this command */
844 ide_prep_sense(drive, rq);
845
843 memset(&cmd, 0, sizeof(cmd)); 846 memset(&cmd, 0, sizeof(cmd));
844 847
845 if (rq_data_dir(rq)) 848 if (rq_data_dir(rq))
diff --git a/include/linux/ide.h b/include/linux/ide.h
index a69ccac56411..9e67ccac3c1f 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -604,7 +604,6 @@ struct ide_drive_s {
604 unsigned long atapi_flags; 604 unsigned long atapi_flags;
605 605
606 struct ide_atapi_pc request_sense_pc; 606 struct ide_atapi_pc request_sense_pc;
607 struct request request_sense_rq;
608 607
609 /* current sense rq and buffer */ 608 /* current sense rq and buffer */
610 bool sense_rq_armed; 609 bool sense_rq_armed;
@@ -1181,7 +1180,7 @@ int ide_do_test_unit_ready(ide_drive_t *, struct gendisk *);
1181int ide_do_start_stop(ide_drive_t *, struct gendisk *, int); 1180int ide_do_start_stop(ide_drive_t *, struct gendisk *, int);
1182int ide_set_media_lock(ide_drive_t *, struct gendisk *, int); 1181int ide_set_media_lock(ide_drive_t *, struct gendisk *, int);
1183void ide_create_request_sense_cmd(ide_drive_t *, struct ide_atapi_pc *); 1182void ide_create_request_sense_cmd(ide_drive_t *, struct ide_atapi_pc *);
1184void ide_retry_pc(ide_drive_t *, struct gendisk *); 1183void ide_retry_pc(ide_drive_t *drive);
1185 1184
1186void ide_prep_sense(ide_drive_t *drive, struct request *rq); 1185void ide_prep_sense(ide_drive_t *drive, struct request *rq);
1187void ide_queue_sense_rq(ide_drive_t *drive, void *special); 1186void ide_queue_sense_rq(ide_drive_t *drive, void *special);