linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: xiongxin <win239@126.com>
To: rjw@rjwysocki.net, pavel@ucw.cz
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	xiongxin <xiongxin@kylinos.cn>
Subject: [PATCH] PM / s2idle: Fix the failure of specifying "mem_sleep_default=" parameter
Date: Fri,  9 Jul 2021 08:32:04 +0800	[thread overview]
Message-ID: <20210709003204.26944-1-win239@126.com> (raw)

From: xiongxin <xiongxin@kylinos.cn>

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;
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 <xiongxin@kylinos.cn>

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


             reply	other threads:[~2021-07-09  1:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-09  0:32 xiongxin [this message]
2021-07-09 15:40 ` [PATCH] PM / s2idle: Fix the failure of specifying "mem_sleep_default=" parameter Rafael J. Wysocki
2021-08-04 16:32 ` Rafael J. Wysocki
  -- strict thread matches above, loose matches on Subject: below --
2021-07-07  7:32 xiongxin
2021-07-04  5:49 xiongxin

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=20210709003204.26944-1-win239@126.com \
    --to=win239@126.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rjw@rjwysocki.net \
    --cc=xiongxin@kylinos.cn \
    /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).