2021-03-31 09:34:24

by yekai (A)

[permalink] [raw]
Subject: [PATCH v2 0/5] bug fix and clear coding style

Fixup coding style such as delete unneeded variable
initialization. Add a comment for block size initialization.
Add data cleared operation in sg buf unmap, and other misc fix.

v1 -> v2:
1. fix [PATCH v2] error in v1.
2. v1 use a macro replace of magic number, v2 use a comment
for block size initialization.

Kai Ye (5):
crypto: hisilicon/sgl - add a comment for block size initialization
crypto: hisilicon/sgl - delete unneeded variable initialization
crypto: hisilicon/sgl - add some dfx logs
crypto: hisilicon/sgl - fix the soft sg map to hardware sg
crypto: hisilicon/sgl - fix the sg buf unmap

drivers/crypto/hisilicon/sgl.c | 37 +++++++++++++++++++++++++++++++------
1 file changed, 31 insertions(+), 6 deletions(-)

--
2.8.1


2021-03-31 09:34:24

by yekai (A)

[permalink] [raw]
Subject: [PATCH v2 3/5] crypto: hisilicon/sgl - add some dfx logs

Add some dfx logs in some abnormal exit situations.

Signed-off-by: Kai Ye <[email protected]>
---
drivers/crypto/hisilicon/sgl.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/hisilicon/sgl.c b/drivers/crypto/hisilicon/sgl.c
index b8a811f..d04e551 100644
--- a/drivers/crypto/hisilicon/sgl.c
+++ b/drivers/crypto/hisilicon/sgl.c
@@ -90,8 +90,10 @@ struct hisi_acc_sgl_pool *hisi_acc_create_sgl_pool(struct device *dev,
block[i].sgl = dma_alloc_coherent(dev, block_size,
&block[i].sgl_dma,
GFP_KERNEL);
- if (!block[i].sgl)
+ if (!block[i].sgl) {
+ dev_err(dev, "Fail to allocate hw SG buffer!\n");
goto err_free_mem;
+ }

block[i].size = block_size;
}
@@ -100,8 +102,10 @@ struct hisi_acc_sgl_pool *hisi_acc_create_sgl_pool(struct device *dev,
block[i].sgl = dma_alloc_coherent(dev, remain_sgl * sgl_size,
&block[i].sgl_dma,
GFP_KERNEL);
- if (!block[i].sgl)
+ if (!block[i].sgl) {
+ dev_err(dev, "Fail to allocate remained hw SG buffer!\n");
goto err_free_mem;
+ }

block[i].size = remain_sgl * sgl_size;
}
@@ -216,16 +220,19 @@ hisi_acc_sg_buf_map_to_hw_sgl(struct device *dev,
sg_n = sg_nents(sgl);

sg_n_mapped = dma_map_sg(dev, sgl, sg_n, DMA_BIDIRECTIONAL);
- if (!sg_n_mapped)
+ if (!sg_n_mapped) {
+ dev_err(dev, "DMA mapping for SG error!\n");
return ERR_PTR(-EINVAL);
+ }

if (sg_n_mapped > pool->sge_nr) {
- dma_unmap_sg(dev, sgl, sg_n, DMA_BIDIRECTIONAL);
+ dev_err(dev, "the number of entries in input scatterlist is bigger than SGL pool setting.\n");
return ERR_PTR(-EINVAL);
}

curr_hw_sgl = acc_get_sgl(pool, index, &curr_sgl_dma);
if (IS_ERR(curr_hw_sgl)) {
+ dev_err(dev, "Get SGL error!\n");
dma_unmap_sg(dev, sgl, sg_n, DMA_BIDIRECTIONAL);
return ERR_PTR(-ENOMEM);

--
2.8.1