mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] drm/ast: Fix soft lockup
@ 2024-04-03  9:02 Jammy Huang
  2024-04-03  9:32 ` Thomas Zimmermann
  2024-04-05  8:26 ` Thomas Zimmermann
  0 siblings, 2 replies; 4+ messages in thread
From: Jammy Huang @ 2024-04-03  9:02 UTC (permalink / raw)
  To: tzimmermann, jfalempe, maarten.lankhorst, mripard, airlied,
	airlied, daniel
  Cc: dri-devel, linux-kernel

There is a while-loop in ast_dp_set_on_off() that could lead to
infinite-loop. This is because the register, VGACRI-Dx, checked in
this API is a scratch register actually controlled by a MCU, named
DPMCU, in BMC.

These scratch registers are protected by scu-lock. If suc-lock is not
off, DPMCU can not update these registers and then host will have soft
lockup due to never updated status.

DPMCU is used to control DP and relative registers to handshake with
host's VGA driver. Even the most time-consuming task, DP's link
training, is less than 100ms. 200ms should be enough.

Signed-off-by: Jammy Huang <jammy_huang@aspeedtech.com>
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
---
 drivers/gpu/drm/ast/ast_dp.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/ast/ast_dp.c b/drivers/gpu/drm/ast/ast_dp.c
index ebb6d8ebd44e..1e9259416980 100644
--- a/drivers/gpu/drm/ast/ast_dp.c
+++ b/drivers/gpu/drm/ast/ast_dp.c
@@ -180,6 +180,7 @@ void ast_dp_set_on_off(struct drm_device *dev, bool on)
 {
 	struct ast_device *ast = to_ast_device(dev);
 	u8 video_on_off = on;
+	u32 i = 0;
 
 	// Video On/Off
 	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xE3, (u8) ~AST_DP_VIDEO_ENABLE, on);
@@ -192,6 +193,8 @@ void ast_dp_set_on_off(struct drm_device *dev, bool on)
 						ASTDP_MIRROR_VIDEO_ENABLE) != video_on_off) {
 			// wait 1 ms
 			mdelay(1);
+			if (++i > 200)
+				break;
 		}
 	}
 }

base-commit: b0546776ad3f332e215cebc0b063ba4351971cca
-- 
2.25.1


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

* Re: [PATCH v2] drm/ast: Fix soft lockup
  2024-04-03  9:02 [PATCH v2] drm/ast: Fix soft lockup Jammy Huang
@ 2024-04-03  9:32 ` Thomas Zimmermann
  2024-04-05  8:26 ` Thomas Zimmermann
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Zimmermann @ 2024-04-03  9:32 UTC (permalink / raw)
  To: Jammy Huang, jfalempe, maarten.lankhorst, mripard, airlied,
	airlied, daniel
  Cc: dri-devel, linux-kernel



Am 03.04.24 um 11:02 schrieb Jammy Huang:
> There is a while-loop in ast_dp_set_on_off() that could lead to
> infinite-loop. This is because the register, VGACRI-Dx, checked in
> this API is a scratch register actually controlled by a MCU, named
> DPMCU, in BMC.
>
> These scratch registers are protected by scu-lock. If suc-lock is not
> off, DPMCU can not update these registers and then host will have soft
> lockup due to never updated status.
>
> DPMCU is used to control DP and relative registers to handshake with
> host's VGA driver. Even the most time-consuming task, DP's link
> training, is less than 100ms. 200ms should be enough.
>
> Signed-off-by: Jammy Huang <jammy_huang@aspeedtech.com>
> Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

> ---
>   drivers/gpu/drm/ast/ast_dp.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/ast/ast_dp.c b/drivers/gpu/drm/ast/ast_dp.c
> index ebb6d8ebd44e..1e9259416980 100644
> --- a/drivers/gpu/drm/ast/ast_dp.c
> +++ b/drivers/gpu/drm/ast/ast_dp.c
> @@ -180,6 +180,7 @@ void ast_dp_set_on_off(struct drm_device *dev, bool on)
>   {
>   	struct ast_device *ast = to_ast_device(dev);
>   	u8 video_on_off = on;
> +	u32 i = 0;
>   
>   	// Video On/Off
>   	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xE3, (u8) ~AST_DP_VIDEO_ENABLE, on);
> @@ -192,6 +193,8 @@ void ast_dp_set_on_off(struct drm_device *dev, bool on)
>   						ASTDP_MIRROR_VIDEO_ENABLE) != video_on_off) {
>   			// wait 1 ms
>   			mdelay(1);
> +			if (++i > 200)
> +				break;
>   		}
>   	}
>   }
>
> base-commit: b0546776ad3f332e215cebc0b063ba4351971cca

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


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

