linux_dsm_epyc7002/arch/powerpc/platforms/powernv
Paul Mackerras 7672691a08 powerpc/powernv: Provide a way to force a core into SMT4 mode
POWER9 processors up to and including "Nimbus" v2.2 have hardware
bugs relating to transactional memory and thread reconfiguration.
One of these bugs has a workaround which is to get the core into
SMT4 state temporarily.  This workaround is only needed when
running bare-metal.

This patch provides a function which gets the core into SMT4 mode
by preventing threads from going to a stop state, and waking up
those which are already in a stop state.  Once at least 3 threads
are not in a stop state, the core will be in SMT4 and we can
continue.

To do this, we add a "dont_stop" flag to the paca to tell the
thread not to go into a stop state.  If this flag is set,
power9_idle_stop() just returns immediately with a return value
of 0.  The pnv_power9_force_smt4_catch() function does the following:

1. Set the dont_stop flag for each thread in the core, except
   ourselves (in fact we use an atomic_inc() in case more than
   one thread is calling this function concurrently).
2. See how many threads are awake, indicated by their
   requested_psscr field in the paca being 0.  If this is at
   least 3, skip to step 5.
3. Send a doorbell interrupt to each thread that was seen as
   being in a stop state in step 2.
4. Until at least 3 threads are awake, scan the threads to which
   we sent a doorbell interrupt and check if they are awake now.

This relies on the following properties:

- Once dont_stop is non-zero, requested_psccr can't go from zero to
  non-zero, except transiently (and without the thread doing stop).
- requested_psscr being zero guarantees that the thread isn't in
  a state-losing stop state where thread reconfiguration could occur.
- Doing stop with a PSSCR value of 0 won't be a state-losing stop
  and thus won't allow thread reconfiguration.
- Once threads_per_core/2 + 1 (i.e. 3) threads are awake, the core
  must be in SMT4 mode, since SMT modes are powers of 2.

This does add a sync to power9_idle_stop(), which is necessary to
provide the correct ordering between setting requested_psscr and
checking dont_stop.  The overhead of the sync should be unnoticeable
compared to the latency of going into and out of a stop state.

Because some objected to incurring this extra latency on systems where
the XER[SO] bug is not relevant, I have put the test in
power9_idle_stop inside a feature section.  This means that
pnv_power9_force_smt4_catch() WILL NOT WORK correctly on systems
without the CPU_FTR_P9_TM_XER_SO_BUG feature bit set, and will
probably hang the system.

In order to cater for uses where the caller has an operation that
has to be done while the core is in SMT4, the core continues to be
kept in SMT4 after pnv_power9_force_smt4_catch() function returns,
until the pnv_power9_force_smt4_release() function is called.
It undoes the effect of step 1 above and allows the other threads
to go into a stop state.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-03-24 00:39:11 +11:00
..
copy-paste.h powerpc/powernv/vas: Define copy/paste interfaces 2017-08-31 14:26:38 +10:00
eeh-powernv.c powerpc/eeh: Add EEH operations to notify resume 2018-01-27 20:02:52 +11:00
idle.c powerpc/powernv: Provide a way to force a core into SMT4 mode 2018-03-24 00:39:11 +11:00
Kconfig License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Makefile powerpc/powernv: Add platform-specific services for opencapi 2018-01-24 11:42:57 +11:00
memtrace.c powerpc/powernv: Enable removal of memory for in memory tracing 2017-08-24 22:14:38 +10:00
npu-dma.c powerpc/powernv/idoa: Remove unnecessary pcidev from pci_dn 2018-01-27 20:39:01 +11:00
ocxl.c ocxl: Add AFU interrupt support 2018-01-24 11:42:58 +11:00
opal-async.c powerpc/opal: Add opal_async_wait_response_interruptible() to opal-async 2017-11-06 20:39:28 +11:00
opal-dump.c powerpc: Use octal numbers for file permissions 2018-01-22 05:48:33 +11:00
opal-elog.c powerpc: Use octal numbers for file permissions 2018-01-22 05:48:33 +11:00
opal-flash.c powerpc: Add const to bin_attribute structures 2017-08-17 21:56:26 +10:00
opal-hmi.c powerpc-opal: Fix a typo in a comment line of two file headers 2017-10-22 12:16:36 +02:00
opal-imc.c powerpc/powernv: Add debugfs interface for imc-mode and imc-command 2018-01-19 23:05:00 +11:00
opal-irqchip.c powerpc/powernv: Make opal_event_shutdown() callable from IRQ context 2017-10-06 20:03:08 +11:00
opal-kmsg.c
opal-lpc.c powerpc: Create asm/debugfs.h and move powerpc_debugfs_root there 2017-04-11 07:46:03 +10:00
opal-memory-errors.c mm/memory_failure: Remove unused trapno from memory_failure 2018-01-23 12:17:42 -06:00
opal-msglog.c locking/atomics: COCCINELLE/treewide: Convert trivial ACCESS_ONCE() patterns to READ_ONCE()/WRITE_ONCE() 2017-10-25 11:01:08 +02:00
opal-nvram.c
opal-power.c
opal-powercap.c powerpc/powernv: Add support for powercap framework 2017-08-10 22:39:53 +10:00
opal-prd.c vfs: do bulk POLL* -> EPOLL* replacement 2018-02-11 14:34:03 -08:00
opal-psr.c powerpc/powernv: Add support to set power-shifting-ratio 2017-08-10 22:40:01 +10:00
opal-rtc.c
opal-sensor-groups.c powerpc/powernv: Add support to clear sensor groups data 2017-08-10 22:40:05 +10:00
opal-sensor.c powernv/opal-sensor: remove not needed lock 2017-11-06 20:33:56 +11:00
opal-sysparam.c powerpc: Use octal numbers for file permissions 2018-01-22 05:48:33 +11:00
opal-tracepoints.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
opal-wrappers.S powerpc/powernv: Add opal calls for opencapi 2018-01-24 11:42:56 +11:00
opal-xscom.c powerpc: Convert to using %pOF instead of full_name 2017-08-23 22:27:04 +10:00
opal.c powerpc/pseries, ps3: panic flush kernel messages before halting system 2018-01-22 11:44:24 +11:00
pci-cxl.c powerpc: Remove all usages of NO_IRQ 2016-09-20 20:57:12 +10:00
pci-ioda.c powerpc updates for 4.16 2018-02-02 10:01:04 -08:00
pci.c powerpc/powernv: Introduce new PHB type for opencapi links 2018-01-24 11:42:56 +11:00
pci.h powerpc/powernv: Introduce new PHB type for opencapi links 2018-01-24 11:42:56 +11:00
powernv.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
rng.c powerpc: Convert to using %pOF instead of full_name 2017-08-23 22:27:04 +10:00
setup.c powerpc/powernv: Check device-tree for RFI flush settings 2018-01-10 21:27:16 +11:00
smp.c powernv/kdump: Fix cases where the kdump kernel can get HMI's 2018-01-16 23:47:11 +11:00
subcore-asm.S
subcore.c powerpc updates for 4.13 2017-07-07 13:55:45 -07:00
subcore.h
vas-debug.c powerpc/vas: Export HVWC to debugfs 2017-11-12 09:03:09 +11:00
vas-window.c powerpc/vas: Add support for user receive window 2017-11-12 09:03:10 +11:00
vas.c powerpc/vas: Export chip_to_vas_id() 2017-11-21 21:02:26 +11:00
vas.h powerpc/vas: Define vas_win_id() 2017-11-12 09:03:10 +11:00