public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Lunz <lunz@falooley.org>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>, B.Zolnierkiewicz@elka.pw.edu.pl
Cc: "Rafael J\. Wysocki" <rjw@sisk.pl>, Andrew Morton <akpm@osdl.org>,
	LKML <linux-kernel@vger.kernel.org>, Pavel Machek <pavel@ucw.cz>,
	Vojtech Pavlik <vojtech@suse.cz>,
	Brad Campbell <brad@wasp.net.au>,
	David Brownell <david-b@pacbell.net>
Subject: [patch, rft] ide: reprogram disk pio timings on resume
Date: Sat, 29 Jul 2006 19:34:16 -0400	[thread overview]
Message-ID: <20060729233416.GA6346@opus.vpn-dev.reflex> (raw)
In-Reply-To: <1154105517.13509.153.camel@localhost.localdomain>


Add a step to the IDE PM state machine that reprograms disk PIO timings
as the first step on resume. This prevents ide deadlock on
resume-from-ram on my nforce3-based laptop.

An earlier implementation was written entirely within the amd74xx ide
driver, but Alan helpfully pointed out that this is the correct thing to
do globally. Still, I'm only calling hwif->tuneproc() for disks, based
on two things:

 - The existing state machine is already passed over for non-disk drives
 - Previous testing on my laptop shows that the hangs are related only
   to the disk - suspend/resume from a livecd showed that there's no
   need for this on the cdrom.

Signed-off-by: Jason Lunz <lunz@falooley.org>

---

Alan: I'm doing tuneproc() before WIN_IDLEIMMEDIATE as you said. It
works. I'd otherwise have done it after, based solely on the name -
thanks for the suggestion.

David, Rafael: It would be helpful if you could verify that this patch
cures your ide-relate hangs on s2ram as well (with my previous patch to
amd74xx unapplied). 

Brad: thanks for volunteering to test! You'll be the lucky first person
to try this on a non-nforce ide chipset. good luck.

Please be careful - I know next to nothing about IDE; I just know that
this make s2ram work on my laptop. This patch means altering ide resume
for all systems where it currently works already. I suppose there could
be regressions.

 drivers/ide/ide-io.c |   25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

Index: linux-2.6.18-rc2-git6/drivers/ide/ide-io.c
===================================================================
--- linux-2.6.18-rc2-git6.orig/drivers/ide/ide-io.c
+++ linux-2.6.18-rc2-git6/drivers/ide/ide-io.c
@@ -135,7 +135,8 @@
 	ide_pm_flush_cache	= ide_pm_state_start_suspend,
 	idedisk_pm_standby,
 
-	idedisk_pm_idle		= ide_pm_state_start_resume,
+	idedisk_pm_restore_pio	= ide_pm_state_start_resume,
+	idedisk_pm_idle,
 	ide_pm_restore_dma,
 };
 
@@ -156,7 +157,10 @@
 	case idedisk_pm_standby:	/* Suspend step 2 (standby) complete */
 		pm->pm_step = ide_pm_state_completed;
 		break;
-	case idedisk_pm_idle:		/* Resume step 1 (idle) complete */
+	case idedisk_pm_restore_pio:	/* Resume step 1 complete */
+		pm->pm_step = idedisk_pm_idle;
+		break;
+	case idedisk_pm_idle:		/* Resume step 2 (idle) complete */
 		pm->pm_step = ide_pm_restore_dma;
 		break;
 	}
@@ -170,8 +174,11 @@
 	memset(args, 0, sizeof(*args));
 
 	if (drive->media != ide_disk) {
-		/* skip idedisk_pm_idle for ATAPI devices */
-		if (pm->pm_step == idedisk_pm_idle)
+		/*
+		 * skip idedisk_pm_restore_pio and idedisk_pm_idle for ATAPI
+		 * devices
+		 */
+		if (pm->pm_step == idedisk_pm_restore_pio)
 			pm->pm_step = ide_pm_restore_dma;
 	}
 
@@ -198,13 +205,19 @@
 		args->handler	   = &task_no_data_intr;
 		return do_rw_taskfile(drive, args);
 
-	case idedisk_pm_idle:		/* Resume step 1 (idle) */
+	case idedisk_pm_restore_pio:	/* Resume step 1 (restore PIO) */
+		if (drive->hwif->tuneproc != NULL)
+			drive->hwif->tuneproc(drive, 255);
+		ide_complete_power_step(drive, rq, 0, 0);
+		return ide_stopped;
+
+	case idedisk_pm_idle:		/* Resume step 2 (idle) */
 		args->tfRegister[IDE_COMMAND_OFFSET] = WIN_IDLEIMMEDIATE;
 		args->command_type = IDE_DRIVE_TASK_NO_DATA;
 		args->handler = task_no_data_intr;
 		return do_rw_taskfile(drive, args);
 
-	case ide_pm_restore_dma:	/* Resume step 2 (restore DMA) */
+	case ide_pm_restore_dma:	/* Resume step 3 (restore DMA) */
 		/*
 		 * Right now, all we do is call hwif->ide_dma_check(drive),
 		 * we could be smarter and check for current xfer_speed

  parent reply	other threads:[~2006-07-29 23:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-28 14:46 [PATCH] amd74xx: implement suspend-to-ram Rafael J. Wysocki
2006-07-28 16:51 ` Alan Cox
2006-07-28 17:13   ` Jason Lunz
2006-07-28 19:16     ` Brad Campbell
2006-07-28 20:00     ` Alan Cox
2006-08-01  7:18       ` Benjamin Herrenschmidt
2006-07-29 23:34   ` Jason Lunz [this message]
2006-07-30  3:25     ` [patch, rft] ide: reprogram disk pio timings on resume Brad Campbell
2006-07-30 17:26     ` Alan Cox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060729233416.GA6346@opus.vpn-dev.reflex \
    --to=lunz@falooley.org \
    --cc=B.Zolnierkiewicz@elka.pw.edu.pl \
    --cc=akpm@osdl.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=brad@wasp.net.au \
    --cc=david-b@pacbell.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rjw@sisk.pl \
    --cc=vojtech@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox