Skip to contentSkip to conversation

drm/amdgpu: add flag to enable/disable poll in suspend/resume path

PATCH In review Guchun Chen 2 participants 3 messages Mar 8, 2023 – Mar 9, 2023

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

PATCH 1/2 drm/amdgpu: add flag to enable/disable poll in suspend/resume path

Some amd asics having reliable hotplug support don't call drm_kms_helper_poll_init in driver init sequence. However, due to the unified suspend/resume path for all asics, because the output_poll_work->func is not set for these asics, a warning arrives when suspending.

[   90.656049]  <TASK>
[   90.656050]  ? console_unlock+0x4d/0x100
[   90.656053]  ? __irq_work_queue_local+0x27/0x60
[   90.656056]  ? irq_work_queue+0x2b/0x50
[   90.656057]  ? __wake_up_klogd+0x40/0x60
[   90.656059]  __cancel_work_timer+0xed/0x180
[   90.656061]  drm_kms_helper_poll_disable.cold+0x1f/0x2c [drm_kms_helper]
[   90.656072]  amdgpu_device_suspend+0x81/0x170 [amdgpu]
[   90.656180]  amdgpu_pmops_runtime_suspend+0xb5/0x1b0 [amdgpu]
[   90.656269]  pci_pm_runtime_suspend+0x61/0x1b0

So add use_kms_poll flag as the initialization check in amdgpu code before calling drm_kms_helper_poll_disable/drm_kms_helper_poll_enable in suspend/resume path.

Fixes a4e771729a51("drm/probe_helper: sort out poll_running vs poll_enabled")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 ++++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h   | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c   | 1 +
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c     | 1 +
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c     | 1 +
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c      | 1 +
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c      | 1 +
 7 files changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -2
index c4a4e2fe6681..74af0b8c0d08 100644
@@ -4145,7 +4145,8 @@ int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)
 	if (amdgpu_acpi_smart_shift_update(dev, AMDGPU_SS_DEV_D3))
 		DRM_WARN("smart shift update failed\n");
 
-	drm_kms_helper_poll_disable(dev);
+	if (adev->mode_info.use_kms_poll)
+		drm_kms_helper_poll_disable(dev);
 
 	if (fbcon)
 		drm_fb_helper_set_suspend_unlocked(adev_to_drm(adev)->fb_helper, true);
@@ -4243,7 +4244,8 @@ int amdgpu_device_resume(struct drm_device *dev, bool fbcon)
 	if (fbcon)
 		drm_fb_helper_set_suspend_unlocked(adev_to_drm(adev)->fb_helper, false);
 
-	drm_kms_helper_poll_enable(dev);
+	if (adev->mode_info.use_kms_poll)
+		drm_kms_helper_poll_enable(dev);
 
 	amdgpu_ras_resume(adev);
 
drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +1 -0
index 32fe05c810c6..d383ea3e8e94 100644
@@ -343,6 +343,7 @@ struct amdgpu_mode_info {
 	int			disp_priority;
 	const struct amdgpu_display_funcs *funcs;
 	const enum drm_plane_type *plane_type;
+	bool use_kms_poll;
 };
 
 #define AMDGPU_MAX_BL_LEVEL 0xFF
drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c +1 -0
index 53ff91fc6cf6..3277799a80bb 100644
@@ -518,6 +518,7 @@ static int amdgpu_vkms_sw_init(void *handle)
 		return r;
 
 	drm_kms_helper_poll_init(adev_to_drm(adev));
+	adev->mode_info.use_kms_poll = true;
 
 	adev->mode_info.mode_config_initialized = true;
 	return 0;
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +1 -0
index 9a24ed463abd..f4d0a7cf588b 100644
@@ -2842,6 +2842,7 @@ static int dce_v10_0_sw_init(void *handle)
 		  amdgpu_display_hotplug_work_func);
 
 	drm_kms_helper_poll_init(adev_to_drm(adev));
+	adev->mode_info.use_kms_poll = true;
 
 	adev->mode_info.mode_config_initialized = true;
 	return 0;
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +1 -0
index c14b70350a51..25d0a866ca28 100644
@@ -2961,6 +2961,7 @@ static int dce_v11_0_sw_init(void *handle)
 		  amdgpu_display_hotplug_work_func);
 
 	drm_kms_helper_poll_init(adev_to_drm(adev));
+	adev->mode_info.use_kms_poll = true;
 
 	adev->mode_info.mode_config_initialized = true;
 	return 0;
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +1 -0
index 7f85ba5b726f..3936c6bfe2e3 100644
@@ -2720,6 +2720,7 @@ static int dce_v6_0_sw_init(void *handle)
 		  amdgpu_display_hotplug_work_func);
 
 	drm_kms_helper_poll_init(adev_to_drm(adev));
