Bug 222802 - [patch] QUIRK: KingDian S200 SSD which crashes when receiving a TRIM command
Summary: [patch] QUIRK: KingDian S200 SSD which crashes when receiving a TRIM command
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 10.3-STABLE
Hardware: Any Any
: --- Affects Only Me
Assignee: Oleksandr Tymoshenko
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2017-10-05 19:53 UTC by Bertrand Petit
Modified: 2019-08-08 17:56 UTC (History)
3 users (show)

See Also:


Attachments
KingDian S200 quirk preventing the kernel from issuing TRIM commands (1.17 KB, patch)
2017-10-05 19:53 UTC, Bertrand Petit
no flags Details | Diff
Same patch for 11-STABLE (1.33 KB, patch)
2017-11-08 11:10 UTC, Bertrand Petit
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Bertrand Petit 2017-10-05 19:53:11 UTC
Created attachment 186926 [details]
KingDian S200 quirk preventing the kernel from issuing TRIM commands

Inexpensive KingDian SATA SSDs are experiencing failures when issued a TRIM command. This can be observed when adding such a device as part of a zpool. Kernel reports a timeout on the TRIM command; then a timeout on the INQUIRY command; them the device reapears. It looks the SSD is crashing. The command is retried, the SSD crash again, etc.

The device identifies itself as

ada1: <KingDian S200 60GB P0921B> ACS-2 ATA SATA 3.x device
ada1: Serial Number <elided>
ada1: 300.000MB/s transfers (SATA 2.x, UDMA5, PIO 512bytes)
ada1: 57241MB (117231408 512 byte sectors)

I was unable to keep track of the error messages as the system is unresponsive while he tries to handle this situation which ultimately require powering the host off to recover control.

To resolve this I had to add a new kind of quirk to ata_da.c, I called it NO_TRIM. It simply clears the device's CAN_TRIM flag. When the quirk is in effect for that device it can then succesfully be used as part of a zpool.

The quirk is applied to devices matching the "KingDian S200 *" pattern, there is currently two models in that line only differing in capacity: 60 and 120 GB.
See http://web.archive.org/web/20171005194459/https://www.king-dian.com/product-category/sata/s200/

The attached diff was made against svn revision 323189.
Comment 1 Bertrand Petit 2017-11-08 11:10:58 UTC
Created attachment 187849 [details]
Same patch for 11-STABLE

Since the host this SSD is hooked on was upgraded to 11-STABLE, I merged the 10-STABLE fix to the 11-STABLE branch (svn 324612).
Comment 2 commit-hook freebsd_committer 2019-01-18 04:24:30 UTC
A commit references this bug:

Author: gonzo
Date: Fri Jan 18 04:23:52 UTC 2019
New revision: 343129
URL: https://svnweb.freebsd.org/changeset/base/343129

Log:
  [ata] Add workaround for KingDian S200 SSD crash on receiving TRIM command

  - Add ADA_Q_NO_TRIM quirk to be used with the device that falsely advertise TRIM support
  - Add ADA_Q_NO_TRIM entry for KingDian S200 SSD

  PR:		222802
  Submitted by:	Bertrand Petit <bsdpr@phoe.frmug.org>
  MFC after:	1 week

Changes:
  head/sys/cam/ata/ata_da.c
Comment 3 Oleksandr Tymoshenko freebsd_committer freebsd_triage 2019-01-18 04:40:22 UTC
Fix has been committed. Thanks for submitting the patch.
Comment 4 commit-hook freebsd_committer 2019-02-03 22:46:46 UTC
A commit references this bug:

Author: gonzo
Date: Sun Feb  3 22:45:50 UTC 2019
New revision: 343725
URL: https://svnweb.freebsd.org/changeset/base/343725

Log:
  MFC r343129:

  [ata] Add workaround for KingDian S200 SSD crash on receiving TRIM command

  - Add ADA_Q_NO_TRIM quirk to be used with the device that falsely advertise TRIM support
  - Add ADA_Q_NO_TRIM entry for KingDian S200 SSD

  PR:		222802
  Submitted by:	Bertrand Petit <bsdpr@phoe.frmug.org>

Changes:
_U  stable/12/
  stable/12/sys/cam/ata/ata_da.c
Comment 5 commit-hook freebsd_committer 2019-08-08 17:56:09 UTC
A commit references this bug:

Author: mav
Date: Thu Aug  8 17:55:18 UTC 2019
New revision: 350765
URL: https://svnweb.freebsd.org/changeset/base/350765

Log:
  MFC r343129 (by gonzo):
  [ata] Add workaround for KingDian S200 SSD crash on receiving TRIM command

  - Add ADA_Q_NO_TRIM quirk to be used with the device that falsely advertise TRIM support
  - Add ADA_Q_NO_TRIM entry for KingDian S200 SSD

  PR:             222802

Changes:
_U  stable/11/
  stable/11/sys/cam/ata/ata_da.c