diff options
author | Marc Carino <marc.ceeeee@gmail.com> | 2013-08-25 02:22:51 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-08-25 09:39:12 -0400 |
commit | 87fb6c31b9ef9ccab9a822b01fc3911f026a29bb (patch) | |
tree | cde77c63326f50564a45afefeffd0003db8ee8c7 | |
parent | ed36911c747c18525691c0aa0fbe6b918c8eac19 (diff) |
libata: Add support for queued DSM TRIM
Some new SSDs support the queued version of the DSM TRIM command.
Let the driver use the new command if supported.
Signed-off-by: Marc Carino <marc.ceeeee@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
-rw-r--r-- | drivers/ata/libata-scsi.c | 25 | ||||
-rw-r--r-- | include/linux/libata.h | 7 |
2 files changed, 26 insertions, 6 deletions
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index f177ad6bfd09..58026106fcd9 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
@@ -3097,12 +3097,25 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc) | |||
3097 | buf = page_address(sg_page(scsi_sglist(scmd))); | 3097 | buf = page_address(sg_page(scsi_sglist(scmd))); |
3098 | size = ata_set_lba_range_entries(buf, 512, block, n_block); | 3098 | size = ata_set_lba_range_entries(buf, 512, block, n_block); |
3099 | 3099 | ||
3100 | tf->protocol = ATA_PROT_DMA; | 3100 | if (ata_ncq_enabled(dev) && ata_fpdma_dsm_supported(dev)) { |
3101 | tf->hob_feature = 0; | 3101 | /* Newer devices support queued TRIM commands */ |
3102 | tf->feature = ATA_DSM_TRIM; | 3102 | tf->protocol = ATA_PROT_NCQ; |
3103 | tf->hob_nsect = (size / 512) >> 8; | 3103 | tf->command = ATA_CMD_FPDMA_SEND; |
3104 | tf->nsect = size / 512; | 3104 | tf->hob_nsect = ATA_SUBCMD_FPDMA_SEND_DSM & 0x1f; |
3105 | tf->command = ATA_CMD_DSM; | 3105 | tf->nsect = qc->tag << 3; |
3106 | tf->hob_feature = (size / 512) >> 8; | ||
3107 | tf->feature = size / 512; | ||
3108 | |||
3109 | tf->auxiliary = 1; | ||
3110 | } else { | ||
3111 | tf->protocol = ATA_PROT_DMA; | ||
3112 | tf->hob_feature = 0; | ||
3113 | tf->feature = ATA_DSM_TRIM; | ||
3114 | tf->hob_nsect = (size / 512) >> 8; | ||
3115 | tf->nsect = size / 512; | ||
3116 | tf->command = ATA_CMD_DSM; | ||
3117 | } | ||
3118 | |||
3106 | tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE | ATA_TFLAG_LBA48 | | 3119 | tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE | ATA_TFLAG_LBA48 | |
3107 | ATA_TFLAG_WRITE; | 3120 | ATA_TFLAG_WRITE; |
3108 | 3121 | ||
diff --git a/include/linux/libata.h b/include/linux/libata.h index a988c2d7d0e8..0e23c26485f4 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
@@ -1606,6 +1606,13 @@ static inline int ata_ncq_enabled(struct ata_device *dev) | |||
1606 | ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ; | 1606 | ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ; |
1607 | } | 1607 | } |
1608 | 1608 | ||
1609 | static inline bool ata_fpdma_dsm_supported(struct ata_device *dev) | ||
1610 | { | ||
1611 | return (dev->flags & ATA_DFLAG_NCQ_SEND_RECV) && | ||
1612 | (dev->ncq_send_recv_cmds[ATA_LOG_NCQ_SEND_RECV_DSM_OFFSET] & | ||
1613 | ATA_LOG_NCQ_SEND_RECV_DSM_TRIM); | ||
1614 | } | ||
1615 | |||
1609 | static inline void ata_qc_set_polling(struct ata_queued_cmd *qc) | 1616 | static inline void ata_qc_set_polling(struct ata_queued_cmd *qc) |
1610 | { | 1617 | { |
1611 | qc->tf.ctl |= ATA_NIEN; | 1618 | qc->tf.ctl |= ATA_NIEN; |