2 * Copyright 2010 IBM Corp, Benjamin Herrenschmidt <benh@kernel.crashing.org>
4 * Generic idle routine for Book3E processors
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 #include <linux/threads.h>
14 #include <asm/ppc_asm.h>
15 #include <asm/asm-offsets.h>
16 #include <asm/ppc-opcode.h>
17 #include <asm/processor.h>
18 #include <asm/thread_info.h>
20 /* 64-bit version only for now */
24 /* Save LR for later */
28 /* Hard disable interrupts */
31 /* Now check if an interrupt came in while we were soft disabled
32 * since we may otherwise lose it (doorbells etc...). We know
33 * that since PACAHARDIRQEN will have been cleared in that case.
35 lbz r3,PACAHARDIRQEN(r13)
39 /* Now we are going to mark ourselves as soft and hard enables in
40 * order to be able to take interrupts while asleep. We inform lockdep
41 * of that. We don't actually turn interrupts on just yet tho.
43 #ifdef CONFIG_TRACE_IRQFLAGS
48 stb r0,PACASOFTIRQEN(r13)
49 stb r0,PACAHARDIRQEN(r13)
51 /* Interrupts will make use return to LR, so get something we want
56 /* Hard disable interrupts again */
59 /* Mark them off again in the PACA as well */
61 stb r0,PACASOFTIRQEN(r13)
62 stb r0,PACAHARDIRQEN(r13)
64 /* Tell lockdep about it */
65 #ifdef CONFIG_TRACE_IRQFLAGS
66 bl .trace_hardirqs_off
73 1: /* Let's set the _TLF_NAPPING flag so interrupts make us return
76 clrrdi r11,r1,THREAD_SHIFT
77 ld r10,TI_LOCAL_FLAGS(r11)
78 ori r10,r10,_TLF_NAPPING
79 std r10,TI_LOCAL_FLAGS(r11)
81 /* We can now re-enable hard interrupts and go to sleep */
86 #endif /* CONFIG_PPC64 */