mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-23 05:56:14 -04:00
crypto: hisilicon/qm - support address prefetching
Kunpeng930 hardware supports address prefetching to improve performance before doing tasks in SVA scenario. This patch enables this function in device initialization by writing hardware registers. In the process of reset, address prefetching is disabled to avoid the failure of interaction between accelerator device and SMMU. Signed-off-by: Longfang Liu <liulongfang@huawei.com> Signed-off-by: Weili Qian <qianweili@huawei.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
@@ -85,6 +85,12 @@
|
||||
#define SEC_USER1_SMMU_MASK (~SEC_USER1_SVA_SET)
|
||||
#define SEC_CORE_INT_STATUS_M_ECC BIT(2)
|
||||
|
||||
#define SEC_PREFETCH_CFG 0x301130
|
||||
#define SEC_SVA_TRANS 0x301EC4
|
||||
#define SEC_PREFETCH_ENABLE (~(BIT(0) | BIT(1) | BIT(11)))
|
||||
#define SEC_PREFETCH_DISABLE BIT(1)
|
||||
#define SEC_SVA_DISABLE_READY (BIT(7) | BIT(11))
|
||||
|
||||
#define SEC_DELAY_10_US 10
|
||||
#define SEC_POLL_TIMEOUT_US 1000
|
||||
#define SEC_DBGFS_VAL_MAX_LEN 20
|
||||
@@ -332,6 +338,42 @@ static u8 sec_get_endian(struct hisi_qm *qm)
|
||||
return SEC_64BE;
|
||||
}
|
||||
|
||||
static void sec_open_sva_prefetch(struct hisi_qm *qm)
|
||||
{
|
||||
u32 val;
|
||||
int ret;
|
||||
|
||||
if (qm->ver < QM_HW_V3)
|
||||
return;
|
||||
|
||||
/* Enable prefetch */
|
||||
val = readl_relaxed(qm->io_base + SEC_PREFETCH_CFG);
|
||||
val &= SEC_PREFETCH_ENABLE;
|
||||
writel(val, qm->io_base + SEC_PREFETCH_CFG);
|
||||
|
||||
ret = readl_relaxed_poll_timeout(qm->io_base + SEC_PREFETCH_CFG,
|
||||
val, !(val & SEC_PREFETCH_DISABLE),
|
||||
SEC_DELAY_10_US, SEC_POLL_TIMEOUT_US);
|
||||
if (ret)
|
||||
pci_err(qm->pdev, "failed to open sva prefetch\n");
|
||||
}
|
||||
|
||||
static void sec_close_sva_prefetch(struct hisi_qm *qm)
|
||||
{
|
||||
u32 val;
|
||||
int ret;
|
||||
|
||||
val = readl_relaxed(qm->io_base + SEC_PREFETCH_CFG);
|
||||
val |= SEC_PREFETCH_DISABLE;
|
||||
writel(val, qm->io_base + SEC_PREFETCH_CFG);
|
||||
|
||||
ret = readl_relaxed_poll_timeout(qm->io_base + SEC_SVA_TRANS,
|
||||
val, !(val & SEC_SVA_DISABLE_READY),
|
||||
SEC_DELAY_10_US, SEC_POLL_TIMEOUT_US);
|
||||
if (ret)
|
||||
pci_err(qm->pdev, "failed to close sva prefetch\n");
|
||||
}
|
||||
|
||||
static int sec_engine_init(struct hisi_qm *qm)
|
||||
{
|
||||
int ret;
|
||||
@@ -751,6 +793,8 @@ static const struct hisi_qm_err_ini sec_err_ini = {
|
||||
.clear_dev_hw_err_status = sec_clear_hw_err_status,
|
||||
.log_dev_hw_err = sec_log_hw_error,
|
||||
.open_axi_master_ooo = sec_open_axi_master_ooo,
|
||||
.open_sva_prefetch = sec_open_sva_prefetch,
|
||||
.close_sva_prefetch = sec_close_sva_prefetch,
|
||||
.err_info_init = sec_err_info_init,
|
||||
};
|
||||
|
||||
@@ -766,6 +810,7 @@ static int sec_pf_probe_init(struct sec_dev *sec)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
sec_open_sva_prefetch(qm);
|
||||
hisi_qm_dev_err_init(qm);
|
||||
sec_debug_regs_clear(qm);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user