* Re: [PATCH v2] drm/ast: Fix soft lockup
  2024-04-03  9:02 [PATCH v2] drm/ast: Fix soft lockup Jammy Huang
  2024-04-03  9:32 ` Thomas Zimmermann
@ 2024-04-05  8:26 ` Thomas Zimmermann
  2024-04-08  9:31   ` Jammy Huang
  1 sibling, 1 reply; 4+ messages in thread
From: Thomas Zimmermann @ 2024-04-05  8:26 UTC (permalink / raw)
  To: Jammy Huang, jfalempe, maarten.lankhorst, mripard, airlied,
	airlied, daniel
  Cc: dri-devel, linux-kernel

Hi,

I've added a Fixes tag and pushed to patch into drm-misc-fixes.

Best regards
Thomas

Am 03.04.24 um 11:02 schrieb Jammy Huang:
> There is a while-loop in ast_dp_set_on_off() that could lead to
> infinite-loop. This is because the register, VGACRI-Dx, checked in
> this API is a scratch register actually controlled by a MCU, named
> DPMCU, in BMC.
>
> These scratch registers are protected by scu-lock. If suc-lock is not
> off, DPMCU can not update these registers and then host will have soft
> lockup due to never updated status.
>
> DPMCU is used to control DP and relative registers to handshake with
> host's VGA driver. Even the most time-consuming task, DP's link
> training, is less than 100ms. 200ms should be enough.
>
> Signed-off-by: Jammy Huang <jammy_huang@aspeedtech.com>
> Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
> ---
>   drivers/gpu/drm/ast/ast_dp.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/ast/ast_dp.c b/drivers/gpu/drm/ast/ast_dp.c
> index ebb6d8ebd44e..1e9259416980 100644
> --- a/drivers/gpu/drm/ast/ast_dp.c
> +++ b/drivers/gpu/drm/ast/ast_dp.c
> @@ -180,6 +180,7 @@ void ast_dp_set_on_off(struct drm_device *dev, bool on)
>   {
>   	struct ast_device *ast = to_ast_device(dev);
>   	u8 video_on_off = on;
> +	u32 i = 0;
>   
>   	// Video On/Off
>   	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xE3, (u8) ~AST_DP_VIDEO_ENABLE, on);
> @@ -192,6 +193,8 @@ void ast_dp_set_on_off(struct drm_device *dev, bool on)
>   						ASTDP_MIRROR_VIDEO_ENABLE) != video_on_off) {
>   			// wait 1 ms
>   			mdelay(1);
> +			if (++i > 200)
> +				break;
>   		}
>   	}
>   }
>
> base-commit: b0546776ad3f332e215cebc0b063ba4351971cca

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


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

* RE: [PATCH v2] drm/ast: Fix soft lockup
  2024-04-05  8:26 ` Thomas Zimmermann
@ 2024-04-08  9:31   ` Jammy Huang
  0 siblings, 0 replies; 4+ messages in thread
From: Jammy Huang @ 2024-04-08  9:31 UTC (permalink / raw)
  To: Thomas Zimmermann, jfalempe, maarten.lankhorst, mripard, airlied,
	airlied, daniel
  Cc: dri-devel, linux-kernel

Hi Thomas,

Thank you.

Regards,
Jammy Huang

> 
> Hi,
> 
> I've added a Fixes tag and pushed to patch into drm-misc-fixes.
> 
> Best regards
> Thomas
> 
> Am 03.04.24 um 11:02 schrieb Jammy Huang:
> > There is a while-loop in ast_dp_set_on_off() that could lead to
> > infinite-loop. This is because the register, VGACRI-Dx, checked in
> > this API is a scratch register actually controlled by a MCU, named
> > DPMCU, in BMC.
> >
> > These scratch registers are protected by scu-lock. If suc-lock is not
> > off, DPMCU can not update these registers and then host will have soft
> > lockup due to never updated status.
> >
> > DPMCU is used to control DP and relative registers to handshake with
> > host's VGA driver. Even the most time-consuming task, DP's link
> > training, is less than 100ms. 200ms should be enough.
> >
> > Signed-off-by: Jammy Huang <jammy_huang@aspeedtech.com>
> > Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
> > ---
> >   drivers/gpu/drm/ast/ast_dp.c | 3 +++
> >   1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/ast/ast_dp.c
> > b/drivers/gpu/drm/ast/ast_dp.c index ebb6d8ebd44e..1e9259416980 100644
> > --- a/drivers/gpu/drm/ast/ast_dp.c
> > +++ b/drivers/gpu/drm/ast/ast_dp.c
> > @@ -180,6 +180,7 @@ void ast_dp_set_on_off(struct drm_device *dev, bool
> on)
> >   {
> >   	struct ast_device *ast = to_ast_device(dev);
> >   	u8 video_on_off = on;
> > +	u32 i = 0;
> >
> >   	// Video On/Off
> >   	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xE3, (u8)
> > ~AST_DP_VIDEO_ENABLE, on); @@ -192,6 +193,8 @@ void
> ast_dp_set_on_off(struct drm_device *dev, bool on)
> >   						ASTDP_MIRROR_VIDEO_ENABLE) !=
> video_on_off) {
> >   			// wait 1 ms
> >   			mdelay(1);
> > +			if (++i > 200)
> > +				break;
> >   		}
> >   	}
> >   }
> >
> > base-commit: b0546776ad3f332e215cebc0b063ba4351971cca
> 
> --
> --
> 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)


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

end of thread, other threads:[~2024-04-08  9:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-03  9:02 [PATCH v2] drm/ast: Fix soft lockup Jammy Huang
2024-04-03  9:32 ` Thomas Zimmermann
2024-04-05  8:26 ` Thomas Zimmermann
2024-04-08  9:31   ` Jammy Huang

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®