]> git.baikalelectronics.ru Git - kernel.git/commit
drm/i915/pmu: Fix KMD and GuC race on accessing busyness
authorUmesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Tue, 25 Jan 2022 02:01:24 +0000 (18:01 -0800)
committerJohn Harrison <John.C.Harrison@Intel.com>
Thu, 27 Jan 2022 23:43:01 +0000 (15:43 -0800)
commit26cd3aa293ed7bc97a69fd01fe8a687967bda169
tree9b6b5d2f9c48915f4cfe19f9dfc781301e5c78e0
parent0715be4c5af1d05247a407234c96b9d69590203e
drm/i915/pmu: Fix KMD and GuC race on accessing busyness

GuC updates shared memory and KMD reads it. Since this is not
synchronized, we run into a race where the value read is inconsistent.
Sometimes the inconsistency is in reading the upper MSB bytes of the
last_switch_in value. 2 types of cases are seen - upper 8 bits are zero
and upper 24 bits are zero. Since these are non-zero values, it is
not trivial to determine validity of these values. Instead we read the
values multiple times until they are consistent. In test runs, 3
attempts results in consistent values. The upper bound is set to 6
attempts and may need to be tuned as per any new occurences.

Since the duration that gt is parked can vary, the patch also updates
the gt timestamp on unpark before starting the worker.

v2:
- Initialize i
- Use READ_ONCE to access engine record

Fixes: e10bc7e8a7a5 ("drm/i915/pmu: Connect engine busyness stats from GuC to pmu")
Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Reviewed-by: Alan Previn <alan.previn.teres.alexis@intel.com>
Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220125020124.788679-2-umesh.nerlige.ramappa@intel.com
drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c