mirror of
https://github.com/torvalds/linux.git
synced 2026-04-22 00:33:58 -04:00
Context Timestamp (CTX_TIMESTAMP) in the LRC accumulates the run ticks
of the context, but only gets updated when the context switches out. In
order to check how long a context has been active before it switches
out, two things are required:
(1) Determine if the context is running:
To do so, we program the WA BB to set an initial value for CTX_TIMESTAMP
in the LRC. The value chosen is 1 since 0 is the initial value when the
LRC is initialized. During a query, we just check for this value to
determine if the context is active. If the context switched out, it
would overwrite this location with the actual CTX_TIMESTAMP MMIO value.
Note that WA BB runs as the last part of the context restore, so reusing
this LRC location will not clobber anything.
(2) Calculate the time that the context has been active for:
The CTX_TIMESTAMP ticks only when the context is active. If a context is
active, we just use the CTX_TIMESTAMP MMIO as the new value of
utilization. While doing so, we need to read the CTX_TIMESTAMP MMIO
for the specific engine instance. Since we do not know which instance
the context is running on until it is scheduled, we also read the
ENGINE_ID MMIO in the WA BB and store it in the PPHSWP.
Using the above 2 instructions in a WA BB, capture active context
utilization.
v2: (Matt Brost)
- This breaks TDR, fix it by saving the CTX_TIMESTAMP register
"drm/xe: Save CTX_TIMESTAMP mmio value instead of LRC value"
- Drop tile from LRC if using gt
"drm/xe: Save the gt pointer in LRC and drop the tile"
v3:
- Remove helpers for bb_per_ctx_ptr (Matt)
- Add define for context active value (Matt)
- Use 64 bit CTX TIMESTAMP for platforms that support it. For platforms
that don't, live with the rare race. (Matt, Lucas)
- Convert engine id to hwe and get the MMIO value (Lucas)
- Correct commit message on when WA BB runs (Lucas)
v4:
- s/GRAPHICS_VER(...)/xe->info.has_64bit_timestamp/ (Matt)
- Drop support for active utilization on a VF (CI failure)
- In xe_lrc_init ensure the lrc value is 0 to begin with (CI regression)
v5:
- Minor checkpatch fix
- Squash into previous commit and make TDR use 32-bit time
- Update code comment to match commit msg
Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/4532
Cc: <stable@vger.kernel.org> # v6.13+
Suggested-by: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://lore.kernel.org/r/20250509161159.2173069-8-umesh.nerlige.ramappa@intel.com
(cherry picked from commit 82b98cadb0)
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
40 lines
1.3 KiB
C
40 lines
1.3 KiB
C
/* SPDX-License-Identifier: MIT */
|
|
/*
|
|
* Copyright © 2023 Intel Corporation
|
|
*/
|
|
|
|
#ifndef _XE_LRC_LAYOUT_H_
|
|
#define _XE_LRC_LAYOUT_H_
|
|
|
|
#define CTX_CONTEXT_CONTROL (0x02 + 1)
|
|
#define CTX_RING_HEAD (0x04 + 1)
|
|
#define CTX_RING_TAIL (0x06 + 1)
|
|
#define CTX_RING_START (0x08 + 1)
|
|
#define CTX_RING_CTL (0x0a + 1)
|
|
#define CTX_BB_PER_CTX_PTR (0x12 + 1)
|
|
#define CTX_TIMESTAMP (0x22 + 1)
|
|
#define CTX_TIMESTAMP_UDW (0x24 + 1)
|
|
#define CTX_INDIRECT_RING_STATE (0x26 + 1)
|
|
#define CTX_PDP0_UDW (0x30 + 1)
|
|
#define CTX_PDP0_LDW (0x32 + 1)
|
|
|
|
#define CTX_LRM_INT_MASK_ENABLE 0x50
|
|
#define CTX_INT_MASK_ENABLE_REG (CTX_LRM_INT_MASK_ENABLE + 1)
|
|
#define CTX_INT_MASK_ENABLE_PTR (CTX_LRM_INT_MASK_ENABLE + 2)
|
|
#define CTX_LRI_INT_REPORT_PTR 0x55
|
|
#define CTX_INT_STATUS_REPORT_REG (CTX_LRI_INT_REPORT_PTR + 1)
|
|
#define CTX_INT_STATUS_REPORT_PTR (CTX_LRI_INT_REPORT_PTR + 2)
|
|
#define CTX_INT_SRC_REPORT_REG (CTX_LRI_INT_REPORT_PTR + 3)
|
|
#define CTX_INT_SRC_REPORT_PTR (CTX_LRI_INT_REPORT_PTR + 4)
|
|
|
|
#define CTX_CS_INT_VEC_REG 0x5a
|
|
#define CTX_CS_INT_VEC_DATA (CTX_CS_INT_VEC_REG + 1)
|
|
|
|
#define INDIRECT_CTX_RING_HEAD (0x02 + 1)
|
|
#define INDIRECT_CTX_RING_TAIL (0x04 + 1)
|
|
#define INDIRECT_CTX_RING_START (0x06 + 1)
|
|
#define INDIRECT_CTX_RING_START_UDW (0x08 + 1)
|
|
#define INDIRECT_CTX_RING_CTL (0x0a + 1)
|
|
|
|
#endif
|