All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/ast: fixed reading monitor EDID not stable issue
@ 2018-10-30  6:00 Y.C. Chen
  2018-10-30 13:01 ` Ilia Mirkin
  2018-10-31  1:31 ` [[PATCH v2]] " Y.C. Chen
  0 siblings, 2 replies; 7+ messages in thread
From: Y.C. Chen @ 2018-10-30  6:00 UTC (permalink / raw)
  To: dri-devel; +Cc: airlied, eich, benh, stable, daniel, yc_chen

From: "Y.C. Chen" <yc_chen@aspeedtech.com>

over-sample data to increase the stability with some specific monitors

Signed-off-by: Y.C. Chen <yc_chen@aspeedtech.com>
---
 drivers/gpu/drm/ast/ast_mode.c | 32 ++++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index 5e77d45..22e80c0 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -972,9 +972,19 @@ static int get_clock(void *i2c_priv)
 {
 	struct ast_i2c_chan *i2c = i2c_priv;
 	struct ast_private *ast = i2c->dev->dev_private;
-	uint32_t val;
+	volatile uint32_t val, val2, count;
+
+	count = 0;
+	val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
+	do {
+		val2 = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
+		if (val == val2) count++;
+		else {
+			count = 0;
+			val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
+		}
+	} while (count < 5);
 
-	val = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4;
 	return val & 1 ? 1 : 0;
 }
 
@@ -982,9 +992,19 @@ static int get_data(void *i2c_priv)
 {
 	struct ast_i2c_chan *i2c = i2c_priv;
 	struct ast_private *ast = i2c->dev->dev_private;
-	uint32_t val;
+	volatile uint32_t val, val2, count;
+
+	count = 0;
+	val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;
+	do {
+		val2 = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;
+		if (val == val2) count++;
+		else {
+			count = 0;
+			val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;
+		}
+	} while (count < 5);
 
-	val = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5;
 	return val & 1 ? 1 : 0;
 }
 
@@ -997,7 +1017,7 @@ static void set_clock(void *i2c_priv, int clock)
 
 	for (i = 0; i < 0x10000; i++) {
 		ujcrb7 = ((clock & 0x01) ? 0 : 1);
-		ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xfe, ujcrb7);
+		ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xf4, ujcrb7);
 		jtemp = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x01);
 		if (ujcrb7 == jtemp)
 			break;
@@ -1013,7 +1033,7 @@ static void set_data(void *i2c_priv, int data)
 
 	for (i = 0; i < 0x10000; i++) {
 		ujcrb7 = ((data & 0x01) ? 0 : 1) << 2;
-		ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xfb, ujcrb7);
+		ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xf1, ujcrb7);
 		jtemp = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x04);
 		if (ujcrb7 == jtemp)
 			break;
-- 
1.8.3.1

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

* Re: [PATCH] drm/ast: fixed reading monitor EDID not stable issue
  2018-10-30  6:00 [PATCH] drm/ast: fixed reading monitor EDID not stable issue Y.C. Chen
@ 2018-10-30 13:01 ` Ilia Mirkin
  2018-10-31  1:31 ` [[PATCH v2]] " Y.C. Chen
  1 sibling, 0 replies; 7+ messages in thread
From: Ilia Mirkin @ 2018-10-30 13:01 UTC (permalink / raw)
  To: yacheng600221; +Cc: dri-devel, # 3.9+, eich, Dave Airlie

