Hardware workarounds
Hardware workarounds are register programming documented to be executed in the driver that fall outside of the normal programming sequences for a platform. There are some basic categories of workarounds, depending on how/when they are applied:
-
LRC workarounds: workarounds that touch registers that are saved/restored to/from the HW context image. The list is emitted (via Load Register Immediate commands) once when initializing the device and saved in the default context. That default context is then used on every context creation to have a "primed golden context", i.e. a context image that already contains the changes needed to all the registers. See drivers/gpu/drm/xe/xe_lrc.c for default context handling.
-
Engine workarounds: the list of these WAs is applied whenever the specific engine is reset. It's also possible that a set of engine classes share a common power domain and they are reset together. This happens on some platforms with render and compute engines. In this case (at least) one of them need to keeep the workaround programming: the approach taken in the driver is to tie those workarounds to the first compute/render engine that is registered. When executing with GuC submission, engine resets are outside of kernel driver control, hence the list of registers involved is written once, on engine initialization, and then passed to GuC, that saves/restores their values before/after the reset takes place. See drivers/gpu/drm/xe/xe_guc_ads.c for reference.
-
GT workarounds: the list of these WAs is applied whenever these registers revert to their default values: on GPU reset, suspend/resume [1]_, etc.
-
Register whitelist: some workarounds need to be implemented in userspace, but need to touch privileged registers. The whitelist in the kernel instructs the hardware to allow the access to happen. From the kernel side, this is just a special case of a MMIO workaround (as we write the list of these to/be-whitelisted registers to some special HW registers).
-
Workaround batchbuffers: buffers that get executed automatically by the hardware on every HW context restore. These buffers are created and programmed in the default context so the hardware always go through those programming sequences when switching contexts. The support for workaround batchbuffers is enabled via these hardware mechanisms:
-
INDIRECT_CTX (also known as mid context restore bb): A batchbuffer and an offset are provided in the default context, pointing the hardware to jump to that location when that offset is reached in the context restore. When a context is being restored, this is executed after the ring context, in the middle (or beginning) of the engine context image.
-
BB_PER_CTX_PTR (also known as post context restore bb): A batchbuffer is provided in the default context, pointing the hardware to a buffer to continue executing after the engine registers are restored in a context restore sequence.
Below is the timeline for a context restore sequence:
-
INDIRECT_CTX_OFFSET
|----------->|
.------------.------------.-------------.------------.--------------.-----------.
|Ring | Engine | Mid-context | Engine | Post-context | Ring |
|Restore | Restore (1)| BB Restore | Restore (2)| BB Restore | Execution |
`------------'------------'-------------'------------'--------------'-----------'
- Other/OOB: There are WAs that, due to their nature, cannot be applied from
a central place. Those are peppered around the rest of the code, as needed.
There's a central place to control which workarounds are enabled:
drivers/gpu/drm/xe/xe_wa_oob.rules for GT workarounds and
drivers/gpu/drm/xe/xe_device_wa_oob.rules for device/SoC workarounds.
These files only record which workarounds are enabled: during early device
initialization those rules are evaluated and recorded by the driver. Then
later the driver checks with
XE_GT_WA()andXE_DEVICE_WA()to implement them.
Internal API #
xe_wa_process_device_oob() #
void process OOB workaround table
Parameters
struct xe_device *xe: device instance to process workarounds for
Description
process OOB workaround table for this device, marking in xe the workarounds that are active.
xe_wa_process_gt_oob() #
void process GT OOB workaround table
Parameters
struct xe_gt *gt: GT instance to process workarounds for
Description
Process OOB workaround table for this platform, marking in gt the workarounds that are active.
xe_wa_process_gt() #
void process GT workaround table
Parameters
struct xe_gt *gt: GT instance to process workarounds for
Description
Process GT workaround table for this platform, saving in gt all the workarounds that need to be applied at the GT level.
xe_wa_process_engine() #
void process engine workaround table
Parameters
struct xe_hw_engine *hwe: engine instance to process workarounds for
Description
Process engine workaround table for this platform, saving in hwe all the workarounds that need to be applied at the engine level that match this engine.
xe_wa_process_lrc() #
void process context workaround table
Parameters
struct xe_hw_engine *hwe: engine instance to process workarounds for
Description
Process context workaround table for this platform, saving in hwe all the workarounds that need to be applied on context restore. These are workarounds touching registers that are part of the HW context image.
xe_wa_device_init() #
int initialize device with workaround oob bookkeeping
Parameters
struct xe_device *xe: Xe device instance to initialize
Description
Returns 0 for success, negative with error code otherwise
xe_wa_gt_init() #
int initialize gt with workaround bookkeeping
Parameters
struct xe_gt *gt: GT instance to initialize
Description
Returns 0 for success, negative error code otherwise.
xe_wa_gt_dump() #
int Dump GT workarounds into a drm printer.
Parameters
struct xe_gt *gt: thexe_gtstruct drm_printer *p: thedrm_printer
Return
always 0.