aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/ide-scsi.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-15 15:21:52 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-15 15:21:52 -0400
commit6c60bd8ea7aa536d67830bc8384ef0ebdfb8aad4 (patch)
tree6e6cb8fe2b80ef19e4e48ad6fefeba6909cbffa3 /drivers/scsi/ide-scsi.c
parentc04bbc812b05b304a9118687d0e0a47e35f00d1d (diff)
ide-scsi: fix Interrupt Reason checking in idescsi_pc_intr()
Set PC_FLAG_WRITING pc flag in idescsi_queue() (if needed) and then fix Interrupt Reason checking in idescsi_pc_intr(). Cc: Borislav Petkov <petkovbb@gmail.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/scsi/ide-scsi.c')
-rw-r--r--drivers/scsi/ide-scsi.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index ed92cf7a7682..08807070e083 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -427,7 +427,15 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
427 printk(KERN_ERR "ide-scsi: CoD != 0 in idescsi_pc_intr\n"); 427 printk(KERN_ERR "ide-scsi: CoD != 0 in idescsi_pc_intr\n");
428 return ide_do_reset (drive); 428 return ide_do_reset (drive);
429 } 429 }
430 if (ireason & IO) { 430 if (((ireason & IO) == IO) == !!(pc->flags & PC_FLAG_WRITING)) {
431 /* Hopefully, we will never get here */
432 printk(KERN_ERR "%s: We wanted to %s, but the device wants us "
433 "to %s!\n", drive->name,
434 (ireason & IO) ? "Write" : "Read",
435 (ireason & IO) ? "Read" : "Write");
436 return ide_do_reset(drive);
437 }
438 if (!(pc->flags & PC_FLAG_WRITING)) {
431 temp = pc->xferred + bcount; 439 temp = pc->xferred + bcount;
432 if (temp > pc->req_xfer) { 440 if (temp > pc->req_xfer) {
433 if (temp > pc->buf_size) { 441 if (temp > pc->buf_size) {
@@ -436,7 +444,6 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
436 "- discarding data\n"); 444 "- discarding data\n");
437 temp = pc->buf_size - pc->xferred; 445 temp = pc->buf_size - pc->xferred;
438 if (temp) { 446 if (temp) {
439 pc->flags &= ~PC_FLAG_WRITING;
440 if (pc->sg) 447 if (pc->sg)
441 idescsi_input_buffers(drive, pc, 448 idescsi_input_buffers(drive, pc,
442 temp); 449 temp);
@@ -457,15 +464,11 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
457 printk (KERN_NOTICE "ide-scsi: The scsi wants to send us more data than expected - allowing transfer\n"); 464 printk (KERN_NOTICE "ide-scsi: The scsi wants to send us more data than expected - allowing transfer\n");
458#endif /* IDESCSI_DEBUG_LOG */ 465#endif /* IDESCSI_DEBUG_LOG */
459 } 466 }
460 }
461 if (ireason & IO) {
462 pc->flags &= ~PC_FLAG_WRITING;
463 if (pc->sg) 467 if (pc->sg)
464 idescsi_input_buffers(drive, pc, bcount); 468 idescsi_input_buffers(drive, pc, bcount);
465 else 469 else
466 hwif->input_data(drive, NULL, pc->cur_pos, bcount); 470 hwif->input_data(drive, NULL, pc->cur_pos, bcount);
467 } else { 471 } else {
468 pc->flags |= PC_FLAG_WRITING;
469 if (pc->sg) 472 if (pc->sg)
470 idescsi_output_buffers(drive, pc, bcount); 473 idescsi_output_buffers(drive, pc, bcount);
471 else 474 else
@@ -777,6 +780,8 @@ static int idescsi_queue (struct scsi_cmnd *cmd,
777 780
778 memset (pc->c, 0, 12); 781 memset (pc->c, 0, 12);
779 pc->flags = 0; 782 pc->flags = 0;
783 if (cmd->sc_data_direction == DMA_TO_DEVICE)
784 pc->flags |= PC_FLAG_WRITING;
780 pc->rq = rq; 785 pc->rq = rq;
781 memcpy (pc->c, cmd->cmnd, cmd->cmd_len); 786 memcpy (pc->c, cmd->cmnd, cmd->cmd_len);
782 pc->buf = NULL; 787 pc->buf = NULL;