Skip to contentSkip to conversation

drm/dp_mst: Correct the bug in drm_dp_update_payload_part1()

PATCH Superseded Wayne Lin 3 participants 4 messages Dec 2, 2019 – Dec 3, 2019

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Wayne Lin

author
#0 lore raw

PATCH 1/1 drm/dp_mst: Correct the bug in drm_dp_update_payload_part1()

[Why]
If the payload_state is DP_PAYLOAD_DELETE_LOCAL in series, current code doesn't delete the payload at current index and just move the index to next one after shuffling payloads.

[How]
After shuffling payloads, decide whether to move on index or not according to payload_state of current payload.

---
 drivers/gpu/drm/drm_dp_mst_topology.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_dp_mst_topology.c +2 -1
index 81e92b260d7a..8da5d461ea01 100644
@@ -3176,7 +3176,8 @@ int drm_dp_update_payload_part1(struct drm_dp_mst_topology_mgr *mgr)
 			drm_dp_mst_topology_put_port(port);
 	}
 
-	for (i = 0; i < mgr->max_payloads; i++) {
+	for (i = 0; i < mgr->max_payloads;
+		(mgr->payloads[i].payload_state == DP_PAYLOAD_DELETE_LOCAL) ? i : i++) {
 		if (mgr->payloads[i].payload_state != DP_PAYLOAD_DELETE_LOCAL)
 			continue;
 
Signature · 6 lines
2.17.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Wayne Lin
Sent: 2019/December/01, Sunday 10:59 PM
To: [email protected]; [email protected]
Cc: Zuo, Jerry <[email protected]>; Wentland, Harry <[email protected]>; Kazlauskas, Nicholas <[email protected]>; Lin, Wayne <[email protected]>
Subject: [PATCH] drm/dp_mst: Correct the bug in drm_dp_update_payload_part1()

[Why]
If the payload_state is DP_PAYLOAD_DELETE_LOCAL in series, current code doesn't delete the payload at current index and just move the index to next one after shuffling payloads.

Quoted 5 lines

[How]
After shuffling payloads, decide whether to move on index or not according to payload_state of current payload.

Quoted 26 lines
---
 drivers/gpu/drm/drm_dp_mst_topology.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_dp_mst_topology.c +2 -1
index 81e92b260d7a..8da5d461ea01 100644
@@ -3176,7 +3176,8 @@ int drm_dp_update_payload_part1(struct
 drm_dp_mst_topology_mgr *mgr)
 			drm_dp_mst_topology_put_port(port);
 	}
 
-	for (i = 0; i < mgr->max_payloads; i++) {
+	for (i = 0; i < mgr->max_payloads;
+		(mgr->payloads[i].payload_state ==

DP_PAYLOAD_DELETE_LOCAL) ? i :

drivers/gpu/drm/drm_dp_mst_topology.c +1 -0
+i++) {
 		if (mgr->payloads[i].payload_state !=

DP_PAYLOAD_DELETE_LOCAL)
continue;

--
2.17.1

Quoted 9 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.
freedesktop.org%2Fmailman%2Flistinfo%2Famd- gfx&amp;data=02%7C01%7Czhan.liu%40amd.com%7Cacbf6c9272c44e5642 ca08d776dbf688%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C6 37108559483579263&amp;sdata=JNUpYWZRxNe%2B0%2FCe04fjWRvWh%2 FPp3CASy4FRrg0iHuI%3D&amp;reserved=0

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

Reviewed-by on v1 1/1
#2 lore raw
In reply to Wayne Lin
Quoted 20 lines · Wayne Lin

[Why]
If the payload_state is DP_PAYLOAD_DELETE_LOCAL in series, current code doesn't delete the payload at current index and just move the index to next one after shuffling payloads.

[How]
After shuffling payloads, decide whether to move on index or not according to payload_state of current payload.

---
 drivers/gpu/drm/drm_dp_mst_topology.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_dp_mst_topology.c +0 -0
index 81e92b260d7a..8da5d461ea01 100644

drivers/gpu/drm/drm_dp_mst_topology.c int drm_dp_update_payload_part1(struct · line 3182

Quoted 8 lines
drivers/gpu/drm/drm_dp_mst_topology.c +2 -1
@@ -3176,7 +3176,8 @@ int drm_dp_update_payload_part1(struct
 drm_dp_mst_topology_mgr *mgr)
 			drm_dp_mst_topology_put_port(port);
 	}
 
-	for (i = 0; i < mgr->max_payloads; i++) {
+	for (i = 0; i < mgr->max_payloads;
+		(mgr->payloads[i].payload_state == DP_PAYLOAD_DELETE_LOCAL) ?
 i : i++) {

Took me a moment to figure out what this line was actually doing. Nice catch by the way!

Anyway: let's just drop this line to avoid making things confusing to read, drop i++ from the for loop instead, and just rewrite it so it looks like this:

for (i = 0; i < mgr->max_payloads; /* do nothing */) {
	if (mgr->payloads[i].payload_state != DP_PAYLOAD_DELETE_LOCAL) {
		i++;
		continue;
	}

With those changes, this patch is:

I can go ahead and push these patches to drm-misc for you once you've sent me the v2

Quoted 3 lines
drivers/gpu/drm/drm_dp_mst_topology.c +0 -0
 		if (mgr->payloads[i].payload_state != DP_PAYLOAD_DELETE_LOCAL)

continue;

Signature · 7 lines
Cheers,
	Lyude Paul

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#3 lore raw
Quoted 54 lines

-----Original Message-----
From: Lyude Paul <[email protected]>
Sent: Tuesday, December 3, 2019 8:23 AM
To: Lin, Wayne <[email protected]>; [email protected]; [email protected]
Cc: Kazlauskas, Nicholas <[email protected]>; Wentland, Harry <[email protected]>; Zuo, Jerry <[email protected]>
Subject: Re: [PATCH] drm/dp_mst: Correct the bug in drm_dp_update_payload_part1()

Quoted 20 lines · Wayne Lin

[Why]
If the payload_state is DP_PAYLOAD_DELETE_LOCAL in series, current code doesn't delete the payload at current index and just move the index to next one after shuffling payloads.

[How]
After shuffling payloads, decide whether to move on index or not according to payload_state of current payload.

---
 drivers/gpu/drm/drm_dp_mst_topology.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_dp_mst_topology.c +0 -0
index 81e92b260d7a..8da5d461ea01 100644

drivers/gpu/drm/drm_dp_mst_topology.c int drm_dp_update_payload_part1(struct · line 3182

Quoted 8 lines
drivers/gpu/drm/drm_dp_mst_topology.c +2 -1
@@ -3176,7 +3176,8 @@ int drm_dp_update_payload_part1(struct
 drm_dp_mst_topology_mgr *mgr)
 			drm_dp_mst_topology_put_port(port);
 	}
 
-	for (i = 0; i < mgr->max_payloads; i++) {
+	for (i = 0; i < mgr->max_payloads;
+		(mgr->payloads[i].payload_state == DP_PAYLOAD_DELETE_LOCAL) ?
 i : i++) {

Took me a moment to figure out what this line was actually doing. Nice catch by the way!

Anyway: let's just drop this line to avoid making things confusing to read, drop i++ from the for loop instead, and just rewrite it so it looks like this:

for (i = 0; i < mgr->max_payloads; /* do nothing */) {
	if (mgr->payloads[i].payload_state != DP_PAYLOAD_DELETE_LOCAL) {
		i++;
		continue;
	}
Quoted 4 lines

With those changes, this patch is:

Thanks for your time and sorry for not well organized code. I will send you the v2 right away. Thanks!

Quoted 8 lines

I can go ahead and push these patches to drm-misc for you once you've sent me the v2

Quoted 3 lines
drivers/gpu/drm/drm_dp_mst_topology.c +0 -0
 		if (mgr->payloads[i].payload_state != DP_PAYLOAD_DELETE_LOCAL)

continue;

--
Cheers,
Lyude Paul

--
BR,
Wayne Lin
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel