Re: [PATCH 1/1] driver core: disable device's runtime pm duringshutdown

From: NeilBrown
Date: Sun Dec 04 2011 - 23:54:08 EST


On Mon, 5 Dec 2011 11:26:40 +0800 Ming Lei <tom.leiming@xxxxxxxxx> wrote:

> Hi,
>
> On Mon, Dec 5, 2011 at 5:56 AM, NeilBrown <neilb@xxxxxxx> 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.
> >
> > So here is a device that should *not* have pm disabled at shutdown.
> >
> > So I feel this fix is a little too heavy-handed.
>
> Maybe the device's runtime PM should not be disabled if
> there is no ->shutdown defined in its driver, how about the blew?

Thanks, but that won't actually help.

dev->bus->shutdown is i2c_device_shutdown so there is a shutdown method.
However i2c_device_shutdown just finds the driver can calls
driver->shutdown(), and that is the 'shutdown' that is NULL.

Thanks,
NeilBrown



>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index d8b3d89..ca30659 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -1743,14 +1743,16 @@ void device_shutdown(void)
> */
> list_del_init(&dev->kobj.entry);
> spin_unlock(&devices_kset->list_lock);
> - /* Disable all device's runtime power management */
> - pm_runtime_disable(dev);
>
> + /* Disable the device's runtime power management if
> + * it is to be shutdown*/
> if (dev->bus && dev->bus->shutdown) {
> dev_dbg(dev, "shutdown\n");
> + pm_runtime_disable(dev);
> dev->bus->shutdown(dev);
> } else if (dev->driver && dev->driver->shutdown) {
> dev_dbg(dev, "shutdown\n");
> + pm_runtime_disable(dev);
> dev->driver->shutdown(dev);
> }
> put_device(dev);
>
>
> > 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?
> >
> > Suggestions?
> >
> > Thanks,
> > NeilBrown
>
>
> thanks,

Attachment: signature.asc
Description: PGP signature