Re: [PATCH 1/2] scsi: sd: set ready_to_power_off for scsi disk
From: Oliver Neukum <hidden>
Date: 2012-09-13 10:18:05
Also in:
linux-acpi, linux-scsi
On Thursday 13 September 2012 10:26:44 James Bottomley wrote:
On Thu, 2012-09-13 at 17:07 +0800, Aaron Lu wrote:
quoted
So I think this is basically 2 things, one is the runtime suspend of the disk, another is when it is runtime suspended, how to remove its power. I'm currently doing the latter one, which is simpler, so I want to do it first :-)Well, I don't like the way the interaction of the patches is going. You're the one proposing powering down the device outside of the standards defined transitions, so you need to be responsible for the actions that necessitates, including synchronizing the cache. The specs (SPC-4) say that cache management is explicitly unnecessary for the standard SCSI power states (Active, Idle, Standby and Stopped), so someone at some point is going to read that and remove the unnecessary cache sync in the code. When that happens, you'll start getting data loss.
The cache is handled identically in sd_suspend() and sd_shutdown(). In fact sd_shutdown() will skip handling it if the device has already been suspended, so the assumption is built into the code and has been so for a long time. Though it wouldn't hurt to add a comment that says that the system going to S3 or S4 will cut power to a lot of disk so that the cache needs to be synced even if the spec says we need not. Runtime PM doesn't much alter the situation. Regards Oliver