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

drm/i915: Update workaround documentation

There were several updates in the driver on how the workarounds are
handled since its documentation was written. Update the documentation to
reflect the current reality.

v2:
- Remove footnote that was wrongly referenced, adding back the
reference in the correct paragraph.
- Remove "Display workarounds" and just mention "display IP" under
"Other" category since all of them are peppered around the driver.

Cc: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Acked-by: Balasubramani Vivekanandan <balasubramani.vivekanandan@intel.com> # v1
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221115192611.179981-1-lucas.demarchi@intel.com

+52 -32
+52 -32
drivers/gpu/drm/i915/gt/intel_workarounds.c
··· 17 17 /** 18 18 * DOC: Hardware workarounds 19 19 * 20 - * This file is intended as a central place to implement most [1]_ of the 21 - * required workarounds for hardware to work as originally intended. They fall 22 - * in five basic categories depending on how/when they are applied: 20 + * Hardware workarounds are register programming documented to be executed in 21 + * the driver that fall outside of the normal programming sequences for a 22 + * platform. There are some basic categories of workarounds, depending on 23 + * how/when they are applied: 23 24 * 24 - * - Workarounds that touch registers that are saved/restored to/from the HW 25 - * context image. The list is emitted (via Load Register Immediate commands) 26 - * everytime a new context is created. 27 - * - GT workarounds. The list of these WAs is applied whenever these registers 28 - * revert to default values (on GPU reset, suspend/resume [2]_, etc..). 29 - * - Display workarounds. The list is applied during display clock-gating 30 - * initialization. 31 - * - Workarounds that whitelist a privileged register, so that UMDs can manage 32 - * them directly. This is just a special case of a MMMIO workaround (as we 33 - * write the list of these to/be-whitelisted registers to some special HW 34 - * registers). 35 - * - Workaround batchbuffers, that get executed automatically by the hardware 36 - * on every HW context restore. 25 + * - Context workarounds: workarounds that touch registers that are 26 + * saved/restored to/from the HW context image. The list is emitted (via Load 27 + * Register Immediate commands) once when initializing the device and saved in 28 + * the default context. That default context is then used on every context 29 + * creation to have a "primed golden context", i.e. a context image that 30 + * already contains the changes needed to all the registers. 37 31 * 38 - * .. [1] Please notice that there are other WAs that, due to their nature, 39 - * cannot be applied from a central place. Those are peppered around the rest 40 - * of the code, as needed. 32 + * - Engine workarounds: the list of these WAs is applied whenever the specific 33 + * engine is reset. It's also possible that a set of engine classes share a 34 + * common power domain and they are reset together. This happens on some 35 + * platforms with render and compute engines. In this case (at least) one of 36 + * them need to keeep the workaround programming: the approach taken in the 37 + * driver is to tie those workarounds to the first compute/render engine that 38 + * is registered. When executing with GuC submission, engine resets are 39 + * outside of kernel driver control, hence the list of registers involved in 40 + * written once, on engine initialization, and then passed to GuC, that 41 + * saves/restores their values before/after the reset takes place. See 42 + * ``drivers/gpu/drm/i915/gt/uc/intel_guc_ads.c`` for reference. 41 43 * 42 - * .. [2] Technically, some registers are powercontext saved & restored, so they 44 + * - GT workarounds: the list of these WAs is applied whenever these registers 45 + * revert to their default values: on GPU reset, suspend/resume [1]_, etc. 46 + * 47 + * - Register whitelist: some workarounds need to be implemented in userspace, 48 + * but need to touch privileged registers. The whitelist in the kernel 49 + * instructs the hardware to allow the access to happen. From the kernel side, 50 + * this is just a special case of a MMIO workaround (as we write the list of 51 + * these to/be-whitelisted registers to some special HW registers). 52 + * 53 + * - Workaround batchbuffers: buffers that get executed automatically by the 54 + * hardware on every HW context restore. These buffers are created and 55 + * programmed in the default context so the hardware always go through those 56 + * programming sequences when switching contexts. The support for workaround 57 + * batchbuffers is enabled these hardware mechanisms: 58 + * 59 + * #. INDIRECT_CTX: A batchbuffer and an offset are provided in the default 60 + * context, pointing the hardware to jump to that location when that offset 61 + * is reached in the context restore. Workaround batchbuffer in the driver 62 + * currently uses this mechanism for all platforms. 63 + * 64 + * #. BB_PER_CTX_PTR: A batchbuffer is provided in the default context, 65 + * pointing the hardware to a buffer to continue executing after the 66 + * engine registers are restored in a context restore sequence. This is 67 + * currently not used in the driver. 68 + * 69 + * - Other: There are WAs that, due to their nature, cannot be applied from a 70 + * central place. Those are peppered around the rest of the code, as needed. 71 + * Workarounds related to the display IP are the main example. 72 + * 73 + * .. [1] Technically, some registers are powercontext saved & restored, so they 43 74 * survive a suspend/resume. In practice, writing them again is not too 44 - * costly and simplifies things. We can revisit this in the future. 45 - * 46 - * Layout 47 - * ~~~~~~ 48 - * 49 - * Keep things in this file ordered by WA type, as per the above (context, GT, 50 - * display, register whitelist, batchbuffer). Then, inside each type, keep the 51 - * following order: 52 - * 53 - * - Infrastructure functions and macros 54 - * - WAs per platform in standard gen/chrono order 55 - * - Public functions to init or apply the given workaround type. 75 + * costly and simplifies things, so it's the approach taken in the driver. 56 76 */ 57 77 58 78 static void wa_init_start(struct i915_wa_list *wal, struct intel_gt *gt,