linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/bridge: analogix-anx6345: fix set of link bandwidth
@ 2020-02-21 16:51 Icenowy Zheng
  2020-02-21 17:13 ` Torsten Duwe
  0 siblings, 1 reply; 8+ messages in thread
From: Icenowy Zheng @ 2020-02-21 16:51 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong, Laurent Pinchart, Jonas Karlman,
	Jernej Skrabec, Torsten Duwe, Maxime Ripard, Vasily Khoruzhick
  Cc: dri-devel, linux-kernel, Icenowy Zheng

Current code tries to store the link rate (in bps, which is a big
number) in a u8, which surely overflow. Then it's converted back to
bandwidth code (which is thus 0) and written to the chip.

The code sometimes works because the chip will automatically fallback to
the lowest possible DP link rate (1.62Gbps) when get the invalid value.
However, on the eDP panel of Olimex TERES-I, which wants 2.7Gbps link,
it failed.

As we had already read the link bandwidth as bandwidth code in earlier
code (to check whether it is supported), use it when setting bandwidth,
instead of converting it to link rate and then converting back.

Fixes: e1cff82c1097 ("drm/bridge: fix anx6345 compilation for v5.5")
Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
---
 drivers/gpu/drm/bridge/analogix/analogix-anx6345.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
index 56f55c53abfd..2dfa2fd2a23b 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
@@ -210,8 +210,7 @@ static int anx6345_dp_link_training(struct anx6345 *anx6345)
 	if (err)
 		return err;
 
-	dpcd[0] = drm_dp_max_link_rate(anx6345->dpcd);
-	dpcd[0] = drm_dp_link_rate_to_bw_code(dpcd[0]);
+	dpcd[0] = dp_bw;
 	err = regmap_write(anx6345->map[I2C_IDX_DPTX],
 			   SP_DP_MAIN_LINK_BW_SET_REG, dpcd[0]);
 	if (err)
-- 
2.24.1


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

* Re: [PATCH] drm/bridge: analogix-anx6345: fix set of link bandwidth
  2020-02-21 16:51 [PATCH] drm/bridge: analogix-anx6345: fix set of link bandwidth Icenowy Zheng
@ 2020-02-21 17:13 ` Torsten Duwe
  2020-02-22  2:43   ` Icenowy Zheng
  0 siblings, 1 reply; 8+ messages in thread
From: Torsten Duwe @ 2020-02-21 17:13 UTC (permalink / raw)
  To: Icenowy Zheng
  Cc: Andrzej Hajda, Neil Armstrong, Laurent Pinchart, Jonas Karlman,
	Jernej Skrabec, Maxime Ripard, Vasily Khoruzhick, dri-devel,
	linux-kernel

On Sat, Feb 22, 2020 at 12:51:27AM +0800, Icenowy Zheng wrote:
> Current code tries to store the link rate (in bps, which is a big
> number) in a u8, which surely overflow. Then it's converted back to
> bandwidth code (which is thus 0) and written to the chip.
> 
> The code sometimes works because the chip will automatically fallback to
> the lowest possible DP link rate (1.62Gbps) when get the invalid value.
> However, on the eDP panel of Olimex TERES-I, which wants 2.7Gbps link,
> it failed.
> 
> As we had already read the link bandwidth as bandwidth code in earlier
> code (to check whether it is supported), use it when setting bandwidth,
> instead of converting it to link rate and then converting back.
> 
> Fixes: e1cff82c1097 ("drm/bridge: fix anx6345 compilation for v5.5")
> Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
> ---
>  drivers/gpu/drm/bridge/analogix/analogix-anx6345.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> index 56f55c53abfd..2dfa2fd2a23b 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> @@ -210,8 +210,7 @@ static int anx6345_dp_link_training(struct anx6345 *anx6345)
>  	if (err)
>  		return err;
>  
> -	dpcd[0] = drm_dp_max_link_rate(anx6345->dpcd);
> -	dpcd[0] = drm_dp_link_rate_to_bw_code(dpcd[0]);
> +	dpcd[0] = dp_bw;

Why do you make this assignment and not use dp_bw directly in the call?

>  	err = regmap_write(anx6345->map[I2C_IDX_DPTX],
>  			   SP_DP_MAIN_LINK_BW_SET_REG, dpcd[0]);
                                                       ^^^^^^
>  	if (err)
> -- 
> 2.24.1

BTW, my version is only a bit more verbose:

https://patchwork.freedesktop.org/patch/354344/

	Torsten


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

* Re: [PATCH] drm/bridge: analogix-anx6345: fix set of link bandwidth
  2020-02-21 17:13 ` Torsten Duwe
