Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 Aug 2019 17:55:17 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r350765 - stable/11/sys/cam/ata
Message-ID:  <201908081755.x78HtHVP091506@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Thu Aug  8 17:55:17 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

Modified:
  stable/11/sys/cam/ata/ata_da.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/cam/ata/ata_da.c
==============================================================================
--- stable/11/sys/cam/ata/ata_da.c	Thu Aug  8 17:48:07 2019	(r350764)
+++ stable/11/sys/cam/ata/ata_da.c	Thu Aug  8 17:55:17 2019	(r350765)
@@ -116,7 +116,8 @@ typedef enum {
 	ADA_Q_4K		= 0x01,
 	ADA_Q_NCQ_TRIM_BROKEN	= 0x02,
 	ADA_Q_LOG_BROKEN	= 0x04,
-	ADA_Q_SMR_DM		= 0x08
+	ADA_Q_SMR_DM		= 0x08,
+	ADA_Q_NO_TRIM		= 0x10
 } ada_quirks;
 
 #define ADA_Q_BIT_STRING	\
@@ -124,7 +125,8 @@ typedef enum {
 	"\0014K"		\
 	"\002NCQ_TRIM_BROKEN"	\
 	"\003LOG_BROKEN"	\
-	"\004SMR_DM"
+	"\004SMR_DM"		\
+	"\005NO_TRIM"
 
 typedef enum {
 	ADA_CCB_RAHEAD		= 0x01,
@@ -534,6 +536,14 @@ static struct ada_quirk_entry ada_quirk_table[] =
 	},
 	{
 		/*
+		 * KingDian S200 60GB P0921B
+		 * Trimming crash the SSD
+		 */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "*", "KingDian S200 *", "*" },
+		/*quirks*/ADA_Q_NO_TRIM
+	},
+	{
+		/*
 		 * Kingston E100 Series SSDs
 		 * 4k optimised & trim only works in 4k requests + 4k aligned
 		 */
@@ -1803,6 +1813,10 @@ adaregister(struct cam_periph *periph, void *arg)
 	softc->disk->d_flags = DISKFLAG_DIRECT_COMPLETION | DISKFLAG_CANZONE;
 	if (softc->flags & ADA_FLAG_CAN_FLUSHCACHE)
 		softc->disk->d_flags |= DISKFLAG_CANFLUSHCACHE;
+	/* Device lies about TRIM capability. */
+	if ((softc->quirks & ADA_Q_NO_TRIM) &&
+	    (softc->flags & ADA_FLAG_CAN_TRIM))
+		softc->flags &= ~ADA_FLAG_CAN_TRIM;
 	if (softc->flags & ADA_FLAG_CAN_TRIM) {
 		softc->disk->d_flags |= DISKFLAG_CANDELETE;
 		softc->disk->d_delmaxsize = softc->params.secsize *



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201908081755.x78HtHVP091506>