qseecom: fix a race condition when loading TA

Userspace and kernel clients may load a same TA at the same time.
To fix potential race condition, first kernel side need to release
mutex before sleep when failed to do ion allocation from QSEECOM_TA
heap. Besides, since kernel client may fail to load TA if this TA is
just being loaded by userspace client when mutex is released, it need
to recheck if this TA exists if TA loading error code is TA already
loaded.

Change-Id: Ie6af9c67b867dfae7b25e4ade6948dea67e476d6
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2 files changed