On Tue, Oct 30, 2018 at 4:24 AM Y.C. Chen <yacheng600221@gmail.com> wrote:
>
> From: "Y.C. Chen" <yc_chen@aspeedtech.com>
>
> over-sample data to increase the stability with some specific monitors
>
> Signed-off-by: Y.C. Chen <yc_chen@aspeedtech.com>
> ---
>  drivers/gpu/drm/ast/ast_mode.c | 32 ++++++++++++++++++++++++++------
>  1 file changed, 26 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
> index 5e77d45..22e80c0 100644
> --- a/drivers/gpu/drm/ast/ast_mode.c
> +++ b/drivers/gpu/drm/ast/ast_mode.c
> @@ -972,9 +972,19 @@ static int get_clock(void *i2c_priv)
>  {
>         struct ast_i2c_chan *i2c = i2c_priv;
>         struct ast_private *ast = i2c->dev->dev_private;
> -       uint32_t val;
> +       volatile uint32_t val, val2, count;
> +
> +       count = 0;
> +       val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
> +       do {
> +               val2 = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
> +               if (val == val2) count++;
> +               else {
> +                       count = 0;
> +                       val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
> +               }
> +       } while (count < 5);

This can lead to an infinite loop if there's no stable output, no? I
think those are frowned upon in the kernel...

Cheers,

  -ilia

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

* [[PATCH v2]] drm/ast: fixed reading monitor EDID not stable issue
  2018-10-30  6:00 [PATCH] drm/ast: fixed reading monitor EDID not stable issue Y.C. Chen
  2018-10-30 13:01 ` Ilia Mirkin
@ 2018-10-31  1:31 ` Y.C. Chen
  2018-11-22  1:15   ` Dave Airlie
  2018-11-22  3:56   ` [PATCH v3] " Y.C. Chen
  1 sibling, 2 replies; 7+ messages in thread
From: Y.C. Chen @ 2018-10-31  1:31 UTC (permalink / raw)
  To: dri-devel; +Cc: airlied, eich, imirkin, yc_chen, stable

From: "Y.C. Chen" <yc_chen@aspeedtech.com>

v1: over-sample data to increase the stability with some specific monitors
v2: refine to avoid infinite loop

Signed-off-by: Y.C. Chen <yc_chen@aspeedtech.com>
---
 drivers/gpu/drm/ast/ast_mode.c | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index 5e77d45..092e9a7 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -972,9 +972,20 @@ static int get_clock(void *i2c_priv)
 {
 	struct ast_i2c_chan *i2c = i2c_priv;
 	struct ast_private *ast = i2c->dev->dev_private;
-	uint32_t val;
+	volatile uint32_t val, val2, count, pass;
+
+	count = 0;
+	pass  = 0;
+	val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
+	do {
+		val2 = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
+		if (val == val2) pass++;
+		else {
+			pass = 0;
+			val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
+		}
+	} while ((pass < 5) && (count++ < 0x10000));
 
-	val = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4;
 	return val & 1 ? 1 : 0;
 }
 
@@ -982,9 +993,20 @@ static int get_data(void *i2c_priv)
 {
 	struct ast_i2c_chan *i2c = i2c_priv;
 	struct ast_private *ast = i2c->dev->dev_private;
-	uint32_t val;
+	volatile uint32_t val, val2, count, pass;
+
+	count = 0;
+	pass  = 0;
+	val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;
+	do {
+		val2 = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;
+		if (val == val2) pass++;
+		else {
+			pass = 0;
+			val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;
+		}
+	} while ((pass < 5) && (count++ < 0x10000));
 
-	val = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5;
 	return val & 1 ? 1 : 0;
 }
 
@@ -997,7 +1019,7 @@ static void set_clock(void *i2c_priv, int clock)
 
 	for (i = 0; i < 0x10000; i++) {
 		ujcrb7 = ((clock & 0x01) ? 0 : 1);
-		ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xfe, ujcrb7);
+		ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xf4, ujcrb7);
 		jtemp = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x01);
 		if (ujcrb7 == jtemp)
 			break;
@@ -1013,7 +1035,7 @@ static void set_data(void *i2c_priv, int data)
 
 	for (i = 0; i < 0x10000; i++) {
 		ujcrb7 = ((data & 0x01) ? 0 : 1) << 2;
-		ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xfb, ujcrb7);
+		ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xf1, ujcrb7);
 		jtemp = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x04);
 		if (ujcrb7 == jtemp)
 			break;
-- 
1.8.3.1

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

* Re: [[PATCH v2]] drm/ast: fixed reading monitor EDID not stable issue
  2018-10-31  1:31 ` [[PATCH v2]] " Y.C. Chen
@ 2018-11-22  1:15   ` Dave Airlie
  2018-11-22  1:42     ` 陳雅正
  2018-11-22  3:56   ` [PATCH v3] " Y.C. Chen
  1 sibling, 1 reply; 7+ messages in thread
