From nobody Sat Oct 4 03:18:50 2025 Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96DCA242D62; Thu, 21 Aug 2025 01:38:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755740302; cv=none; b=kRDxaAWttoMH7xIvgzfyTEVvwsuIWTaTdJtxkuyFTU2pzmQk5z8synroGPS084X5qE3vGQjXjVAAr3L2FezeNXVaR+cY6lLCJFLlvrt+RLM//5nWf6orTxggq6HVjdqQde7EzRoBTV6iFyqi9HvXW47ofPeUqwnNDn6CY+Jz8oI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755740302; c=relaxed/simple; bh=A8tlPZwwTYm1xICAETpYUMgRf2FY/fHYiez3h9vnYr0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HTxbnqSLwfwRQSlN+xp0dGOxOXC6mYtW4aTJ2rhNTAayaepKDJICKZUv7Fh4d8pMauX1xRAtMA8esTrok0h/f53F8ZBcKQj2tyBhd4sPuP8q0q5oCiZCGBEuIzfwPWOXana4CoCGyQo2IG8wamrUSBt4oJ7JHsiP9nPopp/K5YQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4c6mFc37Hjz27jSD; Thu, 21 Aug 2025 09:39:16 +0800 (CST) Received: from dggemv705-chm.china.huawei.com (unknown [10.3.19.32]) by mail.maildlp.com (Postfix) with ESMTPS id 038FB1A0190; Thu, 21 Aug 2025 09:38:11 +0800 (CST) Received: from kwepemq200001.china.huawei.com (7.202.195.16) by dggemv705-chm.china.huawei.com (10.3.19.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 21 Aug 2025 09:38:10 +0800 Received: from localhost.huawei.com (10.90.31.46) by kwepemq200001.china.huawei.com (7.202.195.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 21 Aug 2025 09:38:09 +0800 From: Chenghai Huang To: , CC: , , , , , , , Subject: [PATCH v2 1/6] crypto: hisilicon/zip - remove unnecessary validation for high-performance mode configurations Date: Thu, 21 Aug 2025 09:38:04 +0800 Message-ID: <20250821013809.4016506-2-huangchenghai2@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20250821013809.4016506-1-huangchenghai2@huawei.com> References: <20250821013809.4016506-1-huangchenghai2@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To kwepemq200001.china.huawei.com (7.202.195.16) Content-Type: text/plain; charset="utf-8" When configuring the high-performance mode register, there is no need to verify whether the register has been successfully enabled, as there is no possibility of a write failure for this register. Fixes: a9864bae1806 ("crypto: hisilicon/zip - add zip comp high perf mode c= onfiguration") Signed-off-by: Chenghai Huang --- drivers/crypto/hisilicon/zip/zip_main.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/crypto/hisilicon/zip/zip_main.c b/drivers/crypto/hisil= icon/zip/zip_main.c index d8ba23b7cc7d..fb7b19927dd3 100644 --- a/drivers/crypto/hisilicon/zip/zip_main.c +++ b/drivers/crypto/hisilicon/zip/zip_main.c @@ -448,10 +448,9 @@ bool hisi_zip_alg_support(struct hisi_qm *qm, u32 alg) return false; } =20 -static int hisi_zip_set_high_perf(struct hisi_qm *qm) +static void hisi_zip_set_high_perf(struct hisi_qm *qm) { u32 val; - int ret; =20 val =3D readl_relaxed(qm->io_base + HZIP_HIGH_PERF_OFFSET); if (perf_mode =3D=3D HZIP_HIGH_COMP_PERF) @@ -461,13 +460,6 @@ static int hisi_zip_set_high_perf(struct hisi_qm *qm) =20 /* Set perf mode */ writel(val, qm->io_base + HZIP_HIGH_PERF_OFFSET); - ret =3D readl_relaxed_poll_timeout(qm->io_base + HZIP_HIGH_PERF_OFFSET, - val, val =3D=3D perf_mode, HZIP_DELAY_1_US, - HZIP_POLL_TIMEOUT_US); - if (ret) - pci_err(qm->pdev, "failed to set perf mode\n"); - - return ret; } =20 static void hisi_zip_open_sva_prefetch(struct hisi_qm *qm) @@ -1251,9 +1243,7 @@ static int hisi_zip_pf_probe_init(struct hisi_zip *hi= si_zip) if (ret) return ret; =20 - ret =3D hisi_zip_set_high_perf(qm); - if (ret) - return ret; + hisi_zip_set_high_perf(qm); =20 hisi_zip_open_sva_prefetch(qm); hisi_qm_dev_err_init(qm); --=20 2.33.0 From nobody Sat Oct 4 03:18:50 2025 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE7CD2417E0; Thu, 21 Aug 2025 01:38:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755740297; cv=none; b=ojeJGMhHcZtuUrL5o4kiiEVMejKJTvv+rY0Ke9efTCIQWDal0LI8/FvBuOCQ1dOmnV06/jxeUm1rKaHR+Er4XRd4m4+ukDnC3vb/sesLzJoy4vwbQ8zPEzpnNfkDgrlRUO1jZEznxaA+jk/6/SYxl+k8KJJ7jvLOkJUr4NFAMDc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755740297; c=relaxed/simple; bh=MlHqMVnU07GH6ssx63UQwR8prdxAqb6ytrZHvNp0N2s=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MzXr8T2YiERTK9eGHWkqun3yl7Mre3aGCKD8UnioNTVtrvF5nVkJOWRZmppNViVE4BrVoQmaeH6ueoio4EhjHbMJEo3ph3wnYXmmTj8UHjZLlzfI8z3/nhxrbYWk7IUeN+FGAGyAmaSBq0/3APnGuIaAMwI4wWxj9UEFPYpCwR8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4c6m915pzCz2gLGY; Thu, 21 Aug 2025 09:35:17 +0800 (CST) Received: from dggemv705-chm.china.huawei.com (unknown [10.3.19.32]) by mail.maildlp.com (Postfix) with ESMTPS id 3B163140148; Thu, 21 Aug 2025 09:38:11 +0800 (CST) Received: from kwepemq200001.china.huawei.com (7.202.195.16) by dggemv705-chm.china.huawei.com (10.3.19.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 21 Aug 2025 09:38:10 +0800 Received: from localhost.huawei.com (10.90.31.46) by kwepemq200001.china.huawei.com (7.202.195.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 21 Aug 2025 09:38:10 +0800 From: Chenghai Huang To: , CC: , , , , , , , Subject: [PATCH v2 2/6] crypto: hisilicon - re-enable address prefetch after device resuming Date: Thu, 21 Aug 2025 09:38:05 +0800 Message-ID: <20250821013809.4016506-3-huangchenghai2@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20250821013809.4016506-1-huangchenghai2@huawei.com> References: <20250821013809.4016506-1-huangchenghai2@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To kwepemq200001.china.huawei.com (7.202.195.16) Content-Type: text/plain; charset="utf-8" When the device resumes from a suspended state, it will revert to its initial state and requires re-enabling. Currently, the address prefetch function is not re-enabled after device resuming. Move the address prefetch enable to the initialization process. In this way, the address prefetch can be enabled when the device resumes by calling the initialization process. Fixes: 607c191b371d ("crypto: hisilicon - support runtime PM for accelerato= r device") Signed-off-by: Chenghai Huang --- drivers/crypto/hisilicon/hpre/hpre_main.c | 3 +- drivers/crypto/hisilicon/qm.c | 3 - drivers/crypto/hisilicon/sec2/sec_main.c | 80 +++++++++++------------ drivers/crypto/hisilicon/zip/zip_main.c | 5 +- 4 files changed, 43 insertions(+), 48 deletions(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/his= ilicon/hpre/hpre_main.c index f5b47e5ff48a..34f84978180f 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_main.c +++ b/drivers/crypto/hisilicon/hpre/hpre_main.c @@ -721,6 +721,7 @@ static int hpre_set_user_domain_and_cache(struct hisi_q= m *qm) =20 /* Config data buffer pasid needed by Kunpeng 920 */ hpre_config_pasid(qm); + hpre_open_sva_prefetch(qm); =20 hpre_enable_clock_gate(qm); =20 @@ -1450,8 +1451,6 @@ static int hpre_pf_probe_init(struct hpre *hpre) if (ret) return ret; =20 - hpre_open_sva_prefetch(qm); - hisi_qm_dev_err_init(qm); ret =3D hpre_show_last_regs_init(qm); if (ret) diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index 8d45febb98dd..9bbbfff759a9 100644 --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@ -4447,9 +4447,6 @@ static void qm_restart_prepare(struct hisi_qm *qm) { u32 value; =20 - if (qm->err_ini->open_sva_prefetch) - qm->err_ini->open_sva_prefetch(qm); - if (qm->ver >=3D QM_HW_V3) return; =20 diff --git a/drivers/crypto/hisilicon/sec2/sec_main.c b/drivers/crypto/hisi= licon/sec2/sec_main.c index 72cf48d1f3ab..ddb20f380b54 100644 --- a/drivers/crypto/hisilicon/sec2/sec_main.c +++ b/drivers/crypto/hisilicon/sec2/sec_main.c @@ -464,6 +464,45 @@ static void sec_set_endian(struct hisi_qm *qm) writel_relaxed(reg, qm->io_base + SEC_CONTROL_REG); } =20 +static void sec_close_sva_prefetch(struct hisi_qm *qm) +{ + u32 val; + int ret; + + if (!test_bit(QM_SUPPORT_SVA_PREFETCH, &qm->caps)) + return; + + val =3D readl_relaxed(qm->io_base + SEC_PREFETCH_CFG); + val |=3D SEC_PREFETCH_DISABLE; + writel(val, qm->io_base + SEC_PREFETCH_CFG); + + ret =3D 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 void sec_open_sva_prefetch(struct hisi_qm *qm) +{ + u32 val; + int ret; + + if (!test_bit(QM_SUPPORT_SVA_PREFETCH, &qm->caps)) + return; + + /* Enable prefetch */ + val =3D readl_relaxed(qm->io_base + SEC_PREFETCH_CFG); + val &=3D SEC_PREFETCH_ENABLE; + writel(val, qm->io_base + SEC_PREFETCH_CFG); + + ret =3D 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_engine_sva_config(struct hisi_qm *qm) { u32 reg; @@ -497,45 +536,7 @@ static void sec_engine_sva_config(struct hisi_qm *qm) writel_relaxed(reg, qm->io_base + SEC_INTERFACE_USER_CTRL1_REG); } -} - -static void sec_open_sva_prefetch(struct hisi_qm *qm) -{ - u32 val; - int ret; - - if (!test_bit(QM_SUPPORT_SVA_PREFETCH, &qm->caps)) - return; - - /* Enable prefetch */ - val =3D readl_relaxed(qm->io_base + SEC_PREFETCH_CFG); - val &=3D SEC_PREFETCH_ENABLE; - writel(val, qm->io_base + SEC_PREFETCH_CFG); - - ret =3D 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; - - if (!test_bit(QM_SUPPORT_SVA_PREFETCH, &qm->caps)) - return; - - val =3D readl_relaxed(qm->io_base + SEC_PREFETCH_CFG); - val |=3D SEC_PREFETCH_DISABLE; - writel(val, qm->io_base + SEC_PREFETCH_CFG); - - ret =3D 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"); + sec_open_sva_prefetch(qm); } =20 static void sec_enable_clock_gate(struct hisi_qm *qm) @@ -1152,7 +1153,6 @@ static int sec_pf_probe_init(struct sec_dev *sec) if (ret) return ret; =20 - sec_open_sva_prefetch(qm); hisi_qm_dev_err_init(qm); sec_debug_regs_clear(qm); ret =3D sec_show_last_regs_init(qm); diff --git a/drivers/crypto/hisilicon/zip/zip_main.c b/drivers/crypto/hisil= icon/zip/zip_main.c index fb7b19927dd3..480fa590664a 100644 --- a/drivers/crypto/hisilicon/zip/zip_main.c +++ b/drivers/crypto/hisilicon/zip/zip_main.c @@ -557,6 +557,7 @@ static int hisi_zip_set_user_domain_and_cache(struct hi= si_qm *qm) writel(AXUSER_BASE, base + HZIP_DATA_WUSER_32_63); writel(AXUSER_BASE, base + HZIP_SGL_RUSER_32_63); } + hisi_zip_open_sva_prefetch(qm); =20 /* let's open all compression/decompression cores */ =20 @@ -572,6 +573,7 @@ static int hisi_zip_set_user_domain_and_cache(struct hi= si_qm *qm) CQC_CACHE_WB_ENABLE | FIELD_PREP(SQC_CACHE_WB_THRD, 1) | FIELD_PREP(CQC_CACHE_WB_THRD, 1), base + QM_CACHE_CTL); =20 + hisi_zip_set_high_perf(qm); hisi_zip_enable_clock_gate(qm); =20 return hisi_dae_set_user_domain(qm); @@ -1243,9 +1245,6 @@ static int hisi_zip_pf_probe_init(struct hisi_zip *hi= si_zip) if (ret) return ret; =20 - hisi_zip_set_high_perf(qm); - - hisi_zip_open_sva_prefetch(qm); hisi_qm_dev_err_init(qm); hisi_zip_debug_regs_clear(qm); =20 --=20 2.33.0 From nobody Sat Oct 4 03:18:50 2025 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1BD26261574; Thu, 21 Aug 2025 01:38:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755740304; cv=none; b=L1NtrUbyjxlSc6z52FqQ6wWgEzfyob5bLi+aGn7wyg2yUmY6/KpqbnFNNcFLw5U2XCHLaZImDInqLQvc6voscuGAJ7CVQzKw4IHTVvzUA17WLaDsOMP2ofEboS0VrbcLCydC0Z8/j6bCczTYSL3DbygZAMRiXTzC4U31JdohU7I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755740304; c=relaxed/simple; bh=vSbxs4BqH5DRP182heMxDbAgc0iB7W+HGuO/sb1OSUI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XNkdEYsJAC+ILsVAkSlse2tUQUucbRbHVXzIwR8vpRWQSbO6pjHIV/tw3jYnGg6R4CEEeC5kWe8PBlHJ0i19MwzBNhigq+O92ChHrDX01leeZj7odyjJ7wj1Dq2J1+Me2am33utgUzcy6R2q+xQyKrWYZ8S1kuQfbZWOQqQgkN8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4c6m9F4l5Mz2TTQl; Thu, 21 Aug 2025 09:35:29 +0800 (CST) Received: from dggemv706-chm.china.huawei.com (unknown [10.3.19.33]) by mail.maildlp.com (Postfix) with ESMTPS id 9922F18005F; Thu, 21 Aug 2025 09:38:19 +0800 (CST) Received: from kwepemq200001.china.huawei.com (7.202.195.16) by dggemv706-chm.china.huawei.com (10.3.19.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 21 Aug 2025 09:38:11 +0800 Received: from localhost.huawei.com (10.90.31.46) by kwepemq200001.china.huawei.com (7.202.195.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 21 Aug 2025 09:38:10 +0800 From: Chenghai Huang To: , CC: , , , , , , , Subject: [PATCH v2 3/6] crypto: hisilicon - check the sva module status while enabling or disabling address prefetch Date: Thu, 21 Aug 2025 09:38:06 +0800 Message-ID: <20250821013809.4016506-4-huangchenghai2@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20250821013809.4016506-1-huangchenghai2@huawei.com> References: <20250821013809.4016506-1-huangchenghai2@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To kwepemq200001.china.huawei.com (7.202.195.16) Content-Type: text/plain; charset="utf-8" From: Weili Qian After enabling address prefetch, check the sva module status. If all previous prefetch requests from the sva module are not completed, then disable the address prefetch to ensure normal execution of new task operations. After disabling address prefetch, check if all requests from the sva module have been completed. Fixes: a5c164b195a8 ("crypto: hisilicon/qm - support address prefetching") Signed-off-by: Weili Qian Signed-off-by: Chenghai Huang --- drivers/crypto/hisilicon/hpre/hpre_main.c | 63 ++++++++++++++---- drivers/crypto/hisilicon/sec2/sec_main.c | 48 +++++++++++++- drivers/crypto/hisilicon/zip/zip_main.c | 79 +++++++++++++++++++---- 3 files changed, 164 insertions(+), 26 deletions(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/his= ilicon/hpre/hpre_main.c index 34f84978180f..7b60e89015bd 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_main.c +++ b/drivers/crypto/hisilicon/hpre/hpre_main.c @@ -78,6 +78,11 @@ #define HPRE_PREFETCH_ENABLE (~(BIT(0) | BIT(30))) #define HPRE_PREFETCH_DISABLE BIT(30) #define HPRE_SVA_DISABLE_READY (BIT(4) | BIT(8)) +#define HPRE_SVA_PREFTCH_DFX4 0x301144 +#define HPRE_WAIT_SVA_READY 500000 +#define HPRE_READ_SVA_STATUS_TIMES 3 +#define HPRE_WAIT_US_MIN 10 +#define HPRE_WAIT_US_MAX 20 =20 /* clock gate */ #define HPRE_CLKGATE_CTL 0x301a10 @@ -466,6 +471,33 @@ struct hisi_qp *hpre_create_qp(u8 type) return NULL; } =20 +static int hpre_wait_sva_ready(struct hisi_qm *qm) +{ + u32 val, try_times =3D 0; + u8 count =3D 0; + + /* + * Read the register value every 10-20us. If the value is 0 for three + * consecutive times, the SVA module is ready. + */ + do { + val =3D readl(qm->io_base + HPRE_SVA_PREFTCH_DFX4); + if (val) + count =3D 0; + else if (++count =3D=3D HPRE_READ_SVA_STATUS_TIMES) + break; + + usleep_range(HPRE_WAIT_US_MIN, HPRE_WAIT_US_MAX); + } while (++try_times < HPRE_WAIT_SVA_READY); + + if (try_times =3D=3D HPRE_WAIT_SVA_READY) { + pci_err(qm->pdev, "failed to wait sva prefetch ready\n"); + return -ETIMEDOUT; + } + + return 0; +} + static void hpre_config_pasid(struct hisi_qm *qm) { u32 val1, val2; @@ -563,7 +595,7 @@ static void disable_flr_of_bme(struct hisi_qm *qm) writel(PEH_AXUSER_CFG_ENABLE, qm->io_base + QM_PEH_AXUSER_CFG_ENABLE); } =20 -static void hpre_open_sva_prefetch(struct hisi_qm *qm) +static void hpre_close_sva_prefetch(struct hisi_qm *qm) { u32 val; int ret; @@ -571,20 +603,21 @@ static void hpre_open_sva_prefetch(struct hisi_qm *qm) if (!test_bit(QM_SUPPORT_SVA_PREFETCH, &qm->caps)) return; =20 - /* Enable prefetch */ val =3D readl_relaxed(qm->io_base + HPRE_PREFETCH_CFG); - val &=3D HPRE_PREFETCH_ENABLE; + val |=3D HPRE_PREFETCH_DISABLE; writel(val, qm->io_base + HPRE_PREFETCH_CFG); =20 - ret =3D readl_relaxed_poll_timeout(qm->io_base + HPRE_PREFETCH_CFG, - val, !(val & HPRE_PREFETCH_DISABLE), + ret =3D readl_relaxed_poll_timeout(qm->io_base + HPRE_SVA_PREFTCH_DFX, + val, !(val & HPRE_SVA_DISABLE_READY), HPRE_REG_RD_INTVRL_US, HPRE_REG_RD_TMOUT_US); if (ret) - pci_err(qm->pdev, "failed to open sva prefetch\n"); + pci_err(qm->pdev, "failed to close sva prefetch\n"); + + (void)hpre_wait_sva_ready(qm); } =20 -static void hpre_close_sva_prefetch(struct hisi_qm *qm) +static void hpre_open_sva_prefetch(struct hisi_qm *qm) { u32 val; int ret; @@ -592,16 +625,24 @@ static void hpre_close_sva_prefetch(struct hisi_qm *q= m) if (!test_bit(QM_SUPPORT_SVA_PREFETCH, &qm->caps)) return; =20 + /* Enable prefetch */ val =3D readl_relaxed(qm->io_base + HPRE_PREFETCH_CFG); - val |=3D HPRE_PREFETCH_DISABLE; + val &=3D HPRE_PREFETCH_ENABLE; writel(val, qm->io_base + HPRE_PREFETCH_CFG); =20 - ret =3D readl_relaxed_poll_timeout(qm->io_base + HPRE_SVA_PREFTCH_DFX, - val, !(val & HPRE_SVA_DISABLE_READY), + ret =3D readl_relaxed_poll_timeout(qm->io_base + HPRE_PREFETCH_CFG, + val, !(val & HPRE_PREFETCH_DISABLE), HPRE_REG_RD_INTVRL_US, HPRE_REG_RD_TMOUT_US); + if (ret) { + pci_err(qm->pdev, "failed to open sva prefetch\n"); + hpre_close_sva_prefetch(qm); + return; + } + + ret =3D hpre_wait_sva_ready(qm); if (ret) - pci_err(qm->pdev, "failed to close sva prefetch\n"); + hpre_close_sva_prefetch(qm); } =20 static void hpre_enable_clock_gate(struct hisi_qm *qm) diff --git a/drivers/crypto/hisilicon/sec2/sec_main.c b/drivers/crypto/hisi= licon/sec2/sec_main.c index ddb20f380b54..348f1f52956d 100644 --- a/drivers/crypto/hisilicon/sec2/sec_main.c +++ b/drivers/crypto/hisilicon/sec2/sec_main.c @@ -93,6 +93,16 @@ #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_SVA_PREFETCH_INFO 0x301ED4 +#define SEC_SVA_STALL_NUM GENMASK(23, 8) +#define SEC_SVA_PREFETCH_NUM GENMASK(2, 0) +#define SEC_WAIT_SVA_READY 500000 +#define SEC_READ_SVA_STATUS_TIMES 3 +#define SEC_WAIT_US_MIN 10 +#define SEC_WAIT_US_MAX 20 +#define SEC_WAIT_QP_US_MIN 1000 +#define SEC_WAIT_QP_US_MAX 2000 +#define SEC_MAX_WAIT_TIMES 2000 =20 #define SEC_DELAY_10_US 10 #define SEC_POLL_TIMEOUT_US 1000 @@ -464,6 +474,33 @@ static void sec_set_endian(struct hisi_qm *qm) writel_relaxed(reg, qm->io_base + SEC_CONTROL_REG); } =20 +static int sec_wait_sva_ready(struct hisi_qm *qm, __u32 offset, __u32 mask) +{ + u32 val, try_times =3D 0; + u8 count =3D 0; + + /* + * Read the register value every 10-20us. If the value is 0 for three + * consecutive times, the SVA module is ready. + */ + do { + val =3D readl(qm->io_base + offset); + if (val & mask) + count =3D 0; + else if (++count =3D=3D SEC_READ_SVA_STATUS_TIMES) + break; + + usleep_range(SEC_WAIT_US_MIN, SEC_WAIT_US_MAX); + } while (++try_times < SEC_WAIT_SVA_READY); + + if (try_times =3D=3D SEC_WAIT_SVA_READY) { + pci_err(qm->pdev, "failed to wait sva prefetch ready\n"); + return -ETIMEDOUT; + } + + return 0; +} + static void sec_close_sva_prefetch(struct hisi_qm *qm) { u32 val; @@ -481,6 +518,8 @@ static void sec_close_sva_prefetch(struct hisi_qm *qm) SEC_DELAY_10_US, SEC_POLL_TIMEOUT_US); if (ret) pci_err(qm->pdev, "failed to close sva prefetch\n"); + + (void)sec_wait_sva_ready(qm, SEC_SVA_PREFETCH_INFO, SEC_SVA_STALL_NUM); } =20 static void sec_open_sva_prefetch(struct hisi_qm *qm) @@ -499,8 +538,15 @@ static void sec_open_sva_prefetch(struct hisi_qm *qm) ret =3D 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) + if (ret) { pci_err(qm->pdev, "failed to open sva prefetch\n"); + sec_close_sva_prefetch(qm); + return; + } + + ret =3D sec_wait_sva_ready(qm, SEC_SVA_TRANS, SEC_SVA_PREFETCH_NUM); + if (ret) + sec_close_sva_prefetch(qm); } =20 static void sec_engine_sva_config(struct hisi_qm *qm) diff --git a/drivers/crypto/hisilicon/zip/zip_main.c b/drivers/crypto/hisil= icon/zip/zip_main.c index 480fa590664a..341c4564e21a 100644 --- a/drivers/crypto/hisilicon/zip/zip_main.c +++ b/drivers/crypto/hisilicon/zip/zip_main.c @@ -95,10 +95,16 @@ #define HZIP_PREFETCH_ENABLE (~(BIT(26) | BIT(17) | BIT(0))) #define HZIP_SVA_PREFETCH_DISABLE BIT(26) #define HZIP_SVA_DISABLE_READY (BIT(26) | BIT(30)) +#define HZIP_SVA_PREFETCH_NUM GENMASK(18, 16) +#define HZIP_SVA_STALL_NUM GENMASK(15, 0) #define HZIP_SHAPER_RATE_COMPRESS 750 #define HZIP_SHAPER_RATE_DECOMPRESS 140 -#define HZIP_DELAY_1_US 1 -#define HZIP_POLL_TIMEOUT_US 1000 +#define HZIP_DELAY_1_US 1 +#define HZIP_POLL_TIMEOUT_US 1000 +#define HZIP_WAIT_SVA_READY 500000 +#define HZIP_READ_SVA_STATUS_TIMES 3 +#define HZIP_WAIT_US_MIN 10 +#define HZIP_WAIT_US_MAX 20 =20 /* clock gating */ #define HZIP_PEH_CFG_AUTO_GATE 0x3011A8 @@ -462,7 +468,34 @@ static void hisi_zip_set_high_perf(struct hisi_qm *qm) writel(val, qm->io_base + HZIP_HIGH_PERF_OFFSET); } =20 -static void hisi_zip_open_sva_prefetch(struct hisi_qm *qm) +static int hisi_zip_wait_sva_ready(struct hisi_qm *qm, __u32 offset, __u32= mask) +{ + u32 val, try_times =3D 0; + u8 count =3D 0; + + /* + * Read the register value every 10-20us. If the value is 0 for three + * consecutive times, the SVA module is ready. + */ + do { + val =3D readl(qm->io_base + offset); + if (val & mask) + count =3D 0; + else if (++count =3D=3D HZIP_READ_SVA_STATUS_TIMES) + break; + + usleep_range(HZIP_WAIT_US_MIN, HZIP_WAIT_US_MAX); + } while (++try_times < HZIP_WAIT_SVA_READY); + + if (try_times =3D=3D HZIP_WAIT_SVA_READY) { + pci_err(qm->pdev, "failed to wait sva prefetch ready\n"); + return -ETIMEDOUT; + } + + return 0; +} + +static void hisi_zip_close_sva_prefetch(struct hisi_qm *qm) { u32 val; int ret; @@ -470,19 +503,20 @@ static void hisi_zip_open_sva_prefetch(struct hisi_qm= *qm) if (!test_bit(QM_SUPPORT_SVA_PREFETCH, &qm->caps)) return; =20 - /* Enable prefetch */ val =3D readl_relaxed(qm->io_base + HZIP_PREFETCH_CFG); - val &=3D HZIP_PREFETCH_ENABLE; + val |=3D HZIP_SVA_PREFETCH_DISABLE; writel(val, qm->io_base + HZIP_PREFETCH_CFG); =20 - ret =3D readl_relaxed_poll_timeout(qm->io_base + HZIP_PREFETCH_CFG, - val, !(val & HZIP_SVA_PREFETCH_DISABLE), + ret =3D readl_relaxed_poll_timeout(qm->io_base + HZIP_SVA_TRANS, + val, !(val & HZIP_SVA_DISABLE_READY), HZIP_DELAY_1_US, HZIP_POLL_TIMEOUT_US); if (ret) - pci_err(qm->pdev, "failed to open sva prefetch\n"); + pci_err(qm->pdev, "failed to close sva prefetch\n"); + + (void)hisi_zip_wait_sva_ready(qm, HZIP_SVA_TRANS, HZIP_SVA_STALL_NUM); } =20 -static void hisi_zip_close_sva_prefetch(struct hisi_qm *qm) +static void hisi_zip_open_sva_prefetch(struct hisi_qm *qm) { u32 val; int ret; @@ -490,15 +524,23 @@ static void hisi_zip_close_sva_prefetch(struct hisi_q= m *qm) if (!test_bit(QM_SUPPORT_SVA_PREFETCH, &qm->caps)) return; =20 + /* Enable prefetch */ val =3D readl_relaxed(qm->io_base + HZIP_PREFETCH_CFG); - val |=3D HZIP_SVA_PREFETCH_DISABLE; + val &=3D HZIP_PREFETCH_ENABLE; writel(val, qm->io_base + HZIP_PREFETCH_CFG); =20 - ret =3D readl_relaxed_poll_timeout(qm->io_base + HZIP_SVA_TRANS, - val, !(val & HZIP_SVA_DISABLE_READY), + ret =3D readl_relaxed_poll_timeout(qm->io_base + HZIP_PREFETCH_CFG, + val, !(val & HZIP_SVA_PREFETCH_DISABLE), HZIP_DELAY_1_US, HZIP_POLL_TIMEOUT_US); + if (ret) { + pci_err(qm->pdev, "failed to open sva prefetch\n"); + hisi_zip_close_sva_prefetch(qm); + return; + } + + ret =3D hisi_zip_wait_sva_ready(qm, HZIP_SVA_TRANS, HZIP_SVA_PREFETCH_NUM= ); if (ret) - pci_err(qm->pdev, "failed to close sva prefetch\n"); + hisi_zip_close_sva_prefetch(qm); } =20 static void hisi_zip_enable_clock_gate(struct hisi_qm *qm) @@ -522,6 +564,7 @@ static int hisi_zip_set_user_domain_and_cache(struct hi= si_qm *qm) void __iomem *base =3D qm->io_base; u32 dcomp_bm, comp_bm; u32 zip_core_en; + int ret; =20 /* qm user domain */ writel(AXUSER_BASE, base + QM_ARUSER_M_CFG_1); @@ -576,7 +619,15 @@ static int hisi_zip_set_user_domain_and_cache(struct h= isi_qm *qm) hisi_zip_set_high_perf(qm); hisi_zip_enable_clock_gate(qm); =20 - return hisi_dae_set_user_domain(qm); + ret =3D hisi_dae_set_user_domain(qm); + if (ret) + goto close_sva_prefetch; + + return 0; + +close_sva_prefetch: + hisi_zip_close_sva_prefetch(qm); + return ret; } =20 static void hisi_zip_master_ooo_ctrl(struct hisi_qm *qm, bool enable) --=20 2.33.0 From nobody Sat Oct 4 03:18:50 2025 Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96E3925D1FC; Thu, 21 Aug 2025 01:38:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755740301; cv=none; b=kBEn36FRo2cnbC47Sx9leShOxX8EvBoW9+NyxMdI3OGWs+dGdrb7+8TL4eH3SHnLjIN25ySK+o8uxhGGGlfYguaBa1NOXMOefXawumv+r9i4T1z1mKQ4mEL+7PruskLhT5A4LfAxhu1gDmnZuBni6OI5kG2aFHWaPXBp1r1NDs8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755740301; c=relaxed/simple; bh=SP76kUR2OffvnxNZxJN2KQqKUco78Pwn6aHN6aboaWI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hn2B10Xgo4z72f0Fef2FmzoIh6e0XOkPZDrefIvThDQd5TJh6OQkxG97t/tDJMp1rWButNQt4GiH3CJIRtTa0EjNgQYO9TFrdZT7NlIMT6To5C5U5YYkzK8QxgbpufnCWKXiOaxG4sa/nDAOrG0wFH0/Ok7VtANd9Bs5pMINsVQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4c6mFd3VVQz27jH3; Thu, 21 Aug 2025 09:39:17 +0800 (CST) Received: from dggemv712-chm.china.huawei.com (unknown [10.1.198.32]) by mail.maildlp.com (Postfix) with ESMTPS id 1220F1400CA; Thu, 21 Aug 2025 09:38:12 +0800 (CST) Received: from kwepemq200001.china.huawei.com (7.202.195.16) by dggemv712-chm.china.huawei.com (10.1.198.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 21 Aug 2025 09:38:11 +0800 Received: from localhost.huawei.com (10.90.31.46) by kwepemq200001.china.huawei.com (7.202.195.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 21 Aug 2025 09:38:11 +0800 From: Chenghai Huang To: , CC: , , , , , , , Subject: [PATCH v2 4/6] crypto: hisilicon/qm - check whether the input function and PF are on the same device Date: Thu, 21 Aug 2025 09:38:07 +0800 Message-ID: <20250821013809.4016506-5-huangchenghai2@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20250821013809.4016506-1-huangchenghai2@huawei.com> References: <20250821013809.4016506-1-huangchenghai2@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To kwepemq200001.china.huawei.com (7.202.195.16) Content-Type: text/plain; charset="utf-8" From: Zhushuai Yin Function rate limiting is set through physical function driver. Users configure by providing function information and rate limit values. Before configuration, it is necessary to check whether the provided function and PF belong to the same device. Fixes: 22d7a6c39cab ("crypto: hisilicon/qm - add pci bdf number check") Signed-off-by: Zhushuai Yin Signed-off-by: Chenghai Huang --- drivers/crypto/hisilicon/qm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index 9bbbfff759a9..408e201a7af2 100644 --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@ -3826,6 +3826,10 @@ static ssize_t qm_get_qos_value(struct hisi_qm *qm, = const char *buf, } =20 pdev =3D container_of(dev, struct pci_dev, dev); + if (pci_physfn(pdev) !=3D qm->pdev) { + pci_err(qm->pdev, "the pdev input does not match the pf!\n"); + return -EINVAL; + } =20 *fun_index =3D pdev->devfn; =20 --=20 2.33.0 From nobody Sat Oct 4 03:18:50 2025 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 15B90242D62; Thu, 21 Aug 2025 01:38:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755740297; cv=none; b=UaEhMSiTVKFMZj7z2rFoq7otsBLvc58LQ//Tua7qCzGGwkxTEPBVKEgVmetysOnOLfdpFCZPyD1IBlkAC+QTOvD6OWtp2WyLNZYFTbRIH/cZuO7ctcP0W6ZaQZAW0T0V8OqjjyGSCRRVl29NBrl92VY7Qvt0i0iaVnwW7CJuM68= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755740297; c=relaxed/simple; bh=xf8WH8RCUDuZrcaSE24CIkhh+Cz+7tz+HvYj0wY3rmc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CygOtObTXfp0kDu1kRKQlOvEn4V0hEQu+qHqDz1sP5IrttspfFLd24Hd7gxpMR13YjSTi74Vr9PHsxuQnWsLnlGazafbQdIeblj6neLX8nNH2KqsngXDf8pHcyU2LXSzRpFxnOFrmUkx1THxBOvOcfh4p38ziwbZHuZCmYNpthU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4c6m964dx6z2TTH7; Thu, 21 Aug 2025 09:35:22 +0800 (CST) Received: from dggemv705-chm.china.huawei.com (unknown [10.3.19.32]) by mail.maildlp.com (Postfix) with ESMTPS id 9BF331A016C; Thu, 21 Aug 2025 09:38:12 +0800 (CST) Received: from kwepemq200001.china.huawei.com (7.202.195.16) by dggemv705-chm.china.huawei.com (10.3.19.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 21 Aug 2025 09:38:12 +0800 Received: from localhost.huawei.com (10.90.31.46) by kwepemq200001.china.huawei.com (7.202.195.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 21 Aug 2025 09:38:11 +0800 From: Chenghai Huang To: , CC: , , , , , , , Subject: [PATCH v2 5/6] crypto: hisilicon/qm - request reserved interrupt for virtual function Date: Thu, 21 Aug 2025 09:38:08 +0800 Message-ID: <20250821013809.4016506-6-huangchenghai2@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20250821013809.4016506-1-huangchenghai2@huawei.com> References: <20250821013809.4016506-1-huangchenghai2@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To kwepemq200001.china.huawei.com (7.202.195.16) Content-Type: text/plain; charset="utf-8" From: Weili Qian The device interrupt vector 3 is an error interrupt for physical function and a reserved interrupt for virtual function. However, the driver has not registered the reserved interrupt for virtual function. When allocating interrupts, the number of interrupts is allocated based on powers of two, which includes this interrupt. When the system enables GICv4 and the virtual function passthrough to the virtual machine, releasing the interrupt in the driver triggers a warning. The WARNING report is: WARNING: CPU: 62 PID: 14889 at arch/arm64/kvm/vgic/vgic-its.c:852 its_free_= ite+0x94/0xb4 Therefore, register a reserved interrupt for VF and set the IRQF_NO_AUTOEN flag to avoid that warning. Fixes: 3536cc55cada ("crypto: hisilicon/qm - support get device irq informa= tion from hardware registers") Signed-off-by: Weili Qian Signed-off-by: Chenghai Huang --- drivers/crypto/hisilicon/qm.c | 38 +++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index 408e201a7af2..3a12d291c086 100644 --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@ -4732,6 +4732,15 @@ void hisi_qm_reset_done(struct pci_dev *pdev) } EXPORT_SYMBOL_GPL(hisi_qm_reset_done); =20 +static irqreturn_t qm_rsvd_irq(int irq, void *data) +{ + struct hisi_qm *qm =3D data; + + dev_info(&qm->pdev->dev, "Reserved interrupt, ignore!\n"); + + return IRQ_HANDLED; +} + static irqreturn_t qm_abnormal_irq(int irq, void *data) { struct hisi_qm *qm =3D data; @@ -5015,7 +5024,7 @@ static void qm_unregister_abnormal_irq(struct hisi_qm= *qm) struct pci_dev *pdev =3D qm->pdev; u32 irq_vector, val; =20 - if (qm->fun_type =3D=3D QM_HW_VF) + if (qm->fun_type =3D=3D QM_HW_VF && qm->ver < QM_HW_V3) return; =20 val =3D qm->cap_tables.qm_cap_table[QM_ABNORMAL_IRQ].cap_val; @@ -5032,17 +5041,28 @@ static int qm_register_abnormal_irq(struct hisi_qm = *qm) u32 irq_vector, val; int ret; =20 - if (qm->fun_type =3D=3D QM_HW_VF) - return 0; - val =3D qm->cap_tables.qm_cap_table[QM_ABNORMAL_IRQ].cap_val; if (!((val >> QM_IRQ_TYPE_SHIFT) & QM_ABN_IRQ_TYPE_MASK)) return 0; - irq_vector =3D val & QM_IRQ_VECTOR_MASK; + + /* For VF, this is a reserved interrupt in V3 version. */ + if (qm->fun_type =3D=3D QM_HW_VF) { + if (qm->ver < QM_HW_V3) + return 0; + + ret =3D request_irq(pci_irq_vector(pdev, irq_vector), qm_rsvd_irq, + IRQF_NO_AUTOEN, qm->dev_name, qm); + if (ret) { + dev_err(&pdev->dev, "failed to request reserved irq, ret =3D %d!\n", re= t); + return ret; + } + return 0; + } + ret =3D request_irq(pci_irq_vector(pdev, irq_vector), qm_abnormal_irq, 0,= qm->dev_name, qm); if (ret) - dev_err(&qm->pdev->dev, "failed to request abnormal irq, ret =3D %d", re= t); + dev_err(&qm->pdev->dev, "failed to request abnormal irq, ret =3D %d!\n",= ret); =20 return ret; } @@ -5408,6 +5428,12 @@ static int hisi_qm_pci_init(struct hisi_qm *qm) pci_set_master(pdev); =20 num_vec =3D qm_get_irq_num(qm); + if (!num_vec) { + dev_err(dev, "Device irq num is zero!\n"); + ret =3D -EINVAL; + goto err_get_pci_res; + } + num_vec =3D roundup_pow_of_two(num_vec); ret =3D pci_alloc_irq_vectors(pdev, num_vec, num_vec, PCI_IRQ_MSI); if (ret < 0) { dev_err(dev, "Failed to enable MSI vectors!\n"); --=20 2.33.0 From nobody Sat Oct 4 03:18:50 2025 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F528243951; Thu, 21 Aug 2025 01:38:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755740303; cv=none; b=mhHPlsNFt5oydovSDyvY02v/lQdV3pu3i+URKWYAydw3glh4cISxQ9C6I6nlNQVOBotsWQQ+a0wF8YChHc7EVqCYQ7YseLyg2t3aD/AR9IR+pmgfU8tQS/ddcNAtVf/4DRFXNUtCbojEVq0rbi0xKK/HTYk74tXXvBOI4s6CQls= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755740303; c=relaxed/simple; bh=5wQd8yREeAwrK/mxsFVDN4Qlgb2K6NTve3B5HaAawE0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ij5tLs3b1bU5EpKOoevHr1wIAtob3AblkoGqcLNgugxOG2HPiZzIzpSZTb49ecs4v8K5ETFLCe83IfWhxp5/vL7hvGhH7VamDXlk6uXXGgHNY05k1P7B2Hcwnz0mCOvA4pl8PIZ7r94x9PieGmvXejB8VT0sm2MUmewo65wkT+A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4c6m9B1ctrz2gLC1; Thu, 21 Aug 2025 09:35:26 +0800 (CST) Received: from dggemv706-chm.china.huawei.com (unknown [10.3.19.33]) by mail.maildlp.com (Postfix) with ESMTPS id 9FBA31800CF; Thu, 21 Aug 2025 09:38:19 +0800 (CST) Received: from kwepemq200001.china.huawei.com (7.202.195.16) by dggemv706-chm.china.huawei.com (10.3.19.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 21 Aug 2025 09:38:12 +0800 Received: from localhost.huawei.com (10.90.31.46) by kwepemq200001.china.huawei.com (7.202.195.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 21 Aug 2025 09:38:12 +0800 From: Chenghai Huang To: , CC: , , , , , , , Subject: [PATCH v2 6/6] crypto: hisilicon/zip - enable literal length in stream mode compression Date: Thu, 21 Aug 2025 09:38:09 +0800 Message-ID: <20250821013809.4016506-7-huangchenghai2@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20250821013809.4016506-1-huangchenghai2@huawei.com> References: <20250821013809.4016506-1-huangchenghai2@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To kwepemq200001.china.huawei.com (7.202.195.16) Content-Type: text/plain; charset="utf-8" In stream mode, the hardware needs to combine the length of the previous literal to calculate the length of the current literal. Signed-off-by: Chenghai Huang --- drivers/crypto/hisilicon/zip/zip_main.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/crypto/hisilicon/zip/zip_main.c b/drivers/crypto/hisil= icon/zip/zip_main.c index 341c4564e21a..8c64f145173f 100644 --- a/drivers/crypto/hisilicon/zip/zip_main.c +++ b/drivers/crypto/hisilicon/zip/zip_main.c @@ -117,6 +117,9 @@ /* zip comp high performance */ #define HZIP_HIGH_PERF_OFFSET 0x301208 =20 +#define HZIP_LIT_LEN_EN_OFFSET 0x301204 +#define HZIP_LIT_LEN_EN_EN BIT(4) + enum { HZIP_HIGH_COMP_RATE, HZIP_HIGH_COMP_PERF, @@ -454,6 +457,20 @@ bool hisi_zip_alg_support(struct hisi_qm *qm, u32 alg) return false; } =20 +static void hisi_zip_literal_set(struct hisi_qm *qm) +{ + u32 val; + + if (qm->ver < QM_HW_V3) + return; + + val =3D readl_relaxed(qm->io_base + HZIP_LIT_LEN_EN_OFFSET); + val &=3D ~HZIP_LIT_LEN_EN_EN; + + /* enable literal length in stream mode compression */ + writel(val, qm->io_base + HZIP_LIT_LEN_EN_OFFSET); +} + static void hisi_zip_set_high_perf(struct hisi_qm *qm) { u32 val; @@ -617,6 +634,7 @@ static int hisi_zip_set_user_domain_and_cache(struct hi= si_qm *qm) FIELD_PREP(CQC_CACHE_WB_THRD, 1), base + QM_CACHE_CTL); =20 hisi_zip_set_high_perf(qm); + hisi_zip_literal_set(qm); hisi_zip_enable_clock_gate(qm); =20 ret =3D hisi_dae_set_user_domain(qm); --=20 2.33.0