All of lore.kernel.org
 help / color / mirror / Atom feed
From: Igor Pylypiv <ipylypiv@google.com>
To: Damien Le Moal <dlemoal@kernel.org>
Cc: linux-ide@vger.kernel.org, Niklas Cassel <cassel@kernel.org>
Subject: Re: [PATCH 2/2] ata: libata-core: fix cancellation of a port deferred qc work
Date: Fri, 20 Feb 2026 09:33:09 -0800	[thread overview]
Message-ID: <aZia1dnJ9pVkf3pq@google.com> (raw)
In-Reply-To: <20260220050053.390135-3-dlemoal@kernel.org>

On Fri, Feb 20, 2026 at 02:00:53PM +0900, Damien Le Moal wrote:
> cancel_work_sync() is a sleeping function so it cannot be called with
> the spin lock of a port being held. Move the call to this function in
> ata_port_detach() before locking the port and add a call to
> ata_scsi_requeue_deferred_qc() to make sure there are no remaining
> deferred qc.
> 
> Fixes: 0ea84089dbf6 ("ata: libata-scsi: avoid Non-NCQ command starvation")
> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
> ---
>  drivers/ata/libata-core.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
> index beb6984b379a..54afa4df987e 100644
> --- a/drivers/ata/libata-core.c
> +++ b/drivers/ata/libata-core.c
> @@ -6254,9 +6254,18 @@ static void ata_port_detach(struct ata_port *ap)
>  	/* Wait for any ongoing EH */
>  	ata_port_wait_eh(ap);
>  
> +	/* Requeue any remaining deferred qc. */
> +	ata_scsi_requeue_deferred_qc(ap);
> +

ata_scsi_requeue_deferred_qc() requires the port lock to be held (function
has a lockdep assert).

>  	mutex_lock(&ap->scsi_scan_mutex);
> +
> +	/* Make sure the deferred qc work finished. */
> +	cancel_work_sync(&ap->deferred_qc_work);
> +
>  	spin_lock_irqsave(ap->lock, flags);
>  
> +	WARN_ON(ap->deferred_qc);
> +
>  	/* Remove scsi devices */
>  	ata_for_each_link(link, ap, HOST_FIRST) {
>  		ata_for_each_dev(dev, link, ALL) {
> @@ -6269,10 +6278,6 @@ static void ata_port_detach(struct ata_port *ap)
>  		}
>  	}
>  
> -	/* Make sure the deferred qc work finished. */
> -	cancel_work_sync(&ap->deferred_qc_work);
> -	WARN_ON(ap->deferred_qc);
> -
>  	/* Tell EH to disable all devices */
>  	ap->pflags |= ATA_PFLAG_UNLOADING;
>  	ata_port_schedule_eh(ap);
> -- 
> 2.53.0
> 
> 

  reply	other threads:[~2026-02-20 17:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-20  5:00 [PATCH 0/2] ATA port deferred qc fixes Damien Le Moal
2026-02-20  5:00 ` [PATCH 1/2] ata: libata-eh: correctly handle deferred qc timeouts Damien Le Moal
2026-02-20 16:37   ` Niklas Cassel
2026-02-20  5:00 ` [PATCH 2/2] ata: libata-core: fix cancellation of a port deferred qc work Damien Le Moal
2026-02-20 17:33   ` Igor Pylypiv [this message]
2026-02-20 21:48     ` Damien Le Moal

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=aZia1dnJ9pVkf3pq@google.com \
    --to=ipylypiv@google.com \
    --cc=cassel@kernel.org \
    --cc=dlemoal@kernel.org \
    --cc=linux-ide@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.