From: Longfang Liu liulongfang@huawei.com
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I4JA45
----------------------------------------------------------------------
In the guest reset operation scenario, the driver inside the guest will not perceive the system restart operation, and the corresponding accelerator driver cannot modify the drive state. When the target end of the live migration is restored, the operation of restarting qp cannot be skipped normally. Caused a page fault exception and the reset of the accelerator PF,
Signed-off-by: Longfang Liu liulongfang@huawei.com Signed-off-by: Yang Shen shenyang39@huawei.com Reviewed-by: Hao Fang fanghao11@huawei.com Acked-by: Xie XiuQi xiexiuqi@huawei.com Signed-off-by: Zheng Zengkai zhengzengkai@huawei.com --- .../hisilicon/migration/acc_vf_migration.c | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-)
diff --git a/drivers/crypto/hisilicon/migration/acc_vf_migration.c b/drivers/crypto/hisilicon/migration/acc_vf_migration.c index 54f83edabf44..7dcea3b9a6c6 100644 --- a/drivers/crypto/hisilicon/migration/acc_vf_migration.c +++ b/drivers/crypto/hisilicon/migration/acc_vf_migration.c @@ -500,11 +500,12 @@ static void vf_qm_fun_restart(struct hisi_qm *qm, int i;
/* - * When the system is rebooted, the SMMU page table is destroyed, - * and the QP queue cannot be returned normally at this time. - * if vf_ready == 0x2, don't need to restart QP. + * When the Guest is rebooted or reseted, the SMMU page table + * will be destroyed, and the QP queue cannot be returned + * normally at this time. so if Guest acc driver have removed, + * don't need to restart QP. */ - if (vf_data->vf_state == VF_PREPARE) { + if (vf_data->vf_state != VF_READY) { dev_err(dev, "failed to restart VF!\n"); return; } @@ -805,12 +806,7 @@ static int acc_vf_set_device_state(struct acc_vf_migration *acc_vf_dev,
break; case VFIO_DEVICE_STATE_STOP: - /* restart all VF's QP */ - vf_qm_fun_restart(qm, acc_vf_dev); - - break; case VFIO_DEVICE_STATE_RESUMING: - break; default: ret = -EFAULT; @@ -1210,12 +1206,30 @@ static void acc_vf_release(void *device_data) module_put(THIS_MODULE); }
+static void acc_vf_reset(void *device_data) +{ + struct acc_vf_migration *acc_vf_dev = + vfio_pci_vendor_data(device_data); + struct hisi_qm *qm = acc_vf_dev->vf_qm; + struct device *dev = &qm->pdev->dev; + u32 vf_state = VF_NOT_READY; + int ret; + + dev_info(dev, "QEMU prepare to Reset Guest!\n"); + ret = qm_write_reg(qm, QM_VF_STATE, &vf_state, 1); + if (ret) + dev_err(dev, "failed to write QM_VF_STATE\n"); +} + static long acc_vf_ioctl(void *device_data, unsigned int cmd, unsigned long arg) { switch (cmd) { case VFIO_DEVICE_GET_REGION_INFO: return acc_vf_get_region_info(device_data, cmd, arg); + case VFIO_DEVICE_RESET: + acc_vf_reset(device_data); + return vfio_pci_ioctl(device_data, cmd, arg); default: return vfio_pci_ioctl(device_data, cmd, arg); }