diff options
-rw-r--r-- | drivers/ata/libata-scsi.c | 12 | ||||
-rw-r--r-- | include/linux/ata.h | 11 |
2 files changed, 20 insertions, 3 deletions
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 340a616d226b..e1e186b9dfcc 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
@@ -2115,8 +2115,10 @@ static unsigned int ata_scsiop_inq_b0(struct ata_scsi_args *args, u8 *rbuf) | |||
2115 | * that we support some form of unmap - in thise case via WRITE SAME | 2115 | * that we support some form of unmap - in thise case via WRITE SAME |
2116 | * with the unmap bit set. | 2116 | * with the unmap bit set. |
2117 | */ | 2117 | */ |
2118 | if (ata_id_has_trim(args->id)) | 2118 | if (ata_id_has_trim(args->id)) { |
2119 | put_unaligned_be32(65535 * 512 / 8, &rbuf[20]); | ||
2119 | put_unaligned_be32(1, &rbuf[28]); | 2120 | put_unaligned_be32(1, &rbuf[28]); |
2121 | } | ||
2120 | 2122 | ||
2121 | return 0; | 2123 | return 0; |
2122 | } | 2124 | } |
@@ -2411,8 +2413,12 @@ static unsigned int ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf) | |||
2411 | rbuf[14] = (lowest_aligned >> 8) & 0x3f; | 2413 | rbuf[14] = (lowest_aligned >> 8) & 0x3f; |
2412 | rbuf[15] = lowest_aligned; | 2414 | rbuf[15] = lowest_aligned; |
2413 | 2415 | ||
2414 | if (ata_id_has_trim(args->id)) | 2416 | if (ata_id_has_trim(args->id)) { |
2415 | rbuf[14] |= 0x80; | 2417 | rbuf[14] |= 0x80; /* TPE */ |
2418 | |||
2419 | if (ata_id_has_zero_after_trim(args->id)) | ||
2420 | rbuf[14] |= 0x40; /* TPRZ */ | ||
2421 | } | ||
2416 | } | 2422 | } |
2417 | 2423 | ||
2418 | return 0; | 2424 | return 0; |
diff --git a/include/linux/ata.h b/include/linux/ata.h index e2595e877e44..dfa2298bf488 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h | |||
@@ -75,6 +75,7 @@ enum { | |||
75 | ATA_ID_EIDE_DMA_TIME = 66, | 75 | ATA_ID_EIDE_DMA_TIME = 66, |
76 | ATA_ID_EIDE_PIO = 67, | 76 | ATA_ID_EIDE_PIO = 67, |
77 | ATA_ID_EIDE_PIO_IORDY = 68, | 77 | ATA_ID_EIDE_PIO_IORDY = 68, |
78 | ATA_ID_ADDITIONAL_SUPP = 69, | ||
78 | ATA_ID_QUEUE_DEPTH = 75, | 79 | ATA_ID_QUEUE_DEPTH = 75, |
79 | ATA_ID_MAJOR_VER = 80, | 80 | ATA_ID_MAJOR_VER = 80, |
80 | ATA_ID_COMMAND_SET_1 = 82, | 81 | ATA_ID_COMMAND_SET_1 = 82, |
@@ -816,6 +817,16 @@ static inline int ata_id_has_trim(const u16 *id) | |||
816 | return 0; | 817 | return 0; |
817 | } | 818 | } |
818 | 819 | ||
820 | static inline int ata_id_has_zero_after_trim(const u16 *id) | ||
821 | { | ||
822 | /* DSM supported, deterministic read, and read zero after trim set */ | ||
823 | if (ata_id_has_trim(id) && | ||
824 | (id[ATA_ID_ADDITIONAL_SUPP] & 0x4020) == 0x4020) | ||
825 | return 1; | ||
826 | |||
827 | return 0; | ||
828 | } | ||
829 | |||
819 | static inline int ata_id_current_chs_valid(const u16 *id) | 830 | static inline int ata_id_current_chs_valid(const u16 *id) |
820 | { | 831 | { |
821 | /* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command | 832 | /* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command |