All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libata: replace sata_settings with devslp_timing
@ 2012-12-17 15:18 Shane Huang
  2012-12-26  2:29 ` Huang, Shane
  2012-12-26 10:41 ` Sergei Shtylyov
  0 siblings, 2 replies; 5+ messages in thread
From: Shane Huang @ 2012-12-17 15:18 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: linux-ide, Shane Huang, stable

NCQ capability was used to check availability of SATA Settings page
from Identify Device Data Log, which contains DevSlp timing variables.
It does not work on some HDDs and leads to error messages.

IDENTIFY word 78 bit 5(Hardware Feature Control) can't work either
because it is only the sufficient condition of Identify Device data
log, not the necessary condition.

This patch replaced ata_device->sata_settings with ->devslp_timing
to only save DevSlp timing variables(8 bytes), instead of the whole
SATA Settings page(512 bytes).

Reported-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Shane Huang <shane.huang@amd.com>
Cc: stable@kernel.org
---
 drivers/ata/libahci.c     |    6 +++---
 drivers/ata/libata-core.c |   22 +++++++++++++---------
 include/linux/ata.h       |    8 +++++---
 include/linux/libata.h    |    4 ++--
 4 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index 320712a..6cd7805 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -1951,13 +1951,13 @@ static void ahci_set_aggressive_devslp(struct ata_port *ap, bool sleep)
 	/* Use the nominal value 10 ms if the read MDAT is zero,
 	 * the nominal value of DETO is 20 ms.
 	 */
-	if (dev->sata_settings[ATA_LOG_DEVSLP_VALID] &
+	if (dev->devslp_timing[ATA_LOG_DEVSLP_VALID] &
 	    ATA_LOG_DEVSLP_VALID_MASK) {
-		mdat = dev->sata_settings[ATA_LOG_DEVSLP_MDAT] &
+		mdat = dev->devslp_timing[ATA_LOG_DEVSLP_MDAT] &
 		       ATA_LOG_DEVSLP_MDAT_MASK;
 		if (!mdat)
 			mdat = 10;
-		deto = dev->sata_settings[ATA_LOG_DEVSLP_DETO];
+		deto = dev->devslp_timing[ATA_LOG_DEVSLP_DETO];
 		if (!deto)
 			deto = 20;
 	} else {
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 9e8b99a..46cd3f4 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -2325,24 +2325,28 @@ int ata_dev_configure(struct ata_device *dev)
 			}
 		}
 
-		/* check and mark DevSlp capability */
-		if (ata_id_has_devslp(dev->id))
-			dev->flags |= ATA_DFLAG_DEVSLP;
-
-		/* Obtain SATA Settings page from Identify Device Data Log,
-		 * which contains DevSlp timing variables etc.
-		 * Exclude old devices with ata_id_has_ncq()
+		/* Check and mark DevSlp capability. Get DevSlp timing variables
+		 * from SATA Settings page of Identify Device Data Log.
 		 */
