linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/ast: Fix modeset failed on DisplayPort
@ 2023-04-25  7:03 Jammy Huang
  2023-04-25  7:27 ` Thomas Zimmermann
  0 siblings, 1 reply; 6+ messages in thread
From: Jammy Huang @ 2023-04-25  7:03 UTC (permalink / raw)
  To: airlied, tzimmermann; +Cc: airlied, daniel, dri-devel, linux-kernel

If we switch display and update cursor together, it could lead to
modeset failed because of concurrent access to IO registers.

Add lock protection in DP's edid access to avoid this problem.

Signed-off-by: Jammy Huang <jammy_huang@aspeedtech.com>
---
 drivers/gpu/drm/ast/ast_mode.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index 984ec590a7e7..fe5f1fd61361 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -1635,6 +1635,8 @@ static int ast_dp501_output_init(struct ast_private *ast)
 static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
 {
 	void *edid;
+	struct drm_device *dev = connector->dev;
+	struct ast_private *ast = to_ast_private(dev);
 
 	int succ;
 	int count;
@@ -1643,10 +1645,18 @@ static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
 	if (!edid)
 		goto err_drm_connector_update_edid_property;
 
+	/*
+	 * Protect access to I/O registers from concurrent modesetting
+	 * by acquiring the I/O-register lock.
+	 */
+	mutex_lock(&ast->ioregs_lock);
+
 	succ = ast_astdp_read_edid(connector->dev, edid);
 	if (succ < 0)
 		goto err_kfree;
 
+	mutex_unlock(&ast->ioregs_lock);
+
 	drm_connector_update_edid_property(connector, edid);
 	count = drm_add_edid_modes(connector, edid);
 	kfree(edid);
@@ -1654,6 +1664,7 @@ static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
 	return count;
 
 err_kfree:
+	mutex_unlock(&ast->ioregs_lock);
 	kfree(edid);
 err_drm_connector_update_edid_property:
 	drm_connector_update_edid_property(connector, NULL);

base-commit: 61d325dcbc05d8fef88110d35ef7776f3ac3f68b
-- 
2.25.1


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

* Re: [PATCH] drm/ast: Fix modeset failed on DisplayPort
  2023-04-25  7:03 [PATCH] drm/ast: Fix modeset failed on DisplayPort Jammy Huang
@ 2023-04-25  7:27 ` Thomas Zimmermann
  2023-04-25  7:39   ` Jammy Huang
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Zimmermann @ 2023-04-25  7:27 UTC (permalink / raw)
  To: Jammy Huang, airlied; +Cc: dri-devel, linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 2543 bytes --]

Hi

Am 25.04.23 um 09:03 schrieb Jammy Huang:
> If we switch display and update cursor together, it could lead to
> modeset failed because of concurrent access to IO registers.
> 
> Add lock protection in DP's edid access to avoid this problem.

Thanks for the patch. I thought I fixed this issue already, but that 
apparently only happened for SIL164 and VGA.

What about ast_dp501_connector_helper_get_modes()? Does it require the 
locking as well?

> 
> Signed-off-by: Jammy Huang <jammy_huang@aspeedtech.com>
> ---
>   drivers/gpu/drm/ast/ast_mode.c | 11 +++++++++++
>   1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
> index 984ec590a7e7..fe5f1fd61361 100644
> --- a/drivers/gpu/drm/ast/ast_mode.c
> +++ b/drivers/gpu/drm/ast/ast_mode.c
> @@ -1635,6 +1635,8 @@ static int ast_dp501_output_init(struct ast_private *ast)
>   static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
>   {
>   	void *edid;
> +	struct drm_device *dev = connector->dev;
> +	struct ast_private *ast = to_ast_private(dev);

We've meanwhile renamed ast_private to ast_device. Could you please 
provide an updated patch for the drm-misc-next tree?

Best regards
Thomas

>   
>   	int succ;
>   	int count;
> @@ -1643,10 +1645,18 @@ static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
>   	if (!edid)
>   		goto err_drm_connector_update_edid_property;
>   
> +	/*
> +	 * Protect access to I/O registers from concurrent modesetting
> +	 * by acquiring the I/O-register lock.
> +	 */
> +	mutex_lock(&ast->ioregs_lock);
> +
>   	succ = ast_astdp_read_edid(connector->dev, edid);
>   	if (succ < 0)
>   		goto err_kfree;
>   
> +	mutex_unlock(&ast->ioregs_lock);
> +
>   	drm_connector_update_edid_property(connector, edid);
>   	count = drm_add_edid_modes(connector, edid);
>   	kfree(edid);
> @@ -1654,6 +1664,7 @@ static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
>   	return count;
>   
>   err_kfree:
> +	mutex_unlock(&ast->ioregs_lock);
>   	kfree(edid);
>   err_drm_connector_update_edid_property:
>   	drm_connector_update_edid_property(connector, NULL);
> 
> base-commit: 61d325dcbc05d8fef88110d35ef7776f3ac3f68b

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

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

* Re: [PATCH] drm/ast: Fix modeset failed on DisplayPort
  2023-04-25  7:27 ` Thomas Zimmermann