@ 2020-02-22  2:43   ` Icenowy Zheng
  2020-02-24 10:44     ` Torsten Duwe
  2020-02-26 10:58     ` Thomas Zimmermann
  0 siblings, 2 replies; 8+ messages in thread
From: Icenowy Zheng @ 2020-02-22  2:43 UTC (permalink / raw)
  To: Torsten Duwe
  Cc: Andrzej Hajda, Neil Armstrong, Laurent Pinchart, Jonas Karlman,
	Jernej Skrabec, Maxime Ripard, Vasily Khoruzhick, dri-devel,
	linux-kernel



于 2020年2月22日 GMT+08:00 上午1:13:28, Torsten Duwe <duwe@lst.de> 写到:
>On Sat, Feb 22, 2020 at 12:51:27AM +0800, Icenowy Zheng wrote:
>> Current code tries to store the link rate (in bps, which is a big
>> number) in a u8, which surely overflow. Then it's converted back to
>> bandwidth code (which is thus 0) and written to the chip.
>> 
>> The code sometimes works because the chip will automatically fallback
>to
>> the lowest possible DP link rate (1.62Gbps) when get the invalid
>value.
>> However, on the eDP panel of Olimex TERES-I, which wants 2.7Gbps
>link,
>> it failed.
>> 
>> As we had already read the link bandwidth as bandwidth code in
>earlier
>> code (to check whether it is supported), use it when setting
>bandwidth,
>> instead of converting it to link rate and then converting back.
>> 
>> Fixes: e1cff82c1097 ("drm/bridge: fix anx6345 compilation for v5.5")
>> Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
>> ---
>>  drivers/gpu/drm/bridge/analogix/analogix-anx6345.c | 3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>> 
>> diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
>b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
>> index 56f55c53abfd..2dfa2fd2a23b 100644
>> --- a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
>> +++ b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
>> @@ -210,8 +210,7 @@ static int anx6345_dp_link_training(struct
>anx6345 *anx6345)
>>  	if (err)
>>  		return err;
>>  
>> -	dpcd[0] = drm_dp_max_link_rate(anx6345->dpcd);
>> -	dpcd[0] = drm_dp_link_rate_to_bw_code(dpcd[0]);
>> +	dpcd[0] = dp_bw;
>
>Why do you make this assignment and not use dp_bw directly in the call?

Because the dpcd array is then written as a continous array
back to DPCD.

>
>>  	err = regmap_write(anx6345->map[I2C_IDX_DPTX],
>>  			   SP_DP_MAIN_LINK_BW_SET_REG, dpcd[0]);
>                                                       ^^^^^^
>>  	if (err)
>> -- 
>> 2.24.1
>
>BTW, my version is only a bit more verbose:
>
>https://patchwork.freedesktop.org/patch/354344/
>
>	Torsten

-- 
使用 K-9 Mail 发送自我的Android设备。

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

* Re: [PATCH] drm/bridge: analogix-anx6345: fix set of link bandwidth
  2020-02-22  2:43   ` Icenowy Zheng
@ 2020-02-24 10:44     ` Torsten Duwe
  2020-02-26 10:58     ` Thomas Zimmermann
  1 sibling, 0 replies; 8+ messages in thread
