Commit 077e6dba authored by Borislav Petkov's avatar Borislav Petkov

ide-atapi: switch to rq->resid_len

Now that we have rq->resid_len, use it to account partial completion
amount during the lifetime of an rq, decrementing it on each successful
transfer. As a result, get rid of now unused pc->xferred.

While at it, remove noisy debug call in ide_prep_sense.
Signed-off-by: default avatarBorislav Petkov <petkovbb@gmail.com>
parent dfb7e621
...@@ -172,8 +172,6 @@ void ide_prep_sense(ide_drive_t *drive, struct request *rq) ...@@ -172,8 +172,6 @@ void ide_prep_sense(ide_drive_t *drive, struct request *rq)
unsigned int cmd_len, sense_len; unsigned int cmd_len, sense_len;
int err; int err;
debug_log("%s: enter\n", __func__);
switch (drive->media) { switch (drive->media) {
case ide_floppy: case ide_floppy:
cmd_len = 255; cmd_len = 255;
...@@ -370,7 +368,7 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive) ...@@ -370,7 +368,7 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
? "write" : "read"); ? "write" : "read");
pc->flags |= PC_FLAG_DMA_ERROR; pc->flags |= PC_FLAG_DMA_ERROR;
} else } else
pc->xferred = blk_rq_bytes(rq); rq->resid_len = 0;
debug_log("%s: DMA finished\n", drive->name); debug_log("%s: DMA finished\n", drive->name);
} }
...@@ -379,7 +377,7 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive) ...@@ -379,7 +377,7 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
int uptodate, error; int uptodate, error;
debug_log("Packet command completed, %d bytes transferred\n", debug_log("Packet command completed, %d bytes transferred\n",
pc->xferred); blk_rq_bytes(rq));
pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
...@@ -467,15 +465,15 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive) ...@@ -467,15 +465,15 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
ide_pio_bytes(drive, cmd, write, done); ide_pio_bytes(drive, cmd, write, done);
/* Update transferred byte count */ /* Update transferred byte count */
pc->xferred += done; rq->resid_len -= done;
bcount -= done; bcount -= done;
if (bcount) if (bcount)
ide_pad_transfer(drive, write, bcount); ide_pad_transfer(drive, write, bcount);
debug_log("[cmd %x] transferred %d bytes, padded %d bytes\n", debug_log("[cmd %x] transferred %d bytes, padded %d bytes, resid: %u\n",
rq->cmd[0], done, bcount); rq->cmd[0], done, bcount, rq->resid_len);
/* And set the interrupt handler again */ /* And set the interrupt handler again */
ide_set_handler(drive, ide_pc_intr, timeout); ide_set_handler(drive, ide_pc_intr, timeout);
...@@ -643,16 +641,15 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_cmd *cmd) ...@@ -643,16 +641,15 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_cmd *cmd)
} else { } else {
pc = drive->pc; pc = drive->pc;
/* We haven't transferred any data yet */
pc->xferred = 0;
valid_tf = IDE_VALID_DEVICE; valid_tf = IDE_VALID_DEVICE;
bytes = blk_rq_bytes(rq); bytes = blk_rq_bytes(rq);
bcount = ((drive->media == ide_tape) ? bytes bcount = ((drive->media == ide_tape) ? bytes
: min_t(unsigned int, : min_t(unsigned int,
bytes, 63 * 1024)); bytes, 63 * 1024));
/* We haven't transferred any data yet */
rq->resid_len = bcount;
if (pc->flags & PC_FLAG_DMA_ERROR) { if (pc->flags & PC_FLAG_DMA_ERROR) {
pc->flags &= ~PC_FLAG_DMA_ERROR; pc->flags &= ~PC_FLAG_DMA_ERROR;
ide_dma_off(drive); ide_dma_off(drive);
......
...@@ -301,11 +301,9 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense) ...@@ -301,11 +301,9 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense)
debug_log(DBG_ERR, "pc = %x, sense key = %x, asc = %x, ascq = %x\n", debug_log(DBG_ERR, "pc = %x, sense key = %x, asc = %x, ascq = %x\n",
pc->c[0], tape->sense_key, tape->asc, tape->ascq); pc->c[0], tape->sense_key, tape->asc, tape->ascq);
/* Correct pc->xferred by asking the tape. */ /* correct remaining bytes to transfer */
if (pc->flags & PC_FLAG_DMA_ERROR) if (pc->flags & PC_FLAG_DMA_ERROR)
pc->xferred = blk_rq_bytes(rq) - rq->resid_len = tape->blk_size * get_unaligned_be32(&sense[3]);
tape->blk_size *
get_unaligned_be32(&sense[3]);
/* /*
* If error was the result of a zero-length read or write command, * If error was the result of a zero-length read or write command,
...@@ -339,7 +337,7 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense) ...@@ -339,7 +337,7 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense)
pc->flags |= PC_FLAG_ABORT; pc->flags |= PC_FLAG_ABORT;
} }
if (!(pc->flags & PC_FLAG_ABORT) && if (!(pc->flags & PC_FLAG_ABORT) &&
pc->xferred) (blk_rq_bytes(rq) - rq->resid_len))
pc->retries = IDETAPE_MAX_PC_RETRIES + 1; pc->retries = IDETAPE_MAX_PC_RETRIES + 1;
} }
} }
...@@ -369,7 +367,8 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc) ...@@ -369,7 +367,8 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc)
printk(KERN_ERR "ide-tape: Error in REQUEST SENSE " printk(KERN_ERR "ide-tape: Error in REQUEST SENSE "
"itself - Aborting request!\n"); "itself - Aborting request!\n");
} else if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) { } else if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) {
int blocks = pc->xferred / tape->blk_size; unsigned int blocks =
(blk_rq_bytes(rq) - rq->resid_len) / tape->blk_size;
tape->avg_size += blocks * tape->blk_size; tape->avg_size += blocks * tape->blk_size;
...@@ -381,7 +380,6 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc) ...@@ -381,7 +380,6 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc)
} }
tape->first_frame += blocks; tape->first_frame += blocks;
rq->resid_len = blk_rq_bytes(rq) - blocks * tape->blk_size;
if (pc->error) { if (pc->error) {
uptodate = 0; uptodate = 0;
......
...@@ -357,8 +357,6 @@ struct ide_atapi_pc { ...@@ -357,8 +357,6 @@ struct ide_atapi_pc {
/* bytes to transfer */ /* bytes to transfer */
int req_xfer; int req_xfer;
/* bytes actually transferred */
int xferred;
/* data buffer */ /* data buffer */
u8 *buf; u8 *buf;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment