2020-10-31 09:10:22

by Weili Qian

[permalink] [raw]
Subject: [PATCH 0/8] crypto: hisilicon/qm - misc clean up

This patchset makes some clean up, please see comments in each patch.

Weili Qian (8):
crypto: hisilicon/qm - numbers are replaced by macros
crypto: hisilicon/qm - modify the return type of function
crypto: hisilicon/qm - modify the return type of debugfs interface
crypto: hisilicon/qm - modify return type of 'qm_set_sqctype'
crypto: hisilicon/qm - replace 'sprintf' with 'scnprintf'
crypto: hisilicon/qm - split 'qm_qp_ctx_cfg' into smaller pieces
crypto: hisilicon/qm - split 'qm_eq_ctx_cfg' into smaller pieces
crypto: hisilicon/qm - split 'hisi_qm_init' into smaller pieces

drivers/crypto/hisilicon/hpre/hpre_main.c | 4 +-
drivers/crypto/hisilicon/qm.c | 207 +++++++++++++++++++-----------
drivers/crypto/hisilicon/qm.h | 2 +-
drivers/crypto/hisilicon/sec2/sec_main.c | 4 +-
drivers/crypto/hisilicon/zip/zip_main.c | 4 +-
5 files changed, 134 insertions(+), 87 deletions(-)

--
2.8.1


2020-10-31 09:11:29

by Weili Qian

[permalink] [raw]
Subject: [PATCH 7/8] crypto: hisilicon/qm - split 'qm_eq_ctx_cfg' into smaller pieces

'qm_eq_ctx_cfg' initializes configuration of EQ and AEQ,
split it into two pieces to improve code readability.

Signed-off-by: Weili Qian <[email protected]>
Reviewed-by: Zhou Wang <[email protected]>
---
drivers/crypto/hisilicon/qm.c | 44 +++++++++++++++++++++++++++++++------------
1 file changed, 32 insertions(+), 12 deletions(-)

diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c
index 4c5cc60..6e8d20d 100644
--- a/drivers/crypto/hisilicon/qm.c
+++ b/drivers/crypto/hisilicon/qm.c
@@ -1735,7 +1735,7 @@ void hisi_qm_release_qp(struct hisi_qp *qp)
}
EXPORT_SYMBOL_GPL(hisi_qm_release_qp);

-static int qm_sq_ctx_cfg(struct hisi_qp *qp, int qp_id, int pasid)
+static int qm_sq_ctx_cfg(struct hisi_qp *qp, int qp_id, u32 pasid)
{
struct hisi_qm *qm = qp->qm;
struct device *dev = &qm->pdev->dev;
@@ -1772,7 +1772,7 @@ static int qm_sq_ctx_cfg(struct hisi_qp *qp, int qp_id, int pasid)
return ret;
}

