From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Julian Calaby <julian.calaby@gmail.com>
Cc: linux-block@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
Tejun Heo <tj@kernel.org>,
James Bottomley <James.Bottomley@hansenpartnership.com>,
"Martin K . Petersen" <martin.petersen@oracle.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
linux-ide@vger.kernel.org,
linux-scsi <linux-scsi@vger.kernel.org>
Subject: Re: [PATCH 3/7] scsi: Drop runtime PM usage count after host is added
Date: Fri, 19 Feb 2016 10:18:04 +0200 [thread overview]
Message-ID: <20160219081804.GC1491@lahna.fi.intel.com> (raw)
In-Reply-To: <CAGRGNgUzUDWQ3jDfUuaf8x4G_zsZYe1p2=e_kDR4FkcMp5bUvg@mail.gmail.com>
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.
next prev parent reply other threads:[~2016-02-19 8:18 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-18 8:54 [PATCH 0/7] Runtime PM support for AHCI host controller driver Mika Westerberg
2016-02-18 8:54 ` [PATCH 1/7] block: Add blk_set_runtime_active() Mika Westerberg
2016-02-18 8:54 ` [PATCH 2/7] scsi: Set request queue runtime PM status back to active on resume Mika Westerberg
2016-02-18 8:54 ` [PATCH 3/7] scsi: Drop runtime PM usage count after host is added Mika Westerberg
2016-02-18 22:50 ` Julian Calaby
2016-02-19 8:18 ` Mika Westerberg [this message]
2016-02-18 8:54 ` [PATCH 4/7] ahci: Cache host controller version Mika Westerberg
2016-02-18 8:54 ` [PATCH 5/7] ahci: Convert driver to use modern PM hooks Mika Westerberg
2016-02-18 10:45 ` Andy Shevchenko
2016-02-18 13:12 ` Tejun Heo
2016-02-18 14:41 ` Christoph Hellwig
2016-02-18 8:54 ` [PATCH 6/7] ahci: Add functions to manage runtime PM of AHCI ports Mika Westerberg
2016-02-18 8:54 ` [PATCH 7/7] ahci: Add runtime PM support for the host controller Mika Westerberg
2016-02-18 16:40 ` [PATCH 0/7] Runtime PM support for AHCI host controller driver Tejun Heo
2016-02-19 8:39 ` Mika Westerberg
2016-02-19 15:12 ` Jens Axboe
2016-02-19 15:54 ` Tejun Heo
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=20160219081804.GC1491@lahna.fi.intel.com \
--to=mika.westerberg@linux.intel.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=axboe@kernel.dk \
--cc=julian.calaby@gmail.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=tj@kernel.org \
/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).