crypto: tegra-se-nvhost: Use GFP_ATOMIC if in atomic context

Check if the request may sleep and adjust the GFP flag. This fixes
the issue of sleep during atomic context in tegra-se driver.

Bug 4146804

Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
Change-Id: I40006fd0898a85ced75f49565106a9b47ed0dfd0
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2931331
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Akhil R
2023-07-05 10:21:17 +05:30
committed by mobile promotions
parent 309e6943e3
commit 02c4ecb369

View File

@@ -5261,8 +5261,9 @@ static int tegra_se_ccm_compute_auth(struct aead_request *req, bool encrypt)
total += ilen; total += ilen;
/* 2.2 - Copy adata and map it */ /* 2.2 - Copy adata and map it */
adata = dma_alloc_coherent(se_dev->dev, assoclen, adata = dma_alloc_coherent(se_dev->dev, assoclen, &adata_addr,
&adata_addr, GFP_KERNEL); (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
GFP_KERNEL : GFP_ATOMIC);
num_sgs = tegra_se_count_sgs(sg, assoclen); num_sgs = tegra_se_count_sgs(sg, assoclen);
sg_copy_to_buffer(sg, num_sgs, adata, assoclen); sg_copy_to_buffer(sg, num_sgs, adata, assoclen);
@@ -5461,7 +5462,7 @@ static int tegra_se_ccm_ctr(struct aead_request *req, bool encrypt)
* cryptlen case. * cryptlen case.
*/ */
dst_buf = dma_alloc_coherent(se_dev->dev, cryptlen+1, &dst_buf_dma_addr, dst_buf = dma_alloc_coherent(se_dev->dev, cryptlen+1, &dst_buf_dma_addr,
GFP_KERNEL); (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ? GFP_KERNEL : GFP_ATOMIC);
if (!dst_buf) if (!dst_buf)
return -ENOMEM; return -ENOMEM;
@@ -5994,7 +5995,8 @@ static int tegra_se_gcm_op(struct aead_request *req, bool encrypt)
* cryptlen case. * cryptlen case.
*/ */
dst_buf = dma_alloc_coherent(se_dev->dev, cryptlen+1, &dst_buf_dma_addr, dst_buf = dma_alloc_coherent(se_dev->dev, cryptlen+1, &dst_buf_dma_addr,
GFP_KERNEL); (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
GFP_KERNEL : GFP_ATOMIC);
if (!dst_buf) if (!dst_buf)
return -ENOMEM; return -ENOMEM;