aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ppc64
diff options
context:
space:
mode:
authorMichael Ellerman <michael@ellerman.id.au>2005-07-07 20:56:29 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-07 21:23:40 -0400
commitd200903e11f6867b91dffa81b2038e55be599f49 (patch)
treee741dfb082e94685c6cb0d1ccc3616c216af7c7a /arch/ppc64
parentfd899c0cc725387992ccfc83fb6f70505c36cbeb (diff)
[PATCH] ppc64: Move iSeries_idle() into iSeries_setup.c
Move iSeries_idle() into iSeries_setup.c, no one else needs to know about it. Signed-off-by: Michael Ellerman <michael@ellerman.id.au> Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/ppc64')
-rw-r--r--arch/ppc64/kernel/iSeries_setup.c81
-rw-r--r--arch/ppc64/kernel/idle.c86
2 files changed, 81 insertions, 86 deletions
diff --git a/arch/ppc64/kernel/iSeries_setup.c b/arch/ppc64/kernel/iSeries_setup.c
index b3f770f6d402..1139e27e1713 100644
--- a/arch/ppc64/kernel/iSeries_setup.c
+++ b/arch/ppc64/kernel/iSeries_setup.c
@@ -834,6 +834,87 @@ static int __init iSeries_src_init(void)
834 834
835late_initcall(iSeries_src_init); 835late_initcall(iSeries_src_init);
836 836
837static unsigned long maxYieldTime = 0;
838static unsigned long minYieldTime = 0xffffffffffffffffUL;
839
840static inline void process_iSeries_events(void)
841{
842 asm volatile ("li 0,0x5555; sc" : : : "r0", "r3");
843}
844
845static void yield_shared_processor(void)
846{
847 unsigned long tb;
848 unsigned long yieldTime;
849
850 HvCall_setEnabledInterrupts(HvCall_MaskIPI |
851 HvCall_MaskLpEvent |
852 HvCall_MaskLpProd |
853 HvCall_MaskTimeout);
854
855 tb = get_tb();
856 /* Compute future tb value when yield should expire */
857 HvCall_yieldProcessor(HvCall_YieldTimed, tb+tb_ticks_per_jiffy);
858
859 yieldTime = get_tb() - tb;
860 if (yieldTime > maxYieldTime)
861 maxYieldTime = yieldTime;
862
863 if (yieldTime < minYieldTime)
864 minYieldTime = yieldTime;
865
866 /*
867 * The decrementer stops during the yield. Force a fake decrementer
868 * here and let the timer_interrupt code sort out the actual time.
869 */
870 get_paca()->lppaca.int_dword.fields.decr_int = 1;
871 process_iSeries_events();
872}
873
874static int iSeries_idle(void)
875{
876 struct paca_struct *lpaca;
877 long oldval;
878
879 /* ensure iSeries run light will be out when idle */
880 ppc64_runlatch_off();
881
882 lpaca = get_paca();
883
884 while (1) {
885 if (lpaca->lppaca.shared_proc) {
886 if (hvlpevent_is_pending())
887 process_iSeries_events();
888 if (!need_resched())
889 yield_shared_processor();
890 } else {
891 oldval = test_and_clear_thread_flag(TIF_NEED_RESCHED);
892
893 if (!oldval) {
894 set_thread_flag(TIF_POLLING_NRFLAG);
895
896 while (!need_resched()) {
897 HMT_medium();
898 if (hvlpevent_is_pending())
899 process_iSeries_events();
900 HMT_low();
901 }
902
903 HMT_medium();
904 clear_thread_flag(TIF_POLLING_NRFLAG);
905 } else {
906 set_need_resched();
907 }
908 }
909
910 ppc64_runlatch_on();
911 schedule();
912 ppc64_runlatch_off();
913 }
914
915 return 0;
916}
917
837#ifndef CONFIG_PCI 918#ifndef CONFIG_PCI
838void __init iSeries_init_IRQ(void) { } 919void __init iSeries_init_IRQ(void) { }
839#endif 920#endif
diff --git a/arch/ppc64/kernel/idle.c b/arch/ppc64/kernel/idle.c
index e270055e73e2..226152467791 100644
--- a/arch/ppc64/kernel/idle.c
+++ b/arch/ppc64/kernel/idle.c
@@ -39,90 +39,6 @@ extern void power4_idle(void);
39 39
40static int (*idle_loop)(void); 40static int (*idle_loop)(void);
41 41
42#ifdef CONFIG_PPC_ISERIES
43static unsigned long maxYieldTime = 0;
44static unsigned long minYieldTime = 0xffffffffffffffffUL;
45
46static inline void process_iSeries_events(void)
47{
48 asm volatile ("li 0,0x5555; sc" : : : "r0", "r3");
49}
50
51static void yield_shared_processor(void)
52{
53 unsigned long tb;
54 unsigned long yieldTime;
55
56 HvCall_setEnabledInterrupts(HvCall_MaskIPI |
57 HvCall_MaskLpEvent |
58 HvCall_MaskLpProd |
59 HvCall_MaskTimeout);
60
61 tb = get_tb();
62 /* Compute future tb value when yield should expire */
63 HvCall_yieldProcessor(HvCall_YieldTimed, tb+tb_ticks_per_jiffy);
64
65 yieldTime = get_tb() - tb;
66 if (yieldTime > maxYieldTime)
67 maxYieldTime = yieldTime;
68
69 if (yieldTime < minYieldTime)
70 minYieldTime = yieldTime;
71
72 /*
73 * The decrementer stops during the yield. Force a fake decrementer
74 * here and let the timer_interrupt code sort out the actual time.
75 */
76 get_paca()->lppaca.int_dword.fields.decr_int = 1;
77 process_iSeries_events();
78}
79
80static int iSeries_idle(void)
81{
82 struct paca_struct *lpaca;
83 long oldval;
84
85 /* ensure iSeries run light will be out when idle */
86 ppc64_runlatch_off();
87
88 lpaca = get_paca();
89
90 while (1) {
91 if (lpaca->lppaca.shared_proc) {
92 if (hvlpevent_is_pending())
93 process_iSeries_events();
94 if (!need_resched())
95 yield_shared_processor();
96 } else {
97 oldval = test_and_clear_thread_flag(TIF_NEED_RESCHED);
98
99 if (!oldval) {
100 set_thread_flag(TIF_POLLING_NRFLAG);
101
102 while (!need_resched()) {
103 HMT_medium();
104 if (hvlpevent_is_pending())
105 process_iSeries_events();
106 HMT_low();
107 }
108
109 HMT_medium();
110 clear_thread_flag(TIF_POLLING_NRFLAG);
111 } else {
112 set_need_resched();
113 }
114 }
115
116 ppc64_runlatch_on();
117 schedule();
118 ppc64_runlatch_off();
119 }
120
121 return 0;
122}
123
124#else
125
126int default_idle(void) 42int default_idle(void)
127{ 43{
128 long oldval; 44 long oldval;
@@ -305,8 +221,6 @@ int native_idle(void)
305 return 0; 221 return 0;
306} 222}
307 223
308#endif /* CONFIG_PPC_ISERIES */
309
310void cpu_idle(void) 224void cpu_idle(void)
311{ 225{
312 BUG_ON(NULL == ppc_md.idle_loop); 226 BUG_ON(NULL == ppc_md.idle_loop);