Skip to contentSkip to conversation

drm/amdgpu/dm/mst: Fix incorrect usage of drm_dp_add_payload_part2()

PATCH In review Lyude Paul 3 participants 5 messages Oct 4, 2022 – Oct 19, 2022

Subsystems (3)
lore
Share & tools
lore

Lyude Paul

author
#0 lore raw

PATCH 1/1 drm/amdgpu/dm/mst: Fix incorrect usage of drm_dp_add_payload_part2()

Yikes, it appears somehow I totally made a mistake here. We're currently checking to see if drm_dp_add_payload_part2() returns a non-zero value to indicate success. That's totally wrong though, as this function only returns a zero value on success - not the other way around.

So, fix that.

Issue: https://gitlab.freedesktop.org/drm/amd/-/issues/2171

Fixes 4d07b0bc4034 ("drm/display/dp_mst: Move all payload info into the atomic state")
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +1 -1
index b8077fcd4651..00598def5b39 100644
@@ -297,7 +297,7 @@ bool dm_helpers_dp_mst_send_payload_allocation(
 		clr_flag = MST_ALLOCATE_NEW_PAYLOAD;
 	}
 
-	if (enable && drm_dp_add_payload_part2(mst_mgr, mst_state->base.state, payload)) {
+	if (enable && drm_dp_add_payload_part2(mst_mgr, mst_state->base.state, payload) == 0) {
 		amdgpu_dm_set_mst_status(&aconnector->mst_status,
 			set_flag, false);
 	} else {
Signature · 1 line
2.37.3
#1 lore raw
Quoted 19 lines · Lyude Paul

Yikes, it appears somehow I totally made a mistake here. We're currently checking to see if drm_dp_add_payload_part2() returns a non-zero value to indicate success. That's totally wrong though, as this function only returns a zero value on success - not the other way around.

So, fix that.

Issue: https://gitlab.freedesktop.org/drm/amd/-/issues/2171

Fixes 4d07b0bc4034 ("drm/display/dp_mst: Move all payload info into the atomic state")
---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +0 -0
index b8077fcd4651..00598def5b39 100644

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c bool dm_helpers_dp_mst_send_payload_allocation( · line 303

Quoted 8 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +1 -1
@@ -297,7 +297,7 @@ bool dm_helpers_dp_mst_send_payload_allocation(
  		clr_flag = MST_ALLOCATE_NEW_PAYLOAD;
  	}
 
-	if (enable && drm_dp_add_payload_part2(mst_mgr, mst_state->base.state, payload)) {
+	if (enable && drm_dp_add_payload_part2(mst_mgr, mst_state->base.state, payload) == 0) {
  		amdgpu_dm_set_mst_status(&aconnector->mst_status,
  			set_flag, false);
  	} else {

Hi Lyude,

Maybe I'm missing something, but I can't find the drm_dp_add_payload_part2() function on amd-staging-drm-next. Which repo are you using?

Thanks
Siqueira

author
#2 lore raw
Quoted 32 lines · Rodrigo Siqueira Jordao
Quoted 19 lines · Lyude Paul

Yikes, it appears somehow I totally made a mistake here. We're currently checking to see if drm_dp_add_payload_part2() returns a non-zero value to indicate success. That's totally wrong though, as this function only returns a zero value on success - not the other way around.

So, fix that.

Issue: https://gitlab.freedesktop.org/drm/amd/-/issues/2171

Fixes 4d07b0bc4034 ("drm/display/dp_mst: Move all payload info into the atomic state")
---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +0 -0
index b8077fcd4651..00598def5b39 100644

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c bool dm_helpers_dp_mst_send_payload_allocation( · line 303

Quoted 8 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +1 -1
@@ -297,7 +297,7 @@ bool dm_helpers_dp_mst_send_payload_allocation(
  		clr_flag = MST_ALLOCATE_NEW_PAYLOAD;
  	}
 
-	if (enable && drm_dp_add_payload_part2(mst_mgr, mst_state->base.state, payload)) {
+	if (enable && drm_dp_add_payload_part2(mst_mgr, mst_state->base.state, payload) == 0) {
  		amdgpu_dm_set_mst_status(&aconnector->mst_status,
  			set_flag, false);
  	} else {

Hi Lyude,

Quoted 3 lines

Maybe I'm missing something, but I can't find the drm_dp_add_payload_part2() function on amd-staging-drm-next. Which repo are you using?

If it's not on amd-staging-drm-next then it likely hasn't gotten backported to amd's branch yet and is in drm-misc-next

Quoted 4 lines

Thanks
Siqueira

Signature · 3 lines
Cheers,
 Lyude Paul (she/her)
 Software Engineer at Red Hat
#3 lore raw

[Public]

Quoted 64 lines

-----Original Message-----
From: Lyude Paul <[email protected]>
Sent: Thursday, October 6, 2022 3:37 AM
To: Siqueira, Rodrigo <[email protected]>; dri- [email protected]; [email protected]
Cc: Wentland, Harry <[email protected]>; Li, Sun peng (Leo) <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>; Zuo, Jerry <[email protected]>; Lin, Wayne <[email protected]>; Chen, Ian <[email protected]>; Mikita Lipski <[email protected]>; Mahfooz, Hamza <[email protected]>; Claudio Suarez <[email protected]>; Colin Ian King <[email protected]>; Jani Nikula <[email protected]>; open list <[email protected]>
Subject: Re: [PATCH] drm/amdgpu/dm/mst: Fix incorrect usage of drm_dp_add_payload_part2()

Quoted 6 lines · Rodrigo Siqueira Jordao
Quoted 4 lines · Lyude Paul

Yikes, it appears somehow I totally made a mistake here. We're currently checking to see if drm_dp_add_payload_part2() returns a non-zero value to indicate success. That's totally wrong though, as this function only returns a zero value on success - not the other way

around.

Quoted 6 lines
Quoted 6 lines

So, fix that.

Issue:

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgi

Quoted 1 line
Quoted 1 line

tlab.freedesktop.org%2Fdrm%2Famd%2F-

%2Fissues%2F2171&amp;data=05%7C0

Quoted 1 line
Quoted 1 line

1%7Cwayne.lin%40amd.com%7Ccd5a63120e064f4bb6aa08daa7090baf%7C3d d8961

Quoted 1 line
Quoted 1 line

fe4884e608e11a82d994e183d%7C0%7C0%7C638005954559719396%7CUnkno wn%7CT

Quoted 1 line
Quoted 1 line

WFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLC JXV

Quoted 1 line
Quoted 1 line

CI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=nMIGnUKS6EDrdKJ0rR%2BAh FRa4ST0%2

Quoted 5 lines
Quoted 5 lines

BYr9bILmXv40yv0%3D&amp;reserved=0

Fixes 4d07b0bc4034 ("drm/display/dp_mst: Move all payload info into

the atomic state")

---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 2
+-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 7 lines
Quoted 7 lines

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c index b8077fcd4651..00598def5b39 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
+++

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

Quoted 1 line

Review bool

Quoted 1 line
(quoted diff) +0 -0
@@ -297,7 +297,7 @@ bool

dm_helpers_dp_mst_send_payload_allocation(

Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c bool dm_helpers_dp_mst_send_payload_allocation(

Quoted 4 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +0 -1
  		clr_flag = MST_ALLOCATE_NEW_PAYLOAD;
  	}
 
-	if (enable && drm_dp_add_payload_part2(mst_mgr, mst_state-

base.state, payload)) {

Review bool · line 301

Quoted 2 lines
(quoted diff) +2 -0
+	if (enable && drm_dp_add_payload_part2(mst_mgr,
+mst_state->base.state, payload) == 0) {

Hi Lyude,

This line changes the original logic a bit. The 'if' case was trying to catch failure while sending ALLOCATE_PAYLOAD. If the msg fails, set the set_flag to false. If succeed, set the set_flag to true and clear the clr_flag.

Sorry if the code wording misleading. Thanks!

Quoted 14 lines
Quoted 9 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c bool dm_helpers_dp_mst_send_payload_allocation( · line 303

Quoted 3 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +0 -0
  		amdgpu_dm_set_mst_status(&aconnector->mst_status,
  			set_flag, false);
  	} else {

Hi Lyude,

Maybe I'm missing something, but I can't find the drm_dp_add_payload_part2() function on amd-staging-drm-next. Which repo are you using?

If it's not on amd-staging-drm-next then it likely hasn't gotten backported to amd's branch yet and is in drm-misc-next

Quoted 1 line
Quoted 8 lines
Quoted 3 lines

Thanks
Siqueira

--
Cheers,
Lyude Paul (she/her)
Software Engineer at Red Hat

--
Regards,
Wayne Lin

author
#4 lore raw

Gotcha, I'll take another look at this tomorrow

Quoted 110 lines · Wayne

[Public]

Quoted 64 lines

-----Original Message-----
From: Lyude Paul <[email protected]>
Sent: Thursday, October 6, 2022 3:37 AM
To: Siqueira, Rodrigo <[email protected]>; dri- [email protected]; [email protected]
Cc: Wentland, Harry <[email protected]>; Li, Sun peng (Leo) <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>; Zuo, Jerry <[email protected]>; Lin, Wayne <[email protected]>; Chen, Ian <[email protected]>; Mikita Lipski <[email protected]>; Mahfooz, Hamza <[email protected]>; Claudio Suarez <[email protected]>; Colin Ian King <[email protected]>; Jani Nikula <[email protected]>; open list <[email protected]>
Subject: Re: [PATCH] drm/amdgpu/dm/mst: Fix incorrect usage of drm_dp_add_payload_part2()

Quoted 6 lines · Rodrigo Siqueira Jordao
Quoted 4 lines · Lyude Paul

Yikes, it appears somehow I totally made a mistake here. We're currently checking to see if drm_dp_add_payload_part2() returns a non-zero value to indicate success. That's totally wrong though, as this function only returns a zero value on success - not the other way

around.

Quoted 6 lines
Quoted 6 lines

So, fix that.

Issue:

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgi

Quoted 1 line
Quoted 1 line

tlab.freedesktop.org%2Fdrm%2Famd%2F-

%2Fissues%2F2171&amp;data=05%7C0

Quoted 1 line
Quoted 1 line

1%7Cwayne.lin%40amd.com%7Ccd5a63120e064f4bb6aa08daa7090baf%7C3d d8961

Quoted 1 line
Quoted 1 line

fe4884e608e11a82d994e183d%7C0%7C0%7C638005954559719396%7CUnkno wn%7CT

Quoted 1 line
Quoted 1 line

WFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLC JXV

Quoted 1 line
Quoted 1 line

CI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=nMIGnUKS6EDrdKJ0rR%2BAh FRa4ST0%2

Quoted 5 lines
Quoted 5 lines

BYr9bILmXv40yv0%3D&amp;reserved=0

Fixes 4d07b0bc4034 ("drm/display/dp_mst: Move all payload info into

the atomic state")

---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 2
+-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 7 lines
Quoted 7 lines

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c index b8077fcd4651..00598def5b39 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
+++

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

Quoted 1 line

Review bool

Quoted 1 line
(quoted diff) +0 -0
@@ -297,7 +297,7 @@ bool

dm_helpers_dp_mst_send_payload_allocation(

Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c bool dm_helpers_dp_mst_send_payload_allocation(

Quoted 4 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +0 -1
  		clr_flag = MST_ALLOCATE_NEW_PAYLOAD;
  	}
 
-	if (enable && drm_dp_add_payload_part2(mst_mgr, mst_state-

base.state, payload)) {

Review bool · line 301

Quoted 2 lines
(quoted diff) +2 -0
+	if (enable && drm_dp_add_payload_part2(mst_mgr,
+mst_state->base.state, payload) == 0) {

Hi Lyude,

This line changes the original logic a bit. The 'if' case was trying to catch failure while sending ALLOCATE_PAYLOAD. If the msg fails, set the set_flag to false. If succeed, set the set_flag to true and clear the clr_flag.

Sorry if the code wording misleading. Thanks!

Quoted 14 lines
Quoted 9 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c bool dm_helpers_dp_mst_send_payload_allocation( · line 303

Quoted 3 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +0 -0
  		amdgpu_dm_set_mst_status(&aconnector->mst_status,
  			set_flag, false);
  	} else {

Hi Lyude,

Maybe I'm missing something, but I can't find the drm_dp_add_payload_part2() function on amd-staging-drm-next. Which repo are you using?

If it's not on amd-staging-drm-next then it likely hasn't gotten backported to amd's branch yet and is in drm-misc-next

Quoted 1 line
Quoted 8 lines
Quoted 3 lines

Thanks
Siqueira

--
Cheers,
Lyude Paul (she/her)
Software Engineer at Red Hat

--
Regards,
Wayne Lin

Signature · 3 lines
Cheers,
 Lyude Paul (she/her)
 Software Engineer at Red Hat