linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Nathan Lynch <nathanl@linux.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: tyreld@linux.ibm.com, ajd@linux.ibm.com, mmc@linux.vnet.ibm.com,
	cforno12@linux.vnet.ibm.com, drt@linux.vnet.ibm.com,
	brking@linux.ibm.com
Subject: [PATCH 04/29] powerpc/rtas: rtas_ibm_suspend_me -> rtas_ibm_suspend_me_unsafe
Date: Thu, 29 Oct 2020 20:17:40 -0500	[thread overview]
Message-ID: <20201030011805.1224603-5-nathanl@linux.ibm.com> (raw)
In-Reply-To: <20201030011805.1224603-1-nathanl@linux.ibm.com>

The pseries partition suspend sequence requires that all active CPUs
call H_JOIN, which suspends all but one of them with interrupts
disabled. The "chosen" CPU is then to call ibm,suspend-me to complete
the suspend. Upon returning from ibm,suspend-me, the chosen CPU is to
use H_PROD to wake the joined CPUs.

Using on_each_cpu() for this, as rtas_ibm_suspend_me() does to
implement partition migration, is susceptible to deadlock with other
users of on_each_cpu() and with users of stop_machine APIs. The
callback passed to on_each_cpu() is not allowed to synchronize with
other CPUs in the way it is used here.

Complicating the fix is the fact that rtas_ibm_suspend_me() also
occupies the function name that should be used to provide a more
conventional wrapper for ibm,suspend-me. Rename rtas_ibm_suspend_me()
to rtas_ibm_suspend_me_unsafe() to free up the name and indicate that
it should not gain users.

Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
---
 arch/powerpc/include/asm/rtas.h           | 2 +-
 arch/powerpc/kernel/rtas.c                | 6 +++---
 arch/powerpc/platforms/pseries/mobility.c | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h
index f060181a0d32..8436ed01567b 100644
--- a/arch/powerpc/include/asm/rtas.h
+++ b/arch/powerpc/include/asm/rtas.h
@@ -257,7 +257,7 @@ extern int rtas_set_indicator_fast(int indicator, int index, int new_value);
 extern void rtas_progress(char *s, unsigned short hex);
 extern int rtas_suspend_cpu(struct rtas_suspend_me_data *data);
 extern int rtas_suspend_last_cpu(struct rtas_suspend_me_data *data);
-extern int rtas_ibm_suspend_me(u64 handle);
+int rtas_ibm_suspend_me_unsafe(u64 handle);
 
 struct rtc_time;
 extern time64_t rtas_get_boot_time(void);
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index 132b2ae39009..33adefa84a42 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -843,7 +843,7 @@ static void rtas_percpu_suspend_me(void *info)
 	__rtas_suspend_cpu((struct rtas_suspend_me_data *)info, 1);
 }
 
-int rtas_ibm_suspend_me(u64 handle)
+int rtas_ibm_suspend_me_unsafe(u64 handle)
 {
 	long state;
 	long rc;
@@ -898,7 +898,7 @@ int rtas_ibm_suspend_me(u64 handle)
 	return atomic_read(&data.error);
 }
 #else /* CONFIG_PPC_PSERIES */
-int rtas_ibm_suspend_me(u64 handle)
+int rtas_ibm_suspend_me_unsafe(u64 handle)
 {
 	return -ENOSYS;
 }
@@ -1184,7 +1184,7 @@ SYSCALL_DEFINE1(rtas, struct rtas_args __user *, uargs)
 		int rc = 0;
 		u64 handle = ((u64)be32_to_cpu(args.args[0]) << 32)
 		              | be32_to_cpu(args.args[1]);
-		rc = rtas_ibm_suspend_me(handle);
+		rc = rtas_ibm_suspend_me_unsafe(handle);
 		if (rc == -EAGAIN)
 			args.rets[0] = cpu_to_be32(RTAS_NOT_SUSPENDABLE);
 		else if (rc == -EIO)
