“5568e1a3a7e8074e61869e4bf34b504511c62a5f”上不存在“git@gitcode.net:weixin_50379372/gpt-vue.git”
未验证 提交 a413cd0d 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!425 update patches for sw64 architecture

Merge Pull Request from: @guzitao 
 
These patches generally cover the following tasks:

1.optimize kernel cores, remove unused codes, fix compile errors
2.fixes for perf, iommu
3.add support, add CONFIG_THREAD_INFO_IN_TASK support, support SIMD IO access in guest, add DVFS support 
 
Link:https://gitee.com/openeuler/kernel/pulls/425 

Reviewed-by: Zheng Zengkai <zhengzengkai@huawei.com> 
Signed-off-by: Zheng Zengkai <zhengzengkai@huawei.com> 
...@@ -107,6 +107,7 @@ config SW64 ...@@ -107,6 +107,7 @@ config SW64
select SET_FS select SET_FS
select SPARSEMEM_EXTREME if SPARSEMEM select SPARSEMEM_EXTREME if SPARSEMEM
select SWIOTLB select SWIOTLB
select THREAD_INFO_IN_TASK
config LOCKDEP_SUPPORT config LOCKDEP_SUPPORT
def_bool y def_bool y
......
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
struct clk; struct clk;
extern struct cpufreq_frequency_table sw64_clockmod_table[];
extern char curruent_policy[CPUFREQ_NAME_LEN]; extern char curruent_policy[CPUFREQ_NAME_LEN];
struct clk_ops { struct clk_ops {
...@@ -44,7 +42,7 @@ struct clk { ...@@ -44,7 +42,7 @@ struct clk {
int clk_init(void); int clk_init(void);
void sw64_set_rate(unsigned long rate); void sw64_set_rate(unsigned int index);
struct clk *sw64_clk_get(struct device *dev, const char *id); struct clk *sw64_clk_get(struct device *dev, const char *id);
......
...@@ -2,9 +2,18 @@ ...@@ -2,9 +2,18 @@
#ifndef _ASM_SW64_CURRENT_H #ifndef _ASM_SW64_CURRENT_H
#define _ASM_SW64_CURRENT_H #define _ASM_SW64_CURRENT_H
#include <linux/thread_info.h> #ifndef __ASSEMBLY__
#define get_current() (current_thread_info()->task) struct task_struct;
#define current get_current() static __always_inline struct task_struct *get_current(void)
{
register struct task_struct *tp __asm__("$8");
return tp;
}
#define current get_current()
#endif /* __ASSEMBLY__ */
#endif /* _ASM_SW64_CURRENT_H */ #endif /* _ASM_SW64_CURRENT_H */
...@@ -6,6 +6,10 @@ ...@@ -6,6 +6,10 @@
#include <asm/early_ioremap.h> #include <asm/early_ioremap.h>
#ifdef CONFIG_EFI #ifdef CONFIG_EFI
extern void efi_init(void); extern void efi_init(void);
extern unsigned long entSuspend;
#define SLEEP_ENTRY_GUID EFI_GUID(0x59cb76bb, 0x9c3a, 0x4c8f, 0xbd, 0x5c, 0xc0, 0x0f, 0x20, 0x61, 0x18, 0x4b)
#else #else
#define efi_init() #define efi_init()
#define efi_idmap_init() #define efi_idmap_init()
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
#define HMC_sleepen 0x05 #define HMC_sleepen 0x05
#define HMC_rdksp 0x06 #define HMC_rdksp 0x06
#define HMC_wrasid 0x08 #define HMC_wrasid 0x08
#define HMC_rdktp 0x09
#define HMC_wrktp 0x0A
#define HMC_rdptbr 0x0B #define HMC_rdptbr 0x0B
#define HMC_wrptbr 0x0C #define HMC_wrptbr 0x0C
#define HMC_wrksp 0x0E #define HMC_wrksp 0x0E
...@@ -150,6 +152,11 @@ __CALL_HMC_VOID(wrfen); ...@@ -150,6 +152,11 @@ __CALL_HMC_VOID(wrfen);
__CALL_HMC_VOID(sleepen); __CALL_HMC_VOID(sleepen);
__CALL_HMC_VOID(mtinten); __CALL_HMC_VOID(mtinten);
__CALL_HMC_VOID(rdktp);
#define restore_ktp() rdktp()
__CALL_HMC_VOID(wrktp);
#define save_ktp() wrktp()
__CALL_HMC_R0(rdps, unsigned long); __CALL_HMC_R0(rdps, unsigned long);
__CALL_HMC_R0(rdusp, unsigned long); __CALL_HMC_R0(rdusp, unsigned long);
......
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _ASM_SW64_IDLE_H
#define _ASM_SW64_IDLE_H
extern void arch_cpu_idle(void);
#endif /* _ASM_SW64_IDLE_H */
...@@ -2,8 +2,10 @@ ...@@ -2,8 +2,10 @@
#ifndef _ASM_SW64_PLATFORM_H #ifndef _ASM_SW64_PLATFORM_H
#define _ASM_SW64_PLATFORM_H #define _ASM_SW64_PLATFORM_H
#include <linux/types.h>
#include <asm/chip3_io.h>
struct sw64_platform_ops { struct sw64_platform_ops {
void (*kill_arch)(int mode);
void __iomem *(*ioportmap)(unsigned long); void __iomem *(*ioportmap)(unsigned long);
void (*register_platform_devices)(void); void (*register_platform_devices)(void);
void (*ops_fixup)(void); void (*ops_fixup)(void);
...@@ -13,5 +15,15 @@ struct sw64_platform_ops { ...@@ -13,5 +15,15 @@ struct sw64_platform_ops {
extern struct sw64_platform_ops *sw64_platform; extern struct sw64_platform_ops *sw64_platform;
extern struct sw64_platform_ops xuelang_ops; extern struct sw64_platform_ops xuelang_ops;
extern struct boot_params *sunway_boot_params;
extern void sw64_halt(void);
extern void sw64_poweroff(void);
extern void sw64_restart(void);
extern void (*pm_restart)(void);
extern void (*pm_halt)(void);
extern int i2c_set_adapter(void);
extern void cpld_write(uint8_t slave_addr, uint8_t reg, uint8_t data);
extern void fix_jm585_reset(void);
#endif /* _ASM_SW64_PLATFORM_H */ #endif /* _ASM_SW64_PLATFORM_H */
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include <asm/ptrace.h> #include <asm/ptrace.h>
#define task_pt_regs(task) \ #define task_pt_regs(task) \
((struct pt_regs *) (task_stack_page(task) + 2 * PAGE_SIZE) - 1) ((struct pt_regs *) (task->stack + THREAD_SIZE) - 1)
/* /*
* Returns current instruction pointer ("program counter"). * Returns current instruction pointer ("program counter").
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include <uapi/asm/ptrace.h> #include <uapi/asm/ptrace.h>
#include <asm/hmcall.h> #include <asm/hmcall.h>
#include <asm/thread_info.h>
#include <asm/page.h> #include <asm/page.h>
/* /*
...@@ -58,11 +57,6 @@ struct pt_regs { ...@@ -58,11 +57,6 @@ struct pt_regs {
#define kernel_stack_pointer(regs) ((unsigned long)((regs) + 1)) #define kernel_stack_pointer(regs) ((unsigned long)((regs) + 1))
#define instruction_pointer_set(regs, val) ((regs)->pc = val) #define instruction_pointer_set(regs, val) ((regs)->pc = val)
#define current_pt_regs() \
((struct pt_regs *) ((char *)current_thread_info() + 2 * PAGE_SIZE) - 1)
#define signal_pt_regs current_pt_regs
#define force_successful_syscall_return() (current_pt_regs()->r0 = 0) #define force_successful_syscall_return() (current_pt_regs()->r0 = 0)
#define MAX_REG_OFFSET (offsetof(struct pt_regs, r18)) #define MAX_REG_OFFSET (offsetof(struct pt_regs, r18))
......
...@@ -2,14 +2,16 @@ ...@@ -2,14 +2,16 @@
#ifndef _ASM_SW64_SMP_H #ifndef _ASM_SW64_SMP_H
#define _ASM_SW64_SMP_H #define _ASM_SW64_SMP_H
#include <linux/threads.h>
#include <linux/cpumask.h>
#include <linux/bitops.h>
#include <asm/hmcall.h>
#include <asm/hcall.h>
#include <asm/core.h> #include <asm/core.h>
#include <asm/current.h>
#include <asm/hcall.h>
#include <asm/hmcall.h>
#include <asm/hw_init.h> #include <asm/hw_init.h>
#include <linux/bitops.h>
#include <linux/cpumask.h>
#include <linux/threads.h>
/* HACK: Cabrio WHAMI return value is bogus if more than 8 bits used.. :-( */ /* HACK: Cabrio WHAMI return value is bogus if more than 8 bits used.. :-( */
extern cpumask_t core_start; extern cpumask_t core_start;
...@@ -55,7 +57,13 @@ struct smp_rcb_struct { ...@@ -55,7 +57,13 @@ struct smp_rcb_struct {
#define INIT_SMP_RCB ((struct smp_rcb_struct *) __va(0x820000UL)) #define INIT_SMP_RCB ((struct smp_rcb_struct *) __va(0x820000UL))
#define hard_smp_processor_id() __hard_smp_processor_id() #define hard_smp_processor_id() __hard_smp_processor_id()
#define raw_smp_processor_id() (current_thread_info()->cpu)
#ifdef GENERATING_ASM_OFFSETS
#define raw_smp_processor_id() (0)
#else
#include <asm/asm-offsets.h>
#define raw_smp_processor_id() (*((unsigned int *)((void *)current + TASK_CPU)))
#endif
/* The map from sequential logical cpu number to hard cid. */ /* The map from sequential logical cpu number to hard cid. */
extern int __cpu_to_rcid[NR_CPUS]; extern int __cpu_to_rcid[NR_CPUS];
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#ifdef __KERNEL__ #ifdef __KERNEL__
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#include <asm/processor.h>
#include <asm/types.h> #include <asm/types.h>
#include <asm/sysinfo.h> #include <asm/sysinfo.h>
...@@ -25,12 +24,11 @@ struct pcb_struct { ...@@ -25,12 +24,11 @@ struct pcb_struct {
struct thread_info { struct thread_info {
struct pcb_struct pcb; /* hmcode state */ struct pcb_struct pcb; /* hmcode state */
struct task_struct *task; /* main task structure */
unsigned int flags; /* low level flags */ unsigned int flags; /* low level flags */
unsigned int ieee_state; /* see fpu.h */ unsigned int ieee_state; /* see fpu.h */
mm_segment_t addr_limit; /* thread address space */ mm_segment_t addr_limit; /* thread address space */
unsigned int cpu; /* current CPU */ unsigned int cpu; /* current CPU */
int preempt_count; /* 0 => preemptible, <0 => BUG */ int preempt_count; /* 0 => preemptible, <0 => BUG */
unsigned int status; /* thread-synchronous flags */ unsigned int status; /* thread-synchronous flags */
...@@ -58,14 +56,10 @@ static __always_inline u64 rtid(void) ...@@ -58,14 +56,10 @@ static __always_inline u64 rtid(void)
*/ */
#define INIT_THREAD_INFO(tsk) \ #define INIT_THREAD_INFO(tsk) \
{ \ { \
.task = &tsk, \
.addr_limit = KERNEL_DS, \ .addr_limit = KERNEL_DS, \
.preempt_count = INIT_PREEMPT_COUNT, \ .preempt_count = INIT_PREEMPT_COUNT, \
} }
/* How to get the thread information struct from C. */
register struct thread_info *__current_thread_info __asm__("$8");
#define current_thread_info() __current_thread_info
#endif /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */
......
...@@ -20,6 +20,9 @@ enum perf_event_sw64_regs { ...@@ -20,6 +20,9 @@ enum perf_event_sw64_regs {
PERF_REG_SW64_R13, PERF_REG_SW64_R13,
PERF_REG_SW64_R14, PERF_REG_SW64_R14,
PERF_REG_SW64_R15, PERF_REG_SW64_R15,
PERF_REG_SW64_R16,
PERF_REG_SW64_R17,
PERF_REG_SW64_R18,
PERF_REG_SW64_R19, PERF_REG_SW64_R19,
PERF_REG_SW64_R20, PERF_REG_SW64_R20,
PERF_REG_SW64_R21, PERF_REG_SW64_R21,
...@@ -30,16 +33,9 @@ enum perf_event_sw64_regs { ...@@ -30,16 +33,9 @@ enum perf_event_sw64_regs {
PERF_REG_SW64_R26, PERF_REG_SW64_R26,
PERF_REG_SW64_R27, PERF_REG_SW64_R27,
PERF_REG_SW64_R28, PERF_REG_SW64_R28,
PERF_REG_SW64_HAE,
PERF_REG_SW64_TRAP_A0,
PERF_REG_SW64_TRAP_A1,
PERF_REG_SW64_TRAP_A2,
PERF_REG_SW64_PS,
PERF_REG_SW64_PC,
PERF_REG_SW64_GP, PERF_REG_SW64_GP,
PERF_REG_SW64_R16, PERF_REG_SW64_SP,
PERF_REG_SW64_R17, PERF_REG_SW64_PC,
PERF_REG_SW64_R18,
PERF_REG_SW64_MAX, PERF_REG_SW64_MAX,
}; };
#endif /* _UAPI_ASM_SW64_PERF_REGS_H */ #endif /* _UAPI_ASM_SW64_PERF_REGS_H */
...@@ -17,7 +17,7 @@ obj-y := entry.o fpu.o traps.o process.o sys_sw64.o irq.o \ ...@@ -17,7 +17,7 @@ obj-y := entry.o fpu.o traps.o process.o sys_sw64.o irq.o \
irq_sw64.o signal.o setup.o ptrace.o time.o \ irq_sw64.o signal.o setup.o ptrace.o time.o \
systbls.o dup_print.o tc.o timer.o \ systbls.o dup_print.o tc.o timer.o \
insn.o early_init.o topology.o cacheinfo.o \ insn.o early_init.o topology.o cacheinfo.o \
vdso.o vdso/ hmcall.o stacktrace.o vdso.o vdso/ hmcall.o stacktrace.o idle.o reset.o
obj-$(CONFIG_ACPI) += acpi.o obj-$(CONFIG_ACPI) += acpi.o
obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_SMP) += smp.o
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* and format the required data. * and format the required data.
*/ */
#define GENERATING_ASM_OFFSETS /* asm/smp.h */
#include <linux/stddef.h> #include <linux/stddef.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/kbuild.h> #include <linux/kbuild.h>
...@@ -15,11 +16,11 @@ ...@@ -15,11 +16,11 @@
#include "traps.c" #include "traps.c"
void foo(void) void foo(void)
{ {
DEFINE(TI_TASK, offsetof(struct thread_info, task)); DEFINE(ASM_THREAD_SIZE, THREAD_SIZE);
DEFINE(TI_FLAGS, offsetof(struct thread_info, flags)); DEFINE(TI_FLAGS, offsetof(struct thread_info, flags));
DEFINE(TI_CPU, offsetof(struct thread_info, cpu));
BLANK(); BLANK();
DEFINE(TASK_BLOCKED, offsetof(struct task_struct, blocked)); DEFINE(TASK_BLOCKED, offsetof(struct task_struct, blocked));
...@@ -27,6 +28,10 @@ void foo(void) ...@@ -27,6 +28,10 @@ void foo(void)
DEFINE(TASK_REAL_PARENT, offsetof(struct task_struct, real_parent)); DEFINE(TASK_REAL_PARENT, offsetof(struct task_struct, real_parent));
DEFINE(TASK_GROUP_LEADER, offsetof(struct task_struct, group_leader)); DEFINE(TASK_GROUP_LEADER, offsetof(struct task_struct, group_leader));
DEFINE(TASK_TGID, offsetof(struct task_struct, tgid)); DEFINE(TASK_TGID, offsetof(struct task_struct, tgid));
DEFINE(TASK_STACK, offsetof(struct task_struct, stack));
#ifdef CONFIG_SMP
DEFINE(TASK_CPU, offsetof(struct task_struct, thread_info.cpu));
#endif
BLANK(); BLANK();
OFFSET(PSTATE_REGS, processor_state, regs); OFFSET(PSTATE_REGS, processor_state, regs);
......
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
/*
* linux/arch/sw/kernel/setup.c
*
* Copyright (C) 1995 Linus Torvalds
*/
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/cpufreq.h> #include <linux/cpufreq.h>
...@@ -11,6 +6,7 @@ ...@@ -11,6 +6,7 @@
#include <linux/export.h> #include <linux/export.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <asm/sw64_init.h>
#include <asm/sw64io.h> #include <asm/sw64io.h>
#include <asm/hw_init.h> #include <asm/hw_init.h>
#include <asm/debug.h> #include <asm/debug.h>
...@@ -29,73 +25,7 @@ ...@@ -29,73 +25,7 @@
#define CORE_PLL0_CFG_SHIFT 4 #define CORE_PLL0_CFG_SHIFT 4
#define CORE_PLL2_CFG_SHIFT 18 #define CORE_PLL2_CFG_SHIFT 18
char curruent_policy[CPUFREQ_NAME_LEN]; char curruent_policy[CPUFREQ_NAME_LEN];
/* Minimum CLK support */
enum {
DC_0, DC_1, DC_2, DC_3, DC_4, DC_5, DC_6, DC_7, DC_8,
DC_9, DC_10, DC_11, DC_12, DC_13, DC_14, DC_15, DC_16, DC_RESV
};
static int cpu_freq[14] = {
0, 1200, 1800, 1900,
1950, 2000, 2050, 2100,
2150, 2200, 2250, 2300,
2350, 2400 };
struct cpufreq_frequency_table sw64_clockmod_table[] = {
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{0, DC_1, 0},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{0, DC_2, 0},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{0, DC_3, 0},
{0, DC_4, 0},
{0, DC_5, 0},
{0, DC_6, 0},
{0, DC_7, 0},
{0, DC_8, 0},
{0, DC_9, 0},
{0, DC_10, 0},
{0, DC_11, 0},
{0, DC_12, 0},
{0, DC_13, 0},
{-1, DC_RESV, CPUFREQ_TABLE_END},
};
EXPORT_SYMBOL_GPL(sw64_clockmod_table);
static struct clk cpu_clk = { static struct clk cpu_clk = {
.name = "cpu_clk", .name = "cpu_clk",
...@@ -113,13 +43,13 @@ unsigned int __sw64_cpufreq_get(struct cpufreq_policy *policy) ...@@ -113,13 +43,13 @@ unsigned int __sw64_cpufreq_get(struct cpufreq_policy *policy)
{ {
int i; int i;
u64 val; u64 val;
struct cpufreq_frequency_table *ft = policy->freq_table;
val = sw64_io_read(0, CLK_CTL); val = sw64_io_read(0, CLK_CTL) >> CORE_PLL2_CFG_SHIFT;
val = val >> CORE_PLL2_CFG_SHIFT;
for (i = 0; i < sizeof(cpu_freq)/sizeof(int); i++) { for (i = 0; ft[i].frequency != CPUFREQ_TABLE_END; i++) {
if (cpu_freq[val] == cpu_freq[i]) if (val == ft[i].driver_data)
return cpu_freq[i]; return ft[i].frequency;
} }
return 0; return 0;
} }
...@@ -131,61 +61,41 @@ void sw64_store_policy(struct cpufreq_policy *policy) ...@@ -131,61 +61,41 @@ void sw64_store_policy(struct cpufreq_policy *policy)
} }
EXPORT_SYMBOL_GPL(sw64_store_policy); EXPORT_SYMBOL_GPL(sw64_store_policy);
void sw64_set_rate(unsigned long rate) void sw64_set_rate(unsigned int index)
{ {
unsigned int i, val; unsigned int i, val;
int index = -1; int cpu_num;
rate /= 1000000; cpu_num = sw64_chip->get_cpu_num();
for (i = 0; i < sizeof(cpu_freq)/sizeof(int); i++) { for (i = 0; i < cpu_num; i++) {
if (rate == cpu_freq[i]) { sw64_io_write(i, CLK_CTL, CORE_CLK2_R | CORE_CLK2_V | CLK_PRT);
index = i; val = sw64_io_read(i, CLK_CTL);
update_cpu_freq(cpu_freq[i]);
break;
}
}
if (index < 0)
return -EINVAL;
sw64_io_write(0, CLK_CTL, CORE_CLK2_R | CORE_CLK2_V | CLK_PRT); sw64_io_write(i, CLK_CTL, val | index << CORE_PLL2_CFG_SHIFT);
sw64_io_write(1, CLK_CTL, CORE_CLK2_R | CORE_CLK2_V | CLK_PRT);
val = sw64_io_read(0, CLK_CTL);
sw64_io_write(0, CLK_CTL, val | index << CORE_PLL2_CFG_SHIFT); udelay(1);
sw64_io_write(1, CLK_CTL, val | index << CORE_PLL2_CFG_SHIFT);
udelay(1); sw64_io_write(i, CLK_CTL, CORE_CLK2_V | CLK_PRT
| index << CORE_PLL2_CFG_SHIFT);
val = sw64_io_read(i, CLK_CTL);
sw64_io_write(0, CLK_CTL, CORE_CLK2_V | CLK_PRT /* LV1 select PLL1/PLL2 */
| index << CORE_PLL2_CFG_SHIFT); sw64_io_write(i, CLU_LV1_SEL, CLK_LV1_SEL_MUXA | CLK_LV1_SEL_PRT);
sw64_io_write(1, CLK_CTL, CORE_CLK2_V | CLK_PRT
| index << CORE_PLL2_CFG_SHIFT);
val = sw64_io_read(0, CLK_CTL);
/* LV1 select PLL1/PLL2 */ /* Set CLK_CTL PLL0 */
sw64_io_write(0, CLU_LV1_SEL, CLK_LV1_SEL_MUXA | CLK_LV1_SEL_PRT); sw64_io_write(i, CLK_CTL, val | CORE_CLK0_R | CORE_CLK0_V);
sw64_io_write(1, CLU_LV1_SEL, CLK_LV1_SEL_MUXA | CLK_LV1_SEL_PRT);
/* Set CLK_CTL PLL0 */ sw64_io_write(i, CLK_CTL, val | CORE_CLK0_R | CORE_CLK0_V
sw64_io_write(0, CLK_CTL, val | CORE_CLK0_R | CORE_CLK0_V); | index << CORE_PLL0_CFG_SHIFT);
sw64_io_write(1, CLK_CTL, val | CORE_CLK0_R | CORE_CLK0_V);
sw64_io_write(0, CLK_CTL, val | CORE_CLK0_R | CORE_CLK0_V udelay(1);
| index << CORE_PLL0_CFG_SHIFT);
sw64_io_write(1, CLK_CTL, val | CORE_CLK0_R | CORE_CLK0_V
| index << CORE_PLL0_CFG_SHIFT);
udelay(1); sw64_io_write(i, CLK_CTL, val | CORE_CLK0_V
| index << CORE_PLL0_CFG_SHIFT);
sw64_io_write(0, CLK_CTL, val | CORE_CLK0_V /* LV1 select PLL0/PLL1 */
| index << CORE_PLL0_CFG_SHIFT); sw64_io_write(i, CLU_LV1_SEL, CLK_LV1_SEL_MUXB | CLK_LV1_SEL_PRT);
sw64_io_write(1, CLK_CTL, val | CORE_CLK0_V }
| index << CORE_PLL0_CFG_SHIFT);
/* LV1 select PLL0/PLL1 */
sw64_io_write(0, CLU_LV1_SEL, CLK_LV1_SEL_MUXB | CLK_LV1_SEL_PRT);
sw64_io_write(1, CLU_LV1_SEL, CLK_LV1_SEL_MUXB | CLK_LV1_SEL_PRT);
} }
EXPORT_SYMBOL_GPL(sw64_set_rate); EXPORT_SYMBOL_GPL(sw64_set_rate);
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include <linux/smp.h> #include <linux/smp.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <asm/chip3_io.h> #include <asm/platform.h>
#include <asm/io.h> #include <asm/io.h>
#ifdef CONFIG_SW64_RRK #ifdef CONFIG_SW64_RRK
......
...@@ -24,6 +24,7 @@ static void __init sw64_setup_platform_ops(void) ...@@ -24,6 +24,7 @@ static void __init sw64_setup_platform_ops(void)
asmlinkage __visible void __init sw64_start_kernel(void) asmlinkage __visible void __init sw64_start_kernel(void)
{ {
fixup_hmcall(); fixup_hmcall();
save_ktp();
sw64_setup_chip_ops(); sw64_setup_chip_ops();
sw64_setup_platform_ops(); sw64_setup_platform_ops();
sw64_platform->ops_fixup(); sw64_platform->ops_fixup();
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
* regs 29-30 saved and set up by HMcode * regs 29-30 saved and set up by HMcode
*/ */
.macro SAVE_COMMON_REGS .macro SAVE_ALL
ldi $sp, -PT_REGS_PS($sp) ldi $sp, -PT_REGS_PS($sp)
stl $0, PT_REGS_R0($sp) stl $0, PT_REGS_R0($sp)
stl $1, PT_REGS_R1($sp) stl $1, PT_REGS_R1($sp)
...@@ -32,6 +32,13 @@ ...@@ -32,6 +32,13 @@
stl $6, PT_REGS_R6($sp) stl $6, PT_REGS_R6($sp)
stl $7, PT_REGS_R7($sp) stl $7, PT_REGS_R7($sp)
stl $8, PT_REGS_R8($sp) stl $8, PT_REGS_R8($sp)
stl $9, PT_REGS_R9($sp)
stl $10, PT_REGS_R10($sp)
stl $11, PT_REGS_R11($sp)
stl $12, PT_REGS_R12($sp)
stl $13, PT_REGS_R13($sp)
stl $14, PT_REGS_R14($sp)
stl $15, PT_REGS_R15($sp)
stl $19, PT_REGS_R19($sp) stl $19, PT_REGS_R19($sp)
stl $20, PT_REGS_R20($sp) stl $20, PT_REGS_R20($sp)
stl $21, PT_REGS_R21($sp) stl $21, PT_REGS_R21($sp)
...@@ -41,9 +48,10 @@ ...@@ -41,9 +48,10 @@
stl $25, PT_REGS_R25($sp) stl $25, PT_REGS_R25($sp)
stl $26, PT_REGS_R26($sp) stl $26, PT_REGS_R26($sp)
stl $27, PT_REGS_R27($sp) stl $27, PT_REGS_R27($sp)
sys_call HMC_rdktp
.endm .endm
.macro RESTORE_COMMON_REGS .macro RESTORE_ALL
ldl $0, PT_REGS_R0($sp) ldl $0, PT_REGS_R0($sp)
ldl $1, PT_REGS_R1($sp) ldl $1, PT_REGS_R1($sp)
ldl $2, PT_REGS_R2($sp) ldl $2, PT_REGS_R2($sp)
...@@ -53,6 +61,13 @@ ...@@ -53,6 +61,13 @@
ldl $6, PT_REGS_R6($sp) ldl $6, PT_REGS_R6($sp)
ldl $7, PT_REGS_R7($sp) ldl $7, PT_REGS_R7($sp)
ldl $8, PT_REGS_R8($sp) ldl $8, PT_REGS_R8($sp)
ldl $9, PT_REGS_R9($sp)
ldl $10, PT_REGS_R10($sp)
ldl $11, PT_REGS_R11($sp)
ldl $12, PT_REGS_R12($sp)
ldl $13, PT_REGS_R13($sp)
ldl $14, PT_REGS_R14($sp)
ldl $15, PT_REGS_R15($sp)
ldl $19, PT_REGS_R19($sp) ldl $19, PT_REGS_R19($sp)
ldl $20, PT_REGS_R20($sp) ldl $20, PT_REGS_R20($sp)
ldl $21, PT_REGS_R21($sp) ldl $21, PT_REGS_R21($sp)
...@@ -66,36 +81,6 @@ ...@@ -66,36 +81,6 @@
ldi $sp, PT_REGS_PS($sp) ldi $sp, PT_REGS_PS($sp)
.endm .endm
.macro SAVE_CALLEE_REGS
stl $9, PT_REGS_R9($sp)
stl $10, PT_REGS_R10($sp)
stl $11, PT_REGS_R11($sp)
stl $12, PT_REGS_R12($sp)
stl $13, PT_REGS_R13($sp)
stl $14, PT_REGS_R14($sp)
stl $15, PT_REGS_R15($sp)
.endm
.macro RESTORE_CALLEE_REGS
ldl $9, PT_REGS_R9($sp)
ldl $10, PT_REGS_R10($sp)
ldl $11, PT_REGS_R11($sp)
ldl $12, PT_REGS_R12($sp)
ldl $13, PT_REGS_R13($sp)
ldl $14, PT_REGS_R14($sp)
ldl $15, PT_REGS_R15($sp)
.endm
.macro SAVE_ALL
SAVE_COMMON_REGS
SAVE_CALLEE_REGS
.endm
.macro RESTORE_ALL
RESTORE_CALLEE_REGS
RESTORE_COMMON_REGS
.endm
/* /*
* Non-syscall kernel entry points. * Non-syscall kernel entry points.
*/ */
...@@ -105,9 +90,7 @@ ...@@ -105,9 +90,7 @@
.ent entInt .ent entInt
entInt: entInt:
SAVE_ALL SAVE_ALL
ldi $8, 0x3fff
ldi $26, ret_from_sys_call ldi $26, ret_from_sys_call
bic $sp, $8, $8
mov $sp, $19 mov $sp, $19
call $31, do_entInt call $31, do_entInt
.end entInt .end entInt
...@@ -117,9 +100,7 @@ entInt: ...@@ -117,9 +100,7 @@ entInt:
.ent entArith .ent entArith
entArith: entArith:
SAVE_ALL SAVE_ALL
ldi $8, 0x3fff
ldi $26, ret_from_sys_call ldi $26, ret_from_sys_call
bic $sp, $8, $8
mov $sp, $18 mov $sp, $18
call $31, do_entArith call $31, do_entArith
.end entArith .end entArith
...@@ -129,9 +110,7 @@ entArith: ...@@ -129,9 +110,7 @@ entArith:
.ent entMM .ent entMM
entMM: entMM:
SAVE_ALL SAVE_ALL
ldi $8, 0x3fff
ldi $26, ret_from_sys_call ldi $26, ret_from_sys_call
bic $sp, $8, $8
mov $sp, $19 mov $sp, $19
call $31, do_page_fault call $31, do_page_fault
.end entMM .end entMM
...@@ -141,10 +120,8 @@ entMM: ...@@ -141,10 +120,8 @@ entMM:
.ent entIF .ent entIF
entIF: entIF:
SAVE_ALL SAVE_ALL
ldi $8, 0x3fff
ldi $26, ret_from_sys_call ldi $26, ret_from_sys_call
bic $sp, $8, $8 mov $sp, $18
mov $sp, $17
call $31, do_entIF call $31, do_entIF
.end entIF .end entIF
...@@ -159,8 +136,6 @@ entIF: ...@@ -159,8 +136,6 @@ entIF:
.ent entUna .ent entUna
entUna: entUna:
SAVE_ALL SAVE_ALL
ldi $8, 0x3fff
bic $sp, $8, $8
mov $sp, $19 mov $sp, $19
ldl $0, PT_REGS_PS($sp) ldl $0, PT_REGS_PS($sp)
and $0, 8, $0 /* user mode ? */ and $0, 8, $0 /* user mode ? */
...@@ -192,8 +167,6 @@ entUna: ...@@ -192,8 +167,6 @@ entUna:
entSys: entSys:
SAVE_ALL SAVE_ALL
ldi $8, 0x3fff
bic $sp, $8, $8
ldi $4, NR_SYSCALLS($31) ldi $4, NR_SYSCALLS($31)
stl $16, PT_REGS_R16($sp) stl $16, PT_REGS_R16($sp)
ldi $5, sys_call_table ldi $5, sys_call_table
...@@ -411,8 +384,8 @@ __switch_to: ...@@ -411,8 +384,8 @@ __switch_to:
ldl $13, TASK_THREAD_S4($17) ldl $13, TASK_THREAD_S4($17)
ldl $14, TASK_THREAD_S5($17) ldl $14, TASK_THREAD_S5($17)
ldl $15, TASK_THREAD_S6($17) ldl $15, TASK_THREAD_S6($17)
ldi $8, 0x3fff mov $17, $8
bic $sp, $8, $8 sys_call HMC_wrktp
mov $16, $0 mov $16, $0
ret ret
.end __switch_to .end __switch_to
......
...@@ -100,10 +100,12 @@ void arch_ftrace_update_code(int command) ...@@ -100,10 +100,12 @@ void arch_ftrace_update_code(int command)
int __init ftrace_dyn_arch_init(void) int __init ftrace_dyn_arch_init(void)
{ {
init_thread_info.dyn_ftrace_addr = FTRACE_ADDR; struct thread_info *ti = task_thread_info(&init_task);
ti->dyn_ftrace_addr = FTRACE_ADDR;
#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
init_thread_info.dyn_ftrace_regs_addr = FTRACE_REGS_ADDR; ti->dyn_ftrace_regs_addr = FTRACE_REGS_ADDR;
#endif #endif
return 0; return 0;
} }
......
...@@ -22,9 +22,11 @@ __start: ...@@ -22,9 +22,11 @@ __start:
br $27, 1f br $27, 1f
1: ldgp $29, 0($27) 1: ldgp $29, 0($27)
/* We need to get current_task_info loaded up... */ /* We need to get current_task_info loaded up... */
ldi $8, init_thread_union ldi $8, init_task
ldl $30, TASK_STACK($8)
/* ... and find our stack ... */ /* ... and find our stack ... */
ldi $30, ASM_THREAD_SIZE($8) ldi $30, ASM_THREAD_SIZE($30)
/* ... and then we can clear bss data. */ /* ... and then we can clear bss data. */
ldi $16, __bss_start ldi $16, __bss_start
ldi $18, __bss_stop ldi $18, __bss_stop
...@@ -38,8 +40,10 @@ __start: ...@@ -38,8 +40,10 @@ __start:
call $26, relocate_kernel call $26, relocate_kernel
ldl $29, 0($30) ldl $29, 0($30)
addl $29, $0, $29 addl $29, $0, $29
addl $8, $0, $8
ldi $30, 8($30)
/* Repoint the sp into the new kernel image */ /* Repoint the sp into the new kernel image */
ldi $30, ASM_THREAD_SIZE($8) addl $30, $0, $30
#endif #endif
/* ... and then we can start the kernel. */ /* ... and then we can start the kernel. */
call $26, sw64_start_kernel call $26, sw64_start_kernel
...@@ -68,11 +72,13 @@ __smp_callin: ...@@ -68,11 +72,13 @@ __smp_callin:
s4addl $0, $1, $1 s4addl $0, $1, $1
ldw $0, 0($1) # Get logical cpu number ldw $0, 0($1) # Get logical cpu number
ldi $2, tidle_ksp ldi $2, idle_task_pointer
s8addl $0, $2, $2 s8addl $0, $2, $2
ldl $30, 0($2) # Get ksp of idle thread ldl $8, 0($2) # Get ksp of idle thread
sys_call HMC_wrktp
ldi $8, -ASM_THREAD_SIZE($30) # Find "current" ldl $30, TASK_STACK($8)
ldi $30, ASM_THREAD_SIZE($30)
call $26, smp_callin call $26, smp_callin
sys_call HMC_halt sys_call HMC_halt
......
...@@ -76,6 +76,22 @@ static inline void fixup_wrasid(void) ...@@ -76,6 +76,22 @@ static inline void fixup_wrasid(void)
entry[9] = 0x1ef00000; /* pri_ret/b p23 */ entry[9] = 0x1ef00000; /* pri_ret/b p23 */
} }
static inline void fixup_rdktp(void)
{
unsigned int *entry = __va(HMCALL_ENTRY(rdktp));
entry[0] = 0x95161000; /* pri_ldl/p $8, VC__KTP(vcpucb) */
entry[1] = 0x1ee00000; /* pri_ret $23 */
}
static inline void fixup_wrktp(void)
{
unsigned int *entry = __va(HMCALL_ENTRY(wrktp));
entry[0] = 0xb5161000; /* pri_stl/p $8, VC__KTP(vcpucb) */
entry[1] = 0x1ee00000; /* pri_ret $23 */
}
void __init fixup_hmcall(void) void __init fixup_hmcall(void)
{ {
#if defined(CONFIG_SUBARCH_C3B) #if defined(CONFIG_SUBARCH_C3B)
...@@ -83,6 +99,8 @@ void __init fixup_hmcall(void) ...@@ -83,6 +99,8 @@ void __init fixup_hmcall(void)
fixup_wrtp(); fixup_wrtp();
fixup_tbiasid(); fixup_tbiasid();
fixup_wrasid(); fixup_wrasid();
fixup_rdktp();
fixup_wrktp();
#endif #endif
} }
......
// SPDX-License-Identifier: GPL-2.0
/*
* sw64 idle loop support.
*
*/
#include <linux/cpu.h>
#include <linux/irqflags.h>
#include <asm/cpu.h>
#include <asm/idle.h>
#ifdef CONFIG_HOTPLUG_CPU
void arch_cpu_idle_dead(void)
{
play_dead();
}
#endif
void cpu_idle(void)
{
int i;
local_irq_enable();
cpu_relax();
if (is_in_guest())
hcall(HCALL_HALT, 0, 0, 0);
else {
for (i = 0; i < 16; i++)
asm("nop");
asm("halt");
}
}
void arch_cpu_idle(void)
{
cpu_idle();
}
此差异已折叠。
...@@ -8,7 +8,24 @@ u64 perf_reg_value(struct pt_regs *regs, int idx) ...@@ -8,7 +8,24 @@ u64 perf_reg_value(struct pt_regs *regs, int idx)
if (WARN_ON_ONCE((u32)idx >= PERF_REG_SW64_MAX)) if (WARN_ON_ONCE((u32)idx >= PERF_REG_SW64_MAX))
return 0; return 0;
return ((unsigned long *)regs)[idx]; switch (idx) {
case PERF_REG_SW64_R16:
return regs->r16;
case PERF_REG_SW64_R17:
return regs->r17;
case PERF_REG_SW64_R18:
return regs->r18;
case PERF_REG_SW64_R19 ... PERF_REG_SW64_R28:
return ((unsigned long *)regs)[idx - 3];
case PERF_REG_SW64_GP:
return regs->gp;
case PERF_REG_SW64_SP:
return (user_mode(regs) ? rdusp() : (u64)(regs + 1));
case PERF_REG_SW64_PC:
return regs->pc;
default:
return ((unsigned long *)regs)[idx];
}
} }
#define REG_RESERVED (~((1ULL << PERF_REG_SW64_MAX) - 1)) #define REG_RESERVED (~((1ULL << PERF_REG_SW64_MAX) - 1))
......
此差异已折叠。
...@@ -239,9 +239,6 @@ unsigned int __init relocate_kernel(void) ...@@ -239,9 +239,6 @@ unsigned int __init relocate_kernel(void)
if (plat_post_relocation(offset)) if (plat_post_relocation(offset))
goto out; goto out;
/* The current thread is now within the relocated image */
__current_thread_info = RELOCATED(&init_thread_union);
/* Return the new kernel's offset */ /* Return the new kernel's offset */
return offset; return offset;
} }
......
此差异已折叠。
...@@ -34,7 +34,7 @@ EXPORT_SYMBOL(__cpu_to_rcid); ...@@ -34,7 +34,7 @@ EXPORT_SYMBOL(__cpu_to_rcid);
int __rcid_to_cpu[NR_CPUS]; /* Map physical to logical */ int __rcid_to_cpu[NR_CPUS]; /* Map physical to logical */
EXPORT_SYMBOL(__rcid_to_cpu); EXPORT_SYMBOL(__rcid_to_cpu);
void *tidle_ksp[NR_CPUS]; void *idle_task_pointer[NR_CPUS];
/* State of each CPU */ /* State of each CPU */
DEFINE_PER_CPU(int, cpu_state) = { 0 }; DEFINE_PER_CPU(int, cpu_state) = { 0 };
...@@ -130,7 +130,7 @@ static int secondary_cpu_start(int cpuid, struct task_struct *idle) ...@@ -130,7 +130,7 @@ static int secondary_cpu_start(int cpuid, struct task_struct *idle)
/* /*
* Precalculate the target ksp. * Precalculate the target ksp.
*/ */
tidle_ksp[cpuid] = idle->stack + THREAD_SIZE; idle_task_pointer[cpuid] = idle;
DBGS("Starting secondary cpu %d: state 0x%lx\n", cpuid, idle->state); DBGS("Starting secondary cpu %d: state 0x%lx\n", cpuid, idle->state);
...@@ -237,7 +237,6 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus) ...@@ -237,7 +237,6 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
memset(ipi_data, 0, sizeof(ipi_data)); memset(ipi_data, 0, sizeof(ipi_data));
init_cpu_topology(); init_cpu_topology();
current_thread_info()->cpu = 0;
store_cpu_topology(smp_processor_id()); store_cpu_topology(smp_processor_id());
numa_add_cpu(smp_processor_id()); numa_add_cpu(smp_processor_id());
...@@ -366,10 +365,7 @@ void handle_ipi(struct pt_regs *regs) ...@@ -366,10 +365,7 @@ void handle_ipi(struct pt_regs *regs)
case IPI_CPU_STOP: case IPI_CPU_STOP:
local_irq_disable(); local_irq_disable();
pr_crit("other core panic, now halt...\n"); asm("halt");
while (1)
asm("nop");
halt();
default: default:
pr_crit("Unknown IPI on CPU %d: %lu\n", this_cpu, which); pr_crit("Unknown IPI on CPU %d: %lu\n", this_cpu, which);
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#include <asm/efi.h> #include <asm/efi.h>
unsigned long entSuspend;
static int __init is_memory(efi_memory_desc_t *md) static int __init is_memory(efi_memory_desc_t *md)
{ {
if (md->attribute & (EFI_MEMORY_WB|EFI_MEMORY_WT|EFI_MEMORY_WC)) if (md->attribute & (EFI_MEMORY_WB|EFI_MEMORY_WT|EFI_MEMORY_WC))
...@@ -32,7 +34,8 @@ static int __init is_memory(efi_memory_desc_t *md) ...@@ -32,7 +34,8 @@ static int __init is_memory(efi_memory_desc_t *md)
return 0; return 0;
} }
static efi_config_table_type_t arch_tables[] __initdata = { static efi_config_table_type_t arch_tables[] __initdata = {
{SMBIOS3_TABLE_GUID, NULL, NULL} {SMBIOS3_TABLE_GUID, NULL, NULL},
{SLEEP_ENTRY_GUID, &entSuspend, "SLEEP ENTRY"}
}; };
static int __init uefi_init(u64 efi_system_table) static int __init uefi_init(u64 efi_system_table)
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
# SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_PLATFORM_XUELANG) += legacy_xuelang.o
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册