linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Chanwoo Choi <cw00.choi@samsung.com>
To: Lukasz Luba <l.luba@partner.samsung.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-pm@vger.kernel.org, devicetree@vger.kernel.org
Cc: mark.rutland@arm.com, len.brown@intel.com, tony.luck@intel.com,
	keescook@chromium.org, b.zolnierkie@samsung.com,
	gregkh@linuxfoundation.org, anton@enomsg.org, rjw@rjwysocki.net,
	robh+dt@kernel.org, tjakobi@math.uni-bielefeld.de,
	kyungmin.park@samsung.com, myungjoo.ham@samsung.com,
	kgene@kernel.org, pavel@ucw.cz, ccross@android.com,
	krzk@kernel.org, m.szyprowski@samsung.com
Subject: Re: [PATCH v3 2/5] devfreq: add support for suspend/resume of a devfreq device
Date: Thu, 06 Dec 2018 10:17:52 +0900	[thread overview]
Message-ID: <5C0878C0.4060500@samsung.com> (raw)
In-Reply-To: <1544007956-28889-3-git-send-email-l.luba@partner.samsung.com>

Hi Lukasz,

On 2018년 12월 05일 20:05, Lukasz Luba wrote:
> The patch prepares devfreq device for handling suspend/resume
> functionality. The new fields will store needed information during this
> process. Devfreq framework handles opp-suspend DT entry and there is no
> need of modyfications in the drivers code. It uses atomic variables to
> make sure no race condition affects the process.
> 
> Suggested-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
> Suggested-by: Chanwoo Choi <cw00.choi@samsung.com>
> Signed-off-by: Lukasz Luba <l.luba@partner.samsung.com>
> ---
>  drivers/devfreq/devfreq.c | 47 +++++++++++++++++++++++++++++++++++++++++------
>  include/linux/devfreq.h   |  7 +++++++
>  2 files changed, 48 insertions(+), 6 deletions(-)

Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>

