Shorten original delays to cut boot time by 50%

This changes original delays from DragonflyBSD code. This might prove to
be a problem under certain hardware. Introduce "slowerstart" bootstrap
argument that reverts to original timing.
This commit is contained in:
deadwood 2024-03-16 16:46:37 +01:00
parent dca6bb5e1d
commit 80046e3470
4 changed files with 13 additions and 6 deletions

View File

@ -1460,7 +1460,7 @@ retry:
* Give the new power management state time to settle, then clear
* pending status.
*/
ahci_os_sleep(1000);
ahci_os_sleep(AhciStartDelay << 2);
ahci_flush_tfd(ap);
ahci_pwrite(ap, AHCI_PREG_SERR, -1);
@ -1493,7 +1493,7 @@ retry:
break;
}
ahci_pwrite(ap, AHCI_PREG_SCTL, r);
ahci_os_sleep(1000);
ahci_os_sleep(AhciStartDelay << 2);
ap->ap_flags &= ~AP_F_HARSH_REINIT;
@ -1516,7 +1516,7 @@ retry:
r &= ~AHCI_PREG_SCTL_DET_INIT;
r |= AHCI_PREG_SCTL_DET_NONE;
ahci_pwrite(ap, AHCI_PREG_SCTL, r);
ahci_os_sleep(1000);
ahci_os_sleep(AhciStartDelay << 2);
/*
* Try to determine if there is a device on the port. This operation
@ -1535,7 +1535,7 @@ retry:
* If we fail clear PRCS (phy detect) since we may cycled
* the phy and probably caused another PRCS interrupt.
*/
loop = 2000;
loop = AhciStartDelay * 10;
while (loop > 0) {
r = ahci_pread(ap, AHCI_PREG_SSTS);
if (r & AHCI_PREG_SSTS_DET)
@ -1656,7 +1656,7 @@ ahci_port_hardreset(struct ahci_port *ap, int hard)
/*
* Finish up.
*/
ahci_os_sleep(500);
ahci_os_sleep(AhciStartDelay << 1);
switch(error) {
case 0:

View File

@ -665,6 +665,7 @@ void ahci_os_unlock_port(struct ahci_port *ap);
extern u_int32_t AhciForceGen;
extern u_int32_t AhciNoFeatures;
extern int ahci_synchronous_boot;
extern u_int32_t AhciStartDelay;
enum {AHCI_LINK_PWR_MGMT_NONE, AHCI_LINK_PWR_MGMT_MEDIUM,
AHCI_LINK_PWR_MGMT_AGGR};

View File

@ -46,6 +46,7 @@
u_int32_t AhciForceGen = 0;
u_int32_t AhciNoFeatures = 0;
u_int32_t AhciStartDelay = 25;
#include LC_LIBDEFS_FILE
@ -134,6 +135,11 @@ static int AHCI_Init(struct AHCIBase *AHCIBase)
D(bug("[AHCI--] %s: Disabling AHCI features\n", __func__));
AhciNoFeatures = -1;
}
if (strstr(CmdLine, "slowerstart"))
{
D(bug("[AHCI--] %s: Using original start delays\n", __func__));
AhciStartDelay = 250;
}
}
}
}

View File

@ -303,7 +303,7 @@ retry:
* target 0, because when a PM is attached target 0 represents
* slot #0 behind the PM.
*/
if (ahci_poll(ccb, 5000, ahci_quick_timeout) != ATA_S_COMPLETE) {
if (ahci_poll(ccb, 500 + (AhciStartDelay * 20), ahci_quick_timeout) != ATA_S_COMPLETE) {
kprintf("%s: PMPROBE(2) No Port Multiplier was found.\n",
PORTNAME(ap));
if (--count) {