From: Torsten Duwe @ 2020-02-24 10:44 UTC (permalink / raw)
  To: Icenowy Zheng, Thomas Zimmermann
  Cc: Andrzej Hajda, Neil Armstrong, Laurent Pinchart, Jonas Karlman,
	Jernej Skrabec, Maxime Ripard, Vasily Khoruzhick, Sam Ravnborg,
	Linus Walleij, Stephen Rothwell, dri-devel, linux-kernel

On Sat, Feb 22, 2020 at 10:43:02AM +0800, Icenowy Zheng wrote:
> 
> 
> 于 2020年2月22日 GMT+08:00 上午1:13:28, Torsten Duwe <duwe@lst.de> 写到:
> >On Sat, Feb 22, 2020 at 12:51:27AM +0800, Icenowy Zheng wrote:
> >> Current code tries to store the link rate (in bps, which is a big
> >> number) in a u8, which surely overflow. Then it's converted back to
> >> bandwidth code (which is thus 0) and written to the chip.
> >> 
> >> The code sometimes works because the chip will automatically fallback
> >to
> >> the lowest possible DP link rate (1.62Gbps) when get the invalid
> >value.
> >> However, on the eDP panel of Olimex TERES-I, which wants 2.7Gbps
> >link,
> >> it failed.
> >> 
> >> As we had already read the link bandwidth as bandwidth code in
> >earlier
> >> code (to check whether it is supported), use it when setting
> >bandwidth,
> >> instead of converting it to link rate and then converting back.
> >> 
> >> Fixes: e1cff82c1097 ("drm/bridge: fix anx6345 compilation for v5.5")
> >> Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
> >> ---
> >>  drivers/gpu/drm/bridge/analogix/analogix-anx6345.c | 3 +--
> >>  1 file changed, 1 insertion(+), 2 deletions(-)
> >> 
> >> diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> >b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> >> index 56f55c53abfd..2dfa2fd2a23b 100644
> >> --- a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> >> +++ b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> >> @@ -210,8 +210,7 @@ static int anx6345_dp_link_training(struct
> >anx6345 *anx6345)
> >>  	if (err)
> >>  		return err;
> >>  
> >> -	dpcd[0] = drm_dp_max_link_rate(anx6345->dpcd);
> >> -	dpcd[0] = drm_dp_link_rate_to_bw_code(dpcd[0]);
> >> +	dpcd[0] = dp_bw;
> >
> >Why do you make this assignment and not use dp_bw directly in the call?
> 
> Because the dpcd array is then written as a continous array
> back to DPCD.

But the current code never changes this value?
Anyway, as this might change in the future, I support your version;
I want to see this fixed.

Reviewed-by: Torsten Duwe <duwe@suse.de>
Fixes: e1cff82c1097 ("drm/bridge: fix anx6345 compilation for v5.5")
Cc: Maxime Ripard <maxime@cerno.tech>
Cc: Torsten Duwe <duwe@lst.de>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Icenowy Zheng <icenowy@aosc.io>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>

> >
> >>  	err = regmap_write(anx6345->map[I2C_IDX_DPTX],
> >>  			   SP_DP_MAIN_LINK_BW_SET_REG, dpcd[0]);
> >                                                       ^^^^^^
> >>  	if (err)
> >> -- 
> >> 2.24.1
> >
> >BTW, my version is only a bit more verbose:
> >
> >https://patchwork.freedesktop.org/patch/354344/
> >
> >	Torsten
> 
> -- 
> 使用 K-9 Mail 发送自我的Android设备。

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

* Re: [PATCH] drm/bridge: analogix-anx6345: fix set of link bandwidth
  2020-02-22  2:43   ` Icenowy Zheng
  2020-02-24 10:44     ` Torsten Duwe
@ 2020-02-26 10:58     ` Thomas Zimmermann
  2020-02-26 11:02       ` Icenowy Zheng
  1 sibling, 1 reply; 8+ messages in thread
