Skip to content

Commit 64b9642

Browse files
Weili Qianherbertx
authored andcommitted
crypto: hisilicon/qm - clear all VF configurations in the hardware
When disabling SR-IOV, clear the configuration of each VF in the hardware. Do not exit the configuration clearing process due to the failure of a single VF. Additionally, Clear the VF configurations before decrementing the PM counter. Signed-off-by: Weili Qian <qianweili@huawei.com> Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 80736a9 commit 64b9642

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

  • drivers/crypto/hisilicon

drivers/crypto/hisilicon/qm.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3660,19 +3660,19 @@ static int qm_vf_q_assign(struct hisi_qm *qm, u32 num_vfs)
36603660
return 0;
36613661
}
36623662

3663-
static int qm_clear_vft_config(struct hisi_qm *qm)
3663+
static void qm_clear_vft_config(struct hisi_qm *qm)
36643664
{
3665-
int ret;
36663665
u32 i;
36673666

3668-
for (i = 1; i <= qm->vfs_num; i++) {
3669-
ret = hisi_qm_set_vft(qm, i, 0, 0);
3670-
if (ret)
3671-
return ret;
3672-
}
3673-
qm->vfs_num = 0;
3667+
/*
3668+
* When disabling SR-IOV, clear the configuration of each VF in the hardware
3669+
* sequentially. Failure to clear a single VF should not affect the clearing
3670+
* operation of other VFs.
3671+
*/
3672+
for (i = 1; i <= qm->vfs_num; i++)
3673+
(void)hisi_qm_set_vft(qm, i, 0, 0);
36743674

3675-
return 0;
3675+
qm->vfs_num = 0;
36763676
}
36773677

36783678
static int qm_func_shaper_enable(struct hisi_qm *qm, u32 fun_index, u32 qos)
@@ -4007,13 +4007,13 @@ int hisi_qm_sriov_enable(struct pci_dev *pdev, int max_vfs)
40074007
goto err_put_sync;
40084008
}
40094009

4010+
qm->vfs_num = num_vfs;
40104011
ret = pci_enable_sriov(pdev, num_vfs);
40114012
if (ret) {
40124013
pci_err(pdev, "Can't enable VF!\n");
40134014
qm_clear_vft_config(qm);
40144015
goto err_put_sync;
40154016
}
4016-
qm->vfs_num = num_vfs;
40174017

40184018
pci_info(pdev, "VF enabled, vfs_num(=%d)!\n", num_vfs);
40194019

@@ -4048,11 +4048,10 @@ int hisi_qm_sriov_disable(struct pci_dev *pdev, bool is_frozen)
40484048
}
40494049

40504050
pci_disable_sriov(pdev);
4051-
4052-
qm->vfs_num = 0;
4051+
qm_clear_vft_config(qm);
40534052
qm_pm_put_sync(qm);
40544053

4055-
return qm_clear_vft_config(qm);
4054+
return 0;
40564055
}
40574056
EXPORT_SYMBOL_GPL(hisi_qm_sriov_disable);
40584057

0 commit comments

Comments
 (0)