]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
libata: add ATA_HORKAGE_NOTRIM
authorArne Fitzenreiter <arne_f@ipfire.org>
Wed, 15 Jul 2015 11:54:36 +0000 (13:54 +0200)
committerZefan Li <lizefan@huawei.com>
Mon, 21 Mar 2016 01:17:45 +0000 (09:17 +0800)
commit 71d126fd28de2d4d9b7b2088dbccd7ca62fad6e0 upstream.

Some devices lose data on TRIM whether queued or not.  This patch adds
a horkage to disable TRIM.

tj: Collapsed unnecessary if() nesting.

Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
Signed-off-by: Tejun Heo <tj@kernel.org>
[lizf: Backported to 3.4:
 - adjust context
 - drop changes to show_ata_dev_trim()]
Signed-off-by: Zefan Li <lizefan@huawei.com>
drivers/ata/libata-scsi.c
include/linux/libata.h

index 15863a4b6190056d84c694ca9e342138cce34295..94ccbc15f5fba70fe096a6647ca4c1f47e709102 100644 (file)
@@ -2461,7 +2461,8 @@ static unsigned int ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf)
                rbuf[14] = (lowest_aligned >> 8) & 0x3f;
                rbuf[15] = lowest_aligned;
 
-               if (ata_id_has_trim(args->id)) {
+               if (ata_id_has_trim(args->id) &&
+                   !(dev->horkage & ATA_HORKAGE_NOTRIM)) {
                        rbuf[14] |= 0x80; /* TPE */
 
                        if (ata_id_has_zero_after_trim(args->id))
index 35e7f71cd8a533246be2792ac95d072eba4e7607..9736dbe329e684ff2ba95f3ae34ba57f6e7c2cb6 100644 (file)
@@ -402,6 +402,8 @@ enum {
        ATA_HORKAGE_BROKEN_FPDMA_AA     = (1 << 15),    /* skip AA */
        ATA_HORKAGE_DUMP_ID     = (1 << 16),    /* dump IDENTIFY data */
        ATA_HORKAGE_MAX_SEC_LBA48 = (1 << 17),  /* Set max sects to 65535 */
+       ATA_HORKAGE_NOTRIM      = (1 << 24),    /* don't use TRIM */
+
 
         /* DMA mask for user DMA control: User visible values; DO NOT
            renumber */