[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdUeY62SBvzgHCMxjeDO6f_c3isbw82FKJatzny=qiDULQ@mail.gmail.com>
Date: Wed, 13 Nov 2019 10:46:21 +0100
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: Jacopo Mondi <jacopo@...ndi.org>
Cc: Geert Uytterhoeven <geert+renesas@...der.be>,
Jacopo Mondi <jacopo+renesas@...ndi.org>,
Jonathan Cameron <jic23@...nel.org>,
Hartmut Knaack <knaack.h@....de>,
Lars-Peter Clausen <lars@...afoo.de>,
Peter Meerwald-Stadler <pmeerw@...erw.net>,
Wolfram Sang <wsa+renesas@...g-engineering.com>,
linux-iio@...r.kernel.org,
Linux-Renesas <linux-renesas-soc@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] iio: adc: max9611: Fix too short conversion time delay
Hi Jacopo,
On Wed, Nov 13, 2019 at 10:36 AM Jacopo Mondi <jacopo@...ndi.org> wrote:
> On Wed, Nov 13, 2019 at 10:21:33AM +0100, Geert Uytterhoeven wrote:
> > As of commit b9ddd5091160793e ("iio: adc: max9611: Fix temperature
> > reading in probe"), max9611 initialization sometimes fails on the
> > Salvator-X(S) development board with:
> >
> > max9611 4-007f: Invalid value received from ADC 0x8000: aborting
> > max9611: probe of 4-007f failed with error -5
> >
> > The max9611 driver tests communications with the chip by reading the die
> > temperature during the probe function, which returns an invalid value.
> >
> > According to the datasheet, the typical ADC conversion time is 2 ms, but
> > no minimum or maximum values are provided. However, the driver assumes
> > a 1 ms conversion time. Usually the usleep_range() call returns after
> > more than 1.8 ms, hence it succeeds. When it returns earlier, the data
> > register may be read too early, and the previous measurement value will
> > be returned. After boot, this is the temperature POR (power-on reset)
> > value, causing the failure above.
> >
> > Fix this by increasing the delay from 1000-2000 µs to 2000-2200 µs.
> >
> > Note that this issue has always been present, but it was exposed by the
> > aformentioned commit.
> >
> > Fixes: 69780a3bbc0b1e7e ("iio: adc: Add Maxim max9611 ADC driver")
> > Signed-off-by: Geert Uytterhoeven <geert+renesas@...der.be>
> > ---
> > This problem was exposed in v5.3.
> >
> > After this patch, probing of the two max9611 sensors succeeded during
> > ca. 3000 boot cycles on Salvator-X(S) boards, equipped with various
> > R-Car H3/M3-W/M3-N SoCs.
> > ---
> > drivers/iio/adc/max9611.c | 11 ++++++++---
> > 1 file changed, 8 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/iio/adc/max9611.c b/drivers/iio/adc/max9611.c
> > index da073d72f649f829..b0755f25356d700d 100644
> > --- a/drivers/iio/adc/max9611.c
> > +++ b/drivers/iio/adc/max9611.c
> > @@ -89,6 +89,11 @@
> > #define MAX9611_TEMP_SCALE_NUM 1000000
> > #define MAX9611_TEMP_SCALE_DIV 2083
> >
> > +/*
> > + * Conversion time is 2 ms (typically)
> > + */
> > +#define MAX9611_CONV_TIME_US_RANGE 2000, 2200
> > +
>
> Is a 20% sleep range enough or should it be slightly lengthen ?
10%?
This only impacts the variation, so what really happens depends on the
rate of the hrtimer (if present).
On R-Car Gen3, I think that uses the ARM Architectured Timer (cp15),
which has a period of 120 ns.
> Apart from this, thanks a lot for finding the issue root cause!
>
> Reviewed-by: Jacopo Mondi <jacopo+renesas@...ndi.org>
Thanks!
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Powered by blists - more mailing lists