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)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 26 Mar 2021 09:02:34 +0000 (20:02 +1100)
commit00aa6e65aa04e500a11a2c91e92a11c37b9e234d
tree2d94a889e72182f76de5e514e81978eb58123acd
parent4a5eed1734933bcab8f70b60cc0912867d15423d
crypto: ccp - fix command queuing to TEE ring buffer

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>
drivers/crypto/ccp/tee-dev.c
drivers/crypto/ccp/tee-dev.h