@@ -76,6 +76,7 @@ unsigned long thread_saved_pc(struct task_struct *tsk)
7676 * Need to know about CPUs going idle?
7777 */
7878static ATOMIC_NOTIFIER_HEAD (idle_chain );
79+ DEFINE_PER_CPU (struct s390_idle_data , s390_idle );
7980
8081int register_idle_notifier (struct notifier_block * nb )
8182{
@@ -89,20 +90,40 @@ int unregister_idle_notifier(struct notifier_block *nb)
8990}
9091EXPORT_SYMBOL (unregister_idle_notifier );
9192
92- void do_monitor_call (struct pt_regs * regs , long interruption_code )
93+ static int s390_idle_enter (void )
94+ {
95+ struct s390_idle_data * idle ;
96+ int nr_calls = 0 ;
97+ void * hcpu ;
98+ int rc ;
99+
100+ hcpu = (void * )(long )smp_processor_id ();
101+ rc = __atomic_notifier_call_chain (& idle_chain , S390_CPU_IDLE , hcpu , -1 ,
102+ & nr_calls );
103+ if (rc == NOTIFY_BAD ) {
104+ nr_calls -- ;
105+ __atomic_notifier_call_chain (& idle_chain , S390_CPU_NOT_IDLE ,
106+ hcpu , nr_calls , NULL );
107+ return rc ;
108+ }
109+ idle = & __get_cpu_var (s390_idle );
110+ spin_lock (& idle -> lock );
111+ idle -> idle_count ++ ;
112+ idle -> in_idle = 1 ;
113+ idle -> idle_enter = get_clock ();
114+ spin_unlock (& idle -> lock );
115+ return NOTIFY_OK ;
116+ }
117+
118+ void s390_idle_leave (void )
93119{
94- #ifdef CONFIG_SMP
95120 struct s390_idle_data * idle ;
96121
97122 idle = & __get_cpu_var (s390_idle );
98123 spin_lock (& idle -> lock );
99124 idle -> idle_time += get_clock () - idle -> idle_enter ;
100125 idle -> in_idle = 0 ;
101126 spin_unlock (& idle -> lock );
102- #endif
103- /* disable monitor call class 0 */
104- __ctl_clear_bit (8 , 15 );
105-
106127 atomic_notifier_call_chain (& idle_chain , S390_CPU_NOT_IDLE ,
107128 (void * )(long ) smp_processor_id ());
108129}
@@ -113,61 +134,30 @@ extern void s390_handle_mcck(void);
113134 */
114135static void default_idle (void )
115136{
116- int cpu , rc ;
117- int nr_calls = 0 ;
118- void * hcpu ;
119- #ifdef CONFIG_SMP
120- struct s390_idle_data * idle ;
121- #endif
122-
123137 /* CPU is going idle. */
124- cpu = smp_processor_id ();
125- hcpu = (void * )(long )cpu ;
126138 local_irq_disable ();
127139 if (need_resched ()) {
128140 local_irq_enable ();
129141 return ;
130142 }
131-
132- rc = __atomic_notifier_call_chain (& idle_chain , S390_CPU_IDLE , hcpu , -1 ,
133- & nr_calls );
134- if (rc == NOTIFY_BAD ) {
135- nr_calls -- ;
136- __atomic_notifier_call_chain (& idle_chain , S390_CPU_NOT_IDLE ,
137- hcpu , nr_calls , NULL );
143+ if (s390_idle_enter () == NOTIFY_BAD ) {
138144 local_irq_enable ();
139145 return ;
140146 }
141-
142- /* enable monitor call class 0 */
143- __ctl_set_bit (8 , 15 );
144-
145147#ifdef CONFIG_HOTPLUG_CPU
146- if (cpu_is_offline (cpu )) {
148+ if (cpu_is_offline (smp_processor_id () )) {
147149 preempt_enable_no_resched ();
148150 cpu_die ();
149151 }
150152#endif
151-
152153 local_mcck_disable ();
153154 if (test_thread_flag (TIF_MCCK_PENDING )) {
154155 local_mcck_enable ();
155- /* disable monitor call class 0 */
156- __ctl_clear_bit (8 , 15 );
157- atomic_notifier_call_chain (& idle_chain , S390_CPU_NOT_IDLE ,
158- hcpu );
156+ s390_idle_leave ();
159157 local_irq_enable ();
160158 s390_handle_mcck ();
161159 return ;
162160 }
163- #ifdef CONFIG_SMP
164- idle = & __get_cpu_var (s390_idle );
165- spin_lock (& idle -> lock );
166- idle -> idle_count ++ ;
167- idle -> in_idle = 1 ;
168- idle -> idle_enter = get_clock ();
169- spin_unlock (& idle -> lock );
170- #endif
171161 trace_hardirqs_on ();
172162 /* Wait for external, I/O or machine check interrupt. */
173163 __load_psw_mask (psw_kernel_bits | PSW_MASK_WAIT |
0 commit comments