Skip to content

Commit 190125a

Browse files
shamiali2008awilliam
authored andcommitted
hisi_acc_vfio_pci: Move the dev compatibility tests for early check
Instead of waiting till data transfer is complete to perform dev compatibility, do it as soon as we have enough data to perform the check. This will be useful when we enable the support for PRE_COPY. Signed-off-by: Shameer Kolothum <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alex Williamson <[email protected]>
1 parent d9a871e commit 190125a

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,8 @@ static int vf_qm_check_match(struct hisi_acc_vf_core_device *hisi_acc_vdev,
360360
u32 que_iso_state;
361361
int ret;
362362

363-
if (migf->total_length < QM_MATCH_SIZE)
364-
return -EINVAL;
363+
if (migf->total_length < QM_MATCH_SIZE || hisi_acc_vdev->match_done)
364+
return 0;
365365

366366
if (vf_data->acc_magic != ACC_DEV_MAGIC) {
367367
dev_err(dev, "failed to match ACC_DEV_MAGIC\n");
@@ -406,6 +406,7 @@ static int vf_qm_check_match(struct hisi_acc_vf_core_device *hisi_acc_vdev,
406406
}
407407

408408
hisi_acc_vdev->vf_qm_state = vf_data->vf_qm_state;
409+
hisi_acc_vdev->match_done = true;
409410
return 0;
410411
}
411412

@@ -493,10 +494,6 @@ static int vf_qm_state_save(struct hisi_acc_vf_core_device *hisi_acc_vdev,
493494
struct device *dev = &vf_qm->pdev->dev;
494495
int ret;
495496

496-
ret = vf_qm_get_match_data(hisi_acc_vdev, vf_data);
497-
if (ret)
498-
return ret;
499-
500497
if (unlikely(qm_wait_dev_not_ready(vf_qm))) {
501498
/* Update state and return with match data */
502499
vf_data->vf_qm_state = QM_NOT_READY;
@@ -673,12 +670,6 @@ static int hisi_acc_vf_load_state(struct hisi_acc_vf_core_device *hisi_acc_vdev)
673670
struct hisi_acc_vf_migration_file *migf = hisi_acc_vdev->resuming_migf;
674671
int ret;
675672

676-
/* Check dev compatibility */
677-
ret = vf_qm_check_match(hisi_acc_vdev, migf);
678-
if (ret) {
679-
dev_err(dev, "failed to match the VF!\n");
680-
return ret;
681-
}
682673
/* Recover data to VF */
683674
ret = vf_qm_load_data(hisi_acc_vdev, migf);
684675
if (ret) {
@@ -732,6 +723,10 @@ static ssize_t hisi_acc_vf_resume_write(struct file *filp, const char __user *bu
732723
*pos += len;
733724
done = len;
734725
migf->total_length += len;
726+
727+
ret = vf_qm_check_match(migf->hisi_acc_vdev, migf);
728+
if (ret)
729+
done = -EFAULT;
735730
out_unlock:
736731
mutex_unlock(&migf->lock);
737732
return done;

drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ struct hisi_acc_vf_migration_file {
9898

9999
struct hisi_acc_vf_core_device {
100100
struct vfio_pci_core_device core_device;
101+
u8 match_done:1;
101102
u8 deferred_reset:1;
102103
/* For migration state */
103104
struct mutex state_mutex;

0 commit comments

Comments
 (0)