Skip to contentSkip to conversation

drm/mediatek: Add return value check when reading DPCD

PATCH Superseded Liankun Yang 3 participants 4 messages Dec 18, 2024 – Jan 3, 2025

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 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 f70ac097a2cf ("drm/mediatek: Add MT8195 Embedded DisplayPort driver")

---
Changes in V3:
- Using drm_dp_read_sink_count() to improve patch. Per suggestion from the previous thread:
https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/

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 | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/mediatek/mtk_dp.c +2 -3
index 36713c176cfc..b26dad8783be 100644
@@ -2100,7 +2100,6 @@ static enum drm_connector_status mtk_dp_bdg_detect(struct drm_bridge *bridge)
 	struct mtk_dp *mtk_dp = mtk_dp_from_bridge(bridge);
 	enum drm_connector_status ret = connector_status_disconnected;
 	bool enabled = mtk_dp->enabled;
-	u8 sink_count = 0;
 
 	if (!mtk_dp->train_info.cable_plugged_in)
 		return ret;
@@ -2115,8 +2114,8 @@ 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);
-	if (DP_GET_SINK_COUNT(sink_count))
+
+	if (drm_dp_read_sink_count(&mtk_dp->aux))
 		ret = connector_status_connected;
 
 	if (!enabled)
Signature · 1 line
2.45.2
Reviewed-by on v3 1/1
#1 lore raw
Quoted 1 line · Liankun Yang

Returns the number of bytes transferred (1) on success.

Hi Liankun,

I'm not sure this statement above is true, you are not returning the number of transferred bytes?

Aside of that little nitpick

Quoted 44 lines

Check the return value to confirm that AUX communication is successful.

Fixes f70ac097a2cf ("drm/mediatek: Add MT8195 Embedded DisplayPort driver")

---
Changes in V3:
- Using drm_dp_read_sink_count() to improve patch. Per suggestion from the previous thread:
https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/

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 | 5 ++---

1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/mediatek/mtk_dp.c +2 -4
index 36713c176cfc..b26dad8783be 100644
@@ -2100,7 +2100,6 @@ static enum drm_connector_status mtk_dp_bdg_detect(struct drm_bridge *bridge)
 	struct mtk_dp *mtk_dp = mtk_dp_from_bridge(bridge);
 	enum drm_connector_status ret = connector_status_disconnected;
 	bool enabled = mtk_dp->enabled;
-	u8 sink_count = 0;
 
 	if (!mtk_dp->train_info.cable_plugged_in)
 		return ret;
@@ -2115,8 +2114,8 @@ 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);
-	if (DP_GET_SINK_COUNT(sink_count))
+
+	if (drm_dp_read_sink_count(&mtk_dp->aux))
 		ret = connector_status_connected;
 
 	if (!enabled)
--

2.45.2

#2 lore raw
Quoted 10 lines · Guillaume Ranquet

External email : Please do not click links or open attachments until you have verified the sender or the content.

Quoted 1 line · Liankun Yang

Returns the number of bytes transferred (1) on success.

Hi Liankun,

Quoted 8 lines

I'm not sure this statement above is true, you are not returning the number of transferred bytes?

Aside of that little nitpick

Hi Guillaume,

1. DRM_DP_READ_SINK_COUNT modification is true, returning the current number of real connection devices.
2. SOME DONGLES Still Source HPD When they do not connected to any sink device. To avoid this, we need to read the sink count to make good to sink devices.Therefore, the current judgment of the number of connected devices is just enough.

Best Regards,
Liankun Yang

Quoted 6 lines
Quoted 6 lines

Check the return value to confirm that AUX communication is successful.

Fixes f70ac097a2cf ("drm/mediatek: Add MT8195 Embedded DisplayPort

driver")

Quoted 6 lines
Quoted 6 lines

---
Changes in V3:
- Using drm_dp_read_sink_count() to improve patch. Per suggestion from the previous thread:

https://urldefense.com/v3/__https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/__;!!CTRNKA9wMg0ARbw!hB4quDn5mHgRtBK-Gf2pmkMN_4MbA66eggh1o8gdUWP7pA72uPoZlmbisRetswwyYSenG2ErIZK6oOaQqdCxdx4$

Quoted 5 lines
Quoted 5 lines

Changes in V2:
- Modify Fixes in Commit Message.
Per suggestion from the previous thread:

https://urldefense.com/v3/__https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/__;!!CTRNKA9wMg0ARbw!hB4quDn5mHgRtBK-Gf2pmkMN_4MbA66eggh1o8gdUWP7pA72uPoZlmbisRetswwyYSenG2ErIZK6oOaQWWaDClg$

Quoted 34 lines
Quoted 34 lines

---
drivers/gpu/drm/mediatek/mtk_dp.c | 5 ++---

1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/mediatek/mtk_dp.c +0 -1
index 36713c176cfc..b26dad8783be 100644
@@ -2100,7 +2100,6 @@ static enum drm_connector_status
 mtk_dp_bdg_detect(struct drm_bridge *bridge)
      struct mtk_dp *mtk_dp = mtk_dp_from_bridge(bridge);
      enum drm_connector_status ret =
 connector_status_disconnected;
      bool enabled = mtk_dp->enabled;
-      u8 sink_count = 0;
 
      if (!mtk_dp->train_info.cable_plugged_in)
              return ret;
drivers/gpu/drm/mediatek/mtk_dp.c +0 -0
@@ -2115,8 +2114,8 @@ 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 +2 -3
-      drm_dp_dpcd_readb(&mtk_dp->aux, DP_SINK_COUNT, &sink_count);
-      if (DP_GET_SINK_COUNT(sink_count))
+
+      if (drm_dp_read_sink_count(&mtk_dp->aux))
              ret = connector_status_connected;
 
      if (!enabled)
--

2.45.2

maintainer
#3 lore raw
In reply to Liankun Yang

Hi, Liankun:

Liankun Yang <[email protected]> 於 2024年12月18日 週三 下午7:35寫道:

Quoted 34 lines

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

Fixes f70ac097a2cf ("drm/mediatek: Add MT8195 Embedded DisplayPort driver")

---
Changes in V3:
- Using drm_dp_read_sink_count() to improve patch. Per suggestion from the previous thread:
https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/

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 | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/mediatek/mtk_dp.c +0 -1
index 36713c176cfc..b26dad8783be 100644
@@ -2100,7 +2100,6 @@ static enum drm_connector_status mtk_dp_bdg_detect(struct drm_bridge *bridge)
        struct mtk_dp *mtk_dp = mtk_dp_from_bridge(bridge);
        enum drm_connector_status ret = connector_status_disconnected;
        bool enabled = mtk_dp->enabled;
-       u8 sink_count = 0;
 
        if (!mtk_dp->train_info.cable_plugged_in)
                return ret;

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

Quoted 7 lines
drivers/gpu/drm/mediatek/mtk_dp.c +2 -2
@@ -2115,8 +2114,8 @@ 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);
-       if (DP_GET_SINK_COUNT(sink_count))
+
+       if (drm_dp_read_sink_count(&mtk_dp->aux))

if (drm_dp_read_sink_count(&mtk_dp->aux) > 0)

With this fix-up, applied to mediatek-drm-fixes [1], thanks.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux.git/log/?h=mediatek-drm-fixes

Regards,
Chun-Kuang.

Quoted 6 lines
drivers/gpu/drm/mediatek/mtk_dp.c +0 -1
                ret = connector_status_connected;
 
        if (!enabled)
--

2.45.2