@ 2023-04-25  7:39   ` Jammy Huang
  2023-05-24  2:29     ` Jammy Huang
  0 siblings, 1 reply; 6+ messages in thread
From: Jammy Huang @ 2023-04-25  7:39 UTC (permalink / raw)
  To: Thomas Zimmermann, airlied; +Cc: dri-devel, linux-kernel

Hi Thomas,

I think DP501 is OK. It doesn't use ioregs in ast_dp501_read_edid().

On 2023/4/25 下午 03:27, Thomas Zimmermann wrote:
> Hi
>
> Am 25.04.23 um 09:03 schrieb Jammy Huang:
>> If we switch display and update cursor together, it could lead to
>> modeset failed because of concurrent access to IO registers.
>>
>> Add lock protection in DP's edid access to avoid this problem.
>
> Thanks for the patch. I thought I fixed this issue already, but that 
> apparently only happened for SIL164 and VGA.
>
> What about ast_dp501_connector_helper_get_modes()? Does it require the 
> locking as well?
>
>>
>> Signed-off-by: Jammy Huang <jammy_huang@aspeedtech.com>
>> ---
>>   drivers/gpu/drm/ast/ast_mode.c | 11 +++++++++++
>>   1 file changed, 11 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/ast/ast_mode.c 
>> b/drivers/gpu/drm/ast/ast_mode.c
>> index 984ec590a7e7..fe5f1fd61361 100644
>> --- a/drivers/gpu/drm/ast/ast_mode.c
>> +++ b/drivers/gpu/drm/ast/ast_mode.c
>> @@ -1635,6 +1635,8 @@ static int ast_dp501_output_init(struct 
>> ast_private *ast)
>>   static int ast_astdp_connector_helper_get_modes(struct 
>> drm_connector *connector)
>>   {
>>       void *edid;
>> +    struct drm_device *dev = connector->dev;
>> +    struct ast_private *ast = to_ast_private(dev);
>
> We've meanwhile renamed ast_private to ast_device. Could you please 
> provide an updated patch for the drm-misc-next tree?
>
> Best regards
> Thomas
>
>>         int succ;
>>       int count;
>> @@ -1643,10 +1645,18 @@ static int 
>> ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
>>       if (!edid)
>>           goto err_drm_connector_update_edid_property;
>>   +    /*
>> +     * Protect access to I/O registers from concurrent modesetting
>> +     * by acquiring the I/O-register lock.
>> +     */
>> +    mutex_lock(&ast->ioregs_lock);
>> +
>>       succ = ast_astdp_read_edid(connector->dev, edid);
>>       if (succ < 0)
>>           goto err_kfree;
>>   +    mutex_unlock(&ast->ioregs_lock);
>> +
>>       drm_connector_update_edid_property(connector, edid);
>>       count = drm_add_edid_modes(connector, edid);
>>       kfree(edid);
>> @@ -1654,6 +1664,7 @@ static int 
>> ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
>>       return count;
>>     err_kfree:
>> +    mutex_unlock(&ast->ioregs_lock);
>>       kfree(edid);
>>   err_drm_connector_update_edid_property:
>>       drm_connector_update_edid_property(connector, NULL);
>>
>> base-commit: 61d325dcbc05d8fef88110d35ef7776f3ac3f68b
>
-- 
Best Regards
Jammy


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

* Re: [PATCH] drm/ast: Fix modeset failed on DisplayPort
  2023-04-25  7:39   ` Jammy Huang
@ 2023-05-24  2:29     ` Jammy Huang
  2023-05-24 10:47       ` Thomas Zimmermann
  0 siblings, 1 reply; 6+ messages in thread
From: Jammy Huang @ 2023-05-24  2:29 UTC (permalink / raw)
  To: Thomas Zimmermann, airlied; +Cc: dri-devel, linux-kernel

Hi Thomas,

Do you have other suggestion for this patch??

Please kindly advise.

On 2023/4/25 下午 03:39, Jammy Huang wrote:
> Hi Thomas,
>
> I think DP501 is OK. It doesn't use ioregs in ast_dp501_read_edid().
>
> On 2023/4/25 下午 03:27, Thomas Zimmermann wrote:
>> Hi
>>
>> Am 25.04.23 um 09:03 schrieb Jammy Huang:
>>> If we switch display and update cursor together, it could lead to
>>> modeset failed because of concurrent access to IO registers.
>>>
>>> Add lock protection in DP's edid access to avoid this problem.
>>
>> Thanks for the patch. I thought I fixed this issue already, but that 
>> apparently only happened for SIL164 and VGA.
>>
>> What about ast_dp501_connector_helper_get_modes()? Does it require 
>> the locking as well?
>>
>>>
>>> Signed-off-by: Jammy Huang <jammy_huang@aspeedtech.com>
>>> ---
>>>   drivers/gpu/drm/ast/ast_mode.c | 11 +++++++++++
>>>   1 file changed, 11 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/ast/ast_mode.c 
>>> b/drivers/gpu/drm/ast/ast_mode.c
>>> index 984ec590a7e7..fe5f1fd61361 100644
>>> --- a/drivers/gpu/drm/ast/ast_mode.c
>>> +++ b/drivers/gpu/drm/ast/ast_mode.c
>>> @@ -1635,6 +1635,8 @@ static int ast_dp501_output_init(struct 
>>> ast_private *ast)
>>>   static int ast_astdp_connector_helper_get_modes(struct 
>>> drm_connector *connector)
>>>   {
>>>       void *edid;
>>> +    struct drm_device *dev = connector->dev;
>>> +    struct ast_private *ast = to_ast_private(dev);
>>
>> We've meanwhile renamed ast_private to ast_device. Could you please 
>> provide an updated patch for the drm-misc-next tree?
>>
>> Best regards
>> Thomas
>>
>>>         int succ;
>>>       int count;
>>> @@ -1643,10 +1645,18 @@ static int 
>>> ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
>>>       if (!edid)
>>>           goto err_drm_connector_update_edid_property;
>>>   +    /*
>>> +     * Protect access to I/O registers from concurrent modesetting
>>> +     * by acquiring the I/O-register lock.
>>> +     */
>>> +    mutex_lock(&ast->ioregs_lock);
>>> +
>>>       succ = ast_astdp_read_edid(connector->dev, edid);
>>>       if (succ < 0)
>>>           goto err_kfree;
>>>   +    mutex_unlock(&ast->ioregs_lock);
>>> +
>>>       drm_connector_update_edid_property(connector, edid);
>>>       count = drm_add_edid_modes(connector, edid);
>>>       kfree(edid);
>>> @@ -1654,6 +1664,7 @@ static int 
>>> ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
>>>       return count;
>>>     err_kfree:
>>> +    mutex_unlock(&ast->ioregs_lock);
>>>       kfree(edid);
>>>   err_drm_connector_update_edid_property:
>>>       drm_connector_update_edid_property(connector, NULL);
>>>
>>> base-commit: 61d325dcbc05d8fef88110d35ef7776f3ac3f68b
>>
-- 
Best Regards
Jammy


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

* Re: [PATCH] drm/ast: Fix modeset failed on DisplayPort
  2023-05-24  2:29     ` Jammy Huang
@ 2023-05-24 10:47       ` Thomas Zimmermann
  2023-05-25  1:30         ` Jammy Huang
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Zimmermann @ 2023-05-24 10:47 UTC (permalink / raw)
  To: Jammy Huang, airlied; +Cc: linux-kernel, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 3602 bytes --]

