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

powerpc/pseries/mobility: use struct for shared state



The atomic_t counter is the only shared state for the join/suspend
sequence so far, but that will change. Contain it in a
struct (pseries_suspend_info), and document its intended use. No
functional change.

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/20210315080045.460331-2-nathanl@linux.ibm.com
parent cc7a0bb0
Loading
Loading
Loading
Loading
+19 −3
Original line number Diff line number Diff line
@@ -452,9 +452,21 @@ static int do_suspend(void)
	return ret;
}

/**
 * struct pseries_suspend_info - State shared between CPUs for join/suspend.
 * @counter: Threads are to increment this upon resuming from suspend
 *           or if an error is received from H_JOIN. The thread which performs
 *           the first increment (i.e. sets it to 1) is responsible for
 *           waking the other threads.
 */
struct pseries_suspend_info {
	atomic_t counter;
};

static int do_join(void *arg)
{
	atomic_t *counter = arg;
	struct pseries_suspend_info *info = arg;
	atomic_t *counter = &info->counter;
	long hvrc;
	int ret;

@@ -535,11 +547,15 @@ static int pseries_suspend(u64 handle)
	int ret;

	while (true) {
		atomic_t counter = ATOMIC_INIT(0);
		struct pseries_suspend_info info;
		unsigned long vasi_state;
		int vasi_err;

		ret = stop_machine(do_join, &counter, cpu_online_mask);
		info = (struct pseries_suspend_info) {
			.counter = ATOMIC_INIT(0),
		};

		ret = stop_machine(do_join, &info, cpu_online_mask);
		if (ret == 0)
			break;
		/*