Skip to content

Commit fa2ae4a

Browse files
svens-s390Alexander Gordeev
authored andcommitted
s390/idle: Rewrite psw_idle() in C
To ease maintenance and further enhancements, convert the psw_idle() function to C. Reviewed-by: Heiko Carstens <[email protected]> Signed-off-by: Sven Schnelle <[email protected]> Signed-off-by: Alexander Gordeev <[email protected]>
1 parent 62b672c commit fa2ae4a

File tree

4 files changed

+21
-32
lines changed

4 files changed

+21
-32
lines changed

arch/s390/include/asm/processor.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <asm/setup.h>
4141
#include <asm/runtime_instr.h>
4242
#include <asm/irqflags.h>
43+
#include <asm/alternative.h>
4344

4445
typedef long (*sys_call_ptr_t)(struct pt_regs *regs);
4546

@@ -92,6 +93,14 @@ static inline void get_cpu_id(struct cpuid *ptr)
9293
asm volatile("stidp %0" : "=Q" (*ptr));
9394
}
9495

96+
static __always_inline unsigned long get_cpu_timer(void)
97+
{
98+
unsigned long timer;
99+
100+
asm volatile("stpt %[timer]" : [timer] "=Q" (timer));
101+
return timer;
102+
}
103+
95104
void s390_adjust_jiffies(void);
96105
void s390_update_cpu_mhz(void);
97106
void cpu_detect_mhz_feature(void);
@@ -394,6 +403,11 @@ static __always_inline bool regs_irqs_disabled(struct pt_regs *regs)
394403
return arch_irqs_disabled_flags(regs->psw.mask);
395404
}
396405

406+
static __always_inline void bpon(void)
407+
{
408+
asm volatile(ALTERNATIVE("nop", ".insn rrf,0xb2e80000,0,0,13,0", 82));
409+
}
410+
397411
#endif /* __ASSEMBLY__ */
398412

399413
#endif /* __ASM_S390_PROCESSOR_H */

arch/s390/kernel/asm-offsets.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <linux/purgatory.h>
1414
#include <linux/pgtable.h>
1515
#include <linux/ftrace.h>
16-
#include <asm/idle.h>
1716
#include <asm/gmap.h>
1817
#include <asm/stacktrace.h>
1918

@@ -71,11 +70,6 @@ int main(void)
7170
OFFSET(__SFVDSO_RETURN_ADDRESS, stack_frame_vdso_wrapper, return_address);
7271
DEFINE(STACK_FRAME_VDSO_OVERHEAD, sizeof(struct stack_frame_vdso_wrapper));
7372
BLANK();
74-
/* idle data offsets */
75-
OFFSET(__CLOCK_IDLE_ENTER, s390_idle_data, clock_idle_enter);
76-
OFFSET(__TIMER_IDLE_ENTER, s390_idle_data, timer_idle_enter);
77-
OFFSET(__MT_CYCLES_ENTER, s390_idle_data, mt_cycles_enter);
78-
BLANK();
7973
/* hardware defined lowcore locations 0x000 - 0x1ff */
8074
OFFSET(__LC_EXT_PARAMS, lowcore, ext_params);
8175
OFFSET(__LC_EXT_CPU_ADDR, lowcore, ext_cpu_addr);

arch/s390/kernel/entry.S

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -440,29 +440,6 @@ SYM_CODE_END(\name)
440440
INT_HANDLER ext_int_handler,__LC_EXT_OLD_PSW,do_ext_irq
441441
INT_HANDLER io_int_handler,__LC_IO_OLD_PSW,do_io_irq
442442

443-
/*
444-
* Load idle PSW.
445-
*/
446-
SYM_FUNC_START(psw_idle)
447-
stg %r14,(__SF_GPRS+8*8)(%r15)
448-
stg %r3,__SF_EMPTY(%r15)
449-
larl %r1,psw_idle_exit
450-
stg %r1,__SF_EMPTY+8(%r15)
451-
larl %r1,smp_cpu_mtid
452-
llgf %r1,0(%r1)
453-
ltgr %r1,%r1
454-
jz .Lpsw_idle_stcctm
455-
.insn rsy,0xeb0000000017,%r1,5,__MT_CYCLES_ENTER(%r2)
456-
.Lpsw_idle_stcctm:
457-
oi __LC_CPU_FLAGS+7,_CIF_ENABLED_WAIT
458-
BPON
459-
stckf __CLOCK_IDLE_ENTER(%r2)
460-
stpt __TIMER_IDLE_ENTER(%r2)
461-
lpswe __SF_EMPTY(%r15)
462-
SYM_INNER_LABEL(psw_idle_exit, SYM_L_GLOBAL)
463-
BR_EX %r14
464-
SYM_FUNC_END(psw_idle)
465-
466443
/*
467444
* Machine check handler routines
468445
*/

arch/s390/kernel/idle.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,13 @@ void noinstr arch_cpu_idle(void)
5757
psw_mask = PSW_KERNEL_BITS | PSW_MASK_WAIT |
5858
PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK;
5959
clear_cpu_flag(CIF_NOHZ_DELAY);
60-
61-
/* psw_idle() returns with interrupts disabled. */
62-
psw_idle(idle, psw_mask);
60+
set_cpu_flag(CIF_ENABLED_WAIT);
61+
if (smp_cpu_mtid)
62+
stcctm(MT_DIAG, smp_cpu_mtid, (u64 *)&idle->mt_cycles_enter);
63+
idle->clock_idle_enter = get_tod_clock_fast();
64+
idle->timer_idle_enter = get_cpu_timer();
65+
bpon();
66+
__load_psw_mask(psw_mask);
6367
}
6468

6569
static ssize_t show_idle_count(struct device *dev,

0 commit comments

Comments
 (0)