On Wed, Jan 31, 2024 at 11:43:59PM +0100, Niklas Cassel wrote: > On Wed, Jan 31, 2024 at 07:08:12AM -0400, Daniel Drake wrote: (snip) > In libata we perform a reset of the port at boot, see: > libata-sata.c:sata_link_hardreset() > after writing to SControl, we call > libata-core.c:ata_wait_ready() that will poll for the port being ready > by calling the check_ready callback. > For AHCI, this callback funcion is set to: > libahci.c:ahci_check_ready(). > > A reset should take the device out of deep power state and should be > sufficient to establish a connection (and that also seems to be the > case when not using Intel VMD). > > However, if you want to debug, I would start by adding prints to > libata-sata.c:sata_link_hardreset() > libata-core.c:ata_wait_ready() > libahci.c:ahci_check_ready(). FWIW, this will dump SStatus.DET every time the check_ready callback function (ahci_check_ready()) is called: diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c index 1a63200ea437..0467e150601e 100644 --- a/drivers/ata/libahci.c +++ b/drivers/ata/libahci.c @@ -1533,6 +1533,12 @@ int ahci_check_ready(struct ata_link *link) { void __iomem *port_mmio = ahci_port_base(link->ap); u8 status = readl(port_mmio + PORT_TFDATA) & 0xFF; + u32 cur = 0; + + sata_scr_read(link, SCR_STATUS, &cur); + + ata_link_info(link, "BUSY ? %d (status: %#x) SStatus.DET: %#x\n", + status & ATA_BUSY, status, cur & 0xf); return ata_check_ready(status); }