Hi,

this patch also fell through the cracks. Apologies.

Am 24.05.23 um 04:29 schrieb Jammy Huang:
> Hi Thomas,
> 
> Do you have other suggestion for this patch??

The main issue was that struct ast_private is now called struct 
ast_device.  So the current patch cannot be applied.

> 
> Please kindly advise.
> 
> On 2023/4/25 下午 03:39, Jammy Huang wrote:
>> Hi Thomas,
>>
>> I think DP501 is OK. It doesn't use ioregs in ast_dp501_read_edid().
>>
>> On 2023/4/25 下午 03:27, Thomas Zimmermann wrote:
>>> Hi
>>>
>>> Am 25.04.23 um 09:03 schrieb Jammy Huang:
>>>> If we switch display and update cursor together, it could lead to
>>>> modeset failed because of concurrent access to IO registers.
>>>>
>>>> Add lock protection in DP's edid access to avoid this problem.
>>>
>>> Thanks for the patch. I thought I fixed this issue already, but that 
>>> apparently only happened for SIL164 and VGA.
>>>
>>> What about ast_dp501_connector_helper_get_modes()? Does it require 
>>> the locking as well?
>>>
>>>>
>>>> Signed-off-by: Jammy Huang <jammy_huang@aspeedtech.com>
>>>> ---
>>>>   drivers/gpu/drm/ast/ast_mode.c | 11 +++++++++++
>>>>   1 file changed, 11 insertions(+)
>>>>
>>>> diff --git a/drivers/gpu/drm/ast/ast_mode.c 
>>>> b/drivers/gpu/drm/ast/ast_mode.c
>>>> index 984ec590a7e7..fe5f1fd61361 100644
>>>> --- a/drivers/gpu/drm/ast/ast_mode.c
>>>> +++ b/drivers/gpu/drm/ast/ast_mode.c
>>>> @@ -1635,6 +1635,8 @@ static int ast_dp501_output_init(struct 
>>>> ast_private *ast)
>>>>   static int ast_astdp_connector_helper_get_modes(struct 
>>>> drm_connector *connector)
>>>>   {
>>>>       void *edid;
>>>> +    struct drm_device *dev = connector->dev;
>>>> +    struct ast_private *ast = to_ast_private(dev);
>>>
>>> We've meanwhile renamed ast_private to ast_device. Could you please 
>>> provide an updated patch for the drm-misc-next tree?
>>>
>>> Best regards
>>> Thomas
>>>
>>>>         int succ;
>>>>       int count;
>>>> @@ -1643,10 +1645,18 @@ static int 
>>>> ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
>>>>       if (!edid)
>>>>           goto err_drm_connector_update_edid_property;
>>>>   +    /*
>>>> +     * Protect access to I/O registers from concurrent modesetting
>>>> +     * by acquiring the I/O-register lock.
>>>> +     */
>>>> +    mutex_lock(&ast->ioregs_lock);
>>>> +
>>>>       succ = ast_astdp_read_edid(connector->dev, edid);
>>>>       if (succ < 0)
>>>>           goto err_kfree;
>>>>   +    mutex_unlock(&ast->ioregs_lock);
>>>> +
>>>>       drm_connector_update_edid_property(connector, edid);
>>>>       count = drm_add_edid_modes(connector, edid);
>>>>       kfree(edid);
>>>> @@ -1654,6 +1664,7 @@ static int 
>>>> ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
>>>>       return count;
>>>>     err_kfree:

Here's a minor issue that the goto label should now be called 
err_mutex_unlock.

Best regards
Thomas

>>>> +    mutex_unlock(&ast->ioregs_lock);
>>>>       kfree(edid);
>>>>   err_drm_connector_update_edid_property:
>>>>       drm_connector_update_edid_property(connector, NULL);
>>>>
>>>> base-commit: 61d325dcbc05d8fef88110d35ef7776f3ac3f68b
>>>

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

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

* Re: [PATCH] drm/ast: Fix modeset failed on DisplayPort
  2023-05-24 10:47       ` Thomas Zimmermann
@ 2023-05-25  1:30         ` Jammy Huang
  0 siblings, 0 replies; 6+ messages in thread
From: Jammy Huang @ 2023-05-25  1:30 UTC (permalink / raw)
  To: Thomas Zimmermann, airlied; +Cc: linux-kernel, dri-devel

Hi Thomas,

Thanks, I will modify the patch accordingly.

On 2023/5/24 下午 06:47, Thomas Zimmermann wrote:
> Hi,
>
> this patch also fell through the cracks. Apologies.
>
> Am 24.05.23 um 04:29 schrieb Jammy Huang:
>> Hi Thomas,
>>
>> Do you have other suggestion for this patch??
>
> The main issue was that struct ast_private is now called struct 
> ast_device.  So the current patch cannot be applied.
>
>>
>> Please kindly advise.
>>
>> On 2023/4/25 下午 03:39, Jammy Huang wrote:
>>> Hi Thomas,
>>>
>>> I think DP501 is OK. It doesn't use ioregs in ast_dp501_read_edid().
>>>
>>> On 2023/4/25 下午 03:27, Thomas Zimmermann wrote:
>>>> Hi
>>>>
>>>> Am 25.04.23 um 09:03 schrieb Jammy Huang:
>>>>> If we switch display and update cursor together, it could lead to
>>>>> modeset failed because of concurrent access to IO registers.
>>>>>
>>>>> Add lock protection in DP's edid access to avoid this problem.
>>>>
>>>> Thanks for the patch. I thought I fixed this issue already, but 
>>>> that apparently only happened for SIL164 and VGA.
>>>>
>>>> What about ast_dp501_connector_helper_get_modes()? Does it require 
>>>> the locking as well?
>>>>
>>>>>
>>>>> Signed-off-by: Jammy Huang <jammy_huang@aspeedtech.com>
>>>>> ---
>>>>>   drivers/gpu/drm/ast/ast_mode.c | 11 +++++++++++
>>>>>   1 file changed, 11 insertions(+)
>>>>>
>>>>> diff --git a/drivers/gpu/drm/ast/ast_mode.c 
>>>>> b/drivers/gpu/drm/ast/ast_mode.c
>>>>> index 984ec590a7e7..fe5f1fd61361 100644
>>>>> --- a/drivers/gpu/drm/ast/ast_mode.c
>>>>> +++ b/drivers/gpu/drm/ast/ast_mode.c
>>>>> @@ -1635,6 +1635,8 @@ static int ast_dp501_output_init(struct 
>>>>> ast_private *ast)
>>>>>   static int ast_astdp_connector_helper_get_modes(struct 
>>>>> drm_connector *connector)
>>>>>   {
>>>>>       void *edid;
>>>>> +    struct drm_device *dev = connector->dev;
>>>>> +    struct ast_private *ast = to_ast_private(dev);
>>>>
>>>> We've meanwhile renamed ast_private to ast_device. Could you please 
>>>> provide an updated patch for the drm-misc-next tree?
>>>>
>>>> Best regards
>>>> Thomas
>>>>
>>>>>         int succ;
>>>>>       int count;
>>>>> @@ -1643,10 +1645,18 @@ static int 
>>>>> ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
>>>>>       if (!edid)
>>>>>           goto err_drm_connector_update_edid_property;
>>>>>   +    /*
>>>>> +     * Protect access to I/O registers from concurrent modesetting
>>>>> +     * by acquiring the I/O-register lock.
>>>>> +     */
>>>>> +    mutex_lock(&ast->ioregs_lock);
>>>>> +
>>>>>       succ = ast_astdp_read_edid(connector->dev, edid);
>>>>>       if (succ < 0)
>>>>>           goto err_kfree;
>>>>>   +    mutex_unlock(&ast->ioregs_lock);
>>>>> +
>>>>>       drm_connector_update_edid_property(connector, edid);
>>>>>       count = drm_add_edid_modes(connector, edid);
>>>>>       kfree(edid);
>>>>> @@ -1654,6 +1664,7 @@ static int 
>>>>> ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
>>>>>       return count;
>>>>>     err_kfree:
>
> Here's a minor issue that the goto label should now be called 
> err_mutex_unlock.
>
> Best regards
> Thomas
>
>>>>> + mutex_unlock(&ast->ioregs_lock);
>>>>>       kfree(edid);
>>>>>   err_drm_connector_update_edid_property:
>>>>>       drm_connector_update_edid_property(connector, NULL);
>>>>>
>>>>> base-commit: 61d325dcbc05d8fef88110d35ef7776f3ac3f68b
>>>>
>
-- 
Best Regards
Jammy


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

end of thread, other threads:[~2023-05-25  1:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-25  7:03 [PATCH] drm/ast: Fix modeset failed on DisplayPort Jammy Huang
2023-04-25  7:27 ` Thomas Zimmermann
2023-04-25  7:39   ` Jammy Huang
2023-05-24  2:29     ` Jammy Huang
2023-05-24 10:47       ` Thomas Zimmermann
2023-05-25  1:30         ` Jammy Huang

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