From: Niklas Cassel <cassel@kernel.org>
To: Tommy Kelly <linux@tkel.ly>
Cc: dlemoal@kernel.org, linux-ide@vger.kernel.org,
Igor Pylypiv <ipylypiv@google.com>
Subject: Re: [PATCH v2 0/2] ATA port deferred qc fixes
Date: Fri, 17 Apr 2026 17:19:08 +0200 [thread overview]
Message-ID: <aeJPbLQ-WXCQMxC1@ryzen> (raw)
In-Reply-To: <f93c6f1a-ea5b-46cb-b9a5-cf88bac453cf@tkel.ly>
On Thu, Apr 16, 2026 at 09:38:21PM -0700, Tommy Kelly wrote:
> Hi Niklas and Damien,
>
> Thanks for the responses.
> I managed to build libata/for-next into rpms for my Fedora CoreOS system.
Thank you for testing!
I was worth a shot.
We will need to dig deeper then.
> I am new to this, but perhaps linux is misunderstanding the queue depth.
> There are "32 command slots" for the PMP, but each drive advertises "NCQ (depth 32)" as well, but perhaps there is only actually 32/5=6 slots per drive.
> Not sure if that matters wrt the bug.
For a PMP with FBS, the PMP can communicate with multiple drives simultaneously.
Thus, the commands in the 32 command slots can be for different drives.
There is no fixed limit on how much each one drive can occupy. E.g. one drive
use all 32 if there is only I/O going on to a single drive.
For a PMP without FBS (only CBS), the PMP can only communicate with one drive at
a time. Thus, the commands in the 32 command slots will belong to the same
drive.
I think the problem is that the patch that implements the deferred QC logic
forgot to think about port multipliers.
A PMP with FBS can mix NCQ and non-NCQ commands (to different drives of course).
The current deferred QC design stores a single deferred QC in struct ata_port...
This must instead be stored in struct ata_device, or struct ata_link, or have
an array of deferred QCs in struct ata_port.
This means that, for PMPs with FBS, if we defer a QC to one drive (because you
cannot mix NCQ and non-NCQ commands - within a single drive), we will currently
defer commands to all other drives on the PMP.
This is obviously very bad for PMPs with FBS, as commands to other drives will
be deferred for no reason (it will kill performance).
Your problem however, is with PMPs without FBS (only CBS).
Spawned process 'ata_id --export /dev/sdb' [635] is taking longer than 59s to complete.
https://github.com/systemd/systemd/blob/main/src/udev/ata_id/ata_id.c#L93-L115
ata_id seems to send a ATA PASSTHROUGH (12) non-NCQ command.
Presumably some command is already running on sda.
https://github.com/torvalds/linux/blob/v7.0/drivers/ata/libahci.c#L1682-L1685
https://github.com/torvalds/linux/blob/v7.0/drivers/ata/libata-pmp.c#L115-L120
For CBS, it appears that sata_pmp_qc_defer_cmd_switch() will set:
ap->excl_link and will set qc->flags |= ATA_QCFLAG_CLEAR_EXCL.
and then:
__ata_qc_complete() will clear ap->excl_link, but only if qc->flags
ATA_QCFLAG_CLEAR_EXCL was set.
Once a command is completed, ata_scsi_schedule_deferred_qc() will either:
call ata_scsi_requeue_deferred_qc() which will requeue it in SCSI ML, or:
will call ap->ops->qc_defer(qc) and schedule the deferred QC worker.
Considering that we don't see any actual timeouts from SCSI or ATA in your
dmesg, my best guess is that the command is infinitely getting requeued in
SCSI ML. (Possibly by ata_scsi_requeue_deferred_qc().)
I don't really see it. I guess someone with a PMP would need to debug.
(Should be trivial to force disable FBS for a PMP that supports FBS.)
One behavior change that I see from before with a PMP CBS:
if (ap->deferred_ap) is set, we will now return SCSI_MLQUEUE_DEVICE_BUSY,
while before, sata_pmp_qc_defer_cmd_switch() would cause us to return
either SCSI_MLQUEUE_HOST_BUSY - if there was a command excuting on another
drive, or SCSI_MLQUEUE_DEVICE_BUSY - if the same drive was busy executing
NCQ commands.
Kind regards,
Niklas
next prev parent reply other threads:[~2026-04-17 15:19 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-20 22:14 [PATCH v2 0/2] ATA port deferred qc fixes Damien Le Moal
2026-02-20 22:14 ` [PATCH v2 1/2] ata: libata-eh: correctly handle deferred qc timeouts Damien Le Moal
2026-02-23 12:09 ` Hannes Reinecke
2026-02-23 17:48 ` Igor Pylypiv
2026-03-05 17:59 ` Guenter Roeck
2026-03-05 23:27 ` Niklas Cassel
2026-03-06 0:11 ` Damien Le Moal
2026-03-06 0:59 ` Damien Le Moal
2026-03-06 8:23 ` Niklas Cassel
2026-03-06 0:14 ` Guenter Roeck
2026-03-06 0:21 ` Damien Le Moal
2026-03-06 0:41 ` Guenter Roeck
2026-03-05 23:59 ` Damien Le Moal
2026-03-06 0:32 ` Guenter Roeck
2026-03-06 0:50 ` Damien Le Moal
2026-03-06 1:31 ` Guenter Roeck
2026-03-06 8:24 ` Niklas Cassel
2026-02-20 22:14 ` [PATCH v2 2/2] ata: libata-core: fix cancellation of a port deferred qc work Damien Le Moal
2026-02-23 12:09 ` Hannes Reinecke
2026-02-23 17:49 ` Igor Pylypiv
2026-02-24 0:39 ` [PATCH v2 0/2] ATA port deferred qc fixes Damien Le Moal
2026-04-02 9:22 ` Tommy Kelly
2026-04-05 6:45 ` Damien Le Moal
2026-04-12 18:22 ` Niklas Cassel
2026-04-17 4:38 ` Tommy Kelly
2026-04-17 15:19 ` Niklas Cassel [this message]
2026-04-22 15:18 ` Niklas Cassel
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=aeJPbLQ-WXCQMxC1@ryzen \
--to=cassel@kernel.org \
--cc=dlemoal@kernel.org \
--cc=ipylypiv@google.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux@tkel.ly \
/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