[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 72/88] esp.c: handle TC underflow for DMA SCSI requests
From: |
Mark Cave-Ayland |
Subject: |
[PATCH 72/88] esp.c: handle TC underflow for DMA SCSI requests |
Date: |
Fri, 12 Jan 2024 12:54:04 +0000 |
Detect the case where the guest underflows TC by requesting a DMA transfer which
is larger than the available data. If this case is detected, immediately
complete the SCSI request and handle any remaining FIFO accesses in the STATUS
phase by raising INTR_BS once the FIFO is below the threshold.
Note that handling the premature SCSI bus phase change in the case of TC
underflow fixes booting EMILE on m68k once again.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
hw/scsi/esp.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 8ea100ee9c..a3e18bb3d7 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -579,6 +579,12 @@ static void esp_do_dma(ESPState *s)
s->async_len -= len;
s->ti_size -= len;
+ if (s->async_len == 0 && s->ti_size == 0 && esp_get_tc(s)) {
+ /* If the guest underflows TC then terminate SCSI request */
+ scsi_req_continue(s->current_req);
+ return;
+ }
+
if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) {
/* Defer until the scsi layer has completed */
scsi_req_continue(s->current_req);
@@ -596,6 +602,12 @@ static void esp_do_dma(ESPState *s)
esp_set_tc(s, esp_get_tc(s) - len);
esp_raise_drq(s);
+ if (s->async_len == 0 && s->ti_size == 0 && esp_get_tc(s)) {
+ /* If the guest underflows TC then terminate SCSI request */
+ scsi_req_continue(s->current_req);
+ return;
+ }
+
if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) {
/* Defer until the scsi layer has completed */
scsi_req_continue(s->current_req);
@@ -630,6 +642,15 @@ static void esp_do_dma(ESPState *s)
}
}
break;
+
+ default:
+ /* Consume remaining data if the guest underflows TC */
+ if (fifo8_num_used(&s->fifo) < 2) {
+ s->rregs[ESP_RINTR] |= INTR_BS;
+ esp_raise_irq(s);
+ esp_lower_drq(s);
+ }
+ break;
}
break;
@@ -884,7 +905,9 @@ void esp_command_complete(SCSIRequest *req, size_t resid)
esp_set_phase(s, STAT_ST);
s->rregs[ESP_RINTR] |= INTR_BS;
esp_raise_irq(s);
- esp_lower_drq(s);
+
+ /* Ensure DRQ is set correctly for TC underflow or normal completion */
+ esp_dma_ti_check(s);
if (s->current_req) {
scsi_req_unref(s->current_req);
--
2.39.2
- [PATCH 49/88] esp.c: move CMD_SELATN end of message phase detection to esp_do_dma() and do_dma_pdma_cb(), (continued)
- [PATCH 49/88] esp.c: move CMD_SELATN end of message phase detection to esp_do_dma() and do_dma_pdma_cb(), Mark Cave-Ayland, 2024/01/12
- [PATCH 46/88] esp.c: untangle MESSAGE OUT and COMMAND phase logic in esp_do_dma(), Mark Cave-Ayland, 2024/01/12
- [PATCH 48/88] esp.c: untangle MESSAGE OUT and COMMAND phase logic in esp_do_nodma(), Mark Cave-Ayland, 2024/01/12
- [PATCH 56/88] esp.c: remove unused PDMA callback implementation, Mark Cave-Ayland, 2024/01/12
- [PATCH 54/88] esp.c: move CMD_ICCS command logic to esp_do_dma(), Mark Cave-Ayland, 2024/01/12
- [PATCH 57/88] esp.c: rename data_in_ready to to data_ready, Mark Cave-Ayland, 2024/01/12
- [PATCH 76/88] esp.c: only transfer non-DMA COMMAND phase data for specific commands, Mark Cave-Ayland, 2024/01/12
- [PATCH 66/88] esp.c: process non-DMA FIFO writes in esp_do_nodma(), Mark Cave-Ayland, 2024/01/12
- [PATCH 74/88] esp.c: handle non-DMA FIFO writes used to terminate DMA commands, Mark Cave-Ayland, 2024/01/12
- [PATCH 81/88] esp.c: remove redundant n variable in PDMA COMMAND phase, Mark Cave-Ayland, 2024/01/12
- [PATCH 72/88] esp.c: handle TC underflow for DMA SCSI requests,
Mark Cave-Ayland <=
- [PATCH 64/88] esp.c: don't raise INTR_BS interrupt in DATA IN phase until TI command issued, Mark Cave-Ayland, 2024/01/12
- [PATCH 50/88] esp.c: move CMD_TI end of message phase detection to esp_do_dma() and do_dma_pdma_cb(), Mark Cave-Ayland, 2024/01/12
- [PATCH 75/88] esp.c: improve ESP_RSEQ logic consolidation, Mark Cave-Ayland, 2024/01/12
- [PATCH 79/88] esp.c: consolidate DMA and PDMA logic in DATA IN phase, Mark Cave-Ayland, 2024/01/12
- [PATCH 71/88] esp.c: don't clear the SCSI phase when reading ESP_RINTR, Mark Cave-Ayland, 2024/01/12
- [PATCH 55/88] esp.c: always use esp_do_dma() in pdma_cb(), Mark Cave-Ayland, 2024/01/12
- [PATCH 70/88] esp.c: ensure that STAT_INT is cleared when reading ESP_RINTR, Mark Cave-Ayland, 2024/01/12
- [PATCH 80/88] esp.c: consolidate DMA and PDMA logic in MESSAGE OUT phase, Mark Cave-Ayland, 2024/01/12
- [PATCH 51/88] esp.c: don't use get_cmd() for CMD_SEL DMA commands, Mark Cave-Ayland, 2024/01/12
- [PATCH 65/88] esp.c: move non-DMA TI logic to separate esp_nodma_ti_dataout() function, Mark Cave-Ayland, 2024/01/12