+	adev->mode_info.use_kms_poll = true;
 
 	return r;
 }
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +1 -0
index d421a268c9ff..29fb837f5ebf 100644
@@ -2744,6 +2744,7 @@ static int dce_v8_0_sw_init(void *handle)
 		  amdgpu_display_hotplug_work_func);
 
 	drm_kms_helper_poll_init(adev_to_drm(adev));
+	adev->mode_info.use_kms_poll = true;
 
 	adev->mode_info.mode_config_initialized = true;
 	return 0;
Signature · 1 line
2.25.1
#1 lore raw
Quoted 52 lines · Guchun Chen

Some amd asics having reliable hotplug support don't call drm_kms_helper_poll_init in driver init sequence. However, due to the unified suspend/resume path for all asics, because the output_poll_work->func is not set for these asics, a warning arrives when suspending.

[   90.656049]  <TASK>
[   90.656050]  ? console_unlock+0x4d/0x100
[   90.656053]  ? __irq_work_queue_local+0x27/0x60
[   90.656056]  ? irq_work_queue+0x2b/0x50
[   90.656057]  ? __wake_up_klogd+0x40/0x60
[   90.656059]  __cancel_work_timer+0xed/0x180
[   90.656061]  drm_kms_helper_poll_disable.cold+0x1f/0x2c [drm_kms_helper]
[   90.656072]  amdgpu_device_suspend+0x81/0x170 [amdgpu]
[   90.656180]  amdgpu_pmops_runtime_suspend+0xb5/0x1b0 [amdgpu]
[   90.656269]  pci_pm_runtime_suspend+0x61/0x1b0

So add use_kms_poll flag as the initialization check in amdgpu code before calling drm_kms_helper_poll_disable/drm_kms_helper_poll_enable in suspend/resume path.

Fixes a4e771729a51("drm/probe_helper: sort out poll_running vs poll_enabled")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 ++++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h   | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c   | 1 +
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c     | 1 +
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c     | 1 +
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c      | 1 +
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c      | 1 +
 7 files changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -1
index c4a4e2fe6681..74af0b8c0d08 100644
@@ -4145,7 +4145,8 @@ int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)
        if (amdgpu_acpi_smart_shift_update(dev, AMDGPU_SS_DEV_D3))
                DRM_WARN("smart shift update failed\n");
 
-       drm_kms_helper_poll_disable(dev);
+       if (adev->mode_info.use_kms_poll)
+               drm_kms_helper_poll_disable(dev);
 
        if (fbcon)
                drm_fb_helper_set_suspend_unlocked(adev_to_drm(adev)->fb_helper, true);

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device *dev, bool fbcon) · line 4249

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -1
@@ -4243,7 +4244,8 @@ int amdgpu_device_resume(struct drm_device *dev, bool fbcon)
        if (fbcon)
                drm_fb_helper_set_suspend_unlocked(adev_to_drm(adev)->fb_helper, false);
 
-       drm_kms_helper_poll_enable(dev);
+       if (adev->mode_info.use_kms_poll)
+               drm_kms_helper_poll_enable(dev);
 

Since polling is only enabled for analog outputs and DC doesn't support any analog outputs, I think we can simplify this to

