]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
crypto: ccp - fix command queuing to TEE ring buffer
authorRijo Thomas <Rijo-john.Thomas@amd.com>
Mon, 15 Mar 2021 08:25:29 +0000 (13:55 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 May 2021 08:49:40 +0000 (10:49 +0200)
commitdd5cb323e2448fca6c415c5f595c46ea2f14a3de
treebb1a98dd93d594c4f9961e75243dac84cc00db2b
parentc73c8d99413be184a03f77c6c0df5c247c8d9575
crypto: ccp - fix command queuing to TEE ring buffer

[ Upstream commit 00aa6e65aa04e500a11a2c91e92a11c37b9e234d ]

Multiple threads or clients can submit a command to the TEE ring
buffer. This patch helps to synchronize command submission to the
ring.

One thread shall write a command to a TEE ring buffer entry only if:

 - Trusted OS has notified that the TEE command for the given entry
   has been processed and driver has copied the TEE response into
   client buffer.

 - The command entry is empty and can be written into.

After a command has been written to the TEE ring buffer, the global
wptr (mutex protected) shall be incremented for use by next client.

If PSP became unresponsive while processing TEE request from a
client, then further command submission to queue will be disabled.

Fixes: 33960acccfbd (crypto: ccp - add TEE support for Raven Ridge)
Reviewed-by: Devaraj Rangasamy <Devaraj.Rangasamy@amd.com>
Signed-off-by: Rijo Thomas <Rijo-john.Thomas@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/crypto/ccp/tee-dev.c
drivers/crypto/ccp/tee-dev.h