From 414e448542332bb96ba0f3582381be4a5af3d59f Mon Sep 17 00:00:00 2001 From: David Milburn Date: Thu, 6 Sep 2018 15:31:17 -0500 Subject: [PATCH] libata: sata_down_spd_limit should record link speed limit before return During hotplug, it is possible for a device to fail hard reset ata4: COMRESET failed (errno=-16) In this case, __sata_set_spd_needed() will return false preventing sata_link_hardreset() to never turn off the phy and reconfigure the speed. This patch will reset the sata speed limit allowing a hard reset to reconfigure the speed. Fixes commit (2dc0b46b5ea3 libata: sata_down_spd_limit should return if driver has not recorded sstatus speed. --- drivers/ata/libata-core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 599e01b..b4788ff 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -3082,13 +3082,15 @@ int sata_down_spd_limit(struct ata_link *link, u32 spd_limit) * recorded the link speed from SStatus, the driver has already * masked off the highest bit so mask should already be 1 or 0. * Otherwise, we should not force 1.5Gbps on a link where we have - * not previously recorded speed from SStatus. Just return in this - * case. + * not previously recorded speed from SStatus. Reset the link + * speed limit in case a device fails hard reset, and return. */ if (spd > 1) mask &= (1 << (spd - 1)) - 1; - else + else { + link->sata_spd_limit = mask; return -EINVAL; + } /* were we already at the bottom? */ if (!mask) -- 1.8.3.1