Skip to content

Commit

Permalink
esp.c: keep track of the DRQ state during DMA
Browse files Browse the repository at this point in the history
Currently the DRQ IRQ is updated every time DMA data is sent/received which
is both inefficient and causes excessive logging of the DRQ state. Add a
new drq_state bool that only updates the DRQ IRQ if its state changes.

This commit adds the new drq_state bool to the migration state: since the
version number has already been increased earlier in the series, there is
no need to repeat it again here. The DRQ IRQ is (currently) only used for
PDMA transfers which already have a migration break in this series so
there are no problems setting its value post-load.

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-87-mark.cave-ayland@ilande.co.uk>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
  • Loading branch information
mcayland committed Feb 13, 2024
1 parent 6dec7c0 commit 442de89
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
15 changes: 11 additions & 4 deletions hw/scsi/esp.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,20 @@ static void esp_lower_irq(ESPState *s)

static void esp_raise_drq(ESPState *s)
{
qemu_irq_raise(s->drq_irq);
trace_esp_raise_drq();
if (!(s->drq_state)) {
qemu_irq_raise(s->drq_irq);
trace_esp_raise_drq();
s->drq_state = true;
}
}

static void esp_lower_drq(ESPState *s)
{
qemu_irq_lower(s->drq_irq);
trace_esp_lower_drq();
if (s->drq_state) {
qemu_irq_lower(s->drq_irq);
trace_esp_lower_drq();
s->drq_state = false;
}
}

void esp_dma_enable(ESPState *s, int irq, int level)
Expand Down Expand Up @@ -1358,6 +1364,7 @@ const VMStateDescription vmstate_esp = {
VMSTATE_UINT8_TEST(mig_ti_cmd, ESPState,
esp_is_between_version_5_and_6),
VMSTATE_UINT8_TEST(lun, ESPState, esp_is_version_6),
VMSTATE_BOOL(drq_state, ESPState),
VMSTATE_END_OF_LIST()
},
};
Expand Down
1 change: 1 addition & 0 deletions include/hw/scsi/esp.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ struct ESPState {
uint8_t wregs[ESP_REGS];
qemu_irq irq;
qemu_irq drq_irq;
bool drq_state;
uint8_t chip_id;
bool tchi_written;
int32_t ti_size;
Expand Down

0 comments on commit 442de89

Please sign in to comment.