On 11/27/25 01:39, Michał Winiarski wrote:
[snip]
+static void xe_vfio_pci_reset_done(struct pci_dev *pdev)
+{
+       struct xe_vfio_pci_core_device *xe_vdev = pci_get_drvdata(pdev);
+       int ret;
+
+       if (!pdev->is_virtfn)
+               return;
+
+       /*
+        * VF FLR requires additional processing done by PF driver.
+        * The processing is done after FLR is already finished from PCIe
+        * perspective.
+        * In order to avoid a scenario where VF is used while PF processing
+        * is still in progress, additional synchronization point is needed.
+        */
+       ret = xe_sriov_vfio_wait_flr_done(xe_vdev->xe, xe_vdev->vfid);
+       if (ret)
+               dev_err(&pdev->dev, "Failed to wait for FLR: %d\n", ret);
+
+       if (!xe_vdev->vfid)
+               return;
+
+       /*
+        * As the higher VFIO layers are holding locks across reset and using
+        * those same locks with the mm_lock we need to prevent ABBA deadlock
+        * with the state_mutex and mm_lock.
+        * In case the state_mutex was taken already we defer the cleanup work
+        * to the unlock flow of the other running context.
+        */
+       spin_lock(&xe_vdev->reset_lock);
+       xe_vdev->deferred_reset = true;
+       if (!mutex_trylock(&xe_vdev->state_mutex)) {
+               spin_unlock(&xe_vdev->reset_lock);
+               return;
+       }
+       spin_unlock(&xe_vdev->reset_lock);
+       xe_vfio_pci_state_mutex_unlock(xe_vdev);
+
+       xe_vfio_pci_reset(xe_vdev);
+}
[snip]

My first KVM review :)

I think xe_vfio_pci_reset(xe_vdev) need be protected by state_mutex. So,
we should move xe_vfio_pci_state_mutex_unlock(xe_vdev) after
xe_vfio_pci_reset(xe_vdev). Thoughts?

Thanks,
Angela

Reply via email to