Commit adcc05b3 authored by Damien Le Moal's avatar Damien Le Moal Committed by zhaoxiaoqiang11
Browse files

ata: libata: Fix sata_down_spd_limit() when no link speed is reported

stable inclusion
from stable-v5.10.168
commit 4d9c9627161a06c098f9d7bb566a42da87759463
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7URR4

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=4d9c9627161a06c098f9d7bb566a42da87759463



----------------------------------------------------

[ Upstream commit 69f2c934 ]

Commit 2dc0b46b ("libata: sata_down_spd_limit should return if
driver has not recorded sstatus speed") changed the behavior of
sata_down_spd_limit() to return doing nothing if a drive does not report
a current link speed, to avoid reducing the link speed to the lowest 1.5
Gbps speed.

However, the change assumed that a speed was recorded before probing
(e.g. before a suspend/resume) and set in link->sata_spd. This causes
problems with adapters/drives combination failing to establish a link
speed during probe autonegotiation. One example reported of this problem
is an mvebu adapter with a 3Gbps port-multiplier box: autonegotiation
fails, leaving no recorded link speed and no reported current link
speed. Probe retries also fail as no action is taken by sata_set_spd()
after each retry.

Fix this by returning early in sata_down_spd_limit() only if we do have
a recorded link speed, that is, if link->sata_spd is not 0. With this
fix, a failed probe not leading to a recorded link speed is retried at
the lower 1.5 Gbps speed, with the link speed potentially increased
later on the second revalidate of the device if the device reports
that it supports higher link speeds.

Reported-by: default avatarMarius Dinu <marius@psihoexpert.ro>
Fixes: 2dc0b46b ("libata: sata_down_spd_limit should return if driver has not recorded sstatus speed")
Reviewed-by: default avatarNiklas Cassel <niklas.cassel@wdc.com>
Tested-by: default avatarMarius Dinu <marius@psihoexpert.ro>
Signed-off-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarzhaoxiaoqiang11 <zhaoxiaoqiang11@jd.com>
parent 30567f54
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment