* [PATCH v3 0/2] iio: imu: inv_icm42600: add hwfifo watermark attributes
@ 2026-06-24 16:21 Jean-Baptiste Maneyrol via B4 Relay
2026-06-24 16:21 ` [PATCH v3 1/2] iio: imu: inv_icm42600: reorder includes for buffer module Jean-Baptiste Maneyrol via B4 Relay
2026-06-24 16:21 ` [PATCH v3 2/2] iio: imu: inv_icm42600: add buffer hwfifo watermark attributes Jean-Baptiste Maneyrol via B4 Relay
0 siblings, 2 replies; 8+ messages in thread
From: Jean-Baptiste Maneyrol via B4 Relay @ 2026-06-24 16:21 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko
Cc: linux-iio, linux-kernel, Jean-Baptiste Maneyrol
Add hwfifo_watermark_* buffer attributes.
There is a preliminary patch for reordering includes first.
Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
---
Changes in v3:
- Add a preparatory patch for reordering includes.
- Use IIO_DEVICE_ATTR_RO.
- Link to v2: https://patch.msgid.link/20260624-inv-icm42600-add-buffer-hwfifo_attributes-v2-1-12675259e688@tdk.com
Changes in v2:
- Delete trailing comma after NULL terminator
- Link to v1: https://patch.msgid.link/20260623-inv-icm42600-add-buffer-hwfifo_attributes-v1-1-d190800e60de@tdk.com
To: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
To: Jonathan Cameron <jic23@kernel.org>
To: David Lechner <dlechner@baylibre.com>
To: Nuno Sá <nuno.sa@analog.com>
To: Andy Shevchenko <andy@kernel.org>
Cc: linux-iio@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
Jean-Baptiste Maneyrol (2):
iio: imu: inv_icm42600: reorder includes for buffer module
iio: imu: inv_icm42600: add buffer hwfifo watermark attributes
drivers/iio/imu/inv_icm42600/inv_icm42600.h | 2 ++
drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c | 5 +--
drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c | 42 ++++++++++++++++++++--
drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.h | 1 +
drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c | 5 +--
5 files changed, 48 insertions(+), 7 deletions(-)
---
base-commit: cc746297b23e89bd5df9f91f3a0ca209e8991763
change-id: 20260622-inv-icm42600-add-buffer-hwfifo_attributes-aced0415e341
Best regards,
--
Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH v3 1/2] iio: imu: inv_icm42600: reorder includes for buffer module 2026-06-24 16:21 [PATCH v3 0/2] iio: imu: inv_icm42600: add hwfifo watermark attributes Jean-Baptiste Maneyrol via B4 Relay @ 2026-06-24 16:21 ` Jean-Baptiste Maneyrol via B4 Relay 2026-06-25 6:49 ` Andy Shevchenko 2026-06-24 16:21 ` [PATCH v3 2/2] iio: imu: inv_icm42600: add buffer hwfifo watermark attributes Jean-Baptiste Maneyrol via B4 Relay 1 sibling, 1 reply; 8+ messages in thread From: Jean-Baptiste Maneyrol via B4 Relay @ 2026-06-24 16:21 UTC (permalink / raw) To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko Cc: linux-iio, linux-kernel, Jean-Baptiste Maneyrol From: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com> Reorder includes following rules and delete unneeded kernel.h. Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com> --- drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c index 68a395758031..8ad6374409a9 100644 --- a/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c +++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c @@ -3,18 +3,18 @@ * Copyright (C) 2020 Invensense, Inc. */ -#include <linux/kernel.h> +#include <linux/delay.h> #include <linux/device.h> #include <linux/minmax.h> #include <linux/mutex.h> #include <linux/pm_runtime.h> #include <linux/regmap.h> -#include <linux/delay.h> #include <linux/iio/buffer.h> -#include <linux/iio/common/inv_sensors_timestamp.h> #include <linux/iio/iio.h> +#include <linux/iio/common/inv_sensors_timestamp.h> + #include "inv_icm42600.h" #include "inv_icm42600_buffer.h" -- 2.54.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v3 1/2] iio: imu: inv_icm42600: reorder includes for buffer module 2026-06-24 16:21 ` [PATCH v3 1/2] iio: imu: inv_icm42600: reorder includes for buffer module Jean-Baptiste Maneyrol via B4 Relay @ 2026-06-25 6:49 ` Andy Shevchenko 2026-06-25 6:55 ` Andy Shevchenko 0 siblings, 1 reply; 8+ messages in thread From: Andy Shevchenko @ 2026-06-25 6:49 UTC (permalink / raw) To: jean-baptiste.maneyrol Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, linux-iio, linux-kernel On Wed, Jun 24, 2026 at 06:21:18PM +0200, Jean-Baptiste Maneyrol via B4 Relay wrote: > Reorder includes following rules and delete unneeded kernel.h. Actually it's needed as 'proxy' header. If you want to get rid of it, it should be another patch to replace that with the used headers following IWYU principle. Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com> -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 1/2] iio: imu: inv_icm42600: reorder includes for buffer module 2026-06-25 6:49 ` Andy Shevchenko @ 2026-06-25 6:55 ` Andy Shevchenko 2026-06-25 6:57 ` Andy Shevchenko 0 siblings, 1 reply; 8+ messages in thread From: Andy Shevchenko @ 2026-06-25 6:55 UTC (permalink / raw) To: jean-baptiste.maneyrol Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, linux-iio, linux-kernel On Thu, Jun 25, 2026 at 09:49:47AM +0300, Andy Shevchenko wrote: > On Wed, Jun 24, 2026 at 06:21:18PM +0200, Jean-Baptiste Maneyrol via B4 Relay wrote: > > > Reorder includes following rules and delete unneeded kernel.h. > > Actually it's needed as 'proxy' header. If you want to get rid of it, it should > be another patch to replace that with the used headers following IWYU > principle. > > Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com> Also for the consistency's sake this should be done in all files in that folder. I see the same issue(s) in the _gyro and _accel and I assume the rest *.c and *.h also might be updated. -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 1/2] iio: imu: inv_icm42600: reorder includes for buffer module 2026-06-25 6:55 ` Andy Shevchenko @ 2026-06-25 6:57 ` Andy Shevchenko 2026-06-25 9:03 ` Jean-Baptiste Maneyrol 0 siblings, 1 reply; 8+ messages in thread From: Andy Shevchenko @ 2026-06-25 6:57 UTC (permalink / raw) To: jean-baptiste.maneyrol Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, linux-iio, linux-kernel On Thu, Jun 25, 2026 at 09:56:01AM +0300, Andy Shevchenko wrote: > On Thu, Jun 25, 2026 at 09:49:47AM +0300, Andy Shevchenko wrote: > > On Wed, Jun 24, 2026 at 06:21:18PM +0200, Jean-Baptiste Maneyrol via B4 Relay wrote: > > > > > Reorder includes following rules and delete unneeded kernel.h. > > > > Actually it's needed as 'proxy' header. If you want to get rid of it, it should > > be another patch to replace that with the used headers following IWYU > > principle. > > > > Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com> > > Also for the consistency's sake this should be done in all files in that > folder. I see the same issue(s) in the _gyro and _accel and I assume the rest > *.c and *.h also might be updated. For the simplicity, just sort the each group of headers in all files. The IWYU can be applied later on as it's not in the scope of your series. -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 1/2] iio: imu: inv_icm42600: reorder includes for buffer module 2026-06-25 6:57 ` Andy Shevchenko @ 2026-06-25 9:03 ` Jean-Baptiste Maneyrol 0 siblings, 0 replies; 8+ messages in thread From: Jean-Baptiste Maneyrol @ 2026-06-25 9:03 UTC (permalink / raw) To: Andy Shevchenko Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org >From: Andy Shevchenko <andriy.shevchenko@intel.com> >Sent: Thursday, June 25, 2026 08:57 >To: Jean-Baptiste Maneyrol >Cc: Jonathan Cameron; David Lechner; Nuno Sá; Andy Shevchenko; linux-iio@vger.kernel.org; linux-kernel@vger.kernel.org >Subject: Re: [PATCH v3 1/2] iio: imu: inv_icm42600: reorder includes for buffer module > >On Thu, Jun 25, 2026 at 09: 56: 01AM +0300, Andy Shevchenko wrote: > On Thu, Jun 25, 2026 at 09: 49: 47AM +0300, Andy Shevchenko wrote: > > On Wed, Jun 24, 2026 at 06: 21: 18PM +0200, Jean-Baptiste Maneyrol via B4 Relay wrote: > > > >ZjQcmQRYFpfptBannerStart >This Message Is From an External Sender >This message came from outside your organization. > >ZjQcmQRYFpfptBannerEnd > >On Thu, Jun 25, 2026 at 09:56:01AM +0300, Andy Shevchenko wrote: >> On Thu, Jun 25, 2026 at 09:49:47AM +0300, Andy Shevchenko wrote: >> > On Wed, Jun 24, 2026 at 06:21:18PM +0200, Jean-Baptiste Maneyrol via B4 Relay wrote: >> > >> > > Reorder includes following rules and delete unneeded kernel.h. >> > >> > Actually it's needed as 'proxy' header. If you want to get rid of it, it should >> > be another patch to replace that with the used headers following IWYU >> > principle. >> > >> > Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com> >> >> Also for the consistency's sake this should be done in all files in that >> folder. I see the same issue(s) in the _gyro and _accel and I assume the rest >> *.c and *.h also might be updated. > >For the simplicity, just sort the each group of headers in all files. The IWYU >can be applied later on as it's not in the scope of your series. > >-- >With Best Regards, >Andy Shevchenko > Hello Andy, no problem, I will do that in the next version. Thanks, JB ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v3 2/2] iio: imu: inv_icm42600: add buffer hwfifo watermark attributes 2026-06-24 16:21 [PATCH v3 0/2] iio: imu: inv_icm42600: add hwfifo watermark attributes Jean-Baptiste Maneyrol via B4 Relay 2026-06-24 16:21 ` [PATCH v3 1/2] iio: imu: inv_icm42600: reorder includes for buffer module Jean-Baptiste Maneyrol via B4 Relay @ 2026-06-24 16:21 ` Jean-Baptiste Maneyrol via B4 Relay 2026-06-25 6:54 ` Andy Shevchenko 1 sibling, 1 reply; 8+ messages in thread From: Jean-Baptiste Maneyrol via B4 Relay @ 2026-06-24 16:21 UTC (permalink / raw) To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko Cc: linux-iio, linux-kernel, Jean-Baptiste Maneyrol From: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com> Add hwfifo_watermark/min/max/enabled buffer attributes. Hardware FIFO is always enabled and used. Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com> --- drivers/iio/imu/inv_icm42600/inv_icm42600.h | 2 ++ drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c | 5 +-- drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c | 36 ++++++++++++++++++++++ drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.h | 1 + drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c | 5 +-- 5 files changed, 45 insertions(+), 4 deletions(-) diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600.h b/drivers/iio/imu/inv_icm42600/inv_icm42600.h index c8b48a5c5ed0..7c9b63584a05 100644 --- a/drivers/iio/imu/inv_icm42600/inv_icm42600.h +++ b/drivers/iio/imu/inv_icm42600/inv_icm42600.h @@ -354,6 +354,8 @@ struct inv_icm42600_sensor_state { cpu_to_le16((_wm) & GENMASK(11, 0)) /* FIFO is 2048 bytes, let 12 samples for reading latency */ #define INV_ICM42600_FIFO_WATERMARK_MAX (2048 - 12 * 16) +/* INV_ICM42600_FIFO_WATERMARK_MAX / 8 = 232 */ +#define INV_ICM42600_FIFO_WATERMARK_MAX_SAMPLES 232 #define INV_ICM42600_REG_INT_CONFIG1 0x0064 #define INV_ICM42600_INT_CONFIG1_TPULSE_DURATION BIT(6) diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c index 532d5fdffaf8..1ab73953bef6 100644 --- a/drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c +++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c @@ -1186,8 +1186,9 @@ struct iio_dev *inv_icm42600_accel_init(struct inv_icm42600_state *st) indio_dev->num_channels = ARRAY_SIZE(inv_icm42600_accel_channels); indio_dev->available_scan_masks = inv_icm42600_accel_scan_masks; - ret = devm_iio_kfifo_buffer_setup(dev, indio_dev, - &inv_icm42600_buffer_ops); + ret = devm_iio_kfifo_buffer_setup_ext(dev, indio_dev, + &inv_icm42600_buffer_ops, + inv_icm42600_buffer_attrs); if (ret) return ERR_PTR(ret); diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c index 8ad6374409a9..faa9b460bfdf 100644 --- a/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c +++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c @@ -9,9 +9,11 @@ #include <linux/mutex.h> #include <linux/pm_runtime.h> #include <linux/regmap.h> +#include <linux/stringify.h> #include <linux/iio/buffer.h> #include <linux/iio/iio.h> +#include <linux/iio/sysfs.h> #include <linux/iio/common/inv_sensors_timestamp.h> @@ -437,6 +439,40 @@ const struct iio_buffer_setup_ops inv_icm42600_buffer_ops = { .postdisable = inv_icm42600_buffer_postdisable, }; +static ssize_t hwfifo_watermark_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct inv_icm42600_state *st = iio_device_get_drvdata(indio_dev); + unsigned int wm; + + guard(mutex)(&st->lock); + + if (indio_dev == st->indio_accel) + wm = st->fifo.watermark.eff_accel; + else if (indio_dev == st->indio_gyro) + wm = st->fifo.watermark.eff_gyro; + else + return -EINVAL; + + return sysfs_emit(buf, "%u\n", wm); +} + +IIO_STATIC_CONST_DEVICE_ATTR(hwfifo_watermark_min, "1"); +IIO_STATIC_CONST_DEVICE_ATTR(hwfifo_watermark_max, + __stringify(INV_ICM42600_FIFO_WATERMARK_MAX_SAMPLES)); +static IIO_DEVICE_ATTR_RO(hwfifo_watermark, 0); +IIO_STATIC_CONST_DEVICE_ATTR(hwfifo_enabled, "1"); + +const struct iio_dev_attr *inv_icm42600_buffer_attrs[] = { + &iio_dev_attr_hwfifo_watermark_min, + &iio_dev_attr_hwfifo_watermark_max, + &iio_dev_attr_hwfifo_watermark, + &iio_dev_attr_hwfifo_enabled, + NULL +}; + int inv_icm42600_buffer_fifo_read(struct inv_icm42600_state *st, unsigned int max) { diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.h b/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.h index ffca4da1e249..522e158accc9 100644 --- a/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.h +++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.h @@ -79,6 +79,7 @@ ssize_t inv_icm42600_fifo_decode_packet(const void *packet, const void **accel, const void **timestamp, unsigned int *odr); extern const struct iio_buffer_setup_ops inv_icm42600_buffer_ops; +extern const struct iio_dev_attr *inv_icm42600_buffer_attrs[]; int inv_icm42600_buffer_init(struct inv_icm42600_state *st); diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c index 11339ddf1da3..7d4f6701f124 100644 --- a/drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c +++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c @@ -772,8 +772,9 @@ struct iio_dev *inv_icm42600_gyro_init(struct inv_icm42600_state *st) indio_dev->available_scan_masks = inv_icm42600_gyro_scan_masks; indio_dev->setup_ops = &inv_icm42600_buffer_ops; - ret = devm_iio_kfifo_buffer_setup(dev, indio_dev, - &inv_icm42600_buffer_ops); + ret = devm_iio_kfifo_buffer_setup_ext(dev, indio_dev, + &inv_icm42600_buffer_ops, + inv_icm42600_buffer_attrs); if (ret) return ERR_PTR(ret); -- 2.54.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v3 2/2] iio: imu: inv_icm42600: add buffer hwfifo watermark attributes 2026-06-24 16:21 ` [PATCH v3 2/2] iio: imu: inv_icm42600: add buffer hwfifo watermark attributes Jean-Baptiste Maneyrol via B4 Relay @ 2026-06-25 6:54 ` Andy Shevchenko 0 siblings, 0 replies; 8+ messages in thread From: Andy Shevchenko @ 2026-06-25 6:54 UTC (permalink / raw) To: jean-baptiste.maneyrol Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, linux-iio, linux-kernel On Wed, Jun 24, 2026 at 06:21:19PM +0200, Jean-Baptiste Maneyrol via B4 Relay wrote: > Add hwfifo_watermark/min/max/enabled buffer attributes. > Hardware FIFO is always enabled and used. These attributes are already documented and being used by a few drivers. Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-06-25 9:03 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-06-24 16:21 [PATCH v3 0/2] iio: imu: inv_icm42600: add hwfifo watermark attributes Jean-Baptiste Maneyrol via B4 Relay 2026-06-24 16:21 ` [PATCH v3 1/2] iio: imu: inv_icm42600: reorder includes for buffer module Jean-Baptiste Maneyrol via B4 Relay 2026-06-25 6:49 ` Andy Shevchenko 2026-06-25 6:55 ` Andy Shevchenko 2026-06-25 6:57 ` Andy Shevchenko 2026-06-25 9:03 ` Jean-Baptiste Maneyrol 2026-06-24 16:21 ` [PATCH v3 2/2] iio: imu: inv_icm42600: add buffer hwfifo watermark attributes Jean-Baptiste Maneyrol via B4 Relay 2026-06-25 6:54 ` Andy Shevchenko
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox