Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1337166 > unrolled thread
| Started by | Mika Westerberg <mika.westerberg@linux.intel.com> |
|---|---|
| First post | 2016-02-18 10:00 +0100 |
| Last post | 2016-02-19 09:20 +0100 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 3/7] scsi: Drop runtime PM usage count after host is added Mika Westerberg <mika.westerberg@linux.intel.com> - 2016-02-18 10:00 +0100
Re: [PATCH 3/7] scsi: Drop runtime PM usage count after host is added Julian Calaby <julian.calaby@gmail.com> - 2016-02-19 00:00 +0100
Re: [PATCH 3/7] scsi: Drop runtime PM usage count after host is added Mika Westerberg <mika.westerberg@linux.intel.com> - 2016-02-19 09:20 +0100
| From | Mika Westerberg <mika.westerberg@linux.intel.com> |
|---|---|
| Date | 2016-02-18 10:00 +0100 |
| Subject | [PATCH 3/7] scsi: Drop runtime PM usage count after host is added |
| Message-ID | <r3sBk-311-11@gated-at.bofh.it> |
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> --- drivers/scsi/hosts.c | 7 +++++++ 1 file changed, 7 insertions(+) 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, if (error) goto out_destroy_freelist; + /* + * Increase usage count temporarily here so that calling + * scsi_autopm_put_host() will trigger runtime idle if there is + * nothing else preventing suspending the device. + */ + pm_runtime_get_noresume(&shost->shost_gendev); pm_runtime_set_active(&shost->shost_gendev); pm_runtime_enable(&shost->shost_gendev); device_enable_async_suspend(&shost->shost_gendev); @@ -290,6 +296,7 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev, goto out_destroy_host; scsi_proc_host_add(shost); + scsi_autopm_put_host(shost); return error; out_destroy_host: -- 2.7.0
[toc] | [next] | [standalone]
| From | Julian Calaby <julian.calaby@gmail.com> |
|---|---|
| Date | 2016-02-19 00:00 +0100 |
| Message-ID | <r3FIe-412-15@gated-at.bofh.it> |
| In reply to | #1337166 |
Hi Mika, On Thu, Feb 18, 2016 at 7:54 PM, Mika Westerberg <mika.westerberg@linux.intel.com> wrote: > 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> > --- > drivers/scsi/hosts.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > 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, > if (error) > goto out_destroy_freelist; > > + /* > + * Increase usage count temporarily here so that calling > + * scsi_autopm_put_host() will trigger runtime idle if there is > + * nothing else preventing suspending the device. > + */ > + pm_runtime_get_noresume(&shost->shost_gendev); > pm_runtime_set_active(&shost->shost_gendev); > pm_runtime_enable(&shost->shost_gendev); > device_enable_async_suspend(&shost->shost_gendev); > @@ -290,6 +296,7 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev, > goto out_destroy_host; > > scsi_proc_host_add(shost); > + scsi_autopm_put_host(shost); Would it be cleaner to export the code that runs when the usage counter decrements and call it here? Thanks, -- Julian Calaby Email: julian.calaby@gmail.com Profile: http://www.google.com/profiles/julian.calaby/
[toc] | [prev] | [next] | [standalone]
| From | Mika Westerberg <mika.westerberg@linux.intel.com> |
|---|---|
| Date | 2016-02-19 09:20 +0100 |
| Message-ID | <r3Osa-295-17@gated-at.bofh.it> |
| In reply to | #1337762 |
On Fri, Feb 19, 2016 at 09:50:50AM +1100, Julian Calaby wrote: > Hi Mika, > > On Thu, Feb 18, 2016 at 7:54 PM, Mika Westerberg > <mika.westerberg@linux.intel.com> wrote: > > 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> > > --- > > drivers/scsi/hosts.c | 7 +++++++ > > 1 file changed, 7 insertions(+) > > > > 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, > > if (error) > > goto out_destroy_freelist; > > > > + /* > > + * Increase usage count temporarily here so that calling > > + * scsi_autopm_put_host() will trigger runtime idle if there is > > + * nothing else preventing suspending the device. > > + */ > > + pm_runtime_get_noresume(&shost->shost_gendev); > > pm_runtime_set_active(&shost->shost_gendev); > > pm_runtime_enable(&shost->shost_gendev); > > device_enable_async_suspend(&shost->shost_gendev); > > @@ -290,6 +296,7 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev, > > goto out_destroy_host; > > > > scsi_proc_host_add(shost); > > + scsi_autopm_put_host(shost); > > Would it be cleaner to export the code that runs when the usage > counter decrements and call it here? There actually is no code to run. This just ensures that the device runtime_idle gets called which allows the parent device to runtime suspend (as it returns 0). Alternative way would be just to call pm_request_idle() directly here.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web