From: Niklas Cassel <cassel@kernel.org>
To: Damien Le Moal <dlemoal@kernel.org>
Cc: linux-ide@vger.kernel.org, Igor Pylypiv <ipylypiv@google.com>,
Xingui Yang <yangxingui@huawei.com>,
John Garry <john.g.garry@oracle.com>
Subject: Re: [PATCH v5 2/2] ata: libata-scsi: avoid Non-NCQ command starvation
Date: Sun, 4 Jan 2026 18:16:25 +0100 [thread overview]
Message-ID: <aVqgafdgx3qtfcHx@fedora> (raw)
In-Reply-To: <20260104082203.1212962-3-dlemoal@kernel.org>
On Sun, Jan 04, 2026 at 05:22:03PM +0900, Damien Le Moal wrote:
> @@ -1658,8 +1658,73 @@ static void ata_qc_done(struct ata_queued_cmd *qc)
> done(cmd);
> }
>
> +void ata_scsi_deferred_qc_work(struct work_struct *work)
> +{
> + struct ata_port *ap =
> + container_of(work, struct ata_port, deferred_qc_work);
> + struct ata_queued_cmd *qc;
> + unsigned long flags;
> +
> + spin_lock_irqsave(ap->lock, flags);
> +
> + /*
> + * If we still have a deferred qc and we are not in EH, issue it. In
> + * such case, we should not need any more deferring the qc, so warn if
> + * qc_defer() says otherwise.
> + */
> + qc = ap->deferred_qc;
> + if (qc && !ata_port_eh_scheduled(ap)) {
> + WARN_ON_ONCE(ap->ops->qc_defer(qc));
> + ap->deferred_qc = NULL;
> + ata_qc_issue(qc);
> + }
> +
> + spin_unlock_irqrestore(ap->lock, flags);
> +}
> +
> +void ata_scsi_requeue_deferred_qc(struct ata_port *ap)
> +{
> + struct ata_queued_cmd *qc = ap->deferred_qc;
> + struct scsi_cmnd *scmd;
Since ap->deferred_qc needs to be checked while holding the spinlock,
in order to synchronize with ata_scsi_deferred_qc_work(), please add a
lockdep_assert_held(ap->lock) here.
Yes, I know that you had multiple lockdep_assert_held() in V2.
But I think that a single lockdep_assert_held() in either
ata_scsi_requeue_deferred_qc() or ata_scsi_qc_complete() is warranted
(and yes, it is a no-op on production systems (where lockdep is disabled)).
Other than that, looks good to me, no need for a resend, you canfixup when
applying:
Reviewed-by: Niklas Cassel <cassel@kernel.org>
> +
> + /*
> + * If we have a deferred qc when a reset occurs or NCQ commands fail,
> + * do not try to be smart about what to do with this deferred command
> + * and simply retry it by completing it with DID_SOFT_ERROR.
> + */
> + if (!qc)
> + return;
> +
> + scmd = qc->scsicmd;
> + ap->deferred_qc = NULL;
> + ata_qc_free(qc);
> + scmd->result = (DID_SOFT_ERROR << 16);
> + scsi_done(scmd);
> +}
next prev parent reply other threads:[~2026-01-04 17:16 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-04 8:22 [PATCH v5 0/2] Prevent non-NCQ command starvation Damien Le Moal
2026-01-04 8:22 ` [PATCH v5 1/2] ata: libata-scsi: refactor ata_scsi_translate() Damien Le Moal
2026-01-04 17:05 ` Niklas Cassel
2026-01-05 10:30 ` John Garry
2026-01-05 23:26 ` Igor Pylypiv
2026-01-04 8:22 ` [PATCH v5 2/2] ata: libata-scsi: avoid Non-NCQ command starvation Damien Le Moal
2026-01-04 17:16 ` Niklas Cassel [this message]
2026-01-05 10:51 ` John Garry
2026-01-06 21:03 ` Igor Pylypiv
2026-01-14 3:16 ` yangxingui
2026-01-04 21:49 ` [PATCH v5 0/2] Prevent non-NCQ " Martin K. Petersen
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=aVqgafdgx3qtfcHx@fedora \
--to=cassel@kernel.org \
--cc=dlemoal@kernel.org \
--cc=ipylypiv@google.com \
--cc=john.g.garry@oracle.com \
--cc=linux-ide@vger.kernel.org \
--cc=yangxingui@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