-static int qm_cq_ctx_cfg(struct hisi_qp *qp, int qp_id, int pasid)
+static int qm_cq_ctx_cfg(struct hisi_qp *qp, int qp_id, u32 pasid)
{
struct hisi_qm *qm = qp->qm;
struct device *dev = &qm->pdev->dev;
@@ -1784,7 +1784,6 @@ static int qm_cq_ctx_cfg(struct hisi_qp *qp, int qp_id, int pasid)
cqc = kzalloc(sizeof(struct qm_cqc), GFP_KERNEL);
if (!cqc)
return -ENOMEM;
-
cqc_dma = dma_map_single(dev, cqc, sizeof(struct qm_cqc),
DMA_TO_DEVICE);
if (dma_mapping_error(dev, cqc_dma)) {
@@ -1810,7 +1809,7 @@ static int qm_cq_ctx_cfg(struct hisi_qp *qp, int qp_id, int pasid)
return ret;
}

-static int qm_qp_ctx_cfg(struct hisi_qp *qp, int qp_id, int pasid)
+static int qm_qp_ctx_cfg(struct hisi_qp *qp, int qp_id, u32 pasid)
{
int ret;

@@ -2550,14 +2549,10 @@ static int qm_eq_ctx_cfg(struct hisi_qm *qm)
{
struct device *dev = &qm->pdev->dev;
struct qm_eqc *eqc;
- struct qm_aeqc *aeqc;
dma_addr_t eqc_dma;
- dma_addr_t aeqc_dma;
int ret;

- qm_init_eq_aeq_status(qm);
-
- eqc = kzalloc(sizeof(struct qm_eqc), GFP_KERNEL);
+ eqc = kzalloc(sizeof(struct qm_eqc), GFP_KERNEL); //todo
if (!eqc)
return -ENOMEM;
eqc_dma = dma_map_single(dev, eqc, sizeof(struct qm_eqc),
@@ -2572,11 +2567,20 @@ static int qm_eq_ctx_cfg(struct hisi_qm *qm)
if (qm->ver == QM_HW_V1)
eqc->dw3 = cpu_to_le32(QM_EQE_AEQE_SIZE);
eqc->dw6 = cpu_to_le32((QM_EQ_DEPTH - 1) | (1 << QM_EQC_PHASE_SHIFT));
+
ret = qm_mb(qm, QM_MB_CMD_EQC, eqc_dma, 0, 0);
dma_unmap_single(dev, eqc_dma, sizeof(struct qm_eqc), DMA_TO_DEVICE);
kfree(eqc);
- if (ret)
- return ret;
+
+ return ret;
+}
+
+static int qm_aeq_ctx_cfg(struct hisi_qm *qm)
+{
+ struct device *dev = &qm->pdev->dev;
+ struct qm_aeqc *aeqc;
+ dma_addr_t aeqc_dma;
+ int ret;

aeqc = kzalloc(sizeof(struct qm_aeqc), GFP_KERNEL);
if (!aeqc)
@@ -2599,6 +2603,22 @@ static int qm_eq_ctx_cfg(struct hisi_qm *qm)
return ret;
}

+static int qm_eq_aeq_ctx_cfg(struct hisi_qm *qm)
+{
+ struct device *dev = &qm->pdev->dev;
+ int ret;
+
+ qm_init_eq_aeq_status(qm);
+
+ ret = qm_eq_ctx_cfg(qm);
+ if (ret) {
+ dev_err(dev, "Set eqc failed!\n");
+ return ret;
+ }
+
+ return qm_aeq_ctx_cfg(qm);
+}
+
static int __hisi_qm_start(struct hisi_qm *qm)
{
int ret;
@@ -2615,7 +2635,7 @@ static int __hisi_qm_start(struct hisi_qm *qm)
return ret;
}

- ret = qm_eq_ctx_cfg(qm);
+ ret = qm_eq_aeq_ctx_cfg(qm);
if (ret)
return ret;

--
2.8.1

2020-10-31 09:12:11

by Weili Qian

[permalink] [raw]
Subject: [PATCH 4/8] crypto: hisilicon/qm - modify return type of 'qm_set_sqctype'

Since 'qm_set_sqctype' always returns 0, change it as 'void'.

Signed-off-by: Weili Qian <[email protected]>
Reviewed-by: Zhou Wang <[email protected]>
---
drivers/crypto/hisilicon/qm.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c
index 627479f..17f84db 100644
--- a/drivers/crypto/hisilicon/qm.c
+++ b/drivers/crypto/hisilicon/qm.c
@@ -2118,7 +2118,7 @@ static void hisi_qm_uacce_stop_queue(struct uacce_queue *q)
hisi_qm_stop_qp(q->priv);
}

-static int qm_set_sqctype(struct uacce_queue *q, u16 type)
+static void qm_set_sqctype(struct uacce_queue *q, u16 type)
{
struct hisi_qm *qm = q->uacce->priv;
struct hisi_qp *qp = q->priv;
@@ -2126,8 +2126,6 @@ static int qm_set_sqctype(struct uacce_queue *q, u16 type)
down_write(&qm->qps_lock);
qp->alg_type = type;
up_write(&qm->qps_lock);
-
- return 0;
}

static long hisi_qm_uacce_ioctl(struct uacce_queue *q, unsigned int cmd,
--
2.8.1

2020-11-06 07:04:13

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH 0/8] crypto: hisilicon/qm - misc clean up

On Sat, Oct 31, 2020 at 05:07:00PM +0800, Weili Qian wrote:
> This patchset makes some clean up, please see comments in each patch.
>
> Weili Qian (8):
> crypto: hisilicon/qm - numbers are replaced by macros
> crypto: hisilicon/qm - modify the return type of function
> crypto: hisilicon/qm - modify the return type of debugfs interface
> crypto: hisilicon/qm - modify return type of 'qm_set_sqctype'
> crypto: hisilicon/qm - replace 'sprintf' with 'scnprintf'
> crypto: hisilicon/qm - split 'qm_qp_ctx_cfg' into smaller pieces
> crypto: hisilicon/qm - split 'qm_eq_ctx_cfg' into smaller pieces
> crypto: hisilicon/qm - split 'hisi_qm_init' into smaller pieces
>
> drivers/crypto/hisilicon/hpre/hpre_main.c | 4 +-
> drivers/crypto/hisilicon/qm.c | 207 +++++++++++++++++++-----------
> drivers/crypto/hisilicon/qm.h | 2 +-
> drivers/crypto/hisilicon/sec2/sec_main.c | 4 +-
> drivers/crypto/hisilicon/zip/zip_main.c | 4 +-
> 5 files changed, 134 insertions(+), 87 deletions(-)

All applied. Thanks.
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt