summaryrefslogtreecommitdiff
path: root/pc-bios/openbios-esp.diff
blob: 5d4f836f1229109aa332e4532b492966b77dfe86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
The ESP SCSI driver currently doesn't check whether a DMA requests has 
completed before checking its status. On older qemu versions this works ok 
because DMA happens instantly. On never qemu DMA can take an indeterminate 
amount of time ooto complete, just like on real hardware.

The patch below waits for the controller to raise the DMA interrupt after 
initiating a DMA request.

Index: drivers/esp.c
===================================================================
--- drivers/esp.c	(revision 61)
+++ drivers/esp.c	(working copy)
@@ -113,6 +113,8 @@ do_command(esp_private_t *esp, sd_privat
     esp->espdma.regs->cond_reg = 0;
     // Set ATN, issue command
     esp->ll->regs[ESP_CMD] = ESP_CMD_SELA | ESP_CMD_DMA;
+    // Wait for DMA to complete
+    while ((esp->espdma.regs->cond_reg & DMA_HNDL_INTR) == 0) /* no-op */;
     // Check status
     status = esp->ll->regs[ESP_STATUS];
 
@@ -129,6 +131,8 @@ do_command(esp_private_t *esp, sd_privat
     esp->espdma.regs->cond_reg = DMA_ST_WRITE;
     // Transfer
     esp->ll->regs[ESP_CMD] = ESP_CMD_TI | ESP_CMD_DMA;
+    // Wait for DMA to complete
+    while ((esp->espdma.regs->cond_reg & DMA_HNDL_INTR) == 0) /* no-op */;
     // Check status
     status = esp->ll->regs[ESP_STATUS];