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>
This commit is contained in:
Mark Cave-Ayland 2024-01-12 12:53:22 +00:00
parent cb9881999d
commit af74b3c15d

View File

@ -545,8 +545,11 @@ static void write_response(ESPState *s)
static void esp_dma_done(ESPState *s) static void esp_dma_done(ESPState *s)
{ {
s->rregs[ESP_RINTR] |= INTR_BS; if (esp_get_tc(s) == 0 && fifo8_num_used(&s->fifo) < 2) {
esp_raise_irq(s); s->rregs[ESP_RINTR] |= INTR_BS;
esp_raise_irq(s);
esp_lower_drq(s);
}
} }
static void do_dma_pdma_cb(ESPState *s) static void do_dma_pdma_cb(ESPState *s)
@ -610,12 +613,7 @@ static void do_dma_pdma_cb(ESPState *s)
return; 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);
}
return;
} else { } else {
if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) { if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) {
/* Defer until the scsi layer has completed */ /* Defer until the scsi layer has completed */
@ -624,10 +622,7 @@ static void do_dma_pdma_cb(ESPState *s)
return; 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);
}
/* Copy device data to FIFO */ /* Copy device data to FIFO */
len = MIN(s->async_len, esp_get_tc(s)); len = MIN(s->async_len, esp_get_tc(s));
@ -713,10 +708,7 @@ static void esp_do_dma(ESPState *s)
return; return;
} }
if (esp_get_tc(s) == 0 && fifo8_num_used(&s->fifo) < 2) { esp_dma_done(s);
esp_dma_done(s);
esp_lower_drq(s);
}
} else { } else {
esp_set_pdma_cb(s, DO_DMA_PDMA_CB); esp_set_pdma_cb(s, DO_DMA_PDMA_CB);
esp_raise_drq(s); esp_raise_drq(s);
@ -727,10 +719,7 @@ static void esp_do_dma(ESPState *s)
return; return;
} }
if (esp_get_tc(s) == 0 && fifo8_num_used(&s->fifo) < 2) { esp_dma_done(s);
esp_dma_done(s);
esp_lower_drq(s);
}
} }
} else { } else {
if (s->dma_memory_write) { if (s->dma_memory_write) {
@ -747,10 +736,7 @@ static void esp_do_dma(ESPState *s)
return; return;
} }
if (esp_get_tc(s) == 0 && fifo8_num_used(&s->fifo) < 2) { esp_dma_done(s);
esp_dma_done(s);
esp_lower_drq(s);
}
} else { } else {
/* Copy device data to FIFO */ /* Copy device data to FIFO */
len = MIN(len, fifo8_num_free(&s->fifo)); len = MIN(len, fifo8_num_free(&s->fifo));
@ -768,10 +754,7 @@ static void esp_do_dma(ESPState *s)
return; 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);
}
} }
} }
} }