Linux ATA/IDE development
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: Richard Weinberger <richard@nod.at>, linux-ide@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, upstream+linux@sigma-star.at,
	cassel@kernel.org
Subject: Re: [PATCH] [RFC] libata: Don't busy-wait for PIO data-in command completion
Date: Sat, 18 Jul 2026 11:52:22 +0900	[thread overview]
Message-ID: <49f67374-7c55-4aad-999d-3a74ffefe7ae@kernel.org> (raw)
In-Reply-To: <20260717090404.857078-1-richard@nod.at>

On 7/17/26 18:04, Richard Weinberger wrote:
> libata: Don't busy-wait for PIO data-in command completion
> 
> Unlike PIO data-out, the PIO data-in protocol raises no completion
> interrupt, the last interrupt announces the final data block, and once
> the host has drained it from the data register the ending status must
> be obtained synchronously.  ata_sff_hsm_move() does this by spinning
> in ata_wait_idle() for up to 10ms.
> 
> Usually this is not a big deal unless the device is slow.  In my case
> it's a CF card which keeps BSY asserted for multiple milliseconds(!)
> after the final data block.  Since the waiting happens in the
> interrupt handler, under the port lock with interrupts disabled, the
> CPU is hogged for milliseconds on every read command.
> 
> To improve the situation, bound the inline wait to ~100us.  If the
> device is still busy after that, mark the command ATA_TFLAG_POLLING,
> so the interrupt handler won't race for it, and obtain the ending
> status via ata_sff_pio_task(), which sleeps between status checks
> instead of spinning with the lock held.
> 
> Since ata_sff_pio_task() may now finish a data-in command, it must
> wait for both BSY and DRQ to clear at HSM_ST_LAST, matching what
> ata_wait_idle() enforced.
> 
> Signed-off-by: Richard Weinberger <richard@nod.at>

Looks OK to me, but the patch title should be:

ata: libata-sff: Don't busy-wait for PIO data-in command completion

I can change that when applying if you want.

-- 
Damien Le Moal
Western Digital Research

  reply	other threads:[~2026-07-18  2:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-17  9:04 [PATCH] [RFC] libata: Don't busy-wait for PIO data-in command completion Richard Weinberger
2026-07-18  2:52 ` Damien Le Moal [this message]
2026-07-18  6:08   ` Richard Weinberger

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=49f67374-7c55-4aad-999d-3a74ffefe7ae@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=cassel@kernel.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=richard@nod.at \
    --cc=upstream+linux@sigma-star.at \
    /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