cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

smp.h (2971B)


      1/* SPDX-License-Identifier: GPL-2.0 */
      2/*
      3 * Author: Huacai Chen <chenhuacai@loongson.cn>
      4 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
      5 */
      6#ifndef __ASM_SMP_H
      7#define __ASM_SMP_H
      8
      9#include <linux/atomic.h>
     10#include <linux/bitops.h>
     11#include <linux/linkage.h>
     12#include <linux/threads.h>
     13#include <linux/cpumask.h>
     14
     15extern int smp_num_siblings;
     16extern int num_processors;
     17extern int disabled_cpus;
     18extern cpumask_t cpu_sibling_map[];
     19extern cpumask_t cpu_core_map[];
     20extern cpumask_t cpu_foreign_map[];
     21
     22void loongson3_smp_setup(void);
     23void loongson3_prepare_cpus(unsigned int max_cpus);
     24void loongson3_boot_secondary(int cpu, struct task_struct *idle);
     25void loongson3_init_secondary(void);
     26void loongson3_smp_finish(void);
     27void loongson3_send_ipi_single(int cpu, unsigned int action);
     28void loongson3_send_ipi_mask(const struct cpumask *mask, unsigned int action);
     29#ifdef CONFIG_HOTPLUG_CPU
     30int loongson3_cpu_disable(void);
     31void loongson3_cpu_die(unsigned int cpu);
     32#endif
     33
     34static inline void plat_smp_setup(void)
     35{
     36	loongson3_smp_setup();
     37}
     38
     39static inline int raw_smp_processor_id(void)
     40{
     41#if defined(__VDSO__)
     42	extern int vdso_smp_processor_id(void)
     43		__compiletime_error("VDSO should not call smp_processor_id()");
     44	return vdso_smp_processor_id();
     45#else
     46	return current_thread_info()->cpu;
     47#endif
     48}
     49#define raw_smp_processor_id raw_smp_processor_id
     50
     51/* Map from cpu id to sequential logical cpu number.  This will only
     52 * not be idempotent when cpus failed to come on-line.	*/
     53extern int __cpu_number_map[NR_CPUS];
     54#define cpu_number_map(cpu)  __cpu_number_map[cpu]
     55
     56/* The reverse map from sequential logical cpu number to cpu id.  */
     57extern int __cpu_logical_map[NR_CPUS];
     58#define cpu_logical_map(cpu)  __cpu_logical_map[cpu]
     59
     60#define cpu_physical_id(cpu)	cpu_logical_map(cpu)
     61
     62#define SMP_BOOT_CPU		0x1
     63#define SMP_RESCHEDULE		0x2
     64#define SMP_CALL_FUNCTION	0x4
     65
     66struct secondary_data {
     67	unsigned long stack;
     68	unsigned long thread_info;
     69};
     70extern struct secondary_data cpuboot_data;
     71
     72extern asmlinkage void smpboot_entry(void);
     73
     74extern void calculate_cpu_foreign_map(void);
     75
     76/*
     77 * Generate IPI list text
     78 */
     79extern void show_ipi_list(struct seq_file *p, int prec);
     80
     81/*
     82 * This function sends a 'reschedule' IPI to another CPU.
     83 * it goes straight through and wastes no time serializing
     84 * anything. Worst case is that we lose a reschedule ...
     85 */
     86static inline void smp_send_reschedule(int cpu)
     87{
     88	loongson3_send_ipi_single(cpu, SMP_RESCHEDULE);
     89}
     90
     91static inline void arch_send_call_function_single_ipi(int cpu)
     92{
     93	loongson3_send_ipi_single(cpu, SMP_CALL_FUNCTION);
     94}
     95
     96static inline void arch_send_call_function_ipi_mask(const struct cpumask *mask)
     97{
     98	loongson3_send_ipi_mask(mask, SMP_CALL_FUNCTION);
     99}
    100
    101#ifdef CONFIG_HOTPLUG_CPU
    102static inline int __cpu_disable(void)
    103{
    104	return loongson3_cpu_disable();
    105}
    106
    107static inline void __cpu_die(unsigned int cpu)
    108{
    109	loongson3_cpu_die(cpu);
    110}
    111
    112extern void play_dead(void);
    113#endif
    114
    115#endif /* __ASM_SMP_H */