[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.44L0.1110281444170.2175-100000@iolanthe.rowland.org>
Date: Fri, 28 Oct 2011 14:51:17 -0400 (EDT)
From: Alan Stern <stern@...land.harvard.edu>
To: "Rafael J. Wysocki" <rjw@...k.pl>
cc: Lin Ming <ming.m.lin@...el.com>, Jeff Garzik <jgarzik@...ox.com>,
"linux-ide@...r.kernel.org" <linux-ide@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Tejun Heo <tj@...nel.org>,
Priyanka Gupta <ankaguptaca@...il.com>,
"Zhang, Rui" <rui.zhang@...el.com>,
"Huang, Ying" <ying.huang@...el.com>,
Linux PM list <linux-pm@...r.kernel.org>
Subject: Re: [RFC] ata port runtime pm
On Fri, 28 Oct 2011, Rafael J. Wysocki wrote:
> On Friday, October 28, 2011, Lin Ming wrote:
> > On Fri, 2011-10-28 at 11:37 +0800, Jeff Garzik wrote:
> > > On 10/27/2011 11:21 PM, Lin Ming wrote:
> > > > @@ -3208,6 +3209,11 @@ int ata_scsi_queuecmd(struct Scsi_Host *shost, struct scsi_cmnd *cmd)
> > > >
> > > > ap = ata_shost_to_port(shost);
> > > >
> > > > + if (pm_runtime_suspended(&ap->tdev))
> > > > + pm_runtime_resume(&ap->tdev);
> > > > + pm_runtime_mark_last_busy(&ap->tdev);
> > > > + pm_request_autosuspend(&ap->tdev);
> > > > +
> > > > spin_lock_irqsave(ap->lock, irq_flags);
> > > >
> > >
> > >
> > > Putting this into the core command dispatch fast-path is rather
> > > disappointing. That's at least one additional lock, plus some atomic
> > > instructions and tests.
And it calls pm_runtime_resume(), which requires process context, from
within a SCSI queuecmd routine, which runs in interrupt context.
> > Maybe move suspend request to the resume function, as below.
> >
> > static int ata_port_runtime_resume(struct device *dev)
> > {
> > struct ata_port *ap = to_ata_port(dev);
> > int rc;
> >
> > rc = ata_port_request_pm(ap, PMSG_ON, ATA_EH_RESET,
> > ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET, 1);
> >
> > pm_runtime_mark_last_busy(dev);
> > pm_request_autosuspend(dev);
> >
> > return rc;
> > }
> >
> > Then the fast-path looks like,
> >
> > @@ -3208,6 +3209,9 @@ int ata_scsi_queuecmd(struct Scsi_Host *shost,
> > struct scsi_cmnd *cmd)
> >
> > ap = ata_shost_to_port(shost);
> >
> > + if (pm_runtime_suspended(&ap->tdev))
> > + pm_runtime_resume(&ap->tdev);
> > +
Unfortunately that won't work. It's got a race; the device might be
active when the pm_runtime_suspended() test runs and then it might
suspend immediately after.
> > spin_lock_irqsave(ap->lock, irq_flags);
> >
> > ata_scsi_dump_cdb(ap, cmd);
> >
> > What do you think?
See the example code in section 9 of
Documentation/power/runtime_pm.txt for the outline of a general
approach.
Alan Stern
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists