January 24, 2023 1:00 AM, "Damien Le Moal" <damien.lemoal@xxxxxxxxxxxxxxxxxx> wrote: >> I think that the old behaviour (before commit >> 2dc0b46b5ea30f169b0b272253ea846a5a281731) of slowing down sata speed >> when a connection can't be established is in fact the right thing to >> do. Maybe a longer delay before reducing the link speed would satisfy >> the random cases that the commit author reported. Maybe he was just >> having a loose connector issue - especially since he only reported one >> case. > > I do not think that a longer delay will change anything in your case since > the device presence cannot be established when starting speed negotiation > without a limit: see the "debounce, SCR=0x100" messages in your debug, > while the 1.5gbps link speed forcing leads to an immediate device presence > detected (debounce, SCR=0x113 message). I was referring to the original "bug" the commit author (David Milburn) was trying to fix. > Can you please try this one: > > diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c > index 884ae73b11ea..a4e2a93af0e5 100644 > --- a/drivers/ata/libata-core.c > +++ b/drivers/ata/libata-core.c > @@ -3085,10 +3085,17 @@ int sata_down_spd_limit(struct ata_link *link, u32 > spd_limit) > * If not, use cached value in link->sata_spd. > */ > rc = sata_scr_read(link, SCR_STATUS, &sstatus); > - if (rc == 0 && ata_sstatus_online(sstatus)) > + if (rc == 0 && ata_sstatus_online(sstatus)) { > spd = (sstatus >> 4) & 0xf; > - else > + } else { > + /* > + * Device is not reporting a speed yet. Use the last recorded > + * speed. If we do not have that either, start with Gen3 > speed. > + */ > + if (!link->sata_spd) > + link->sata_spd = 3; > spd = link->sata_spd; > + } > > mask = link->sata_spd_limit; > if (mask <= 1) It works. [ 19.408712][ T113] hardreset, Online=>Offline [ 19.408721][ T113] sata_set_spd_needed, scontrol=0x330 [ 19.413195][ T113] __sata_set_spd_needed, initial limit=0xFFFFFFFF [ 19.418473][ T113] __sata_set_spd_needed, corrected limit=0xFFFFFFFF [ 19.424789][ T113] __sata_set_spd_needed, target=0x3 [ 19.431265][ T113] __sata_set_spd_needed, spd=0x3 [ 19.436358][ T113] __sata_set_spd_needed, final *scontrol=0x330 [ 19.442248][ T113] resume, do loop [ 19.673966][ T113] resume, after do loop [ 19.733966][ T113] debounce, SCR=0x100 [ 19.793965][ T113] debounce, SCR=0x100 [ 19.853965][ T113] debounce, SCR=0x100 [ 19.913966][ T113] debounce, SCR=0x100 [ 19.973965][ T113] debounce, SCR=0x100 [ 20.033966][ T113] debounce, SCR=0x100 [ 20.093966][ T113] debounce, SCR=0x100 [ 20.153965][ T113] debounce, SCR=0x0 [ 20.213987][ T113] debounce, SCR=0x0 [ 20.217673][ T113] resume, return at end of function [ 20.221358][ T113] hardreset, ata_phys_link_offline check failed [ 20.226462][ T113] ata2: SATA link down (SStatus 0 SControl 330) [ 20.321504][ T113] sata_down_spd_limit: limit 0x1, cur spd 0x0, saved limit 0xffffffff, hw limit 0xffffffff [ 20.331407][ T113] ata2: limiting SATA link speed to 1.5 Gbps [ 20.337294][ T113] hardreset, Online=>Offline [ 20.337300][ T113] sata_set_spd_needed, scontrol=0x330 [ 20.341770][ T113] __sata_set_spd_needed, initial limit=0x1 [ 20.347037][ T113] __sata_set_spd_needed, corrected limit=0x1 [ 20.352728][ T113] __sata_set_spd_needed, target=0x1 [ 20.358605][ T113] __sata_set_spd_needed, spd=0x3 [ 20.363684][ T113] __sata_set_spd_needed, final *scontrol=0x310 [ 20.368515][ T113] __sata_set_spd_needed, initial limit=0x1 [ 20.374576][ T113] __sata_set_spd_needed, corrected limit=0x1 [ 20.380267][ T113] __sata_set_spd_needed, target=0x1 [ 20.386144][ T113] __sata_set_spd_needed, spd=0x3 [ 20.391223][ T113] __sata_set_spd_needed, final *scontrol=0x314 [ 20.397127][ T113] resume, do loop [ 20.623966][ T113] resume, after do loop [ 20.683966][ T113] debounce, SCR=0x113 [ 20.733987][ T113] debounce, SCR=0x113 [ 20.793966][ T113] debounce, SCR=0x113 [ 20.853965][ T113] debounce, SCR=0x113 [ 20.913966][ T113] debounce, SCR=0x113 [ 20.973965][ T113] debounce, SCR=0x113 [ 21.033966][ T113] debounce, SCR=0x113 [ 21.093966][ T113] debounce, SCR=0x113 [ 21.153965][ T113] debounce, SCR=0x113 [ 21.157826][ T113] resume, return at end of function [ 21.161684][ T113] hardreset, Offline=>Online [ 21.171249][ T113] hardreset, sata_pmp_supported, before check_ready [ 21.343968][ T113] ata2: SATA link up 1.5 Gbps (SStatus 113 SControl 310) [ 21.357696][ T113] ata2.15: Port Multiplier 1.2, 0x197b:0x0325 r193, 8 ports, feat 0xf/0x1f [ 21.366318][ T113] device: 'link2.0': device_add [ 21.371124][ T113] device: 'link2.0': device_add [ 21.376120][ T113] device: 'dev2.0.0': device_add [ 21.380966][ T113] device: 'dev2.0.0': device_add [ 21.385953][ T113] device: 'link2.1': device_add [ 21.390711][ T113] device: 'link2.1': device_add [ 21.395569][ T113] device: 'dev2.1.0': device_add [ 21.400437][ T113] device: 'dev2.1.0': device_add [ 21.405469][ T113] device: 'link2.2': device_add [ 21.410232][ T113] device: 'link2.2': device_add [ 21.415086][ T113] device: 'dev2.2.0': device_add [ 21.419937][ T113] device: 'dev2.2.0': device_add [ 21.424910][ T113] device: 'link2.3': device_add [ 21.429669][ T113] device: 'link2.3': device_add [ 21.434528][ T113] device: 'dev2.3.0': device_add [ 21.439374][ T113] device: 'dev2.3.0': device_add ... [ 21.640403][ T113] device: 'link2.14': device_add [ 21.645287][ T113] device: 'link2.14': device_add [ 21.650234][ T113] device: 'dev2.14.0': device_add [ 21.655197][ T113] device: 'dev2.14.0': device_add [ 21.660252][ T113] ahci-mvebu f10a8000.sata: FBS is enabled [ 21.666005][ T113] ata2.00: SCR_CONTROL = 0x300 [ 21.670684][ T113] ata2.01: SCR_CONTROL = 0x300 [ 21.675389][ T113] ata2.02: SCR_CONTROL = 0x300 [ 21.680066][ T113] ata2.03: SCR_CONTROL = 0x300 [ 21.684774][ T113] ata2.04: SCR_CONTROL = 0x300 [ 21.689452][ T113] ata2.05: SCR_CONTROL = 0x300 [ 21.694194][ T113] ata2.06: SCR_CONTROL = 0x300 [ 21.698871][ T113] ata2.07: SCR_CONTROL = 0x300 [ 21.703624][ T113] ata2.00: hard resetting link [ 21.708304][ T113] hardreset, Online=>Offline [ 21.708343][ T113] sata_set_spd_needed, scontrol=0x300 [ 21.712815][ T113] __sata_set_spd_needed, initial limit=0xFFFFFFFF [ 21.718093][ T113] __sata_set_spd_needed, corrected limit=0x1 [ 21.724409][ T113] __sata_set_spd_needed, target=0x1 [ 21.730274][ T113] __sata_set_spd_needed, spd=0x0 [ 21.735366][ T113] __sata_set_spd_needed, final *scontrol=0x310 [ 21.740280][ T113] __sata_set_spd_needed, initial limit=0xFFFFFFFF [ 21.746343][ T113] __sata_set_spd_needed, corrected limit=0x1 [ 21.752643][ T113] __sata_set_spd_needed, target=0x1 [ 21.758522][ T113] __sata_set_spd_needed, spd=0x0 [ 21.763602][ T113] __sata_set_spd_needed, final *scontrol=0x310 [ 21.769655][ T113] resume, do loop [ 22.004001][ T113] resume, after do loop [ 22.012645][ T113] debounce, SCR=0x123 [ 22.021803][ T113] debounce, SCR=0x123 [ 22.030784][ T113] debounce, SCR=0x123 [ 22.039763][ T113] debounce, SCR=0x123 [ 22.048725][ T113] debounce, SCR=0x123 [ 22.057686][ T113] debounce, SCR=0x123 [ 22.066647][ T113] debounce, SCR=0x123 [ 22.075608][ T113] debounce, SCR=0x123 [ 22.084568][ T113] debounce, SCR=0x123 [ 22.093529][ T113] debounce, SCR=0x123 [ 22.102511][ T113] debounce, SCR=0x123 [ 22.111494][ T113] debounce, SCR=0x123 [ 22.115437][ T113] resume, return at end of function [ 22.119327][ T113] hardreset, Offline=>Online [ 22.128892][ T113] hardreset, after check_ready [ 22.129113][ T113] ata2.00: SATA link up 3.0 Gbps (SStatus 123 SControl 300) [ 22.140984][ T113] ata2.01: hard resetting link [ 22.145653][ T113] hardreset, Online=>Offline [ 22.145691][ T113] sata_set_spd_needed, scontrol=0x300 [ 22.150161][ T113] __sata_set_spd_needed, initial limit=0xFFFFFFFF [ 22.155436][ T113] __sata_set_spd_needed, corrected limit=0x1 [ 22.161737][ T113] __sata_set_spd_needed, target=0x1 [ 22.167614][ T113] __sata_set_spd_needed, spd=0x0 [ 22.172695][ T113] __sata_set_spd_needed, final *scontrol=0x310 [ 22.177617][ T113] __sata_set_spd_needed, initial limit=0xFFFFFFFF [ 22.183657][ T113] __sata_set_spd_needed, corrected limit=0x1 [ 22.189979][ T113] __sata_set_spd_needed, target=0x1 [ 22.195857][ T113] __sata_set_spd_needed, spd=0x0 [ 22.200936][ T113] __sata_set_spd_needed, final *scontrol=0x310 [ 22.206971][ T113] resume, do loop [ 22.434000][ T113] resume, after do loop [ 22.442642][ T113] debounce, SCR=0x123 [ 22.451798][ T113] debounce, SCR=0x123 [ 22.460779][ T113] debounce, SCR=0x123 [ 22.469760][ T113] debounce, SCR=0x123 [ 22.478720][ T113] debounce, SCR=0x123 [ 22.487680][ T113] debounce, SCR=0x123 [ 22.496641][ T113] debounce, SCR=0x123 [ 22.505602][ T113] debounce, SCR=0x123 [ 22.514563][ T113] debounce, SCR=0x123 [ 22.523524][ T113] debounce, SCR=0x123 [ 22.532504][ T113] debounce, SCR=0x123 [ 22.541487][ T113] debounce, SCR=0x123 [ 22.545429][ T113] resume, return at end of function [ 22.549320][ T113] hardreset, Offline=>Online [ 22.558885][ T113] hardreset, after check_ready [ 22.559103][ T113] ata2.01: SATA link up 3.0 Gbps (SStatus 123 SControl 300) [ 22.570973][ T113] ata2.02: hard resetting link [ 22.575639][ T113] hardreset, Online=>Offline [ 22.575677][ T113] sata_set_spd_needed, scontrol=0x300 [ 22.580148][ T113] __sata_set_spd_needed, initial limit=0xFFFFFFFF [ 22.585423][ T113] __sata_set_spd_needed, corrected limit=0x1 [ 22.591724][ T113] __sata_set_spd_needed, target=0x1 [ 22.597602][ T113] __sata_set_spd_needed, spd=0x0 [ 22.602682][ T113] __sata_set_spd_needed, final *scontrol=0x310 [ 22.607608][ T113] __sata_set_spd_needed, initial limit=0xFFFFFFFF [ 22.613648][ T113] __sata_set_spd_needed, corrected limit=0x1 [ 22.619968][ T113] __sata_set_spd_needed, target=0x1 [ 22.625847][ T113] __sata_set_spd_needed, spd=0x0 [ 22.630927][ T113] __sata_set_spd_needed, final *scontrol=0x310 [ 22.636959][ T113] resume, do loop [ 22.864000][ T113] resume, after do loop [ 22.872642][ T113] debounce, SCR=0x0 [ 22.881798][ T113] debounce, SCR=0x0 [ 22.890603][ T113] debounce, SCR=0x0 [ 22.899408][ T113] debounce, SCR=0x0 [ 22.908194][ T113] debounce, SCR=0x0 [ 22.916979][ T113] debounce, SCR=0x0 [ 22.925766][ T113] debounce, SCR=0x0 [ 22.934553][ T113] debounce, SCR=0x0 [ 22.943339][ T113] debounce, SCR=0x0 [ 22.952146][ T113] debounce, SCR=0x0 [ 22.960953][ T113] debounce, SCR=0x0 [ 22.969761][ T113] debounce, SCR=0x0 [ 22.978547][ T113] debounce, SCR=0x0 [ 22.982295][ T113] resume, return at end of function [ 22.986033][ T113] hardreset, ata_phys_link_offline check failed [ 22.991325][ T113] ata2.02: SATA link down (SStatus 0 SControl 300) ... [ 25.191319][ T113] ata2.07: SATA link down (SStatus 0 SControl 300) [ 25.204010][ T113] ata2.00: ATA-6: WDC WD50ARC-5040-VOL#01, 0100 AX, max UDMA/133 [ 25.211624][ T113] ata2.00: 976773168 sectors, multi 0: LBA48 [ 25.217741][ T113] ata2.00: configured for UDMA/133 [ 25.222815][ T113] ata2.01: ATA-6: Areca Archive, 0100 AX, max UDMA/133 [ 25.229751][ T113] ata2.01: 23437498368 sectors, multi 0: LBA48 [ 25.236026][ T113] ata2.01: configured for UDMA/133 [ 25.241168][ T113] ata2: EH complete Marius Dinu