]> xenbits.xensource.com Git - seabios.git/commitdiff
esp-scsi: flush FIFO before sending SCSI command
authorMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Mon, 7 Aug 2023 06:52:58 +0000 (07:52 +0100)
committerGerd Hoffmann <kraxel@redhat.com>
Thu, 24 Aug 2023 08:40:09 +0000 (10:40 +0200)
The ESP FIFO is used as a buffer for DMA requests and so isn't guaranteed to
be empty in the case of SCSI errors or a mixed DMA/non-DMA request. Flush the
FIFO before sending a SCSI command to guarantee that it is correctly
positioned at the start of the FIFO.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20230807065300.366070-2-mark.cave-ayland@ilande.co.uk>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
src/hw/esp-scsi.c

index cc25f227c7f0c5b6a11fb6d08df6e5b58ab968e9..e4815aa3ef15517917c23cfce32ef0a27faf2d78 100644 (file)
@@ -46,6 +46,7 @@
 #define ESP_DMA_WMAC  0x58c
 
 #define ESP_CMD_DMA      0x80
+#define ESP_CMD_FLUSH    0x01
 #define ESP_CMD_RESET    0x02
 #define ESP_CMD_TI       0x10
 #define ESP_CMD_ICCS     0x11
@@ -96,6 +97,9 @@ esp_scsi_process_op(struct disk_op_s *op)
 
     outb(target, iobase + ESP_WBUSID);
 
+    /* Clear FIFO before sending command.  */
+    outb(ESP_CMD_FLUSH, iobase + ESP_CMD);
+
     /*
      * We need to pass the LUN at the beginning of the command, and the FIFO
      * is only 16 bytes, so we cannot support 16-byte CDBs.  The alternative