Messages in this thread |  | | From | David Lechner <> | | Subject | [PATCH v2 0/5] iio: buffer: fix timestamp alignment (in rare case) | | Date | Sat, 07 Mar 2026 19:44:08 -0600 |
| |
In [1], it was pointed out that the iio_push_to_buffers_with_timestamp() function is not putting the timestamp at the correct offset in the scan buffer in rare cases where the largest scan element size is larger than sizeof(int64_t).
[1]: https://lore.kernel.org/linux-iio/20260215162351.79f40b32@jic23-huawei/
This only affected one driver, namely hid-sensor-rotation since it is the only driver that meets the condition. To fix things up, first we fix the hid-sensor-rotation driver in a way that preserves compatibility with the broken timestamp alignment. Then we are free to fix the core IIO code without affecting any users.
The first patch depends on [2] which is now in iio/fixes-togreg. It should be OK to apply the first patch there and let the rest of the patches go through iio/togreg (the later patches are just preventing future bugs).
[2]: https://lore.kernel.org/linux-iio/20260228-iio-fix-repeat-alignment-v2-0-d58bfaa2920d@baylibre.com/
Signed-off-by: David Lechner <dlechner@baylibre.com> --- Changes in v2: - Don't say "HACK" in comments. - Cache timestamp offset instead of largest scan element size. - New patch to ensure size/alignment is always power of 2 bytes. - Link to v1: https://lore.kernel.org/r/20260301-iio-fix-timestamp-alignment-v1-0-1a54980bfb90@baylibre.com
--- David Lechner (5): iio: orientation: hid-sensor-rotation: add timestamp hack to not break userspace iio: buffer: check return value of iio_compute_scan_bytes() iio: buffer: cache timestamp offset in scan buffer iio: buffer: ensure repeat alignment is a power of two iio: buffer: fix timestamp alignment when quaternion in scan
drivers/iio/industrialio-buffer.c | 46 ++++++++++++++++++++------- drivers/iio/orientation/hid-sensor-rotation.c | 22 +++++++++++-- include/linux/iio/buffer.h | 12 +++++-- include/linux/iio/iio.h | 3 ++ 4 files changed, 66 insertions(+), 17 deletions(-) --- base-commit: 6f25a6105c41a7d6b12986dbe80ded396a5667f8 change-id: 20260228-iio-fix-timestamp-alignment-89ade1af458b prerequisite-message-id: <20260228-iio-fix-repeat-alignment-v2-0-d58bfaa2920d@baylibre.com> prerequisite-patch-id: e155a526d57c5759a2fcfbfca7f544cb419addfd prerequisite-patch-id: 6c69eaad0dd2ae69bd2745e7d387f739fc1a9ba0
Best regards, -- David Lechner <dlechner@baylibre.com>
|  |