Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/ahci/ahci.c
Show First 20 Lines • Show All 149 Lines • ▼ Show 20 Lines | if ((ATA_INL(ctlr->r_mem, AHCI_VS) >= 0x00010200) && | ||||
(ATA_INL(ctlr->r_mem, AHCI_CAP2) & AHCI_CAP2_BOH) && | (ATA_INL(ctlr->r_mem, AHCI_CAP2) & AHCI_CAP2_BOH) && | ||||
((v = ATA_INL(ctlr->r_mem, AHCI_BOHC)) & AHCI_BOHC_OOS) == 0) { | ((v = ATA_INL(ctlr->r_mem, AHCI_BOHC)) & AHCI_BOHC_OOS) == 0) { | ||||
/* Request OS ownership. */ | /* Request OS ownership. */ | ||||
ATA_OUTL(ctlr->r_mem, AHCI_BOHC, v | AHCI_BOHC_OOS); | ATA_OUTL(ctlr->r_mem, AHCI_BOHC, v | AHCI_BOHC_OOS); | ||||
/* Wait up to 2s for BIOS ownership release. */ | /* Wait up to 2s for BIOS ownership release. */ | ||||
for (timeout = 0; timeout < 80; timeout++) { | for (timeout = 0; timeout < 80; timeout++) { | ||||
DELAY(25000); | DELAY(25000); | ||||
v = ATA_INL(ctlr->r_mem, AHCI_BOHC); | v = ATA_INL(ctlr->r_mem, AHCI_BOHC); | ||||
allanjude: while the comment is updated, the code still appears to do 25ms * 80 = 2 seconds | |||||
Done Inline ActionsThis time is ok, I screw up the comment fix. Suggested in PR. oshogbo: This time is ok, I screw up the comment fix. Suggested in PR. | |||||
if ((v & AHCI_BOHC_BOS) == 0) | if ((v & AHCI_BOHC_BOS) == 0) | ||||
break; | break; | ||||
if ((v & AHCI_BOHC_BB) == 0) | if ((v & AHCI_BOHC_BB) == 0) | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
/* Enable AHCI mode */ | /* Enable AHCI mode */ | ||||
▲ Show 20 Lines • Show All 2,433 Lines • ▼ Show 20 Lines | ahci_setup_fis(struct ahci_channel *ch, struct ahci_cmd_tab *ctp, union ccb *ccb, int tag) | ||||
} | } | ||||
return (20); | return (20); | ||||
} | } | ||||
static int | static int | ||||
ahci_sata_connect(struct ahci_channel *ch) | ahci_sata_connect(struct ahci_channel *ch) | ||||
{ | { | ||||
u_int32_t status; | u_int32_t status; | ||||
int timeout, found = 0; | int timeout, timeoutslot, found = 0; | ||||
/* Wait up to 100ms for "connect well" */ | /* | ||||
for (timeout = 0; timeout < 1000 ; timeout++) { | * Wait for "connect well", up to 100ms by default and | ||||
* up to 500ms for devices with the SLOWDEV quirk. | |||||
*/ | |||||
timeoutslot = ((ch->quirks & AHCI_Q_SLOWDEV) ? 5000 : 1000); | |||||
for (timeout = 0; timeout < timeoutslot; timeout++) { | |||||
Done Inline ActionsIs this clearer: 'Wait for "connect well", up to 100ms by default and up to 500ms for devices with the SLOWDEV quirk.' thj: Is this clearer:
'Wait for "connect well", up to 100ms by default and up to 500ms for devices… | |||||
status = ATA_INL(ch->r_mem, AHCI_P_SSTS); | status = ATA_INL(ch->r_mem, AHCI_P_SSTS); | ||||
if ((status & ATA_SS_DET_MASK) != ATA_SS_DET_NO_DEVICE) | if ((status & ATA_SS_DET_MASK) != ATA_SS_DET_NO_DEVICE) | ||||
found = 1; | found = 1; | ||||
if (((status & ATA_SS_DET_MASK) == ATA_SS_DET_PHY_ONLINE) && | if (((status & ATA_SS_DET_MASK) == ATA_SS_DET_PHY_ONLINE) && | ||||
((status & ATA_SS_SPD_MASK) != ATA_SS_SPD_NO_SPEED) && | ((status & ATA_SS_SPD_MASK) != ATA_SS_SPD_NO_SPEED) && | ||||
((status & ATA_SS_IPM_MASK) == ATA_SS_IPM_ACTIVE)) | ((status & ATA_SS_IPM_MASK) == ATA_SS_IPM_ACTIVE)) | ||||
break; | break; | ||||
if ((status & ATA_SS_DET_MASK) == ATA_SS_DET_PHY_OFFLINE) { | if ((status & ATA_SS_DET_MASK) == ATA_SS_DET_PHY_OFFLINE) { | ||||
if (bootverbose) { | if (bootverbose) { | ||||
device_printf(ch->dev, "SATA offline status=%08x\n", | device_printf(ch->dev, "SATA offline status=%08x\n", | ||||
status); | status); | ||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
if (found == 0 && timeout >= 100) | if (found == 0 && timeout >= 100) | ||||
break; | break; | ||||
DELAY(100); | DELAY(100); | ||||
} | } | ||||
if (timeout >= 1000 || !found) { | if (timeout >= timeoutslot || !found) { | ||||
if (bootverbose) { | if (bootverbose) { | ||||
device_printf(ch->dev, | device_printf(ch->dev, | ||||
"SATA connect timeout time=%dus status=%08x\n", | "SATA connect timeout time=%dus status=%08x\n", | ||||
timeout * 100, status); | timeout * 100, status); | ||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
if (bootverbose) { | if (bootverbose) { | ||||
▲ Show 20 Lines • Show All 271 Lines • Show Last 20 Lines |
while the comment is updated, the code still appears to do 25ms * 80 = 2 seconds