All of lore.kernel.org
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>, Greg KH <greg@kroah.com>,
	Peter Chen <peter.chen@freescale.com>, <gregkh@suse.de>,
	<linux-kernel@vger.kernel.org>, <linux-pm@vger.kernel.org>,
	<hzpeterchen@gmail.com>, Igor Grinberg <grinberg@compulab.co.il>
Subject: Re: [PATCH 1/1] driver core: disable device's runtime pm during shutdown
Date: Mon, 5 Dec 2011 14:37:17 +1100	[thread overview]
Message-ID: <20111205143717.13cf6015@notabene.brown> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1112042133470.7508-100000@netrider.rowland.org>

[-- Attachment #1: Type: text/plain, Size: 2902 bytes --]

On Sun, 4 Dec 2011 21:42:02 -0500 (EST) Alan Stern
<stern@rowland.harvard.edu> wrote:

> On Mon, 5 Dec 2011, NeilBrown wrote:
> 
> > Hi,
> >  this patches causes a problem for me.
> > 
> > Specifically it makes it impossible to power-down a device which uses twl4030
> > for power control on an omap3 processor.
> > 
> > To perform the shutdown we need to send a command over the i2c bus.
> > The relevant bus is called omap_i2c.1 and this is normally in suspend mode.
> > When a request is sent, omap_i2c_xfer uses pm_runtime_get_sync to wake it up,
> > performs the transfer, then calls pm_runtime_put to let it go back to sleep.
> > 
> > So it is asleep when the new pm_runtime_disable() call is made, so it stays
> > asleep, omap_i2c_xfer cannot wake it, the transfer doesn't happen and the
> > system doesn't get powered off.
> 
> In other words, to perform the system shutdown you need to send a 
> command over the i2c bus after the bus controller's shutdown routine 
> has been called?

Correct.
Though in this case the i2c bus doesn't have a shutdown routine so it doesn't
cause a problem.  It is only the inability to pm_resume that is a problem.


> 
> > So here is a device that should *not* have pm disabled at shutdown.
> 
> Or maybe it shouldn't be shut down at all.

Maybe not.  Current 'device_shutdown()' shuts down every device.
I guess having a "don't shutdown at power-off" flag could be used to solve
the problem.

> 
> > So I feel this fix is a little too heavy-handed.
> > I don't fully understand the problem scenario described above but it seems to
> > me that if the auto-suspend timer can fire after the hardware has been shut
> > down, then maybe the hardware-shutdown should be disabling that timer.  Maybe?
> 
> That's not robust.  The timer can be restarted, and there are other 
> ways of initiating runtime PM besides the timer.

Still, shouldn't they notice that the hardware has been shutdown and so not
do anything?

> 
> > Suggestions?
> 
> Can the shutdown routine for the i2c controller simply call
> pm_runtime_enable()?

No.
The shutdown routine is in drivers/mfd/twl4030-power.c (not in mainline
currently but there are various patches floating around that add
twl4030_poweroff, and this is the obviously-correct place for the code).
It has a 'struct i2c_adapter' device.
The device that needs to have pm_runtime_enable called on it is a 'struct
platform_device' that is linked through the dev_data of the i2c_adapter.

i.e. only omap-i2c specific code knows how to find the device that needs to
be enabled.  The twl4030 code doesn't.

So even if we had a used_for_shutdown flag in dev_pm_info I don't know how we
would manage to set it for the right device.... unless we had a dev_pm_ops
method to ask a device to set it on all devices it depends on.  Sounds messy.

Thanks,
NeilBrown

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

  reply	other threads:[~2011-12-05  3:37 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-14  0:43 [PATCH 1/1] driver core: disable device's runtime pm during shutdown Peter Chen
2011-11-14  9:54 ` Ming Lei
2011-11-14 22:28   ` Rafael J. Wysocki
2011-11-14 22:27 ` Rafael J. Wysocki
2011-11-15  0:59   ` Greg KH
2011-11-15 23:16     ` Rafael J. Wysocki
2011-12-04 21:56       ` NeilBrown
2011-12-05  2:42         ` Alan Stern
2011-12-05  3:37           ` NeilBrown [this message]
2011-12-05  3:26         ` Ming Lei
2011-12-05  4:42           ` Chen Peter-B29397
2011-12-05  5:12             ` Ming Lei
2011-12-05  9:01               ` Ming Lei
2011-12-05  9:05                 ` Ming Lei
2011-12-05 16:02                   ` Alan Stern
2011-12-05 18:35                     ` NeilBrown
2011-12-05 20:55                       ` Alan Stern
2011-12-05 22:32                         ` Rafael J. Wysocki
2011-12-06 15:26                           ` [PATCH] Driver core: leave runtime PM enabled during system shutdown Alan Stern
2011-12-06 21:34                             ` NeilBrown
2011-12-06 21:48                             ` Greg KH
2011-12-06 22:05                               ` Rafael J. Wysocki
2011-12-06 22:03                             ` Rafael J. Wysocki
2011-12-05  4:53           ` [PATCH 1/1] driver core: disable device's runtime pm during shutdown NeilBrown
2011-12-05  5:53             ` Chen Peter-B29397
2011-12-05  8:08               ` NeilBrown
2011-12-05  8:32                 ` Chen Peter-B29397
2011-12-05  8:52                   ` NeilBrown
2011-12-05  3:29         ` Chen Peter-B29397
2011-12-05  5:09           ` NeilBrown

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=20111205143717.13cf6015@notabene.brown \
    --to=neilb@suse.de \
    --cc=greg@kroah.com \
    --cc=gregkh@suse.de \
    --cc=grinberg@compulab.co.il \
    --cc=hzpeterchen@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=peter.chen@freescale.com \
    --cc=rjw@sisk.pl \
    --cc=stern@rowland.harvard.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.