git: 4eab6e77fc2a - stable/13 - ata_da: add quirk to disable NCQ TRIM for Samsung 860/870 SSDs

From: Andriy Gapon <avg_at_FreeBSD.org>
Date: Sat, 16 Mar 2024 15:16:38 UTC
The branch stable/13 has been updated by avg:

URL: https://cgit.FreeBSD.org/src/commit/?id=4eab6e77fc2a050e3da6bedcabb406f9596921d4

commit 4eab6e77fc2a050e3da6bedcabb406f9596921d4
Author:     Andriy Gapon <avg@FreeBSD.org>
AuthorDate: 2024-02-19 10:08:12 +0000
Commit:     Andriy Gapon <avg@FreeBSD.org>
CommitDate: 2024-03-16 15:13:42 +0000

    ata_da: add quirk to disable NCQ TRIM for Samsung 860/870 SSDs
    
    NCQ TRIM for Samsung 860/870 SSDs results in data corruption on systems
    with some SATA controllers.
    
    This can be easily reproduced using ZFS which uses TRIM and is able to
    detect block content changes.
    
    Linux bug report for this issue:
     https://bugzilla.kernel.org/show_bug.cgi?id=201693
    
    Since at present we can not limit a quirk based on the contorller / SIM,
    apply the quirk in all cases.
    
    Reviewed by:    imp
    
    (cherry picked from commit c01af41c3c8fdd570764ff9b6bfbad6ac9ca1664)
---
 sys/cam/ata/ata_da.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/sys/cam/ata/ata_da.c b/sys/cam/ata/ata_da.c
index 359ece18960e..c5c567645166 100644
--- a/sys/cam/ata/ata_da.c
+++ b/sys/cam/ata/ata_da.c
@@ -726,6 +726,22 @@ static struct ada_quirk_entry ada_quirk_table[] =
 		{ T_DIRECT, SIP_MEDIA_FIXED, "*", "Samsung SSD 850*", "*" },
 		/*quirks*/ADA_Q_4K | ADA_Q_NCQ_TRIM_BROKEN
 	},
+	{
+		/*
+		 * Samsung 860 SSDs
+		 * 4k optimised, NCQ TRIM broken (normal TRIM fine)
+		 */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "*", "Samsung SSD 860*", "*" },
+		/*quirks*/ADA_Q_4K | ADA_Q_NCQ_TRIM_BROKEN
+	},
+	{
+		/*
+		 * Samsung 870 SSDs
+		 * 4k optimised, NCQ TRIM broken (normal TRIM fine)
+		 */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "*", "Samsung SSD 870*", "*" },
+		/*quirks*/ADA_Q_4K | ADA_Q_NCQ_TRIM_BROKEN
+	},
 	{
 		/*
 		 * Samsung SM863 Series SSDs (MZ7KM*)