[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 63/88] esp.c: remove unneeded ti_cmd field
From: |
Mark Cave-Ayland |
Subject: |
[PULL 63/88] esp.c: remove unneeded ti_cmd field |
Date: |
Tue, 13 Feb 2024 19:40:27 +0000 |
According to the datasheet the previous ESP command remains in the ESP_CMD
register, which caused a problem when consecutive TI commands were issued as
it becomes impossible for the state machine to know when the first TI
command finishes.
This was the original reason for introducing the ti_cmd field which kept
track of the last written command for this purpose. However closer reading
of the datasheet shows that a TI command that terminates due to a change of
SCSI target phase resets the ESP_CMD register to zero which solves this
problem.
Now that this has been fixed in the previous commit, remove the unneeded
ti_cmd field and access the ESP_CMD register directly instead. Bump the
vmstate_esp version to indicate that the ti_cmd field is no longer included.
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-64-mark.cave-ayland@ilande.co.uk>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
hw/scsi/esp.c | 19 +++++++++++++------
include/hw/scsi/esp.h | 3 ++-
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index ccb8ad4bae..bcebd00831 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -321,7 +321,6 @@ static void do_command_phase(ESPState *s)
fifo8_reset(&s->cmdfifo);
s->data_ready = false;
if (datalen != 0) {
- s->ti_cmd = 0;
/*
* Switch to DATA phase but wait until initial data xfer is
* complete before raising the command completion interrupt
@@ -908,12 +907,12 @@ void esp_transfer_data(SCSIRequest *req, uint32_t len)
* async data transfer is delayed then s->dma is set incorrectly.
*/
- if (s->ti_cmd == (CMD_TI | CMD_DMA)) {
+ if (s->rregs[ESP_CMD] == (CMD_TI | CMD_DMA)) {
/* When the SCSI layer returns more data, raise deferred INTR_BS */
esp_dma_ti_check(s);
esp_do_dma(s);
- } else if (s->ti_cmd == CMD_TI) {
+ } else if (s->rregs[ESP_CMD] == CMD_TI) {
esp_do_nodma(s);
}
}
@@ -927,7 +926,6 @@ static void handle_ti(ESPState *s)
return;
}
- s->ti_cmd = s->rregs[ESP_CMD];
if (s->dma) {
dmalen = esp_get_tc(s);
trace_esp_handle_ti(dmalen);
@@ -1200,6 +1198,14 @@ static bool esp_is_version_6(void *opaque, int
version_id)
return version_id >= 6;
}
+static bool esp_is_between_version_5_and_6(void *opaque, int version_id)
+{
+ ESPState *s = ESP(opaque);
+
+ version_id = MIN(version_id, s->mig_version_id);
+ return version_id >= 5 && version_id <= 6;
+}
+
int esp_pre_save(void *opaque)
{
ESPState *s = ESP(object_resolve_path_component(
@@ -1237,7 +1243,7 @@ static int esp_post_load(void *opaque, int version_id)
const VMStateDescription vmstate_esp = {
.name = "esp",
- .version_id = 6,
+ .version_id = 7,
.minimum_version_id = 3,
.post_load = esp_post_load,
.fields = (const VMStateField[]) {
@@ -1265,7 +1271,8 @@ const VMStateDescription vmstate_esp = {
VMSTATE_UINT8_TEST(cmdfifo_cdb_offset, ESPState, esp_is_version_5),
VMSTATE_FIFO8_TEST(fifo, ESPState, esp_is_version_5),
VMSTATE_FIFO8_TEST(cmdfifo, ESPState, esp_is_version_5),
- VMSTATE_UINT8_TEST(ti_cmd, ESPState, esp_is_version_5),
+ VMSTATE_UINT8_TEST(mig_ti_cmd, ESPState,
+ esp_is_between_version_5_and_6),
VMSTATE_UINT8_TEST(lun, ESPState, esp_is_version_6),
VMSTATE_END_OF_LIST()
},
diff --git a/include/hw/scsi/esp.h b/include/hw/scsi/esp.h
index 1036606943..39b416f538 100644
--- a/include/hw/scsi/esp.h
+++ b/include/hw/scsi/esp.h
@@ -41,7 +41,6 @@ struct ESPState {
uint32_t do_cmd;
bool data_ready;
- uint8_t ti_cmd;
int dma_enabled;
uint32_t async_len;
@@ -62,6 +61,8 @@ struct ESPState {
uint8_t mig_ti_buf[ESP_FIFO_SZ];
uint8_t mig_cmdbuf[ESP_CMDFIFO_SZ];
uint32_t mig_cmdlen;
+
+ uint8_t mig_ti_cmd;
};
#define TYPE_SYSBUS_ESP "sysbus-esp"
--
2.39.2
- [PULL 53/88] esp.c: replace do_dma_pdma_cb() with esp_do_dma(), (continued)
- [PULL 53/88] esp.c: replace do_dma_pdma_cb() with esp_do_dma(), Mark Cave-Ayland, 2024/02/13
- [PULL 88/88] esp.c: add my copyright to the file, Mark Cave-Ayland, 2024/02/13
- [PULL 83/88] esp.c: replace n variable with len in esp_do_nodma(), Mark Cave-Ayland, 2024/02/13
- [PULL 52/88] esp.c: move CMD_SELATNS end of command logic to esp_do_dma() and do_dma_pdma_cb(), Mark Cave-Ayland, 2024/02/13
- [PULL 62/88] esp.c: zero command register when TI command terminates due to phase change, Mark Cave-Ayland, 2024/02/13
- [PULL 77/88] esp.c: only transfer non-DMA MESSAGE OUT phase data for specific commands, Mark Cave-Ayland, 2024/02/13
- [PULL 55/88] esp.c: always use esp_do_dma() in pdma_cb(), Mark Cave-Ayland, 2024/02/13
- [PULL 85/88] esp.c: rename irq_data IRQ to drq_irq, Mark Cave-Ayland, 2024/02/13
- [PULL 76/88] esp.c: only transfer non-DMA COMMAND phase data for specific commands, Mark Cave-Ayland, 2024/02/13
- [PULL 66/88] esp.c: process non-DMA FIFO writes in esp_do_nodma(), Mark Cave-Ayland, 2024/02/13
- [PULL 63/88] esp.c: remove unneeded ti_cmd field,
Mark Cave-Ayland <=
- [PULL 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/02/13
- [PULL 86/88] esp.c: keep track of the DRQ state during DMA, Mark Cave-Ayland, 2024/02/13
- [PULL 61/88] esp.c: remove DATA IN phase logic when reading from FIFO, Mark Cave-Ayland, 2024/02/13
- [PULL 68/88] esp.c: move write_response() non-DMA logic to esp_do_nodma(), Mark Cave-Ayland, 2024/02/13
- [PULL 74/88] esp.c: handle non-DMA FIFO writes used to terminate DMA commands, Mark Cave-Ayland, 2024/02/13
- [PULL 59/88] esp.c: separate logic based upon ESP command in esp_transfer_data(), Mark Cave-Ayland, 2024/02/13
- [PULL 72/88] esp.c: handle TC underflow for DMA SCSI requests, Mark Cave-Ayland, 2024/02/13
- [PULL 75/88] esp.c: improve ESP_RSEQ logic consolidation, Mark Cave-Ayland, 2024/02/13
- [PULL 84/88] esp.c: implement DMA Transfer Pad command for DATA phases, Mark Cave-Ayland, 2024/02/13
- [PULL 60/88] esp.c: use deferred interrupts for both DATA IN and DATA OUT phases, Mark Cave-Ayland, 2024/02/13