Skip to contentSkip to conversation

SCSI mid-layer suspend/resume

PATCH/RFC Randy Dunlap 5 participants 13 messages Oct 24, 2005 – Oct 27, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC.

Although Jens's SATA suspend/resume patch works, it seems that the SCSI maintainer(s) want something different, e.g., Nathan Bryant's 2004 patch[1] with some changes:

Jeff's comments[2]:
- Use START STOP UNIT on suspend & resume (done);
- Issue hardware or software reset on suspend (not done).

Christoph's comments[3][4]:
- some functions should be renamed (done, maybe :);
- some (same) functions should be in scsi_sysfs.c (done);
- drop the CONFIG_PM ifdefs (done);
- way to avoid spinning down (or generically: suspending) external disks, such as a sysfs-controllable flag (done at device level);

TBD:
James Smart's comment about limiting number of drive spin-ups[5]; Stefan Richter's comment about which driver decides to support or
implement suspend/resume[6];
Mark Lord: where is the GFP_KERNEL usage that you were concerned
about on resume? [7]

BTW, what does this comment in scsi_sysfs.c refer to when I am adding an attribute to it?
/* Default template for device attributes. May NOT be modified */ static struct device_attribute *scsi_sysfs_sdev_attrs[] = {

---
[1] http://lwn.net/Articles/97453/
[2] http://marc.theaimsgroup.com/?l=linux-scsi&m=112797130926411&w=2
[3] http://marc.theaimsgroup.com/?l=linux-scsi&m=112797930421645&w=2
[4] http://marc.theaimsgroup.com/?l=linux-scsi&m=112798153124878&w=2
[5] http://marc.theaimsgroup.com/?l=linux-scsi&m=112800404305403&w=2
[6] http://marc.theaimsgroup.com/?l=linux-scsi&m=112800966123767&w=2
[7] http://marc.theaimsgroup.com/?l=linux-scsi&m=112819108407925&w=2
---

From: Randy Dunlap <[email protected]>

Update Nathan Bryant's SCSI midlayer suspend/resume patch per email suggestions from Jeff Garzik and Christoph Hellwig. "suspend" is a device-level flag that controls whether a device should participate in suspend operations. Then it's up to each device driver to determine what that means for a device.

---
 drivers/scsi/scsi_priv.h   |    2
 drivers/scsi/scsi_sysfs.c  |   63 +++++++++++++++++++++++++-
 drivers/scsi/sd.c          |   82 ++++++++++++++++++++++++++++++++++-
 include/scsi/scsi_device.h |    1
 include/scsi/scsi_driver.h |    2
 5 files changed, 146 insertions(+), 4 deletions(-)
drivers/scsi/scsi_priv.h +2 -0
diff -Naurp -X /home/rddunlap/doc/dontdiff linux-2614-rc4-pv/drivers/scsi/scsi_priv.h linux-2614-rc4-scsi/drivers/scsi/scsi_priv.h
@@ -55,6 +55,8 @@ static inline void scsi_log_send(struct 
 static inline void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
 	{ };
 #endif
+extern int scsi_device_suspend(struct device *dev, pm_message_t state);
+extern int scsi_device_wakeup(struct device *dev);
 
 /* scsi_devinfo.c */
 extern int scsi_get_device_flags(struct scsi_device *sdev,
drivers/scsi/scsi_sysfs.c +60 -3

99 lines not on this page · raw message

drivers/scsi/sd.c +81 -1

100 lines not on this page · raw message

include/scsi/scsi_device.h +1 -0
diff -Naurp -X /home/rddunlap/doc/dontdiff linux-2614-rc4-pv/include/scsi/scsi_device.h linux-2614-rc4-scsi/include/scsi/scsi_device.h
@@ -83,6 +83,7 @@ struct scsi_device {
 	char * model;		/* ... after scan; point to static string */
 	char * rev;		/* ... "nullnullnullnull" before scan */
 	unsigned char current_tag;	/* current tag */
+	unsigned char suspend;	/* ok to participate in suspend/resume */
 	struct scsi_target      *sdev_target;   /* used only for single_lun */
 
 	unsigned int	sdev_bflags; /* black/white flags as also found in
include/scsi/scsi_driver.h +2 -0
diff -Naurp -X /home/rddunlap/doc/dontdiff linux-2614-rc4-pv/include/scsi/scsi_driver.h linux-2614-rc4-scsi/include/scsi/scsi_driver.h
@@ -13,6 +13,8 @@ struct scsi_driver {
 
 	int (*init_command)(struct scsi_cmnd *);
 	void (*rescan)(struct device *);
+	int (*suspend)(struct device *dev, pm_message_t state);
+	int (*resume)(struct device *dev);
 	int (*issue_flush)(struct device *, sector_t *);
 	int (*prepare_flush)(struct request_queue *, struct request *);
 	void (*end_flush)(struct request_queue *, struct request *);
#1 lore raw
Quoted 2 lines · Randy Dunlap

Jeff's comments[2]:
- Issue hardware or software reset on suspend (not done).

Note that's an ATA-specific comment.

Jeff

#10 lore raw
In reply to Randy Dunlap
Quoted 5 lines · Randy Dunlap

RFC.

Although Jens's SATA suspend/resume patch works, it seems that the SCSI maintainer(s) want something different, e.g., Nathan Bryant's 2004 patch[1] with some changes:

...

Quoted 2 lines

Mark Lord: where is the GFP_KERNEL usage that you were concerned
about on resume? [7]

Seems to be gone now in 2.6.14-rc*.
Not an issue now.

#11 lore raw
In reply to Randy Dunlap
Quoted 3 lines · Randy Dunlap

Although Jens's SATA suspend/resume patch works, it seems that the SCSI maintainer(s) want something different, e.g., Nathan Bryant's 2004 patch[1] with some changes:

..
As-is, the patch fails the practical examination:

My notebook fails to come back from suspend (to-RAM) using this patch, but works fine with Jens' patch.

Modern notebook, no serial port, backlight still off so no on-screen messages. Using ata_piix (libata) for hard disk.

Cheers

#12 lore raw
Quoted 9 lines · On Mon, 24 Oct 2005 23:08:03 -0400 Mark Lord <[email protected]> wrote:
Quoted 3 lines · Randy Dunlap

Although Jens's SATA suspend/resume patch works, it seems that the SCSI maintainer(s) want something different, e.g., Nathan Bryant's 2004 patch[1] with some changes:

..
As-is, the patch fails the practical examination:

My notebook fails to come back from suspend (to-RAM) using this patch, but works fine with Jens' patch.

Maybe I should have used Jeff's "DO NOT APPLY" wording here. I didn't mean to give the impression that the patch was complete. It's a work in progress, looking for constructive feedback, which yours is, of course.

Quoted 2 lines

Modern notebook, no serial port, backlight still off so no on-screen messages. Using ata_piix (libata) for hard disk.

---
~Randy

#2 lore raw
In reply to Jeff Garzik
Quoted 5 lines · On Mon, 24 Oct 2005 19:29:11 -0400 Jeff Garzik <[email protected]> wrote:
Quoted 2 lines · Randy Dunlap

Jeff's comments[2]:
- Issue hardware or software reset on suspend (not done).

Note that's an ATA-specific comment.

So it is. Thanks for the reminder.

How/where can I put low-level driver specific suspend/resume code, for PATA or SATA or usb-storage or ieee1394 or SCSI? What is the linkage (chain, pointers, whatever) thru the SCSI stack to each driver's "methods"? Or do those not exist yet?

---
~Randy

#3 lore raw
Quoted 12 lines · Randy Dunlap
Quoted 6 lines · On Mon, 24 Oct 2005 19:29:11 -0400 Jeff Garzik <[email protected]> wrote:
Quoted 2 lines · Randy Dunlap

Jeff's comments[2]:
- Issue hardware or software reset on suspend (not done).

Note that's an ATA-specific comment.

Quoted 7 lines

So it is. Thanks for the reminder.

How/where can I put low-level driver specific suspend/resume code, for PATA or SATA or usb-storage or ieee1394 or SCSI? What is the linkage (chain, pointers, whatever) thru the SCSI stack to each driver's "methods"? Or do those not exist yet?

Want the completely honest answer? :) I have no clue, and thinking about suspend gives me a headache Anytime I start reading the actual suspend code, I wind up either confused or depressed, or both.

We have emperical evidence that Jens' patch works on SATA, so see if the two patches can meet in the middle somewhere?

Jeff

#9 lore raw
In reply to Randy Dunlap
Quoted 5 lines · Randy Dunlap

How/where can I put low-level driver specific suspend/resume code, for PATA or SATA or usb-storage or ieee1394 or SCSI? What is the linkage (chain, pointers, whatever) thru the SCSI stack to each driver's "methods"? Or do those not exist yet?

I will try to post a more concrete followup to my earlier comment about involvement of lower levels, notably ieee1394, at the end of the week. So far I have to say about ieee1394 that
- "internal power management" i.e. suspend/resume of the local 1394 host adapters seems not to fully work yet according to sparse reports from users (I did not test it myself under Linux 2.6 yet),
- "external power management" i.e. management of power states of attached 1394 nodes is not implemented yet. I hope to implement bus manager contention (a prerequisite for bus-wide power management) in late November or in December.

Signature · 3 lines
Stefan Richter
-=====-=-=-= =-=- ==-=-
http://arcgraph.de/sr/
#4 lore raw
In reply to Jeff Garzik
Quoted 2 lines · Jeff Garzik

We have emperical evidence that Jens' patch works on SATA, so see if the two patches can meet in the middle somewhere?

And just to muddy the waters somewhat..

I have an extra hard drive caddy for my Dell notebook, with a different 2.5" drive mounted in it.

When using THAT drive, my machine cannot resume successully from suspend-to-RAM. Hangs with the hard drive light on solid some of the time, and not on other times.
Drove me crazy figuring this out, but I eventually tried a different drive and it worked fine.

So.. not all drives work for me.

Now, the drive that doesn't work with suspend/resume (RAM) happens to claim to support Advanced Power Management. Except that "hdparm -Bxx" has zero effect on it -- cannot enable it or modify the setting in anyway.

My other drives also have the APM feature, and have it turned *on*, and "hdparm -Bxx" can be used to turn it on/off and modify the setting.

Very weird, possibly not related to the resume failures. Or maybe.

Cheers

#5 lore raw
Quoted 10 lines · Mark Lord

I have an extra hard drive caddy for my Dell notebook, with a different 2.5" drive mounted in it.

When using THAT drive, my machine cannot resume successully from suspend-to-RAM. Hangs with the hard drive light on solid some of the time, and not on other times.
Drove me crazy figuring this out, but I eventually tried a different drive and it worked fine.

So.. not all drives work for me.

Any idea how this extra drive is actually connected? I was thinking PATA drive with SATA bridge, PATA directly (comes to mind...) or maybe it's even a SATA drive connected directly...

#6 lore raw
Quoted 4 lines · Erik Slagter
Quoted 2 lines · Mark Lord

I have an extra hard drive caddy for my Dell notebook, with a different 2.5" drive mounted in it.

..

Quoted 3 lines

Any idea how this extra drive is actually connected? I was thinking PATA drive with SATA bridge, PATA directly (comes to mind...) or maybe it's even a SATA drive connected directly...

Definitely, absolutely, I have it in the palm of my hand, this is a PATA drive.

Jeff suspects that there must be a SATA bridge
inside the notebook itself.

Cheers

#7 lore raw

(receiver list trimmed)

Quoted 2 lines · Mark Lord
Quoted 2 lines
Quoted 2 lines

I have an extra hard drive caddy for my Dell notebook, with a different 2.5" drive mounted in it.

..

Quoted 5 lines

Definitely, absolutely, I have it in the palm of my hand, this is a PATA drive.

Jeff suspects that there must be a SATA bridge
inside the notebook itself.

Oh, and just to be super clear -- the "caddy" is simply the common name for the "Dell internal hard drive try", which holds the primary (the *only*) internal hard disk for the notebook.

Very useful having an extra caddy -- lets one swap drives and operating systems completely for experiments.

I've added the Dell part numbers for this to my website, in case anyone else here (Eric) also has a Dell Inspiron 9300 (or XPS) and wants to order their own extra caddy.

http://rtr.ca/dell_i9300/

Cheers

#8 lore raw
In reply to Mark Lord
Quoted 10 lines · Mark Lord
Quoted 4 lines · Erik Slagter
Quoted 2 lines · Mark Lord

I have an extra hard drive caddy for my Dell notebook, with a different 2.5" drive mounted in it.

..

Quoted 3 lines

Any idea how this extra drive is actually connected? I was thinking PATA drive with SATA bridge, PATA directly (comes to mind...) or maybe it's even a SATA drive connected directly...

Quoted 5 lines

Definitely, absolutely, I have it in the palm of my hand, this is a PATA drive.

Jeff suspects that there must be a SATA bridge
inside the notebook itself.

Ah, OK, I think I understand now (also read your other mail), this drive is a _replacement_ for the original drive, not additional, right?

In that case it's a very strange phenomena indeed.

BTW I'd rather have an _extra_ drive to run mirroring on ;-)