lkml.org 
[lkml]   [2011]   [Dec]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    SubjectRe: [PATCH 1/1] driver core: disable device's runtime pm during shutdown
    On Mon, 5 Dec 2011 11:02:38 -0500 (EST) Alan Stern
    <stern@rowland.harvard.edu> wrote:

    > On Mon, 5 Dec 2011, Ming Lei wrote:
    >
    > > Sorry, the above is line wrapped badly, see the below:
    > >
    > > diff --git a/drivers/base/core.c b/drivers/base/core.c
    > > index d8b3d89..96b266c 100644
    > > --- a/drivers/base/core.c
    > > +++ b/drivers/base/core.c
    > > @@ -1743,8 +1743,9 @@ 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);
    > > +
    > > + /* put device into active state and forbit runtime pm */
    > > + pm_runtime_forbid(dev);
    > >
    > > if (dev->bus && dev->bus->shutdown) {
    > > dev_dbg(dev, "shutdown\n");
    >
    > We don't want to put devices into the active state when it's not
    > necessary. A better approach would be:
    >
    > /* Don't allow any more runtime suspends */
    > pm_runtime_get_noresume(dev);
    > pm_runtime_barrier(dev);
    >
    > Alan Stern

    That sounds like a reasonable approach if we really need to do something at
    this level. But is this the only place that ->shutdown methods are called
    from? If they are called from elsewhere, would those places need the
    same pm_runtime protection?

    BTW I was wrong when I said that only calling pm_runtime_disable if there was
    a ->shutdown function would not work for me. i.e. the following patch does
    solve my particular issue (though I'm not sure it is "right").
    I was getting confused by the two different devices: the i2c device and the
    platform device.
    The i2c device has a ->shutdown which does nothing, but doesn't need to wake
    up.
    The platform device is the one which needs to wake up, but it doesn't have a
    ->shutdown function is this patch causes it not have pm_runtime disabled.

    Thanks,
    NeilBrown

    diff --git a/drivers/base/core.c b/drivers/base/core.c
    index d8b3d89..b9aa5d2 100644
    --- a/drivers/base/core.c
    +++ b/drivers/base/core.c
    @@ -1743,13 +1743,13 @@ 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);

    if (dev->bus && dev->bus->shutdown) {
    + pm_runtime_disable(dev);
    dev_dbg(dev, "shutdown\n");
    dev->bus->shutdown(dev);
    } else if (dev->driver && dev->driver->shutdown) {
    + pm_runtime_disable(dev);
    dev_dbg(dev, "shutdown\n");
    dev->driver->shutdown(dev);
    }[unhandled content-type:application/pgp-signature]
    \
     
     \ /
      Last update: 2011-12-05 19:39    [W:0.039 / U:1.416 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site