Skip to content

drivers: implement HiSilicon Queue Management (QM) module - #6368

Merged
jforissier merged 1 commit into
OP-TEE:masterfrom
xiaoxuZeng:master
Nov 23, 2023
Merged

drivers: implement HiSilicon Queue Management (QM) module#6368
jforissier merged 1 commit into
OP-TEE:masterfrom
xiaoxuZeng:master

Conversation

@xiaoxuZeng

Copy link
Copy Markdown
Contributor

The Hisilicon QM is a Queue Management module.
In order to unify the interface between accelerator and software, a unified queue management module QM is used to interact with software. Each accelerator module integrates a QM. Software issues tasks to the SQ (Submmision Queue),and the QM obtains the address of the SQE (Submmision Queue Element). The BD (Buffer Description, same as SQE) information is sent to the accelerator. After the task processing is complete, the accelerator applies for a write-back address from the QM to write back the SQ.

@xiaoxuZeng

Copy link
Copy Markdown
Contributor Author

This patch is based on the following 2 PRs:
#6297
#6212

We warmly welcome your comments,thanks.

@etienne-lms etienne-lms left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 main comments to be addressed. Otherwise the implementation LGTM.
@xiaoxuZeng, maybe some comments apply to hisi_qm part1 P-R.

Comment thread core/drivers/crypto/hisilicon/include/hisi_qm.h Outdated
Comment thread core/drivers/crypto/hisilicon/hisi_qm.c Outdated
Comment thread core/drivers/crypto/hisilicon/hisi_qm.c
Comment thread core/drivers/crypto/hisilicon/hisi_qm.c Outdated
Comment thread core/drivers/crypto/hisilicon/hisi_qm.c Outdated
Comment thread core/drivers/crypto/hisilicon/include/hisi_qm.h Outdated
@xiaoxuZeng
xiaoxuZeng force-pushed the master branch 2 times, most recently from a707419 to cd21284 Compare October 16, 2023 08:18
@ZijjWang

ZijjWang commented Oct 17, 2023

Copy link
Copy Markdown

LGTM

review_by: wangzijian <wangzijian22@huawei.com>

@etienne-lms etienne-lms left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few remaining nitpicking comments and question around allocated memory: should it be zeored before it's used?

Comment thread core/drivers/crypto/hisilicon/hisi_qm.c Outdated
Comment thread core/drivers/crypto/hisilicon/hisi_qm.c Outdated
Comment thread core/drivers/crypto/hisilicon/hisi_qm.c Outdated
Comment thread core/drivers/crypto/hisilicon/hisi_qm.c Outdated
Comment thread core/drivers/crypto/hisilicon/hisi_qm.c Outdated
Comment thread core/drivers/crypto/hisilicon/hisi_qm.c Outdated
Comment thread core/drivers/crypto/hisilicon/hisi_qm.c Outdated
Comment thread core/drivers/crypto/hisilicon/hisi_qm.c
Comment thread core/drivers/crypto/hisilicon/hisi_qm.c
Comment thread core/drivers/crypto/hisilicon/hisi_qm.c Outdated

@etienne-lms etienne-lms left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @xiaoxuZeng, I think you made too many changes in this last series. It seems all uint32_t have changed into unsigned int despite most of them are expected to be 32bit values used with io_read32()/write32(). I've started to puts some comments but there are too many occurrences. Could you come back to the series previous version and change s/uint32_t/unsigned int/ only for the few function local variables used as index in for or like loops?

Comment thread core/drivers/crypto/hisilicon/hisi_qm.c
Comment thread core/drivers/crypto/hisilicon/hisi_qm.c Outdated
Comment thread core/drivers/crypto/hisilicon/hisi_qm.c Outdated
@xiaoxuZeng
xiaoxuZeng force-pushed the master branch 3 times, most recently from 877a2ae to 8761fa9 Compare October 25, 2023 03:47

@etienne-lms etienne-lms left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks consistent to me.
Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>

Comment thread core/arch/arm/plat-d06/conf.mk
@xiaoxuZeng

Copy link
Copy Markdown
Contributor Author

Hi @jforissier

Please review this patch when you are convenience. We look forward to your guidance.

Thanks.

@jforissier jforissier left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @xiaoxuZeng, please see my comments below. Overall this looks good to me.
Please replace the commit subject " The Hisilicon QM is a Queue Management module." with "drivers: implement HiSilicon Queue Management (QM) module".

Acked-by: Jerome Forissier <jerome.forissier@linaro.org>

Comment thread core/drivers/crypto/hisilicon/hisi_qm.c Outdated
}
}

