Skip to content

Commit 0fef4ca

Browse files
peter-mitsiscfriedt
authored andcommitted
doc: Add notes on lazy HiFi sharing
Updates the Xtensa hardware documentation to provide details about the new lazy HiFi sharing model. Signed-off-by: Peter Mitsis <[email protected]>
1 parent 24d67b8 commit 0fef4ca

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

doc/hardware/arch/xtensa.rst

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,28 @@ Shared HiFi registers mode
5050

5151
This mode is used when the application has two or more threads that use HiFi
5252
registers. When enabled, the kernel automatically allows all threads to use the
53-
HiFi registers. During each thread context switch, the kernel saves the outgoing
54-
thread's HiFi registers and loads the incoming thread's HiFi registers,
55-
regardless of whether the thread utilizes them or not.
53+
HiFi registers. Conceptually, it can be sub-divided into two sub-modes--eager
54+
mode and lazy mode. They will both save and restore the HiFi registers, but
55+
they differ in when the registers are saved and restored, as well as to where
56+
they are saved and from where they are restored.
5657

58+
In the eager sharing model, the HiFi registers are saved and restored during
59+
every thread context switch, regardless of whether the thread used them or not.
5760
Additional stack space may be required for each thread to account for the extra
58-
registers that must be saved.
61+
registers that must be saved. This is default of the two models.
62+
63+
In the lazy sharing model, the kernel tracks the thread that 'owns' the
64+
coprocessor. If the 'owning' thread is switched out, the HiFi registers will
65+
not be saved until a new thread attempts to use the HiFi, after which that
66+
new thread becomes the new owner and its HiFi registers are loaded.
67+
68+
.. note::
69+
If an SMP system detects that the owner-to-be is still an owner on another
70+
CPU, an IPI will be sent to that CPU to initiate the saving of its HiFi
71+
registers to memory. The current processor will then spin until the HiFi
72+
registers are saved. This spinning may result in sporadically longer
73+
delays. For the best performance, it is recommended that a thread
74+
using HiFi be pinned to a single CPU.
5975

6076
Configuration Options
6177
=====================
@@ -71,3 +87,10 @@ configuration options :kconfig:option:`CONFIG_XTENSA_HIFI3` and/or
7187
:kconfig:option:`CONFIG_XTENSA_HIFI4`. Threads must have sufficient
7288
stack space for saving the HiFi register values during context switches
7389
as described above.
90+
91+
Both eager and lazy HiFi sharing modes require the configuration option
92+
:kconfig:option:`CONFIG_XTENSA_HIFI_SHARING` to be enabled. Although eager
93+
HiFi sharing is the default, it can be explicitly selected by enabling the
94+
configuration option :kconfig:option:`CONFIG_XTENSA_EAGER_HIFI_SHARING`. To
95+
select lazy HiFi sharing instead, enable the configuration option
96+
:kconfig:option:`CONFIG_XTENSA_LAZY_HIFI_SHARING`.

0 commit comments

Comments
 (0)