Package: hdparm
Version: 9.43-1
Severity: wishlist
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu saucy ubuntu-patch

Hi guys,

In Ubuntu, we've applied a patch to the hdparm package taken from the
upstream bug tracker (contributed by David Woodhouse) to enable hdparm -I to
output information about the new DevSleep feature.

  http://sourceforge.net/p/hdparm/patches/35/

The changelog entry for this upload to Ubuntu is:

  * hdparm.c, identify.c, sgio.h: import patch from
    http://sourceforge.net/p/hdparm/patches/35/ to add support to 'hdparm -I'
    for reporting DevSleep information.  LP: #1031173.

You may find this feature worthwhile to enable in Debian as well, or perhaps
you would prefer to wait for the change to be included in an upstream
release.

Thanks for considering the patch.
-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
Ubuntu Developer                                    http://www.debian.org/
slanga...@ubuntu.com                                     vor...@debian.org
=== modified file 'hdparm.c'
--- hdparm.c	2012-12-03 17:00:23 +0000
+++ hdparm.c	2013-04-26 18:15:06 +0000
@@ -887,6 +887,28 @@
 		__le16_to_cpus(&id[i]);
 }
 
+static int get_id_log_page_data (int fd, __u8 pagenr, __u8 *buf)
+{
+	struct hdio_taskfile *r;
+	int err = 0;
+
+	r = malloc(sizeof(struct hdio_taskfile) + 512);
+	if (!r) {
+		err = errno;
+		perror("malloc()");
+		return err;
+	}
+
+	init_hdio_taskfile(r, ATA_OP_READ_LOG_EXT, RW_READ, LBA48_FORCE, 0x30 + (pagenr << 8), 1, 512);
+	if (do_taskfile_cmd(fd, r, timeout_15secs)) {
+		err = errno;
+	} else {
+		memcpy(buf, r->data, 512);
+	}
+	free(r);
+	return err;
+}
+
 static void confirm_i_know_what_i_am_doing (const char *opt, const char *explanation)
 {
 	if (!i_know_what_i_am_doing) {
@@ -2175,6 +2197,26 @@
 				dump_sectors(id, 1);
 			else
 				identify((void *)id);
+
+			/* Print DEVSLP information */
+			if (id[78] & 0x0100) {
+				__u8 buf[512];
+				int deto = 0;
+				int mdat = 0;
+
+				memset(buf, 0, 512);
+				if (!get_id_log_page_data(fd, 8, buf) &&
+				    (buf[0x37] & 0x80)) {
+					mdat = buf[0x30] & 0x1f;
+					deto = buf[0x31];
+				}
+				printf("Device Sleep:\n");
+				printf("\tDEVSLP Exit Timeout (DETO): %d ms (%s)\n",
+				       deto?deto:20, deto?"drive":"default");
+
+				printf("\tMinimum DEVSLP Assertion Time (MDAT): %d ms (%s)\n",
+				       mdat?mdat:10, deto?"drive":"default");
+			}
 		}
 	}
 	if (get_lookahead) {

=== modified file 'identify.c'
--- identify.c	2012-10-25 03:08:04 +0000
+++ identify.c	2013-04-26 18:15:06 +0000
@@ -421,9 +421,9 @@
 	"Disable Data Transfer After Error Detection"	/* word 119 bit  0 (ref: 2014DT)*/
 };
 static const char *cap_sata0_str[16] = { 
-	"unknown 76[15]",				/* word 76 bit 15 */
-	"unknown 76[14]",				/* word 76 bit 14 */
-	"unknown 76[13]",				/* word 76 bit 13 */
+	"READ_LOG_DMA_EXT equivalent to READ_LOG_EXT",	/* word 76 bit 15 */
+	"Device automatic Partial to Slumber transitions",/* word 76 bit 14 */
+	"Host automatic Partial to Slumber transitions",/* word 76 bit 13 */
 	"NCQ priority information",			/* word 76 bit 12 */
 	"Idle-Unload when NCQ is active",		/* word 76 bit 11 */
 	"Phy event counters",				/* word 76 bit 10 */
@@ -446,7 +446,7 @@
 	"unknown 78[11]",				/* word 78 bit 11 */
 	"unknown 78[10]",				/* word 78 bit 10 */
 	"unknown 78[9]",				/* word 78 bit  9 */
-	"unknown 78[8]",				/* word 78 bit  8 */
+	"Device Sleep (DEVSLP)",			/* word 78 bit  8 */
 	"unknown 78[7]",				/* word 78 bit  7 */
 	"Software settings preservation",		/* word 78 bit  6 */
 	"Asynchronous notification (eg. media change)",	/* word 78 bit  5 */

=== modified file 'sgio.h'
--- sgio.h	2012-10-09 11:19:21 +0000
+++ sgio.h	2013-04-26 18:15:06 +0000
@@ -10,6 +10,7 @@
 	ATA_OP_READ_LONG_ONCE		= 0x23,
 	ATA_OP_READ_PIO_EXT		= 0x24,
 	ATA_OP_READ_DMA_EXT		= 0x25,
+	ATA_OP_READ_LOG_EXT		= 0x2f,
 	ATA_OP_READ_FPDMA		= 0x60,	// NCQ
 	ATA_OP_WRITE_PIO		= 0x30,
 	ATA_OP_WRITE_LONG		= 0x32,

Reply via email to