Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759252Ab2EWOnd (ORCPT ); Wed, 23 May 2012 10:43:33 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:51741 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1752184Ab2EWOnb (ORCPT ); Wed, 23 May 2012 10:43:31 -0400 Date: Wed, 23 May 2012 10:43:30 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Lin Ming cc: Jens Axboe , , , Subject: Re: [RFC PATCH v3 4/4] [SCSI] sd: change to auto suspend mode In-Reply-To: <1337671292-15583-5-git-send-email-ming.m.lin@intel.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1891 Lines: 58 On Tue, 22 May 2012, Lin Ming wrote: > Uses block layer runtime pm helper functions in scsi_runtime_suspend/resume. > Remove scsi_autopm_* from sd open/release/remove path. Sorry I didn't have time to get to this yesterday... > --- a/drivers/scsi/scsi_pm.c > +++ b/drivers/scsi/scsi_pm.c > @@ -171,9 +183,10 @@ static int scsi_runtime_idle(struct device *dev) > > /* Insert hooks here for targets, hosts, and transport classes */ > > - if (scsi_is_sdev_device(dev)) > - err = pm_schedule_suspend(dev, 100); > - else > + if (scsi_is_sdev_device(dev)) { > + pm_runtime_mark_last_busy(dev); > + err = pm_request_autosuspend(dev); This really should be pm_runtime_autosuspend(dev). In practice there's very little difference; it's mostly a matter of style. > --- a/drivers/scsi/sd.c > +++ b/drivers/scsi/sd.c > @@ -2631,7 +2624,7 @@ static void sd_probe_async(void *data, async_cookie_t cookie) > > sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n", > sdp->removable ? "removable " : ""); > - scsi_autopm_put_device(sdp); > + pm_runtime_put_sync_autosuspend(&sdp->sdev_gendev); This should be left the way it was. scsi_autopm_put_device() does pm_runtime_put_sync(), which will call scsi_runtime_idle(), which will now call pm_runtime_autosuspend(). > put_device(&sdkp->dev); > } > > @@ -2755,7 +2748,6 @@ static int sd_remove(struct device *dev) > struct scsi_disk *sdkp; > > sdkp = dev_get_drvdata(dev); > - scsi_autopm_get_device(sdkp->device); This line should be kept as is. The SCSI core uses the incremented usage count to prevent driverless devices from being runtime-suspended. Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/