-		if (ata_id_has_ncq(dev->id)) {
+		if (ata_id_has_devslp(dev->id)) {
+			u8 sata_setting[ATA_SECT_SIZE];
+			int i, j;
+
+			dev->flags |= ATA_DFLAG_DEVSLP;
 			err_mask = ata_read_log_page(dev,
 						     ATA_LOG_SATA_ID_DEV_DATA,
 						     ATA_LOG_SATA_SETTINGS,
-						     dev->sata_settings,
+						     sata_setting,
 						     1);
 			if (err_mask)
 				ata_dev_dbg(dev,
 					    "failed to get Identify Device Data, Emask 0x%x\n",
 					    err_mask);
+			else
+				for (i = 0; i < ATA_LOG_DEVSLP_SIZE; i++) {
+					j = ATA_LOG_DEVSLP_OFFSET + i;
+					dev->devslp_timing[i] = sata_setting[j];
+				}
 		}
 
 		dev->cdb_len = 16;
diff --git a/include/linux/ata.h b/include/linux/ata.h
index 408da95..8f7a3d6 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -297,10 +297,12 @@ enum {
 	ATA_LOG_SATA_NCQ	= 0x10,
 	ATA_LOG_SATA_ID_DEV_DATA  = 0x30,
 	ATA_LOG_SATA_SETTINGS	  = 0x08,
-	ATA_LOG_DEVSLP_MDAT	  = 0x30,
+	ATA_LOG_DEVSLP_OFFSET	  = 0x30,
+	ATA_LOG_DEVSLP_SIZE	  = 0x08,
+	ATA_LOG_DEVSLP_MDAT	  = 0x00,
 	ATA_LOG_DEVSLP_MDAT_MASK  = 0x1F,
-	ATA_LOG_DEVSLP_DETO	  = 0x31,
-	ATA_LOG_DEVSLP_VALID	  = 0x37,
+	ATA_LOG_DEVSLP_DETO	  = 0x01,
+	ATA_LOG_DEVSLP_VALID	  = 0x07,
 	ATA_LOG_DEVSLP_VALID_MASK = 0x80,
 
 	/* READ/WRITE LONG (obsolete) */
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 83ba0ab..649e5f8 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -652,8 +652,8 @@ struct ata_device {
 		u32		gscr[SATA_PMP_GSCR_DWORDS]; /* PMP GSCR block */
 	};
 
-	/* Identify Device Data Log (30h), SATA Settings (page 08h) */
-	u8			sata_settings[ATA_SECT_SIZE];
+	/* DEVSLP Timing Variables from Identify Device Data Log */
+	u8			devslp_timing[ATA_LOG_DEVSLP_SIZE];
 
 	/* error history */
 	int			spdn_cnt;
-- 
1.7.10.4



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

* RE: [PATCH] libata: replace sata_settings with devslp_timing
  2012-12-17 15:18 [PATCH] libata: replace sata_settings with devslp_timing Shane Huang
@ 2012-12-26  2:29 ` Huang, Shane
  2012-12-26 10:41 ` Sergei Shtylyov
  1 sibling, 0 replies; 5+ messages in thread
From: Huang, Shane @ 2012-12-26  2:29 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: linux-ide, bp, kou1.ono, Tom Rini, jlee, Huang, Shane

Jeff,

> NCQ capability was used to check availability of SATA Settings page
> from Identify Device Data Log, which contains DevSlp timing variables.
> It does not work on some HDDs and leads to error messages.
> 
> IDENTIFY word 78 bit 5(Hardware Feature Control) can't work either
> because it is only the sufficient condition of Identify Device data
> log, not the necessary condition.
> 
> This patch replaced ata_device->sata_settings with ->devslp_timing
> to only save DevSlp timing variables(8 bytes), instead of the whole
> SATA Settings page(512 bytes).
> 
> Reported-by: Borislav Petkov <bp@alien8.de>
> Signed-off-by: Shane Huang <shane.huang@amd.com>
> Cc: stable@kernel.org

Happy holidays!

Do you have comments to this patch? It also fixed bugzilla #51881
reported and verified by Kouichi.

Please also help to apply it into the stable tree.

Thanks,
Shane



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

* Re: [PATCH] libata: replace sata_settings with devslp_timing
  2012-12-17 15:18 [PATCH] libata: replace sata_settings with devslp_timing Shane Huang
  2012-12-26  2:29 ` Huang, Shane
@ 2012-12-26 10:41 ` Sergei Shtylyov
  2012-12-27  2:01   ` Huang, Shane
  1 sibling, 1 reply; 5+ messages in thread
From: Sergei Shtylyov @ 2012-12-26 10:41 UTC (permalink / raw)
  To: Shane Huang; +Cc: Jeff Garzik, linux-ide, stable

Hello.

On 17-12-2012 19:18, Shane Huang wrote:

> NCQ capability was used to check availability of SATA Settings page
> from Identify Device Data Log, which contains DevSlp timing variables.
> It does not work on some HDDs and leads to error messages.

> IDENTIFY word 78 bit 5(Hardware Feature Control) can't work either
> because it is only the sufficient condition of Identify Device data
> log, not the necessary condition.

> This patch replaced ata_device->sata_settings with ->devslp_timing
> to only save DevSlp timing variables(8 bytes), instead of the whole
> SATA Settings page(512 bytes).

> Reported-by: Borislav Petkov <bp@alien8.de>
> Signed-off-by: Shane Huang <shane.huang@amd.com>
> Cc: stable@kernel.org

    The new address is stable@vger.kernel.org. The old address doesn't work 
anymore.

MBR, Sergei


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

* RE: [PATCH] libata: replace sata_settings with devslp_timing
  2012-12-26 10:41 ` Sergei Shtylyov
@ 2012-12-27  2:01   ` Huang, Shane
  0 siblings, 0 replies; 5+ messages in thread
From: Huang, Shane @ 2012-12-27  2:01 UTC (permalink / raw)
  To: Sergei Shtylyov, Jeff Garzik; +Cc: linux-ide, Huang, Shane

Sergei,

> The new address is stable@vger.kernel.org. The old address doesn't
> work anymore.

Understood, thanks. I expect Jeff's help and won't resend the patch.

Regards,
Shane


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

* Re: [PATCH] libata: replace sata_settings with devslp_timing
@ 2013-01-04 16:53 Sedat Dilek
  0 siblings, 0 replies; 5+ messages in thread
From: Sedat Dilek @ 2013-01-04 16:53 UTC (permalink / raw)
  To: Shane Huang; +Cc: Jeff Garzik, Aaron Lu, Borislav Petkov, linux-ide, LKML

Feel free to add "Reported-by" (against v3.8-rcX and even a report
existed by Boris) and "Tested-by".
For more details look into my "monlogue" thread in [1].

- Sedat -

[1] http://marc.info/?t=135731410800001&r=1&w=2

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

end of thread, other threads:[~2013-01-04 16:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-17 15:18 [PATCH] libata: replace sata_settings with devslp_timing Shane Huang
2012-12-26  2:29 ` Huang, Shane
2012-12-26 10:41 ` Sergei Shtylyov
2012-12-27  2:01   ` Huang, Shane
2013-01-04 16:53 Sedat Dilek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.