Skip to contentSkip to conversation

drm/amd/display: Fix memory leaks in S3 resume

PATCH In review Stylon Wang 4 participants 8 messages Nov 10, 2020 – Dec 21, 2020

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

PATCH 1/1 drm/amd/display: Fix memory leaks in S3 resume

EDID parsing in S3 resume pushes new display modes
to probed_modes list but doesn't consolidate to actual mode list. This creates a race condition when amdgpu_dm_connector_ddc_get_modes() re-initializes the list head without walking the list and results in memory leak.

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -1
index 0b6adf23d316..715e0bd489f8 100644
@@ -2337,7 +2337,8 @@ void amdgpu_dm_update_connector_after_detect(
 
 			drm_connector_update_edid_property(connector,
 							   aconnector->edid);
-			drm_add_edid_modes(connector, aconnector->edid);
+			aconnector->num_modes = drm_add_edid_modes(connector, aconnector->edid);
+			drm_connector_list_update(connector);
 
 			if (aconnector->dc_link->aux_mode)
 				drm_dp_cec_set_edid(&aconnector->dm_dp_aux.aux,
Signature · 6 lines
2.25.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Stylon Wang

EDID parsing in S3 resume pushes new display modes
to probed_modes list but doesn't consolidate to actual mode list. This creates a race condition when amdgpu_dm_connector_ddc_get_modes() re-initializes the list head without walking the list and results in memory leak.

Looks reasonable to me but haven't had a chance to understand whether this is the best solution.

Harry

Quoted 10 lines
---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
index 0b6adf23d316..715e0bd489f8 100644

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_update_connector_after_detect( · line 2344

Quoted 9 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -1
@@ -2337,7 +2337,8 @@ void amdgpu_dm_update_connector_after_detect(
 
  			drm_connector_update_edid_property(connector,
  							   aconnector->edid);
-			drm_add_edid_modes(connector, aconnector->edid);
+			aconnector->num_modes = drm_add_edid_modes(connector, aconnector->edid);
+			drm_connector_list_update(connector);
 
  			if (aconnector->dc_link->aux_mode)
  				drm_dp_cec_set_edid(&aconnector->dm_dp_aux.aux,

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

maintainer Acked-by Harry Wentland
#2 lore raw

[AMD Official Use Only - Internal Distribution Only]

Lee Starnes just sent the exact same patch yesterday. Please review that one:
https://patchwork.freedesktop.org/patch/399497/

Alex

________________________________
From: Wentland, Harry <[email protected]>
Sent: Tuesday, November 10, 2020 9:27 AM
To: Wang, Chao-kai (Stylon) <[email protected]>; [email protected] <[email protected]>
Cc: Kazlauskas, Nicholas <[email protected]>; Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amd/display: Fix memory leaks in S3 resume

Quoted 7 lines · Stylon Wang

EDID parsing in S3 resume pushes new display modes
to probed_modes list but doesn't consolidate to actual mode list. This creates a race condition when amdgpu_dm_connector_ddc_get_modes() re-initializes the list head without walking the list and results in memory leak.

Looks reasonable to me but haven't had a chance to understand whether this is the best solution.

Harry

Quoted 10 lines
---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
index 0b6adf23d316..715e0bd489f8 100644

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_update_connector_after_detect( · line 2344

Quoted 9 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -1
@@ -2337,7 +2337,8 @@ void amdgpu_dm_update_connector_after_detect(
 
                       drm_connector_update_edid_property(connector,
                                                          aconnector->edid);
-                     drm_add_edid_modes(connector, aconnector->edid);
+                     aconnector->num_modes = drm_add_edid_modes(connector, aconnector->edid);
+                     drm_connector_list_update(connector);
 
                       if (aconnector->dc_link->aux_mode)
                               drm_dp_cec_set_edid(&aconnector->dm_dp_aux.aux,

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

maintainer
#3 lore raw

It's missing the "drm_connector_list_update" call which I assume is important.

Stylon, can you review Lee Starnes's patch? Is the drm_connector_list_update call maybe not needed?

Thanks,
Harry

Quoted 42 lines · Alexander

[AMD Official Use Only - Internal Distribution Only]

Lee Starnes just sent the exact same patch yesterday.  Please review that one:
https://patchwork.freedesktop.org/patch/399497/ <https://patchwork.freedesktop.org/patch/399497/>

Alex

------------------------------------------------------------------------
*From:* Wentland, Harry <[email protected]>
*Sent:* Tuesday, November 10, 2020 9:27 AM
*To:* Wang, Chao-kai (Stylon) <[email protected]>; [email protected] <[email protected]> *Cc:* Kazlauskas, Nicholas <[email protected]>; Deucher, Alexander <[email protected]> *Subject:* Re: [PATCH] drm/amd/display: Fix memory leaks in S3 resume

Quoted 7 lines · Stylon Wang

EDID parsing in S3 resume pushes new display modes to probed_modes list but doesn't consolidate to actual mode list. This creates a race condition when amdgpu_dm_connector_ddc_get_modes() re-initializes the list head without walking the list and results in memory leak.

Looks reasonable to me but haven't had a chance to understand whether this is the best solution.

Harry

Review

Quoted 5 lines

---
   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++-

   1 file changed, 2 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

Quoted 5 lines

index 0b6adf23d316..715e0bd489f8 100644

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
@@ -2337,7 +2337,8 @@ void amdgpu_dm_update_connector_after_detect(
 
Quoted 10 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_update_connector_after_detect(

Quoted 4 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -1
 drm_connector_update_edid_property(connector,
                                                         aconnector->edid);
-                     drm_add_edid_modes(connector, aconnector->edid);
+                     aconnector->num_modes = 

drm_add_edid_modes(connector, aconnector->edid);

Quoted 5 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -0
+ drm_connector_list_update(connector);
 
                         if (aconnector->dc_link->aux_mode)
 drm_dp_cec_set_edid(&aconnector->dm_dp_aux.aux,

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

maintainer Acked-by Harry Wentland
#4 lore raw

[AMD Official Use Only - Internal Distribution Only]

Ah, sorry, I missed that part of the patch.

Alex

________________________________
From: Wentland, Harry <[email protected]>
Sent: Tuesday, November 10, 2020 11:42 AM
To: Deucher, Alexander <[email protected]>; Wang, Chao-kai (Stylon) <[email protected]>; [email protected] <[email protected]>
Cc: Kazlauskas, Nicholas <[email protected]>
Subject: Re: [PATCH] drm/amd/display: Fix memory leaks in S3 resume

It's missing the "drm_connector_list_update" call which I assume is important.

Stylon, can you review Lee Starnes's patch? Is the drm_connector_list_update call maybe not needed?

Thanks,
Harry

On 2020-11-10 11:26 a.m., Deucher, Alexander wrote:

[AMD Official Use Only - Internal Distribution Only]

Lee Starnes just sent the exact same patch yesterday. Please review that one:
https://patchwork.freedesktop.org/patch/399497/

Alex

________________________________
From: Wentland, Harry <[email protected]><mailto:[email protected]>
Sent: Tuesday, November 10, 2020 9:27 AM
To: Wang, Chao-kai (Stylon) <[email protected]><mailto:[email protected]>; [email protected]<mailto:[email protected]> <[email protected]><mailto:[email protected]>
Cc: Kazlauskas, Nicholas <[email protected]><mailto:[email protected]>; Deucher, Alexander <[email protected]><mailto:[email protected]>
Subject: Re: [PATCH] drm/amd/display: Fix memory leaks in S3 resume

Quoted 7 lines · Stylon Wang

EDID parsing in S3 resume pushes new display modes
to probed_modes list but doesn't consolidate to actual mode list. This creates a race condition when amdgpu_dm_connector_ddc_get_modes() re-initializes the list head without walking the list and results in memory leak.

Looks reasonable to me but haven't had a chance to understand whether this is the best solution.

Harry

Quoted 10 lines
---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
index 0b6adf23d316..715e0bd489f8 100644

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_update_connector_after_detect( · line 2344

Quoted 9 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -1
@@ -2337,7 +2337,8 @@ void amdgpu_dm_update_connector_after_detect(
 
                       drm_connector_update_edid_property(connector,
                                                          aconnector->edid);
-                     drm_add_edid_modes(connector, aconnector->edid);
+                     aconnector->num_modes = drm_add_edid_modes(connector, aconnector->edid);
+                     drm_connector_list_update(connector);
 
                       if (aconnector->dc_link->aux_mode)
                               drm_dp_cec_set_edid(&aconnector->dm_dp_aux.aux,

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

author Acked-by Harry Wentland
#5 lore raw

[AMD Official Use Only - Internal Distribution Only]

Hi Harry,

Checked Lee Starnes's patch. It does not fix the issue but does preserve the tradition of assigning the number of probed modes to aconnector->num_modes, which appears elsewhere in AMD code. I observed in some cases the memory leak is not reproducing (or not detected) even without mine or Lee's fix. Maybe that's why Lee thinks it may fix the leak.

Another way to fix the issue is to not wipe out the probed list by calling INIT_LIST_HEAD() in amdgpu_dm_connector_ddc_get_modes(). But I am not entirely sure what other impact will that do.

I am checking out how everyone is handling resume from S3 so would like some second opinions.

Regards
Regards

Stylon Wang

MTS Software Development Eng. | AMD
Display Solution Team

O +(886) 2-3789-3667 ext. 23667 C +(886) 921-897-142

----------------------------------------------------------------------------------------------------------------------------------

6F, 3, YuanCyu St (NanKang Software Park) Taipei, Taiwan

Facebook<https://www.facebook.com/AMD> | Twitter<https://twitter.com/AMD> | amd.com<http://www.amd.com/>

________________________________
From: Deucher, Alexander <[email protected]>
Sent: November 11, 2020 12:55 AM
To: Wentland, Harry <[email protected]>; Wang, Chao-kai (Stylon) <[email protected]>; [email protected] <[email protected]>
Cc: Kazlauskas, Nicholas <[email protected]>
Subject: Re: [PATCH] drm/amd/display: Fix memory leaks in S3 resume

[AMD Official Use Only - Internal Distribution Only]

Ah, sorry, I missed that part of the patch.

Alex

________________________________
From: Wentland, Harry <[email protected]>
Sent: Tuesday, November 10, 2020 11:42 AM
To: Deucher, Alexander <[email protected]>; Wang, Chao-kai (Stylon) <[email protected]>; [email protected] <[email protected]>
Cc: Kazlauskas, Nicholas <[email protected]>
Subject: Re: [PATCH] drm/amd/display: Fix memory leaks in S3 resume

It's missing the "drm_connector_list_update" call which I assume is important.

Stylon, can you review Lee Starnes's patch? Is the drm_connector_list_update call maybe not needed?

Thanks,
Harry

On 2020-11-10 11:26 a.m., Deucher, Alexander wrote:

[AMD Official Use Only - Internal Distribution Only]

Lee Starnes just sent the exact same patch yesterday. Please review that one:
https://patchwork.freedesktop.org/patch/399497/

Alex

________________________________
From: Wentland, Harry <[email protected]><mailto:[email protected]>
Sent: Tuesday, November 10, 2020 9:27 AM
To: Wang, Chao-kai (Stylon) <[email protected]><mailto:[email protected]>; [email protected]<mailto:[email protected]> <[email protected]><mailto:[email protected]>
Cc: Kazlauskas, Nicholas <[email protected]><mailto:[email protected]>; Deucher, Alexander <[email protected]><mailto:[email protected]>
Subject: Re: [PATCH] drm/amd/display: Fix memory leaks in S3 resume

Quoted 7 lines · Stylon Wang

EDID parsing in S3 resume pushes new display modes
to probed_modes list but doesn't consolidate to actual mode list. This creates a race condition when amdgpu_dm_connector_ddc_get_modes() re-initializes the list head without walking the list and results in memory leak.

Looks reasonable to me but haven't had a chance to understand whether this is the best solution.

Harry

Quoted 10 lines
---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
index 0b6adf23d316..715e0bd489f8 100644

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_update_connector_after_detect( · line 2344

Quoted 9 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -1
@@ -2337,7 +2337,8 @@ void amdgpu_dm_update_connector_after_detect(
 
                       drm_connector_update_edid_property(connector,
                                                          aconnector->edid);
-                     drm_add_edid_modes(connector, aconnector->edid);
+                     aconnector->num_modes = drm_add_edid_modes(connector, aconnector->edid);
+                     drm_connector_list_update(connector);
 
                       if (aconnector->dc_link->aux_mode)
                               drm_dp_cec_set_edid(&aconnector->dm_dp_aux.aux,

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

maintainer Acked-by on v1 1/1
#6 lore raw
In reply to Stylon Wang

[AMD Official Use Only - Internal Distribution Only]

This leak is still present. Can we get this applied?

________________________________
From: Wang, Chao-kai (Stylon) <[email protected]>
Sent: Tuesday, November 10, 2020 2:49 AM
To: [email protected] <[email protected]>
Cc: Wang, Chao-kai (Stylon) <[email protected]>; Kazlauskas, Nicholas <[email protected]>; Deucher, Alexander <[email protected]>; Wentland, Harry <[email protected]>
Subject: [PATCH] drm/amd/display: Fix memory leaks in S3 resume

EDID parsing in S3 resume pushes new display modes
to probed_modes list but doesn't consolidate to actual mode list. This creates a race condition when amdgpu_dm_connector_ddc_get_modes() re-initializes the list head without walking the list and results in memory leak.

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -1
index 0b6adf23d316..715e0bd489f8 100644
@@ -2337,7 +2337,8 @@ void amdgpu_dm_update_connector_after_detect(
 
                         drm_connector_update_edid_property(connector,
                                                            aconnector->edid);
-                       drm_add_edid_modes(connector, aconnector->edid);
+                       aconnector->num_modes = drm_add_edid_modes(connector, aconnector->edid);
+                       drm_connector_list_update(connector);
 
                         if (aconnector->dc_link->aux_mode)
                                 drm_dp_cec_set_edid(&aconnector->dm_dp_aux.aux,

--
2.25.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#7 lore raw

Feel free to merge.

Regards,
Nicholas Kazlauskas

Quoted 39 lines · Alexander

[AMD Official Use Only - Internal Distribution Only]

This leak is still present.  Can we get this applied?

------------------------------------------------------------------------
*From:* Wang, Chao-kai (Stylon) <[email protected]>
*Sent:* Tuesday, November 10, 2020 2:49 AM
*To:* [email protected] <[email protected]>
*Cc:* Wang, Chao-kai (Stylon) <[email protected]>; Kazlauskas, Nicholas <[email protected]>; Deucher, Alexander <[email protected]>; Wentland, Harry <[email protected]> *Subject:* [PATCH] drm/amd/display: Fix memory leaks in S3 resume
EDID parsing in S3 resume pushes new display modes
to probed_modes list but doesn't consolidate to actual
mode list. This creates a race condition when
amdgpu_dm_connector_ddc_get_modes() re-initializes the
list head without walking the list and results in  memory leak.

---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -1
index 0b6adf23d316..715e0bd489f8 100644
@@ -2337,7 +2337,8 @@ void amdgpu_dm_update_connector_after_detect(
 
                          drm_connector_update_edid_property(connector,
 
 aconnector->edid);
-                       drm_add_edid_modes(connector, aconnector->edid);
+                       aconnector->num_modes = 
 drm_add_edid_modes(connector, aconnector->edid);
+                       drm_connector_list_update(connector);
 

                         if (aconnector->dc_link->aux_mode)

Quoted 4 lines

drm_dp_cec_set_edid(&aconnector->dm_dp_aux.aux,

Signature · 1 line
2.25.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx