[PATCH 14/18] drm/amdgpu: Fix amdgpu reload failure under SRIOV

Monk Liu Monk.Liu at amd.com
Mon Sep 18 06:11:58 UTC 2017


From: Horace Chen <horace.chen at amd.com>

Kernel will set the PCI power state to UNKNOWN after unloading,
Since SRIOV has faked PCI config space so the UNKNOWN state
will be kept forever.

In driver reload if the power state is UNKNOWN then enabling msi
will fail.

forcely set it to D0 for SRIOV to fix this kernel flawness.

Change-Id: I6a72d5fc9b653b21c3c98167515a511c5edeb91c
Signed-off-by: Horace Chen <horace.chen at amd.com>
Signed-off-by: Monk Liu <Monk.Liu at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
index 914c5bf..345406a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
@@ -229,7 +229,15 @@ int amdgpu_irq_init(struct amdgpu_device *adev)
 	adev->irq.msi_enabled = false;
 
 	if (amdgpu_msi_ok(adev)) {
-		int ret = pci_enable_msi(adev->pdev);
+		int ret;
+		if (amdgpu_sriov_vf(adev) &&
+		    adev->pdev->current_state == PCI_UNKNOWN){
+			/* If pci power state is unknown on the SRIOV platform,
+			 * it may be set in the remove device. We need to forcely
+			 * set it to D0 to enable the msi*/
+			adev->pdev->current_state = PCI_D0;
+		}
+		ret = pci_enable_msi(adev->pdev);
 		if (!ret) {
 			adev->irq.msi_enabled = true;
 			dev_info(adev->dev, "amdgpu: using MSI.\n");
-- 
2.7.4



More information about the amd-gfx mailing list