Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
at v6.12 117 lines 2.6 kB view raw
1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* 3 * Copyright (C) 2012 Regents of the University of California 4 */ 5 6#ifndef _ASM_RISCV_SMP_H 7#define _ASM_RISCV_SMP_H 8 9#include <linux/cpumask.h> 10#include <linux/irqreturn.h> 11#include <linux/thread_info.h> 12 13#define INVALID_HARTID ULONG_MAX 14 15struct seq_file; 16extern unsigned long boot_cpu_hartid; 17 18#ifdef CONFIG_SMP 19 20#include <linux/jump_label.h> 21 22/* 23 * Mapping between linux logical cpu index and hartid. 24 */ 25extern unsigned long __cpuid_to_hartid_map[NR_CPUS]; 26#define cpuid_to_hartid_map(cpu) __cpuid_to_hartid_map[cpu] 27 28/* print IPI stats */ 29void show_ipi_stats(struct seq_file *p, int prec); 30 31/* SMP initialization hook for setup_arch */ 32void __init setup_smp(void); 33 34/* Hook for the generic smp_call_function_many() routine. */ 35void arch_send_call_function_ipi_mask(struct cpumask *mask); 36 37/* Hook for the generic smp_call_function_single() routine. */ 38void arch_send_call_function_single_ipi(int cpu); 39 40int riscv_hartid_to_cpuid(unsigned long hartid); 41 42/* Enable IPI for CPU hotplug */ 43void riscv_ipi_enable(void); 44 45/* Disable IPI for CPU hotplug */ 46void riscv_ipi_disable(void); 47 48/* Check if IPI interrupt numbers are available */ 49bool riscv_ipi_have_virq_range(void); 50 51/* Set the IPI interrupt numbers for arch (called by irqchip drivers) */ 52void riscv_ipi_set_virq_range(int virq, int nr); 53 54/* Check other CPUs stop or not */ 55bool smp_crash_stop_failed(void); 56 57/* Secondary hart entry */ 58asmlinkage void smp_callin(void); 59 60/* 61 * Obtains the hart ID of the currently executing task. This relies on 62 * THREAD_INFO_IN_TASK, but we define that unconditionally. 63 */ 64#define raw_smp_processor_id() (current_thread_info()->cpu) 65 66#if defined CONFIG_HOTPLUG_CPU 67int __cpu_disable(void); 68static inline void __cpu_die(unsigned int cpu) { } 69#endif /* CONFIG_HOTPLUG_CPU */ 70 71#else 72 73static inline void show_ipi_stats(struct seq_file *p, int prec) 74{ 75} 76 77static inline int riscv_hartid_to_cpuid(unsigned long hartid) 78{ 79 if (hartid == boot_cpu_hartid) 80 return 0; 81 82 return -1; 83} 84static inline unsigned long cpuid_to_hartid_map(int cpu) 85{ 86 return boot_cpu_hartid; 87} 88 89static inline void riscv_ipi_enable(void) 90{ 91} 92 93static inline void riscv_ipi_disable(void) 94{ 95} 96 97static inline bool riscv_ipi_have_virq_range(void) 98{ 99 return false; 100} 101 102static inline void riscv_ipi_set_virq_range(int virq, int nr) 103{ 104} 105 106#endif /* CONFIG_SMP */ 107 108#if defined(CONFIG_HOTPLUG_CPU) && (CONFIG_SMP) 109bool cpu_has_hotplug(unsigned int cpu); 110#else 111static inline bool cpu_has_hotplug(unsigned int cpu) 112{ 113 return false; 114} 115#endif 116 117#endif /* _ASM_RISCV_SMP_H */