Skip to content

Commit

Permalink
ide-cd: convert to using generic sense request
Browse files Browse the repository at this point in the history
Preallocate a sense request in the ->do_request method and reinitialize
it only on demand, in case it's been consumed in the IRQ handler path.
The reason for this is that we don't want to be mapping rq to bio in
the IRQ path and introduce all kinds of unnecessary hacks to the block
layer.

tj: * Both user and kernel PC requests expect sense data to be stored
      in separate storage other than drive->sense_data.  Copy sense
      data to rq->sense on completion if rq->sense is not NULL.  This
      fixes bogus sense data on PC requests.

As a result, remove cdrom_queue_request_sense.

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>
  • Loading branch information
Borislav Petkov authored and Tejun Heo committed Apr 18, 2009
1 parent a1df516 commit 746d5e4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 46 deletions.
54 changes: 12 additions & 42 deletions drivers/ide/ide-cd.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,56 +206,23 @@ static void cdrom_analyze_sense_data(ide_drive_t *drive,
ide_cd_log_error(drive->name, failed_command, sense);
}

static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense,
struct request *failed_command)
{
struct cdrom_info *info = drive->driver_data;
struct request *rq = &drive->request_sense_rq;

ide_debug_log(IDE_DBG_SENSE, "enter");

if (sense == NULL)
sense = &info->sense_data;

memset(sense, 0, 18);

/* stuff the sense request in front of our current request */
blk_rq_init(NULL, rq);
rq->cmd_type = REQ_TYPE_ATA_PC;
rq->rq_disk = info->disk;

rq->data = sense;
rq->cmd[0] = GPCMD_REQUEST_SENSE;
rq->cmd[4] = 18;
rq->data_len = 18;

rq->cmd_type = REQ_TYPE_SENSE;
rq->cmd_flags |= REQ_PREEMPT;

/* NOTE! Save the failed command in "rq->special" */
rq->special = (void *)failed_command;

if (failed_command)
ide_debug_log(IDE_DBG_SENSE, "failed_cmd: 0x%x",
failed_command->cmd[0]);

drive->hwif->rq = NULL;

elv_add_request(drive->queue, rq, ELEVATOR_INSERT_FRONT, 0);
}

static void ide_cd_complete_failed_rq(ide_drive_t *drive, struct request *rq)
{
/*
* For REQ_TYPE_SENSE, "rq->special" points to the original
* failed request
*/
struct request *failed = (struct request *)rq->special;
struct cdrom_info *info = drive->driver_data;
void *sense = &info->sense_data;
struct request_sense *sense = &drive->sense_data;

if (failed) {
if (failed->sense) {
/*
* Sense is always read into drive->sense_data.
* Copy back if the failed request has its
* sense pointer set.
*/
memcpy(failed->sense, sense, 18);
sense = failed->sense;
failed->sense_len = rq->sense_len;
}
Expand Down Expand Up @@ -431,7 +398,7 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)

/* if we got a CHECK_CONDITION status, queue a request sense command */
if (stat & ATA_ERR)
cdrom_queue_request_sense(drive, NULL, NULL);
ide_queue_sense_rq(drive, NULL);
return 1;

end_request:
Expand All @@ -445,7 +412,7 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)

hwif->rq = NULL;

cdrom_queue_request_sense(drive, rq->sense, rq);
ide_queue_sense_rq(drive, rq);
return 1;
} else
return 2;
Expand Down Expand Up @@ -893,6 +860,9 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
goto out_end;
}

/* prepare sense request for this command */
ide_prep_sense(drive, rq);

memset(&cmd, 0, sizeof(cmd));

if (rq_data_dir(rq))
Expand Down
4 changes: 0 additions & 4 deletions drivers/ide/ide-cd.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ struct cdrom_info {

struct atapi_toc *toc;

/* The result of the last successful request sense command
on this device. */
struct request_sense sense_data;

u8 max_speed; /* Max speed of the drive. */
u8 current_speed; /* Current speed of the drive. */

Expand Down

0 comments on commit 746d5e4

Please sign in to comment.