Skip to content

Commit 6b544fc

Browse files
Borislav Petkovhtejun
authored andcommitted
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>
1 parent 746d5e4 commit 6b544fc

4 files changed

Lines changed: 23 additions & 39 deletions

File tree

‎drivers/ide/ide-atapi.c‎

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -79,34 +79,6 @@ void ide_init_pc(struct ide_atapi_pc *pc)
7979
}
8080
EXPORT_SYMBOL_GPL(ide_init_pc);
8181

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-
*/
87-
static 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-
11082
/*
11183
* Add a special packet command request to the tail of the request queue,
11284
* and wait for it to be serviced.
@@ -254,18 +226,26 @@ EXPORT_SYMBOL_GPL(ide_queue_sense_rq);
254226

255227
/*
256228
* 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.
258231
*/
259-
void ide_retry_pc(ide_drive_t *drive, struct gendisk *disk)
232+
void ide_retry_pc(ide_drive_t *drive)
260233
{
261-
struct request *rq = &drive->request_sense_rq;
234+
struct request *sense_rq = &drive->sense_rq;
262235
struct ide_atapi_pc *pc = &drive->request_sense_pc;
263236

264237
(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+
266245
if (drive->media == ide_tape)
267246
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);
269249
}
270250
EXPORT_SYMBOL_GPL(ide_retry_pc);
271251

@@ -404,7 +384,7 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
404384
debug_log("[cmd %x]: check condition\n", rq->cmd[0]);
405385

406386
/* Retry operation */
407-
ide_retry_pc(drive, rq->rq_disk);
387+
ide_retry_pc(drive);
408388

409389
/* queued, but not started */
410390
return ide_stopped;

‎drivers/ide/ide-floppy.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
263263
}
264264
pc = &floppy->queued_pc;
265265
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)) {
267267
pc = (struct ide_atapi_pc *)rq->special;
268268
} else if (blk_pc_request(rq)) {
269269
pc = &floppy->queued_pc;
@@ -273,6 +273,8 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
273273
goto out_end;
274274
}
275275

276+
ide_prep_sense(drive, rq);
277+
276278
memset(&cmd, 0, sizeof(cmd));
277279

278280
if (rq_data_dir(rq))

‎drivers/ide/ide-tape.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive)
695695
printk(KERN_ERR "ide-tape: %s: I/O error, ",
696696
tape->name);
697697
/* Retry operation */
698-
ide_retry_pc(drive, tape->disk);
698+
ide_retry_pc(drive);
699699
return ide_stopped;
700700
}
701701
pc->error = 0;
@@ -752,7 +752,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
752752
(unsigned long long)rq->sector, rq->nr_sectors,
753753
rq->current_nr_sectors);
754754

755-
if (!blk_special_request(rq)) {
755+
if (!(blk_special_request(rq) || blk_sense_request(rq))) {
756756
/* We do not support buffer cache originated requests. */
757757
printk(KERN_NOTICE "ide-tape: %s: Unsupported request in "
758758
"request queue (%d)\n", drive->name, rq->cmd_type);
@@ -840,6 +840,9 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
840840
BUG();
841841

842842
out:
843+
/* prepare sense request for this command */
844+
ide_prep_sense(drive, rq);
845+
843846
memset(&cmd, 0, sizeof(cmd));
844847

845848
if (rq_data_dir(rq))

‎include/linux/ide.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,6 @@ struct ide_drive_s {
604604
unsigned long atapi_flags;
605605

606606
struct ide_atapi_pc request_sense_pc;
607-
struct request request_sense_rq;
608607

609608
/* current sense rq and buffer */
610609
bool sense_rq_armed;
@@ -1181,7 +1180,7 @@ int ide_do_test_unit_ready(ide_drive_t *, struct gendisk *);
11811180
int ide_do_start_stop(ide_drive_t *, struct gendisk *, int);
11821181
int ide_set_media_lock(ide_drive_t *, struct gendisk *, int);
11831182
void ide_create_request_sense_cmd(ide_drive_t *, struct ide_atapi_pc *);
1184-
void ide_retry_pc(ide_drive_t *, struct gendisk *);
1183+
void ide_retry_pc(ide_drive_t *drive);
11851184

11861185
void ide_prep_sense(ide_drive_t *drive, struct request *rq);
11871186
void ide_queue_sense_rq(ide_drive_t *drive, void *special);

0 commit comments

Comments
 (0)