diff options
author | Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> | 2024-01-12 12:53:22 +0000 |
---|---|---|
committer | Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> | 2024-02-13 19:37:27 +0000 |
commit | af74b3c15d440d3a3718b8dc6a751c094db75ba3 (patch) | |
tree | 1f72dae74a09604b263bde4ef2e80e7ad892add0 /hw | |
parent | cb9881999dead51723bc5eb6d6fc2837f9345920 (diff) | |
download | qemu-af74b3c15d440d3a3718b8dc6a751c094db75ba3.zip qemu-af74b3c15d440d3a3718b8dc6a751c094db75ba3.tar.gz qemu-af74b3c15d440d3a3718b8dc6a751c094db75ba3.tar.bz2 |
esp.c: move TC and FIFO check logic into esp_dma_done()
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>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/scsi/esp.c | 39 |
1 files changed, 11 insertions, 28 deletions
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index c6151d3..4d58a49 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); } } } |