crypto: rockchip: v2: modify the length limit under dma_fd

When using DMA_fd, hardware crypto is used regardless of
 whether the data length is greater than 32K.

Signed-off-by: Lin Jinhan <troy.lin@rock-chips.com>
Change-Id: Ifcc78bca17beb99ae7eae73f3def6ebf55f5cf1b
This commit is contained in:
Lin Jinhan
2022-01-27 19:33:52 +08:00
committed by Tao Huang
parent 388805c56b
commit d54578aabc

View File

@@ -349,6 +349,23 @@ exit:
return ret;
}
static bool check_from_dmafd(struct skcipher_request *req)
{
if (!req || !req->src || !req->dst)
return false;
if (sg_nents_for_len(req->src, req->cryptlen) == 1 &&
sg_virt(req->src) &&
sg_dma_address(req->src) &&
sg_nents_for_len(req->dst, req->cryptlen) == 1 &&
sg_virt(req->dst) &&
sg_dma_address(req->dst) &&
sg_dma_len(req->src) == sg_dma_len(req->dst))
return true;
return false;
}
static int rk_cipher_crypt(struct skcipher_request *req, bool encrypt)
{
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
@@ -376,7 +393,8 @@ static int rk_cipher_crypt(struct skcipher_request *req, bool encrypt)
if (is_force_fallback(algt, ctx->keylen) ||
req->cryptlen > ctx->rk_dev->vir_max) {
return rk_cipher_fallback(req, ctx, encrypt);
if (!check_from_dmafd(req))
return rk_cipher_fallback(req, ctx, encrypt);
}
ctx->mode = cipher_algo2bc[algt->algo] |