if (qm->qp_num == 0 || qm->sqe_size == 0) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer if (!qm->qp_num || !qm->sqe_size) {

Comment thread core/drivers/crypto/hisilicon/hisi_qm.c Outdated
}

if (qm->qp_num == 0 || qm->sqe_size == 0) {
EMSG("Invalid qm parameters");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer uppercase QM: Invalid QM parameters

Comment thread core/drivers/crypto/hisilicon/hisi_qm.c Outdated
for (i = QM_SQC_VFT; i <= QM_CQC_VFT; i++) {
ret = qm_set_vft_common(qm, i, function, base, num);
if (ret) {
EMSG("QM set type%d fail", i);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space: type %d

Comment on lines +284 to +285
*base = (sqc_vft >> QM_SQC_VFT_START_SQN_SHIFT) & QM_SQC_VFT_BASE_MASK;
*num = ((sqc_vft >> QM_SQC_VFT_SQ_NUM_SHIFT) & QM_SQC_VFT_NUM_MASK) + 1;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jenswi-linaro should we define SHIFTR_U64() for such right-shift operations? Or are they safe to do like this?

Comment thread core/drivers/crypto/hisilicon/hisi_qm.c Outdated
free(qp->cqe);
}

static enum hisi_drv_status qp_memory_init(struct hisi_qm *qm, uint32_t id)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest s/qp_memory_init/qp_alloc/ and s/qp_memory_uninit/qp_free/ because the names are simpler and better reflect the fact that you are indeed allocating/freeing from the heap, not just initializing/clearing some data.

Comment thread core/drivers/crypto/hisilicon/hisi_qm.c Outdated
free(qm->cqc);
}

static enum hisi_drv_status qm_memory_init(struct hisi_qm *qm)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same suggestion here: qm_alloc() and qm_free().

Comment thread core/drivers/crypto/hisilicon/hisi_qm.c Outdated
{
uint32_t val = 0;

/* return 0 mailbox ready, HISI_QM_DRVCRYPT_ETMOUT hardware timeout */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to start comments with an uppercase letter: /* Return 0... */

@jforissier

Copy link
Copy Markdown
Contributor

Please also rebase on master to fix the IBART CI error. Thanks!

@xiaoxuZeng

Copy link
Copy Markdown
Contributor Author

Please also rebase on master to fix the IBART CI error. Thanks!

Thank you for your guidance, and we will complete the remaining issues in the near future.

@xiaoxuZeng xiaoxuZeng closed this Nov 21, 2023
@xiaoxuZeng xiaoxuZeng reopened this Nov 22, 2023
@xiaoxuZeng xiaoxuZeng changed the title drivers: crypto: hisilicon: implement QM driver drivers: implement HiSilicon Queue Management (QM) module Nov 22, 2023
@xiaoxuZeng
xiaoxuZeng force-pushed the master branch 2 times, most recently from 98d1747 to 79e5acd Compare November 22, 2023 06:52
Comment thread core/arch/arm/plat-d06/conf.mk
Comment thread core/drivers/crypto/hisilicon/hisi_qm.c Outdated
{ .reg_name = "QM_DFX_WB_SQE_FROM_ACC_CNT", .reg_offset = 0x104058 },
{ .reg_name = "QM_DFX_ACC_FINISH_CNT ", .reg_offset = 0x104060 },
{ .reg_name = "QM_DFX_CQE_ERR_CNT ", .reg_offset = 0x1040b4 },
{ .reg_name = NULL, 0 }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/{ .reg_name = NULL, 0 }/{ }/

/**
* @Description: Init QM for Kunpeng drv
* @param qm: Handle of Queue Management module
* @return success: 0,fail: HISI_QM_DRVCRYPT_EBUSY/HISI_QM_DRVCRYPT_EINVAL

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/0/HISI_QM_DRVCRYPT_NO_ERR/ ?
Dittto at 248 and 256

The Hisilicon QM is a Queue Management module.
In order to unify the interface between accelerator and software,
a unified queue management module QM is used to interact with software.
Each accelerator module integrates a QM. Software issues tasks to the SQ
(Submmision Queue),and the QM obtains the address of the SQE (Submmision
Queue Element). The BD (Buffer Description, same as SQE) information is
sent to the accelerator. After the task processing is complete, the
accelerator applies for a write-back address from the QM to write back
the SQ.

Signed-off-by: Xiaoxu Zeng <zengxiaoxu@huawei.com>
Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
@jforissier

Copy link
Copy Markdown
Contributor

@xiaoxuZeng thanks, I am merging this now (the CI error is unrelated and will go away when the code is rebased to include #6484).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants