Commit e3bfae4c authored by Borislav Petkov's avatar Borislav Petkov Committed by Bartlomiej Zolnierkiewicz

ide-scsi: do non-atomic pc->flags testing

...also, convert ide-scsi to using the generic pc->flags defines.
Signed-off-by: default avatarBorislav Petkov <petkovbb@gmail.com>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent eaec3e7d
...@@ -60,14 +60,6 @@ ...@@ -60,14 +60,6 @@
#define IDESCSI_DEBUG_LOG 0 #define IDESCSI_DEBUG_LOG 0
/*
* Packet command status bits.
*/
#define PC_DMA_IN_PROGRESS 0 /* 1 while DMA in progress */
#define PC_WRITING 1 /* Data direction */
#define PC_TIMEDOUT 3 /* command timed out */
#define PC_DMA_OK 4 /* Use DMA */
/* /*
* SCSI command transformation layer * SCSI command transformation layer
*/ */
...@@ -319,8 +311,10 @@ static int idescsi_end_request (ide_drive_t *drive, int uptodate, int nrsecs) ...@@ -319,8 +311,10 @@ static int idescsi_end_request (ide_drive_t *drive, int uptodate, int nrsecs)
pc = opc; pc = opc;
rq = pc->rq; rq = pc->rq;
pc->scsi_cmd->result = (CHECK_CONDITION << 1) | pc->scsi_cmd->result = (CHECK_CONDITION << 1) |
((test_bit(PC_TIMEDOUT, &pc->flags)?DID_TIME_OUT:DID_OK) << 16); (((pc->flags & PC_FLAG_TIMEDOUT) ?
} else if (test_bit(PC_TIMEDOUT, &pc->flags)) { DID_TIME_OUT :
DID_OK) << 16);
} else if (pc->flags & PC_FLAG_TIMEDOUT) {
if (log) if (log)
printk (KERN_WARNING "ide-scsi: %s: timed out for %lu\n", printk (KERN_WARNING "ide-scsi: %s: timed out for %lu\n",
drive->name, pc->scsi_cmd->serial_number); drive->name, pc->scsi_cmd->serial_number);
...@@ -362,7 +356,7 @@ static int idescsi_expiry(ide_drive_t *drive) ...@@ -362,7 +356,7 @@ static int idescsi_expiry(ide_drive_t *drive)
#if IDESCSI_DEBUG_LOG #if IDESCSI_DEBUG_LOG
printk(KERN_WARNING "idescsi_expiry called for %lu at %lu\n", pc->scsi_cmd->serial_number, jiffies); printk(KERN_WARNING "idescsi_expiry called for %lu at %lu\n", pc->scsi_cmd->serial_number, jiffies);
#endif #endif
set_bit(PC_TIMEDOUT, &pc->flags); pc->flags |= PC_FLAG_TIMEDOUT;
return 0; /* we do not want the ide subsystem to retry */ return 0; /* we do not want the ide subsystem to retry */
} }
...@@ -384,7 +378,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) ...@@ -384,7 +378,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
printk (KERN_INFO "ide-scsi: Reached idescsi_pc_intr interrupt handler\n"); printk (KERN_INFO "ide-scsi: Reached idescsi_pc_intr interrupt handler\n");
#endif /* IDESCSI_DEBUG_LOG */ #endif /* IDESCSI_DEBUG_LOG */
if (test_bit(PC_TIMEDOUT, &pc->flags)){ if (pc->flags & PC_FLAG_TIMEDOUT) {
#if IDESCSI_DEBUG_LOG #if IDESCSI_DEBUG_LOG
printk(KERN_WARNING "idescsi_pc_intr: got timed out packet %lu at %lu\n", printk(KERN_WARNING "idescsi_pc_intr: got timed out packet %lu at %lu\n",
pc->scsi_cmd->serial_number, jiffies); pc->scsi_cmd->serial_number, jiffies);
...@@ -393,7 +387,8 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) ...@@ -393,7 +387,8 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
idescsi_end_request (drive, 1, 0); idescsi_end_request (drive, 1, 0);
return ide_stopped; return ide_stopped;
} }
if (test_and_clear_bit (PC_DMA_IN_PROGRESS, &pc->flags)) { if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
#if IDESCSI_DEBUG_LOG #if IDESCSI_DEBUG_LOG
printk ("ide-scsi: %s: DMA complete\n", drive->name); printk ("ide-scsi: %s: DMA complete\n", drive->name);
#endif /* IDESCSI_DEBUG_LOG */ #endif /* IDESCSI_DEBUG_LOG */
...@@ -432,7 +427,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) ...@@ -432,7 +427,7 @@ 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) {
clear_bit(PC_WRITING, &pc->flags); pc->flags &= ~PC_FLAG_WRITING;
if (pc->sg) if (pc->sg)
idescsi_input_buffers(drive, pc, idescsi_input_buffers(drive, pc,
temp); temp);
...@@ -454,14 +449,14 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) ...@@ -454,14 +449,14 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
} }
} }
if (ireason & IO) { if (ireason & IO) {
clear_bit(PC_WRITING, &pc->flags); 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->atapi_input_bytes(drive, pc->cur_pos, hwif->atapi_input_bytes(drive, pc->cur_pos,
bcount); bcount);
} else { } else {
set_bit(PC_WRITING, &pc->flags); 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
...@@ -501,8 +496,8 @@ static ide_startstop_t idescsi_transfer_pc(ide_drive_t *drive) ...@@ -501,8 +496,8 @@ static ide_startstop_t idescsi_transfer_pc(ide_drive_t *drive)
ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), idescsi_expiry); ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), idescsi_expiry);
/* Send the actual packet */ /* Send the actual packet */
drive->hwif->atapi_output_bytes(drive, scsi->pc->c, 12); drive->hwif->atapi_output_bytes(drive, scsi->pc->c, 12);
if (test_bit (PC_DMA_OK, &pc->flags)) { if (pc->flags & PC_FLAG_DMA_OK) {
set_bit (PC_DMA_IN_PROGRESS, &pc->flags); pc->flags |= PC_FLAG_DMA_IN_PROGRESS;
hwif->dma_start(drive); hwif->dma_start(drive);
} }
return ide_started; return ide_started;
...@@ -512,10 +507,10 @@ static inline int idescsi_set_direction(struct ide_atapi_pc *pc) ...@@ -512,10 +507,10 @@ static inline int idescsi_set_direction(struct ide_atapi_pc *pc)
{ {
switch (pc->c[0]) { switch (pc->c[0]) {
case READ_6: case READ_10: case READ_12: case READ_6: case READ_10: case READ_12:
clear_bit(PC_WRITING, &pc->flags); pc->flags &= ~PC_FLAG_WRITING;
return 0; return 0;
case WRITE_6: case WRITE_10: case WRITE_12: case WRITE_6: case WRITE_10: case WRITE_12:
set_bit(PC_WRITING, &pc->flags); pc->flags |= PC_FLAG_WRITING;
return 0; return 0;
default: default:
return 1; return 1;
...@@ -572,7 +567,7 @@ static ide_startstop_t idescsi_issue_pc(ide_drive_t *drive, ...@@ -572,7 +567,7 @@ static ide_startstop_t idescsi_issue_pc(ide_drive_t *drive,
ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK, bcount, dma); ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK, bcount, dma);
if (dma) if (dma)
set_bit(PC_DMA_OK, &pc->flags); pc->flags |= PC_FLAG_DMA_OK;
if (test_bit(IDESCSI_DRQ_INTERRUPT, &scsi->flags)) { if (test_bit(IDESCSI_DRQ_INTERRUPT, &scsi->flags)) {
ide_execute_command(drive, WIN_PACKETCMD, &idescsi_transfer_pc, ide_execute_command(drive, WIN_PACKETCMD, &idescsi_transfer_pc,
......
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