CHROMIUM: drm/i915/pxp: handle init/term race condition

If the PXP TEE message to initialize a session is interrupted by a
signal, instead of waiting for the response to confirm the session has
been initialized the driver exits immediately. The message however was
still sent and the session ends up being created later.

Normally upon app crash, intel_pxp_file_close() will cleanup and
terminate any associated sessions.
In this case however, a race condition occurs since the terminate is
called after the signal but before the session has finished initializing
so the terminate does nothing and afterwards the session is created
without the driver knowing.
Eg. SW thinks the sessions is free but HW session is initialized

To fix this, if we find a session where the SW and HW state don't align,
attempt to terminate the session before trying to reserve it again.

Signed-off-by: Juston Li <juston.li@intel.com>
Change-Id: Ia5a98259001e56ba947bbd4e88a01602836e4cfa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/3222757
Reviewed-by: Jeffrey Kardatzke <jkardatzke@google.com>
Commit-Queue: Jeffrey Kardatzke <jkardatzke@google.com>
Tested-by: Jeffrey Kardatzke <jkardatzke@google.com>
1 file changed