From patchwork Tue Jan 7 16:08:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Stern X-Patchwork-Id: 3449101 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 108779F2E9 for ; Tue, 7 Jan 2014 16:08:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CAB3620122 for ; Tue, 7 Jan 2014 16:08:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C02A620114 for ; Tue, 7 Jan 2014 16:08:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752640AbaAGQIX (ORCPT ); Tue, 7 Jan 2014 11:08:23 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:55036 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751631AbaAGQIX (ORCPT ); Tue, 7 Jan 2014 11:08:23 -0500 Received: (qmail 5456 invoked by uid 2102); 7 Jan 2014 11:08:22 -0500 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 7 Jan 2014 11:08:22 -0500 Date: Tue, 7 Jan 2014 11:08:22 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Phillip Susi cc: Aaron Lu , Sujit Reddy Thumma , , , , , , Linux-pm mailing list , "Rafael J. Wysocki" Subject: Re: REQ_PM vs REQ_TYPE_PM_RESUME In-Reply-To: <52CC20A0.7060606@ubuntu.com> Message-ID: MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, 7 Jan 2014, Phillip Susi wrote: > On 1/7/2014 10:25 AM, Alan Stern wrote: > > This doesn't seem like a good idea. The way to speed up resumes is > > to allow sd's resume routine to return while the disk is still > > spinning up (i.e., make the spin-up asynchronous). There already > > have been patches submitted to do this; I don't know what happened > > to them. > > Sure, if that is your *only* goal. I also want the disk to not spin > up *at all* if possible. There's no sense spinning up all of your > disks every time you resume when you very rarely access some of them. Okay, that's a different matter. There's a much simpler way to accomplish this. The patch below will avoid spinning up drives that were already in runtime suspend when the system sleep started. (If a drive wasn't in runtime suspend then presumably it was used recently; therefore it's likely to be used again in the near future and so it _should_ be spun up.) Warning: This patch is completely untested. I didn't even try to compile it. Still, it should give you a good idea as to what is really needed here. Alan Stern --- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: usb-3.13/drivers/scsi/scsi_pm.c =================================================================== --- usb-3.13.orig/drivers/scsi/scsi_pm.c +++ usb-3.13/drivers/scsi/scsi_pm.c @@ -71,14 +71,11 @@ scsi_bus_resume_common(struct device *de { int err = 0; + if (pm_runtime_status_suspended(dev)) + return err; + if (scsi_is_sdev_device(dev)) err = scsi_dev_type_resume(dev, cb); - - if (err == 0) { - pm_runtime_disable(dev); - pm_runtime_set_active(dev); - pm_runtime_enable(dev); - } return err; }