original_kernel/arch/powerpc/kernel
Shreyas B. Prabhu b32aadc1a8 powerpc/powernv: Fix race in updating core_idle_state
core_idle_state is maintained for each core. It uses 0-7 bits to track
whether a thread in the core has entered fastsleep or winkle. 8th bit is
used as a lock bit.
The lock bit is set in these 2 scenarios-
 - The thread is first in subcore to wakeup from sleep/winkle.
 - If its the last thread in the core about to enter sleep/winkle

While the lock bit is set, if any other thread in the core wakes up, it
loops until the lock bit is cleared before proceeding in the wakeup
path. This helps prevent race conditions w.r.t fastsleep workaround and
prevents threads from switching to process context before core/subcore
resources are restored.

But, in the path to sleep/winkle entry, we currently don't check for
lock-bit. This exposes us to following race when running with subcore
on-

First thread in the subcorea		Another thread in the same
waking up		   		core entering sleep/winkle

lwarx   r15,0,r14
ori     r15,r15,PNV_CORE_IDLE_LOCK_BIT
stwcx.  r15,0,r14
[Code to restore subcore state]

						lwarx   r15,0,r14
						[clear thread bit]
						stwcx.  r15,0,r14

andi.   r15,r15,PNV_CORE_IDLE_THREAD_BITS
stw     r15,0(r14)

Here, after the thread entering sleep clears its thread bit in
core_idle_state, the value is overwritten by the thread waking up.
In such cases when the core enters fastsleep, code mistakes an idle
thread as running. Because of this, the first thread waking up from
fastsleep which is supposed to resync timebase skips it. So we can
end up having a core with stale timebase value.

This patch fixes the above race by looping on the lock bit even while
entering the idle states.

Signed-off-by: Shreyas B. Prabhu <shreyas@linux.vnet.ibm.com>
Fixes: 7b54e9f213f76 'powernv/powerpc: Add winkle support for offline cpus'
Cc: stable@vger.kernel.org # 3.19+
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2015-07-07 10:16:52 +10:00
..
vdso32
vdso64
.gitignore
Makefile
align.c
asm-offsets.c
audit.c
btext.c
cacheinfo.c
cacheinfo.h
compat_audit.c
cpu_setup_6xx.S
cpu_setup_44x.S
cpu_setup_fsl_booke.S
cpu_setup_pa6t.S
cpu_setup_power.S
cpu_setup_ppc970.S
cputable.c
crash.c
crash_dump.c
dbell.c
dma-iommu.c
dma-swiotlb.c
dma.c
eeh.c
eeh_cache.c
eeh_dev.c
eeh_driver.c
eeh_event.c
eeh_pe.c
eeh_sysfs.c
entry_32.S
entry_64.S
epapr_hcalls.S
epapr_paravirt.c
exceptions-64e.S
exceptions-64s.S
fadump.c
firmware.c
fpu.S
fsl_booke_entry_mapping.S
ftrace.c
head_8xx.S
head_32.S
head_40x.S
head_44x.S
head_64.S
head_booke.h
head_fsl_booke.S
hw_breakpoint.c
ibmebus.c
idle.c
idle_6xx.S
idle_book3e.S
idle_e500.S
idle_power4.S
idle_power7.S
io-workarounds.c
io.c
iomap.c
iommu.c
irq.c
isa-bridge.c
jump_label.c
kgdb.c
kprobes.c
kvm.c
kvm_emul.S
l2cr_6xx.S
legacy_serial.c
machine_kexec.c
machine_kexec_32.c
machine_kexec_64.c
mce.c
mce_power.c
misc.S
misc_32.S
misc_64.S
module.c
module_32.c
module_64.c
msi.c
nvram_64.c
of_platform.c
paca.c
pci-common.c
pci-hotplug.c
pci_32.c
pci_64.c
pci_dn.c
pci_of_scan.c
pmc.c
ppc32.h
ppc_ksyms.c
ppc_ksyms_32.c
ppc_save_regs.S
proc_powerpc.c
process.c
prom.c
prom_init.c
prom_init_check.sh
prom_parse.c
ptrace.c
ptrace32.c
reloc_32.S
reloc_64.S
rtas-proc.c
rtas-rtc.c
rtas.c
rtas_flash.c
rtas_pci.c
rtasd.c
setup-common.c
setup_32.c
setup_64.c
signal.c
signal.h
signal_32.c
signal_64.c
smp-tbsync.c
smp.c
stacktrace.c
suspend.c
swsusp.c
swsusp_32.S
swsusp_64.c
swsusp_asm64.S
swsusp_booke.S
sys_ppc32.c
syscalls.c
sysfs.c
systbl.S
systbl_chk.c
systbl_chk.sh
tau_6xx.c
time.c
tm.S
traps.c
udbg.c
udbg_16550.c
uprobes.c
vdso.c
vecemu.c
vector.S
vio.c
vmlinux.lds.S