Skip to content

Commit 1962920

Browse files
Longfang Liuawilliam
authored andcommitted
hisi_acc_vfio_pci: create subfunction for data reading
This patch generates the code for the operation of reading data from the device into a sub-function. Then, it can be called during the device status data saving phase of the live migration process and the device status data reading function in debugfs. Thereby reducing the redundant code of the driver. Signed-off-by: Longfang Liu <[email protected]> Reviewed-by: Shameer Kolothum <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alex Williamson <[email protected]>
1 parent ece8a2c commit 1962920

File tree

1 file changed

+33
-21
lines changed

1 file changed

+33
-21
lines changed

drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -486,31 +486,11 @@ static int vf_qm_load_data(struct hisi_acc_vf_core_device *hisi_acc_vdev,
486486
return 0;
487487
}
488488

489-
static int vf_qm_state_save(struct hisi_acc_vf_core_device *hisi_acc_vdev,
490-
struct hisi_acc_vf_migration_file *migf)
489+
static int vf_qm_read_data(struct hisi_qm *vf_qm, struct acc_vf_data *vf_data)
491490
{
492-
struct acc_vf_data *vf_data = &migf->vf_data;
493-
struct hisi_qm *vf_qm = &hisi_acc_vdev->vf_qm;
494491
struct device *dev = &vf_qm->pdev->dev;
495492
int ret;
496493

497-
if (unlikely(qm_wait_dev_not_ready(vf_qm))) {
498-
/* Update state and return with match data */
499-
vf_data->vf_qm_state = QM_NOT_READY;
500-
hisi_acc_vdev->vf_qm_state = vf_data->vf_qm_state;
501-
migf->total_length = QM_MATCH_SIZE;
502-
return 0;
503-
}
504-
505-
vf_data->vf_qm_state = QM_READY;
506-
hisi_acc_vdev->vf_qm_state = vf_data->vf_qm_state;
507-
508-
ret = vf_qm_cache_wb(vf_qm);
509-
if (ret) {
510-
dev_err(dev, "failed to writeback QM Cache!\n");
511-
return ret;
512-
}
513-
514494
ret = qm_get_regs(vf_qm, vf_data);
515495
if (ret)
516496
return -EINVAL;
@@ -536,6 +516,38 @@ static int vf_qm_state_save(struct hisi_acc_vf_core_device *hisi_acc_vdev,
536516
return -EINVAL;
537517
}
538518

519+
return 0;
520+
}
521+
522+
static int vf_qm_state_save(struct hisi_acc_vf_core_device *hisi_acc_vdev,
523+
struct hisi_acc_vf_migration_file *migf)
524+
{
525+
struct acc_vf_data *vf_data = &migf->vf_data;
526+
struct hisi_qm *vf_qm = &hisi_acc_vdev->vf_qm;
527+
struct device *dev = &vf_qm->pdev->dev;
528+
int ret;
529+
530+
if (unlikely(qm_wait_dev_not_ready(vf_qm))) {
531+
/* Update state and return with match data */
532+
vf_data->vf_qm_state = QM_NOT_READY;
533+
hisi_acc_vdev->vf_qm_state = vf_data->vf_qm_state;
534+
migf->total_length = QM_MATCH_SIZE;
535+
return 0;
536+
}
537+
538+
vf_data->vf_qm_state = QM_READY;
539+
hisi_acc_vdev->vf_qm_state = vf_data->vf_qm_state;
540+
541+
ret = vf_qm_cache_wb(vf_qm);
542+
if (ret) {
543+
dev_err(dev, "failed to writeback QM Cache!\n");
544+
return ret;
545+
}
546+
547+
ret = vf_qm_read_data(vf_qm, vf_data);
548+
if (ret)
549+
return -EINVAL;
550+
539551
migf->total_length = sizeof(struct acc_vf_data);
540552
return 0;
541553
}

0 commit comments

Comments
 (0)