aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/hosts.c
diff options
context:
space:
mode:
authorMika Westerberg <mika.westerberg@linux.intel.com>2016-02-18 03:54:13 -0500
committerTejun Heo <tj@kernel.org>2016-02-19 10:52:45 -0500
commit5c6fab9d558470b4e53c6d113f7dbcb31049ffc5 (patch)
tree13253ccc8e2f0fc4b5364100ec8b0ceb02dd186e /drivers/scsi/hosts.c
parent356fd2663cff131fb9db573a3e45830778cfdbdd (diff)
scsi: Drop runtime PM usage count after host is added
Runtime PM of the SCSI host is already handled by calls to scsi_autopm_get_host() and scsi_autopm_put_host() from appropriate places whenever the host needs to be powered on. This works fine when there is device connected to the host as once it runtime suspends the host will too. However, if there is no device connected the host is never runtime suspended (the usage counter is always 0). Allow runtime suspend of host even if it has no devices connected by calling scsi_autopm_put_host() at the end of scsi_add_host_with_dma(). We temporarily increase runtime PM usage counter first so call to scsi_autopm_put_host() will result idle request to be scheduled for the device. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'drivers/scsi/hosts.c')
-rw-r--r--drivers/scsi/hosts.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 82ac1cd818ac..e46bf4d152a0 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -250,6 +250,12 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev,
250 if (error) 250 if (error)
251 goto out_destroy_freelist; 251 goto out_destroy_freelist;
252 252
253 /*
254 * Increase usage count temporarily here so that calling
255 * scsi_autopm_put_host() will trigger runtime idle if there is
256 * nothing else preventing suspending the device.
257 */
258 pm_runtime_get_noresume(&shost->shost_gendev);
253 pm_runtime_set_active(&shost->shost_gendev); 259 pm_runtime_set_active(&shost->shost_gendev);
254 pm_runtime_enable(&shost->shost_gendev); 260 pm_runtime_enable(&shost->shost_gendev);
255 device_enable_async_suspend(&shost->shost_gendev); 261 device_enable_async_suspend(&shost->shost_gendev);
@@ -290,6 +296,7 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev,
290 goto out_destroy_host; 296 goto out_destroy_host;
291 297
292 scsi_proc_host_add(shost); 298 scsi_proc_host_add(shost);
299 scsi_autopm_put_host(shost);
293 return error; 300 return error;
294 301
295 out_destroy_host: 302 out_destroy_host: