xref: /linux/Documentation/gpu/amdgpu/process-isolation.rst (revision 23b0f90ba871f096474e1c27c3d14f455189d2d9)
1.. _amdgpu-process-isolation:
2.. SPDX-License-Identifier: GPL-2.0
3
4=========================
5 AMDGPU Process Isolation
6=========================
7
8The AMDGPU driver includes a feature that enables automatic process isolation on the graphics engine. This feature serializes access to the graphics engine and adds a cleaner shader which clears the Local Data Store (LDS) and General Purpose Registers (GPRs) between jobs. All processes using the GPU, including both graphics and compute workloads, are serialized when this feature is enabled. On GPUs that support partitionable graphics engines, this feature can be enabled on a per-partition basis.
9
10In addition, there is an interface to manually run the cleaner shader when the use of the GPU is complete. This may be preferable in some use cases, such as a single-user system where the login manager triggers the cleaner shader when the user logs out.
11
12Process Isolation
13=================
14
15The `run_cleaner_shader` and `enforce_isolation` sysfs interfaces allow users to manually execute the cleaner shader and control the process isolation feature, respectively.
16
17Partition Handling
18------------------
19
20The `enforce_isolation` file in sysfs can be used to enable process isolation and automatic shader cleanup between processes. On GPUs that support graphics engine partitioning, this can be enabled per partition. The partition and its current setting (0 disabled, 1 enabled) can be read from sysfs. On GPUs that do not support graphics engine partitioning, only a single partition will be present. Writing 1 to the partition position enables enforce isolation, writing 0 disables it.
21
22Example of enabling enforce isolation on a GPU with multiple partitions:
23
24.. code-block:: console
25
26    $ echo 1 0 1 0 > /sys/class/drm/card0/device/enforce_isolation
27    $ cat /sys/class/drm/card0/device/enforce_isolation
28    1 0 1 0
29
30The output indicates that enforce isolation is enabled on zeroth and second partition and disabled on first and third partition.
31
32For devices with a single partition or those that do not support partitions, there will be only one element:
33
34.. code-block:: console
35
36    $ echo 1 > /sys/class/drm/card0/device/enforce_isolation
37    $ cat /sys/class/drm/card0/device/enforce_isolation
38    1
39
40Cleaner Shader Execution
41========================
42
43The driver can trigger a cleaner shader to clean up the LDS and GPR state on the graphics engine. When process isolation is enabled, this happens automatically between processes. In addition, there is a sysfs file to manually trigger cleaner shader execution.
44
45To manually trigger the execution of the cleaner shader, write `0` to the `run_cleaner_shader` sysfs file:
46
47.. code-block:: console
48
49    $ echo 0 > /sys/class/drm/card0/device/run_cleaner_shader
50
51For multi-partition devices, you can specify the partition index when triggering the cleaner shader:
52
53.. code-block:: console
54
55    $ echo 0 > /sys/class/drm/card0/device/run_cleaner_shader # For partition 0
56    $ echo 1 > /sys/class/drm/card0/device/run_cleaner_shader # For partition 1
57    $ echo 2 > /sys/class/drm/card0/device/run_cleaner_shader # For partition 2
58    # ... and so on for each partition
59
60This command initiates the cleaner shader, which will run and complete before any new tasks are scheduled on the GPU.
61