Commit 7049b288 authored by Nathan Lynch's avatar Nathan Lynch Committed by Michael Ellerman
Browse files

powerpc/rtas: rtas_ibm_suspend_me -> rtas_ibm_suspend_me_unsafe



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: default avatarNathan Lynch <nathanl@linux.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20201207215200.1785968-4-nathanl@linux.ibm.com
parent 970e453e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);
+3 −3
Original line number Diff line number Diff line
@@ -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;
@@ -949,7 +949,7 @@ int rtas_call_reentrant(int token, int nargs, int nret, int *outputs, ...)
}

#else /* CONFIG_PPC_PSERIES */
int rtas_ibm_suspend_me(u64 handle)
int rtas_ibm_suspend_me_unsafe(u64 handle)
{
	return -ENOSYS;
}
@@ -1185,7 +1185,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)
+1 −1
Original line number Diff line number Diff line
@@ -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);