Skip to contentSkip to conversation

drm/amdgpu: skip pci_restore_state under sriov during device init

PATCH In review Victor Zhao 2 participants 2 messages Oct 24, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: skip pci_restore_state under sriov during device init

during device init, under sriov, pci_restore_state happens after fullaccess released, and it can have race condition with mmio protection enable from host side.

Since msix was toggled during pci_restore_state, if mmio protection happens during this time, guest side msix will not be properly programmed and leading to missing interrupts.

So skip pci_restore_state during device init.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
index 6c0ff1c2ae4c..52803cd91ef5 100644
@@ -4524,7 +4524,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 		dev_err(adev->dev, "amdgpu_pmu_init failed\n");
 
 	/* Have stored pci confspace at hand for restore in sudden PCI error */
-	if (amdgpu_device_cache_pci_state(adev->pdev))
+	if (!amdgpu_sriov_vf(adev) && amdgpu_device_cache_pci_state(adev->pdev))
 		pci_restore_state(pdev);
 
 	/* if we have > 1 VGA cards, then disable the amdgpu VGA resources */
Signature · 1 line
2.34.1
#1 lore raw
Quoted 20 lines · Victor Zhao

during device init, under sriov, pci_restore_state happens after fullaccess released, and it can have race condition with mmio protection enable from host side.

Since msix was toggled during pci_restore_state, if mmio protection happens during this time, guest side msix will not be properly programmed and leading to missing interrupts.

So skip pci_restore_state during device init.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index 6c0ff1c2ae4c..52803cd91ef5 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct amdgpu_device *adev, · line 4527

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -4524,7 +4524,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 		dev_err(adev->dev, "amdgpu_pmu_init failed\n");
 
 	/* Have stored pci confspace at hand for restore in sudden PCI error */
-	if (amdgpu_device_cache_pci_state(adev->pdev))
+	if (!amdgpu_sriov_vf(adev) && amdgpu_device_cache_pci_state(adev->pdev))

This also prevents caching the state. If the intention is that way, put the check inside amdgpu_device_cache_pci_state to make it explicit that VFs avoid caching config space.

Thanks,
Lijo

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
 		pci_restore_state(pdev);
 
 	/* if we have > 1 VGA cards, then disable the amdgpu VGA resources */