[ide] ide-cd: fix possible race in PIO mode

From: Alan Cox <alan@lxorguk.ukuu.org.uk>

When we issue an ide command the status bits don't become valid for
400nS. In the DMA case ide_execute_command handles this but in the PIO
case we don't do the needed locking, use OUTBSYNC to avoid posting or
delay. This means that in some situations we can execute the command
handler in PIO mode before the command status bits are valid and the
handler may read and act wrongly.
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent bb8857fe
...@@ -890,8 +890,14 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, ...@@ -890,8 +890,14 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive,
ide_execute_command(drive, WIN_PACKETCMD, handler, ATAPI_WAIT_PC, cdrom_timer_expiry); ide_execute_command(drive, WIN_PACKETCMD, handler, ATAPI_WAIT_PC, cdrom_timer_expiry);
return ide_started; return ide_started;
} else { } else {
unsigned long flags;
/* packet command */ /* packet command */
HWIF(drive)->OUTB(WIN_PACKETCMD, IDE_COMMAND_REG); spin_lock_irqsave(&ide_lock, flags);
hwif->OUTBSYNC(drive, WIN_PACKETCMD, IDE_COMMAND_REG);
ndelay(400);
spin_unlock_irqrestore(&ide_lock, flags);
return (*handler) (drive); return (*handler) (drive);
} }
} }
......
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