If you're troubleshooting a SATA drive connection in Linux and you run into errors like this:
[14465.577496] ata2: SATA link down (SStatus 4 SControl 300)
[14476.281867] ata2: SATA link down (SStatus 4 SControl 3F0)
You will likely have trawled the open Internet for solutions and found wonderful advice like "check your cables" and "hard drive is dying". In one case you even get the odd "you dirty boy, elsewhere in your dmesg you loaded a non-GPL module!"
None of it, however, actually attempts to understand *the error message itself*!!
Of course, this is Linux Land, so "just read the source" is the general ethos, so I did. Hopefully I can spare you the pain.
In Linus' Github mirror, you can find this section:
https://github.com/torvalds/linux/blob/b1427432d3b656fac71b3f42824ff4aea3c9f93b/drivers/ata/libata-core.c#L3190
You don't have to click that, though:
if (sata_scr_read(link, SCR_STATUS, &sstatus))
return;
if (sata_scr_read(link, SCR_CONTROL, &scontrol))
return;
if (ata_phys_link_online(link)) {
tmp = (sstatus >> 4) & 0xf;
ata_link_info(link, "SATA link up %s (SStatus %X SControl %X)\n",
sata_spd_string(tmp), sstatus, scontrol);
} else {
ata_link_info(link, "SATA link down (SStatus %X SControl %X)\n",
sstatus, scontrol);
}
So what this message is reporting is merely the hardware register values from the SATA device itself when this function is called. Neat.
So, what are these registers? Well:
https://github.com/torvalds/linux/blob/b1427432d3b656fac71b3f42824ff4aea3c9f93b/drivers/ata/ahci.h#L124
PORT_SCR_STAT = 0x28, /* SATA phy register: SStatus */
PORT_SCR_CTL = 0x2c, /* SATA phy register: SControl */
The SATA register interface is defined as part of AHCI. From Intel's AHCI spec (thanks, Wikipedia!):
3.3.11 Offset 2Ch: PxSCTL – Port x Serial ATA Control (SCR2: SControl)
3.3.10 Offset 28h: PxSSTS – Port x Serial ATA Status (SCR0: SStatus)
In my case, SStatus of 4 means:
4h Phy in offline mode as a result of the interface being disabled or running in a
BIST loopback mode
So, the physical connection part of the SATA controller is off for some reason.
Also, for SControl:
300h: no detection or init requested, no speed negotiation restrictions, Partial and Slumber sleep disabled
3F0h: no detection or init requested, RESERVED, Partial and Slumber sleep disabled
Unfortunately this doesn't also print SCR1 SError, so it's hard to say what actually went wrong.
No comments:
Post a Comment