提交 bed94bc1 编写于 作者: K Kai Ye 提交者: Zheng Zengkai

crypto: hisilicon/qm - fix the qos value initialization

mainline inclusion
from v6.1-rc4
commit f5b657e5
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I5ZHPY
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f5b657e5dbf830cfcb19b588b784b8190a5164a0

----------------------------------------------------------------------

The default qos value is not initialized when sriov is repeatedly enabled
and disabled. So add the vf qos value initialized in the sriov enable
process.
Signed-off-by: NKai Ye <yekai13@huawei.com>
Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: NJiangshui Yang <yangjiangshui@h-partners.com>
Reviewed-by: NXiu Jianfeng <xiujianfeng@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 711b4a78
......@@ -4805,6 +4805,14 @@ void hisi_qm_debug_regs_clear(struct hisi_qm *qm)
}
EXPORT_SYMBOL_GPL(hisi_qm_debug_regs_clear);
static void hisi_qm_init_vf_qos(struct hisi_qm *qm, int total_func)
{
int i;
for (i = 1; i <= total_func; i++)
qm->factor[i].func_qos = QM_QOS_MAX_VAL;
}
/**
* hisi_qm_sriov_enable() - enable virtual functions
* @pdev: the PCIe device
......@@ -4838,6 +4846,10 @@ int hisi_qm_sriov_enable(struct pci_dev *pdev, int max_vfs)
}
num_vfs = max_vfs;
if (test_bit(QM_SUPPORT_FUNC_QOS, &qm->caps))
hisi_qm_init_vf_qos(qm, num_vfs);
ret = qm_vf_q_assign(qm, num_vfs);
if (ret) {
pci_err(pdev, "Can't assign queues for VF!\n");
......@@ -4873,7 +4885,6 @@ EXPORT_SYMBOL_GPL(hisi_qm_sriov_enable);
int hisi_qm_sriov_disable(struct pci_dev *pdev, bool is_frozen)
{
struct hisi_qm *qm = pci_get_drvdata(pdev);
int total_vfs = pci_sriov_get_totalvfs(qm->pdev);
int ret;
if (pci_vfs_assigned(pdev)) {
......@@ -4888,9 +4899,6 @@ int hisi_qm_sriov_disable(struct pci_dev *pdev, bool is_frozen)
}
pci_disable_sriov(pdev);
/* clear vf function shaper configure array */
if (test_bit(QM_SUPPORT_FUNC_QOS, &qm->caps))
memset(qm->factor + 1, 0, sizeof(struct qm_shaper_factor) * total_vfs);
ret = qm_clear_vft_config(qm);
if (ret)
......@@ -6303,7 +6311,7 @@ static int hisi_qp_alloc_memory(struct hisi_qm *qm)
static int hisi_qm_memory_init(struct hisi_qm *qm)
{
struct device *dev = &qm->pdev->dev;
int ret, total_func, i;
int ret, total_func;
size_t off = 0;
if (test_bit(QM_SUPPORT_FUNC_QOS, &qm->caps)) {
......@@ -6312,8 +6320,8 @@ static int hisi_qm_memory_init(struct hisi_qm *qm)
if (!qm->factor)
return -ENOMEM;
for (i = 0; i < total_func; i++)
qm->factor[i].func_qos = QM_QOS_MAX_VAL;
/* Only the PF value needs to be initialized */
qm->factor[0].func_qos = QM_QOS_MAX_VAL;
}
#define QM_INIT_BUF(qm, type, num) do { \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册