Thread (4 messages) 4 messages, 2 authors, 2017-12-04

[PATCH] libata: sata_down_spd_limit should return if driver has not recorded sstatus speed

From: David Milburn <hidden>
Date: 2017-11-14 22:17:26
Subsystem: libata subsystem (serial and parallel ata drivers), the rest · Maintainers: Damien Le Moal, Niklas Cassel, Linus Torvalds

During hotplug, it is possible for 6Gbps link speed to
be limited all the way down to 1.5 Gbps which may lead
to a slower link speed when drive is re-connected.

This behavior has been seen on a Intel Lewisburg SATA
controller (8086:a1d2) with HGST HUH728080ALE600 drive
where SATA link speed was limited to 1.5 Gbps and
when re-connected the link came up 3.0 Gbps.

This patch was retested on above configuration and
showed the hotplugged link to come back online at max
speed (6Gbps). I did not see the downgrade when testing
on Intel C600/X79, but retested patched linux-4.14-rc5
kernel and didn't see any side effects from this
change. Also, successfully retested hotplug on port
multiplier 3Gbps link.

Signed-off-by: David Milburn <redacted>
---
 drivers/ata/libata-core.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index ee4c1ec..b72b242 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -3081,12 +3081,17 @@ int sata_down_spd_limit(struct ata_link *link, u32 spd_limit)
 	mask &= ~(1 << bit);
 
 	/* Mask off all speeds higher than or equal to the current
-	 * one.  Force 1.5Gbps if current SPD is not available.
+	 * one. At this point if current SPD is not available and we
+	 * previously recorded the link speed from the Status register,
+	 * the driver has already masked off the highest bit so mask
+	 * should already be set to 1 or 0. Otherwise, we should
+	 * not force 1.5Gbps on a link where we have not previously 
+	 * recorded speed from Status register, just return in this case.
 	 */
 	if (spd > 1)
 		mask &= (1 << (spd - 1)) - 1;
 	else
-		mask &= 1;
+		return -EINVAL;
 
 	/* were we already at the bottom? */
 	if (!mask)
-- 
1.8.3.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help