All of lore.kernel.org
 help / color / mirror / Atom feed
From: Niklas Cassel <cassel@kernel.org>
To: Igor Pylypiv <ipylypiv@google.com>
Cc: Damien Le Moal <dlemoal@kernel.org>,
	John Garry <john.garry@linux.dev>,
	Johannes Thumshirn <johannes.thumshirn@wdc.com>,
	Hannes Reinecke <hare@suse.de>,
	linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ata: libata-sata: allow re-enabling NCQ with the same queue_depth
Date: Thu, 29 Oct 2026 22:03:18 +0100	[thread overview]
Message-ID: <auO0lmGIi0AZUH40@ryzen> (raw)
In-Reply-To: <20261029184445.1615717-1-ipylypiv@google.com>

On Thu, Oct 29, 2026 at 11:44:45AM -0700, Igor Pylypiv wrote:
> When ata_eh_speed_down() disables NCQ due to excessive errors, it sets
> ATA_DFLAG_NCQ_OFF without changing sdev->queue_depth. Userspace can
> re-enable NCQ by writing a queue depth > 1 to the sysfs queue_depth
> attribute, which invokes ata_change_queue_depth() to clear
> ATA_DFLAG_NCQ_OFF.
> 
> However, ata_change_queue_depth() returns early if the requested
> queue_depth is equal to sdev->queue_depth before clearing
> ATA_DFLAG_NCQ_OFF. As a result, writing a different queue depth > 1
> re-enables NCQ, whereas writing the current sdev->queue_depth value
> leaves ATA_DFLAG_NCQ_OFF set.
> 
> Since ata_change_queue_depth() already checks whether queue_depth equals
> sdev->queue_depth before calling scsi_change_queue_depth(), remove the
> early check so that writing the current queue_depth > 1 clears
> ATA_DFLAG_NCQ_OFF and re-enables NCQ.
> 
> Fixes: 45623d33bfc0 ("ata: libata-sata: Improve ata_change_queue_depth()")
> Signed-off-by: Igor Pylypiv <ipylypiv@google.com>
> ---
> Commit 45623d33bfc0 ("ata: libata-sata: Improve ata_change_queue_depth()")
> didn't add the first queue depth check, but it changed the return value
> of the second check from -EINVAL to sdev->queue_depth so it seemed like
> a better candidate for the Fixes tag.
> 
>  drivers/ata/libata-sata.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/ata/libata-sata.c b/drivers/ata/libata-sata.c
> index 32fd0e804654..d917242ac136 100644
> --- a/drivers/ata/libata-sata.c
> +++ b/drivers/ata/libata-sata.c
> @@ -1287,7 +1287,7 @@ int ata_change_queue_depth(struct ata_port *ap, struct scsi_device *sdev,
>  	spin_lock_irqsave(ap->lock, flags);
>  
>  	dev = ata_scsi_find_dev(ap, sdev);
> -	if (!dev || queue_depth < 1 || queue_depth == sdev->queue_depth) {
> +	if (!dev || queue_depth < 1) {
>  		spin_unlock_irqrestore(ap->lock, flags);
>  		return sdev->queue_depth;
>  	}
> -- 
> 2.56.0.317.g454f8302e1-goog
> 

You could probably even change you commit message to say:
before 45623d33bfc0 ("ata: libata-sata: Improve ata_change_queue_depth()"),
ata_change_queue_depth() cleared ATA_DFLAG_NCQ_OFF unconditionally:
-       dev->flags &= ~ATA_DFLAG_NCQ_OFF;

So the subject of the patch could theoretically be:
ata: libata-sata: re-allow re-enabling NCQ with the same queue_depth

Perhaps that is too many re-..

Anyway, re-gardless:
Reviewed-by: Niklas Cassel <cassel@kernel.org>

      reply	other threads:[~2026-10-29 21:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29 18:44 [PATCH] ata: libata-sata: allow re-enabling NCQ with the same queue_depth Igor Pylypiv
2026-10-29 21:03 ` Niklas Cassel [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=auO0lmGIi0AZUH40@ryzen \
    --to=cassel@kernel.org \
    --cc=dlemoal@kernel.org \
    --cc=hare@suse.de \
    --cc=ipylypiv@google.com \
    --cc=johannes.thumshirn@wdc.com \
    --cc=john.garry@linux.dev \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@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.