File: cpu_ops_spinwait.c

package info (click to toggle)
linux 5.10.46-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,191,996 kB
  • sloc: ansic: 19,502,768; asm: 263,759; sh: 73,960; makefile: 44,724; perl: 34,644; python: 32,387; cpp: 6,070; yacc: 4,755; lex: 2,742; awk: 1,214; ruby: 25; sed: 5
file content (43 lines) | stat: -rw-r--r-- 1,153 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2020 Western Digital Corporation or its affiliates.
 */

#include <linux/errno.h>
#include <linux/of.h>
#include <linux/string.h>
#include <asm/cpu_ops.h>
#include <asm/sbi.h>
#include <asm/smp.h>

const struct cpu_operations cpu_ops_spinwait;

static int spinwait_cpu_prepare(unsigned int cpuid)
{
	if (!cpu_ops_spinwait.cpu_start) {
		pr_err("cpu start method not defined for CPU [%d]\n", cpuid);
		return -ENODEV;
	}
	return 0;
}

static int spinwait_cpu_start(unsigned int cpuid, struct task_struct *tidle)
{
	/*
	 * In this protocol, all cpus boot on their own accord.  _start
	 * selects the first cpu to boot the kernel and causes the remainder
	 * of the cpus to spin in a loop waiting for their stack pointer to be
	 * setup by that main cpu.  Writing to bootdata
	 * (i.e __cpu_up_stack_pointer) signals to the spinning cpus that they
	 * can continue the boot process.
	 */
	cpu_update_secondary_bootdata(cpuid, tidle);

	return 0;
}

const struct cpu_operations cpu_ops_spinwait = {
	.name		= "spinwait",
	.cpu_prepare	= spinwait_cpu_prepare,
	.cpu_start	= spinwait_cpu_start,
};