mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-29 07:04:10 +08:00
e4aa991c05
Running sparse shows cpu_ops_spinwait.c is missing two definitions
found in head.h, so include it to stop the following warnings:
arch/riscv/kernel/cpu_ops_spinwait.c:15:6: warning: symbol '__cpu_spinwait_stack_pointer' was not declared. Should it be static?
arch/riscv/kernel/cpu_ops_spinwait.c:16:6: warning: symbol '__cpu_spinwait_task_pointer' was not declared. Should it be static?
Signed-off-by: Ben Dooks <ben.dooks@sifive.com>
Link: https://lore.kernel.org/r/20220713215306.94675-1-ben.dooks@sifive.com
Fixes: c78f94f35c
("RISC-V: Use __cpu_up_stack/task_pointer only for spinwait method")
Cc: stable@vger.kernel.org
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
71 lines
2.1 KiB
C
71 lines
2.1 KiB
C
// 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 <linux/sched/task_stack.h>
|
|
#include <asm/cpu_ops.h>
|
|
#include <asm/sbi.h>
|
|
#include <asm/smp.h>
|
|
|
|
#include "head.h"
|
|
|
|
const struct cpu_operations cpu_ops_spinwait;
|
|
void *__cpu_spinwait_stack_pointer[NR_CPUS] __section(".data");
|
|
void *__cpu_spinwait_task_pointer[NR_CPUS] __section(".data");
|
|
|
|
static void cpu_update_secondary_bootdata(unsigned int cpuid,
|
|
struct task_struct *tidle)
|
|
{
|
|
unsigned long hartid = cpuid_to_hartid_map(cpuid);
|
|
|
|
/*
|
|
* The hartid must be less than NR_CPUS to avoid out-of-bound access
|
|
* errors for __cpu_spinwait_stack/task_pointer. That is not always possible
|
|
* for platforms with discontiguous hartid numbering scheme. That's why
|
|
* spinwait booting is not the recommended approach for any platforms
|
|
* booting Linux in S-mode and can be disabled in the future.
|
|
*/
|
|
if (hartid == INVALID_HARTID || hartid >= (unsigned long) NR_CPUS)
|
|
return;
|
|
|
|
/* Make sure tidle is updated */
|
|
smp_mb();
|
|
WRITE_ONCE(__cpu_spinwait_stack_pointer[hartid],
|
|
task_stack_page(tidle) + THREAD_SIZE);
|
|
WRITE_ONCE(__cpu_spinwait_task_pointer[hartid], tidle);
|
|
}
|
|
|
|
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_spinwait_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,
|
|
};
|