bugfix some issues under abnormal scenarios.
Longfang Liu
maintainerv2 cover bugfix some issues under abnormal scenarios.
In certain reset scenarios, repeated migration scenarios, and error injection scenarios, it is essential to ensure that the device driver functions properly. Issues arising in these scenarios need to be addressed and fixed
Change v1 -> v2
Fix the reset state handling issue
Longfang Liu (3):
hisi_acc_vfio_pci: update status after RAS error
hisi_acc_vfio_pci: resolve duplicate migration states
hisi_acc_vfio_pci: fix the queue parameter anomaly issue
Weili Qian (1):
hisi_acc_vfio_pci: fix VF reset timeout issue
.../vfio/pci/hisilicon/hisi_acc_vfio_pci.c | 30 +++++++++++++++++-- .../vfio/pci/hisilicon/hisi_acc_vfio_pci.h | 2 ++ 2 files changed, 29 insertions(+), 3 deletions(-)
Signature · 1 line
2.33.0
Longfang Liu
maintainerPATCH v2 1/4 hisi_acc_vfio_pci: fix VF reset timeout issue
From: Weili Qian <[email protected]>
If device error occurs during live migration, qemu will reset the VF. At this time, VF reset and device reset are performed simultaneously. The VF reset will timeout. Therefore, the QM_RESETTING flag is used to ensure that VF reset and device reset are performed serially.
--- .../vfio/pci/hisilicon/hisi_acc_vfio_pci.c | 24 +++++++++++++++++++ .../vfio/pci/hisilicon/hisi_acc_vfio_pci.h | 2 ++ 2 files changed, 26 insertions(+)
drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c +24 -0
@@ -1188,9 +1188,32 @@ hisi_acc_vfio_pci_get_device_state(struct vfio_device *vdev,return 0 ; } +static void hisi_acc_vf_pci_reset_prepare (struct pci_dev *pdev) +{ +struct hisi_acc_vf_core_device *hisi_acc_vdev =hisi_acc_drvdata (pdev); +struct hisi_qm *qm = hisi_acc_vdev->pf_qm; +struct device *dev = &qm->pdev->dev; +u32 delay =0 ; + +/* All reset requests need to be queued for processing */ +while (test_and_set_bit (QM_RESETTING , &qm->misc_ctl)) { +msleep (1 ); +if (++delay >QM_RESET_WAIT_TIMEOUT ) { +dev_err (dev,"reset prepare failed\n" ); +return ; + } + } + + hisi_acc_vdev->set_reset_flag = true; +} +static void hisi_acc_vf_pci_aer_reset_done (struct pci_dev *pdev) {struct hisi_acc_vf_core_device *hisi_acc_vdev =hisi_acc_drvdata (pdev); +struct hisi_qm *qm = hisi_acc_vdev->pf_qm; + +if (hisi_acc_vdev->set_reset_flag) +clear_bit (QM_RESETTING , &qm->misc_ctl);if (hisi_acc_vdev->core_device.vdev.migration_flags !=VFIO_MIGRATION_STOP_COPY )
@@ -1734,6 +1757,7 @@ static const struct pci_device_id hisi_acc_vfio_pci_table[] = {MODULE_DEVICE_TABLE (pci, hisi_acc_vfio_pci_table);static const struct pci_error_handlers hisi_acc_vf_err_handlers = { + .reset_prepare = hisi_acc_vf_pci_reset_prepare, .reset_done = hisi_acc_vf_pci_aer_reset_done, .error_detected = vfio_pci_core_aer_err_detected, };
drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.h +2 -0
@@ -27,6 +27,7 @@#define ERROR_CHECK_TIMEOUT 100#define CHECK_DELAY_TIME 100 +#define QM_RESET_WAIT_TIMEOUT 60000#define QM_SQC_VFT_BASE_SHIFT_V2 28#define QM_SQC_VFT_BASE_MASK_V2 GENMASK(15, 0)
@@ -128,6 +129,7 @@ struct hisi_acc_vf_migration_file {struct hisi_acc_vf_core_device {struct vfio_pci_core_device core_device;u8 match_done; +bool set_reset_flag;/* * io_base is only valid when dev_opened is true, * which is protected by open_mutex.
Signature · 1 line
2.33.0
Longfang Liu
maintainerPATCH v2 2/4 hisi_acc_vfio_pci: update status after RAS error
In reply to Longfang LiuAfter a RAS error occurs on the accelerator device, the accelerator device will be reset. The live migration state will be abnormal after reset, and the original state needs to be restored during the reset process.
Therefore, reset processing needs to be performed in a live migration scenario.
--- drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c +1 -2
@@ -1215,8 +1215,7 @@ static void hisi_acc_vf_pci_aer_reset_done(struct pci_dev *pdev)if (hisi_acc_vdev->set_reset_flag)clear_bit (QM_RESETTING , &qm->misc_ctl); -if (hisi_acc_vdev->core_device.vdev.migration_flags != -VFIO_MIGRATION_STOP_COPY ) +if (!hisi_acc_vdev->core_device.vdev.mig_ops)return ;mutex_lock (&hisi_acc_vdev->state_mutex);
Signature · 1 line
2.33.0
Longfang Liu
maintainerPATCH v2 3/4 hisi_acc_vfio_pci: resolve duplicate migration states
In reply to Longfang LiuIn special scenarios involving duplicate migrations, after the first migration is completed, if the original VF device is used again and then migrated to another destination, the state indicating data migration completion for the VF device is not reset. This results in the second migration to the destination being skipped without performing data migration.
After the modification, it ensures that a complete data migration is performed after the subsequent migration.
--- drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c | 1 + 1 file changed, 1 insertion(+)
drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c +1 -0
@@ -1569,6 +1569,7 @@ static int hisi_acc_vfio_pci_open_device(struct vfio_device *core_vdev) } hisi_acc_vdev->mig_state =VFIO_DEVICE_STATE_RUNNING ; hisi_acc_vdev->dev_opened = true; + hisi_acc_vdev->match_done =0 ;mutex_unlock (&hisi_acc_vdev->open_mutex); }
Signature · 1 line
2.33.0
Longfang Liu
maintainerPATCH v2 4/4 hisi_acc_vfio_pci: fix the queue parameter anomaly issue
In reply to Longfang LiuWhen the number of QPs initialized by the device, as read via vft, is zero, it indicates either an abnormal device configuration or an abnormal read result.
Returning 0 directly in this case would allow the live migration operation to complete successfully, leading to incorrect parameter configuration after migration and preventing the service from recovering normal functionality. Therefore, in such situations, an error should be returned to roll back the live migration operation.
--- drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c +1 -1
@@ -426,7 +426,7 @@ static int vf_qm_check_match(struct hisi_acc_vf_core_device *hisi_acc_vdev, ret =qm_get_vft (vf_qm, &vf_qm->qp_base);if (ret <=0 ) {dev_err (dev,"failed to get vft qp nums\n" ); -return ret; +return ret <0 ? ret : -EINVAL ; }if (ret != vf_data->qp_num) {
Signature · 1 line
2.33.0
Quoted 12 lines · On Thu, 22 Jan 2026 10:02:01 +0800 Longfang Liu <[email protected]> wrote:
In certain reset scenarios, repeated migration scenarios, and error injection scenarios, it is essential to ensure that the device driver functions properly. Issues arising in these scenarios need to be addressed and fixed
Change v1 -> v2
Fix the reset state handling issueLongfang Liu (3):
hisi_acc_vfio_pci: update status after RAS error
hisi_acc_vfio_pci: resolve duplicate migration states
hisi_acc_vfio_pci: fix the queue parameter anomaly issue
Quoted 7 lines
Weili Qian (1):
hisi_acc_vfio_pci: fix VF reset timeout issue.../vfio/pci/hisilicon/hisi_acc_vfio_pci.c | 30 +++++++++++++++++-- .../vfio/pci/hisilicon/hisi_acc_vfio_pci.h | 2 ++ 2 files changed, 29 insertions(+), 3 deletions(-)
Applied to vfio next branch for v6.20/v7.0. Thanks,
Alex
liulongfang
maintainerQuoted 23 lines · Alex Williamson
Quoted 12 lines · On Thu, 22 Jan 2026 10:02:01 +0800 Longfang Liu <[email protected]> wrote:
In certain reset scenarios, repeated migration scenarios, and error injection scenarios, it is essential to ensure that the device driver functions properly. Issues arising in these scenarios need to be addressed and fixed
Change v1 -> v2
Fix the reset state handling issueLongfang Liu (3):
hisi_acc_vfio_pci: update status after RAS error
hisi_acc_vfio_pci: resolve duplicate migration states
hisi_acc_vfio_pci: fix the queue parameter anomaly issueQuoted 7 lines
Weili Qian (1):
hisi_acc_vfio_pci: fix VF reset timeout issue.../vfio/pci/hisilicon/hisi_acc_vfio_pci.c | 30 +++++++++++++++++-- .../vfio/pci/hisilicon/hisi_acc_vfio_pci.h | 2 ++ 2 files changed, 29 insertions(+), 3 deletions(-)
Quoted 5 lines
Applied to vfio next branch for v6.20/v7.0. Thanks,
Alex
.
Thanks.
Longfang