Skip to contentSkip to conversation

libata: force hardreset if link is in powersave mode

PATCH Tejun Heo 2 participants 2 messages May 15, 2008 libata

lore
Share & tools
lore

Tejun Heo

author
#0 lore raw

Inhibiting link PM mode doesn't bring the link back online if it's already in powersave mode. If SRST is used in these cases, libata EH thinks that the link is offline and fails detection. Force hardreset if link is in powersave mode.

---
Patch for -stable only. Devel branch now uses hardreset by default so this type of promotion logic isn't necessary anymore.

drivers/ata/libata-core.c | 12 ++++++++++++

1 file changed, 12 insertions(+)
drivers/ata/libata-core.c +0 -0
Index: linux-2.6.25/drivers/ata/libata-core.c
===================================================================
@@ -3960,6 +3960,7 @@ int ata_std_prereset(struct ata_link *li
	struct ata_port *ap = link->ap;
	struct ata_eh_context *ehc = &link->eh_context;
	const unsigned long *timing = sata_ehc_deb_timing(ehc);
+	u32 sstatus;
	int rc;

	/* handle link resume */
@@ -3973,6 +3974,17 @@ int ata_std_prereset(struct ata_link *li
	if (ap->flags & ATA_FLAG_PMP)
		ehc->i.action |= ATA_EH_HARDRESET;

+ /* if link powersave is on, force hardreset */
+ if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0) {
+ u8 ipm = sstatus >> 8;
+
+ if (ipm == 2 || ipm == 6) {
+ ata_link_printk(link, KERN_INFO, "link in powersave "
+ "mode (ipm=%d), forcing hardreset\n", ipm);
+ ehc->i.action |= ATA_EH_HARDRESET;
+ }
+ }
+

	/* if we're about to do hardreset, nothing more to do */
	if (ehc->i.action & ATA_EH_HARDRESET)
		return 0;
#1 lore raw

patch libata-force-hardreset-if-link-is-in-powersave-mode.patch added to 2.6.25-stable tree

This is a note to let you know that we have just queued up the patch titled

Subject: libata: force hardreset if link is in powersave mode

to the 2.6.25-stable tree. Its filename is

libata-force-hardreset-if-link-is-in-powersave-mode.patch

A git repo of this tree can be found at
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

Quoted 1 line

From [email protected] Thu May 15 06:15:27 2008

From: Tejun Heo <[email protected]>
Date: Thu, 15 May 2008 22:14:57 +0900
Subject: libata: force hardreset if link is in powersave mode
To: Jeff Garzik <[email protected]>, IDE/ATA development list <[email protected]>, [email protected]
Cc: [email protected]
Message-ID: <[email protected]>

From: Tejun Heo <[email protected]>

Inhibiting link PM mode doesn't bring the link back online if it's already in powersave mode. If SRST is used in these cases, libata EH thinks that the link is offline and fails detection. Force hardreset if link is in powersave mode.

---
 drivers/ata/libata-core.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/ata/libata-core.c +12 -0
@@ -3947,6 +3947,7 @@ int ata_std_prereset(struct ata_link *li
 	struct ata_port *ap = link->ap;
 	struct ata_eh_context *ehc = &link->eh_context;
 	const unsigned long *timing = sata_ehc_deb_timing(ehc);
+	u32 sstatus;
 	int rc;
 
 	/* handle link resume */
@@ -3960,6 +3961,17 @@ int ata_std_prereset(struct ata_link *li
 	if (ap->flags & ATA_FLAG_PMP)
 		ehc->i.action |= ATA_EH_HARDRESET;
 
+	/* if link powersave is on, force hardreset */
+	if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0) {
+		u8 ipm = sstatus >> 8;
+
+		if (ipm == 2 || ipm == 6) {
+			ata_link_printk(link, KERN_INFO, "link in powersave "
+				"mode (ipm=%d), forcing hardreset\n", ipm);
+			ehc->i.action |= ATA_EH_HARDRESET;
+		}
+	}
+
 	/* if we're about to do hardreset, nothing more to do */
 	if (ehc->i.action & ATA_EH_HARDRESET)
 		return 0;

Patches currently in stable-queue which might be from [email protected] are

queue-2.6.25/libata-force-hardreset-if-link-is-in-powersave-mode.patch