Message ID | 1540949474-1269-1-git-send-email-yc_chen@aspeedtech.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [[PATCH,v2] ] drm/ast: fixed reading monitor EDID not stable issue | expand |
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
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 > <div dir="ltr">Hi Dave,<div>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.</div><div><br></div><div>Regards,</div><div><br></div><div>Y.C. Chen</div></div><br><div class="gmail_quote"><div dir="ltr">Dave Airlie <<a href="mailto:airlied@gmail.com">airlied@gmail.com</a>> 於 2018年11月22日 週四 上午9:15寫道:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Wed, 31 Oct 2018 at 18:12, Y.C. Chen <<a href="mailto:yacheng600221@gmail.com" target="_blank">yacheng600221@gmail.com</a>> wrote:<br> ><br> > From: "Y.C. Chen" <<a href="mailto:yc_chen@aspeedtech.com" target="_blank">yc_chen@aspeedtech.com</a>><br> ><br> > v1: over-sample data to increase the stability with some specific monitors<br> > v2: refine to avoid infinite loop<br> <br> This contains at least 4 whitespace breakages (val =) in a few<br> places, also why the volatiles, I don't think they make much sense<br> here, have you verified they are required?<br> <br> Dave.<br> <br> ><br> > Signed-off-by: Y.C. Chen <<a href="mailto:yc_chen@aspeedtech.com" target="_blank">yc_chen@aspeedtech.com</a>><br> > ---<br> > drivers/gpu/drm/ast/ast_mode.c | 34 ++++++++++++++++++++++++++++------<br> > 1 file changed, 28 insertions(+), 6 deletions(-)<br> ><br> > diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c<br> > index 5e77d45..092e9a7 100644<br> > --- a/drivers/gpu/drm/ast/ast_mode.c<br> > +++ b/drivers/gpu/drm/ast/ast_mode.c<br> > @@ -972,9 +972,20 @@ static int get_clock(void *i2c_priv)<br> > {<br> > struct ast_i2c_chan *i2c = i2c_priv;<br> > struct ast_private *ast = i2c->dev->dev_private;<br> > - uint32_t val;<br> > + volatile uint32_t val, val2, count, pass;<br> > +<br> > + count = 0;<br> > + pass = 0;<br> > + val = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;<br> > + do {<br> > + val2 = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;<br> > + if (val == val2) pass++;<br> > + else {<br> > + pass = 0;<br> > + val = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;<br> <br> <br> <br> <br> > + }<br> > + } while ((pass < 5) && (count++ < 0x10000));<br> ><br> > - val = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4;<br> > return val & 1 ? 1 : 0;<br> > }<br> ><br> > @@ -982,9 +993,20 @@ static int get_data(void *i2c_priv)<br> > {<br> > struct ast_i2c_chan *i2c = i2c_priv;<br> > struct ast_private *ast = i2c->dev->dev_private;<br> > - uint32_t val;<br> > + volatile uint32_t val, val2, count, pass;<br> > +<br> > + count = 0;<br> > + pass = 0;<br> > + val = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;<br> > + do {<br> > + val2 = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;<br> > + if (val == val2) pass++;<br> > + else {<br> > + pass = 0;<br> > + val = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;<br> > + }<br> > + } while ((pass < 5) && (count++ < 0x10000));<br> ><br> > - val = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5;<br> > return val & 1 ? 1 : 0;<br> > }<br> ><br> > @@ -997,7 +1019,7 @@ static void set_clock(void *i2c_priv, int clock)<br> ><br> > for (i = 0; i < 0x10000; i++) {<br> > ujcrb7 = ((clock & 0x01) ? 0 : 1);<br> > - ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xfe, ujcrb7);<br> > + ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xf4, ujcrb7);<br> > jtemp = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x01);<br> > if (ujcrb7 == jtemp)<br> > break;<br> > @@ -1013,7 +1035,7 @@ static void set_data(void *i2c_priv, int data)<br> ><br> > for (i = 0; i < 0x10000; i++) {<br> > ujcrb7 = ((data & 0x01) ? 0 : 1) << 2;<br> > - ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xfb, ujcrb7);<br> > + ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xf1, ujcrb7);<br> > jtemp = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x04);<br> > if (ujcrb7 == jtemp)<br> > break;<br> > --<br> > 1.8.3.1<br> ><br> > _______________________________________________<br> > dri-devel mailing list<br> > <a href="mailto:dri-devel@lists.freedesktop.org" target="_blank">dri-devel@lists.freedesktop.org</a><br> > <a href="https://lists.freedesktop.org/mailman/listinfo/dri-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/dri-devel</a><br> </blockquote></div>
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.
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;