Linux Audio

Check our new training course

Loading...
v5.9
  1/* SPDX-License-Identifier: GPL-2.0-or-later */
  2/*
  3 * Copyright 2010 IBM Corp, Benjamin Herrenschmidt <benh@kernel.crashing.org>
  4 *
  5 * Generic idle routine for Book3E processors
 
 
 
 
 
  6 */
  7
  8#include <linux/threads.h>
  9#include <asm/reg.h>
 10#include <asm/ppc_asm.h>
 11#include <asm/asm-offsets.h>
 12#include <asm/ppc-opcode.h>
 13#include <asm/processor.h>
 14#include <asm/thread_info.h>
 15#include <asm/epapr_hcalls.h>
 16#include <asm/hw_irq.h>
 17
 18/* 64-bit version only for now */
 19#ifdef CONFIG_PPC64
 20
 21.macro BOOK3E_IDLE name loop
 22_GLOBAL(\name)
 23	/* Save LR for later */
 24	mflr	r0
 25	std	r0,16(r1)
 26
 27	/* Hard disable interrupts */
 28	wrteei	0
 29
 30	/* Now check if an interrupt came in while we were soft disabled
 31	 * since we may otherwise lose it (doorbells etc...).
 32	 */
 33	lbz	r3,PACAIRQHAPPENED(r13)
 34	cmpwi	cr0,r3,0
 35	bne	2f
 36
 37	/* Now we are going to mark ourselves as soft and hard enabled in
 38	 * order to be able to take interrupts while asleep. We inform lockdep
 39	 * of that. We don't actually turn interrupts on just yet tho.
 40	 */
 41#ifdef CONFIG_TRACE_IRQFLAGS
 42	stdu    r1,-128(r1)
 43	bl	trace_hardirqs_on
 44	addi    r1,r1,128
 45#endif
 46	li	r0,IRQS_ENABLED
 47	stb	r0,PACAIRQSOFTMASK(r13)
 48	
 49	/* Interrupts will make use return to LR, so get something we want
 50	 * in there
 51	 */
 52	bl	1f
 53
 54	/* And return (interrupts are on) */
 55	ld	r0,16(r1)
 56	mtlr	r0
 57	blr
 58
 591:	/* Let's set the _TLF_NAPPING flag so interrupts make us return
 60	 * to the right spot
 61	*/
 62	ld	r11, PACACURRENT(r13)
 63	ld	r10,TI_LOCAL_FLAGS(r11)
 64	ori	r10,r10,_TLF_NAPPING
 65	std	r10,TI_LOCAL_FLAGS(r11)
 66
 67	/* We can now re-enable hard interrupts and go to sleep */
 68	wrteei	1
 69	\loop
 70
 712:
 72	lbz	r10,PACAIRQHAPPENED(r13)
 73	ori	r10,r10,PACA_IRQ_HARD_DIS
 74	stb	r10,PACAIRQHAPPENED(r13)
 75	blr
 76.endm
 77
 78.macro BOOK3E_IDLE_LOOP
 791:
 80	PPC_WAIT(0)
 81	b	1b
 82.endm
 83
 84/* epapr_ev_idle_start below is patched with the proper hcall
 85   opcodes during kernel initialization */
 86.macro EPAPR_EV_IDLE_LOOP
 87idle_loop:
 88	LOAD_REG_IMMEDIATE(r11, EV_HCALL_TOKEN(EV_IDLE))
 89
 90.global epapr_ev_idle_start
 91epapr_ev_idle_start:
 92	li      r3, -1
 93	nop
 94	nop
 95	nop
 96	b       idle_loop
 97.endm
 98
 99BOOK3E_IDLE epapr_ev_idle EPAPR_EV_IDLE_LOOP
100
101BOOK3E_IDLE book3e_idle BOOK3E_IDLE_LOOP
102
103#endif /* CONFIG_PPC64 */
v4.17
 
  1/*
  2 * Copyright 2010 IBM Corp, Benjamin Herrenschmidt <benh@kernel.crashing.org>
  3 *
  4 * Generic idle routine for Book3E processors
  5 *
  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.
 10 */
 11
 12#include <linux/threads.h>
 13#include <asm/reg.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>
 19#include <asm/epapr_hcalls.h>
 20#include <asm/hw_irq.h>
 21
 22/* 64-bit version only for now */
 23#ifdef CONFIG_PPC64
 24
 25.macro BOOK3E_IDLE name loop
 26_GLOBAL(\name)
 27	/* Save LR for later */
 28	mflr	r0
 29	std	r0,16(r1)
 30
 31	/* Hard disable interrupts */
 32	wrteei	0
 33
 34	/* Now check if an interrupt came in while we were soft disabled
 35	 * since we may otherwise lose it (doorbells etc...).
 36	 */
 37	lbz	r3,PACAIRQHAPPENED(r13)
 38	cmpwi	cr0,r3,0
 39	bnelr
 40
 41	/* Now we are going to mark ourselves as soft and hard enabled in
 42	 * order to be able to take interrupts while asleep. We inform lockdep
 43	 * of that. We don't actually turn interrupts on just yet tho.
 44	 */
 45#ifdef CONFIG_TRACE_IRQFLAGS
 46	stdu    r1,-128(r1)
 47	bl	trace_hardirqs_on
 48	addi    r1,r1,128
 49#endif
 50	li	r0,IRQS_ENABLED
 51	stb	r0,PACAIRQSOFTMASK(r13)
 52	
 53	/* Interrupts will make use return to LR, so get something we want
 54	 * in there
 55	 */
 56	bl	1f
 57
 58	/* And return (interrupts are on) */
 59	ld	r0,16(r1)
 60	mtlr	r0
 61	blr
 62
 631:	/* Let's set the _TLF_NAPPING flag so interrupts make us return
 64	 * to the right spot
 65	*/
 66	CURRENT_THREAD_INFO(r11, r1)
 67	ld	r10,TI_LOCAL_FLAGS(r11)
 68	ori	r10,r10,_TLF_NAPPING
 69	std	r10,TI_LOCAL_FLAGS(r11)
 70
 71	/* We can now re-enable hard interrupts and go to sleep */
 72	wrteei	1
 73	\loop
 74
 
 
 
 
 
 75.endm
 76
 77.macro BOOK3E_IDLE_LOOP
 781:
 79	PPC_WAIT(0)
 80	b	1b
 81.endm
 82
 83/* epapr_ev_idle_start below is patched with the proper hcall
 84   opcodes during kernel initialization */
 85.macro EPAPR_EV_IDLE_LOOP
 86idle_loop:
 87	LOAD_REG_IMMEDIATE(r11, EV_HCALL_TOKEN(EV_IDLE))
 88
 89.global epapr_ev_idle_start
 90epapr_ev_idle_start:
 91	li      r3, -1
 92	nop
 93	nop
 94	nop
 95	b       idle_loop
 96.endm
 97
 98BOOK3E_IDLE epapr_ev_idle EPAPR_EV_IDLE_LOOP
 99
100BOOK3E_IDLE book3e_idle BOOK3E_IDLE_LOOP
101
102#endif /* CONFIG_PPC64 */