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: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent c04bbc81
...@@ -427,7 +427,15 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) ...@@ -427,7 +427,15 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
printk(KERN_ERR "ide-scsi: CoD != 0 in idescsi_pc_intr\n"); printk(KERN_ERR "ide-scsi: CoD != 0 in idescsi_pc_intr\n");
return ide_do_reset (drive); return ide_do_reset (drive);
} }
if (ireason & IO) { if (((ireason & IO) == IO) == !!(pc->flags & PC_FLAG_WRITING)) {
/* Hopefully, we will never get here */
printk(KERN_ERR "%s: We wanted to %s, but the device wants us "
"to %s!\n", drive->name,
(ireason & IO) ? "Write" : "Read",
(ireason & IO) ? "Read" : "Write");
return ide_do_reset(drive);
}
if (!(pc->flags & PC_FLAG_WRITING)) {
temp = pc->xferred + bcount; temp = pc->xferred + bcount;
if (temp > pc->req_xfer) { if (temp > pc->req_xfer) {
if (temp > pc->buf_size) { if (temp > pc->buf_size) {
...@@ -436,7 +444,6 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) ...@@ -436,7 +444,6 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
"- discarding data\n"); "- discarding data\n");
temp = pc->buf_size - pc->xferred; temp = pc->buf_size - pc->xferred;
if (temp) { if (temp) {
pc->flags &= ~PC_FLAG_WRITING;
if (pc->sg) if (pc->sg)
idescsi_input_buffers(drive, pc, idescsi_input_buffers(drive, pc,
temp); temp);
...@@ -457,15 +464,11 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) ...@@ -457,15 +464,11 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
printk (KERN_NOTICE "ide-scsi: The scsi wants to send us more data than expected - allowing transfer\n"); printk (KERN_NOTICE "ide-scsi: The scsi wants to send us more data than expected - allowing transfer\n");
#endif /* IDESCSI_DEBUG_LOG */ #endif /* IDESCSI_DEBUG_LOG */
} }
}
if (ireason & IO) {
pc->flags &= ~PC_FLAG_WRITING;
if (pc->sg) if (pc->sg)
idescsi_input_buffers(drive, pc, bcount); idescsi_input_buffers(drive, pc, bcount);
else else
hwif->input_data(drive, NULL, pc->cur_pos, bcount); hwif->input_data(drive, NULL, pc->cur_pos, bcount);
} else { } else {
pc->flags |= PC_FLAG_WRITING;
if (pc->sg) if (pc->sg)
idescsi_output_buffers(drive, pc, bcount); idescsi_output_buffers(drive, pc, bcount);
else else
...@@ -777,6 +780,8 @@ static int idescsi_queue (struct scsi_cmnd *cmd, ...@@ -777,6 +780,8 @@ static int idescsi_queue (struct scsi_cmnd *cmd,
memset (pc->c, 0, 12); memset (pc->c, 0, 12);
pc->flags = 0; pc->flags = 0;
if (cmd->sc_data_direction == DMA_TO_DEVICE)
pc->flags |= PC_FLAG_WRITING;
pc->rq = rq; pc->rq = rq;
memcpy (pc->c, cmd->cmnd, cmd->cmd_len); memcpy (pc->c, cmd->cmnd, cmd->cmd_len);
pc->buf = NULL; pc->buf = NULL;
......
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