Skip to content

Commit

Permalink
ide-cd: handle fragmented packet commands gracefully
Browse files Browse the repository at this point in the history
There are some devices in the wild that clear the DRQ bit during the
last word of a packet command and therefore could use a "second chance"
for that last word of data to be xferred instead of simply failing the
request. Do that by attempting to suck in those last bytes in PIO mode.

In addition, the ATA_ERR bit has to be cleared for we cannot be sure the
data is valid otherwise.

See http://bugzilla.kernel.org/show_bug.cgi?id=13399 for details.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Acked-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Borislav Petkov authored and David S. Miller committed Jun 26, 2009
1 parent 5e95524 commit 9c72ebe
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions drivers/ide/ide-cd.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,9 +592,19 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
}
} else if (!blk_pc_request(rq)) {
ide_cd_request_sense_fixup(drive, cmd);
/* complain if we still have data left to transfer */

uptodate = cmd->nleft ? 0 : 1;
if (uptodate == 0)

/*
* suck out the remaining bytes from the drive in an
* attempt to complete the data xfer. (see BZ#13399)
*/
if (!(stat & ATA_ERR) && !uptodate && thislen) {
ide_pio_bytes(drive, cmd, write, thislen);
uptodate = cmd->nleft ? 0 : 1;
}

if (!uptodate)
rq->cmd_flags |= REQ_FAILED;
}
goto out_end;
Expand Down

0 comments on commit 9c72ebe

Please sign in to comment.