[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 28/88] esp.c: consolidate async_len and TC == 0 checks in do_dma_p
From: |
Mark Cave-Ayland |
Subject: |
[PULL 28/88] esp.c: consolidate async_len and TC == 0 checks in do_dma_pdma_cb() and esp_do_dma() |
Date: |
Tue, 13 Feb 2024 19:39:52 +0000 |
Ensure that the async_len checks for requesting data from the SCSI layer and
the TC == 0 checks to detect the end of the DMA transfer are consistent in both
do_dma_pdma_cb() and esp_do_dma(). In particular this involves adding the check
to see if the FIFO is at its low threshold since PDMA and mixed DMA and non-DMA
requests can leave data remaining in the FIFO.
At the same time update all the comments so that they are also consistent
between
all similar code paths.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Tested-by: Helge Deller <deller@gmx.de>
Tested-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20240112125420.514425-29-mark.cave-ayland@ilande.co.uk>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
hw/scsi/esp.c | 44 +++++++++++++++++++++++++++++++-------------
1 file changed, 31 insertions(+), 13 deletions(-)
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 6b0811d3ce..f20026c3dc 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -604,12 +604,13 @@ static void do_dma_pdma_cb(ESPState *s)
s->async_len -= n;
s->ti_size += n;
- if (s->async_len == 0) {
+ if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) {
+ /* Defer until the scsi layer has completed */
scsi_req_continue(s->current_req);
return;
}
- if (esp_get_tc(s) == 0) {
+ if (esp_get_tc(s) == 0 && fifo8_num_used(&s->fifo) < 2) {
esp_lower_drq(s);
esp_dma_done(s);
}
@@ -706,24 +707,30 @@ static void esp_do_dma(ESPState *s)
s->async_len -= len;
s->ti_size += len;
- if (s->async_len == 0) {
+ if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) {
+ /* Defer until the scsi layer has completed */
scsi_req_continue(s->current_req);
- /*
- * If there is still data to be read from the device then
- * complete the DMA operation immediately. Otherwise defer
- * until the scsi layer has completed.
- */
return;
}
- if (esp_get_tc(s) == 0) {
- /* Partially filled a scsi buffer. Complete immediately. */
+ if (esp_get_tc(s) == 0 && fifo8_num_used(&s->fifo) < 2) {
esp_dma_done(s);
esp_lower_drq(s);
}
} else {
esp_set_pdma_cb(s, DO_DMA_PDMA_CB);
esp_raise_drq(s);
+
+ if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) {
+ /* Defer until the scsi layer has completed */
+ scsi_req_continue(s->current_req);
+ return;
+ }
+
+ if (esp_get_tc(s) == 0 && fifo8_num_used(&s->fifo) < 2) {
+ esp_dma_done(s);
+ esp_lower_drq(s);
+ }
}
} else {
if (s->dma_memory_write) {
@@ -734,13 +741,13 @@ static void esp_do_dma(ESPState *s)
s->async_len -= len;
s->ti_size -= len;
- if (s->async_len == 0) {
+ if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) {
+ /* Defer until the scsi layer has completed */
scsi_req_continue(s->current_req);
return;
}
- if (esp_get_tc(s) == 0) {
- /* Partially filled a scsi buffer. Complete immediately. */
+ if (esp_get_tc(s) == 0 && fifo8_num_used(&s->fifo) < 2) {
esp_dma_done(s);
esp_lower_drq(s);
}
@@ -754,6 +761,17 @@ static void esp_do_dma(ESPState *s)
esp_set_tc(s, esp_get_tc(s) - len);
esp_set_pdma_cb(s, DO_DMA_PDMA_CB);
esp_raise_drq(s);
+
+ if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) {
+ /* Defer until the scsi layer has completed */
+ scsi_req_continue(s->current_req);
+ return;
+ }
+
+ if (esp_get_tc(s) == 0 && fifo8_num_used(&s->fifo) < 2) {
+ esp_lower_drq(s);
+ esp_dma_done(s);
+ }
}
}
}
--
2.39.2
- [PULL 18/88] esp.c: don't clear RFLAGS register when DMA is complete, (continued)
- [PULL 18/88] esp.c: don't clear RFLAGS register when DMA is complete, Mark Cave-Ayland, 2024/02/13
- [PULL 17/88] esp.c: don't reset the TC and ESP_RSEQ state when executing a SCSI command, Mark Cave-Ayland, 2024/02/13
- [PULL 20/88] esp.c: update condition for esp_dma_done() in esp_do_dma() from device path, Mark Cave-Ayland, 2024/02/13
- [PULL 22/88] esp.c: ensure that the PDMA callback is called for every device read, Mark Cave-Ayland, 2024/02/13
- [PULL 21/88] esp.c: update condition for esp_dma_done() in esp_do_dma() to device path, Mark Cave-Ayland, 2024/02/13
- [PULL 23/88] esp.c: don't immediately raise INTR_BS if SCSI data needed in esp_do_dma(), Mark Cave-Ayland, 2024/02/13
- [PULL 25/88] esp.c: remove unaligned adjustment in do_dma_pdma_cb() to device path, Mark Cave-Ayland, 2024/02/13
- [PULL 26/88] esp.c: remove unneeded if() check in esp_transfer_data(), Mark Cave-Ayland, 2024/02/13
- [PULL 24/88] esp.c: remove TC adjustment in esp_do_dma() from device path, Mark Cave-Ayland, 2024/02/13
- [PULL 27/88] esp.c: update end of transfer logic at the end of esp_transfer_data(), Mark Cave-Ayland, 2024/02/13
- [PULL 28/88] esp.c: consolidate async_len and TC == 0 checks in do_dma_pdma_cb() and esp_do_dma(),
Mark Cave-Ayland <=
- [PULL 29/88] esp.c: fix premature end of phase logic esp_command_complete, Mark Cave-Ayland, 2024/02/13
- [PULL 30/88] esp.c: move TC and FIFO check logic into esp_dma_done(), Mark Cave-Ayland, 2024/02/13
- [PULL 31/88] esp.c: rename esp_dma_done() to esp_dma_ti_check(), Mark Cave-Ayland, 2024/02/13
- [PULL 32/88] esp.c: copy PDMA logic for transfers to device from do_dma_pdma_cb() to esp_do_dma(), Mark Cave-Ayland, 2024/02/13
- [PULL 33/88] esp.c: copy logic for do_cmd transfers from do_dma_pdma_cb() to esp_do_dma(), Mark Cave-Ayland, 2024/02/13
- [PULL 34/88] esp.c: update esp_do_dma() bypass if async_len is zero to include non-zero transfer check, Mark Cave-Ayland, 2024/02/13
- [PULL 35/88] esp.c: move end of SCSI transfer check after TC adjustment in do_dma_pdma_cb(), Mark Cave-Ayland, 2024/02/13
- [PULL 36/88] esp.c: remove s_without_satn_pdma_cb() PDMA callback, Mark Cave-Ayland, 2024/02/13
- [PULL 39/88] esp.c: convert do_dma_pdma_db() to switch statement based upon SCSI phase, Mark Cave-Ayland, 2024/02/13
- [PULL 40/88] esp.c: convert esp_do_nodma() to switch statement based upon SCSI phase, Mark Cave-Ayland, 2024/02/13