From: Dave Airlie @ 2018-11-22  1:15 UTC (permalink / raw)
  To: yacheng600221; +Cc: dri-devel, Dave Airlie, stable, Egbert Eich

On Wed, 31 Oct 2018 at 18:12, Y.C. Chen <yacheng600221@gmail.com> wrote:
>
> From: "Y.C. Chen" <yc_chen@aspeedtech.com>
>
> v1: over-sample data to increase the stability with some specific monitors
> v2: refine to avoid infinite loop

This contains at least 4 whitespace breakages (val  =) in a few
places, also why the volatiles, I don't think they make much sense
here, have you verified they are required?

Dave.

>
> Signed-off-by: Y.C. Chen <yc_chen@aspeedtech.com>
> ---
>  drivers/gpu/drm/ast/ast_mode.c | 34 ++++++++++++++++++++++++++++------
>  1 file changed, 28 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
> index 5e77d45..092e9a7 100644
> --- a/drivers/gpu/drm/ast/ast_mode.c
> +++ b/drivers/gpu/drm/ast/ast_mode.c
> @@ -972,9 +972,20 @@ static int get_clock(void *i2c_priv)
>  {
>         struct ast_i2c_chan *i2c = i2c_priv;
>         struct ast_private *ast = i2c->dev->dev_private;
> -       uint32_t val;
> +       volatile uint32_t val, val2, count, pass;
> +
> +       count = 0;
> +       pass  = 0;
> +       val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
> +       do {
> +               val2 = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
> +               if (val == val2) pass++;
> +               else {
> +                       pass = 0;
> +                       val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;




> +               }
> +       } while ((pass < 5) && (count++ < 0x10000));
>
> -       val = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4;
>         return val & 1 ? 1 : 0;
>  }
>
> @@ -982,9 +993,20 @@ static int get_data(void *i2c_priv)
>  {
>         struct ast_i2c_chan *i2c = i2c_priv;
>         struct ast_private *ast = i2c->dev->dev_private;
> -       uint32_t val;
> +       volatile uint32_t val, val2, count, pass;
> +
> +       count = 0;
> +       pass  = 0;
> +       val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;
> +       do {
> +               val2 = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;
> +               if (val == val2) pass++;
> +               else {
> +                       pass = 0;
> +                       val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;
> +               }
> +       } while ((pass < 5) && (count++ < 0x10000));
>
> -       val = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5;
>         return val & 1 ? 1 : 0;
>  }
>
> @@ -997,7 +1019,7 @@ static void set_clock(void *i2c_priv, int clock)
>
>         for (i = 0; i < 0x10000; i++) {
>                 ujcrb7 = ((clock & 0x01) ? 0 : 1);
> -               ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xfe, ujcrb7);
> +               ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xf4, ujcrb7);
>                 jtemp = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x01);
>                 if (ujcrb7 == jtemp)
>                         break;
> @@ -1013,7 +1035,7 @@ static void set_data(void *i2c_priv, int data)
>
>         for (i = 0; i < 0x10000; i++) {
>                 ujcrb7 = ((data & 0x01) ? 0 : 1) << 2;
> -               ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xfb, ujcrb7);
> +               ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xf1, ujcrb7);
>                 jtemp = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x04);
>                 if (ujcrb7 == jtemp)
>                         break;
> --
> 1.8.3.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [[PATCH v2]] drm/ast: fixed reading monitor EDID not stable issue
  2018-11-22  1:15   ` Dave Airlie
@ 2018-11-22  1:42     ` 陳雅正
  2018-11-22  2:48       ` Dave Airlie
  0 siblings, 1 reply; 7+ messages in thread
From: 陳雅正 @ 2018-11-22  1:42 UTC (permalink / raw)
  To: airlied; +Cc: airlied, stable, dri-devel, eich


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

Hi Dave,
Thanks for your feedback. No issue found actually if I remove "volatile" on
my platform. In my experience, if the value is volatile, adding "volatile"
will be safer and no harm, that is why I add it by default. If you think it
is not necessary, it's ok for me to remove it.

Regards,

Y.C. Chen

Dave Airlie <airlied@gmail.com> 於 2018年11月22日 週四 上午9:15寫道:

> On Wed, 31 Oct 2018 at 18:12, Y.C. Chen <yacheng600221@gmail.com> wrote:
> >
> > From: "Y.C. Chen" <yc_chen@aspeedtech.com>
> >
> > v1: over-sample data to increase the stability with some specific
> monitors
> > v2: refine to avoid infinite loop
>
> This contains at least 4 whitespace breakages (val  =) in a few
> places, also why the volatiles, I don't think they make much sense
> here, have you verified they are required?
>
> Dave.
>
> >
> > Signed-off-by: Y.C. Chen <yc_chen@aspeedtech.com>
> > ---
> >  drivers/gpu/drm/ast/ast_mode.c | 34 ++++++++++++++++++++++++++++------
> >  1 file changed, 28 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/ast/ast_mode.c
> b/drivers/gpu/drm/ast/ast_mode.c
> > index 5e77d45..092e9a7 100644
> > --- a/drivers/gpu/drm/ast/ast_mode.c
> > +++ b/drivers/gpu/drm/ast/ast_mode.c
> > @@ -972,9 +972,20 @@ static int get_clock(void *i2c_priv)
> >  {
> >         struct ast_i2c_chan *i2c = i2c_priv;
> >         struct ast_private *ast = i2c->dev->dev_private;
> > -       uint32_t val;
> > +       volatile uint32_t val, val2, count, pass;
> > +
> > +       count = 0;
> > +       pass  = 0;
> > +       val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7,
> 0x10) >> 4) & 0x01;
> > +       do {
> > +               val2 = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT,
> 0xb7, 0x10) >> 4) & 0x01;
> > +               if (val == val2) pass++;
> > +               else {
> > +                       pass = 0;
> > +                       val   = (ast_get_index_reg_mask(ast,
> AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
>
>
>
>
> > +               }
> > +       } while ((pass < 5) && (count++ < 0x10000));
> >
> > -       val = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10)
> >> 4;
> >         return val & 1 ? 1 : 0;
> >  }
> >
> > @@ -982,9 +993,20 @@ static int get_data(void *i2c_priv)
> >  {
> >         struct ast_i2c_chan *i2c = i2c_priv;
> >         struct ast_private *ast = i2c->dev->dev_private;
> > -       uint32_t val;
> > +       volatile uint32_t val, val2, count, pass;
> > +
> > +       count = 0;
> > +       pass  = 0;
> > +       val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7,
> 0x20) >> 5) & 0x01;
> > +       do {
> > +               val2 = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT,
> 0xb7, 0x20) >> 5) & 0x01;
> > +               if (val == val2) pass++;
> > +               else {
> > +                       pass = 0;
> > +                       val   = (ast_get_index_reg_mask(ast,
> AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;
> > +               }
> > +       } while ((pass < 5) && (count++ < 0x10000));
> >
> > -       val = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20)
> >> 5;
> >         return val & 1 ? 1 : 0;
> >  }
> >
> > @@ -997,7 +1019,7 @@ static void set_clock(void *i2c_priv, int clock)
> >
> >         for (i = 0; i < 0x10000; i++) {
> >                 ujcrb7 = ((clock & 0x01) ? 0 : 1);
> > -               ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7,
> 0xfe, ujcrb7);
> > +               ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7,
> 0xf4, ujcrb7);
> >                 jtemp = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT,
> 0xb7, 0x01);
> >                 if (ujcrb7 == jtemp)
> >                         break;
> > @@ -1013,7 +1035,7 @@ static void set_data(void *i2c_priv, int data)
> >
> >         for (i = 0; i < 0x10000; i++) {
> >                 ujcrb7 = ((data & 0x01) ? 0 : 1) << 2;
> > -               ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7,
> 0xfb, ujcrb7);
> > +               ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7,
> 0xf1, ujcrb7);
> >                 jtemp = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT,
> 0xb7, 0x04);
> >                 if (ujcrb7 == jtemp)
> >                         break;
> > --
> > 1.8.3.1
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
>

[-- Attachment #1.2: Type: text/html, Size: 6117 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [[PATCH v2]] drm/ast: fixed reading monitor EDID not stable issue
  2018-11-22  1:42     ` 陳雅正
