* [PATCH] ata: libata: preserve sata_spd link cache across ata_dev_init
@ 2026-10-10 7:54 tongzhiwei
2026-10-15 5:30 ` Damien Le Moal
0 siblings, 1 reply; 3+ messages in thread
From: tongzhiwei @ 2026-10-10 7:54 UTC (permalink / raw)
To: dlemoal, cassel; +Cc: tongzhiwei, linux-ide, linux-kernel
a hot-unplug goes through
ata_eh_schedule_probe() -> ata_dev_init() -> sata_spd = 0.
After commit 69f2c9346313 ("ata: libata: Fix sata_down_spd_limit() when no
link speed is reported"), when
the device is unplugged, every probe lowers sata_spd_limit, which breaks
commit 2dc0b46b5ea3 ("libata: sata_down_spd_limit should return if
driver has not recorded sstatus speed"). The harm is, when the device
is plugged back, it is limited to low speed which will never be recovered.
This patch stops zeroing sata_spd in ata_dev_init (sata_spd was
introduced in commit 008a78961ec7 ("libata: improve SATA PHY speed down
logic")). sata_spd is then written only on a successful reset. At
struct ata_port's init time the sata_spd field is zeroed by kzalloc.
Fixes: 69f2c9346313 ("ata: libata: Fix sata_down_spd_limit() when no link speed is reported")
Assisted-by: LLM
Signed-off-by: tongzhiwei <tongzhiwei@cmss.chinamobile.com>
---
drivers/ata/libata-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index f482c0a6d7e9..2ddad2e6ebd2 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -5659,7 +5659,7 @@ void ata_dev_init(struct ata_device *dev)
/* SATA spd limit is bound to the attached device, reset together */
link->sata_spd_limit = link->hw_sata_spd_limit;
- link->sata_spd = 0;
+ /* link->sata_spd caches last negotiated link speed; not zeroed here */
/* High bits of dev->flags are used to record warm plug
* requests which occur asynchronously. Synchronize using
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ata: libata: preserve sata_spd link cache across ata_dev_init
2026-10-10 7:54 [PATCH] ata: libata: preserve sata_spd link cache across ata_dev_init tongzhiwei
@ 2026-10-15 5:30 ` Damien Le Moal
2026-10-15 7:59 ` Damien Le Moal
0 siblings, 1 reply; 3+ messages in thread
From: Damien Le Moal @ 2026-10-15 5:30 UTC (permalink / raw)
To: tongzhiwei, cassel; +Cc: linux-ide, linux-kernel
On 2026/10/10 9:54, tongzhiwei wrote:
> a hot-unplug goes through
> ata_eh_schedule_probe() -> ata_dev_init() -> sata_spd = 0.
> After commit 69f2c9346313 ("ata: libata: Fix sata_down_spd_limit() when no
> link speed is reported"), when
> the device is unplugged, every probe lowers sata_spd_limit, which breaks
> commit 2dc0b46b5ea3 ("libata: sata_down_spd_limit should return if
> driver has not recorded sstatus speed"). The harm is, when the device
> is plugged back, it is limited to low speed which will never be recovered.
>
> This patch stops zeroing sata_spd in ata_dev_init (sata_spd was
> introduced in commit 008a78961ec7 ("libata: improve SATA PHY speed down
> logic")). sata_spd is then written only on a successful reset. At
> struct ata_port's init time the sata_spd field is zeroed by kzalloc.
>
> Fixes: 69f2c9346313 ("ata: libata: Fix sata_down_spd_limit() when no link speed is reported")
> Assisted-by: LLM
> Signed-off-by: tongzhiwei <tongzhiwei@cmss.chinamobile.com>
> ---
> drivers/ata/libata-core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
> index f482c0a6d7e9..2ddad2e6ebd2 100644
> --- a/drivers/ata/libata-core.c
> +++ b/drivers/ata/libata-core.c
> @@ -5659,7 +5659,7 @@ void ata_dev_init(struct ata_device *dev)
>
> /* SATA spd limit is bound to the attached device, reset together */
> link->sata_spd_limit = link->hw_sata_spd_limit;
> - link->sata_spd = 0;
> + /* link->sata_spd caches last negotiated link speed; not zeroed here */
This contradicts the previous comment, so let's make this consistent. E.g.
something like:
/*
* The SATA speed limit is bound to the attached device, so reset it
* but keep the last negotiated speed indicated by link->sata_spd.
*/
to replace the previous comment.
>
> /* High bits of dev->flags are used to record warm plug
> * requests which occur asynchronously. Synchronize using
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ata: libata: preserve sata_spd link cache across ata_dev_init
2026-10-15 5:30 ` Damien Le Moal
@ 2026-10-15 7:59 ` Damien Le Moal
0 siblings, 0 replies; 3+ messages in thread
From: Damien Le Moal @ 2026-10-15 7:59 UTC (permalink / raw)
To: tongzhiwei, cassel; +Cc: linux-ide, linux-kernel
On 2026/10/15 7:30, Damien Le Moal wrote:
> On 2026/10/10 9:54, tongzhiwei wrote:
>> a hot-unplug goes through
>> ata_eh_schedule_probe() -> ata_dev_init() -> sata_spd = 0.
>> After commit 69f2c9346313 ("ata: libata: Fix sata_down_spd_limit() when no
>> link speed is reported"), when
>> the device is unplugged, every probe lowers sata_spd_limit, which breaks
>> commit 2dc0b46b5ea3 ("libata: sata_down_spd_limit should return if
>> driver has not recorded sstatus speed"). The harm is, when the device
>> is plugged back, it is limited to low speed which will never be recovered.
>>
>> This patch stops zeroing sata_spd in ata_dev_init (sata_spd was
>> introduced in commit 008a78961ec7 ("libata: improve SATA PHY speed down
>> logic")). sata_spd is then written only on a successful reset. At
>> struct ata_port's init time the sata_spd field is zeroed by kzalloc.
>>
>> Fixes: 69f2c9346313 ("ata: libata: Fix sata_down_spd_limit() when no link speed is reported")
>> Assisted-by: LLM
>> Signed-off-by: tongzhiwei <tongzhiwei@cmss.chinamobile.com>
>> ---
>> drivers/ata/libata-core.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
>> index f482c0a6d7e9..2ddad2e6ebd2 100644
>> --- a/drivers/ata/libata-core.c
>> +++ b/drivers/ata/libata-core.c
>> @@ -5659,7 +5659,7 @@ void ata_dev_init(struct ata_device *dev)
>>
>> /* SATA spd limit is bound to the attached device, reset together */
>> link->sata_spd_limit = link->hw_sata_spd_limit;
>> - link->sata_spd = 0;
>> + /* link->sata_spd caches last negotiated link speed; not zeroed here */
>
> This contradicts the previous comment, so let's make this consistent. E.g.
> something like:
>
> /*
> * The SATA speed limit is bound to the attached device, so reset it
> * but keep the last negotiated speed indicated by link->sata_spd.
> */
>
> to replace the previous comment.
>
>>
>> /* High bits of dev->flags are used to record warm plug
>> * requests which occur asynchronously. Synchronize using
Looking at the Sashiko comment on this patch, I think it is valid and should be
addressed as well.
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-15 7:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-10 7:54 [PATCH] ata: libata: preserve sata_spd link cache across ata_dev_init tongzhiwei
2026-10-15 5:30 ` Damien Le Moal
2026-10-15 7:59 ` Damien Le Moal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®