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 <qianweili@huawei.com> Reviewed-by: Zhou Wang <wangzhou1@hisilicon.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
Родитель
3bf1ef9d51
Коммит
53737881da
|
@ -1735,7 +1735,7 @@ void hisi_qm_release_qp(struct hisi_qp *qp)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(hisi_qm_release_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 hisi_qm *qm = qp->qm;
|
||||||
struct device *dev = &qm->pdev->dev;
|
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;
|
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 hisi_qm *qm = qp->qm;
|
||||||
struct device *dev = &qm->pdev->dev;
|
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);
|
cqc = kzalloc(sizeof(struct qm_cqc), GFP_KERNEL);
|
||||||
if (!cqc)
|
if (!cqc)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
cqc_dma = dma_map_single(dev, cqc, sizeof(struct qm_cqc),
|
cqc_dma = dma_map_single(dev, cqc, sizeof(struct qm_cqc),
|
||||||
DMA_TO_DEVICE);
|
DMA_TO_DEVICE);
|
||||||
if (dma_mapping_error(dev, cqc_dma)) {
|
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;
|
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;
|
int ret;
|
||||||
|
|
||||||
|
@ -2550,14 +2549,10 @@ static int qm_eq_ctx_cfg(struct hisi_qm *qm)
|
||||||
{
|
{
|
||||||
struct device *dev = &qm->pdev->dev;
|
struct device *dev = &qm->pdev->dev;
|
||||||
struct qm_eqc *eqc;
|
struct qm_eqc *eqc;
|
||||||
struct qm_aeqc *aeqc;
|
|
||||||
dma_addr_t eqc_dma;
|
dma_addr_t eqc_dma;
|
||||||
dma_addr_t aeqc_dma;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
qm_init_eq_aeq_status(qm);
|
eqc = kzalloc(sizeof(struct qm_eqc), GFP_KERNEL); //todo
|
||||||
|
|
||||||
eqc = kzalloc(sizeof(struct qm_eqc), GFP_KERNEL);
|
|
||||||
if (!eqc)
|
if (!eqc)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
eqc_dma = dma_map_single(dev, eqc, sizeof(struct qm_eqc),
|
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)
|
if (qm->ver == QM_HW_V1)
|
||||||
eqc->dw3 = cpu_to_le32(QM_EQE_AEQE_SIZE);
|
eqc->dw3 = cpu_to_le32(QM_EQE_AEQE_SIZE);
|
||||||
eqc->dw6 = cpu_to_le32((QM_EQ_DEPTH - 1) | (1 << QM_EQC_PHASE_SHIFT));
|
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);
|
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);
|
dma_unmap_single(dev, eqc_dma, sizeof(struct qm_eqc), DMA_TO_DEVICE);
|
||||||
kfree(eqc);
|
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);
|
aeqc = kzalloc(sizeof(struct qm_aeqc), GFP_KERNEL);
|
||||||
if (!aeqc)
|
if (!aeqc)
|
||||||
|
@ -2599,6 +2603,22 @@ static int qm_eq_ctx_cfg(struct hisi_qm *qm)
|
||||||
return ret;
|
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)
|
static int __hisi_qm_start(struct hisi_qm *qm)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -2615,7 +2635,7 @@ static int __hisi_qm_start(struct hisi_qm *qm)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = qm_eq_ctx_cfg(qm);
|
ret = qm_eq_aeq_ctx_cfg(qm);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче