From: yangxingui <yangxingui@huawei.com>
To: Damien Le Moal <dlemoal@kernel.org>, <cassel@kernel.org>
Cc: <linux-scsi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<liuyonglong@huawei.com>, <kangfenglong@huawei.com>,
<linux-ide@vger.kernel.org>
Subject: Re: [PATCH] ata: libata-sata: retry hardreset when device detected but PHY not established
Date: Mon, 27 Apr 2026 09:51:03 +0800 [thread overview]
Message-ID: <a118114e-9828-06d6-d38b-2b426c92bb14@huawei.com> (raw)
In-Reply-To: <e8d237bc-7191-4881-924b-86a34ff0f3b9@kernel.org>
On 2026/4/26 6:53, Damien Le Moal wrote:
> On 4/25/26 15:04, Xingui Yang wrote:
>> When sata_link_hardreset() detects that the link is offline, it currently
>> returns immediately without distinguishing the reason. According to SATA
>> specification, the SStatus register's det filed (bits 0-3) indicates:
>> - 0x0: No device detected, PHY not communicating
>> - 0x1: Device detected but PHY communication not established
>> - 0x3: Device detected and PHY communication established
>>
>> This patch helps improve device detection reliability and adds a check
>> when the link is offline but det filed shows 0x1, return -EAGAIN to
>> trigger retry, rather than giving up immediately.
>>
>> Signed-off-by: Xingui Yang <yangxingui@huawei.com>
>
> This is a pure ATA patch so please CC the linux-ide list, not the linux-scsi list.
Ok.
>
> Also, please check your mail setup: your email was in my Junk folder.
Well, patche was sent using the git send command.
>
>> ---
>> drivers/ata/libata-sata.c | 12 +++++++++++-
>> 1 file changed, 11 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/ata/libata-sata.c b/drivers/ata/libata-sata.c
>> index b9d635088f5f..e5bb92c38e38 100644
>> --- a/drivers/ata/libata-sata.c
>> +++ b/drivers/ata/libata-sata.c
>> @@ -667,8 +667,18 @@ int sata_link_hardreset(struct ata_link *link, const unsigned int *timing,
>> if (rc)
>> goto out;
>> /* if link is offline nothing more to do */
>> - if (ata_phys_link_offline(link))
>> + if (ata_phys_link_offline(link)) {
>
> This is preceeded by a call to sata_link_resume(), which calls
> sata_link_debounce() and that function makes sure that DET is stable. So if
> after that DET still shows that their is no PHY, there is likely a big problem
> with it and it is super slow to be established.
>
> In this case, I do not think that doing another hardreset is the right thing to
> do. Have you tried increasing the deadline for hardreset ? That deadline is used
> as the limit for the link debounce too.
>
> Do you have a specific controller/device where you see this issue ? What exactly
> is the hardware setup where you see this issue ?
Our customer imports and verifies a new disk, there is an occasional
failure in performing a hard reset on the disk and no exception log is
generated for resume and debounce.
[ 22.864418][ T1285] ahci 0000:76:03.0: Adding to iommu group 23
[ 22.870403][ T1285] ahci 0000:76:03.0: controller does not support
SXS, disabling CAP_SXS
[ 22.878655][ T1285] ahci 0000:76:03.0: SSS flag set, parallel bus
scan disabled
[ 22.885966][ T1285] ahci 0000:76:03.0: AHCI 0001.0300 32 slots 2
ports 6 Gbps 0x3 impl SATA mode
[ 22.894743][ T1285] ahci 0000:76:03.0: flags: 64bit ncq sntf stag pm
led clo only pmp fbs slum part ccc ems boh
[ 22.905277][ T1285] scsi host0: ahci
[ 22.909061][ T1285] scsi host1: ahci
[ 22.966463][ T1285] ata1: SATA max UDMA/133 abar m4096@0xa3010000
port 0xa3010100 irq 108
[ 22.974629][ T1285] ata2: SATA max UDMA/133 abar m4096@0xa3010000
port 0xa3010180 irq 109
[ 25.242373][ T1286] ata1: SATA link down (SStatus 1 SControl 300)
<==============
[ 25.659901][ T1288] ata2: SATA link down (SStatus 0 SControl 300)
>
>
>
>> + u32 sstatus;
>> +
>> + if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 &&
>> + (sstatus & 0xf) == 0x1) {
>> + ata_link_warn(link, "device detected but PHY not ready (SStatus %X), retrying\n",
>> + sstatus);
>> + rc = -EAGAIN;
>> + }
>> +
>> goto out;
>> + }
>>
>> /* Link is online. From this point, -ENODEV too is an error. */
>> if (online)
>
>
Thanks,
Xingui
next prev parent reply other threads:[~2026-04-27 1:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-25 6:04 [PATCH] ata: libata-sata: retry hardreset when device detected but PHY not established Xingui Yang
2026-04-25 22:53 ` Damien Le Moal
2026-04-27 1:51 ` yangxingui [this message]
2026-04-27 4:45 ` Damien Le Moal
2026-04-29 1:14 ` yangxingui
2026-04-27 13:17 ` Niklas Cassel
2026-04-29 1:06 ` yangxingui
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=a118114e-9828-06d6-d38b-2b426c92bb14@huawei.com \
--to=yangxingui@huawei.com \
--cc=cassel@kernel.org \
--cc=dlemoal@kernel.org \
--cc=kangfenglong@huawei.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=liuyonglong@huawei.com \
/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