From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3DA1D442118; Tue, 21 Jul 2026 22:25:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784672744; cv=none; b=lrxOwVPhuy12X1snzZbwQC41b9I+xagt8N3m0YV2UlxrzOSCsy2MrHd/aCxxzSxIYJavphfasti7LyI6cCXBQZWuA8y1SpX3rLQmc5DnXsuFMvhueuFlR4A7a0M5mSnq/LKEjaggL5XUieLRIVO3jlRLxwR+jt0Js+Qzo2B8K5w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784672744; c=relaxed/simple; bh=awItKM6ZpQIwPJSmM6nvoHnB0r4Bz3Gp+CllEPA9lQ0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u0CjqNTtN4TY+EapZHoRHkdbzysq2MovHMB+GE6y8iIwVJff5TfgTqiuDOxyc+1St+JJGXO8pH+/0qAQlbXuXlTldSejQI1jiWg80Kz8J+SXfzmxnP54uF/AnHLK3COybOtaW0toN+Z9goKICzWkWQ8tIcLBbsHLnmp584CEppo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Z3dBsLNQ; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Z3dBsLNQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94ECF1F000E9; Tue, 21 Jul 2026 22:25:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784672743; bh=4VjYzxl+rYv4jz1/4w8Y0xrt13jPd7uuIsWeV055O9Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Z3dBsLNQ+2T3n3FXAQsYVAc8/zp/97F5aqI7/qaYxcWohDsN1p0u/m3VrbUAISVNF gjHKpG8n4PYHoCOzQlVdlq/5KaSkxwgERIPw/sl+K6PtZYps4Xk4MBSDmVdXaK97rA fgyRpQQSPHiVj8rqtEfHgfx6loE81j9Wu2Uxe/4g= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jean-Baptiste Maneyrol , Jonathan Cameron , Sasha Levin Subject: [PATCH 5.15 741/843] iio: imu: inv_icm42600: fix timestamping by limiting FIFO reading Date: Tue, 21 Jul 2026 17:26:16 +0200 Message-ID: <20260721152422.717096195@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152405.946368001@linuxfoundation.org> References: <20260721152405.946368001@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jean-Baptiste Maneyrol [ Upstream commit affe3f077d7a4eeb25937f5323ff059a54b4712c ] Timestamps are made by measuring the chip clock using the watermark interrupts. If we read more than watermark samples as done today, we are reducing the period between interrupts and distort the time measurement. Fix that by reading only watermark samples in the interrupt case. Fixes: 7f85e42a6c54 ("iio: imu: inv_icm42600: add buffer support in iio devices") Cc: stable@vger.kernel.org Signed-off-by: Jean-Baptiste Maneyrol Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c | 9 +++++---- drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.h | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) --- a/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c +++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c @@ -257,6 +257,7 @@ int inv_icm42600_buffer_update_watermark /* compute watermark value in bytes */ wm_size = watermark * packet_size; + st->fifo.watermark.value = watermark; /* changing FIFO watermark requires to turn off watermark interrupt */ ret = regmap_update_bits_check(st->map, INV_ICM42600_REG_INT_SOURCE0, @@ -476,11 +477,10 @@ int inv_icm42600_buffer_fifo_read(struct st->fifo.nb.accel = 0; st->fifo.nb.total = 0; - /* compute maximum FIFO read size */ + /* compute maximum FIFO read size (watermark for max = 0 interrupt case) */ if (max == 0) - max_count = sizeof(st->fifo.data); - else - max_count = max * inv_icm42600_get_packet_size(st->fifo.en); + max = st->fifo.watermark.value; + max_count = max * inv_icm42600_get_packet_size(st->fifo.en); /* read FIFO count value */ raw_fifo_count = (__be16 *)st->buffer; @@ -592,6 +592,7 @@ int inv_icm42600_buffer_init(struct inv_ st->fifo.watermark.eff_gyro = 1; st->fifo.watermark.eff_accel = 1; + st->fifo.watermark.value = 1; /* * Default FIFO configuration (bits 7 to 5) --- a/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.h +++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.h @@ -34,6 +34,7 @@ struct inv_icm42600_fifo { unsigned int accel; unsigned int eff_gyro; unsigned int eff_accel; + unsigned int value; } watermark; size_t count; struct {