Message ID | 20240429-fix-cocci-v3-26-3c4865f5a4b0@chromium.org (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
Series | media: Fix coccinelle warning/errors | expand |
Em Mon, 29 Apr 2024 15:05:05 +0000 Ricardo Ribalda <ribalda@chromium.org> escreveu: > We do not expect the sample_freq to be over 613MHz. > > Found by cocci: > drivers/media/dvb-frontends/tda10048.c:345:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > --- > drivers/media/dvb-frontends/tda10048.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/media/dvb-frontends/tda10048.c b/drivers/media/dvb-frontends/tda10048.c > index 3e725cdcc66b..1886f733dbbf 100644 > --- a/drivers/media/dvb-frontends/tda10048.c > +++ b/drivers/media/dvb-frontends/tda10048.c > @@ -328,7 +328,8 @@ static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz, > u32 bw) > { > struct tda10048_state *state = fe->demodulator_priv; > - u64 t, z; > + u32 z; > + u64 t; > > dprintk(1, "%s()\n", __func__); > > @@ -341,6 +342,7 @@ static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz, > /* t *= 2147483648 on 32bit platforms */ > t *= (2048 * 1024); > t *= 1024; > + /* Sample frequency is under 613MHz */ Are you sure about that? Some DVB devices have very high frequency clocks, specially if they're also used for satellite, so I can't be sure by just looking at the driver's code. Also, we had already a bunch of regressions with "fixes" like this that actually broke frontend drivers. If you're sure, please add a note at the description mentioning on what part of the datasheet you got it. Otherwise, let's stick with the current code and address cocci warning on a different way. Regards, Mauro PS.: I partially applied this patch series. I left a few patches out of the merge to let other people review/comment (and/or for me to take a deeper look later on). Regards, Mauro
On Fri, May 03, 2024 at 11:27:58AM +0100, Mauro Carvalho Chehab wrote: > Em Mon, 29 Apr 2024 15:05:05 +0000 > Ricardo Ribalda <ribalda@chromium.org> escreveu: > > > We do not expect the sample_freq to be over 613MHz. > > > > Found by cocci: > > drivers/media/dvb-frontends/tda10048.c:345:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. > > > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > > --- > > drivers/media/dvb-frontends/tda10048.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/media/dvb-frontends/tda10048.c b/drivers/media/dvb-frontends/tda10048.c > > index 3e725cdcc66b..1886f733dbbf 100644 > > --- a/drivers/media/dvb-frontends/tda10048.c > > +++ b/drivers/media/dvb-frontends/tda10048.c > > @@ -328,7 +328,8 @@ static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz, > > u32 bw) > > { > > struct tda10048_state *state = fe->demodulator_priv; > > - u64 t, z; > > + u32 z; > > + u64 t; > > > > dprintk(1, "%s()\n", __func__); > > > > @@ -341,6 +342,7 @@ static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz, > > /* t *= 2147483648 on 32bit platforms */ > > t *= (2048 * 1024); > > t *= 1024; > > + /* Sample frequency is under 613MHz */ > > Are you sure about that? Some DVB devices have very high frequency > clocks, specially if they're also used for satellite, so I can't > be sure by just looking at the driver's code. > > Also, we had already a bunch of regressions with "fixes" like this > that actually broke frontend drivers. This patch preserves the existing behavior. The sample_freq_hz variable is a u32 so, in the original code, z couldn't have been more than U32_MAX even though it was declared as a u64. It's possible that the original code was wrong. We have seen that in other places in this patchset. Adding a note about the datasheet is also a good idea. regards, dan carpenter
I am trying to get the DS, but https://www.nxp.com/acrobat_download/literature/9397/75015931.pdf is a dead links now. Anyone have access to the datasheet? Thanks! On Fri, 3 May 2024 at 13:55, Dan Carpenter <dan.carpenter@linaro.org> wrote: > > On Fri, May 03, 2024 at 11:27:58AM +0100, Mauro Carvalho Chehab wrote: > > Em Mon, 29 Apr 2024 15:05:05 +0000 > > Ricardo Ribalda <ribalda@chromium.org> escreveu: > > > > > We do not expect the sample_freq to be over 613MHz. > > > > > > Found by cocci: > > > drivers/media/dvb-frontends/tda10048.c:345:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. > > > > > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > > > --- > > > drivers/media/dvb-frontends/tda10048.c | 4 +++- > > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/media/dvb-frontends/tda10048.c b/drivers/media/dvb-frontends/tda10048.c > > > index 3e725cdcc66b..1886f733dbbf 100644 > > > --- a/drivers/media/dvb-frontends/tda10048.c > > > +++ b/drivers/media/dvb-frontends/tda10048.c > > > @@ -328,7 +328,8 @@ static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz, > > > u32 bw) > > > { > > > struct tda10048_state *state = fe->demodulator_priv; > > > - u64 t, z; > > > + u32 z; > > > + u64 t; > > > > > > dprintk(1, "%s()\n", __func__); > > > > > > @@ -341,6 +342,7 @@ static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz, > > > /* t *= 2147483648 on 32bit platforms */ > > > t *= (2048 * 1024); > > > t *= 1024; > > > + /* Sample frequency is under 613MHz */ > > > > Are you sure about that? Some DVB devices have very high frequency > > clocks, specially if they're also used for satellite, so I can't > > be sure by just looking at the driver's code. > > > > Also, we had already a bunch of regressions with "fixes" like this > > that actually broke frontend drivers. > > This patch preserves the existing behavior. The sample_freq_hz variable > is a u32 so, in the original code, z couldn't have been more than > U32_MAX even though it was declared as a u64. > > It's possible that the original code was wrong. We have seen that in > other places in this patchset. Adding a note about the datasheet is > also a good idea. > > regards, > dan carpenter >
Hello Ricardo, On 2024-05-03 13:56, Ricardo Ribalda wrote: > I am trying to get the DS, but > https://www.nxp.com/acrobat_download/literature/9397/75015931.pdf is a > dead links now. > > Anyone have access to the datasheet? It's kind of available on the link below, but for some strange reason the download fails after downloading the first 128 KB or so. https://web.archive.org/web/20080907185532/https://www.nxp.com/acrobat_download/literature/9397/75015931.pdf > On Fri, 3 May 2024 at 13:55, Dan Carpenter <dan.carpenter@linaro.org> > wrote: >> >> On Fri, May 03, 2024 at 11:27:58AM +0100, Mauro Carvalho Chehab wrote: >> > Em Mon, 29 Apr 2024 15:05:05 +0000 >> > Ricardo Ribalda <ribalda@chromium.org> escreveu: >> > >> > > We do not expect the sample_freq to be over 613MHz. >> > > >> > > Found by cocci: >> > > drivers/media/dvb-frontends/tda10048.c:345:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. >> > > >> > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> >> > > --- >> > > drivers/media/dvb-frontends/tda10048.c | 4 +++- >> > > 1 file changed, 3 insertions(+), 1 deletion(-) >> > > >> > > diff --git a/drivers/media/dvb-frontends/tda10048.c b/drivers/media/dvb-frontends/tda10048.c >> > > index 3e725cdcc66b..1886f733dbbf 100644 >> > > --- a/drivers/media/dvb-frontends/tda10048.c >> > > +++ b/drivers/media/dvb-frontends/tda10048.c >> > > @@ -328,7 +328,8 @@ static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz, >> > > u32 bw) >> > > { >> > > struct tda10048_state *state = fe->demodulator_priv; >> > > - u64 t, z; >> > > + u32 z; >> > > + u64 t; >> > > >> > > dprintk(1, "%s()\n", __func__); >> > > >> > > @@ -341,6 +342,7 @@ static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz, >> > > /* t *= 2147483648 on 32bit platforms */ >> > > t *= (2048 * 1024); >> > > t *= 1024; >> > > + /* Sample frequency is under 613MHz */ >> > >> > Are you sure about that? Some DVB devices have very high frequency >> > clocks, specially if they're also used for satellite, so I can't >> > be sure by just looking at the driver's code. >> > >> > Also, we had already a bunch of regressions with "fixes" like this >> > that actually broke frontend drivers. >> >> This patch preserves the existing behavior. The sample_freq_hz >> variable >> is a u32 so, in the original code, z couldn't have been more than >> U32_MAX even though it was declared as a u64. >> >> It's possible that the original code was wrong. We have seen that in >> other places in this patchset. Adding a note about the datasheet is >> also a good idea. >> >> regards, >> dan carpenter >>
On Fri, 3 May 2024 at 16:08, Dragan Simic <dsimic@manjaro.org> wrote: > > Hello Ricardo, > > On 2024-05-03 13:56, Ricardo Ribalda wrote: > > I am trying to get the DS, but > > https://www.nxp.com/acrobat_download/literature/9397/75015931.pdf is a > > dead links now. > > > > Anyone have access to the datasheet? > > It's kind of available on the link below, but for some strange reason > the download fails after downloading the first 128 KB or so. > > https://web.archive.org/web/20080907185532/https://www.nxp.com/acrobat_download/literature/9397/75015931.pdf\ Mike, by any chance do you have a copy of the DS? > > > > On Fri, 3 May 2024 at 13:55, Dan Carpenter <dan.carpenter@linaro.org> > > wrote: > >> > >> On Fri, May 03, 2024 at 11:27:58AM +0100, Mauro Carvalho Chehab wrote: > >> > Em Mon, 29 Apr 2024 15:05:05 +0000 > >> > Ricardo Ribalda <ribalda@chromium.org> escreveu: > >> > > >> > > We do not expect the sample_freq to be over 613MHz. > >> > > > >> > > Found by cocci: > >> > > drivers/media/dvb-frontends/tda10048.c:345:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. > >> > > > >> > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > >> > > --- > >> > > drivers/media/dvb-frontends/tda10048.c | 4 +++- > >> > > 1 file changed, 3 insertions(+), 1 deletion(-) > >> > > > >> > > diff --git a/drivers/media/dvb-frontends/tda10048.c b/drivers/media/dvb-frontends/tda10048.c > >> > > index 3e725cdcc66b..1886f733dbbf 100644 > >> > > --- a/drivers/media/dvb-frontends/tda10048.c > >> > > +++ b/drivers/media/dvb-frontends/tda10048.c > >> > > @@ -328,7 +328,8 @@ static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz, > >> > > u32 bw) > >> > > { > >> > > struct tda10048_state *state = fe->demodulator_priv; > >> > > - u64 t, z; > >> > > + u32 z; > >> > > + u64 t; > >> > > > >> > > dprintk(1, "%s()\n", __func__); > >> > > > >> > > @@ -341,6 +342,7 @@ static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz, > >> > > /* t *= 2147483648 on 32bit platforms */ > >> > > t *= (2048 * 1024); > >> > > t *= 1024; > >> > > + /* Sample frequency is under 613MHz */ > >> > > >> > Are you sure about that? Some DVB devices have very high frequency > >> > clocks, specially if they're also used for satellite, so I can't > >> > be sure by just looking at the driver's code. > >> > > >> > Also, we had already a bunch of regressions with "fixes" like this > >> > that actually broke frontend drivers. > >> > >> This patch preserves the existing behavior. The sample_freq_hz > >> variable > >> is a u32 so, in the original code, z couldn't have been more than > >> U32_MAX even though it was declared as a u64. I agree with Dan, we keep the existing behaviour. So it wont hurt to merge the code... All that said, if someone has access to the DS, I do not mind reviewing it. > >> > >> It's possible that the original code was wrong. We have seen that in > >> other places in this patchset. Adding a note about the datasheet is > >> also a good idea. > >> > >> regards, > >> dan carpenter > >>
On Mon, May 13, 2024 at 9:38 AM Ricardo Ribalda <ribalda@chromium.org> wrote: > > On Fri, 3 May 2024 at 16:08, Dragan Simic <dsimic@manjaro.org> wrote: > > > > Hello Ricardo, > > > > On 2024-05-03 13:56, Ricardo Ribalda wrote: > > > I am trying to get the DS, but > > > https://www.nxp.com/acrobat_download/literature/9397/75015931.pdf is a > > > dead links now. > > > > > > Anyone have access to the datasheet? > > > > It's kind of available on the link below, but for some strange reason > > the download fails after downloading the first 128 KB or so. > > > > https://web.archive.org/web/20080907185532/https://www.nxp.com/acrobat_download/literature/9397/75015931.pdf\ > > Mike, by any chance do you have a copy of the DS? > > > > > > > > > On Fri, 3 May 2024 at 13:55, Dan Carpenter <dan.carpenter@linaro.org> > > > wrote: > > >> > > >> On Fri, May 03, 2024 at 11:27:58AM +0100, Mauro Carvalho Chehab wrote: > > >> > Em Mon, 29 Apr 2024 15:05:05 +0000 > > >> > Ricardo Ribalda <ribalda@chromium.org> escreveu: > > >> > > > >> > > We do not expect the sample_freq to be over 613MHz. > > >> > > > > >> > > Found by cocci: > > >> > > drivers/media/dvb-frontends/tda10048.c:345:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. > > >> > > > > >> > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > > >> > > --- > > >> > > drivers/media/dvb-frontends/tda10048.c | 4 +++- > > >> > > 1 file changed, 3 insertions(+), 1 deletion(-) > > >> > > > > >> > > diff --git a/drivers/media/dvb-frontends/tda10048.c b/drivers/media/dvb-frontends/tda10048.c > > >> > > index 3e725cdcc66b..1886f733dbbf 100644 > > >> > > --- a/drivers/media/dvb-frontends/tda10048.c > > >> > > +++ b/drivers/media/dvb-frontends/tda10048.c > > >> > > @@ -328,7 +328,8 @@ static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz, > > >> > > u32 bw) > > >> > > { > > >> > > struct tda10048_state *state = fe->demodulator_priv; > > >> > > - u64 t, z; > > >> > > + u32 z; > > >> > > + u64 t; > > >> > > > > >> > > dprintk(1, "%s()\n", __func__); > > >> > > > > >> > > @@ -341,6 +342,7 @@ static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz, > > >> > > /* t *= 2147483648 on 32bit platforms */ > > >> > > t *= (2048 * 1024); > > >> > > t *= 1024; > > >> > > + /* Sample frequency is under 613MHz */ > > >> > > > >> > Are you sure about that? Some DVB devices have very high frequency > > >> > clocks, specially if they're also used for satellite, so I can't > > >> > be sure by just looking at the driver's code. > > >> > > > >> > Also, we had already a bunch of regressions with "fixes" like this > > >> > that actually broke frontend drivers. > > >> > > >> This patch preserves the existing behavior. The sample_freq_hz > > >> variable > > >> is a u32 so, in the original code, z couldn't have been more than > > >> U32_MAX even though it was declared as a u64. > > > I agree with Dan, we keep the existing behaviour. So it wont hurt to > merge the code... > > All that said, if someone has access to the DS, I do not mind reviewing it. > > > > >> > > >> It's possible that the original code was wrong. We have seen that in > > >> other places in this patchset. Adding a note about the datasheet is > > >> also a good idea. > > >> > > >> regards, > > >> dan carpenter > > >> > > > > -- > Ricardo Ribalda > Nice to hear from you! :-) I believe that I may have a copy of it on an old "spinny" hard drive somewhere in one of the ancient desktop computers I have lining my basement walls, lol. It will take me some time to locate it. I hope this isn't urgent o:-) ...It so happens that the dev box I used when I worked on that driver is up right now, but the datasheet isn't in my home directory. There are two other drives in the chassis but not connected / powered - I'll give these a look and let you know if I find anything. Best, Michael Krufky
Hi It does not seem that we will find the datasheet. Any objection to land the patch as it? It is as incorrect as the original code ;) Regards! On Mon, 13 May 2024 at 16:26, Michael Ira Krufky <mkrufky@linuxtv.org> wrote: > > On Mon, May 13, 2024 at 9:38 AM Ricardo Ribalda <ribalda@chromium.org> wrote: > > > > On Fri, 3 May 2024 at 16:08, Dragan Simic <dsimic@manjaro.org> wrote: > > > > > > Hello Ricardo, > > > > > > On 2024-05-03 13:56, Ricardo Ribalda wrote: > > > > I am trying to get the DS, but > > > > https://www.nxp.com/acrobat_download/literature/9397/75015931.pdf is a > > > > dead links now. > > > > > > > > Anyone have access to the datasheet? > > > > > > It's kind of available on the link below, but for some strange reason > > > the download fails after downloading the first 128 KB or so. > > > > > > https://web.archive.org/web/20080907185532/https://www.nxp.com/acrobat_download/literature/9397/75015931.pdf\ > > > > Mike, by any chance do you have a copy of the DS? > > > > > > > > > > > > > > On Fri, 3 May 2024 at 13:55, Dan Carpenter <dan.carpenter@linaro.org> > > > > wrote: > > > >> > > > >> On Fri, May 03, 2024 at 11:27:58AM +0100, Mauro Carvalho Chehab wrote: > > > >> > Em Mon, 29 Apr 2024 15:05:05 +0000 > > > >> > Ricardo Ribalda <ribalda@chromium.org> escreveu: > > > >> > > > > >> > > We do not expect the sample_freq to be over 613MHz. > > > >> > > > > > >> > > Found by cocci: > > > >> > > drivers/media/dvb-frontends/tda10048.c:345:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. > > > >> > > > > > >> > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > > > >> > > --- > > > >> > > drivers/media/dvb-frontends/tda10048.c | 4 +++- > > > >> > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > >> > > > > > >> > > diff --git a/drivers/media/dvb-frontends/tda10048.c b/drivers/media/dvb-frontends/tda10048.c > > > >> > > index 3e725cdcc66b..1886f733dbbf 100644 > > > >> > > --- a/drivers/media/dvb-frontends/tda10048.c > > > >> > > +++ b/drivers/media/dvb-frontends/tda10048.c > > > >> > > @@ -328,7 +328,8 @@ static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz, > > > >> > > u32 bw) > > > >> > > { > > > >> > > struct tda10048_state *state = fe->demodulator_priv; > > > >> > > - u64 t, z; > > > >> > > + u32 z; > > > >> > > + u64 t; > > > >> > > > > > >> > > dprintk(1, "%s()\n", __func__); > > > >> > > > > > >> > > @@ -341,6 +342,7 @@ static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz, > > > >> > > /* t *= 2147483648 on 32bit platforms */ > > > >> > > t *= (2048 * 1024); > > > >> > > t *= 1024; > > > >> > > + /* Sample frequency is under 613MHz */ > > > >> > > > > >> > Are you sure about that? Some DVB devices have very high frequency > > > >> > clocks, specially if they're also used for satellite, so I can't > > > >> > be sure by just looking at the driver's code. > > > >> > > > > >> > Also, we had already a bunch of regressions with "fixes" like this > > > >> > that actually broke frontend drivers. > > > >> > > > >> This patch preserves the existing behavior. The sample_freq_hz > > > >> variable > > > >> is a u32 so, in the original code, z couldn't have been more than > > > >> U32_MAX even though it was declared as a u64. > > > > > > I agree with Dan, we keep the existing behaviour. So it wont hurt to > > merge the code... > > > > All that said, if someone has access to the DS, I do not mind reviewing it. > > > > > > > >> > > > >> It's possible that the original code was wrong. We have seen that in > > > >> other places in this patchset. Adding a note about the datasheet is > > > >> also a good idea. > > > >> > > > >> regards, > > > >> dan carpenter > > > >> > > > > > > > > -- > > Ricardo Ribalda > > > > Nice to hear from you! :-) > > I believe that I may have a copy of it on an old "spinny" hard drive > somewhere in one of the ancient desktop computers I have lining my > basement walls, lol. It will take me some time to locate it. I hope > this isn't urgent o:-) > > ...It so happens that the dev box I used when I worked on that driver > is up right now, but the datasheet isn't in my home directory. There > are two other drives in the chassis but not connected / powered - I'll > give these a look and let you know if I find anything. > > Best, > Michael Krufky
diff --git a/drivers/media/dvb-frontends/tda10048.c b/drivers/media/dvb-frontends/tda10048.c index 3e725cdcc66b..1886f733dbbf 100644 --- a/drivers/media/dvb-frontends/tda10048.c +++ b/drivers/media/dvb-frontends/tda10048.c @@ -328,7 +328,8 @@ static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz, u32 bw) { struct tda10048_state *state = fe->demodulator_priv; - u64 t, z; + u32 z; + u64 t; dprintk(1, "%s()\n", __func__); @@ -341,6 +342,7 @@ static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz, /* t *= 2147483648 on 32bit platforms */ t *= (2048 * 1024); t *= 1024; + /* Sample frequency is under 613MHz */ z = 7 * sample_freq_hz; do_div(t, z); t += 5;
We do not expect the sample_freq to be over 613MHz. Found by cocci: drivers/media/dvb-frontends/tda10048.c:345:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> --- drivers/media/dvb-frontends/tda10048.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)