diff options
author | Martin K. Petersen <martin.petersen@oracle.com> | 2015-05-04 21:54:19 -0400 |
---|---|---|
committer | Sasha Levin <sasha.levin@oracle.com> | 2015-08-27 13:26:11 -0400 |
commit | 90eebd37c8175cb60c99b9cd1e3f5e61eb7b7468 (patch) | |
tree | 6b72bdab2cbe4458c09c1f037f57be10ced951c4 /drivers/ata | |
parent | f17728b7a635d5bea4ddd7836140fd7ca1b53638 (diff) | |
download | linux-stable-90eebd37c8175cb60c99b9cd1e3f5e61eb7b7468.tar.gz linux-stable-90eebd37c8175cb60c99b9cd1e3f5e61eb7b7468.tar.bz2 linux-stable-90eebd37c8175cb60c99b9cd1e3f5e61eb7b7468.zip |
libata: Expose TRIM capability in sysfs
[ Upstream commit f303074160d3401970ccae082014e1ee5a9a52c5 ]
Create a sysfs "trim" attribute for each ata_device that displays
whether DSM TRIM is "unsupported", "unqueued", "forced_unqueued"
(blacklisted) or "queued".
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Diffstat (limited to 'drivers/ata')
-rw-r--r-- | drivers/ata/libata-transport.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/ata/libata-transport.c b/drivers/ata/libata-transport.c index e37413228228..c660923c4b28 100644 --- a/drivers/ata/libata-transport.c +++ b/drivers/ata/libata-transport.c @@ -559,6 +559,27 @@ show_ata_dev_gscr(struct device *dev, static DEVICE_ATTR(gscr, S_IRUGO, show_ata_dev_gscr, NULL); +static ssize_t +show_ata_dev_trim(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct ata_device *ata_dev = transport_class_to_dev(dev); + unsigned char *mode; + + if (!ata_id_has_trim(ata_dev->id)) + mode = "unsupported"; + else if (ata_dev->horkage & ATA_HORKAGE_NO_NCQ_TRIM) + mode = "forced_unqueued"; + else if (ata_fpdma_dsm_supported(ata_dev)) + mode = "queued"; + else + mode = "unqueued"; + + return snprintf(buf, 20, "%s\n", mode); +} + +static DEVICE_ATTR(trim, S_IRUGO, show_ata_dev_trim, NULL); + static DECLARE_TRANSPORT_CLASS(ata_dev_class, "ata_device", NULL, NULL, NULL); @@ -732,6 +753,7 @@ struct scsi_transport_template *ata_attach_transport(void) SETUP_DEV_ATTRIBUTE(ering); SETUP_DEV_ATTRIBUTE(id); SETUP_DEV_ATTRIBUTE(gscr); + SETUP_DEV_ATTRIBUTE(trim); BUG_ON(count > ATA_DEV_ATTRS); i->dev_attrs[count] = NULL; |