Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Definitions for measuring cputime on powerpc machines.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 2006 Paul Mackerras, IBM Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * If we have CONFIG_VIRT_CPU_ACCOUNTING_NATIVE, we measure cpu time in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * the same units as the timebase.  Otherwise we measure cpu time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * in jiffies using the generic definitions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #ifndef __POWERPC_CPUTIME_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #define __POWERPC_CPUTIME_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/time.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <asm/div64.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <asm/time.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <asm/param.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) typedef u64 __nocast cputime_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) typedef u64 __nocast cputime64_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #define cmpxchg_cputime(ptr, old, new) cmpxchg(ptr, old, new)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #ifdef __KERNEL__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  * Convert cputime <-> microseconds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) extern u64 __cputime_usec_factor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) static inline unsigned long cputime_to_usecs(const cputime_t ct)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	return mulhdu((__force u64) ct, __cputime_usec_factor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #define cputime_to_nsecs(cputime) tb_to_ns((__force u64)cputime)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  * PPC64 uses PACA which is task independent for storing accounting data while
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  * PPC32 uses struct thread_info, therefore at task switch the accounting data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  * has to be populated in the new task
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #ifdef CONFIG_PPC64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) #define get_accounting(tsk)	(&get_paca()->accounting)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #define raw_get_accounting(tsk)	(&local_paca->accounting)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) static inline void arch_vtime_task_switch(struct task_struct *tsk) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #define get_accounting(tsk)	(&task_thread_info(tsk)->accounting)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #define raw_get_accounting(tsk)	get_accounting(tsk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  * Called from the context switch with interrupts disabled, to charge all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  * accumulated times to the current process, and to prepare accounting on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  * the next process.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) static inline void arch_vtime_task_switch(struct task_struct *prev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	struct cpu_accounting_data *acct = get_accounting(current);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	struct cpu_accounting_data *acct0 = get_accounting(prev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	acct->starttime = acct0->starttime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  * account_cpu_user_entry/exit runs "unreconciled", so can't trace,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  * can't use get_paca()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) static notrace inline void account_cpu_user_entry(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	unsigned long tb = mftb();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	struct cpu_accounting_data *acct = raw_get_accounting(current);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	acct->utime += (tb - acct->starttime_user);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	acct->starttime = tb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) static notrace inline void account_cpu_user_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	unsigned long tb = mftb();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	struct cpu_accounting_data *acct = raw_get_accounting(current);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	acct->stime += (tb - acct->starttime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	acct->starttime_user = tb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) #endif /* __KERNEL__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) #else /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) static inline void account_cpu_user_entry(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) static inline void account_cpu_user_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) #endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) #endif /* __POWERPC_CPUTIME_H */