Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp349528pxt; Wed, 4 Aug 2021 12:50:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAHpXUVfcL+Akd+qiWCYlaulDO+1ajwDVx9q+K/Va2soedJvrLI0QvBju4og/4a8hunyEB X-Received: by 2002:a6b:1642:: with SMTP id 63mr882126iow.68.1628106646924; Wed, 04 Aug 2021 12:50:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628106646; cv=none; d=google.com; s=arc-20160816; b=jmuBaq9dWn3DJ+QL+4Ck6Ep+Qkk4ogQRaDz9FaTXKmW1jjXIIAvXcHtfcuIa6k7hRz WfzeAqT1+2V3VkI4qrCeQNU27A18C10Wa3PmDbOaLPnmMrjvyW8aCBIhNX4FSBIRcbfR 0eEt2wdWqE3/SkOdJJnut3JTXNWzKfBUVMoWB1thmCI69zd2zzOsZWkhpas/y9jcbs/y KDbguipAQnw0SUMg2XCphdBV1NcQITzuL9t6rSzulKfcgpjvdlrskvRqX+xK/Q/ZWuRM BatTkHk9BgxWCmCzf/CkybnLdxVogPOlayLIj7dKPp3cuD+E9CKC5wxZK1UePLiiD6Kg KOiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=DWa0uh1W/Nbg1hoTafvW6Mebrx5ojhLkUa52uY/Ibow=; b=K6P3AnLmaG2igBHeUP+k2i8AGBJtQE+dTnyJLKxk+mhdT6AIPYzTPu7zyKTh5wOqwo E12XMef43ky2CTwnZxMTn11XC95mCUm3AaoeRI4mcczPY4Ls7ac8bMOrQbuFAcRo62Mh 6hrRwA9jNBOSIARNOL5qU1TIgSmDwsxuWR5eISqVhkA5mmIWSn0dy4IZr91IB1n3/dVM oB2NxSeWiJPu6mxUjvZ9JNVWZ2HHcCp1+ITNRGS5T5Nt1S4whzl3m36jZH2FUGUHVAPm bYmn/YhnpNGxPBrGEhQPY+q1ZaiewFVm5fhPP3hn8YpmvzbXiJtyDp6OW218aFPiO1ot zP3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m6si3147027iol.83.2021.08.04.12.50.30; Wed, 04 Aug 2021 12:50:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237953AbhHDQcr (ORCPT + 99 others); Wed, 4 Aug 2021 12:32:47 -0400 Received: from mail-oi1-f176.google.com ([209.85.167.176]:34711 "EHLO mail-oi1-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237804AbhHDQcr (ORCPT ); Wed, 4 Aug 2021 12:32:47 -0400 Received: by mail-oi1-f176.google.com with SMTP id t128so3528993oig.1; Wed, 04 Aug 2021 09:32:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DWa0uh1W/Nbg1hoTafvW6Mebrx5ojhLkUa52uY/Ibow=; b=iXVpWRQB9v63X2IXmirShLmiPi/oka3OZDc34O2ueIosTM73QIf8Fj9ARYPKrmHkGG 6qJSCYBBzMKUJpdCJyBp/yd8MJfZCC4+/4ICTkJS2uptyqiG7IHRBiQlQversMjPjvUj tnAABiK137P6UYu0eRvxhgQSQdEloANI0vC5zaWiXcCgzCLZIwMBswgSt0uaylvHWBej 7Kxh/jFq8M7p5sxj2/gMCYC5zb52FEI6WSHqfAyhB09zdOE8+dvyJjIBSfVwGPrehVjY ySc70mJl60m2p6A6OE+7kRmJqQN6hB7NlymlQ3FvRO4UP7pkrYfDwGFCy4nJkfg+JxvQ drWw== X-Gm-Message-State: AOAM533igL+f39MIPkVLVqLpW9qwXWaYo78whWKt+HdYBpItu4jZW3J0 PeZNIVs0a2dksX19/oiY8VjG+H+YrJnYyzOOVuk= X-Received: by 2002:a05:6808:198c:: with SMTP id bj12mr252366oib.71.1628094753377; Wed, 04 Aug 2021 09:32:33 -0700 (PDT) MIME-Version: 1.0 References: <20210709003204.26944-1-win239@126.com> In-Reply-To: <20210709003204.26944-1-win239@126.com> From: "Rafael J. Wysocki" Date: Wed, 4 Aug 2021 18:32:22 +0200 Message-ID: Subject: Re: [PATCH] PM / s2idle: Fix the failure of specifying "mem_sleep_default=" parameter To: xiongxin Cc: "Rafael J. Wysocki" , Pavel Machek , Linux PM , Linux Kernel Mailing List , xiongxin , Sudeep Holla Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 9, 2021 at 3:03 AM xiongxin wrote: > > From: xiongxin > > On the arm64 platform, the psci driver is used by default to set the > suspend_ops structure; but the psci_acpi_init() function is called > before the command-line parameter "mem_sleep_default=" is specified; You seem to mean that psci_acpi_init() runs before mem_sleep_default_setup() and so there is a confusion regarding the mem_sleep_default setting. Clearly, suspend_ops cannot be set before mem_sleep_default_setup() runs, so I'd prefer to fix the ordering instead of hacking the latter to fix up the mess. > the user cannot set the desired suspend mode through the > "mem_sleep_default=" parameter; > > In mem_sleep_default_setup(), judge whether suspend_ops is set, if it > has been assigned, rewrite the value of mem_sleep_current variable; in > order to complete the user setting; > > Signed-off-by: xiongxin > > diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c > index d8cae434f9eb..bef4b17de3f6 100644 > --- a/kernel/power/suspend.c > +++ b/kernel/power/suspend.c > @@ -192,6 +192,21 @@ static int __init mem_sleep_default_setup(char *str) > break; > } > > + /* > + * When the suspend_ops has been set, "mem_sleep_default=*" will > + * be invalid, here to fix this situation. > + */ > + if (suspend_ops) { > + if (mem_sleep_default == PM_SUSPEND_TO_IDLE) > + mem_sleep_current = PM_SUSPEND_TO_IDLE; > + else if ((mem_sleep_default == PM_SUSPEND_STANDBY) && > + valid_state(PM_SUSPEND_STANDBY)) > + mem_sleep_current = PM_SUSPEND_STANDBY; > + else if ((mem_sleep_default >= PM_SUSPEND_MEM) && > + valid_state(PM_SUSPEND_MEM)) > + mem_sleep_current = PM_SUSPEND_MEM; > + } > + > return 1; > } > __setup("mem_sleep_default=", mem_sleep_default_setup); > -- > 2.25.1 >