From: Lukasz Luba <l.luba@partner.samsung.com>
To: Chanwoo Choi <cw00.choi@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: tjakobi@math.uni-bielefeld.de, myungjoo.ham@samsung.com,
kyungmin.park@samsung.com, rjw@rjwysocki.net,
len.brown@intel.com, pavel@ucw.cz, gregkh@linuxfoundation.org,
keescook@chromium.org, anton@enomsg.org, ccross@android.com,
tony.luck@intel.com, robh+dt@kernel.org, mark.rutland@arm.com,
kgene@kernel.org, krzk@kernel.org, m.szyprowski@samsung.com,
b.zolnierkie@samsung.com
Subject: Re: [PATCH v2 2/5] devfreq: add support for suspend/resume of a devfreq device
Date: Tue, 4 Dec 2018 10:39:12 +0100 [thread overview]
Message-ID: <f88c4bda-d2d4-0f5c-67ea-eecf32c2fe4c@partner.samsung.com> (raw)
In-Reply-To: <5C06124B.5030409@samsung.com>
Hi Chanwoo,
On 12/4/18 6:36 AM, Chanwoo Choi wrote:
> Hi Lukasz,
>
> Looks good to me. But, I add the some comments.
> If you will fix it, feel free to add my tag:
> Reviewed-by: Chanwoo choi <cw00.choi@samsung.com>
>
> On 2018년 12월 03일 23:31, Lukasz Luba wrote:
>> The patch prepares devfreq device for handling suspend/resume
>> functionality. The new fields will store needed information during this
>
> nitpick. Remove unneeded space. There are two spaces between '.' and 'The new'.
>
>> process. Devfreq framework handles opp-suspend DT entry and there is no
>
> ditto.
>
>> need of modyfications in the drivers code. It uses atomic variables to
>
> ditto.
>
>> make sure no race condition affects the process.
>>
>> The patch is based on earlier work by Tobias Jakobi.
>
> Please remove it from each patch description.
>
Comments addressed in next v3 patch set. Thank you.
Regards,
Lukasz
>>
>> 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 | 51 +++++++++++++++++++++++++++++++++++++++--------
>> include/linux/devfreq.h | 7 +++++++
>> 2 files changed, 50 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
>> index a9fd61b..36bed24 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)
>> - return 0;
>> + if (devfreq->governor) {
>> + ret = devfreq->governor->event_handler(devfreq,
>> + DEVFREQ_GOV_SUSPEND, NULL);
>> + if (ret)
>> + return ret;
>> + }
>> +
>> + if (devfreq->suspend_freq) {
>> + if (atomic_inc_return(&devfreq->suspend_count) > 1)
>> + return 0;
>> +
>> + ret = devfreq_set_target(devfreq, devfreq->suspend_freq, 0);
>> + if (ret)
>> + return ret;
>> + }
>>
>> - return devfreq->governor->event_handler(devfreq,
>> - DEVFREQ_GOV_SUSPEND, NULL);
>> + 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)
>> - return 0;
>> + if (devfreq->resume_freq) {
>> + if (atomic_dec_return(&devfreq->suspend_count) >= 1)
>> + return 0;
>>
>> - return devfreq->governor->event_handler(devfreq,
>> - DEVFREQ_GOV_RESUME, NULL);
>> + 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;
>>
>
>
next prev parent reply other threads:[~2018-12-04 9:39 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20181203143127eucas1p2604fc066139a32fdffe996212b42b40e@eucas1p2.samsung.com>
2018-12-03 14:31 ` [PATCH v2 0/5] devfreq: handle suspend/resume Lukasz Luba
[not found] ` <CGME20181203143129eucas1p2955b6becc60ee57110cbc52f6e4f60c5@eucas1p2.samsung.com>
2018-12-03 14:31 ` [PATCH v2 1/5] devfreq: refactor set_target frequency function Lukasz Luba
2018-12-04 4:39 ` Chanwoo Choi
2018-12-04 5:43 ` Chanwoo Choi
2018-12-04 9:36 ` Lukasz Luba
[not found] ` <CGME20181203143131eucas1p217f22ac6d19682a54a57658a06980914@eucas1p2.samsung.com>
2018-12-03 14:31 ` [PATCH v2 2/5] devfreq: add support for suspend/resume of a devfreq device Lukasz Luba
2018-12-04 5:36 ` Chanwoo Choi
2018-12-04 5:43 ` Chanwoo Choi
2018-12-04 6:10 ` Chanwoo Choi
2018-12-04 9:53 ` Lukasz Luba
2018-12-05 0:09 ` Chanwoo Choi
2018-12-05 11:07 ` Lukasz Luba
2018-12-04 9:39 ` Lukasz Luba [this message]
2018-12-09 9:00 ` Pavel Machek
[not found] ` <CGME20181203143132eucas1p128c029a7c7461e1127924a08e4a71811@eucas1p1.samsung.com>
2018-12-03 14:31 ` [PATCH v2 3/5] devfreq: add devfreq_suspend/resume() functions Lukasz Luba
2018-12-04 6:19 ` Chanwoo Choi
2018-12-04 9:44 ` Lukasz Luba
[not found] ` <CGME20181203143134eucas1p1edd70b0f4dca115f6f154555d8829427@eucas1p1.samsung.com>
2018-12-03 14:31 ` [PATCH v2 4/5] drivers: power: suspend: call devfreq suspend/resume Lukasz Luba
[not found] ` <CGME20181203143135eucas1p165fe6183ae90de7906f9683cb41ff4c1@eucas1p1.samsung.com>
2018-12-03 14:31 ` [PATCH v2 5/5] arm: dts: exynos4: opp-suspend in DMC and leftbus Lukasz Luba
2018-12-03 17:22 ` Krzysztof Kozlowski
2018-12-03 17:48 ` 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=f88c4bda-d2d4-0f5c-67ea-eecf32c2fe4c@partner.samsung.com \
--to=l.luba@partner.samsung.com \
--cc=anton@enomsg.org \
--cc=b.zolnierkie@samsung.com \
--cc=ccross@android.com \
--cc=cw00.choi@samsung.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=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).