linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lin Ming <ming.m.lin@intel.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>,
	Jeff Garzik <jgarzik@pobox.com>,
	"linux-ide@vger.kernel.org" <linux-ide@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Tejun Heo <tj@kernel.org>, Priyanka Gupta <ankaguptaca@gmail.com>,
	"Zhang, Rui" <rui.zhang@intel.com>,
	"Huang, Ying" <ying.huang@intel.com>,
	Linux PM list <linux-pm@vger.kernel.org>
Subject: Re: [RFC] ata port runtime pm
Date: Tue, 01 Nov 2011 16:12:25 +0800	[thread overview]
Message-ID: <1320135145.3489.19.camel@minggr> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1110281444170.2175-100000@iolanthe.rowland.org>

On Sat, 2011-10-29 at 02:51 +0800, Alan Stern wrote:
> 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.

Hi, 

Thanks to point this out. I change the code to do ata port runtime
suspend/resume through scsi layer.

scsi host runtime suspend/resume framework is already there(scsi_pm.c).
So I only need to insert hooks for ata port in
scsi_runtime_suspend/resume(...).

But I found a live lock when testing my patch.

<scsi host runtime suspend>
  scsi_autopm_put_host
    pm_runtime_put_sync
      <scsi_host runtime pm status updated to RPM_SUSPENDING>
      ......
        <call libata hook to do suspend>
          <wake up scsi EH to handle suspend>
          <wait for scsi EH ...>

<scsi EH wake up>
  scsi_error_handler
    <resume scsi host>
    scsi_autopm_get_host
      pm_runtime_get_sync
      .....
        <sleep to wait for the ongoing scsi host suspend> 

libata schedules scsi EH to handle suspend, then dead lock happens
because scsi EH in turn waits for the ongoing suspend.

Any idea how to resolve this dead lock?

Thanks,
Lin Ming

  reply	other threads:[~2011-11-01  8:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-28  3:21 [RFC] ata port runtime pm Lin Ming
2011-10-28  3:37 ` Jeff Garzik
2011-10-28  5:36   ` Lin Ming
2011-10-28 17:31     ` Rafael J. Wysocki
2011-10-28 18:51       ` Alan Stern
2011-11-01  8:12         ` Lin Ming [this message]
2011-11-01 19:34           ` Alan Stern
  -- strict thread matches above, loose matches on Subject: below --
2011-10-28  3:20 Lin Ming

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=1320135145.3489.19.camel@minggr \
    --to=ming.m.lin@intel.com \
    --cc=ankaguptaca@gmail.com \
    --cc=jgarzik@pobox.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@sisk.pl \
    --cc=rui.zhang@intel.com \
    --cc=stern@rowland.harvard.edu \
    --cc=tj@kernel.org \
    --cc=ying.huang@intel.com \
    /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).