On 20 August 2012 15:49, MyungJoo Ham <myungjoo....@samsung.com> wrote:

> > This patch adds suspend and resume apis needed
> > for devices which can idle. Suspend/resume apis
> > are called from driver to suspend/resume devfreq
> > load monitoring of that device.
> >
> > Signed-off-by: Rajagopal Venkat <rajagopal.ven...@linaro.org>
>
> 1. Some devfreq devices may need their own code to do suspend/resume; e.g.,
> setting a specific frequency for suspend (especially with suspend-to-RAM).
>

Assuming device driver is using devfreq ondemand governor, when driver
detects idleness perhaps through runtime-pm, let driver set specific
frequency
and then suspend its devfreq. Also let driver resume its devfreq when device
is back online.


> 2. Are these new APIs (devfreq_suspend/resume_device()) intended to be
> used by runtime_pm and pm(Suspend-to-RAM) callbacks of the parent devices?
> If so, could you consider use the structure of runtime-pm (I don't have
> an idea on how to do this for now)? For example, when a device is being
> suspended, devfreq device's suspend is also called without calling it
> explicitly at the device driver's suspend callback.
>

These new apis are not coupled with runtime-pm. Though runtime-pm is good
candidate for detecting idleness, drivers can have their own logic. So its
at
device drivers discretion when to call devfreq_suspend_device() and
devfreq_resume_device().


> 3. As in the patch 1/3, could you consider to integrate class-wide
> features in devfreq.c, not in a governor?
>
>
Yes, these apis are part of devfreq core. Core sends events to governors
for taking specific actions. Again, only governor knows what to do with
DEVFREQ_GOV_SUSPEND and DEVFREQ_GOV_RESUME events.
For instance ondemand cancels/queues delayed work.


> Cheers!
> MyungJoo
>
> > ---
> >  drivers/devfreq/devfreq.c                 | 30
> ++++++++++++++++++++++++++++++
> >  drivers/devfreq/governor_simpleondemand.c | 15 +++++++++++++++
> >  include/linux/devfreq.h                   | 16 ++++++++++++++++
> >  3 files changed, 61 insertions(+)
> >
> > diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> > index 5aa23a8..375b5aa1 100644
> > --- a/drivers/devfreq/devfreq.c
> > +++ b/drivers/devfreq/devfreq.c
> > @@ -233,6 +233,36 @@ int devfreq_remove_device(struct devfreq *devfreq)
> >  }
> >  EXPORT_SYMBOL(devfreq_remove_device);
> >
> > +/**
> > + * devfreq_suspend_device() - Suspend devfreq of a device.
> > + * @devfreq  the devfreq instance to be suspended
> > + */
> > +int devfreq_suspend_device(struct devfreq *devfreq)
> > +{
> > +     if (!devfreq)
> > +             return -EINVAL;
> > +
> > +     devfreq->governor->event_handler(devfreq, DEVFREQ_GOV_SUSPEND);
> > +
> > +     return 0;
> > +}
> > +EXPORT_SYMBOL(devfreq_suspend_device);
> > +
> > +/**
> > + * devfreq_resume_device() - Resume devfreq of a device.
> > + * @devfreq  the devfreq instance to be resumed
> > + */
> > +int devfreq_resume_device(struct devfreq *devfreq)
> > +{
> > +     if (!devfreq)
> > +             return -EINVAL;
> > +
> > +     devfreq->governor->event_handler(devfreq, DEVFREQ_GOV_RESUME);
> > +
> > +     return 0;
> > +}
> > +EXPORT_SYMBOL(devfreq_resume_device);
> > +
> >  static ssize_t show_governor(struct device *dev,
> >                            struct device_attribute *attr, char *buf)
> >  {
> > diff --git a/drivers/devfreq/governor_simpleondemand.c
> b/drivers/devfreq/governor_simpleondemand.c
> > index 7c70c30..95e4db9 100644
> > --- a/drivers/devfreq/governor_simpleondemand.c
> > +++ b/drivers/devfreq/governor_simpleondemand.c
> > @@ -221,6 +221,21 @@ static int devfreq_simple_ondemand_func(struct
> devfreq *df,
> >               ondemand_exit(df);
> >               break;
> >
> > +     case DEVFREQ_GOV_SUSPEND:
> > +             if (delayed_work_pending(&data->work)) {
> > +                     data->stop_queuing = true;
> > +                     cancel_delayed_work_sync(&data->work);
> > +             }
> > +             break;
> > +
> > +     case DEVFREQ_GOV_RESUME:
> > +             if (!delayed_work_pending(&data->work)) {
> > +                     data->stop_queuing = false;
> > +                     queue_delayed_work(devfreq_wq, &data->work,
> > +                             msecs_to_jiffies(df->profile->polling_ms));
> > +             }
> > +             break;
> > +
> >       case DEVFREQ_GOV_LIMITS:
> >               if (delayed_work_pending(&data->work)) {
> >                       mutex_lock(&df->lock);
> > diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
> > index 600cc2e..7c6517f 100644
> > --- a/include/linux/devfreq.h
> > +++ b/include/linux/devfreq.h
> > @@ -56,6 +56,8 @@ struct devfreq_dev_status {
> >  #define DEVFREQ_GOV_START                    0x1
> >  #define DEVFREQ_GOV_STOP                     0x2
> >  #define DEVFREQ_GOV_LIMITS                   0x3
> > +#define DEVFREQ_GOV_SUSPEND                  0x4
> > +#define DEVFREQ_GOV_RESUME                   0x5
> >
> >  /**
> >   * struct devfreq_dev_profile - Devfreq's user device profile
> > @@ -155,6 +157,10 @@ extern struct devfreq *devfreq_add_device(struct
> device *dev,
> >                                 void *data);
> >  extern int devfreq_remove_device(struct devfreq *devfreq);
> >
> > +extern int devfreq_suspend_device(struct devfreq *devfreq);
> > +
> > +extern int devfreq_resume_device(struct devfreq *devfreq);
> > +
> >  /* Helper functions for devfreq user device driver with OPP. */
> >  extern struct opp *devfreq_recommended_opp(struct device *dev,
> >                                          unsigned long *freq, u32 flags);
> > @@ -207,6 +213,16 @@ static int devfreq_remove_device(struct devfreq
> *devfreq)
> >       return 0;
> >  }
> >
> > +static int devfreq_suspend_device(struct devfreq *devfreq)
> > +{
> > +     return 0;
> > +}
> > +
> > +extern int devfreq_resume_device(struct devfreq *devfreq)
> > +{
> > +     return 0;
> > +}
> > +
> >  static struct opp *devfreq_recommended_opp(struct device *dev,
> >                                          unsigned long *freq, u32 flags)
> >  {
> > --
> > 1.7.11.3
> >
>



-- 
Regards,
Rajagopal
_______________________________________________
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev

Reply via email to