linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: John Garry <john.g.garry@oracle.com>,
	linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org,
	"Martin K . Petersen" <martin.petersen@oracle.com>
Cc: Jason Yan <yanaijie@huawei.com>
Subject: Re: [PATCH] ata: libata-sata: Simplify ata_change_queue_depth()
Date: Mon, 5 Jun 2023 10:25:02 +0900	[thread overview]
Message-ID: <c7507777-a4ac-55f5-698c-bff33ab7038a@kernel.org> (raw)
In-Reply-To: <cdc68c52-4320-1820-028d-c0af9dfe38c1@oracle.com>

On 6/2/23 17:02, John Garry wrote:
> On 01/06/2023 23:26, Damien Le Moal wrote:
>> Commit 141f3d6256e5 ("ata: libata-sata: Fix device queue depth control")
>> added a struct ata_device argument to ata_change_queue_depth() to
>> address problems with changing the queue depth of ATA devices managed
>> through libsas. This was due to problems with ata_scsi_find_dev() which
>> are now fixed with commit 7f875850f20a ("ata: libata-scsi: Use correct
>> device no in ata_find_dev()").
>>
>> Undo some of the changes of commit 141f3d6256e5: remove the added struct
>> ata_device aregument and use again ata_scsi_find_dev() to find the
>> target ATA device structure. While doing this, also make sure that
>> ata_scsi_find_dev() is called with ap->lock held, as it should.
>>
>> libsas and libata call sites of ata_change_queue_depth() are updated to
>> match the modified function arguments.
>>
>> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
> 
> Reviewed-by: John Garry <john.g.garry@oracle.com>
> 
> Thanks!
> 
> Just a reminder to all - I'm not asking anyone to fix it - we still have 
> that funky libsas behaviour for attempting to set queue depth at 33:
> 
> https://lore.kernel.org/linux-scsi/db84e61a-1069-982a-5659-297fcffc14f4@huawei.com/

I checked that again. For a libsas device, with this patch applied, we have:

# echo 1 > /sys/block/sdg/device/queue_depth
# cat /sys/block/sdg/device/queue_depth
1
# echo 33 > /sys/block/sdg/device/queue_depth; echo $?
0		<-- success !
# cat /sys/block/sdg/device/queue_depth
32		<-- qd was capped
# echo 33 > /sys/block/sdg/device/queue_depth; echo $?
1		<-- error !
# cat /sys/block/sdg/device/queue_depth
32		<-- no change

For a libata device, we have:

# echo 1 > /sys/block/sdc/device/queue_depth
# cat /sys/block/sdc/device/queue_depth
1
# echo 33 > /sys/block/sdc/device/queue_depth
# echo $?
1		<-- error !
# cat /sys/block/sdc/device/queue_depth
1		<-- no change

This is not consistent. The attempt to change from 1 to 33 with libsas should
error and not change anything.

That is because sdev->host->can_queue is larger than 32 for libsas devices as it
indicates the number of commands that the HBA can queue rather than the device
max queue depth.


>>   	/* NCQ enabled? */
>> -	spin_lock_irqsave(ap->lock, flags);
>>   	dev->flags &= ~ATA_DFLAG_NCQ_OFF;
>>   	if (queue_depth == 1 || !ata_ncq_enabled(dev)) {
> 
> Apart from this change, should we call ata_ncq_supported() here (instead 
> of ata_ncq_enabled())? ata_ncq_enabled() checks if ATA_DFLAG_NCQ_OFF is 
> not set, which we have already ensured.

Good catch. ata_ncq_enabled() calls ata_ncq_supported(), so this is not really a
bug, but it would be indeed cleaner (and less confusing) to call
ata_ncq_supported().

I am sending a patch to clean this up.

-- 
Damien Le Moal
Western Digital Research


      reply	other threads:[~2023-06-05  1:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-01 22:26 [PATCH] ata: libata-sata: Simplify ata_change_queue_depth() Damien Le Moal
2023-06-02  2:37 ` Jason Yan
2023-06-02  8:02 ` John Garry
2023-06-05  1:25   ` Damien Le Moal [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=c7507777-a4ac-55f5-698c-bff33ab7038a@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=john.g.garry@oracle.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=yanaijie@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;
as well as URLs for NNTP newsgroup(s).