From: Thomas Zimmermann @ 2020-02-26 10:58 UTC (permalink / raw)
  To: Icenowy Zheng, Torsten Duwe
  Cc: Jernej Skrabec, Jonas Karlman, Neil Armstrong, linux-kernel,
	dri-devel, Vasily Khoruzhick, Andrzej Hajda, Laurent Pinchart,
	Maxime Ripard

Hi Iceynow,

Torsten asked me to merge your patch via drm-misc-next. I'd add the
additional cc and fixes tags that Torsten listed. Are you OK with that?

Best regards
Thomas

Am 22.02.20 um 03:43 schrieb Icenowy Zheng:
> 
> 
> 于 2020年2月22日 GMT+08:00 上午1:13:28, Torsten Duwe <duwe@lst.de> 写到:
>> On Sat, Feb 22, 2020 at 12:51:27AM +0800, Icenowy Zheng wrote:
>>> Current code tries to store the link rate (in bps, which is a big
>>> number) in a u8, which surely overflow. Then it's converted back to
>>> bandwidth code (which is thus 0) and written to the chip.
>>>
>>> The code sometimes works because the chip will automatically fallback
>> to
>>> the lowest possible DP link rate (1.62Gbps) when get the invalid
>> value.
>>> However, on the eDP panel of Olimex TERES-I, which wants 2.7Gbps
>> link,
>>> it failed.
>>>
>>> As we had already read the link bandwidth as bandwidth code in
>> earlier
>>> code (to check whether it is supported), use it when setting
>> bandwidth,
>>> instead of converting it to link rate and then converting back.
>>>
>>> Fixes: e1cff82c1097 ("drm/bridge: fix anx6345 compilation for v5.5")
>>> Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
>>> ---
>>>  drivers/gpu/drm/bridge/analogix/analogix-anx6345.c | 3 +--
>>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
>> b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
>>> index 56f55c53abfd..2dfa2fd2a23b 100644
>>> --- a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
>>> +++ b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
>>> @@ -210,8 +210,7 @@ static int anx6345_dp_link_training(struct
>> anx6345 *anx6345)
>>>  	if (err)
>>>  		return err;
>>>  
>>> -	dpcd[0] = drm_dp_max_link_rate(anx6345->dpcd);
>>> -	dpcd[0] = drm_dp_link_rate_to_bw_code(dpcd[0]);
>>> +	dpcd[0] = dp_bw;
>>
>> Why do you make this assignment and not use dp_bw directly in the call?
> 
> Because the dpcd array is then written as a continous array
> back to DPCD.
> 
>>
>>>  	err = regmap_write(anx6345->map[I2C_IDX_DPTX],
>>>  			   SP_DP_MAIN_LINK_BW_SET_REG, dpcd[0]);
>>                                                       ^^^^^^
>>>  	if (err)
>>> -- 
>>> 2.24.1
>>
>> BTW, my version is only a bit more verbose:
>>
>> https://patchwork.freedesktop.org/patch/354344/
>>
>> 	Torsten
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer

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

* Re: [PATCH] drm/bridge: analogix-anx6345: fix set of link bandwidth
  2020-02-26 10:58     ` Thomas Zimmermann
@ 2020-02-26 11:02       ` Icenowy Zheng
  2020-02-26 11:59         ` Thomas Zimmermann
  2020-02-27 11:34         ` Thomas Zimmermann
  0 siblings, 2 replies; 8+ messages in thread
From: Icenowy Zheng @ 2020-02-26 11:02 UTC (permalink / raw)
  To: Thomas Zimmermann, Torsten Duwe
  Cc: Jernej Skrabec, Jonas Karlman, Neil Armstrong, linux-kernel,
	dri-devel, Vasily Khoruzhick, Andrzej Hajda, Laurent Pinchart,
	Maxime Ripard



于 2020年2月26日 GMT+08:00 下午6:58:43, Thomas Zimmermann <tzimmermann@suse.de> 写到:
>Hi Iceynow,
>
>Torsten asked me to merge your patch via drm-misc-next. I'd add the
>additional cc and fixes tags that Torsten listed. Are you OK with that?

I think this fixes a driver (and a board) available in 5.6.

Maybe it should enter fixes?

>
>Best regards
>Thomas
>
>Am 22.02.20 um 03:43 schrieb Icenowy Zheng:
>> 
>> 
>> 于 2020年2月22日 GMT+08:00 上午1:13:28, Torsten Duwe <duwe@lst.de> 写到:
>>> On Sat, Feb 22, 2020 at 12:51:27AM +0800, Icenowy Zheng wrote:
>>>> Current code tries to store the link rate (in bps, which is a big
>>>> number) in a u8, which surely overflow. Then it's converted back to
>>>> bandwidth code (which is thus 0) and written to the chip.
>>>>
>>>> The code sometimes works because the chip will automatically
>fallback
>>> to
>>>> the lowest possible DP link rate (1.62Gbps) when get the invalid
>>> value.
>>>> However, on the eDP panel of Olimex TERES-I, which wants 2.7Gbps
>>> link,
>>>> it failed.
>>>>
>>>> As we had already read the link bandwidth as bandwidth code in
>>> earlier
>>>> code (to check whether it is supported), use it when setting
>>> bandwidth,
>>>> instead of converting it to link rate and then converting back.
>>>>
>>>> Fixes: e1cff82c1097 ("drm/bridge: fix anx6345 compilation for
>v5.5")
>>>> Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
>>>> ---
>>>>  drivers/gpu/drm/bridge/analogix/analogix-anx6345.c | 3 +--
>>>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
>>> b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
>>>> index 56f55c53abfd..2dfa2fd2a23b 100644
>>>> --- a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
>>>> +++ b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
>>>> @@ -210,8 +210,7 @@ static int anx6345_dp_link_training(struct
>>> anx6345 *anx6345)
>>>>  	if (err)
>>>>  		return err;
>>>>  
>>>> -	dpcd[0] = drm_dp_max_link_rate(anx6345->dpcd);
>>>> -	dpcd[0] = drm_dp_link_rate_to_bw_code(dpcd[0]);
>>>> +	dpcd[0] = dp_bw;
>>>
>>> Why do you make this assignment and not use dp_bw directly in the
>call?
>> 
>> Because the dpcd array is then written as a continous array
>> back to DPCD.
>> 
>>>
>>>>  	err = regmap_write(anx6345->map[I2C_IDX_DPTX],
>>>>  			   SP_DP_MAIN_LINK_BW_SET_REG, dpcd[0]);
>>>                                                       ^^^^^^
>>>>  	if (err)
>>>> -- 
>>>> 2.24.1
>>>
>>> BTW, my version is only a bit more verbose:
>>>
>>> https://patchwork.freedesktop.org/patch/354344/
>>>
>>> 	Torsten
>> 

-- 
使用 K-9 Mail 发送自我的Android设备。

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

* Re: [PATCH] drm/bridge: analogix-anx6345: fix set of link bandwidth
  2020-02-26 11:02       ` Icenowy Zheng
@ 2020-02-26 11:59         ` Thomas Zimmermann
  2020-02-27 11:34         ` Thomas Zimmermann
  1 sibling, 0 replies; 8+ messages in thread
From: Thomas Zimmermann @ 2020-02-26 11:59 UTC (permalink / raw)
  To: Icenowy Zheng, Torsten Duwe
  Cc: Jernej Skrabec, Jonas Karlman, Neil Armstrong, linux-kernel,
	dri-devel, Vasily Khoruzhick, Andrzej Hajda, Laurent Pinchart,
	Maxime Ripard

Hi

Am 26.02.20 um 12:02 schrieb Icenowy Zheng:
> 
> 
> 于 2020年2月26日 GMT+08:00 下午6:58:43, Thomas Zimmermann <tzimmermann@suse.de> 写到:
>> Hi Iceynow,
>>
>> Torsten asked me to merge your patch via drm-misc-next. I'd add the
>> additional cc and fixes tags that Torsten listed. Are you OK with that?
> 
> I think this fixes a driver (and a board) available in 5.6.
> 
> Maybe it should enter fixes?

I think we can do that. Anything else?

Best regards
Thomas

> 
>>
>> Best regards
>> Thomas
>>
>> Am 22.02.20 um 03:43 schrieb Icenowy Zheng:
>>>
>>>
>>> 于 2020年2月22日 GMT+08:00 上午1:13:28, Torsten Duwe <duwe@lst.de> 写到:
>>>> On Sat, Feb 22, 2020 at 12:51:27AM +0800, Icenowy Zheng wrote:
>>>>> Current code tries to store the link rate (in bps, which is a big
>>>>> number) in a u8, which surely overflow. Then it's converted back to
>>>>> bandwidth code (which is thus 0) and written to the chip.
>>>>>
>>>>> The code sometimes works because the chip will automatically
>> fallback
>>>> to
>>>>> the lowest possible DP link rate (1.62Gbps) when get the invalid
>>>> value.
>>>>> However, on the eDP panel of Olimex TERES-I, which wants 2.7Gbps
>>>> link,
>>>>> it failed.
>>>>>
>>>>> As we had already read the link bandwidth as bandwidth code in
>>>> earlier
>>>>> code (to check whether it is supported), use it when setting
>>>> bandwidth,
>>>>> instead of converting it to link rate and then converting back.
>>>>>
>>>>> Fixes: e1cff82c1097 ("drm/bridge: fix anx6345 compilation for
>> v5.5")
>>>>> Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
>>>>> ---
>>>>>  drivers/gpu/drm/bridge/analogix/analogix-anx6345.c | 3 +--
>>>>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>>>>
>>>>> diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
>>>> b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
>>>>> index 56f55c53abfd..2dfa2fd2a23b 100644
>>>>> --- a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
>>>>> +++ b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
>>>>> @@ -210,8 +210,7 @@ static int anx6345_dp_link_training(struct
>>>> anx6345 *anx6345)
>>>>>  	if (err)
>>>>>  		return err;
>>>>>  
>>>>> -	dpcd[0] = drm_dp_max_link_rate(anx6345->dpcd);
>>>>> -	dpcd[0] = drm_dp_link_rate_to_bw_code(dpcd[0]);
>>>>> +	dpcd[0] = dp_bw;
>>>>
>>>> Why do you make this assignment and not use dp_bw directly in the
>> call?
>>>
>>> Because the dpcd array is then written as a continous array
>>> back to DPCD.
>>>
>>>>
>>>>>  	err = regmap_write(anx6345->map[I2C_IDX_DPTX],
>>>>>  			   SP_DP_MAIN_LINK_BW_SET_REG, dpcd[0]);
>>>>                                                       ^^^^^^
>>>>>  	if (err)
>>>>> -- 
>>>>> 2.24.1
>>>>
>>>> BTW, my version is only a bit more verbose:
>>>>
>>>> https://patchwork.freedesktop.org/patch/354344/
>>>>
>>>> 	Torsten
>>>
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer

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

* Re: [PATCH] drm/bridge: analogix-anx6345: fix set of link bandwidth
  2020-02-26 11:02       ` Icenowy Zheng
  2020-02-26 11:59         ` Thomas Zimmermann
@ 2020-02-27 11:34         ` Thomas Zimmermann
  1 sibling, 0 replies; 8+ messages in thread
From: Thomas Zimmermann @ 2020-02-27 11:34 UTC (permalink / raw)
  To: Icenowy Zheng, Torsten Duwe
  Cc: Jernej Skrabec, Neil Armstrong, Jonas Karlman, linux-kernel,
	dri-devel, Vasily Khoruzhick, Andrzej Hajda, Laurent Pinchart,
	Maxime Ripard

Hi

Am 26.02.20 um 12:02 schrieb Icenowy Zheng:
> 
> 
> 于 2020年2月26日 GMT+08:00 下午6:58:43, Thomas Zimmermann <tzimmermann@suse.de> 写到:
>> Hi Iceynow,
>>
>> Torsten asked me to merge your patch via drm-misc-next. I'd add the
>> additional cc and fixes tags that Torsten listed. Are you OK with that?
> 
> I think this fixes a driver (and a board) available in 5.6.
> 
> Maybe it should enter fixes?

Pushed to drm-misc-fixes

Best regards
Thomas

> 
>>
>> Best regards
>> Thomas
>>
>> Am 22.02.20 um 03:43 schrieb Icenowy Zheng:
>>>
>>>
>>> 于 2020年2月22日 GMT+08:00 上午1:13:28, Torsten Duwe <duwe@lst.de> 写到:
>>>> On Sat, Feb 22, 2020 at 12:51:27AM +0800, Icenowy Zheng wrote:
>>>>> Current code tries to store the link rate (in bps, which is a big
>>>>> number) in a u8, which surely overflow. Then it's converted back to
>>>>> bandwidth code (which is thus 0) and written to the chip.
>>>>>
>>>>> The code sometimes works because the chip will automatically
>> fallback
>>>> to
>>>>> the lowest possible DP link rate (1.62Gbps) when get the invalid
>>>> value.
>>>>> However, on the eDP panel of Olimex TERES-I, which wants 2.7Gbps
>>>> link,
>>>>> it failed.
>>>>>
>>>>> As we had already read the link bandwidth as bandwidth code in
>>>> earlier
>>>>> code (to check whether it is supported), use it when setting
>>>> bandwidth,
>>>>> instead of converting it to link rate and then converting back.
>>>>>
>>>>> Fixes: e1cff82c1097 ("drm/bridge: fix anx6345 compilation for
>> v5.5")
>>>>> Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
>>>>> ---
>>>>>  drivers/gpu/drm/bridge/analogix/analogix-anx6345.c | 3 +--
>>>>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>>>>
>>>>> diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
>>>> b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
>>>>> index 56f55c53abfd..2dfa2fd2a23b 100644
>>>>> --- a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
>>>>> +++ b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
>>>>> @@ -210,8 +210,7 @@ static int anx6345_dp_link_training(struct
>>>> anx6345 *anx6345)
>>>>>  	if (err)
>>>>>  		return err;
>>>>>  
>>>>> -	dpcd[0] = drm_dp_max_link_rate(anx6345->dpcd);
>>>>> -	dpcd[0] = drm_dp_link_rate_to_bw_code(dpcd[0]);
>>>>> +	dpcd[0] = dp_bw;
>>>>
>>>> Why do you make this assignment and not use dp_bw directly in the
>> call?
>>>
>>> Because the dpcd array is then written as a continous array
>>> back to DPCD.
>>>
>>>>
>>>>>  	err = regmap_write(anx6345->map[I2C_IDX_DPTX],
>>>>>  			   SP_DP_MAIN_LINK_BW_SET_REG, dpcd[0]);
>>>>                                                       ^^^^^^
>>>>>  	if (err)
>>>>> -- 
>>>>> 2.24.1
>>>>
>>>> BTW, my version is only a bit more verbose:
>>>>
>>>> https://patchwork.freedesktop.org/patch/354344/
>>>>
>>>> 	Torsten
>>>
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer

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

end of thread, other threads:[~2020-02-27 11:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-21 16:51 [PATCH] drm/bridge: analogix-anx6345: fix set of link bandwidth Icenowy Zheng
2020-02-21 17:13 ` Torsten Duwe
2020-02-22  2:43   ` Icenowy Zheng
2020-02-24 10:44     ` Torsten Duwe
2020-02-26 10:58     ` Thomas Zimmermann
2020-02-26 11:02       ` Icenowy Zheng
2020-02-26 11:59         ` Thomas Zimmermann
2020-02-27 11:34         ` Thomas Zimmermann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).