aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-atapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-atapi.c')
-rw-r--r--drivers/ide/ide-atapi.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index afe5a4323879..757e5956b132 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -246,6 +246,7 @@ EXPORT_SYMBOL_GPL(ide_queue_sense_rq);
246 */ 246 */
247void ide_retry_pc(ide_drive_t *drive) 247void ide_retry_pc(ide_drive_t *drive)
248{ 248{
249 struct request *failed_rq = drive->hwif->rq;
249 struct request *sense_rq = &drive->sense_rq; 250 struct request *sense_rq = &drive->sense_rq;
250 struct ide_atapi_pc *pc = &drive->request_sense_pc; 251 struct ide_atapi_pc *pc = &drive->request_sense_pc;
251 252
@@ -255,13 +256,22 @@ void ide_retry_pc(ide_drive_t *drive)
255 ide_init_pc(pc); 256 ide_init_pc(pc);
256 memcpy(pc->c, sense_rq->cmd, 12); 257 memcpy(pc->c, sense_rq->cmd, 12);
257 pc->buf = bio_data(sense_rq->bio); /* pointer to mapped address */ 258 pc->buf = bio_data(sense_rq->bio); /* pointer to mapped address */
258 pc->req_xfer = sense_rq->data_len; 259 pc->req_xfer = blk_rq_bytes(sense_rq);
259 260
260 if (drive->media == ide_tape) 261 if (drive->media == ide_tape)
261 set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags); 262 set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags);
262 263
263 if (ide_queue_sense_rq(drive, pc)) 264 /*
264 ide_complete_rq(drive, -EIO, blk_rq_bytes(drive->hwif->rq)); 265 * Push back the failed request and put request sense on top
266 * of it. The failed command will be retried after sense data
267 * is acquired.
268 */
269 blk_requeue_request(failed_rq->q, failed_rq);
270 drive->hwif->rq = NULL;
271 if (ide_queue_sense_rq(drive, pc)) {
272 blk_start_request(failed_rq);
273 ide_complete_rq(drive, -EIO, blk_rq_bytes(failed_rq));
274 }
265} 275}
266EXPORT_SYMBOL_GPL(ide_retry_pc); 276EXPORT_SYMBOL_GPL(ide_retry_pc);
267 277
@@ -303,7 +313,7 @@ int ide_cd_get_xferlen(struct request *rq)
303 return 32768; 313 return 32768;
304 else if (blk_sense_request(rq) || blk_pc_request(rq) || 314 else if (blk_sense_request(rq) || blk_pc_request(rq) ||
305 rq->cmd_type == REQ_TYPE_ATA_PC) 315 rq->cmd_type == REQ_TYPE_ATA_PC)
306 return rq->data_len; 316 return blk_rq_bytes(rq);
307 else 317 else
308 return 0; 318 return 0;
309} 319}
@@ -367,7 +377,6 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
367 /* No more interrupts */ 377 /* No more interrupts */
368 if ((stat & ATA_DRQ) == 0) { 378 if ((stat & ATA_DRQ) == 0) {
369 int uptodate, error; 379 int uptodate, error;
370 unsigned int done;
371 380
372 debug_log("Packet command completed, %d bytes transferred\n", 381 debug_log("Packet command completed, %d bytes transferred\n",
373 pc->xferred); 382 pc->xferred);
@@ -431,7 +440,7 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
431 error = uptodate ? 0 : -EIO; 440 error = uptodate ? 0 : -EIO;
432 } 441 }
433 442
434 ide_complete_rq(drive, error, done); 443 ide_complete_rq(drive, error, blk_rq_bytes(rq));
435 return ide_stopped; 444 return ide_stopped;
436 } 445 }
437 446