From patchwork Wed Nov 2 14:21:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 14280 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3670242wru; Wed, 2 Nov 2022 08:02:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7PHsFguvsYMyettsk4adfeMafhelb/qYQ0GpqsdGOez2xI07MDJfvdh/JAshj0ZE+Y2q+g X-Received: by 2002:a17:90a:7786:b0:214:2a4a:4a28 with SMTP id v6-20020a17090a778600b002142a4a4a28mr4634396pjk.132.1667401345959; Wed, 02 Nov 2022 08:02:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667401345; cv=none; d=google.com; s=arc-20160816; b=Oez8NjktiL+h4F+8P+isgOWK/MMA9jsUsU6NgOymyaut7PvbAqpgEPcjVj+IyZ7FRg TvXFVyRm6Hi07/bADsEnj9mYakCSxmnMWT//GGYLlDRvX20NIG0XOJgZFaoci6yc8hm8 f9eqb63T2wPFrtNL6/QzSqiAz5GcS6H/SZ9jjxiyS4vzoHKWzXHS0YzuiT57Y7/7Ookb 9DTanlmZ9Pb73Vf1dDEFBuP8GBhVVyVm7tlsNeMdi0pYIcYaKW57oFq0zV2cMGjWl0B0 ndRSQtYapErlToFj/BB0O0htL8ZsJvtRWnqp5R2918nmvrdJXx4cJCK8G2Uc7gocvKvi QOLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ODaPlzoiM2wGPR3JeVuPfzDqwHYUcKlkdeyiRb2Q0lw=; b=s9f42Mk8FaFtAxQjL7dAVm7oHQ+fGt+B1iYdanyJ/dW+ZzB5swpV83AWez5u/GSi7e 2n/48wFQZ5Tn9vg5s1gXV80AxspqCsX0V3P0pKjSLkpSTIKZRIzGytT5NhUqiHhkjWB3 i+JizwQKFpYbvZYyKqKYmB4PC/ZwC5bmROVEZASdzrKczD22HXckmWooZahHGdPqmYY9 rhQGM+QILENNpf8OUGbVXIeNe8XN1VQqfIcVJ8u2Ycbu+mSx7Jl7ZwZXRnMQScYxDGXz okLEyX+eYw9McbhbUK4nsqAPY+7/tE2iKU6hut8pgSkmt+eisiXXV1K9dsboy7by/PBn rFQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dak2HCVp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y127-20020a623285000000b0053836f22d73si14942927pfy.214.2022.11.02.08.02.11; Wed, 02 Nov 2022 08:02:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dak2HCVp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230320AbiKBOWB (ORCPT + 99 others); Wed, 2 Nov 2022 10:22:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231466AbiKBOVs (ORCPT ); Wed, 2 Nov 2022 10:21:48 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A89D29C9D for ; Wed, 2 Nov 2022 07:21:46 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id k7so7000319pll.6 for ; Wed, 02 Nov 2022 07:21:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ODaPlzoiM2wGPR3JeVuPfzDqwHYUcKlkdeyiRb2Q0lw=; b=dak2HCVpbEaeVp7CSu+TOT5ppVs2qsQOQoQSzIcU5YzTb/X4cctoidWvx1Y+mWXgJC rXX14WjJcAycOPiZAuyD4EzZv2OO5H4Q/wDFdS3UAgSZdiPyC2TKLzRvcKzZBENjx8ru 5e2yu0z4x08FDLahkeTp4/kViprl7KWaAGk2SlNTVWpTrZ62TIDl1s8J5d+EFO3dSFky SI+BDDgi1kOnposCaxtKTnpGtgGRzbqLpkduGlzGqiNb1rKPmGgVaMh4lLPGhknmmoWv njo7EXv22zsqXyOUBlSzmhOAs2/e0UMzhM4TXQP7R76rtCXpCKE/QzvkWvarmcNiUYhJ NWTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ODaPlzoiM2wGPR3JeVuPfzDqwHYUcKlkdeyiRb2Q0lw=; b=kiKMhCWAfmpFBw567y+t86SYYgn5Ts+qikx0z+lMsegX16nNzs7ZOq/39Ak+plBUdh bvH4PWNmhstYNj1M+2DWUOGBN7q3tAXRn1R6MW0GJrd5dwhhCHk5kuiBzwcDPC4e0tsD SKfHQjIvYbuGtkclBpO5dVGacidsdaHAOC5RDRuFhO/sDG0keWvlFfAqz4tZ3tQafTcy 1rNmZOkRMBXZadk8yozYXAceV4JybcilrliWTnt95e84H+1No9Q16zqqow45L28sJCO2 FO+yVHWKMWJ9AaePkv4yedv1PVP3RY6Dh4Tjgkmw7S+0/3qkIfKkvDRSiZ2dlWlv+lIH gK8A== X-Gm-Message-State: ACrzQf1U6mg8UVI9bfNJlFKg8yoEd+qQkgIcidrqbF03irdC5u1K9qU8 S50AHhRjQ/sSbbjDAXi44uj9fw== X-Received: by 2002:a17:90b:164d:b0:213:6a84:2529 with SMTP id il13-20020a17090b164d00b002136a842529mr26114236pjb.32.1667398905990; Wed, 02 Nov 2022 07:21:45 -0700 (PDT) Received: from localhost.localdomain (80.251.214.228.16clouds.com. [80.251.214.228]) by smtp.gmail.com with ESMTPSA id o28-20020aa7979c000000b0056b8181861esm8817773pfp.19.2022.11.02.07.21.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 07:21:45 -0700 (PDT) From: Shawn Guo To: "Rafael J . Wysocki" Cc: Kevin Hilman , Ulf Hansson , Len Brown , Pavel Machek , Greg Kroah-Hartman , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Shawn Guo Subject: [PATCH v3 1/4] PM: domains: Drop genpd status manipulation for hibernate restore Date: Wed, 2 Nov 2022 22:21:01 +0800 Message-Id: <20221102142104.2006554-2-shawn.guo@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221102142104.2006554-1-shawn.guo@linaro.org> References: <20221102142104.2006554-1-shawn.guo@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748397033768402129?= X-GMAIL-MSGID: =?utf-8?q?1748397033768402129?= The genpd status manipulation for hibernate restore has really never worked as intended. For example, if the genpd->status was GENPD_STATE_ON, the parent domain's `sd_count` must have been increased, so it needs to be adjusted too. So drop this status manipulation. Suggested-by: Ulf Hansson Signed-off-by: Shawn Guo Reviewed-by: Ulf Hansson --- drivers/base/power/domain.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 6471b559230e..97deae1d4e77 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1374,20 +1374,7 @@ static int genpd_restore_noirq(struct device *dev) if (IS_ERR(genpd)) return -EINVAL; - /* - * At this point suspended_count == 0 means we are being run for the - * first time for the given domain in the present cycle. - */ genpd_lock(genpd); - if (genpd->suspended_count++ == 0) { - /* - * The boot kernel might put the domain into arbitrary state, - * so make it appear as powered off to genpd_sync_power_on(), - * so that it tries to power it on in case it was really off. - */ - genpd->status = GENPD_STATE_OFF; - } - genpd_sync_power_on(genpd, true, 0); genpd_unlock(genpd); From patchwork Wed Nov 2 14:21:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 14279 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3668955wru; Wed, 2 Nov 2022 08:00:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5FQiZtcf2MAC1aUb3I2TqkTr6vmZkz2tXPtdR3t5JWNzkCc8g7Rd9Q+u1YNtVwe6boZPNA X-Received: by 2002:a05:6a00:4206:b0:56c:2e49:ca0d with SMTP id cd6-20020a056a00420600b0056c2e49ca0dmr25759587pfb.22.1667401223937; Wed, 02 Nov 2022 08:00:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667401223; cv=none; d=google.com; s=arc-20160816; b=E4CG9C/HCFdyY6Jmzga8+BbKA8pYN4CLRWNlOxhGhH5jzN+4rK8DRZ7unE1fxBShW1 zPTMHRs9UaZDuFAnPK+0ejZ8hKC+chs8eFxp01EuCnY3kuoM8ToJcLRllkcfvr5H8xuF RhJzjLzhmfdIp7nqdN4++jMWe11nzEQYMwJM/vgeff978gZ6AtE+fBwzopGvi0fBdrml YnbEVMFWJ8Z/PtcVPqOdhPx9T7xplS2FBKi3LYjXrQuFn4ep/ndB8jBjbObq59fD7zFh FtEA7uunSN1SWgujV+C1JHkMDroq9DlyDAfyodoLJk+3UKJbrZ9iGGVXSB7jPnYFhvre WiFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=u3X2UOS5GCzAk+RwX2Y3XrY61x6yZgTDSncBoSeqZLI=; b=ZrtQjaGYXQVi7FU5bgL82frTx/zg3w8be3HMEh8aaC0mFNJKReHmpALEXrGmnvLyen r3xBuf5RtH9rqBsnKtDjjyKXRFISbpxtgPw33xGcFk3b/AwwgNP9EPlxhuD6+c38G+TW Ja1no3DI7ML3DHxUb8ROVUazBVXr6yvKdWYYBEYOkWZ+JdIDFCn9VCphFDbeSRCOnkNf F4uBXLHNechQCBinKHphps7koJ9zrr2uIBDMs8mZYf3O7zDwfxu2MpCm17yr8inaNAuE tDDdPxc6lkSXYEQerUqVUaEEp6dFOOYOCnEU680mvf+BArlC4cc3ii76LYA40WARzvmd u1Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tP92GVRc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j10-20020a636e0a000000b0046fbce5fbe1si11469597pgc.237.2022.11.02.08.00.11; Wed, 02 Nov 2022 08:00:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tP92GVRc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231648AbiKBOWK (ORCPT + 99 others); Wed, 2 Nov 2022 10:22:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231506AbiKBOVu (ORCPT ); Wed, 2 Nov 2022 10:21:50 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8CD9201B4 for ; Wed, 2 Nov 2022 07:21:49 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id 4so16751084pli.0 for ; Wed, 02 Nov 2022 07:21:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=u3X2UOS5GCzAk+RwX2Y3XrY61x6yZgTDSncBoSeqZLI=; b=tP92GVRcbpnSB3xByd6EKkdFhI2ZZxEFq+0qM0sGK5E+2xuX6AHz+yeAWxUIRaFqur AU3x3apJWWF5aeMB+VrgbTciJbWFSd7zo/WZRF0pEi6LgmVXPO30AYNBoO4+G1hi/ijt 1jncQwvWehSCooj+r+y0aIOk9l0rxvB2kRewercVL8R3IktqPtZmqyZL3QkQ6rNA8aaH sSWEgANy+SHsjEpUjsN1OFjRilyWolHnh19b+FyPKhNuePvhf/m2OEyd8w3gyckD3uT8 H7rF1A9ldjjt0b0xjFv51yGzcZAdkPZb6ew+0hEWjN3+HqnrTHMTyc9s0FU4QbCmrLvD P17A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u3X2UOS5GCzAk+RwX2Y3XrY61x6yZgTDSncBoSeqZLI=; b=niAUDq4FTIJRdsUVBPVKKUZB930LcKrsFAE8fEoLTyR2tZ3eWKiF7qjUzUGiTR9ZsL d6LZTMkXn0pxMheGKxagWvv0EoYKZ/DcbYYp2nhw3adHooxeJ3rMqsT/46M4bcqm5DNZ 1ywklv8IsrFFGHR1kLpnVor2Hp9bXEybjnhXWglPc9QBAtHh8yXoaeJ06Mv8J85Qq4wQ 2lRTFSbh+Ia3hz/lO94NPopoaea7U+3+Nd46aNclCEzC4ci6G6V7XlQRHl3bzpUH4k/k 0UeSCGlpKkR+gaDCnmXsH1mkCKeZpRfYthrFBCrTekkl+zJmymBVkDYxqgOov5yKhBsz P36g== X-Gm-Message-State: ACrzQf29xL113LWGt3bFJ/n/8KfV14EuUtdW2WZ3OeLHPzmU0T/BEZcj S7ri6Y8mgj/8V6SdLSFvUOseHg== X-Received: by 2002:a17:903:188:b0:187:dd28:5fc1 with SMTP id z8-20020a170903018800b00187dd285fc1mr2273476plg.26.1667398909278; Wed, 02 Nov 2022 07:21:49 -0700 (PDT) Received: from localhost.localdomain (80.251.214.228.16clouds.com. [80.251.214.228]) by smtp.gmail.com with ESMTPSA id o28-20020aa7979c000000b0056b8181861esm8817773pfp.19.2022.11.02.07.21.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 07:21:48 -0700 (PDT) From: Shawn Guo To: "Rafael J . Wysocki" Cc: Kevin Hilman , Ulf Hansson , Len Brown , Pavel Machek , Greg Kroah-Hartman , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Shawn Guo Subject: [PATCH v3 2/4] PM: domains: Pass generic PM noirq hooks to genpd_finish_suspend() Date: Wed, 2 Nov 2022 22:21:02 +0800 Message-Id: <20221102142104.2006554-3-shawn.guo@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221102142104.2006554-1-shawn.guo@linaro.org> References: <20221102142104.2006554-1-shawn.guo@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748396905852520994?= X-GMAIL-MSGID: =?utf-8?q?1748396905852520994?= While argument `poweroff` works fine for genpd_finish_suspend() to handle distinction between suspend and poweroff, it won't scale if we want to use it for freeze as well. Pass generic PM noirq hooks as arguments instead, so that the function can possibly cover freeze case too. Signed-off-by: Shawn Guo Reviewed-by: Ulf Hansson --- drivers/base/power/domain.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 97deae1d4e77..f18b8b1bc17a 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1189,12 +1189,15 @@ static int genpd_prepare(struct device *dev) * genpd_finish_suspend - Completion of suspend or hibernation of device in an * I/O pm domain. * @dev: Device to suspend. - * @poweroff: Specifies if this is a poweroff_noirq or suspend_noirq callback. + * @suspend_noirq: Generic suspend_noirq callback. + * @resume_noirq: Generic resume_noirq callback. * * Stop the device and remove power from the domain if all devices in it have * been stopped. */ -static int genpd_finish_suspend(struct device *dev, bool poweroff) +static int genpd_finish_suspend(struct device *dev, + int (*suspend_noirq)(struct device *dev), + int (*resume_noirq)(struct device *dev)) { struct generic_pm_domain *genpd; int ret = 0; @@ -1203,10 +1206,7 @@ static int genpd_finish_suspend(struct device *dev, bool poweroff) if (IS_ERR(genpd)) return -EINVAL; - if (poweroff) - ret = pm_generic_poweroff_noirq(dev); - else - ret = pm_generic_suspend_noirq(dev); + ret = suspend_noirq(dev); if (ret) return ret; @@ -1217,10 +1217,7 @@ static int genpd_finish_suspend(struct device *dev, bool poweroff) !pm_runtime_status_suspended(dev)) { ret = genpd_stop_dev(genpd, dev); if (ret) { - if (poweroff) - pm_generic_restore_noirq(dev); - else - pm_generic_resume_noirq(dev); + resume_noirq(dev); return ret; } } @@ -1244,7 +1241,9 @@ static int genpd_suspend_noirq(struct device *dev) { dev_dbg(dev, "%s()\n", __func__); - return genpd_finish_suspend(dev, false); + return genpd_finish_suspend(dev, + pm_generic_suspend_noirq, + pm_generic_resume_noirq); } /** @@ -1353,7 +1352,9 @@ static int genpd_poweroff_noirq(struct device *dev) { dev_dbg(dev, "%s()\n", __func__); - return genpd_finish_suspend(dev, true); + return genpd_finish_suspend(dev, + pm_generic_poweroff_noirq, + pm_generic_restore_noirq); } /** From patchwork Wed Nov 2 14:21:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 14278 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3668938wru; Wed, 2 Nov 2022 08:00:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Ck/Mjqdq9o3CtwIBxHNdjHnZzercIBtXuyBMWC9w6+d0t+mJfxu1lDnMaT+PxVsnkk63d X-Received: by 2002:a17:903:2014:b0:186:8937:28a6 with SMTP id s20-20020a170903201400b00186893728a6mr24371016pla.39.1667401222184; Wed, 02 Nov 2022 08:00:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667401222; cv=none; d=google.com; s=arc-20160816; b=lG+SJiwoMDWH0RxI/4/zl1pv61y7JjsoxGPlKQdKNFLWSWYcJ1K6sLAx9Iwpgw0HPG CgaTbFJ0iw5TzK7Zc2Z3V+DfySvW3w7QUm2F411N70wt7Y4JJ104PyEKQNxzxwzkNeVf xoE/jbkOhFpbiJltCr8XjgjZPR/xniWmIs5LLwNAIY6Bu2wXOq2O0E9+1jxztpVTpI7D rx7S/nSOe2/1ePflJp15nq+//7xwJaY6JKjwMD9AjThbHqoYHScU3GuYB71k+KJu/UsA ssjSvSa8D/pJEr6b5XTtSMqkE/R7zHFS/zBkAxKeZ7ZkacMzpxr76PJM5bDX3bFGyMGS rr3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GG7lcQ6B6Fm/T8LV8zudWuwDEbtHmTF64TDq9Olscfs=; b=E7bgP5VYtWDQ/u2IyOophTmyMSoux0jNIL9LtszPk6lGjbM+wd3h73y6Tq9IBGhVdh DWHgdce7IBAVZVXZszjTKZ/OUnn5/zBywbHcxJLT0fpmOvi5IS9tPJXJy+v9/ez4BVwQ ygfW42UXuIAZXZtHzmJv1Dl29kd4Ja/jOEZbLCrNqZehyQH1BkJNgaPK4mfnEWcY/30X zMz4rqxJuVHvjynntuJT6KGYCfiVrN2LFKT0QcrsYJBe2PmvIHwdxE2OWV6/tWcSbhFv jGSDz8bMuj58TtH4wbGl1o9z7ayGNAG3R54j9JILBpAwHcYy+2faxUFiTwNXJqDp6z84 hoBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PvzIPDEa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y10-20020a65528a000000b00461f71a53e1si6861209pgp.505.2022.11.02.08.00.09; Wed, 02 Nov 2022 08:00:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PvzIPDEa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231610AbiKBOWN (ORCPT + 99 others); Wed, 2 Nov 2022 10:22:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231620AbiKBOVz (ORCPT ); Wed, 2 Nov 2022 10:21:55 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15C7C22B1E for ; Wed, 2 Nov 2022 07:21:53 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id gw22so3463664pjb.3 for ; Wed, 02 Nov 2022 07:21:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GG7lcQ6B6Fm/T8LV8zudWuwDEbtHmTF64TDq9Olscfs=; b=PvzIPDEaMTxlCBzHeWB28vY0jwJKBCLL1AR3V06rmFooumUv1jPop0oiy7VlFAab+8 9X2W/hENaPNuh5hwH030LiHExwbxx4PlOmsmhD37ydMeugOoka5U3ADPw4TZkwYvqPG8 IcWS6xYmcj32PB2fh79Kk7136zg1voEKRW91DGoBHR+kFgIL69TrJ5foYR3hrZlaOdxQ o7m+EMklaYGDOO2e0ROew1+eXiH0eV1GwwXB9b893TqSRX7QJr9c/57qQENio0fe+fih z2gjPV6x1XGWkeSYnElgigWVp0yt8ShTlAptC14iiTL/YHnjSE2qi7Efuo1um5IF/s5V p2Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GG7lcQ6B6Fm/T8LV8zudWuwDEbtHmTF64TDq9Olscfs=; b=oaHhmvKuBVp67Xjca8sVM1JdeSYMrfjZZk8wgtGiAqEQzsVMofMFzEiZ1krphFFkiv 1ny8NqwpnKWUBUCHMnmEwvXbv5unEz/CiFErklNlBpLRGBP8TXK05Aq87jUSoPWUZLGj 1RuLhwX9eJX98QQN7fJD0NTlA+OmKGySZ5i9nkyPf/Mw5VWfr6Ql27fO6/+RMzlaP24Y c13BFM1uj/27MDrojePIixy1Myle8FCWDqsQNAPGHY/KEsOptVEQWPqCekswXalKzGHV tUTaCFr3BDWRZX00sWwHd4RyrmkONqrnVrwWqS/Imor0CWvTKMAGaxrKU29kpQCdyRef 7Tug== X-Gm-Message-State: ACrzQf0xVN52+FIevUTxhbTWNGomJDqxxIL5rWxUsasi2omsy0gK423s nYHqFETm9ukwTqe/lxlj2S446ZtIT+cE+A== X-Received: by 2002:a17:902:8a93:b0:17f:66ae:b6c with SMTP id p19-20020a1709028a9300b0017f66ae0b6cmr25058677plo.94.1667398912588; Wed, 02 Nov 2022 07:21:52 -0700 (PDT) Received: from localhost.localdomain (80.251.214.228.16clouds.com. [80.251.214.228]) by smtp.gmail.com with ESMTPSA id o28-20020aa7979c000000b0056b8181861esm8817773pfp.19.2022.11.02.07.21.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 07:21:52 -0700 (PDT) From: Shawn Guo To: "Rafael J . Wysocki" Cc: Kevin Hilman , Ulf Hansson , Len Brown , Pavel Machek , Greg Kroah-Hartman , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Shawn Guo Subject: [PATCH v3 3/4] PM: domains: Consolidate genpd_restore_noirq() and genpd_resume_noirq() Date: Wed, 2 Nov 2022 22:21:03 +0800 Message-Id: <20221102142104.2006554-4-shawn.guo@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221102142104.2006554-1-shawn.guo@linaro.org> References: <20221102142104.2006554-1-shawn.guo@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748396904287148646?= X-GMAIL-MSGID: =?utf-8?q?1748396904287148646?= Most of the logic between genpd_restore_noirq() and genpd_resume_noirq() are identical. The suspended_count decrement for restore should be the right thing to do anyway, considering there is an increment in genpd_finish_suspend() for hibernation. So consolidate these two functions into genpd_finish_resume(). Signed-off-by: Shawn Guo Reviewed-by: Ulf Hansson --- drivers/base/power/domain.c | 41 +++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index f18b8b1bc17a..7cee9439fd21 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1247,12 +1247,14 @@ static int genpd_suspend_noirq(struct device *dev) } /** - * genpd_resume_noirq - Start of resume of device in an I/O PM domain. + * genpd_finish_resume - Completion of resume of device in an I/O PM domain. * @dev: Device to resume. + * @resume_noirq: Generic resume_noirq callback. * * Restore power to the device's PM domain, if necessary, and start the device. */ -static int genpd_resume_noirq(struct device *dev) +static int genpd_finish_resume(struct device *dev, + int (*resume_noirq)(struct device *dev)) { struct generic_pm_domain *genpd; int ret; @@ -1264,7 +1266,7 @@ static int genpd_resume_noirq(struct device *dev) return -EINVAL; if (device_wakeup_path(dev) && genpd_is_active_wakeup(genpd)) - return pm_generic_resume_noirq(dev); + return resume_noirq(dev); genpd_lock(genpd); genpd_sync_power_on(genpd, true, 0); @@ -1281,6 +1283,19 @@ static int genpd_resume_noirq(struct device *dev) return pm_generic_resume_noirq(dev); } +/** + * genpd_resume_noirq - Start of resume of device in an I/O PM domain. + * @dev: Device to resume. + * + * Restore power to the device's PM domain, if necessary, and start the device. + */ +static int genpd_resume_noirq(struct device *dev) +{ + dev_dbg(dev, "%s()\n", __func__); + + return genpd_finish_resume(dev, pm_generic_resume_noirq); +} + /** * genpd_freeze_noirq - Completion of freezing a device in an I/O PM domain. * @dev: Device to freeze. @@ -1366,27 +1381,9 @@ static int genpd_poweroff_noirq(struct device *dev) */ static int genpd_restore_noirq(struct device *dev) { - struct generic_pm_domain *genpd; - int ret = 0; - dev_dbg(dev, "%s()\n", __func__); - genpd = dev_to_genpd(dev); - if (IS_ERR(genpd)) - return -EINVAL; - - genpd_lock(genpd); - genpd_sync_power_on(genpd, true, 0); - genpd_unlock(genpd); - - if (genpd->dev_ops.stop && genpd->dev_ops.start && - !pm_runtime_status_suspended(dev)) { - ret = genpd_start_dev(genpd, dev); - if (ret) - return ret; - } - - return pm_generic_restore_noirq(dev); + return genpd_finish_resume(dev, pm_generic_restore_noirq); } /** From patchwork Wed Nov 2 14:21:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 14272 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3662777wru; Wed, 2 Nov 2022 07:45:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5TxbOXUCgMkXVQ1n4ZgDvrnwZrgBn8Xn/yljTJGD4zkvUdbjorjMj5pbwngjfYKlfAda8N X-Received: by 2002:a05:6402:4446:b0:457:eebd:fe52 with SMTP id o6-20020a056402444600b00457eebdfe52mr24971747edb.234.1667400341049; Wed, 02 Nov 2022 07:45:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667400341; cv=none; d=google.com; s=arc-20160816; b=kLJum1ITIGXuvOlZBAiXkC4eK9xRoo4ARQlFATC+pfnvI/PKZ5kclf3LlCrQGHwzKz jaBM2StPM9UafJZ9ZhkegoNDuxOvDF58YrTzbXdhwgnBQOvN7dnpnT6qH7ma/0HWwDvX SnN8d3olNbTO4O2JIhDg+tNFgIGk9XBV+Yv9uFTIPibLvXaXVuw3ok00LKY1YF5T55gr bbxZc4RZsJsL+V+nuBbrFhgj+s+paionH2cFK9xJO5hpHeA/jrlQpRjSlMoX6oYh8geK aur4z72FNJZfM0M4OvlkifIRVWMSSnXYgCOLwp4fM2uc8XNWpBcTxwDUK/Mgv2swcXNE 3tdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=c/pMCaexTxPLJj78ppz2hR1Nnq2hMOxwXWSwZaAwP1o=; b=vWlIdALtToXorfil8lW3X72MatOKkFS7J73xZlUtWNZLM9QDA0fPCXmNzl9wU+E/qR Ef9yADscsjqlIfbtsmqYoVITxlPAAP0SX2+HF8859ACIqvmxu20x9XAjFct4ssbWcU7o FBwcYpjLmY/dKtLbHefNmwO8hYX+36Hj7lkZTwJ4r5RR6hHBmYsMS0+g17ZfZihrnXuN 1zH9Xz3RHfavRd+Jw2PjZthsOeFXbVDQ2l/Sxdk8mx/oKyGFiEgrFDspFS30X8WiffnE RBC9pB/LH6MZunjbLWG1LMIVw0fhhrj0UIvyLqHzm0HLFheX2+c2gjxxOF+mMS9pWmNr sn5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v2KPaSNw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b19-20020a056402279300b004616acd9cbcsi18295885ede.360.2022.11.02.07.45.17; Wed, 02 Nov 2022 07:45:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v2KPaSNw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231556AbiKBOWe (ORCPT + 99 others); Wed, 2 Nov 2022 10:22:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231462AbiKBOV6 (ORCPT ); Wed, 2 Nov 2022 10:21:58 -0400 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E91E1F630 for ; Wed, 2 Nov 2022 07:21:56 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id b1-20020a17090a7ac100b00213fde52d49so2054522pjl.3 for ; Wed, 02 Nov 2022 07:21:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=c/pMCaexTxPLJj78ppz2hR1Nnq2hMOxwXWSwZaAwP1o=; b=v2KPaSNwlUsp7p+WI5eQrzk4CxEQ6P+VRict3TlT67cdkOV/KtVsTQn1bBV14Y2xFO M8iBDtfXrhY2DbRs3tQQNOkLjkdUY82UJJqDY+Yl/unoGbQJNfn398w3vhZPkbwkrS2h 5JC21Q1z1i3DqZn9MSKDNQEhrzRa0DvrsJKeuxCwN4H0Za6QySEnjA90r53MOB9JEY0w UMISsBQmaJHGYYCzVoSXOGHlHeaahNz1VAxpoL4LfN/bcaTQ3gGtzt0fqqGW183CHhjC w1FSWrIobeM+RnDn2GHoAUhyA07K5CPRng9lsDQuK1MpgoOo3DiUlY/lSh6Ke8Q6EUv7 o7jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=c/pMCaexTxPLJj78ppz2hR1Nnq2hMOxwXWSwZaAwP1o=; b=u7jgZtmGILqt+ejioe8kUf9MxIpnMfJe/01Hn+YiidNm+GxK76yKl9KVGddMBD3Xd2 tbtZG6bdQNiEGB/w5MywGHdsbaAQjpENtA+4ojyJT0jNfmmrUxKIclzf8vJwueqt9PYh D/pBbgqn2VHYfI+TFqHrxhelqPaFEgEzzAVITq/Rb5gMdGSI0qRX4AfRBz4bykF9zuCh usgfIHUuvL+ZQ3jpV+6tSkEnw6HYGXLjGoxKMtYYZxbQVSQj9kL1I7PgjwyJu04dvgZs EmXrHH644zGG131AnucWxl9HngYm8Iw8ziwYPowpr4pWLcx0cu8Pl2Caocjouop6oa+S 3NMg== X-Gm-Message-State: ACrzQf3Cx+Pc8jVIOfA0NZKoslGP8lQPJTiOeV0EUOtibwICOoQulOHg aWDDkM1VfcCV9rt6k51M2WIbfA== X-Received: by 2002:a17:903:11c4:b0:178:634b:1485 with SMTP id q4-20020a17090311c400b00178634b1485mr24234234plh.142.1667398915892; Wed, 02 Nov 2022 07:21:55 -0700 (PDT) Received: from localhost.localdomain (80.251.214.228.16clouds.com. [80.251.214.228]) by smtp.gmail.com with ESMTPSA id o28-20020aa7979c000000b0056b8181861esm8817773pfp.19.2022.11.02.07.21.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 07:21:55 -0700 (PDT) From: Shawn Guo To: "Rafael J . Wysocki" Cc: Kevin Hilman , Ulf Hansson , Len Brown , Pavel Machek , Greg Kroah-Hartman , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Shawn Guo Subject: [PATCH v3 4/4] PM: domains: Power off[on] domain in hibernate .freeze[thaw]_noirq hook Date: Wed, 2 Nov 2022 22:21:04 +0800 Message-Id: <20221102142104.2006554-5-shawn.guo@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221102142104.2006554-1-shawn.guo@linaro.org> References: <20221102142104.2006554-1-shawn.guo@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748395980491739153?= X-GMAIL-MSGID: =?utf-8?q?1748395980491739153?= On platforms which use SHUTDOWN as hibernation mode, the genpd noirq hooks will be called like below. genpd_freeze_noirq() genpd_restore_noirq() ↓ ↑ Create snapshot image Restore target kernel ↓ ↑ genpd_thaw_noirq() genpd_freeze_noirq() ↓ ↑ Write snapshot image Read snapshot image ↓ ↑ power_down() Kernel boot As of today suspend hooks genpd_suspend[resume]_noirq() manages domain on/off state, but hibernate hooks genpd_freeze[thaw]_noirq() doesn't. This results in a different behavior of domain power state between suspend and hibernate freeze, i.e. domain is powered off for the former while on for the later. It causes a problem on platforms like i.MX where the domain needs to be powered on/off by calling clock and regulator interface. When the platform restores from hibernation, the domain is off in hardware and genpd_restore_noirq() tries to power it on, but will never succeed because software state of domain (clock and regulator) is left on from the last hibernate freeze, so kernel thinks that clock and regulator are enabled while they are actually not turned on in hardware. The consequence would be that devices in the power domain will access registers without clock or power, and cause hardware lockup. Power off[on] domain in hibernate .freeze[thaw]_noirq hook for reasons: - Align the behavior between suspend and hibernate freeze. - Have power state of domains stay in sync between hardware and software for hibernate freeze, and thus fix the lockup issue seen on i.MX platform. Signed-off-by: Shawn Guo Reviewed-by: Ulf Hansson --- drivers/base/power/domain.c | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 7cee9439fd21..2f0787d5101b 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1307,24 +1307,11 @@ static int genpd_resume_noirq(struct device *dev) */ static int genpd_freeze_noirq(struct device *dev) { - const struct generic_pm_domain *genpd; - int ret = 0; - dev_dbg(dev, "%s()\n", __func__); - genpd = dev_to_genpd(dev); - if (IS_ERR(genpd)) - return -EINVAL; - - ret = pm_generic_freeze_noirq(dev); - if (ret) - return ret; - - if (genpd->dev_ops.stop && genpd->dev_ops.start && - !pm_runtime_status_suspended(dev)) - ret = genpd_stop_dev(genpd, dev); - - return ret; + return genpd_finish_suspend(dev, + pm_generic_freeze_noirq, + pm_generic_thaw_noirq); } /** @@ -1336,23 +1323,9 @@ static int genpd_freeze_noirq(struct device *dev) */ static int genpd_thaw_noirq(struct device *dev) { - const struct generic_pm_domain *genpd; - int ret = 0; - dev_dbg(dev, "%s()\n", __func__); - genpd = dev_to_genpd(dev); - if (IS_ERR(genpd)) - return -EINVAL; - - if (genpd->dev_ops.stop && genpd->dev_ops.start && - !pm_runtime_status_suspended(dev)) { - ret = genpd_start_dev(genpd, dev); - if (ret) - return ret; - } - - return pm_generic_thaw_noirq(dev); + return genpd_finish_resume(dev, pm_generic_thaw_noirq); } /**