(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index c4a4e2fe6681..74af0b8c0d08 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
@@ -4145,7 +4145,8 @@ int amdgpu_device_suspend(struct drm_device

*dev, bool fbcon)
if (amdgpu_acpi_smart_shift_update(dev, AMDGPU_SS_DEV_D3)) DRM_WARN("smart shift update failed\n");

- drm_kms_helper_poll_disable(dev);
+ if (!adev->dc_enabled)
+ drm_kms_helper_poll_disable(dev);

if (fbcon) drm_fb_helper_set_suspend_unlocked(adev_to_drm(adev)->fb_helper, true);
@@ -4243,7 +4244,8 @@ int amdgpu_device_resume(struct drm_device *dev, bool fbcon)
if (fbcon) drm_fb_helper_set_suspend_unlocked(adev_to_drm(adev)->fb_helper, false);

- drm_kms_helper_poll_enable(dev);
+ if (!adev->dc_enabled)
+ drm_kms_helper_poll_enable(dev);

  amdgpu_ras_resume(adev);

Alternatively, we could also just move drm_kms_helper_poll_disable() into amdgpu_display_suspend_helper() and drm_kms_helper_poll_enable() into amdgpu_display_resume_helper(), but I'm not sure if the ordering here is important or not off hand.

Alex

Quoted 77 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
        amdgpu_ras_resume(adev);
 
drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +1 -0
index 32fe05c810c6..d383ea3e8e94 100644
@@ -343,6 +343,7 @@ struct amdgpu_mode_info {
        int                     disp_priority;
        const struct amdgpu_display_funcs *funcs;
        const enum drm_plane_type *plane_type;
+       bool use_kms_poll;
 };
 
 #define AMDGPU_MAX_BL_LEVEL 0xFF
drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c +1 -0
index 53ff91fc6cf6..3277799a80bb 100644
@@ -518,6 +518,7 @@ static int amdgpu_vkms_sw_init(void *handle)
                return r;
 
        drm_kms_helper_poll_init(adev_to_drm(adev));
+       adev->mode_info.use_kms_poll = true;
 
        adev->mode_info.mode_config_initialized = true;
        return 0;
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +1 -0
index 9a24ed463abd..f4d0a7cf588b 100644
@@ -2842,6 +2842,7 @@ static int dce_v10_0_sw_init(void *handle)
                  amdgpu_display_hotplug_work_func);
 
        drm_kms_helper_poll_init(adev_to_drm(adev));
+       adev->mode_info.use_kms_poll = true;
 
        adev->mode_info.mode_config_initialized = true;
        return 0;
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +1 -0
index c14b70350a51..25d0a866ca28 100644
@@ -2961,6 +2961,7 @@ static int dce_v11_0_sw_init(void *handle)
                  amdgpu_display_hotplug_work_func);
 
        drm_kms_helper_poll_init(adev_to_drm(adev));
+       adev->mode_info.use_kms_poll = true;
 
        adev->mode_info.mode_config_initialized = true;
        return 0;
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +1 -0
index 7f85ba5b726f..3936c6bfe2e3 100644
@@ -2720,6 +2720,7 @@ static int dce_v6_0_sw_init(void *handle)
                  amdgpu_display_hotplug_work_func);
 
        drm_kms_helper_poll_init(adev_to_drm(adev));
+       adev->mode_info.use_kms_poll = true;
 
        return r;
 }
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +1 -1
index d421a268c9ff..29fb837f5ebf 100644
@@ -2744,6 +2744,7 @@ static int dce_v8_0_sw_init(void *handle)
                  amdgpu_display_hotplug_work_func);
 
        drm_kms_helper_poll_init(adev_to_drm(adev));
+       adev->mode_info.use_kms_poll = true;
 
        adev->mode_info.mode_config_initialized = true;
        return 0;
--

2.25.1

#2 lore raw

Relying on dc_enabled will be more simple, thanks for your suggestion. I will send v2 to address this.

Regards,
Guchun

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Thursday, March 9, 2023 12:29 AM
To: Chen, Guchun <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: add flag to enable/disable poll in suspend/resume path

Quoted 60 lines · Guchun Chen

Some amd asics having reliable hotplug support don't call drm_kms_helper_poll_init in driver init sequence. However, due to the unified suspend/resume path for all asics, because the output_poll_work->func is not set for these asics, a warning arrives when suspending.

[   90.656049]  <TASK>
[   90.656050]  ? console_unlock+0x4d/0x100
[   90.656053]  ? __irq_work_queue_local+0x27/0x60
[   90.656056]  ? irq_work_queue+0x2b/0x50
[   90.656057]  ? __wake_up_klogd+0x40/0x60
[   90.656059]  __cancel_work_timer+0xed/0x180
[   90.656061]  drm_kms_helper_poll_disable.cold+0x1f/0x2c [drm_kms_helper]
[   90.656072]  amdgpu_device_suspend+0x81/0x170 [amdgpu]
[   90.656180]  amdgpu_pmops_runtime_suspend+0xb5/0x1b0 [amdgpu]
[   90.656269]  pci_pm_runtime_suspend+0x61/0x1b0

So add use_kms_poll flag as the initialization check in amdgpu code before calling drm_kms_helper_poll_disable/drm_kms_helper_poll_enable in suspend/resume path.

Fixes a4e771729a51("drm/probe_helper: sort out poll_running vs

poll_enabled")

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 ++++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h   | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c   | 1 +
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c     | 1 +
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c     | 1 +
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c      | 1 +
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c      | 1 +
 7 files changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -1
index c4a4e2fe6681..74af0b8c0d08 100644
@@ -4145,7 +4145,8 @@ int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)
        if (amdgpu_acpi_smart_shift_update(dev, AMDGPU_SS_DEV_D3))
                DRM_WARN("smart shift update failed\n");
 
