Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <liulongfang@huawei.com>
Reviewed-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
Link: https://lore.kernel.org/r/20241112073322.54550-3-liulongfang@huawei.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>

authored by

Longfang Liu and committed by
Alex Williamson
19629206 ece8a2c7

+33 -21
+33 -21
drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c
··· 486 486 return 0; 487 487 } 488 488 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) 491 490 { 492 - struct acc_vf_data *vf_data = &migf->vf_data; 493 - struct hisi_qm *vf_qm = &hisi_acc_vdev->vf_qm; 494 491 struct device *dev = &vf_qm->pdev->dev; 495 492 int ret; 496 - 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 493 514 494 ret = qm_get_regs(vf_qm, vf_data); 515 495 if (ret) ··· 515 535 dev_err(dev, "failed to read CQC addr!\n"); 516 536 return -EINVAL; 517 537 } 538 + 539 + return 0; 540 + } 541 + 542 + static int vf_qm_state_save(struct hisi_acc_vf_core_device *hisi_acc_vdev, 543 + struct hisi_acc_vf_migration_file *migf) 544 + { 545 + struct acc_vf_data *vf_data = &migf->vf_data; 546 + struct hisi_qm *vf_qm = &hisi_acc_vdev->vf_qm; 547 + struct device *dev = &vf_qm->pdev->dev; 548 + int ret; 549 + 550 + if (unlikely(qm_wait_dev_not_ready(vf_qm))) { 551 + /* Update state and return with match data */ 552 + vf_data->vf_qm_state = QM_NOT_READY; 553 + hisi_acc_vdev->vf_qm_state = vf_data->vf_qm_state; 554 + migf->total_length = QM_MATCH_SIZE; 555 + return 0; 556 + } 557 + 558 + vf_data->vf_qm_state = QM_READY; 559 + hisi_acc_vdev->vf_qm_state = vf_data->vf_qm_state; 560 + 561 + ret = vf_qm_cache_wb(vf_qm); 562 + if (ret) { 563 + dev_err(dev, "failed to writeback QM Cache!\n"); 564 + return ret; 565 + } 566 + 567 + ret = vf_qm_read_data(vf_qm, vf_data); 568 + if (ret) 569 + return -EINVAL; 518 570 519 571 migf->total_length = sizeof(struct acc_vf_data); 520 572 return 0;