From: Damien Le Moal <damien.lemoal@opensource.wdc.com>
To: John Garry <john.garry@huawei.com>,
linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org,
"Martin K . Petersen" <martin.petersen@oracle.com>
Subject: Re: [PATCH v2 2/2] ata: libata-sata: Fix device queue depth control
Date: Wed, 28 Sep 2022 16:00:25 +0900 [thread overview]
Message-ID: <6f08d6b9-63ba-10f6-2900-020db60a94be@opensource.wdc.com> (raw)
In-Reply-To: <66dbb3da-595e-c673-320d-00f139435192@huawei.com>
On 9/28/22 01:09, John Garry wrote:
> On 27/09/2022 16:03, Damien Le Moal wrote:
>> On 9/27/22 20:51, John Garry wrote:
>>> On 26/09/2022 00:08, Damien Le Moal wrote:
>>>> The function __ata_change_queue_depth() uses the helper
>>>> ata_scsi_find_dev() to get the ata_device structure of a scsi device and
>>>> set that device maximum queue depth. However, when the ata device is
>>>> managed by libsas, ata_scsi_find_dev() returns NULL, turning
>>>> __ata_change_queue_depth() into a nop, which prevents the user from
>>>> setting the maximum queue depth of ATA devices used with libsas based
>>>> HBAs.
>>>>
>>>> Fix this by renaming __ata_change_queue_depth() to
>>>> ata_change_queue_depth() and adding a pointer to the ata_device
>>>> structure of the target device as argument. This pointer is provided by
>>>> ata_scsi_change_queue_depth() using ata_scsi_find_dev() in the case of
>>>> a libata managed device and by sas_change_queue_depth() using
>>>> sas_to_ata_dev() in the case of a libsas managed ata device.
>>>>
>>>> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
>>>
>>> Tested-by: John Garry <john.garry@huawei.com>
>>>
>>> However - a big however - I will note that this following behaviour is
>>> strange for a SATA device for libsas:
>>>
>>> root@(none)$ echo 33 > 0:0:2:0/device/queue_depth
>>> root@(none)$ echo 33 > 0:0:2:0/device/queue_depth
>>> sh: echo: write error: Invalid argument
>>> root@(none)$
>>
>> Weird. I am not getting any error (pm80xx driver). The qd gets capped at
>> 32 as expected. Is it something that changes per libsas driver ?
>
> That is with my pm8001 card.
>
> What happens here is that the first store of 33 gets through to
> ata_change_queue_depth() as it does not exceed the SAS shost can_queue,
> which is >> 32, and then we cap this to 32 and store it in
> sdev->queue_depth. And then the 2nd store of 33 also gets through, but
> this following expression not evaluate true in ata_change_queue_depth():
>
> queue_depth < 1 || queue_depth == sdev->queue_depth
>
> So we don't return. However the following subsequent test does evaluate
> true in ata_change_queue_depth():
>
> if (sdev->queue_depth == queue_depth)
> return -EINVAL;
>
> And we error.
I dug further into this. For AHCI, I still get an error when trying to set
33. No capping and defaulting to 32. The reason is I believe that
sdev_store_queue_depth() has the check:
if (depth < 1 || depth > sdev->host->can_queue)
return -EINVAL;
as you mentioned. So all good.
So changing that last "if" in ata_change_queue_depth() to
if (sdev->queue_depth == queue_depth)
return sdev->queue_depth;
has no effect. The error remains.
Now, for a libsas SATA drive, if I add the above change, I do indeed get a
cap to 32 and the QD changes, no error. That is bothering me as that is
really inconsistent. Instead of suppressing the error, shouldn't we unify
AHCI and libsas behavior and error if the user is attempting to set a
value larger than what the *device* supports (the host can_queue was
checked already). In a nutshell, the difference comes form
sdev->host->can_queue being equal to the device max qd for AHCI but not
necessarily for libsas.
I am tempted to leave things as is for now (not changin gthe current weird
behavior) and cleaning that up during the next round. Thoughts ?
>
>>
>>> I also note that setting a value out of range is just rejected for a SAS
>>> device, and not capped to the max range (like it is for SATA).
>>
>> Not sure where that come from. A quick look does not reveal anything
>> obvious. Need to dig into that one.
>>>
>>> AHCI rejects out of range values it as it exceeds the shost can_queue in
>>> sdev_store_queue_depth().
>>
>> Indeed:
>>
>> echo 1 > /sys/block/sdk/device/queue_depth
>> echo 33 > /sys/block/sdk/device/queue_depth
>
> Hmmmm... why no error message? is the printk silenced?
>
>> cat /sys/block/sdk/device/queue_depth
>> 1
>>
>> But for the libsas SATA device:
>>
>> echo 1 > /sys/block/sdd/device/queue_depth
>> cat /sys/block/sdd/device/queue_depth
>> 1
>> echo 33 > /sys/block/sdd/device/queue_depth
>> cat /sys/block/sdd/device/queue_depth
>> 32
>>
>> As one would expect... > Need to dig into that one.
>>
>
> thanks,
> John
>
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2022-09-28 7:01 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-25 23:08 [PATCH v2 0/2] Fixes for ATA device queue depth control Damien Le Moal
2022-09-25 23:08 ` [PATCH v2 1/2] ata: libata-scsi: Fix initialization of device queue depth Damien Le Moal
2022-09-25 23:08 ` [PATCH v2 2/2] ata: libata-sata: Fix device queue depth control Damien Le Moal
2022-09-26 11:31 ` John Garry
2022-09-26 23:05 ` Damien Le Moal
2022-09-27 7:05 ` John Garry
2022-09-27 9:28 ` Damien Le Moal
2022-09-27 9:47 ` John Garry
2022-09-27 14:47 ` Damien Le Moal
2022-09-27 11:51 ` John Garry
2022-09-27 15:03 ` Damien Le Moal
2022-09-27 16:09 ` John Garry
2022-09-27 23:39 ` Damien Le Moal
2022-09-28 7:00 ` Damien Le Moal [this message]
2022-09-28 7:53 ` John Garry
2022-09-28 9:10 ` 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=6f08d6b9-63ba-10f6-2900-020db60a94be@opensource.wdc.com \
--to=damien.lemoal@opensource.wdc.com \
--cc=john.garry@huawei.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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