Skip to contentSkip to conversation

drm/dp_mst: fix drm_dp_dpcd_read return value checks

PATCH In review Simon Ser 2 participants 2 messages Feb 10, 2022

Subsystems (2)
lore
Share & tools
lore

Simon Ser

author
#0 lore raw

PATCH 1/1 drm/dp_mst: fix drm_dp_dpcd_read return value checks

drm_dp_dpcd_read returns the number of bytes read. The previous code would print garbage on DPCD error, and would exit with on error on success.

Fixes cb897542c6d2 ("drm/dp_mst: Fix W=1 warnings")
Cc Lyude Paul <[email protected]>
Cc Benjamin Gaignard <[email protected]>
---
 drivers/gpu/drm/dp/drm_dp_mst_topology.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/dp/drm_dp_mst_topology.c +4 -4
index 11300b53d24f..f5998b7cf602 100644
@@ -4912,21 +4912,21 @@ void drm_dp_mst_dump_topology(struct seq_file *m,
 		int ret;
 
 		ret = drm_dp_dpcd_read(mgr->aux, DP_DPCD_REV, buf, DP_RECEIVER_CAP_SIZE);
-		if (ret) {
+		if (ret != DP_RECEIVER_CAP_SIZE) {
 			seq_printf(m, "dpcd read failed\n");
 			goto out;
 		}
 		seq_printf(m, "dpcd: %*ph\n", DP_RECEIVER_CAP_SIZE, buf);
 
 		ret = drm_dp_dpcd_read(mgr->aux, DP_FAUX_CAP, buf, 2);
-		if (ret) {
+		if (ret != 2) {
 			seq_printf(m, "faux/mst read failed\n");
 			goto out;
 		}
 		seq_printf(m, "faux/mst: %*ph\n", 2, buf);
 
 		ret = drm_dp_dpcd_read(mgr->aux, DP_MSTM_CTRL, buf, 1);
-		if (ret) {
+		if (ret != 1) {
 			seq_printf(m, "mst ctrl read failed\n");
 			goto out;
 		}
@@ -4934,7 +4934,7 @@ void drm_dp_mst_dump_topology(struct seq_file *m,
 
 		/* dump the standard OUI branch header */
 		ret = drm_dp_dpcd_read(mgr->aux, DP_BRANCH_OUI, buf, DP_BRANCH_OUI_HEADER_SIZE);
-		if (ret) {
+		if (ret != DP_BRANCH_OUI_HEADER_SIZE) {
 			seq_printf(m, "branch oui read failed\n");
 			goto out;
 		}

base-commit: ded74cafeea9311c1eaf6fccce963de2516145f7

Signature · 1 line
2.35.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Simon Ser

drm_dp_dpcd_read returns the number of bytes read. The previous code would print garbage on DPCD error, and would exit with on error on success.

I do wish we'd just made dpcd access return 0 when the number of bytes transferred matches the request, and an error otherwise.

BR,
Jani.

Quoted 49 lines
Fixes cb897542c6d2 ("drm/dp_mst: Fix W=1 warnings")
Cc Lyude Paul <[email protected]>
Cc Benjamin Gaignard <[email protected]>
---
 drivers/gpu/drm/dp/drm_dp_mst_topology.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/dp/drm_dp_mst_topology.c +4 -4
index 11300b53d24f..f5998b7cf602 100644
@@ -4912,21 +4912,21 @@ void drm_dp_mst_dump_topology(struct seq_file *m,
 		int ret;
 
 		ret = drm_dp_dpcd_read(mgr->aux, DP_DPCD_REV, buf, DP_RECEIVER_CAP_SIZE);
-		if (ret) {
+		if (ret != DP_RECEIVER_CAP_SIZE) {
 			seq_printf(m, "dpcd read failed\n");
 			goto out;
 		}
 		seq_printf(m, "dpcd: %*ph\n", DP_RECEIVER_CAP_SIZE, buf);
 
 		ret = drm_dp_dpcd_read(mgr->aux, DP_FAUX_CAP, buf, 2);
-		if (ret) {
+		if (ret != 2) {
 			seq_printf(m, "faux/mst read failed\n");
 			goto out;
 		}
 		seq_printf(m, "faux/mst: %*ph\n", 2, buf);
 
 		ret = drm_dp_dpcd_read(mgr->aux, DP_MSTM_CTRL, buf, 1);
-		if (ret) {
+		if (ret != 1) {
 			seq_printf(m, "mst ctrl read failed\n");
 			goto out;
 		}
@@ -4934,7 +4934,7 @@ void drm_dp_mst_dump_topology(struct seq_file *m,
 
 		/* dump the standard OUI branch header */
 		ret = drm_dp_dpcd_read(mgr->aux, DP_BRANCH_OUI, buf, DP_BRANCH_OUI_HEADER_SIZE);
-		if (ret) {
+		if (ret != DP_BRANCH_OUI_HEADER_SIZE) {
 			seq_printf(m, "branch oui read failed\n");
 			goto out;
 		}

base-commit: ded74cafeea9311c1eaf6fccce963de2516145f7

Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center