Linux ATA/IDE development
 help / color / mirror / Atom feed
From: Damien Le Moal <damien.lemoal@opensource.wdc.com>
To: marius@psihoexpert.ro
Cc: linux-ide@vger.kernel.org
Subject: Re: Bug report for ahci-mvebu driver
Date: Tue, 24 Jan 2023 08:00:07 +0900	[thread overview]
Message-ID: <fa7f7eea-7b43-f2d7-18e5-f253ed316919@opensource.wdc.com> (raw)
In-Reply-To: <7fe0b96f30bf787d339ba656d5d2df01@psihoexpert.ro>


On 1/24/23 05:00, marius@psihoexpert.ro wrote:
> January 23, 2023 9:02 AM, "Damien Le Moal"
> <damien.lemoal@opensource.wdc.com> wrote:
> 
>> But I think I got an idea of what is wrong here. Can you try this
>> patch:
>> 
>> diff --git a/drivers/ata/libata-sata.c b/drivers/ata/libata-sata.c 
>> index 18ef14e749a0..cb12054c733f 100644 ---
>> a/drivers/ata/libata-sata.c +++ b/drivers/ata/libata-sata.c @@ -436,7
>> +436,8 @@ static int __sata_set_spd_needed(struct ata_link *link, u32
>> *scontrol) limit &= (1 << host_link->sata_spd) - 1;
>> 
>> if (limit == UINT_MAX) - target = 0; + /* Try highest gen 3 limit */ 
>> + target = 3; else target = fls(limit);
> 
> It doesn't work. I didn't really expect it to work, since manually
> forcing 3Gbps didn't work either - probably a hardware issue like you
> said.

Well, this one was not intended to limit the link speed to anything.
target == 0 written to scontrol means "no autonegociation speed limit",
while target == 3 means "limit autonegotiated speed to gen 3", which are
effectively equivalent since the max speed is gen 3 :) The point was to
force an scontrol write: in your case, spd is 0 and the default code with
target == 0 ends up with __sata_set_spd_needed returning false and so
sata_set_spd() doing nothing. Setting target to 3 forced trying to set the
speed to gen3. Wanted to see what that did.

Given that things are working by forcing 1.5gbps, and you endup with the
correct 3gbps link speed, it seems that this hardware does not like
negotiation starting from the highest speed. The SATA-IO specifications do
clearly mandate that adapters should allow for any initial speed, the
highest or the lowest and be ready for negotiation from any starting
combination of device and adapter speeds. But it seems that the designers
of this adapter and/or of the pmp box missed that chapter :)

> 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).

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)

If that does not work, we'll have to handle your case with a HORKAGE flag
for that adapter.

-- 
Damien Le Moal
Western Digital Research


  reply	other threads:[~2023-01-23 23:01 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-01 19:21 Bug report for ahci-mvebu driver Dinu Marius
2022-11-06  7:05 ` Damien Le Moal
2022-11-07  9:22   ` marius
2022-11-08  6:27     ` Damien Le Moal
2022-11-09 19:52       ` marius
2022-11-09 19:55       ` marius
2022-11-10  2:05         ` Damien Le Moal
2022-11-11 22:32           ` marius
2022-11-12  1:57             ` Damien Le Moal
2022-11-14 20:52               ` marius
2022-11-15  3:02                 ` Damien Le Moal
2022-11-15  7:28                   ` marius
2022-11-15  8:10                     ` Damien Le Moal
2022-11-18 18:24                       ` Dinu Marius
2022-11-24  2:40                         ` Damien Le Moal
2022-12-04  1:41                           ` marius
2022-12-04 10:22                             ` Pali Rohár
2022-12-04 21:14                               ` marius
2022-12-04 21:46                                 ` Pali Rohár
2022-12-05  2:02                                 ` Damien Le Moal
2022-12-06  6:08                             ` Damien Le Moal
2022-12-07 18:27                               ` marius
2022-12-07 21:54                                 ` Damien Le Moal
2022-12-07 22:51                                 ` Damien Le Moal
2022-12-08 18:06                                   ` marius
2022-12-09  0:34                                     ` Damien Le Moal
2022-12-09  2:58                                     ` Damien Le Moal
2022-12-09  7:31                                       ` marius
2022-12-09  9:28                                         ` Damien Le Moal
2022-12-09 18:30                                           ` marius
2023-01-14 18:01                                             ` marius
2023-01-15 23:37                                               ` Damien Le Moal
2023-01-17  8:26                                               ` Damien Le Moal
2023-01-18 19:43                                                 ` marius
2023-01-19  0:29                                                   ` Damien Le Moal
2023-01-19 18:46                                                     ` marius
2023-01-23  7:02                                                       ` Damien Le Moal
2023-01-23 20:00                                                         ` marius
2023-01-23 23:00                                                           ` Damien Le Moal [this message]
2023-01-24  8:04                                                             ` marius
2023-01-24  9:53                                                               ` Damien Le Moal
2023-01-24 17:02                                                                 ` marius
2023-01-27  5:13                                                                   ` Damien Le Moal
2023-01-27  6:28                                                                     ` Damien Le Moal
2023-01-28 17:08                                                                       ` marius
2023-01-29  2:23                                                                         ` Damien Le Moal
2023-01-29 10:24                                                                           ` marius
2023-01-30  1:16                                                                             ` Damien Le Moal
2023-01-30  2:38                                                                             ` Damien Le Moal
2023-01-30  7:23                                                                               ` marius
2023-01-30  7:37                                                                                 ` Damien Le Moal
2023-01-30 23:22                                                                                   ` Damien Le Moal
2023-01-31  7:20                                                                                     ` marius
2023-01-31  7:28                                                                                       ` Damien Le Moal
2023-02-07 18:40                                                                                         ` marius
2023-02-07 23:39                                                                                           ` Damien Le Moal
2023-02-08 12:17                                                                                             ` marius
2023-02-08 23:00                                                                                               ` Damien Le Moal
2023-02-12 13:14                                                                                                 ` marius
2023-02-12 23:11                                                                                                   ` Damien Le Moal
2023-01-24 17:06                                           ` Bug report for sata_via driver marius
2023-01-25  1:26                                             ` Damien Le Moal
2022-12-08 21:26                               ` Bug report for ahci-mvebu driver Pali Rohár
2022-12-09  1:54                                 ` Damien Le Moal
2022-11-26 14:26 ` Pali Rohár
2023-01-23  9:10 ` Hajo Noerenberg
2023-01-23 12:13   ` Damien Le Moal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fa7f7eea-7b43-f2d7-18e5-f253ed316919@opensource.wdc.com \
    --to=damien.lemoal@opensource.wdc.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=marius@psihoexpert.ro \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox