drm/amdgpu: retry init if it fails due to exclusive mode timeout (v2)
Subsystems (2)
PATCH 7/7 drm/amdgpu: retry init if it fails due to exclusive mode timeout (v2)
From: pding <[email protected]>
The exclusive mode has real-time limitation in reality, such like being done in 300ms. It's easy observed if running many VF/VMs in single host with heavy CPU workload.
If we find the init fails due to exclusive mode timeout, try it again.
v2:
- rewrite the condition for readable value.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 ++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 14 ++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +10 -0
@@ -2301,6 +2301,15 @@ int amdgpu_device_init(struct amdgpu_device *adev, r =amdgpu_init (adev);if (r) { +/* failed in exclusive mode due to timeout */ +if (amdgpu_sriov_vf (adev) && + !amdgpu_sriov_runtime (adev) && +amdgpu_virt_mmio_blocked (adev) && + !amdgpu_virt_wait_reset (adev)) { +dev_err (adev->dev,"VF exclusive mode timeout\n" ); + r = -EAGAIN ; + goto failed; + }dev_err (adev->dev,"amdgpu_init failed\n" );amdgpu_vf_error_put (adev,AMDGIM_ERROR_VF_AMDGPU_INIT_FAIL ,0 ,0 );amdgpu_fini (adev);
@@ -2388,6 +2397,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,amdgpu_vf_error_trans_all (adev);if (runtime)vga_switcheroo_fini_domain_pm_ops (adev->dev); +return r; }
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +12 -2
@@ -86,7 +86,7 @@ void amdgpu_driver_unload_kms(struct drm_device *dev)int amdgpu_driver_load_kms (struct drm_device *dev,unsigned long flags) {struct amdgpu_device *adev; -int r, acpi_status; +int r, acpi_status, retry =0 ;#ifdef CONFIG_DRM_AMDGPU_SI if (!amdgpu_si_support) {
@@ -122,6 +122,7 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) } }#endif +retry_init: adev =kzalloc (sizeof (struct amdgpu_device ),GFP_KERNEL );if (adev ==NULL ) {
@@ -144,7 +145,16 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)* VRAM allocation */ r =amdgpu_device_init (adev, dev, dev->pdev, flags); -if (r) { +if (++retry >=3 && r == -EAGAIN ) { + adev->virt.caps &= ~AMDGPU_SRIOV_CAPS_RUNTIME ; + adev->virt.ops =NULL ; +amdgpu_device_fini (adev); +kfree (adev); + dev->dev_private =NULL ; +msleep (5000 ); +dev_err (&dev->pdev->dev,"retry init %d\n" , retry); + goto retry_init; + }else if (r) {dev_err (&dev->pdev->dev,"Fatal error during GPU init\n" ); goto out; }
Signature · 6 lines
2.9.5 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1508897994-23151-1-git-send-email-Pixel.Ding-5C7GfCeVMHo@public.gmane.org
Quoted 67 lines · Pixel Ding
From: pding <[email protected]>
The exclusive mode has real-time limitation in reality, such like being done in 300ms. It's easy observed if running many VF/VMs in single host with heavy CPU workload.
If we find the init fails due to exclusive mode timeout, try it again.
v2:
- rewrite the condition for readable value.Signed-off-by pding <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 ++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 14 ++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +10
-0@@ -2301,6 +2301,15 @@ int amdgpu_device_init(struct amdgpu_device *adev, r =amdgpu_init (adev);if (r) { +/* failed in exclusive mode due to timeout */ +if (amdgpu_sriov_vf (adev) && + !amdgpu_sriov_runtime (adev) && +amdgpu_virt_mmio_blocked (adev) && + !amdgpu_virt_wait_reset (adev)) { +dev_err (adev->dev,"VF exclusive mode timeout\n" ); + r = -EAGAIN ; + goto failed; + }dev_err (adev->dev,"amdgpu_init failed\n" );amdgpu_vf_error_put (adev,AMDGIM_ERROR_VF_AMDGPU_INIT_FAIL ,0 ,0 );amdgpu_fini (adev);@@ -2388,6 +2397,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,amdgpu_vf_error_trans_all (adev);if (runtime)vga_switcheroo_fini_domain_pm_ops (adev->dev); +return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +2
-1@@ -86,7 +86,7 @@ void amdgpu_driver_unload_kms(struct drm_device *dev)int amdgpu_driver_load_kms (struct drm_device *dev,unsigned long flags) {struct amdgpu_device *adev; -int r, acpi_status; +int r, acpi_status, retry =0 ;#ifdef CONFIG_DRM_AMDGPU_SI if (!amdgpu_si_support) {@@ -122,6 +122,7 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) } }#endif +retry_init: adev =kzalloc (sizeof (struct amdgpu_device ),GFP_KERNEL );if (adev ==NULL ) {
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) · line 148
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1
-1@@ -144,7 +145,16 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)* VRAM allocation */ r =amdgpu_device_init (adev, dev, dev->pdev, flags); -if (r) { +if (++retry >=3 && r == -EAGAIN ) {
Might be better to check for -EAGAIN first.
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) · line 154
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +6
-0+ adev->virt.caps &= ~AMDGPU_SRIOV_CAPS_RUNTIME ; + adev->virt.ops =NULL ; +amdgpu_device_fini (adev); +kfree (adev); + dev->dev_private =NULL ; +msleep (5000 );
Why do we need the sleep here?
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3
-1+dev_err (&dev->pdev->dev,"retry init %d\n" , retry); + goto retry_init; + }else if (r) {dev_err (&dev->pdev->dev,"Fatal error during GPU init\n" ); goto out; } --2.9.5
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CADnq5_ODQDx4vghCo7aW_w-g_O7-PG1jh7UNREq0UFu+y77AUA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Host rejects frequent exclusive mode requesting, otherwise an attacking VF may cause problems. Sleep for a while to let host accept next request here.
—
Sincerely Yours,
Pixel
Quoted 84 lines · Alex Deucher
Quoted 67 lines · Pixel Ding
From: pding <[email protected]>
The exclusive mode has real-time limitation in reality, such like being done in 300ms. It's easy observed if running many VF/VMs in single host with heavy CPU workload.
If we find the init fails due to exclusive mode timeout, try it again.
v2:
- rewrite the condition for readable value.Signed-off-by pding <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 ++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 14 ++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +10
-0@@ -2301,6 +2301,15 @@ int amdgpu_device_init(struct amdgpu_device *adev, r =amdgpu_init (adev);if (r) { +/* failed in exclusive mode due to timeout */ +if (amdgpu_sriov_vf (adev) && + !amdgpu_sriov_runtime (adev) && +amdgpu_virt_mmio_blocked (adev) && + !amdgpu_virt_wait_reset (adev)) { +dev_err (adev->dev,"VF exclusive mode timeout\n" ); + r = -EAGAIN ; + goto failed; + }dev_err (adev->dev,"amdgpu_init failed\n" );amdgpu_vf_error_put (adev,AMDGIM_ERROR_VF_AMDGPU_INIT_FAIL ,0 ,0 );amdgpu_fini (adev);@@ -2388,6 +2397,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,amdgpu_vf_error_trans_all (adev);if (runtime)vga_switcheroo_fini_domain_pm_ops (adev->dev); +return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +2
-1@@ -86,7 +86,7 @@ void amdgpu_driver_unload_kms(struct drm_device *dev)int amdgpu_driver_load_kms (struct drm_device *dev,unsigned long flags) {struct amdgpu_device *adev; -int r, acpi_status; +int r, acpi_status, retry =0 ;#ifdef CONFIG_DRM_AMDGPU_SI if (!amdgpu_si_support) {@@ -122,6 +122,7 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) } }#endif +retry_init: adev =kzalloc (sizeof (struct amdgpu_device ),GFP_KERNEL );if (adev ==NULL ) {drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) · line 148
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1
-1@@ -144,7 +145,16 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)* VRAM allocation */ r =amdgpu_device_init (adev, dev, dev->pdev, flags); -if (r) { +if (++retry >=3 && r == -EAGAIN ) {Might be better to check for
-EAGAINfirst.drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) · line 154
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +6
-0+ adev->virt.caps &= ~AMDGPU_SRIOV_CAPS_RUNTIME ; + adev->virt.ops =NULL ; +amdgpu_device_fini (adev); +kfree (adev); + dev->dev_private =NULL ; +msleep (5000 );
Quoted 15 lines
Why do we need the sleep here?
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3
-1+dev_err (&dev->pdev->dev,"retry init %d\n" , retry); + goto retry_init; + }else if (r) {dev_err (&dev->pdev->dev,"Fatal error during GPU init\n" ); goto out; } --2.9.5
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): D72531CF-A38D-4137-83DB-BF7E78A0CF19-5C7GfCeVMHo@public.gmane.org
Alex Deucher
Acked-byQuoted 2 lines · Pixel
Host rejects frequent exclusive mode requesting, otherwise an attacking VF may cause problems. Sleep for a while to let host accept next request here.
Please add a comment about that. With that added:
Quoted 10 lines
—
Sincerely Yours,
Pixel
Quoted 101 lines
Quoted 99 lines · Alex Deucher
Quoted 67 lines · Pixel Ding
From: pding <[email protected]>
The exclusive mode has real-time limitation in reality, such like being done in 300ms. It's easy observed if running many VF/VMs in single host with heavy CPU workload.
If we find the init fails due to exclusive mode timeout, try it again.
v2:
- rewrite the condition for readable value.Signed-off-by pding <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 ++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 14 ++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +10
-0@@ -2301,6 +2301,15 @@ int amdgpu_device_init(struct amdgpu_device *adev, r =amdgpu_init (adev);if (r) { +/* failed in exclusive mode due to timeout */ +if (amdgpu_sriov_vf (adev) && + !amdgpu_sriov_runtime (adev) && +amdgpu_virt_mmio_blocked (adev) && + !amdgpu_virt_wait_reset (adev)) { +dev_err (adev->dev,"VF exclusive mode timeout\n" ); + r = -EAGAIN ; + goto failed; + }dev_err (adev->dev,"amdgpu_init failed\n" );amdgpu_vf_error_put (adev,AMDGIM_ERROR_VF_AMDGPU_INIT_FAIL ,0 ,0 );amdgpu_fini (adev);@@ -2388,6 +2397,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,amdgpu_vf_error_trans_all (adev);if (runtime)vga_switcheroo_fini_domain_pm_ops (adev->dev); +return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +2
-1@@ -86,7 +86,7 @@ void amdgpu_driver_unload_kms(struct drm_device *dev)int amdgpu_driver_load_kms (struct drm_device *dev,unsigned long flags) {struct amdgpu_device *adev; -int r, acpi_status; +int r, acpi_status, retry =0 ;#ifdef CONFIG_DRM_AMDGPU_SI if (!amdgpu_si_support) {@@ -122,6 +122,7 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) } }#endif +retry_init: adev =kzalloc (sizeof (struct amdgpu_device ),GFP_KERNEL );if (adev ==NULL ) {drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) · line 148
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1
-1@@ -144,7 +145,16 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)* VRAM allocation */ r =amdgpu_device_init (adev, dev, dev->pdev, flags); -if (r) { +if (++retry >=3 && r == -EAGAIN ) {Might be better to check for
-EAGAINfirst.drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) · line 154
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +6
-0+ adev->virt.caps &= ~AMDGPU_SRIOV_CAPS_RUNTIME ; + adev->virt.ops =NULL ; +amdgpu_device_fini (adev); +kfree (adev); + dev->dev_private =NULL ; +msleep (5000 );Why do we need the sleep here?
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3
-1+dev_err (&dev->pdev->dev,"retry init %d\n" , retry); + goto retry_init; + }else if (r) {dev_err (&dev->pdev->dev,"Fatal error during GPU init\n" ); goto out; } --2.9.5
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx