mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3 1/1] drm/mediatek: Add return value check when reading DPCD
@ 2024-12-18 11:34 Liankun Yang
  2024-12-19  9:51 ` Guillaume Ranquet
  2025-01-02 14:10 ` Chun-Kuang Hu
  0 siblings, 2 replies; 4+ messages in thread
From: Liankun Yang @ 2024-12-18 11:34 UTC (permalink / raw)
  To: chunkuang.hu, p.zabel, airlied, simona, matthias.bgg,
	angelogioacchino.delregno, ck.hu, granquet, dmitry.osipenko,
	rex-bc.chen, jitao.shi, mac.shen, peng.liu, liankun.yang,
	Project_Global_Chrome_Upstream_Group
  Cc: dri-devel, linux-mediatek, linux-arm-kernel, linux-kernel

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")

Signed-off-by: Liankun Yang <liankun.yang@mediatek.com>
---
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/20241128030940.25657-1-liankun.yang@mediatek.com/

Changes in V2:
- Modify Fixes in Commit Message.
Per suggestion from the previous thread:
https://patchwork.kernel.org/project/linux-mediatek/patch/20240930092000.5385-1-liankun.yang@mediatek.com/
---
 drivers/gpu/drm/mediatek/mtk_dp.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c
index 36713c176cfc..b26dad8783be 100644
--- a/drivers/gpu/drm/mediatek/mtk_dp.c
+++ b/drivers/gpu/drm/mediatek/mtk_dp.c
@@ -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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3 1/1] drm/mediatek: Add return value check when reading DPCD
  2024-12-18 11:34 [PATCH v3 1/1] drm/mediatek: Add return value check when reading DPCD Liankun Yang
@ 2024-12-19  9:51 ` Guillaume Ranquet
  2025-01-03  3:02   ` LIANKUN YANG (杨连坤)
  2025-01-02 14:10 ` Chun-Kuang Hu
  1 sibling, 1 reply; 4+ messages in thread
From: Guillaume Ranquet @ 2024-12-19  9:51 UTC (permalink / raw)
  To: Liankun Yang, chunkuang.hu, p.zabel, airlied, simona,
	matthias.bgg, angelogioacchino.delregno, ck.hu, dmitry.osipenko,
	rex-bc.chen, jitao.shi, mac.shen, peng.liu,
	Project_Global_Chrome_Upstream_Group
  Cc: dri-devel, linux-mediatek, linux-arm-kernel, linux-kernel

On Wed, 18 Dec 2024 12:34, Liankun Yang <liankun.yang@mediatek.com> wrote:
>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

Reviewed-by: Guillaume Ranquet <granquet@baylibre.com>

>Check the return value to confirm that AUX communication is successful.
>
>Fixes: f70ac097a2cf ("drm/mediatek: Add MT8195 Embedded DisplayPort driver")
>
>Signed-off-by: Liankun Yang <liankun.yang@mediatek.com>
>---
>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/20241128030940.25657-1-liankun.yang@mediatek.com/
>
>Changes in V2:
>- Modify Fixes in Commit Message.
>Per suggestion from the previous thread:
>https://patchwork.kernel.org/project/linux-mediatek/patch/20240930092000.5385-1-liankun.yang@mediatek.com/
>---
> drivers/gpu/drm/mediatek/mtk_dp.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
>diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c
>index 36713c176cfc..b26dad8783be 100644
>--- a/drivers/gpu/drm/mediatek/mtk_dp.c
>+++ b/drivers/gpu/drm/mediatek/mtk_dp.c
>@@ -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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3 1/1] drm/mediatek: Add return value check when reading DPCD
  2024-12-18 11:34 [PATCH v3 1/1] drm/mediatek: Add return value check when reading DPCD Liankun Yang
  2024-12-19  9:51 ` Guillaume Ranquet
@ 2025-01-02 14:10 ` Chun-Kuang Hu
  1 sibling, 0 replies; 4+ messages in thread
From: Chun-Kuang Hu @ 2025-01-02 14:10 UTC (permalink / raw)
  To: Liankun Yang
  Cc: chunkuang.hu, p.zabel, airlied, simona, matthias.bgg,
	angelogioacchino.delregno, ck.hu, granquet, dmitry.osipenko,
	rex-bc.chen, jitao.shi, mac.shen, peng.liu,
	Project_Global_Chrome_Upstream_Group, dri-devel, linux-mediatek,
	linux-arm-kernel, linux-kernel

Hi, Liankun:

Liankun Yang <liankun.yang@mediatek.com> 於 2024年12月18日 週三 下午7:35寫道:
>
> 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")
>
> Signed-off-by: Liankun Yang <liankun.yang@mediatek.com>
> ---
> 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/20241128030940.25657-1-liankun.yang@mediatek.com/
>
> Changes in V2:
> - Modify Fixes in Commit Message.
> Per suggestion from the previous thread:
> https://patchwork.kernel.org/project/linux-mediatek/patch/20240930092000.5385-1-liankun.yang@mediatek.com/
> ---
>  drivers/gpu/drm/mediatek/mtk_dp.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c
> index 36713c176cfc..b26dad8783be 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dp.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dp.c
> @@ -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))

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.

>                 ret = connector_status_connected;
>
>         if (!enabled)
> --
> 2.45.2
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3 1/1] drm/mediatek: Add return value check when reading DPCD
  2024-12-19  9:51 ` Guillaume Ranquet
@ 2025-01-03  3:02   ` LIANKUN YANG (杨连坤)
  0 siblings, 0 replies; 4+ messages in thread
From: LIANKUN YANG (杨连坤) @ 2025-01-03  3:02 UTC (permalink / raw)
  To: Peng Liu (刘鹏), Mac Shen (沈俊),
	chunkuang.hu, simona, Jitao Shi (石记涛),
	p.zabel, granquet, CK Hu (胡俊光),
	Project_Global_Chrome_Upstream_Group, airlied, matthias.bgg,
	dmitry.osipenko, Rex-BC Chen (陳柏辰),
	AngeloGioacchino Del Regno
  Cc: dri-devel, linux-arm-kernel, linux-mediatek, linux-kernel

On Thu, 2024-12-19 at 03:51 -0600, Guillaume Ranquet wrote:
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> 
> 
> On Wed, 18 Dec 2024 12:34, Liankun Yang <liankun.yang@mediatek.com>
> wrote:
> > 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
> 
> Reviewed-by: Guillaume Ranquet <granquet@baylibre.com>
> 
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

> > Check the return value to confirm that AUX communication is
> > successful.
> > 
> > Fixes: f70ac097a2cf ("drm/mediatek: Add MT8195 Embedded DisplayPort
> > driver")
> > 
> > Signed-off-by: Liankun Yang <liankun.yang@mediatek.com>
> > ---
> > 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/20241128030940.25657-1-liankun.yang@mediatek.com/__;!!CTRNKA9wMg0ARbw!hB4quDn5mHgRtBK-Gf2pmkMN_4MbA66eggh1o8gdUWP7pA72uPoZlmbisRetswwyYSenG2ErIZK6oOaQqdCxdx4$
> > 
> > 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/20240930092000.5385-1-liankun.yang@mediatek.com/__;!!CTRNKA9wMg0ARbw!hB4quDn5mHgRtBK-Gf2pmkMN_4MbA66eggh1o8gdUWP7pA72uPoZlmbisRetswwyYSenG2ErIZK6oOaQWWaDClg$
> > ---
> > drivers/gpu/drm/mediatek/mtk_dp.c | 5 ++---
> > 1 file changed, 2 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c
> > b/drivers/gpu/drm/mediatek/mtk_dp.c
> > index 36713c176cfc..b26dad8783be 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_dp.c
> > +++ b/drivers/gpu/drm/mediatek/mtk_dp.c
> > @@ -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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-01-03  3:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-18 11:34 [PATCH v3 1/1] drm/mediatek: Add return value check when reading DPCD Liankun Yang
2024-12-19  9:51 ` Guillaume Ranquet
2025-01-03  3:02   ` LIANKUN YANG (杨连坤)
2025-01-02 14:10 ` Chun-Kuang Hu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®