diff options
author | Ian Moffett <ian@osmora.org> | 2025-05-09 22:52:43 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-05-09 22:52:43 -0400 |
commit | a0d52cd327ba742c8c9c00c1f95127f7eceabeee (patch) | |
tree | 858f2da7be3c377b3af7b47903a755d86098d8f8 | |
parent | b9ace17f0a2ae6de78de3914873016f60cf70c6f (diff) |
kernel: ahci: Initialize device link before init
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r-- | sys/dev/ic/ahci.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/sys/dev/ic/ahci.c b/sys/dev/ic/ahci.c index 13d7d0a..a9fa8c3 100644 --- a/sys/dev/ic/ahci.c +++ b/sys/dev/ic/ahci.c @@ -423,19 +423,26 @@ ahci_init_port(struct ahci_hba *hba, uint32_t portno) struct hba_port *port; struct hba_device *dp; size_t clen, pagesz; - uint32_t lo, hi; + uint32_t lo, hi, ssts; paddr_t fra, cmdlist, tmp; int error; - pr_trace("found device @ port %d\n", portno); pagesz = DEFAULT_PAGESIZE; port = &abar->ports[portno]; - if ((error = hba_port_stop(port)) < 0) { - pr_trace("failed to stop port %d\n", portno); + /* Reset and stop the port */ + if ((error = hba_port_reset(port)) < 0) { + pr_trace("failed to reset port %d\n", portno); return error; } + /* Is anything on the port? */ + ssts = mmio_read32(&port->ssts); + if (AHCI_PXSCTL_DET(ssts) == AHCI_DET_NULL) { + return 0; + } + + pr_trace("found device @ port %d\n", portno); dp = &devs[portno]; dp->io = port; dp->hba = hba; |