From: Aaron Lu <aaron.lu@intel.com>
To: "Rafael J. Wysocki" <rjw@sisk.pl>,
Alan Stern <stern@rowland.harvard.edu>
Cc: Oliver Neukum <oliver@neukum.org>,
James Bottomley <James.Bottomley@hansenpartnership.com>,
Jeff Garzik <jgarzik@pobox.com>,
linux-scsi@vger.kernel.org, linux-ide@vger.kernel.org,
linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org,
Aaron Lu <aaron.lwe@gmail.com>
Subject: Re: [PATCH v7 3/6] scsi: sr: support zero power ODD(ZPODD)
Date: Thu, 27 Sep 2012 17:26:29 +0800 [thread overview]
Message-ID: <50641BC5.2090000@intel.com> (raw)
In-Reply-To: <201209212302.19896.rjw@sisk.pl>
On 09/22/2012 05:02 AM, Rafael J. Wysocki wrote:
> On Friday, September 21, 2012, Aaron Lu wrote:
>> On Fri, Sep 21, 2012 at 12:07:23AM +0200, Rafael J. Wysocki wrote:
>>> On Wednesday, September 12, 2012, Aaron Lu wrote:
>>>> static struct scsi_driver sr_template = {
>>>> .owner = THIS_MODULE,
>>>> @@ -87,6 +89,8 @@ static struct scsi_driver sr_template = {
>>>> .name = "sr",
>>>> .probe = sr_probe,
>>>> .remove = sr_remove,
>>>> + .suspend = sr_suspend,
>>>> + .resume = sr_resume,
>>>> },
>>>> .done = sr_done,
>>>> };
>>>> @@ -172,6 +176,52 @@ static void scsi_cd_put(struct scsi_cd *cd)
>>>> mutex_unlock(&sr_ref_mutex);
>>>> }
>>>
>>> Besides, I need some help to understand how this is supposed to work.
>>>
>>> Do I think correctly that sr_suspend(), for example, will be run by the
>>> SCSI bus type layer in case of a CD device runtime suspend? However,
>>
>> Yes.
>>
>>> won't this routine be used during system suspend as well and won't it cause
>>> problems to happen if so?
>>
>> On system suspend, nothing needs to be done.
>> I'll add the following code in next version.
>>
>> if (!PMSG_IS_AUTO(msg))
>> return 0;
>
> Please don't. The pm_message_t thing is obsolete and shoulnd't really be
> used by device drivers. I know that ATA relies on it internally, but that's
> just something that needs to be changed at one point.
>
> Moreover, I'd like to migrate SCSI drivers to the PM handling based on struct
> dev_pm_ops eventually and your change is kind of going in the opposite
> direction. I don't know how much effort the migration is going to take,
> though, so perhaps we can just make this change first.
Does the following change look OK?
diff --git a/drivers/scsi/scsi_pm.c b/drivers/scsi/scsi_pm.c
index dc0ad85..1fb7ccc 100644
--- a/drivers/scsi/scsi_pm.c
+++ b/drivers/scsi/scsi_pm.c
@@ -143,7 +143,15 @@ static int scsi_runtime_suspend(struct device *dev)
dev_dbg(dev, "scsi_runtime_suspend\n");
if (scsi_is_sdev_device(dev)) {
- err = scsi_dev_type_suspend(dev, PMSG_AUTO_SUSPEND);
+ err = scsi_device_quiesce(to_scsi_device(dev));
+ if (err)
+ goto out;
+
+ err = pm_generic_runtime_suspend(dev);
+ if (!err)
+ goto out;
+
+ scsi_device_resume(to_scsi_device(dev));
if (err == -EAGAIN)
pm_schedule_suspend(dev, jiffies_to_msecs(
round_jiffies_up_relative(HZ/10)));
@@ -151,6 +159,7 @@ static int scsi_runtime_suspend(struct device *dev)
/* Insert hooks here for targets, hosts, and transport classes */
+out:
return err;
}
@@ -159,11 +168,17 @@ static int scsi_runtime_resume(struct device *dev)
int err = 0;
dev_dbg(dev, "scsi_runtime_resume\n");
- if (scsi_is_sdev_device(dev))
+ if (scsi_is_sdev_device(dev)) {
+ err = pm_generic_runtime_resume(dev);
+ if (err)
+ goto out;
+
err = scsi_dev_type_resume(dev);
+ }
/* Insert hooks here for targets, hosts, and transport classes */
+out:
return err;
}
And I'll define runtime callbacks for sr and sd.
Thanks,
Aaron
next prev parent reply other threads:[~2012-09-27 9:26 UTC|newest]
Thread overview: 84+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-12 8:29 [PATCH v7 0/6] ZPODD patches Aaron Lu
2012-09-12 8:29 ` [PATCH v7 1/6] block: genhd: add an interface to set disk poll interval Aaron Lu
2012-09-20 20:35 ` Rafael J. Wysocki
2012-09-12 8:29 ` [PATCH v7 2/6] scsi: sr: support runtime pm Aaron Lu
2012-09-20 20:48 ` Rafael J. Wysocki
2012-09-20 20:54 ` Alan Stern
2012-09-21 1:02 ` Aaron Lu
2012-09-21 20:49 ` Rafael J. Wysocki
2012-09-24 1:20 ` Aaron Lu
2012-09-24 12:55 ` Rafael J. Wysocki
2012-09-24 14:52 ` Aaron Lu
2012-09-24 21:40 ` Rafael J. Wysocki
2012-09-25 8:01 ` Aaron Lu
2012-09-25 11:47 ` Rafael J. Wysocki
2012-09-25 14:20 ` Aaron Lu
2012-09-25 14:23 ` Oliver Neukum
2012-09-25 14:46 ` Aaron Lu
2012-09-25 21:45 ` Rafael J. Wysocki
2012-09-26 1:03 ` Aaron Lu
2012-09-26 11:18 ` Rafael J. Wysocki
2012-09-26 14:52 ` Aaron Lu
2012-09-26 7:20 ` Oliver Neukum
2012-09-27 10:46 ` Oliver Neukum
2012-09-28 8:20 ` Aaron Lu
2012-09-12 8:29 ` [PATCH v7 3/6] scsi: sr: support zero power ODD(ZPODD) Aaron Lu
2012-09-20 22:07 ` Rafael J. Wysocki
2012-09-21 1:39 ` Aaron Lu
2012-09-21 21:02 ` Rafael J. Wysocki
2012-09-27 9:26 ` Aaron Lu [this message]
2012-09-27 14:42 ` Alan Stern
2012-09-27 14:55 ` Aaron Lu
2012-09-27 23:29 ` Rafael J. Wysocki
2012-09-24 21:55 ` Jeff Garzik
2012-09-12 8:29 ` [PATCH v7 4/6] scsi: pm: add may_power_off flag Aaron Lu
2012-09-12 8:29 ` [PATCH v7 5/6] scsi: sr: use may_power_off Aaron Lu
2012-09-12 8:29 ` [PATCH v7 6/6] libata: acpi: respect may_power_off flag Aaron Lu
2012-09-24 21:55 ` Jeff Garzik
2012-09-19 8:03 ` [PATCH v7 0/6] ZPODD patches Aaron Lu
2012-09-19 12:27 ` James Bottomley
2012-09-19 12:50 ` Rafael J. Wysocki
2012-09-19 14:19 ` Aaron Lu
2012-09-20 20:00 ` Rafael J. Wysocki
2012-09-21 5:48 ` Aaron Lu
2012-09-21 21:18 ` Rafael J. Wysocki
2012-09-22 7:32 ` Oliver Neukum
2012-09-22 11:28 ` Rafael J. Wysocki
2012-09-22 15:38 ` Alan Stern
2012-09-22 19:46 ` Rafael J. Wysocki
2012-09-22 20:23 ` Alan Stern
2012-09-22 21:48 ` Rafael J. Wysocki
2012-09-24 2:55 ` Aaron Lu
2012-09-24 13:06 ` Rafael J. Wysocki
2012-09-24 15:04 ` Aaron Lu
2012-09-24 21:46 ` Rafael J. Wysocki
2012-09-25 8:18 ` Aaron Lu
2012-09-25 11:02 ` James Bottomley
2012-09-25 13:56 ` Aaron Lu
2012-09-27 9:43 ` Aaron Lu
2012-09-19 14:52 ` James Bottomley
2012-09-20 21:46 ` Rafael J. Wysocki
2012-09-19 13:05 ` Oliver Neukum
2012-09-19 15:19 ` David Woodhouse
2012-09-20 0:34 ` Jack Wang
[not found] ` <201209280115.06964.rjw@sisk.pl>
[not found] ` <5064FA08.6030005@intel.com>
[not found] ` <201209282346.15872.rjw@sisk.pl>
2012-09-29 2:10 ` [PATCH v7 2/6] scsi: sr: support runtime pm Aaron Lu
2012-09-29 14:29 ` Alan Stern
2012-09-29 15:03 ` Aaron Lu
2012-09-29 22:44 ` Rafael J. Wysocki
2012-09-30 12:32 ` Aaron Lu
2012-09-30 14:47 ` Alan Stern
2012-09-30 15:39 ` Aaron Lu
2012-09-30 19:15 ` Jeff Garzik
2012-09-30 19:08 ` Jeff Garzik
2012-09-29 22:31 ` Rafael J. Wysocki
2012-09-30 19:03 ` Jeff Garzik
2012-09-30 19:43 ` Alan Stern
2012-10-01 4:57 ` Jeff Garzik
2012-10-08 9:27 ` Aaron Lu
2012-10-08 10:21 ` James Bottomley
2012-10-09 7:20 ` Aaron Lu
2012-10-09 14:58 ` James Bottomley
2012-10-11 7:49 ` Aaron Lu
2012-10-09 23:26 ` Rafael J. Wysocki
2012-09-29 22:27 ` Rafael J. Wysocki
2012-09-30 12:38 ` Aaron Lu
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=50641BC5.2090000@intel.com \
--to=aaron.lu@intel.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=aaron.lwe@gmail.com \
--cc=jgarzik@pobox.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=oliver@neukum.org \
--cc=rjw@sisk.pl \
--cc=stern@rowland.harvard.edu \
/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).