@ 2018-11-22  2:48       ` Dave Airlie
  0 siblings, 0 replies; 7+ messages in thread
From: Dave Airlie @ 2018-11-22  2:48 UTC (permalink / raw)
  To: yacheng600221; +Cc: dri-devel, Dave Airlie, stable, Egbert Eich, Y.C. Chen

On Thu, 22 Nov 2018 at 11:42, 陳雅正 <yacheng600221@gmail.com> wrote:
>
> Hi Dave,
> Thanks for your feedback. No issue found actually if I remove "volatile" on my platform. In my experience, if the value is volatile, adding "volatile" will be safer and no harm, that is why I add it by default. If you think it is not necessary, it's ok for me to remove it.
>

Don't add it unless you've got proof you need it, we don't want it
confusing people later.

Dave.

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

* [PATCH v3] drm/ast: fixed reading monitor EDID not stable issue
  2018-10-31  1:31 ` [[PATCH v2]] " Y.C. Chen
  2018-11-22  1:15   ` Dave Airlie
@ 2018-11-22  3:56   ` Y.C. Chen
  1 sibling, 0 replies; 7+ messages in thread
From: Y.C. Chen @ 2018-11-22  3:56 UTC (permalink / raw)
  To: dri-devel; +Cc: airlied, eich, stable, yc_chen

