This helps simplify the existing implementation.
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-31-mark.cave-ayland@ilande.co.uk>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
hw/scsi/esp.c | 39 +++++++++++----------------------------
1 file changed, 11 insertions(+), 28 deletions(-)
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index c6151d306e..4d58a49c73 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -545,8 +545,11 @@ static void write_response(ESPState *s)
static void esp_dma_done(ESPState *s)
{
- s->rregs[ESP_RINTR] |= INTR_BS;
- esp_raise_irq(s);
+ if (esp_get_tc(s) == 0 && fifo8_num_used(&s->fifo) < 2) {
+ s->rregs[ESP_RINTR] |= INTR_BS;
+ esp_raise_irq(s);
+ esp_lower_drq(s);
+ }
}
static void do_dma_pdma_cb(ESPState *s)
@@ -610,12 +613,7 @@ static void do_dma_pdma_cb(ESPState *s)
return;
}
- if (esp_get_tc(s) == 0 && fifo8_num_used(&s->fifo) < 2) {
- esp_lower_drq(s);
- esp_dma_done(s);
- }
-
- return;
+ esp_dma_done(s);
} else {
if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) {
/* Defer until the scsi layer has completed */
@@ -624,10 +622,7 @@ static void do_dma_pdma_cb(ESPState *s)
return;
}
- if (esp_get_tc(s) == 0 && fifo8_num_used(&s->fifo) < 2) {
- esp_lower_drq(s);
- esp_dma_done(s);
- }
+ esp_dma_done(s);
/* Copy device data to FIFO */
len = MIN(s->async_len, esp_get_tc(s));
@@ -713,10 +708,7 @@ static void esp_do_dma(ESPState *s)
return;
}
- if (esp_get_tc(s) == 0 && fifo8_num_used(&s->fifo) < 2) {
- esp_dma_done(s);
- esp_lower_drq(s);
- }
+ esp_dma_done(s);
} else {
esp_set_pdma_cb(s, DO_DMA_PDMA_CB);
esp_raise_drq(s);
@@ -727,10 +719,7 @@ static void esp_do_dma(ESPState *s)
return;
}
- if (esp_get_tc(s) == 0 && fifo8_num_used(&s->fifo) < 2) {
- esp_dma_done(s);
- esp_lower_drq(s);
- }
+ esp_dma_done(s);
}
} else {
if (s->dma_memory_write) {
@@ -747,10 +736,7 @@ static void esp_do_dma(ESPState *s)
return;
}
- if (esp_get_tc(s) == 0 && fifo8_num_used(&s->fifo) < 2) {
- esp_dma_done(s);
- esp_lower_drq(s);
- }
+ esp_dma_done(s);
} else {
/* Copy device data to FIFO */
len = MIN(len, fifo8_num_free(&s->fifo));
@@ -768,10 +754,7 @@ static void esp_do_dma(ESPState *s)
return;
}
- if (esp_get_tc(s) == 0 && fifo8_num_used(&s->fifo) < 2) {
- esp_lower_drq(s);
- esp_dma_done(s);
- }
+ esp_dma_done(s);
}
}
}
--
2.39.2