From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9070C4740A for ; Mon, 9 Sep 2019 12:36:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 98C49218DE for ; Mon, 9 Sep 2019 12:36:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727793AbfIIMgO (ORCPT ); Mon, 9 Sep 2019 08:36:14 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:58997 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727428AbfIIMgN (ORCPT ); Mon, 9 Sep 2019 08:36:13 -0400 Received: from localhost ([46.78.15.232]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1M3lsh-1i71eB1YQt-000wUv; Mon, 09 Sep 2019 14:35:48 +0200 Date: Mon, 9 Sep 2019 14:35:46 +0200 From: Andreas Klinger To: Jonathan Cameron Cc: knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] iio: adc: hx711: optimize sampling of data Message-ID: <20190909123545.cecciemnmhspdsmq@arbad> References: <20190907101759.kft6xwsqc5lf4acq@arbad> <20190908144922.51ba448e@archlinux> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-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BT8+dji58fulyX3Q vc0D8chSt/gvRpUikrKSH8W+sBFqYB2GYfrzgCe8w8P+Kgj7WWAjZQfLVQYDqnl1bBOVfIQ4O eQwtNwWIYVEeFjD9EaHoLiQNWyz5+iv/7o/F7lyk1THW8lRkbA= Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Hi Jonathan, only patch 1 fixes a bug which is occurring on systems. In my test it happened every one of about 10 - 15.000 measurements. But this depends on the interrupt load of the system. With a high interrupt load there might be much more wrong measurements. Patch 2 is a performance optimization which prevents unneded reads. There is no bug which is fixed by it. I'll send out the patch set with more detailed commit messages. Thanks, Andreas Jonathan Cameron schrieb am So, 08. Sep 14:49: > On Sat, 7 Sep 2019 12:18:00 +0200 > Andreas Klinger wrote: > > > Fix bug in sampling function hx711_cycle() when interrupt occures while > > PD_SCK is high. If PD_SCK is high for at least 60 us power down mode of > > the sensor is entered which in turn leads to a wrong measurement. > > > > Move query of DOUT at the latest point of time which is at the end of > > PD_SCK low period. > > > > Signed-off-by: Andreas Klinger > > Hi Andreas, > > One thing I'm not clear on from these is how much a 'fix' they > are. That just effects whether we mark them for stable / push them > out as quickly as possible or not. So has this been seen in > normal operation? > > + please add fixes tags to the two fixes. > > For patch 3, it's in the very low importance category so it may > well get forgotten if these two go through the fixes tree > (up to you to remind me!) > > Thanks, > > Jonathan > > > --- > > drivers/iio/adc/hx711.c | 9 +++++---- > > 1 file changed, 5 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c > > index 88c7fe15003b..0678964dbd21 100644 > > --- a/drivers/iio/adc/hx711.c > > +++ b/drivers/iio/adc/hx711.c > > @@ -101,13 +101,14 @@ struct hx711_data { > > static int hx711_cycle(struct hx711_data *hx711_data) > > { > > int val; > > + unsigned long flags; > > > > /* > > * if preempted for more then 60us while PD_SCK is high: > > * hx711 is going in reset > > * ==> measuring is false > > */ > > - preempt_disable(); > > + local_irq_save(flags); > > gpiod_set_value(hx711_data->gpiod_pd_sck, 1); > > > > /* > > @@ -117,7 +118,6 @@ static int hx711_cycle(struct hx711_data *hx711_data) > > */ > > ndelay(hx711_data->data_ready_delay_ns); > > > > - val = gpiod_get_value(hx711_data->gpiod_dout); > > /* > > * here we are not waiting for 0.2 us as suggested by the datasheet, > > * because the oscilloscope showed in a test scenario > > @@ -125,7 +125,7 @@ static int hx711_cycle(struct hx711_data *hx711_data) > > * and 0.56 us for PD_SCK low on TI Sitara with 800 MHz > > */ > > gpiod_set_value(hx711_data->gpiod_pd_sck, 0); > > - preempt_enable(); > > + local_irq_restore(flags); > > > > /* > > * make it a square wave for addressing cases with capacitance on > > @@ -133,7 +133,8 @@ static int hx711_cycle(struct hx711_data *hx711_data) > > */ > > ndelay(hx711_data->data_ready_delay_ns); > > > > - return val; > > + /* sample as late as possible */ > > + return gpiod_get_value(hx711_data->gpiod_dout); > > } > > > > static int hx711_read(struct hx711_data *hx711_data) > -- Andreas Klinger Grabenreith 27 84508 Burgkirchen +49 8623 919966 ak@it-klinger.de www.it-klinger.de www.grabenreith.de