Skip to content

Commit

Permalink
hisi_acc_vfio_pci: Move the dev compatibility tests for early check
Browse files Browse the repository at this point in the history
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 <shameerali.kolothum.thodi@huawei.com>
Link: https://lore.kernel.org/r/20221123113236.896-4-shameerali.kolothum.thodi@huawei.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
  • Loading branch information
Shameer Kolothum authored and Alex Williamson committed Dec 6, 2022
1 parent d9a871e commit 190125a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
19 changes: 7 additions & 12 deletions drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,8 @@ static int vf_qm_check_match(struct hisi_acc_vf_core_device *hisi_acc_vdev,
u32 que_iso_state;
int ret;

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

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

hisi_acc_vdev->vf_qm_state = vf_data->vf_qm_state;
hisi_acc_vdev->match_done = true;
return 0;
}

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

ret = vf_qm_get_match_data(hisi_acc_vdev, vf_data);
if (ret)
return ret;

if (unlikely(qm_wait_dev_not_ready(vf_qm))) {
/* Update state and return with match data */
vf_data->vf_qm_state = QM_NOT_READY;
Expand Down Expand Up @@ -673,12 +670,6 @@ static int hisi_acc_vf_load_state(struct hisi_acc_vf_core_device *hisi_acc_vdev)
struct hisi_acc_vf_migration_file *migf = hisi_acc_vdev->resuming_migf;
int ret;

/* Check dev compatibility */
ret = vf_qm_check_match(hisi_acc_vdev, migf);
if (ret) {
dev_err(dev, "failed to match the VF!\n");
return ret;
}
/* Recover data to VF */
ret = vf_qm_load_data(hisi_acc_vdev, migf);
if (ret) {
Expand Down Expand Up @@ -732,6 +723,10 @@ static ssize_t hisi_acc_vf_resume_write(struct file *filp, const char __user *bu
*pos += len;
done = len;
migf->total_length += len;

ret = vf_qm_check_match(migf->hisi_acc_vdev, migf);
if (ret)
done = -EFAULT;
out_unlock:
mutex_unlock(&migf->lock);
return done;
Expand Down
1 change: 1 addition & 0 deletions drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ struct hisi_acc_vf_migration_file {

struct hisi_acc_vf_core_device {
struct vfio_pci_core_device core_device;
u8 match_done:1;
u8 deferred_reset:1;
/* For migration state */
struct mutex state_mutex;
Expand Down

0 comments on commit 190125a

Please sign in to comment.