Skip to content

Commit 35f6bed

Browse files
committed
ata: libata-eh: Fix link state check for IDE/PATA ports
Commit 4371fe1 ("ata: libata-eh: Avoid unnecessary resets when revalidating devices") replaced the call to ata_phys_link_offline() in ata_eh_revalidate_and_attach() with the new function ata_eh_link_established() which relaxes the checks on a device link state to account for low power mode transitions. However, this change assumed that the device port has a valid scr_read method to obtain the SStatus register for the port. This is not always the case, especially with older IDE/PATA adapters (e.g. PATA/IDE devices emulated with QEMU). For such adapter, ata_eh_link_established() will always return false, causing ata_eh_revalidate_and_attach() to go into its error path and ultimately to the device being disabled. Avoid this by restoring the previous behavior, which is to assume that the link is online if reading the port SStatus register fails. While at it, also fix the spelling of SStatus in the comment describing the function ata_eh_link_established(). Reported-by: Shin'ichiro Kawasaki <[email protected]> Fixes: 4371fe1 ("ata: libata-eh: Avoid unnecessary resets when revalidating devices") Signed-off-by: Damien Le Moal <[email protected]> Tested-by: Shin'ichiro Kawasaki <[email protected]> Reviewed-by: Niklas Cassel <[email protected]>
1 parent dfc0f63 commit 35f6bed

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/ata/libata-eh.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2075,7 +2075,7 @@ static void ata_eh_get_success_sense(struct ata_link *link)
20752075
* Check if a link is established. This is a relaxed version of
20762076
* ata_phys_link_online() which accounts for the fact that this is potentially
20772077
* called after changing the link power management policy, which may not be
2078-
* reflected immediately in the SSTAUS register (e.g., we may still be seeing
2078+
* reflected immediately in the SStatus register (e.g., we may still be seeing
20792079
* the PHY in partial, slumber or devsleep Partial power management state.
20802080
* So check that:
20812081
* - A device is still present, that is, DET is 1h (Device presence detected
@@ -2089,8 +2089,13 @@ static bool ata_eh_link_established(struct ata_link *link)
20892089
u32 sstatus;
20902090
u8 det, ipm;
20912091

2092+
/*
2093+
* For old IDE/PATA adapters that do not have a valid scr_read method,
2094+
* or if reading the SStatus register fails, assume that the device is
2095+
* present. Device probe will determine if that is really the case.
2096+
*/
20922097
if (sata_scr_read(link, SCR_STATUS, &sstatus))
2093-
return false;
2098+
return true;
20942099

20952100
det = sstatus & 0x0f;
20962101
ipm = (sstatus >> 8) & 0x0f;

0 commit comments

Comments
 (0)