idle_book3s.S 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. /*
  2. * This file contains idle entry/exit functions for POWER7,
  3. * POWER8 and POWER9 CPUs.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version
  8. * 2 of the License, or (at your option) any later version.
  9. */
  10. #include <linux/threads.h>
  11. #include <asm/processor.h>
  12. #include <asm/page.h>
  13. #include <asm/cputable.h>
  14. #include <asm/thread_info.h>
  15. #include <asm/ppc_asm.h>
  16. #include <asm/asm-offsets.h>
  17. #include <asm/ppc-opcode.h>
  18. #include <asm/hw_irq.h>
  19. #include <asm/kvm_book3s_asm.h>
  20. #include <asm/opal.h>
  21. #include <asm/cpuidle.h>
  22. #include <asm/book3s/64/mmu-hash.h>
  23. #include <asm/mmu.h>
  24. #undef DEBUG
  25. /*
  26. * Use unused space in the interrupt stack to save and restore
  27. * registers for winkle support.
  28. */
  29. #define _SDR1 GPR3
  30. #define _RPR GPR4
  31. #define _SPURR GPR5
  32. #define _PURR GPR6
  33. #define _TSCR GPR7
  34. #define _DSCR GPR8
  35. #define _AMOR GPR9
  36. #define _WORT GPR10
  37. #define _WORC GPR11
  38. #define _PTCR GPR12
  39. #define PSSCR_HV_TEMPLATE PSSCR_ESL | PSSCR_EC | \
  40. PSSCR_PSLL_MASK | PSSCR_TR_MASK | \
  41. PSSCR_MTL_MASK
  42. .text
  43. /*
  44. * Used by threads before entering deep idle states. Saves SPRs
  45. * in interrupt stack frame
  46. */
  47. save_sprs_to_stack:
  48. /*
  49. * Note all register i.e per-core, per-subcore or per-thread is saved
  50. * here since any thread in the core might wake up first
  51. */
  52. BEGIN_FTR_SECTION
  53. mfspr r3,SPRN_PTCR
  54. std r3,_PTCR(r1)
  55. /*
  56. * Note - SDR1 is dropped in Power ISA v3. Hence not restoring
  57. * SDR1 here
  58. */
  59. FTR_SECTION_ELSE
  60. mfspr r3,SPRN_SDR1
  61. std r3,_SDR1(r1)
  62. ALT_FTR_SECTION_END_IFSET(CPU_FTR_ARCH_300)
  63. mfspr r3,SPRN_RPR
  64. std r3,_RPR(r1)
  65. mfspr r3,SPRN_SPURR
  66. std r3,_SPURR(r1)
  67. mfspr r3,SPRN_PURR
  68. std r3,_PURR(r1)
  69. mfspr r3,SPRN_TSCR
  70. std r3,_TSCR(r1)
  71. mfspr r3,SPRN_DSCR
  72. std r3,_DSCR(r1)
  73. mfspr r3,SPRN_AMOR
  74. std r3,_AMOR(r1)
  75. mfspr r3,SPRN_WORT
  76. std r3,_WORT(r1)
  77. mfspr r3,SPRN_WORC
  78. std r3,_WORC(r1)
  79. blr
  80. /*
  81. * Used by threads when the lock bit of core_idle_state is set.
  82. * Threads will spin in HMT_LOW until the lock bit is cleared.
  83. * r14 - pointer to core_idle_state
  84. * r15 - used to load contents of core_idle_state
  85. */
  86. core_idle_lock_held:
  87. HMT_LOW
  88. 3: lwz r15,0(r14)
  89. andi. r15,r15,PNV_CORE_IDLE_LOCK_BIT
  90. bne 3b
  91. HMT_MEDIUM
  92. lwarx r15,0,r14
  93. blr
  94. /*
  95. * Pass requested state in r3:
  96. * r3 - PNV_THREAD_NAP/SLEEP/WINKLE in POWER8
  97. * - Requested STOP state in POWER9
  98. *
  99. * To check IRQ_HAPPENED in r4
  100. * 0 - don't check
  101. * 1 - check
  102. *
  103. * Address to 'rfid' to in r5
  104. */
  105. _GLOBAL(pnv_powersave_common)
  106. /* Use r3 to pass state nap/sleep/winkle */
  107. /* NAP is a state loss, we create a regs frame on the
  108. * stack, fill it up with the state we care about and
  109. * stick a pointer to it in PACAR1. We really only
  110. * need to save PC, some CR bits and the NV GPRs,
  111. * but for now an interrupt frame will do.
  112. */
  113. mflr r0
  114. std r0,16(r1)
  115. stdu r1,-INT_FRAME_SIZE(r1)
  116. std r0,_LINK(r1)
  117. std r0,_NIP(r1)
  118. /* Hard disable interrupts */
  119. mfmsr r9
  120. rldicl r9,r9,48,1
  121. rotldi r9,r9,16
  122. mtmsrd r9,1 /* hard-disable interrupts */
  123. /* Check if something happened while soft-disabled */
  124. lbz r0,PACAIRQHAPPENED(r13)
  125. andi. r0,r0,~PACA_IRQ_HARD_DIS@l
  126. beq 1f
  127. cmpwi cr0,r4,0
  128. beq 1f
  129. addi r1,r1,INT_FRAME_SIZE
  130. ld r0,16(r1)
  131. li r3,0 /* Return 0 (no nap) */
  132. mtlr r0
  133. blr
  134. 1: /* We mark irqs hard disabled as this is the state we'll
  135. * be in when returning and we need to tell arch_local_irq_restore()
  136. * about it
  137. */
  138. li r0,PACA_IRQ_HARD_DIS
  139. stb r0,PACAIRQHAPPENED(r13)
  140. /* We haven't lost state ... yet */
  141. li r0,0
  142. stb r0,PACA_NAPSTATELOST(r13)
  143. /* Continue saving state */
  144. SAVE_GPR(2, r1)
  145. SAVE_NVGPRS(r1)
  146. mfcr r4
  147. std r4,_CCR(r1)
  148. std r9,_MSR(r1)
  149. std r1,PACAR1(r13)
  150. #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
  151. /* Tell KVM we're entering idle */
  152. li r4,KVM_HWTHREAD_IN_IDLE
  153. stb r4,HSTATE_HWTHREAD_STATE(r13)
  154. #endif
  155. /*
  156. * Go to real mode to do the nap, as required by the architecture.
  157. * Also, we need to be in real mode before setting hwthread_state,
  158. * because as soon as we do that, another thread can switch
  159. * the MMU context to the guest.
  160. */
  161. LOAD_REG_IMMEDIATE(r7, MSR_IDLE)
  162. li r6, MSR_RI
  163. andc r6, r9, r6
  164. mtmsrd r6, 1 /* clear RI before setting SRR0/1 */
  165. mtspr SPRN_SRR0, r5
  166. mtspr SPRN_SRR1, r7
  167. rfid
  168. .globl pnv_enter_arch207_idle_mode
  169. pnv_enter_arch207_idle_mode:
  170. stb r3,PACA_THREAD_IDLE_STATE(r13)
  171. cmpwi cr3,r3,PNV_THREAD_SLEEP
  172. bge cr3,2f
  173. IDLE_STATE_ENTER_SEQ(PPC_NAP)
  174. /* No return */
  175. 2:
  176. /* Sleep or winkle */
  177. lbz r7,PACA_THREAD_MASK(r13)
  178. ld r14,PACA_CORE_IDLE_STATE_PTR(r13)
  179. lwarx_loop1:
  180. lwarx r15,0,r14
  181. andi. r9,r15,PNV_CORE_IDLE_LOCK_BIT
  182. bnel core_idle_lock_held
  183. andc r15,r15,r7 /* Clear thread bit */
  184. andi. r15,r15,PNV_CORE_IDLE_THREAD_BITS
  185. /*
  186. * If cr0 = 0, then current thread is the last thread of the core entering
  187. * sleep. Last thread needs to execute the hardware bug workaround code if
  188. * required by the platform.
  189. * Make the workaround call unconditionally here. The below branch call is
  190. * patched out when the idle states are discovered if the platform does not
  191. * require it.
  192. */
  193. .global pnv_fastsleep_workaround_at_entry
  194. pnv_fastsleep_workaround_at_entry:
  195. beq fastsleep_workaround_at_entry
  196. stwcx. r15,0,r14
  197. bne- lwarx_loop1
  198. isync
  199. common_enter: /* common code for all the threads entering sleep or winkle */
  200. bgt cr3,enter_winkle
  201. IDLE_STATE_ENTER_SEQ(PPC_SLEEP)
  202. fastsleep_workaround_at_entry:
  203. ori r15,r15,PNV_CORE_IDLE_LOCK_BIT
  204. stwcx. r15,0,r14
  205. bne- lwarx_loop1
  206. isync
  207. /* Fast sleep workaround */
  208. li r3,1
  209. li r4,1
  210. bl opal_rm_config_cpu_idle_state
  211. /* Clear Lock bit */
  212. li r0,0
  213. lwsync
  214. stw r0,0(r14)
  215. b common_enter
  216. enter_winkle:
  217. bl save_sprs_to_stack
  218. IDLE_STATE_ENTER_SEQ(PPC_WINKLE)
  219. /*
  220. * r3 - requested stop state
  221. */
  222. power_enter_stop:
  223. /*
  224. * Check if the requested state is a deep idle state.
  225. */
  226. LOAD_REG_ADDRBASE(r5,pnv_first_deep_stop_state)
  227. ld r4,ADDROFF(pnv_first_deep_stop_state)(r5)
  228. cmpd r3,r4
  229. bge 2f
  230. IDLE_STATE_ENTER_SEQ(PPC_STOP)
  231. 2:
  232. /*
  233. * Entering deep idle state.
  234. * Clear thread bit in PACA_CORE_IDLE_STATE, save SPRs to
  235. * stack and enter stop
  236. */
  237. lbz r7,PACA_THREAD_MASK(r13)
  238. ld r14,PACA_CORE_IDLE_STATE_PTR(r13)
  239. lwarx_loop_stop:
  240. lwarx r15,0,r14
  241. andi. r9,r15,PNV_CORE_IDLE_LOCK_BIT
  242. bnel core_idle_lock_held
  243. andc r15,r15,r7 /* Clear thread bit */
  244. stwcx. r15,0,r14
  245. bne- lwarx_loop_stop
  246. isync
  247. bl save_sprs_to_stack
  248. IDLE_STATE_ENTER_SEQ(PPC_STOP)
  249. _GLOBAL(power7_idle)
  250. /* Now check if user or arch enabled NAP mode */
  251. LOAD_REG_ADDRBASE(r3,powersave_nap)
  252. lwz r4,ADDROFF(powersave_nap)(r3)
  253. cmpwi 0,r4,0
  254. beqlr
  255. li r3, 1
  256. /* fall through */
  257. _GLOBAL(power7_nap)
  258. mr r4,r3
  259. li r3,PNV_THREAD_NAP
  260. LOAD_REG_ADDR(r5, pnv_enter_arch207_idle_mode)
  261. b pnv_powersave_common
  262. /* No return */
  263. _GLOBAL(power7_sleep)
  264. li r3,PNV_THREAD_SLEEP
  265. li r4,1
  266. LOAD_REG_ADDR(r5, pnv_enter_arch207_idle_mode)
  267. b pnv_powersave_common
  268. /* No return */
  269. _GLOBAL(power7_winkle)
  270. li r3,PNV_THREAD_WINKLE
  271. li r4,1
  272. LOAD_REG_ADDR(r5, pnv_enter_arch207_idle_mode)
  273. b pnv_powersave_common
  274. /* No return */
  275. #define CHECK_HMI_INTERRUPT \
  276. mfspr r0,SPRN_SRR1; \
  277. BEGIN_FTR_SECTION_NESTED(66); \
  278. rlwinm r0,r0,45-31,0xf; /* extract wake reason field (P8) */ \
  279. FTR_SECTION_ELSE_NESTED(66); \
  280. rlwinm r0,r0,45-31,0xe; /* P7 wake reason field is 3 bits */ \
  281. ALT_FTR_SECTION_END_NESTED_IFSET(CPU_FTR_ARCH_207S, 66); \
  282. cmpwi r0,0xa; /* Hypervisor maintenance ? */ \
  283. bne 20f; \
  284. /* Invoke opal call to handle hmi */ \
  285. ld r2,PACATOC(r13); \
  286. ld r1,PACAR1(r13); \
  287. std r3,ORIG_GPR3(r1); /* Save original r3 */ \
  288. li r3,0; /* NULL argument */ \
  289. bl hmi_exception_realmode; \
  290. nop; \
  291. ld r3,ORIG_GPR3(r1); /* Restore original r3 */ \
  292. 20: nop;
  293. /*
  294. * r3 - requested stop state
  295. */
  296. _GLOBAL(power9_idle_stop)
  297. LOAD_REG_IMMEDIATE(r4, PSSCR_HV_TEMPLATE)
  298. or r4,r4,r3
  299. mtspr SPRN_PSSCR, r4
  300. li r4, 1
  301. LOAD_REG_ADDR(r5,power_enter_stop)
  302. b pnv_powersave_common
  303. /* No return */
  304. /*
  305. * Called from reset vector. Check whether we have woken up with
  306. * hypervisor state loss. If yes, restore hypervisor state and return
  307. * back to reset vector.
  308. *
  309. * r13 - Contents of HSPRG0
  310. * cr3 - set to gt if waking up with partial/complete hypervisor state loss
  311. */
  312. _GLOBAL(pnv_restore_hyp_resource)
  313. BEGIN_FTR_SECTION
  314. ld r2,PACATOC(r13);
  315. /*
  316. * POWER ISA 3. Use PSSCR to determine if we
  317. * are waking up from deep idle state
  318. */
  319. LOAD_REG_ADDRBASE(r5,pnv_first_deep_stop_state)
  320. ld r4,ADDROFF(pnv_first_deep_stop_state)(r5)
  321. mfspr r5,SPRN_PSSCR
  322. /*
  323. * 0-3 bits correspond to Power-Saving Level Status
  324. * which indicates the idle state we are waking up from
  325. */
  326. rldicl r5,r5,4,60
  327. cmpd cr4,r5,r4
  328. bge cr4,pnv_wakeup_tb_loss
  329. /*
  330. * Waking up without hypervisor state loss. Return to
  331. * reset vector
  332. */
  333. blr
  334. END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)
  335. /*
  336. * POWER ISA 2.07 or less.
  337. * Check if last bit of HSPGR0 is set. This indicates whether we are
  338. * waking up from winkle.
  339. */
  340. clrldi r5,r13,63
  341. clrrdi r13,r13,1
  342. /* Now that we are sure r13 is corrected, load TOC */
  343. ld r2,PACATOC(r13);
  344. cmpwi cr4,r5,1
  345. mtspr SPRN_HSPRG0,r13
  346. lbz r0,PACA_THREAD_IDLE_STATE(r13)
  347. cmpwi cr2,r0,PNV_THREAD_NAP
  348. bgt cr2,pnv_wakeup_tb_loss /* Either sleep or Winkle */
  349. /*
  350. * We fall through here if PACA_THREAD_IDLE_STATE shows we are waking
  351. * up from nap. At this stage CR3 shouldn't contains 'gt' since that
  352. * indicates we are waking with hypervisor state loss from nap.
  353. */
  354. bgt cr3,.
  355. blr /* Return back to System Reset vector from where
  356. pnv_restore_hyp_resource was invoked */
  357. /*
  358. * Called if waking up from idle state which can cause either partial or
  359. * complete hyp state loss.
  360. * In POWER8, called if waking up from fastsleep or winkle
  361. * In POWER9, called if waking up from stop state >= pnv_first_deep_stop_state
  362. *
  363. * r13 - PACA
  364. * cr3 - gt if waking up with partial/complete hypervisor state loss
  365. * cr4 - gt or eq if waking up from complete hypervisor state loss.
  366. */
  367. _GLOBAL(pnv_wakeup_tb_loss)
  368. ld r1,PACAR1(r13)
  369. /*
  370. * Before entering any idle state, the NVGPRs are saved in the stack
  371. * and they are restored before switching to the process context. Hence
  372. * until they are restored, they are free to be used.
  373. *
  374. * Save SRR1 and LR in NVGPRs as they might be clobbered in
  375. * opal_call() (called in CHECK_HMI_INTERRUPT). SRR1 is required
  376. * to determine the wakeup reason if we branch to kvm_start_guest. LR
  377. * is required to return back to reset vector after hypervisor state
  378. * restore is complete.
  379. */
  380. mflr r17
  381. mfspr r16,SPRN_SRR1
  382. BEGIN_FTR_SECTION
  383. CHECK_HMI_INTERRUPT
  384. END_FTR_SECTION_IFSET(CPU_FTR_HVMODE)
  385. lbz r7,PACA_THREAD_MASK(r13)
  386. ld r14,PACA_CORE_IDLE_STATE_PTR(r13)
  387. lwarx_loop2:
  388. lwarx r15,0,r14
  389. andi. r9,r15,PNV_CORE_IDLE_LOCK_BIT
  390. /*
  391. * Lock bit is set in one of the 2 cases-
  392. * a. In the sleep/winkle enter path, the last thread is executing
  393. * fastsleep workaround code.
  394. * b. In the wake up path, another thread is executing fastsleep
  395. * workaround undo code or resyncing timebase or restoring context
  396. * In either case loop until the lock bit is cleared.
  397. */
  398. bnel core_idle_lock_held
  399. cmpwi cr2,r15,0
  400. /*
  401. * At this stage
  402. * cr2 - eq if first thread to wakeup in core
  403. * cr3- gt if waking up with partial/complete hypervisor state loss
  404. * cr4 - gt or eq if waking up from complete hypervisor state loss.
  405. */
  406. ori r15,r15,PNV_CORE_IDLE_LOCK_BIT
  407. stwcx. r15,0,r14
  408. bne- lwarx_loop2
  409. isync
  410. BEGIN_FTR_SECTION
  411. lbz r4,PACA_SUBCORE_SIBLING_MASK(r13)
  412. and r4,r4,r15
  413. cmpwi r4,0 /* Check if first in subcore */
  414. or r15,r15,r7 /* Set thread bit */
  415. beq first_thread_in_subcore
  416. END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_300)
  417. or r15,r15,r7 /* Set thread bit */
  418. beq cr2,first_thread_in_core
  419. /* Not first thread in core or subcore to wake up */
  420. b clear_lock
  421. first_thread_in_subcore:
  422. /*
  423. * If waking up from sleep, subcore state is not lost. Hence
  424. * skip subcore state restore
  425. */
  426. blt cr4,subcore_state_restored
  427. /* Restore per-subcore state */
  428. ld r4,_SDR1(r1)
  429. mtspr SPRN_SDR1,r4
  430. ld r4,_RPR(r1)
  431. mtspr SPRN_RPR,r4
  432. ld r4,_AMOR(r1)
  433. mtspr SPRN_AMOR,r4
  434. subcore_state_restored:
  435. /*
  436. * Check if the thread is also the first thread in the core. If not,
  437. * skip to clear_lock.
  438. */
  439. bne cr2,clear_lock
  440. first_thread_in_core:
  441. /*
  442. * First thread in the core waking up from any state which can cause
  443. * partial or complete hypervisor state loss. It needs to
  444. * call the fastsleep workaround code if the platform requires it.
  445. * Call it unconditionally here. The below branch instruction will
  446. * be patched out if the platform does not have fastsleep or does not
  447. * require the workaround. Patching will be performed during the
  448. * discovery of idle-states.
  449. */
  450. .global pnv_fastsleep_workaround_at_exit
  451. pnv_fastsleep_workaround_at_exit:
  452. b fastsleep_workaround_at_exit
  453. timebase_resync:
  454. /*
  455. * Use cr3 which indicates that we are waking up with atleast partial
  456. * hypervisor state loss to determine if TIMEBASE RESYNC is needed.
  457. */
  458. ble cr3,clear_lock
  459. /* Time base re-sync */
  460. bl opal_rm_resync_timebase;
  461. /*
  462. * If waking up from sleep, per core state is not lost, skip to
  463. * clear_lock.
  464. */
  465. blt cr4,clear_lock
  466. /*
  467. * First thread in the core to wake up and its waking up with
  468. * complete hypervisor state loss. Restore per core hypervisor
  469. * state.
  470. */
  471. BEGIN_FTR_SECTION
  472. ld r4,_PTCR(r1)
  473. mtspr SPRN_PTCR,r4
  474. ld r4,_RPR(r1)
  475. mtspr SPRN_RPR,r4
  476. END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)
  477. ld r4,_TSCR(r1)
  478. mtspr SPRN_TSCR,r4
  479. ld r4,_WORC(r1)
  480. mtspr SPRN_WORC,r4
  481. clear_lock:
  482. andi. r15,r15,PNV_CORE_IDLE_THREAD_BITS
  483. lwsync
  484. stw r15,0(r14)
  485. common_exit:
  486. /*
  487. * Common to all threads.
  488. *
  489. * If waking up from sleep, hypervisor state is not lost. Hence
  490. * skip hypervisor state restore.
  491. */
  492. blt cr4,hypervisor_state_restored
  493. /* Waking up from winkle */
  494. BEGIN_MMU_FTR_SECTION
  495. b no_segments
  496. END_MMU_FTR_SECTION_IFSET(MMU_FTR_TYPE_RADIX)
  497. /* Restore SLB from PACA */
  498. ld r8,PACA_SLBSHADOWPTR(r13)
  499. .rept SLB_NUM_BOLTED
  500. li r3, SLBSHADOW_SAVEAREA
  501. LDX_BE r5, r8, r3
  502. addi r3, r3, 8
  503. LDX_BE r6, r8, r3
  504. andis. r7,r5,SLB_ESID_V@h
  505. beq 1f
  506. slbmte r6,r5
  507. 1: addi r8,r8,16
  508. .endr
  509. no_segments:
  510. /* Restore per thread state */
  511. ld r4,_SPURR(r1)
  512. mtspr SPRN_SPURR,r4
  513. ld r4,_PURR(r1)
  514. mtspr SPRN_PURR,r4
  515. ld r4,_DSCR(r1)
  516. mtspr SPRN_DSCR,r4
  517. ld r4,_WORT(r1)
  518. mtspr SPRN_WORT,r4
  519. /* Call cur_cpu_spec->cpu_restore() */
  520. LOAD_REG_ADDR(r4, cur_cpu_spec)
  521. ld r4,0(r4)
  522. ld r12,CPU_SPEC_RESTORE(r4)
  523. #ifdef PPC64_ELF_ABI_v1
  524. ld r12,0(r12)
  525. #endif
  526. mtctr r12
  527. bctrl
  528. hypervisor_state_restored:
  529. mtspr SPRN_SRR1,r16
  530. mtlr r17
  531. blr /* Return back to System Reset vector from where
  532. pnv_restore_hyp_resource was invoked */
  533. fastsleep_workaround_at_exit:
  534. li r3,1
  535. li r4,0
  536. bl opal_rm_config_cpu_idle_state
  537. b timebase_resync
  538. /*
  539. * R3 here contains the value that will be returned to the caller
  540. * of power7_nap.
  541. */
  542. _GLOBAL(pnv_wakeup_loss)
  543. ld r1,PACAR1(r13)
  544. BEGIN_FTR_SECTION
  545. CHECK_HMI_INTERRUPT
  546. END_FTR_SECTION_IFSET(CPU_FTR_HVMODE)
  547. REST_NVGPRS(r1)
  548. REST_GPR(2, r1)
  549. ld r6,_CCR(r1)
  550. ld r4,_MSR(r1)
  551. ld r5,_NIP(r1)
  552. addi r1,r1,INT_FRAME_SIZE
  553. mtcr r6
  554. mtspr SPRN_SRR1,r4
  555. mtspr SPRN_SRR0,r5
  556. rfid
  557. /*
  558. * R3 here contains the value that will be returned to the caller
  559. * of power7_nap.
  560. */
  561. _GLOBAL(pnv_wakeup_noloss)
  562. lbz r0,PACA_NAPSTATELOST(r13)
  563. cmpwi r0,0
  564. bne pnv_wakeup_loss
  565. BEGIN_FTR_SECTION
  566. CHECK_HMI_INTERRUPT
  567. END_FTR_SECTION_IFSET(CPU_FTR_HVMODE)
  568. ld r1,PACAR1(r13)
  569. ld r6,_CCR(r1)
  570. ld r4,_MSR(r1)
  571. ld r5,_NIP(r1)
  572. addi r1,r1,INT_FRAME_SIZE
  573. mtcr r6
  574. mtspr SPRN_SRR1,r4
  575. mtspr SPRN_SRR0,r5
  576. rfid