From: sashiko-bot@kernel.org
To: "Sasha Levin" <sashal@kernel.org>
Cc: linux-ide@vger.kernel.org, dlemoal@kernel.org, cassel@kernel.org
Subject: Re: [PATCH AUTOSEL 6.18-5.10] ata: libata-sff: don't busy-wait for PIO data-in command completion
Date: Mon, 19 Oct 2026 14:42:45 +0000 [thread overview]
Message-ID: <sashiko-outbox-177477@kernel.org> (raw)
In-Reply-To: <20261019135441.1420968-182-sashal@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] ata: libata-sff: race between ata_sff_hsm_move() and ata_sff_flush_pio_task()
--
commit ffe3d0726a492588a046ac4c8f5eafd55e0c371b
Author: Richard Weinberger <richard@nod.at>
ata: libata-sff: don't busy-wait for PIO data-in command completion
This commit bounds the inline busy-wait for PIO data-in completion in
ata_sff_hsm_move() to ~100us. If the device remains busy after draining the
final data block, it sets ATA_TFLAG_POLLING and queues ata_sff_pio_task() to
poll for completion in process context.
> diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
> index 1e2a2c33cdc80..416e1239ed56d 100644
> --- a/drivers/ata/libata-sff.c
> +++ b/drivers/ata/libata-sff.c
> @@ -1114,8 +1114,14 @@ int ata_sff_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,
>
> if (ap->hsm_task_state == HSM_ST_LAST &&
> (!(qc->tf.flags & ATA_TFLAG_WRITE))) {
> - /* all data read */
> - status = ata_wait_idle(ap);
> + status = ata_sff_busy_wait(ap,
> + ATA_BUSY | ATA_DRQ, 10);
> + if (status != 0xff &&
> + (status & (ATA_BUSY | ATA_DRQ))) {
> + qc->tf.flags |= ATA_TFLAG_POLLING;
> + ata_sff_queue_pio_task(link, 0);
> + return 0;
> + }
> goto fsm_start;
> }
> }
[Severity: High]
Can queuing ap->sff_pio_task from the interrupt handler here race with
ata_sff_flush_pio_task() during timeout recovery and trigger a BUG_ON()?
Previously, ap->sff_pio_task was only initially queued at command issue time
and re-queued by ata_sff_pio_task() itself, so cancel_delayed_work_sync() in
ata_sff_flush_pio_task() guaranteed the work item would not be re-armed
before ap->hsm_task_state was reset to HSM_ST_IDLE:
drivers/ata/libata-sff.c:ata_sff_flush_pio_task() {
...
cancel_delayed_work_sync(&ap->sff_pio_task);
spin_lock_irq(ap->lock);
ap->hsm_task_state = HSM_ST_IDLE;
spin_unlock_irq(ap->lock);
ap->sff_pio_task_link = NULL;
}
When an interrupt-driven PIO data-in command times out (via
ata_scsi_cmd_error_handler() -> ata_sff_flush_pio_task() or
ata_exec_internal_sg() -> ata_sff_flush_pio_task()), ap->sff_pio_task is not
yet pending, so cancel_delayed_work_sync() returns immediately.
If the final data block interrupt arrives on another CPU before
ata_sff_flush_pio_task() acquires ap->lock:
CPU0 CPU1 (IRQ)
ata_sff_flush_pio_task()
cancel_delayed_work_sync()
__ata_sff_port_intr()
ata_sff_hsm_move()
ata_pio_sectors(qc)
qc->tf.flags |= ATA_TFLAG_POLLING;
ata_sff_queue_pio_task(link, 0);
spin_lock_irq(ap->lock);
ap->hsm_task_state = HSM_ST_IDLE;
spin_unlock_irq(ap->lock);
ap->sff_pio_task_link = NULL;
When ata_sff_pio_task() then executes on ata_sff_wq, wouldn't it hit
BUG_ON(ap->sff_pio_task_link == NULL), or enter fsm_start with
ap->hsm_task_state == HSM_ST_IDLE while error handling is active?
[ ... ]
>
endasi
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261019135441.1420968-182-sashal@kernel.org?part=1
prev parent reply other threads:[~2026-10-19 14:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261019135441.1420968-1-sashal@kernel.org>
2026-10-19 13:45 ` [PATCH AUTOSEL 6.18-5.10] ata: ata_generic: Don't store pci_device_id Sasha Levin
2026-10-19 13:46 ` [PATCH AUTOSEL 6.18-6.12] ata: pata_ep93xx: fix PIO fallback when DMA init fails Sasha Levin
2026-10-19 13:47 ` [PATCH AUTOSEL 6.18-5.10] ata: libata-sff: don't busy-wait for PIO data-in command completion Sasha Levin
2026-10-19 14:42 ` sashiko-bot [this message]
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=sashiko-outbox-177477@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=cassel@kernel.org \
--cc=dlemoal@kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=sashal@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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