Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu/gfx_v9_4_3: Apply Isolation Enforcement to GFX & Compute rings

This commit applies isolation enforcement to the GFX and Compute rings
in the gfx_v9_4_3 module.

The commit sets `amdgpu_gfx_enforce_isolation_ring_begin_use` and
`amdgpu_gfx_enforce_isolation_ring_end_use` as the functions to be
called when a ring begins and ends its use, respectively.

`amdgpu_gfx_enforce_isolation_ring_begin_use` is called when a ring
begins its use. This function cancels any scheduled
`enforce_isolation_work` and, if necessary, signals the Kernel Fusion
Driver (KFD) to stop the runqueue.

`amdgpu_gfx_enforce_isolation_ring_end_use` is called when a ring ends
its use. This function schedules `enforce_isolation_work` to be run
after a delay.

These functions are part of the Enforce Isolation Handler, which
enforces shader isolation on AMD GPUs to prevent data leakage between
different processes.

The commit also includes a check for the type of the ring. If the type
of the ring is `AMDGPU_RING_TYPE_COMPUTE`, the `xcp_id` of the
`enforce_isolation` structure in the `gfx` structure of the
`amdgpu_device` is set to the `xcp_id` of the ring. This ensures that
the correct `xcp_id` is used when enforcing isolation on compute rings.
The `xcp_id` is an identifier for an XCP partition, and different rings
can be associated with different XCP partitions.

Cc: Christian König <christian.koenig@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>

authored by

Srinivasan Shanmugam and committed by
Alex Deucher
f846250b b710dbe5

+6
+4
drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c
··· 75 75 uint32_t inst_mask; 76 76 77 77 ring->xcp_id = AMDGPU_XCP_NO_PARTITION; 78 + if (ring->funcs->type == AMDGPU_RING_TYPE_COMPUTE) 79 + adev->gfx.enforce_isolation[0].xcp_id = ring->xcp_id; 78 80 if (adev->xcp_mgr->mode == AMDGPU_XCP_MODE_NONE) 79 81 return; 80 82 ··· 105 103 for (xcp_id = 0; xcp_id < adev->xcp_mgr->num_xcps; xcp_id++) { 106 104 if (adev->xcp_mgr->xcp[xcp_id].ip[ip_blk].inst_mask & inst_mask) { 107 105 ring->xcp_id = xcp_id; 106 + if (ring->funcs->type == AMDGPU_RING_TYPE_COMPUTE) 107 + adev->gfx.enforce_isolation[xcp_id].xcp_id = xcp_id; 108 108 break; 109 109 } 110 110 }
+2
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
··· 4671 4671 .emit_wave_limit = gfx_v9_4_3_emit_wave_limit, 4672 4672 .reset = gfx_v9_4_3_reset_kcq, 4673 4673 .emit_cleaner_shader = gfx_v9_4_3_ring_emit_cleaner_shader, 4674 + .begin_use = amdgpu_gfx_enforce_isolation_ring_begin_use, 4675 + .end_use = amdgpu_gfx_enforce_isolation_ring_end_use, 4674 4676 }; 4675 4677 4676 4678 static const struct amdgpu_ring_funcs gfx_v9_4_3_ring_funcs_kiq = {