diff options
author | Ian Moffett <ian@osmora.org> | 2025-05-10 14:28:02 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-05-10 14:28:30 -0400 |
commit | e99ccf090bf17857d0a91e7bc02c2e3d36080b6f (patch) | |
tree | adc5680ef237e3e913dfbdcc14d1d1e4516ca776 /sys/dev/ic/ahci.c | |
parent | 6fb2e7e123ed3fd083ddd0428f082913c81ee656 (diff) |
kernel: ahci: Improve COMRESET reset logicexpt
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/dev/ic/ahci.c')
-rw-r--r-- | sys/dev/ic/ahci.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/sys/dev/ic/ahci.c b/sys/dev/ic/ahci.c index 51da235..246adde 100644 --- a/sys/dev/ic/ahci.c +++ b/sys/dev/ic/ahci.c @@ -312,7 +312,7 @@ hba_port_chkerr(struct hba_port *port) * COMRESET is complete. */ static int -hba_port_reset(struct hba_port *port) +hba_port_reset(struct ahci_hba *hba, struct hba_port *port) { uint32_t sctl, ssts; uint8_t det, ipm; @@ -335,7 +335,7 @@ hba_port_reset(struct hba_port *port) * Wait for the link to become reestablished * between the port and the HBA. */ - tmr.msleep(150); + tmr.msleep(300); sctl &= ~AHCI_DET_COMRESET; mmio_write32(&port->sctl, sctl); @@ -628,23 +628,26 @@ ahci_init_port(struct ahci_hba *hba, uint32_t portno) struct hba_device *dp; size_t clen, pagesz; uint32_t lo, hi, ssts; + uint8_t det; paddr_t fra, cmdlist, tmp; - devmajor_t major; int error; pagesz = DEFAULT_PAGESIZE; port = &abar->ports[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) { + det = AHCI_PXSCTL_DET(ssts); + switch (det) { + case AHCI_DET_NULL: + /* No device attached */ return 0; + case AHCI_DET_PRESENT: + if ((error = hba_port_reset(hba, port)) < 0) { + pr_trace("failed to reset port %d\n", portno); + return error; + } + break; } pr_trace("found device @ port %d\n", portno); |