Re: [PATCH] libata: add horkage for M88V29

Damien Le Moal
2022-06-23T09:55:51Z

On 6/23/22 18:32, Böszörményi Zoltán wrote:
> 2022. 06. 23. 10:46 keltezéssel, Damien Le Moal írta:
>> On 6/23/22 17:38, Böszörményi Zoltán wrote:
>>> 2022. 06. 23. 10:22 keltezéssel, Damien Le Moal írta:
>>>> On 6/23/22 16:47, Böszörményi Zoltán wrote:
>>>>> 2022. 02. 08. 9:07 keltezéssel, Damien Le Moal írta:
>>>>>> On 2/4/22 21:57, zboszor@pr.hu wrote:
>>>>>>> From: Zoltán Böszörményi <zboszor@gmail.com>
>>>>>>>
>>>>>>> This device is a CF card, or possibly an SSD in CF form factor.
>>>>>>> It supports NCQ and high speed DMA.
>>>>>>>
>>>>>>> While it also advertises TRIM support, I/O errors are reported
>>>>>>> when the discard mount option fstrim is used. TRIM also fails
>>>>>>> when disabling NCQ and not just as an NCQ command.
>>>>>>>
>>>>>>> TRIM must be disabled for this device.
>>>>>>>
>>>>>>> Signed-off-by: Zoltán Böszörményi <zboszor@gmail.com>
>>>>>>> ---
>>>>>>> drivers/ata/libata-core.c | 1 +
>>>>>>> 1 file changed, 1 insertion(+)
>>>>>>>
>>>>>>> diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
>>>>>>> index 67f88027680a..4a7f58fcc411 100644
>>>>>>> --- a/drivers/ata/libata-core.c
>>>>>>> +++ b/drivers/ata/libata-core.c
>>>>>>> @@ -4028,6 +4028,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
>>>>>>>
>>>>>>> /* devices that don't properly handle TRIM commands */
>>>>>>> { "SuperSSpeed S238*", NULL, ATA_HORKAGE_NOTRIM, },
>>>>>>> + { "M88V29*", NULL, ATA_HORKAGE_NOTRIM, },
>>>>>>>
>>>>>>> /*
>>>>>>> * As defined, the DRAT (Deterministic Read After Trim) and RZAT
>>>>>> Applied to for-5.17-fixes. Thanks !
>>>>> Thank you. However, I have second thoughts about this patch.
>>>>> The device advertises this:
>>>>>
>>>>> # hdparm -iI /dev/sda
>>>>> ...
>>>>>  Enabled Supported
>>>>>     *    Data Set Management TRIM supported (limit 1 block)
>>>>> ...
>>>>>
>>>>> but the I/O failures always reported higher number of blocks,
>>>>> IIRC the attempted number of block was 8 or so.
>>>>>
>>>>> Can the kernel limit or split TRIM commands according to the
>>>>> advertised limit? If not (or not yet) then the quirk is good for now.
>>>> Yes, the kernel does that. See the sysfs queue attributes
>>>> discard_max_bytes and discard_max_hw_bytes. What are the values for your
>>>> device ? I think that the "limit 1 block" indicated by hdparm is simply to
>>>> say that the DSM command (to trim the device) accept only at most a 1
>>>> block (512 B) list of sectors to trim. That is not the actual trim limit
>>>> for each sector range in that list.
>>> With the quirk in effect (TRIM disabled) I have these:
>>>
>>> [root@chef queue]# pwd
>>> /sys/block/sda/queue
>>> [root@chef queue]# cat discard_granularity
>>> 0
>>> [root@chef queue]# cat discard_max_bytes
>>> 0
>>> [root@chef queue]# cat discard_max_hw_bytes
>>> 0
>> Yes, expected. What are the values without the quirk applied ?
>
> I built 5.18.6 with removing the quirk.
>
> [root@chef queue]# pwd
> /sys/block/sda/queue/
> [root@chef queue]# cat discard_granularity
> 512
> [root@chef queue]# cat discard_max_bytes
> 2147450880
> [root@chef queue]# cat discard_max_hw_bytes
> 2147450880
> [root@chef queue]# cat max_discard_segments
> 1

All normal. This is 65535 sectors at most per trim range times 64 ranges
at most (64 range in at most 1 512B range list).
65535*512*64=2147450880

So if that is not working, then it means that DSM TRIM are not working
correctly on that device. Have you tried disabling NCQ trim ?
Use libata.force noncqtrim option.

>
>> With 5.19, you can use libata.force to disable/enable it. See
>> Documentation/admin-guide/kernel-parameters.txt for details.
>> You could try disabling DSM TRIM (queued trim) and see if the non-ncq trim
>> work.
>>
>

--
Damien Le Moal
Western Digital Research