From: "Y.C. Chen" <yc_chen@aspeedtech.com>

v1: over-sample data to increase the stability with some specific monitors
v2: refine to avoid infinite loop
v3: remove un-necessary "volatile" declaration

Signed-off-by: Y.C. Chen <yc_chen@aspeedtech.com>
---
 drivers/gpu/drm/ast/ast_mode.c | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index 5e77d45..843e2f9 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -972,9 +972,20 @@ static int get_clock(void *i2c_priv)
 {
 	struct ast_i2c_chan *i2c = i2c_priv;
 	struct ast_private *ast = i2c->dev->dev_private;
-	uint32_t val;
+	uint32_t val, val2, count, pass;
+
+	count = 0;
+	pass = 0;
+	val = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
+	do {
+		val2 = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
+		if (val == val2) pass++;
+		else {
+			pass = 0;
+			val = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
+		}
+	} while ((pass < 5) && (count++ < 0x10000));
 
-	val = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4;
 	return val & 1 ? 1 : 0;
 }
 
@@ -982,9 +993,20 @@ static int get_data(void *i2c_priv)
 {
 	struct ast_i2c_chan *i2c = i2c_priv;
 	struct ast_private *ast = i2c->dev->dev_private;
-	uint32_t val;
+	uint32_t val, val2, count, pass;
+
+	count = 0;
+	pass = 0;
+	val = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;
+	do {
+		val2 = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;
+		if (val == val2) pass++;
+		else {
+			pass = 0;
+			val = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;
+		}
+	} while ((pass < 5) && (count++ < 0x10000));
 
-	val = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5;
 	return val & 1 ? 1 : 0;
 }
 
@@ -997,7 +1019,7 @@ static void set_clock(void *i2c_priv, int clock)
 
 	for (i = 0; i < 0x10000; i++) {
 		ujcrb7 = ((clock & 0x01) ? 0 : 1);
-		ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xfe, ujcrb7);
+		ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xf4, ujcrb7);
 		jtemp = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x01);
 		if (ujcrb7 == jtemp)
 			break;
@@ -1013,7 +1035,7 @@ static void set_data(void *i2c_priv, int data)
 
 	for (i = 0; i < 0x10000; i++) {
 		ujcrb7 = ((data & 0x01) ? 0 : 1) << 2;
-		ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xfb, ujcrb7);
+		ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xf1, ujcrb7);
 		jtemp = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x04);
 		if (ujcrb7 == jtemp)
 			break;
-- 
1.8.3.1

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

end of thread, other threads:[~2018-11-22 14:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-30  6:00 [PATCH] drm/ast: fixed reading monitor EDID not stable issue Y.C. Chen
2018-10-30 13:01 ` Ilia Mirkin
2018-10-31  1:31 ` [[PATCH v2]] " Y.C. Chen
2018-11-22  1:15   ` Dave Airlie
2018-11-22  1:42     ` 陳雅正
2018-11-22  2:48       ` Dave Airlie
2018-11-22  3:56   ` [PATCH v3] " Y.C. Chen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.