From 532cc55f8fb2319e685642641439236f788dd144 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sat, 14 Jun 2025 10:16:02 -0400 Subject: kernel: ahci: Wait until ready before any I/O Signed-off-by: Ian Moffett --- sys/dev/ic/ahci.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'sys') 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 #include #include +#include #include #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; } -- cgit v1.2.3