提交 66d64f28 编写于 作者: L Longfang Liu 提交者: Zheng Zengkai

acc/migration: bugfix Guest reset scene

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: NLongfang Liu <liulongfang@huawei.com>
Signed-off-by: NYang Shen <shenyang39@huawei.com>
Reviewed-by: NHao Fang <fanghao11@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 ef502dc2
...@@ -500,11 +500,12 @@ static void vf_qm_fun_restart(struct hisi_qm *qm, ...@@ -500,11 +500,12 @@ static void vf_qm_fun_restart(struct hisi_qm *qm,
int i; int i;
/* /*
* When the system is rebooted, the SMMU page table is destroyed, * When the Guest is rebooted or reseted, the SMMU page table
* and the QP queue cannot be returned normally at this time. * will be destroyed, and the QP queue cannot be returned
* if vf_ready == 0x2, don't need to restart QP. * 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"); dev_err(dev, "failed to restart VF!\n");
return; return;
} }
...@@ -805,12 +806,7 @@ static int acc_vf_set_device_state(struct acc_vf_migration *acc_vf_dev, ...@@ -805,12 +806,7 @@ static int acc_vf_set_device_state(struct acc_vf_migration *acc_vf_dev,
break; break;
case VFIO_DEVICE_STATE_STOP: case VFIO_DEVICE_STATE_STOP:
/* restart all VF's QP */
vf_qm_fun_restart(qm, acc_vf_dev);
break;
case VFIO_DEVICE_STATE_RESUMING: case VFIO_DEVICE_STATE_RESUMING:
break; break;
default: default:
ret = -EFAULT; ret = -EFAULT;
...@@ -1210,12 +1206,30 @@ static void acc_vf_release(void *device_data) ...@@ -1210,12 +1206,30 @@ static void acc_vf_release(void *device_data)
module_put(THIS_MODULE); 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, static long acc_vf_ioctl(void *device_data,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
switch (cmd) { switch (cmd) {
case VFIO_DEVICE_GET_REGION_INFO: case VFIO_DEVICE_GET_REGION_INFO:
return acc_vf_get_region_info(device_data, cmd, arg); 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: default:
return vfio_pci_ioctl(device_data, cmd, arg); return vfio_pci_ioctl(device_data, cmd, arg);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册