diff --git a/arch/powerpc/platforms/pseries/mobility.c b/arch/powerpc/platforms/pseries/mobility.c
index d6f4162478a5..b6de65cbfcd9 100644
--- a/arch/powerpc/platforms/pseries/mobility.c
+++ b/arch/powerpc/platforms/pseries/mobility.c
@@ -370,7 +370,7 @@ static ssize_t migration_store(struct class *class,
 		return rc;
 
 	do {
-		rc = rtas_ibm_suspend_me(streamid);
+		rc = rtas_ibm_suspend_me_unsafe(streamid);
 		if (rc == -EAGAIN)
 			ssleep(1);
 	} while (rc == -EAGAIN);
-- 
2.25.4


  parent reply	other threads:[~2020-10-30  1:28 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-30  1:17 [PATCH 00/29] partition suspend updates Nathan Lynch
2020-10-30  1:17 ` [PATCH 01/29] powerpc/rtas: move rtas_call_reentrant() out of pseries guards Nathan Lynch
2020-12-04 20:37   ` Nathan Lynch
2020-10-30  1:17 ` [PATCH 02/29] powerpc/rtas: prevent suspend-related sys_rtas use on LE Nathan Lynch
2020-10-30  3:45   ` Andrew Donnellan
2020-10-30 12:10     ` Nathan Lynch
2020-11-06 14:59       ` Andrew Donnellan
2020-11-06 16:44         ` Nathan Lynch
2020-10-30  1:17 ` [PATCH 03/29] powerpc/rtas: complete ibm,suspend-me status codes Nathan Lynch
2020-12-04 12:52   ` Michael Ellerman
2020-12-04 14:40     ` Nathan Lynch
2020-10-30  1:17 ` Nathan Lynch [this message]
2020-10-30  1:17 ` [PATCH 05/29] powerpc/rtas: add rtas_ibm_suspend_me() Nathan Lynch
2020-10-30  1:17 ` [PATCH 06/29] powerpc/rtas: add rtas_activate_firmware() Nathan Lynch
2020-10-30  1:17 ` [PATCH 07/29] powerpc/hvcall: add token and codes for H_VASI_SIGNAL Nathan Lynch
2020-10-30  1:17 ` [PATCH 08/29] powerpc/pseries/mobility: don't error on absence of ibm, update-nodes Nathan Lynch
2020-10-30  1:17 ` [PATCH 09/29] powerpc/pseries/mobility: add missing break to default case Nathan Lynch
2020-10-30  1:17 ` [PATCH 10/29] powerpc/pseries/mobility: error message improvements Nathan Lynch
2020-10-30  1:17 ` [PATCH 11/29] powerpc/pseries/mobility: use rtas_activate_firmware() on resume Nathan Lynch
2020-10-30  1:17 ` [PATCH 12/29] powerpc/pseries/mobility: extract VASI session polling logic Nathan Lynch
2020-12-04 12:51   ` Michael Ellerman
2020-12-04 14:46     ` Nathan Lynch
2020-10-30  1:17 ` [PATCH 13/29] powerpc/pseries/mobility: use stop_machine for join/suspend Nathan Lynch
2020-12-04 12:52   ` Michael Ellerman
2020-12-04 16:01     ` Nathan Lynch
2020-12-05 11:03       ` Michael Ellerman
2020-10-30  1:17 ` [PATCH 14/29] powerpc/pseries/mobility: signal suspend cancellation to platform Nathan Lynch
2020-10-30  1:17 ` [PATCH 15/29] powerpc/pseries/mobility: retry partition suspend after error Nathan Lynch
2020-10-30  1:17 ` [PATCH 16/29] powerpc/rtas: dispatch partition migration requests to pseries Nathan Lynch
2020-12-04 12:52   ` Michael Ellerman
2020-12-04 16:04     ` Nathan Lynch
2020-10-30  1:17 ` [PATCH 17/29] powerpc/rtas: remove rtas_ibm_suspend_me_unsafe() Nathan Lynch
2020-10-30  1:17 ` [PATCH 18/29] powerpc/pseries/hibernation: drop pseries_suspend_begin() from suspend ops Nathan Lynch
2020-10-30  1:17 ` [PATCH 19/29] powerpc/pseries/hibernation: pass stream id via function arguments Nathan Lynch
2020-10-30  1:17 ` [PATCH 20/29] powerpc/pseries/hibernation: remove pseries_suspend_cpu() Nathan Lynch
2020-10-30  1:17 ` [PATCH 21/29] powerpc/machdep: remove suspend_disable_cpu() Nathan Lynch
2020-10-30  1:17 ` [PATCH 22/29] powerpc/rtas: remove rtas_suspend_cpu() Nathan Lynch
2020-10-30  1:17 ` [PATCH 23/29] powerpc/pseries/hibernation: switch to rtas_ibm_suspend_me() Nathan Lynch
2020-10-30  1:18 ` [PATCH 24/29] powerpc/rtas: remove unused rtas_suspend_last_cpu() Nathan Lynch
2020-10-30  1:18 ` [PATCH 25/29] powerpc/pseries/hibernation: remove redundant cacheinfo update Nathan Lynch
2020-10-30  1:18 ` [PATCH 26/29] powerpc/pseries/hibernation: perform post-suspend fixups later Nathan Lynch
2020-10-30  1:18 ` [PATCH 27/29] powerpc/pseries/hibernation: remove prepare_late() callback Nathan Lynch
2020-10-30  1:18 ` [PATCH 28/29] powerpc/rtas: remove unused rtas_suspend_me_data Nathan Lynch
2020-10-30  1:18 ` [PATCH 29/29] powerpc/pseries/mobility: refactor node lookup during DT update Nathan Lynch
2020-11-20 16:09   ` Nathan Lynch

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=20201030011805.1224603-5-nathanl@linux.ibm.com \
    --to=nathanl@linux.ibm.com \
    --cc=ajd@linux.ibm.com \
    --cc=brking@linux.ibm.com \
    --cc=cforno12@linux.vnet.ibm.com \
    --cc=drt@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mmc@linux.vnet.ibm.com \
    --cc=tyreld@linux.ibm.com \
    /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).