-       drm_kms_helper_poll_disable(dev);
+       if (adev->mode_info.use_kms_poll)
+               drm_kms_helper_poll_disable(dev);
 
        if (fbcon)
 

drm_fb_helper_set_suspend_unlocked(adev_to_drm(adev)->fb_helper, true); @@ -4243,7 +4244,8 @@ int amdgpu_device_resume(struct drm_device *dev, bool fbcon)
if (fbcon)

drm_fb_helper_set_suspend_unlocked(adev_to_drm(adev)->fb_helper, false);

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -1
-       drm_kms_helper_poll_enable(dev);
+       if (adev->mode_info.use_kms_poll)
+               drm_kms_helper_poll_enable(dev);

Since polling is only enabled for analog outputs and DC doesn't support any analog outputs, I think we can simplify this to

(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index c4a4e2fe6681..74af0b8c0d08 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -1
@@ -4145,7 +4145,8 @@ int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)
  if (amdgpu_acpi_smart_shift_update(dev, AMDGPU_SS_DEV_D3))
  DRM_WARN("smart shift update failed\n");
 
- drm_kms_helper_poll_disable(dev);
+ if (!adev->dc_enabled)
+ drm_kms_helper_poll_disable(dev);
 
  if (fbcon)
  drm_fb_helper_set_suspend_unlocked(adev_to_drm(adev)->fb_helper, true); @@ -4243,7 +4244,8 @@ int amdgpu_device_resume(struct drm_device *dev, bool fbcon)

if (fbcon) drm_fb_helper_set_suspend_unlocked(adev_to_drm(adev)->fb_helper, false);

- drm_kms_helper_poll_enable(dev);
+ if (!adev->dc_enabled)
+ drm_kms_helper_poll_enable(dev);

  amdgpu_ras_resume(adev);

Alternatively, we could also just move drm_kms_helper_poll_disable() into amdgpu_display_suspend_helper() and drm_kms_helper_poll_enable() into amdgpu_display_resume_helper(), but I'm not sure if the ordering here is important or not off hand.

Alex

Quoted 83 lines
        amdgpu_ras_resume(adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +1 -0
index 32fe05c810c6..d383ea3e8e94 100644
@@ -343,6 +343,7 @@ struct amdgpu_mode_info {
        int                     disp_priority;
        const struct amdgpu_display_funcs *funcs;
        const enum drm_plane_type *plane_type;
+       bool use_kms_poll;
 };
 
 #define AMDGPU_MAX_BL_LEVEL 0xFF
drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c +1 -0
index 53ff91fc6cf6..3277799a80bb 100644
@@ -518,6 +518,7 @@ static int amdgpu_vkms_sw_init(void *handle)
                return r;
 
        drm_kms_helper_poll_init(adev_to_drm(adev));
+       adev->mode_info.use_kms_poll = true;
 
        adev->mode_info.mode_config_initialized = true;
        return 0;
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +1 -0
index 9a24ed463abd..f4d0a7cf588b 100644
@@ -2842,6 +2842,7 @@ static int dce_v10_0_sw_init(void *handle)
                  amdgpu_display_hotplug_work_func);
 
        drm_kms_helper_poll_init(adev_to_drm(adev));
+       adev->mode_info.use_kms_poll = true;
 
        adev->mode_info.mode_config_initialized = true;
        return 0;
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +1 -0
index c14b70350a51..25d0a866ca28 100644
@@ -2961,6 +2961,7 @@ static int dce_v11_0_sw_init(void *handle)
                  amdgpu_display_hotplug_work_func);
 
        drm_kms_helper_poll_init(adev_to_drm(adev));
+       adev->mode_info.use_kms_poll = true;
 
        adev->mode_info.mode_config_initialized = true;
        return 0;
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +1 -0
index 7f85ba5b726f..3936c6bfe2e3 100644
@@ -2720,6 +2720,7 @@ static int dce_v6_0_sw_init(void *handle)
                  amdgpu_display_hotplug_work_func);
 
        drm_kms_helper_poll_init(adev_to_drm(adev));
+       adev->mode_info.use_kms_poll = true;
 
        return r;
 }
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +1 -1
index d421a268c9ff..29fb837f5ebf 100644
@@ -2744,6 +2744,7 @@ static int dce_v8_0_sw_init(void *handle)
                  amdgpu_display_hotplug_work_func);
 
        drm_kms_helper_poll_init(adev_to_drm(adev));
+       adev->mode_info.use_kms_poll = true;
 
        adev->mode_info.mode_config_initialized = true;
        return 0;
--

2.25.1