Add workaround for bug in VirtualBox AHCI implementation

ICC register is not set to IDLE by chipset. Disabling detection of this
change on VirtualBox saves 2 seconds on boot time.
This commit is contained in:
deadwood 2024-03-19 17:10:21 +01:00
parent f5ee826e7f
commit d750b68e5a
2 changed files with 9 additions and 0 deletions

View File

@ -85,6 +85,8 @@ static void ahci_empty_done(struct ahci_ccb *ccb);
static void ahci_ata_cmd_done(struct ahci_ccb *ccb);
static u_int32_t ahci_pactive(struct ahci_port *ap);
extern int ahci_icc_bug;
/*
* Initialize the global AHCI hardware. This code does not set up any of
* its ports.
@ -1431,6 +1433,7 @@ ahci_comreset(struct ahci_port *ap, int *pmdetectp)
cmd |= AHCI_PREG_CMD_SUD | AHCI_PREG_CMD_POD;
cmd |= AHCI_PREG_CMD_ICC_ACTIVE;
ahci_pwrite(ap, AHCI_PREG_CMD, cmd);
if (!ahci_icc_bug)
ahci_pwait_clr(ap, AHCI_PREG_CMD, AHCI_PREG_CMD_ICC);
/*
@ -1811,6 +1814,7 @@ ahci_port_hardstop(struct ahci_port *ap)
AHCI_PREG_CMD_SUD |
AHCI_PREG_CMD_ICC_ACTIVE;
ahci_pwrite(ap, AHCI_PREG_CMD, cmd);
if (!ahci_icc_bug)
ahci_pwait_clr(ap, AHCI_PREG_CMD, AHCI_PREG_CMD_ICC);
/*

View File

@ -119,6 +119,7 @@ static const struct ahci_pciid ahci_msi_blacklist[] = {
static int ahci_msi_enable = 1;
int ahci_synchronous_boot = 1;
int ahci_icc_bug = 0;
/*
* Match during probe and attach. The device does not yet have a softc.
@ -296,6 +297,10 @@ ahci_pci_attach(device_t dev)
}
}
/* VirtualBox AHCI controller */
if (vid == PCI_VENDOR_INTEL && did == 0x2829 && rev == 0x2)
ahci_icc_bug = 1;
sc->sc_irq_type = pci_alloc_1intr(dev, msi_enable,
&sc->sc_rid_irq, &irq_flags);