diff options
author | Ian Moffett <ian@osmora.org> | 2025-06-14 10:16:02 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-06-14 10:16:02 -0400 |
commit | 532cc55f8fb2319e685642641439236f788dd144 (patch) | |
tree | df9a2269b808cfed37231732b22a3869b0887d1b /sys | |
parent | 115be63f63535c98aa44d0aa7417c0f151ed67b0 (diff) |
kernel: ahci: Wait until ready before any I/O
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/ic/ahci.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/sys/dev/ic/ahci.c b/sys/dev/ic/ahci.c index d8d4a6f..5dbf4a7 100644 --- a/sys/dev/ic/ahci.c +++ b/sys/dev/ic/ahci.c @@ -46,6 +46,7 @@ #include <fs/ctlfs.h> #include <vm/dynalloc.h> #include <vm/physmem.h> +#include <machine/cdefs.h> #include <string.h> #define pr_trace(fmt, ...) kprintf("ahci: " fmt, ##__VA_ARGS__) @@ -57,6 +58,7 @@ static struct hba_device *devs; static struct pci_device *ahci_dev; static struct timer tmr; static struct ahci_hba g_hba; +static struct driver_var __driver_var; /* * Poll register to have 'bits' set/unset. @@ -718,6 +720,10 @@ sata_dev_rw(dev_t dev, struct sio_txn *sio, bool write) static int ahci_dev_read(dev_t dev, struct sio_txn *sio, int flags) { + while (DRIVER_DEFERRED()) { + md_pause(); + } + return sata_dev_rw(dev, sio, false); } @@ -727,6 +733,10 @@ ahci_dev_read(dev_t dev, struct sio_txn *sio, int flags) static int ahci_dev_write(dev_t dev, struct sio_txn *sio, int flags) { + while (DRIVER_DEFERRED()) { + md_pause(); + } + return sata_dev_rw(dev, sio, true); } @@ -738,6 +748,10 @@ ahci_dev_bsize(dev_t dev) { struct hba_device *dp; + while (DRIVER_DEFERRED()) { + md_pause(); + } + if ((dp = ahci_get_dev(dev)) == NULL) { return -ENODEV; } |