> 
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index a9fd61b..46517b6 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -316,6 +316,10 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,
>  			"Couldn't update frequency transition information.\n");
>  
>  	devfreq->previous_freq = new_freq;
> +
> +	if (devfreq->suspend_freq)
> +		devfreq->resume_freq = cur_freq;
> +
>  	return err;
>  }
>  
> @@ -667,6 +671,9 @@ struct devfreq *devfreq_add_device(struct device *dev,
>  	}
>  	devfreq->max_freq = devfreq->scaling_max_freq;
>  
> +	devfreq->suspend_freq = dev_pm_opp_get_suspend_opp_freq(dev);
> +	atomic_set(&devfreq->suspend_count, 0);
> +
>  	dev_set_name(&devfreq->dev, "devfreq%d",
>  				atomic_inc_return(&devfreq_no));
>  	err = device_register(&devfreq->dev);
> @@ -867,14 +874,28 @@ EXPORT_SYMBOL(devm_devfreq_remove_device);
>   */
>  int devfreq_suspend_device(struct devfreq *devfreq)
>  {
> +	int ret;
> +
>  	if (!devfreq)
>  		return -EINVAL;
>  
> -	if (!devfreq->governor)
> +	if (atomic_inc_return(&devfreq->suspend_count) > 1)
>  		return 0;
>  
> -	return devfreq->governor->event_handler(devfreq,
> -				DEVFREQ_GOV_SUSPEND, NULL);
> +	if (devfreq->governor) {
> +		ret = devfreq->governor->event_handler(devfreq,
> +					DEVFREQ_GOV_SUSPEND, NULL);
> +		if (ret)
> +			return ret;
> +	}
> +
> +	if (devfreq->suspend_freq) {
> +		ret = devfreq_set_target(devfreq, devfreq->suspend_freq, 0);
> +		if (ret)
> +			return ret;
> +	}
> +
> +	return 0;
>  }
>  EXPORT_SYMBOL(devfreq_suspend_device);
>  
> @@ -888,14 +909,28 @@ EXPORT_SYMBOL(devfreq_suspend_device);
>   */
>  int devfreq_resume_device(struct devfreq *devfreq)
>  {
> +	int ret;
> +
>  	if (!devfreq)
>  		return -EINVAL;
>  
> -	if (!devfreq->governor)
> +	if (atomic_dec_return(&devfreq->suspend_count) >= 1)
>  		return 0;
>  
> -	return devfreq->governor->event_handler(devfreq,
> -				DEVFREQ_GOV_RESUME, NULL);
> +	if (devfreq->resume_freq) {
> +		ret = devfreq_set_target(devfreq, devfreq->resume_freq, 0);
> +		if (ret)
> +			return ret;
> +	}
> +
> +	if (devfreq->governor) {
> +		ret = devfreq->governor->event_handler(devfreq,
> +					DEVFREQ_GOV_RESUME, NULL);
> +		if (ret)
> +			return ret;
> +	}
> +
> +	return 0;
>  }
>  EXPORT_SYMBOL(devfreq_resume_device);
>  
> diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
> index e4963b0..d985199 100644
> --- a/include/linux/devfreq.h
> +++ b/include/linux/devfreq.h
> @@ -131,6 +131,9 @@ struct devfreq_dev_profile {
>   * @scaling_min_freq:	Limit minimum frequency requested by OPP interface
>   * @scaling_max_freq:	Limit maximum frequency requested by OPP interface
>   * @stop_polling:	 devfreq polling status of a device.
> + * @suspend_freq:	 frequency of a device set during suspend phase.
> + * @resume_freq:	 frequency of a device set in resume phase.
> + * @suspend_count:	 suspend requests counter for a device.
>   * @total_trans:	Number of devfreq transitions
>   * @trans_table:	Statistics of devfreq transitions
>   * @time_in_state:	Statistics of devfreq states
> @@ -167,6 +170,10 @@ struct devfreq {
>  	unsigned long scaling_max_freq;
>  	bool stop_polling;
>  
> +	unsigned long suspend_freq;
> +	unsigned long resume_freq;
> +	atomic_t suspend_count;
> +
>  	/* information for device frequency transition */
>  	unsigned int total_trans;
>  	unsigned int *trans_table;
> 


-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2018-12-06  1:18 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20181205110616eucas1p1e0e17b0c6a96c3b6d77516d4b02de8b1@eucas1p1.samsung.com>
2018-12-05 11:05 ` [PATCH v3 0/5] devfreq: handle suspend/resume Lukasz Luba
2018-12-05 11:05   ` [PATCH v3 1/5] devfreq: refactor set_target frequency function Lukasz Luba
2018-12-11  2:08     ` MyungJoo Ham
2018-12-05 11:05   ` [PATCH v3 2/5] devfreq: add support for suspend/resume of a devfreq device Lukasz Luba
2018-12-06  1:17     ` Chanwoo Choi [this message]
2018-12-06 10:13       ` Lukasz Luba
2018-12-11  1:43       ` MyungJoo Ham
2018-12-11  8:26         ` Lukasz Luba
2018-12-05 11:05   ` [PATCH v3 3/5] devfreq: add devfreq_suspend/resume() functions Lukasz Luba
2018-12-06  1:30     ` Chanwoo Choi
2018-12-11  2:45       ` MyungJoo Ham
2018-12-05 11:05   ` [PATCH v3 4/5] drivers: power: suspend: call devfreq suspend/resume Lukasz Luba
2018-12-13 14:35     ` Lukasz Luba
2018-12-21  0:33       ` MyungJoo Ham
2019-01-02 15:08         ` Lukasz Luba
2019-01-03 10:08           ` Rafael J. Wysocki
2018-12-05 11:05   ` [PATCH v3 5/5] arm: dts: exynos4: opp-suspend in DMC and leftbus Lukasz Luba
2018-12-05 11:12     ` Krzysztof Kozlowski
2018-12-05 11:45       ` Lukasz Luba

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=5C0878C0.4060500@samsung.com \
    --to=cw00.choi@samsung.com \
    --cc=anton@enomsg.org \
    --cc=b.zolnierkie@samsung.com \
    --cc=ccross@android.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=keescook@chromium.org \
    --cc=kgene@kernel.org \
    --cc=krzk@kernel.org \
    --cc=kyungmin.park@samsung.com \
    --cc=l.luba@partner.samsung.com \
    --cc=len.brown@intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=mark.rutland@arm.com \
    --cc=myungjoo.ham@samsung.com \
    --cc=pavel@ucw.cz \
    --cc=rjw@rjwysocki.net \
    --cc=robh+dt@kernel.org \
    --cc=tjakobi@math.uni-bielefeld.de \
    --cc=tony.luck@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).