~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/powerpc/include/asm/idle.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0-or-later */
  2 #ifndef _ASM_POWERPC_IDLE_H
  3 #define _ASM_POWERPC_IDLE_H
  4 #include <asm/runlatch.h>
  5 #include <asm/paca.h>
  6 
  7 #ifdef CONFIG_PPC_PSERIES
  8 DECLARE_PER_CPU(u64, idle_spurr_cycles);
  9 DECLARE_PER_CPU(u64, idle_entry_purr_snap);
 10 DECLARE_PER_CPU(u64, idle_entry_spurr_snap);
 11 
 12 static __always_inline void snapshot_purr_idle_entry(void)
 13 {
 14         *this_cpu_ptr(&idle_entry_purr_snap) = mfspr(SPRN_PURR);
 15 }
 16 
 17 static __always_inline void snapshot_spurr_idle_entry(void)
 18 {
 19         *this_cpu_ptr(&idle_entry_spurr_snap) = mfspr(SPRN_SPURR);
 20 }
 21 
 22 static __always_inline void update_idle_purr_accounting(void)
 23 {
 24         u64 wait_cycles;
 25         u64 in_purr = *this_cpu_ptr(&idle_entry_purr_snap);
 26 
 27         wait_cycles = be64_to_cpu(get_lppaca()->wait_state_cycles);
 28         wait_cycles += mfspr(SPRN_PURR) - in_purr;
 29         get_lppaca()->wait_state_cycles = cpu_to_be64(wait_cycles);
 30 }
 31 
 32 static __always_inline void update_idle_spurr_accounting(void)
 33 {
 34         u64 *idle_spurr_cycles_ptr = this_cpu_ptr(&idle_spurr_cycles);
 35         u64 in_spurr = *this_cpu_ptr(&idle_entry_spurr_snap);
 36 
 37         *idle_spurr_cycles_ptr += mfspr(SPRN_SPURR) - in_spurr;
 38 }
 39 
 40 static __always_inline void pseries_idle_prolog(void)
 41 {
 42         ppc64_runlatch_off();
 43         snapshot_purr_idle_entry();
 44         snapshot_spurr_idle_entry();
 45         /*
 46          * Indicate to the HV that we are idle. Now would be
 47          * a good time to find other work to dispatch.
 48          */
 49         get_lppaca()->idle = 1;
 50 }
 51 
 52 static __always_inline void pseries_idle_epilog(void)
 53 {
 54         update_idle_purr_accounting();
 55         update_idle_spurr_accounting();
 56         get_lppaca()->idle = 0;
 57         ppc64_runlatch_on();
 58 }
 59 
 60 static inline u64 read_this_idle_purr(void)
 61 {
 62         /*
 63          * If we are reading from an idle context, update the
 64          * idle-purr cycles corresponding to the last idle period.
 65          * Since the idle context is not yet over, take a fresh
 66          * snapshot of the idle-purr.
 67          */
 68         if (unlikely(get_lppaca()->idle == 1)) {
 69                 update_idle_purr_accounting();
 70                 snapshot_purr_idle_entry();
 71         }
 72 
 73         return be64_to_cpu(get_lppaca()->wait_state_cycles);
 74 }
 75 
 76 static inline u64 read_this_idle_spurr(void)
 77 {
 78         /*
 79          * If we are reading from an idle context, update the
 80          * idle-spurr cycles corresponding to the last idle period.
 81          * Since the idle context is not yet over, take a fresh
 82          * snapshot of the idle-spurr.
 83          */
 84         if (get_lppaca()->idle == 1) {
 85                 update_idle_spurr_accounting();
 86                 snapshot_spurr_idle_entry();
 87         }
 88 
 89         return *this_cpu_ptr(&idle_spurr_cycles);
 90 }
 91 
 92 #endif /* CONFIG_PPC_PSERIES */
 93 #endif
 94 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php