linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers/ata: print trim features at device initialization
@ 2019-06-07  7:34 Konstantin Khlebnikov
  2019-06-07 16:58 ` Martin K. Petersen
  2019-06-08  8:25 ` Christoph Hellwig
  0 siblings, 2 replies; 10+ messages in thread
From: Konstantin Khlebnikov @ 2019-06-07  7:34 UTC (permalink / raw)
  To: Jens Axboe, linux-ide, linux-kernel; +Cc: Dmitry Monakhov

Print trim status once at ata device initialization in form:

ataX.YZ: trim: <supported|blacklisted>, queued: <no|yes|blacklisted>, zero_after_trim: <no|yes|maybe>

Full example:

  ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
  ata1.00: NCQ Send/Recv Log not supported
  ata1.00: ATA-9: SAMSUNG MZ7GE900HMHP-000DX, EXT03Y3Q, max UDMA/133
  ata1.00: 1758174768 sectors, multi 16: LBA48 NCQ (depth 32), AA
  ata1.00: trim: supported, queued: no, zero_after_trim: maybe
  ata1.00: NCQ Send/Recv Log not supported
  ata1.00: configured for UDMA/133
  scsi 0:0:0:0: Direct-Access     ATA      SAMSUNG MZ7GE900 3Y3Q PQ: 0 ANSI: 5
  sd 0:0:0:0: [sda] 1758174768 512-byte logical blocks: (900 GB/838 GiB)
  sd 0:0:0:0: Attached scsi generic sg0 type 0
  sd 0:0:0:0: [sda] Write Protect is off
  sd 0:0:0:0: [sda] Mode Sense: 00 3a 00 00
  sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
   sda: sda1 sda2
  sd 0:0:0:0: [sda] Attached SCSI disk

Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
---
 drivers/ata/libata-core.c |   28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index aaa57e0c809d..6ff33e79cfc2 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -2617,6 +2617,34 @@ int ata_dev_configure(struct ata_device *dev)
 			}
 		}
 
+		if (print_info && ata_id_has_trim(id)) {
+			const char *trim_status;
+			const char *trim_queued;
+			const char *trim_zero;
+
+			if (dev->horkage & ATA_HORKAGE_NOTRIM)
+				trim_status = "backlisted";
+			else
+				trim_status = "supported";
+
+			if (!ata_fpdma_dsm_supported(dev))
+				trim_queued = "no";
+			else if (dev->horkage & ATA_HORKAGE_NO_NCQ_TRIM)
+				trim_queued = "backlisted";
+			else
+				trim_queued = "yes";
+
+			if (!ata_id_has_zero_after_trim(id))
+				trim_zero = "no";
+			else if (dev->horkage & ATA_HORKAGE_ZERO_AFTER_TRIM)
+				trim_zero = "yes";
+			else
+				trim_zero = "maybe";
+
+			ata_dev_info(dev, "trim: %s, queued: %s, zero_after_trim: %s\n",
+				     trim_status, trim_queued, trim_zero);
+		}
+
 		/* Check and mark DevSlp capability. Get DevSlp timing variables
 		 * from SATA Settings page of Identify Device Data Log.
 		 */

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-06-14 14:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-07  7:34 [PATCH] drivers/ata: print trim features at device initialization Konstantin Khlebnikov
2019-06-07 16:58 ` Martin K. Petersen
2019-06-08  9:12   ` Konstantin Khlebnikov
2019-06-08 14:13     ` Konstantin Khlebnikov
2019-06-09 21:37       ` James Bottomley
2019-06-10  7:49         ` Konstantin Khlebnikov
2019-06-10 22:48           ` James Bottomley
2019-06-14 13:49             ` Konstantin Khlebnikov
2019-06-14 14:54               ` James Bottomley
2019-06-08  8:25 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).