From: James Bottomley <James.Bottomley@SteelEye.com>
To: Jeff Garzik <jgarzik@pobox.com>
Cc: SCSI Mailing List <linux-scsi@vger.kernel.org>,
linux-ide@vger.kernel.org, Jens Axboe <axboe@suse.de>
Subject: Re: [PATCH] libata: device suspend/resume
Date: Mon, 23 May 2005 17:10:06 -0500 [thread overview]
Message-ID: <1116886206.5021.42.camel@mulgrave> (raw)
In-Reply-To: <20050523204516.GA28058@havoc.gtf.org>
On Mon, 2005-05-23 at 16:45 -0400, Jeff Garzik wrote:
> On Mon, May 23, 2005 at 03:41:15PM -0500, James Bottomley wrote:
> > The thread petered out before a resolution, however, I think
> > at least disk devices should be doing a synchronize cache on suspend.
>
> Agreed.
OK, try this as a straw horse. It plumbs our scsi bus model into
suspend and resume via the driver (which would be the ULD) function.
The only ULD which has an extra function is sd, and all it does is
synchronize the cache if it was writeback. I believe you translate SYNC
CACHE in libata, so this patch should be sufficient (unless we still
have a problem with ATA devices that lie about their cache types?)
I think this is sufficient, because if the LLD also wants this
information, it can get it from the model of the bus it's attached to.
James
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -199,10 +200,37 @@ static int scsi_bus_match(struct device
return (sdp->inq_periph_qual == SCSI_INQ_PQ_CON)? 1: 0;
}
+static int scsi_bus_suspend(struct device *dev, pm_message_t state)
+{
+ struct scsi_device *sdev = to_scsi_device(dev);
+ int err = scsi_device_quiesce(sdev);
+
+ if (err)
+ return err;
+
+ if(dev->driver && dev->driver->suspend)
+ return dev->driver->suspend(dev, state, 0);
+ return 0;
+}
+
+static int scsi_bus_resume(struct device *dev)
+{
+ struct scsi_device *sdev = to_scsi_device(dev);
+ int err = 0;
+
+ if(dev->driver && dev->driver->resume)
+ err = dev->driver->resume(dev, 0);
+
+ scsi_device_resume(sdev);
+ return err;
+}
+
struct bus_type scsi_bus_type = {
.name = "scsi",
.match = scsi_bus_match,
+ .suspend = scsi_bus_suspend,
+ .resume = scsi_bus_resume
};
int scsi_sysfs_register(void)
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -119,6 +119,7 @@ static void sd_rw_intr(struct scsi_cmnd
static int sd_probe(struct device *);
static int sd_remove(struct device *);
static void sd_shutdown(struct device *dev);
+static int sd_suspend(struct device *dev, pm_message_t state, u32 level);
static void sd_rescan(struct device *);
static int sd_init_command(struct scsi_cmnd *);
static int sd_issue_flush(struct device *, sector_t *);
@@ -134,6 +135,7 @@ static struct scsi_driver sd_template =
.probe = sd_probe,
.remove = sd_remove,
.shutdown = sd_shutdown,
+ .suspend = sd_suspend,
},
.rescan = sd_rescan,
.init_command = sd_init_command,
@@ -1710,7 +1712,28 @@ static void sd_shutdown(struct device *d
printk(KERN_NOTICE "Synchronizing SCSI cache for disk %s: \n",
sdkp->disk->disk_name);
sd_sync_cache(sdp);
-}
+}
+
+/* Just quietly quiesce the device and SYNCHRONIZE CACHE for suspend too */
+static int sd_suspend(struct device *dev, pm_message_t state, u32 level)
+{
+ struct scsi_device *sdp = to_scsi_device(dev);
+ struct scsi_disk *sdkp = dev_get_drvdata(dev);
+
+ if (!sdkp)
+ return 0; /* this can happen */
+
+ if (!sdkp->WCE)
+ return 0;
+
+ /* don't try to sync an offline device ... it will only error */
+ if (!scsi_device_online(sdp))
+ return 0;
+
+ if (sd_sync_cache(sdp))
+ return -EIO;
+ return 0;
+}
/**
* init_sd - entry point for this driver (both when built in or when
next prev parent reply other threads:[~2005-05-23 22:11 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-23 20:15 [PATCH] libata: device suspend/resume Jeff Garzik
2005-05-23 20:41 ` James Bottomley
2005-05-23 20:45 ` Jeff Garzik
2005-05-23 22:10 ` James Bottomley [this message]
2005-05-24 6:21 ` Jens Axboe
2005-05-24 6:53 ` Jeff Garzik
2005-05-24 7:06 ` Hannes Reinecke
2005-05-24 7:08 ` Jens Axboe
2005-05-24 7:16 ` Jeff Garzik
2005-05-24 7:07 ` Jens Axboe
2005-05-24 7:10 ` Jeff Garzik
2005-05-24 7:13 ` Jens Axboe
2005-05-27 2:49 ` libata, SCSI and storage drivers Jeff Garzik
2005-05-27 6:45 ` Douglas Gilbert
2005-05-27 14:41 ` Luben Tuikov
2005-05-24 7:14 ` [PATCH] libata: device suspend/resume Hannes Reinecke
2005-05-24 7:15 ` Jens Axboe
2005-05-24 7:18 ` Jeff Garzik
2005-05-24 10:17 ` Douglas Gilbert
2005-05-24 17:10 ` Jeff Garzik
2005-05-24 7:59 ` Jens Axboe
2005-05-24 8:21 ` Jeff Garzik
2005-05-24 8:51 ` Jens Axboe
2005-05-24 16:37 ` Jeff Garzik
2005-05-25 9:29 ` Jens Axboe
2005-05-25 23:40 ` Guennadi Liakhovetski
2005-05-26 1:05 ` Jeff Garzik
2005-05-26 5:57 ` Jens Axboe
2005-05-26 22:56 ` Bartlomiej Zolnierkiewicz
2005-05-27 6:54 ` Jens Axboe
2005-05-27 2:01 ` Benjamin Herrenschmidt
2005-05-27 6:55 ` Jens Axboe
2005-05-24 13:48 ` Luben Tuikov
2005-05-24 17:29 ` Jeff Garzik
2005-05-24 13:05 ` Luben Tuikov
2005-05-27 2:54 ` Jeff Garzik
2005-05-24 16:27 ` Mark Lord
2005-05-24 16:33 ` Mark Lord
2005-05-24 16:04 ` Mark Lord
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=1116886206.5021.42.camel@mulgrave \
--to=james.bottomley@steeleye.com \
--cc=axboe@suse.de \
--cc=jgarzik@pobox.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).