tee: amdtee: unload TA only when its refcount becomes 0
authorRijo Thomas <Rijo-john.Thomas@amd.com>
Wed, 14 Apr 2021 17:38:27 +0000 (23:08 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 May 2021 10:06:47 +0000 (12:06 +0200)
commitc39a190d834dee504a09ef8b54786cc43c9e3568
tree7b7322d0701ad361414ccf63456b1200295ba2f9
parent12de3ff989358fc20110e1ea53ba17fb1a79630d
tee: amdtee: unload TA only when its refcount becomes 0

[ Upstream commit 9f015b3765bf593b3ed5d3b588e409dc0ffa9f85 ]

Same Trusted Application (TA) can be loaded in multiple TEE contexts.

If it is a single instance TA, the TA should not get unloaded from AMD
Secure Processor, while it is still in use in another TEE context.

Therefore reference count TA and unload it when the count becomes zero.

Fixes: 757cc3e9ff1d ("tee: add AMD-TEE driver")
Reviewed-by: Devaraj Rangasamy <Devaraj.Rangasamy@amd.com>
Signed-off-by: Rijo Thomas <Rijo-john.Thomas@amd.com>
Acked-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/tee/amdtee/amdtee_private.h
drivers/tee/amdtee/call.c
drivers/tee/amdtee/core.c