Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1683351ybc; Wed, 13 Nov 2019 02:44:08 -0800 (PST) X-Google-Smtp-Source: APXvYqyGkM4/ShNnWc/FjFpLd07B7Rw+9aLTwEfIQq00gueLhM7w0M4J6VRCylbxzfVrLr5s4RAj X-Received: by 2002:aa7:c301:: with SMTP id l1mr2596824edq.209.1573641848563; Wed, 13 Nov 2019 02:44:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573641848; cv=none; d=google.com; s=arc-20160816; b=aqFIQda0QKBgSdPDCGVYN6EoczgDQoT2LJZ43R/UhVhC2Y9WygR4R4hy6EhWJRFYtJ 5lGEFXAEUOTvGU2RGKZXL5YYlRb8JI6rSRu4pbIJWA2JendqyEFZOnzqgLhNDW83u+eF u3j2OMwWh+ywI1C41+MR5lVjroRemO/EaY4lAyl4qGENpm22B8Y23B9zL+vdeCUeTIWX dqW6s8prVOzELb7bHKuNdZU1NsSoMIgJ7wFDPYc/iiu2Xw92X1xOkyZxxk5jVZvW8Bm2 k/lwoJqmk6pd8g2YVV4xfe8lRnEsz7NpugVQ+ANJhltOcc8HI1g64zasdv2Hvt5pD9F9 ulmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=rVGJCWtOTf2EJyaHcHP9hUuBP2kA2I0/xDeKCnde5S0=; b=a5KTRdI1IKZJhJ2tXM1+h/dell7swJ6GKIHpUcoO5LMy9JpSqyhlZ4J0fEDa9lD/6O yrj2IaHF36ykp0tivK5Y0tHdMYLWaWl7MBq/EONcdcLB5uKCsX7PtjSEUB2L+b02Ubuw RkSJVhBJw43b+l45J/JM7juh1KNq2oGfpnlu6ASg7q7v3+Oo22RVT9NsNsJ66QPeEe45 v8jlD0qTloDGcY3dAkPdG/1t+iZs8ppwuDYag69JCHSgSQHAUAWy279bAVzJWYPjwhuO xuqQYIZdbzXLHgNuQGNL1glwclnTw/TBRkfDWViEnc6lEw+osTvtCsHXggTeLvJhKmmT H/BA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z15si868254eju.310.2019.11.13.02.43.43; Wed, 13 Nov 2019 02:44:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727388AbfKMKma (ORCPT + 99 others); Wed, 13 Nov 2019 05:42:30 -0500 Received: from jabberwock.ucw.cz ([46.255.230.98]:50244 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727113AbfKMKma (ORCPT ); Wed, 13 Nov 2019 05:42:30 -0500 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 571C01C122E; Wed, 13 Nov 2019 11:42:28 +0100 (CET) Date: Wed, 13 Nov 2019 11:42:27 +0100 From: Pavel Machek To: pavel@denx.de Cc: linux-kernel@vger.kernel.org, Jean-Baptiste Maneyrol , Jonathan Cameron , Sasha Levin Subject: Re: [PATCH 4.19 123/125] iio: imu: inv_mpu6050: fix no data on MPU6050 Message-ID: <20191113104227.GC32553@amd> References: <20191111181438.945353076@linuxfoundation.org> <20191111181456.142299857@linuxfoundation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="c3bfwLpm8qysLVxt" Content-Disposition: inline In-Reply-To: <20191111181456.142299857@linuxfoundation.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --c3bfwLpm8qysLVxt Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon 2019-11-11 19:29:22, Greg Kroah-Hartman wrote: > From: Jean-Baptiste Maneyrol >=20 > [ Upstream commit 6e82ae6b8d11b948b74e71396efd8e074c415f44 ] >=20 > Some chips have a fifo overflow bit issue where the bit is always > set. The result is that every data is dropped. >=20 > Change fifo overflow management by checking fifo count against > a maximum value. >=20 > Add fifo size in chip hardware set of values. > @@ -216,6 +213,18 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p) > if (result) > goto end_session; > fifo_count =3D get_unaligned_be16(&data[0]); > + > + /* > + * Handle fifo overflow by resetting fifo. > + * Reset if there is only 3 data set free remaining to mitigate > + * possible delay between reading fifo count and fifo data. > + */ > + nb =3D 3 * bytes_per_datum; > + if (fifo_count >=3D st->hw->fifo_size - nb) { > + dev_warn(regmap_get_device(st->map), "fifo overflow reset\n"); > + goto flush_fifo; > + } > + > /* compute and process all complete datum */ > nb =3D fifo_count / bytes_per_datum; > inv_mpu6050_update_period(st, pf->timestamp, nb); Would this make sense to reduce code duplication? Signed-off-by: Pavel Machek Best regards, Pavel diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c b/drivers/iio/imu/i= nv_mpu6050/inv_mpu_ring.c index 548e042f7b5b..9b9d90f41610 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c @@ -232,16 +232,12 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p) timestamp =3D inv_mpu6050_get_timestamp(st); iio_push_to_buffers_with_timestamp(indio_dev, data, timestamp); } - -end_session: - mutex_unlock(&st->lock); - iio_trigger_notify_done(indio_dev->trig); - - return IRQ_HANDLED; + goto end_session; =20 flush_fifo: /* Flush HW and SW FIFOs. */ inv_reset_fifo(indio_dev); +end_session: mutex_unlock(&st->lock); iio_trigger_notify_done(indio_dev->trig); =20 --=20 DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany --c3bfwLpm8qysLVxt Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAl3L3hMACgkQMOfwapXb+vK3BQCfQf/mNq0hXcQ2MvLDrh/KCvUU OCkAnjKy1oEzOXUNQmkWf+iH6Kdji+Eo =kKFw -----END PGP SIGNATURE----- --c3bfwLpm8qysLVxt--