svn commit: r359500 - head/sys/dev/ahci
Alexander Motin
mav at FreeBSD.org
Wed Apr 1 03:35:40 UTC 2020
Author: mav
Date: Wed Apr 1 03:27:47 2020
New Revision: 359500
URL: https://svnweb.freebsd.org/changeset/base/359500
Log:
Add support for AHCI BIOS/OS Handoff.
This allows clean handoff from BIOS implementing some asynchronous I/O to
the OS AHCI driver. During attach driver declares OS ownership request
and waits from 25ms to 2s for BIOS to complete operation and release the
hardware.
MFC after: 2 weeks
Modified:
head/sys/dev/ahci/ahci.c
head/sys/dev/ahci/ahci.h
Modified: head/sys/dev/ahci/ahci.c
==============================================================================
--- head/sys/dev/ahci/ahci.c Wed Apr 1 03:19:42 2020 (r359499)
+++ head/sys/dev/ahci/ahci.c Wed Apr 1 03:27:47 2020 (r359500)
@@ -141,7 +141,27 @@ int
ahci_ctlr_reset(device_t dev)
{
struct ahci_controller *ctlr = device_get_softc(dev);
+ uint32_t v;
int timeout;
+
+ /* BIOS/OS Handoff */
+ if ((ATA_INL(ctlr->r_mem, AHCI_VS) >= 0x00010200) &&
+ (ATA_INL(ctlr->r_mem, AHCI_CAP2) & AHCI_CAP2_BOH) &&
+ ((v = ATA_INL(ctlr->r_mem, AHCI_BOHC)) & AHCI_BOHC_OOS) == 0) {
+
+ /* Request OS ownership. */
+ ATA_OUTL(ctlr->r_mem, AHCI_BOHC, v | AHCI_BOHC_OOS);
+
+ /* Wait up to 2s for BIOS ownership release. */
+ for (timeout = 0; timeout < 80; timeout++) {
+ DELAY(25000);
+ v = ATA_INL(ctlr->r_mem, AHCI_BOHC);
+ if ((v & AHCI_BOHC_BOS) == 0)
+ break;
+ if ((v & AHCI_BOHC_BB) == 0)
+ break;
+ }
+ }
/* Enable AHCI mode */
ATA_OUTL(ctlr->r_mem, AHCI_GHC, AHCI_GHC_AE);
Modified: head/sys/dev/ahci/ahci.h
==============================================================================
--- head/sys/dev/ahci/ahci.h Wed Apr 1 03:19:42 2020 (r359499)
+++ head/sys/dev/ahci/ahci.h Wed Apr 1 03:27:47 2020 (r359500)
@@ -214,6 +214,13 @@
#define AHCI_CAP2_SADM 0x00000010
#define AHCI_CAP2_DESO 0x00000020
+#define AHCI_BOHC 0x28
+#define AHCI_BOHC_BOS 0x00000001
+#define AHCI_BOHC_OOS 0x00000002
+#define AHCI_BOHC_SOOE 0x00000004
+#define AHCI_BOHC_OOC 0x00000008
+#define AHCI_BOHC_BB 0x00000010
+
#define AHCI_VSCAP 0xa4
#define AHCI_OFFSET 0x100
#define AHCI_STEP 0x80
More information about the svn-src-all
mailing list