Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2490849imu; Wed, 21 Nov 2018 12:29:11 -0800 (PST) X-Google-Smtp-Source: AFSGD/XdByob2RBEVT0jMEARJvIdFa/ivn4XQH1i4Z9Q4lTfbm8Uxg0QkknnQXI9UBfLi+QFghf9 X-Received: by 2002:a63:d655:: with SMTP id d21mr7297084pgj.280.1542832151576; Wed, 21 Nov 2018 12:29:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542832151; cv=none; d=google.com; s=arc-20160816; b=WulAb7+HHtgR9ik7hfpAKn7cY9vbxq7eUWfFeNC/uTl5Ve1mCpo9Fq4xL3G20YYzS0 8hjO4sR585HN8xQkEWSWWXE8o/r5EmG1SyP8F4M3bjGYwTlu6QA2VBjUB3cK/DJ5FJaD NSH9/Klw4zQ/IgPoZLts3L83ehZisImAkDmxdutx0urJQ1aePmUrINIftiJzYCu2uXHY abKywtU0xtpvmMvQFVBttu1zJj5ZwibVy0/qsI+LR1jEnwkKeYl2ilaLfUfV6HA2py6T vLVcO2vXxqJ7YCekeybw4k2jLGKnDmo1VE9K8Aakt23uAIzEt4BmY5TVuF2wU0/pwgj7 ZgqQ== 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:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=axMoCdjjhQCxHj2Q1e8pQzBP0D1acRsUCt4LxqCbmyo=; b=ckTkyWE1duPPGphQPMVDNWj92izpu7ugSnud0GSlIy7/0dT4BApQpDWC3OtuQYZLEO eRTnhpMeOmv52lA5epuZ+/80C0wGoAAGGxZ4xh1ySsRCk1I3Vj92hLqGe+i1d7rqT5LA GlwqMjBavDw7Vj0rMQkr/0PsAuDLr1NPTF/4SheY1JgBnjunsHWCV1hjzq3vQdwqPaoi us5gpNHG4JFjpPaxtyHPEyzazliQlVP11D9MKwRBIpjckoJVn7iTXrsHg9q6rgq/LB8y xmGWcHuwCtr7HYMqF40MKjpCoEn9ftGw0n2zSs80Nt/bLy3jUiGVPBOtg5J9q5F/eXiE 7mpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=MwK0PQha; 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 11-v6si50971873pfx.102.2018.11.21.12.28.55; Wed, 21 Nov 2018 12:29:11 -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=MwK0PQha; 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 S1732903AbeKVEhd (ORCPT + 99 others); Wed, 21 Nov 2018 23:37:33 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:38119 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732888AbeKVEhb (ORCPT ); Wed, 21 Nov 2018 23:37:31 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20181121180207euoutp014ba86e253fe6c2cc2a5d2744854c0dc0~pNaRww-8e0920709207euoutp01D for ; Wed, 21 Nov 2018 18:02:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20181121180207euoutp014ba86e253fe6c2cc2a5d2744854c0dc0~pNaRww-8e0920709207euoutp01D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1542823327; bh=axMoCdjjhQCxHj2Q1e8pQzBP0D1acRsUCt4LxqCbmyo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MwK0PQhaPHWj6hoEkprkeWu/62ovg6f226P9H4PVg18+eiwGqHkTjT/bJ++z7J4Ua IksdapoVw8ZsHbkdAxNkWNGQl1YC0sa8vNXxJ8BTY1loZe5Tml1+V+YRT7IZrp5fYt MbEaxYVNo+vImmok6xRCtN2m6W4vYwSobQmnbOBc= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181121180206eucas1p143bfcd4572435bcb997b49b95d6d17dc~pNaQrRJhe3116331163eucas1p1g; Wed, 21 Nov 2018 18:02:06 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 19.89.04294.E9D95FB5; Wed, 21 Nov 2018 18:02:06 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20181121180205eucas1p1dc52369476400cd07058d232bd8dbcd7~pNaPq-yFi3115931159eucas1p1W; Wed, 21 Nov 2018 18:02:05 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20181121180205eusmtrp2c0f09882ef4f00cb548235e0fe26c4b3~pNaPbcUsd0880108801eusmtrp2I; Wed, 21 Nov 2018 18:02:05 +0000 (GMT) X-AuditID: cbfec7f4-835ff700000010c6-c5-5bf59d9eb799 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 0E.48.04284.D9D95FB5; Wed, 21 Nov 2018 18:02:05 +0000 (GMT) Received: from AMDC3778.DIGITAL.local (unknown [106.120.51.20]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20181121180204eusmtip2a122851a9fd70407df58db04269308ad~pNaOjDyEp1642316423eusmtip2P; Wed, 21 Nov 2018 18:02:04 +0000 (GMT) From: Lukasz Luba To: 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, cw00.choi@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, Lukasz Luba Subject: [PATCH 4/6] devfreq: add devfreq_suspend/resume() functions Date: Wed, 21 Nov 2018 19:01:39 +0100 Message-Id: <1542823301-23563-5-git-send-email-l.luba@partner.samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1542823301-23563-1-git-send-email-l.luba@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0WSbVBMYRTHe+7L3tuyubboDA3NKlONytuHZyYMow93MCbjUy3D0lVGm+xV hGFFSqEGU4a2mKRsJSVbthdaS/T+MnnJbIMYQxhshRlir7v49nv+5/zP/8yZhyXVY/QMdnvi bsGQqEvQKJSU5f737tBC05h2vqlEhVtuBuPqc1U0rqsep/Hj0Tc0LrJ30fhIcZUCd2Trcc7w CIm7u68zuDPtPYMHjX74/NkmAtcMP6Jxv7VAgZ0n7Qif624mcKXdweCSx70Efna4TIEdbfdc M9r7aJzeZGfwsfJPNH7fM0QtB97SYKH5isIKxF8w9lJ8bs4XxBc3viX4GvNxBX/bVMHwNy4f 4ifuM3zLx0aCrx3IoPhTtWbEl5V/ZXhnzaworxjlklghYXuKYAhftlkZb6l8RSQ1++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cxcnJICJhIfL6wh7GL kYtDSGApo8Sb5h/sEAkxiUn7tkPZwhJ/rnWxQRR9YpS4d2g1kMPBwSagJ7FjVSFIXERgOaPE /Z+z2UEcZoEHzBIdzzexgnQLC7hInGn+wAhiswioSuxtmgw2lVfAS2LOvTksEBvkJG6e62QG sTkFvCU+r5oAVi8EVHNl3kLWCYx8CxgZVjGKpJYW56bnFhvqFSfmFpfmpesl5+duYgRG7LZj PzfvYLy0MfgQowAHoxIPr0bk12gh1sSy4srcQ4wSHMxKIrwdUUAh3pTEyqrUovz4otKc1OJD jKZAR01klhJNzgcmk7ySeENTQ3MLS0NzY3NjMwslcd7zBpVRQgLpiSWp2ampBalFMH1MHJxS DYy+u9/F2lf+YvblDnt3JGqp5aarQV+OGuu8evzzw0JXWceIZ1pRa8y1L69YpbAqftOlgOay /SUa2y4aKJTHn9vGf+ipvvrUJfKl/++IXtXaXKQ085iP0LN5bY2rAy9ap1Rbzi70tuS2mi9a y1LY/evvRZMd599LPDtmZ9RqP1Fa5fSjAr/ZLGZKLMUZiYZazEXFiQAcq5Dr7gIAAA== X-CMS-MailID: 20181121180205eucas1p1dc52369476400cd07058d232bd8dbcd7 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20181121180205eucas1p1dc52369476400cd07058d232bd8dbcd7 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181121180205eucas1p1dc52369476400cd07058d232bd8dbcd7 References: <1542823301-23563-1-git-send-email-l.luba@partner.samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds implementation for global suspend/resume for devfreq framework. System suspend will next use these functions. The patch draws on Tobias Jakobi's work posted ~2 years ago, who tried to solve issue with devfreq device's frequency during suspend/resume. During the discussion on LKML some corner cases and comments appeared related to the design. This patch address them keeping in mind suggestions from Chanwoo Choi. Suggested-by: Tobias Jakobi Suggested-by: Chanwoo Choi Signed-off-by: Lukasz Luba --- drivers/devfreq/devfreq.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/devfreq.h | 7 +++++++ 2 files changed, 56 insertions(+) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 7e09de8..2f4391c 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -44,6 +44,9 @@ static LIST_HEAD(devfreq_governor_list); static LIST_HEAD(devfreq_list); static DEFINE_MUTEX(devfreq_list_lock); +/* Flag showing state of suspend/resume */ +static bool devfreq_suspended; + /** * find_device_devfreq() - find devfreq struct using device pointer * @dev: device pointer used to lookup device devfreq. @@ -938,6 +941,52 @@ int devfreq_resume_device(struct devfreq *devfreq) EXPORT_SYMBOL(devfreq_resume_device); /** + * devfreq_suspend() - Suspend devfreq governors and devices + * + * Called during system wide Suspend/Hibernate cycles for suspending governors + * and devices preserving the state for resume. On some platforms the devfreq + * device must have precise state (frequency) after resume in order to provide + * fully operating setup. + */ +void devfreq_suspend(void) +{ + struct devfreq *devfreq; + int ret; + + mutex_lock(&devfreq_list_lock); + list_for_each_entry(devfreq, &devfreq_list, node) { + ret = devfreq_suspend_device(devfreq); + if (ret) + dev_warn(&devfreq->dev, "device suspend failed\n"); + } + mutex_unlock(&devfreq_list_lock); + + devfreq_suspended = true; +} + +/** + * devfreq_resume() - Resume devfreq governors and devices + * + * Called during system wide Suspend/Hibernate cycle for resuming governors and + * devices that are suspended with devfreq_suspend(). + */ +void devfreq_resume(void) +{ + struct devfreq *devfreq; + int ret; + + devfreq_suspended = false; + + mutex_lock(&devfreq_list_lock); + list_for_each_entry(devfreq, &devfreq_list, node) { + ret = devfreq_resume_device(devfreq); + if (ret) + dev_warn(&devfreq->dev, "device resume failed\n"); + } + mutex_unlock(&devfreq_list_lock); +} + +/** * devfreq_add_governor() - Add devfreq governor * @governor: the devfreq governor to be added */ diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h index 7fe96f9..4f0fea8 100644 --- a/include/linux/devfreq.h +++ b/include/linux/devfreq.h @@ -202,6 +202,10 @@ extern void devm_devfreq_remove_device(struct device *dev, extern int devfreq_suspend_device(struct devfreq *devfreq); extern int devfreq_resume_device(struct devfreq *devfreq); + +extern void devfreq_suspend(void); +extern void devfreq_resume(void); + /** * update_devfreq() - Reevaluate the device and configure frequency * @devfreq: the devfreq device @@ -396,6 +400,9 @@ static inline int devfreq_update_stats(struct devfreq *df) { return -EINVAL; } + +static inline void devfreq_suspend(void) {} +static inline void devfreq_resume(void) {} #endif /* CONFIG_PM_DEVFREQ */ #endif /* __LINUX_DEVFREQ_H__ */ -- 2.7.4