Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8036239imu; Tue, 4 Dec 2018 01:40:19 -0800 (PST) X-Google-Smtp-Source: AFSGD/W1AkgkOZ4aYdhs1lFRkFSD5RdRkfA15wudnsz0hmnKiiF1NtmmNCEkfHvqfpmDJf7bHjlu X-Received: by 2002:a62:61c3:: with SMTP id v186mr8037783pfb.55.1543916419689; Tue, 04 Dec 2018 01:40:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543916419; cv=none; d=google.com; s=arc-20160816; b=TZ+xDi1thvRNQyEyxv5ygSB1fmmyn7OvHDIe73vhu+Ja1n97lqYunn5MQgrSjqnZKV i14u5pVNqns10bVINm14usYQi4HL1gtsOjed5MdkUVyn1OCfhX6L9vId3q1A1EEZEZmj 0JEfF05PhV5HciSiwZGg24AkEJQUzAVApLuzjm8QPRDQdCSoOBow77aXYS93VS/HcHBW Ufn7KnrlGJzl8pcHHlK//JXwm5j2lI+1AudQE8PfmO9uwnL1MQLrJ1IooICLQBxnPSD0 a4XKkibiNJJMafdzA/JzSc1Kq0JIxHZzg34L0bK2tQbtzS8YsU5fUUhquJcWZThi6khm 9/dQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type :content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:cc:to:subject:dkim-signature :dkim-filter; bh=C8IBKV9+nMmxFxhmNUDLidx1UPSncRAX3HQbcV0+l6M=; b=ephnLmVuWF/8TocWZ0146+fjwyfEogkQu2qfA0xwoBHLWR1pbbb0cHtuM9cXnjVweA BrUN/qcjUy4Z7wwf4TvFN4327HLr9/rJdwUQDoEmmkcZI74sGmYzCrY73MpLU7xj73Of lVAtwPKB2dSX+U56PHAhzLYVz0/gSQQqgGPid7tez/st7D+blID1aHXcKCnMWIyQlsiG TOboss9n4INZvKWWWFnWPORSNXOyXafzG2gXOU3qBXNw51GGhpfihHQhu741RyySDgRV QqCuk5Rsnu0uxuTDwkzMFcio7A8zEu2+7eBEV+eOlD6+S/tTgXJvao32DO/XIn+cqG5j t6NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=eeLzNH08; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33si3821628plt.228.2018.12.04.01.40.03; Tue, 04 Dec 2018 01:40:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=eeLzNH08; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725956AbeLDJjS (ORCPT + 99 others); Tue, 4 Dec 2018 04:39:18 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:47060 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725613AbeLDJjS (ORCPT ); Tue, 4 Dec 2018 04:39:18 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20181204093917euoutp02fbf44f247b7eb97e140e8b3c406feb64~tF785VfOJ1127011270euoutp02v for ; Tue, 4 Dec 2018 09:39:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20181204093917euoutp02fbf44f247b7eb97e140e8b3c406feb64~tF785VfOJ1127011270euoutp02v DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1543916357; bh=C8IBKV9+nMmxFxhmNUDLidx1UPSncRAX3HQbcV0+l6M=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=eeLzNH08lllc00+0MInxCoQTOcxawFFH5000iTCM600mKepD/gxuTG53hlAOFZ8sQ caUsSlnI6kF0ziKx6e4YRgRLJac8GoihY2WJwqDoyJ62ZJfjzUbvBkVE/44J1YbrP9 QtqTpmuCgicuKvRI75PkCdkP3oD0tgVMoHef5Cvg= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181204093916eucas1p21984ecd86d3ff6b99699c90570af9034~tF77xghcB2456524565eucas1p2r; Tue, 4 Dec 2018 09:39:16 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id D7.12.04806.34B460C5; Tue, 4 Dec 2018 09:39:15 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20181204093915eucas1p240fb2571fce0b0cd226ca096d077b449~tF768HLm-2434424344eucas1p25; Tue, 4 Dec 2018 09:39:15 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20181204093914eusmtrp2630c1d5f94eff1802e7ab0d2d658123e~tF76sCBWf0442304423eusmtrp2d; Tue, 4 Dec 2018 09:39:14 +0000 (GMT) X-AuditID: cbfec7f5-367ff700000012c6-aa-5c064b430b88 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 1F.2B.04284.24B460C5; Tue, 4 Dec 2018 09:39:14 +0000 (GMT) Received: from [106.120.51.20] (unknown [106.120.51.20]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20181204093913eusmtip17e5df4b724e70f45bb461ba845e5f603~tF75t2xR62932329323eusmtip1E; Tue, 4 Dec 2018 09:39:13 +0000 (GMT) Subject: Re: [PATCH v2 2/5] devfreq: add support for suspend/resume of a devfreq device To: Chanwoo Choi , 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 From: Lukasz Luba Message-ID: Date: Tue, 4 Dec 2018 10:39:12 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <5C06124B.5030409@samsung.com> Content-Language: en-US Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA02Se0yNcRjH/d57Z057Oy49K2M7M8RU6I/fxtzZOzaXyYQ2Dt5VdJLzVnLZ 5BIpFEM5RYiV00k63tLtFMfRGXW6uGWIY5hbuSXWcOj0HtN/n+/3eX7P83y3H0dq8pgALiYu QTTE6WK1jIqqaOhtnjhnIRMZmu0MxTfKg3BZTimNr5V9p3H7tzc0zrc303hvQSmDmzL0OPPl BxK3tFxhsXNPJ4uNx60Etrx8SON71XkM7j5sRzinpY7AJfYOFl9sbyPwk91FDO64c6vvfeNd Gqda7SzeX/yZxp2tz6iZ/kJFTQUtmM+YkZCb0kYJWZlfkVBQ+44QLKaDjFB/2swKVy/sEtwN rCA/OEAJR2QTEoqKf7BCt2XkEvUq1bQNYmxMkmgImb5WFX2020XFu8Ymv/n+k01BTa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dVu3ibZK88RtDotHxwukbUxsr2KVCoXBGN5KHh0XJFWFTSutAI2dq4 mFQ+42A2L6yNS5Gnn58aIjKHlh/+NP2bzgOdSwqBFwPZcKhvbCYKgTcjZW8DePZWMeYJ/GFx k4X2sA/801dIeUpjALZdtlHuwIfdA9srPuLuwJftALDE0Y65B5wtwKFz/CbwKDMAdjWcctUY hmLlsLEqy40SNh4+KNzlRoJdCh0Wb/dOP3Y37HLWADdL2AXw2ZVRws1e7Cp4ZbjrH+NsJLxm HsY9HADfjF7HPLwE5teX4UVAapijG+YohjmKYY5yAxBVwJfXiao0laiQi0qVqFOnyfdrVLXA 9S4NrT/NjaDHtKMFsAyQzZeUbiQTpaQyW8xRtQDI4DJfycAyKlEqSVXmHOEFTbKgy+DFFhDh uu08HuS3X+N6PrU2WRGhiELRiqiwqLBIJAuQOEJy9krZNKWWP8Tzmbzw38MYr6A8sGic35ob +zT4x2L7L11/zeat/ZUhnT25KRmRu55glyztSmtK70TvQvhD0FvxLPvrnBif+FndhXk1M+XR 64sCjo0EMrbAAk1I/na9xvghsrvc9sg8kOtcvU+r+1xmthr9k6TPnZOZsyVbrF/v7FT3CS8v e6XXbYpblHD0gO19/BYZIaYrFStxQVT+BUoSXWlEAwAA X-CMS-MailID: 20181204093915eucas1p240fb2571fce0b0cd226ca096d077b449 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20181203143131eucas1p217f22ac6d19682a54a57658a06980914 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181203143131eucas1p217f22ac6d19682a54a57658a06980914 References: <1543847475-7600-1-git-send-email-l.luba@partner.samsung.com> <1543847475-7600-3-git-send-email-l.luba@partner.samsung.com> <5C06124B.5030409@samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > 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 >> Suggested-by: Chanwoo Choi >> Signed-off-by: Lukasz Luba >> --- >> 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; >> > >