Skip to contentSkip to conversation

drm/mediatek: Add return value check when reading DPCD

PATCH Superseded Liankun Yang 2 participants 2 messages Nov 28, 2024 – Dec 2, 2024

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/mediatek: Add return value check when reading DPCD

Returns the number of bytes transferred (1) on success. Check the return value to confirm that AUX communication is successful.

Fixes d9e6ea02fc3f ("drm/mediatek: dp: Add MT8195 External DisplayPort support")

---
Changes in V2:
- Modify Fixes in Commit Message.
Per suggestion from the previous thread:
https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/

---
 drivers/gpu/drm/mediatek/mtk_dp.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_dp.c +7 -1
index 1cc916b16471..9dc68ec2ff43 100644
@@ -2101,6 +2101,7 @@ static enum drm_connector_status mtk_dp_bdg_detect(struct drm_bridge *bridge)
 	enum drm_connector_status ret = connector_status_disconnected;
 	bool enabled = mtk_dp->enabled;
 	u8 sink_count = 0;
+	size_t value;
 
 	if (!mtk_dp->train_info.cable_plugged_in)
 		return ret;
@@ -2115,7 +2116,12 @@ static enum drm_connector_status mtk_dp_bdg_detect(struct drm_bridge *bridge)
 	 * function, we just need to check the HPD connection to check
 	 * whether we connect to a sink device.
 	 */
-	drm_dp_dpcd_readb(&mtk_dp->aux, DP_SINK_COUNT, &sink_count);
+	value = drm_dp_dpcd_readb(&mtk_dp->aux, DP_SINK_COUNT, &sink_count);
+	if (value < 0) {
+		drm_err(mtk_dp->drm_dev, "Failed to read DP Sink Count: %zd\n", value);
+		return ret;
+	}
+
 	if (DP_GET_SINK_COUNT(sink_count))
 		ret = connector_status_connected;
 
Signature · 1 line
2.45.2
#1 lore raw
Quoted 30 lines · Liankun Yang

Returns the number of bytes transferred (1) on success. Check the return value to confirm that AUX communication is successful.

Fixes d9e6ea02fc3f ("drm/mediatek: dp: Add MT8195 External DisplayPort support")

---
Changes in V2:
- Modify Fixes in Commit Message.
Per suggestion from the previous thread:
https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/
---
drivers/gpu/drm/mediatek/mtk_dp.c | 8 +++++++-

1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_dp.c +1 -0
index 1cc916b16471..9dc68ec2ff43 100644
@@ -2101,6 +2101,7 @@ static enum drm_connector_status mtk_dp_bdg_detect(struct drm_bridge *bridge)
 	enum drm_connector_status ret = connector_status_disconnected;
 	bool enabled = mtk_dp->enabled;
 	u8 sink_count = 0;
+	size_t value;
 
 	if (!mtk_dp->train_info.cable_plugged_in)
 		return ret;
@@ -2115,7 +2116,12 @@ static enum drm_connector_status mtk_dp_bdg_detect(struct drm_bridge *bridge)
 	 * function, we just need to check the HPD connection to check
 	 * whether we connect to a sink device.

drivers/gpu/drm/mediatek/mtk_dp.c static enum drm_connector_status mtk_dp_bdg_detect(struct drm_bridge *bridge) · line 2126

Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dp.c +6 -1
 	 */
-	drm_dp_dpcd_readb(&mtk_dp->aux, DP_SINK_COUNT, &sink_count);
+	value = drm_dp_dpcd_readb(&mtk_dp->aux, DP_SINK_COUNT, &sink_count);
+	if (value < 0) {
+		drm_err(mtk_dp->drm_dev, "Failed to read DP Sink Count: %zd\n", value);
+		return ret;
+	}
+
 	if (DP_GET_SINK_COUNT(sink_count))
 		ret = connector_status_connected;

Hi Liankun,

thx for your fix.
I think your patch could be improved by using the drm_dp_helper function drm_dp_read_sink_count() ?

Thx,
Guillaume.

Quoted 3 lines
drivers/gpu/drm/mediatek/mtk_dp.c +0 -1
--

2.45.2