diff mbox series

[06/11] iio: cros_ec_sensors: Fix alignment of buffer in iio_push_to_buffers_with_timestamp()

Message ID 20210501171352.512953-7-jic23@kernel.org (mailing list archive)
State New, archived
Headers show
Series IIO: Alignment fixes part 3 - __aligned(8) used to ensure alignment | expand

Commit Message

Jonathan Cameron May 1, 2021, 5:13 p.m. UTC
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

The samples buffer is passed to iio_push_to_buffers_with_timestamp()
which requires a buffer aligned to 8 bytes as it is assumed that
the timestamp will be naturally aligned if present.

Fixes tag is inaccurate but prior to that likely manual backporting needed.

Fixes: 5a0b8cb46624c ("iio: cros_ec: Move cros_ec_sensors_core.h in /include")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Gwendal Grignou <gwendal@chromium.org>
---
 include/linux/iio/common/cros_ec_sensors_core.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Gwendal Grignou May 1, 2021, 11:58 p.m. UTC | #1
Fixes tag is correct up to kernel stable 4.18.
Before, the include file to fix is
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.h:
commit 974e6f02e27 ("iio: cros_ec_sensors_core: Add common functions
for the ChromeOS EC Sensor Hub.") present since kernel stable 4.10.

Reviewed-by: Gwendal Grignou <gwendal@chromium.org

On Sat, May 1, 2021 at 10:15 AM Jonathan Cameron <jic23@kernel.org> wrote:
>
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> The samples buffer is passed to iio_push_to_buffers_with_timestamp()
> which requires a buffer aligned to 8 bytes as it is assumed that
> the timestamp will be naturally aligned if present.
>
> Fixes tag is inaccurate but prior to that likely manual backporting needed.
>
> Fixes: 5a0b8cb46624c ("iio: cros_ec: Move cros_ec_sensors_core.h in /include")
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Gwendal Grignou <gwendal@chromium.org>
> ---
>  include/linux/iio/common/cros_ec_sensors_core.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/iio/common/cros_ec_sensors_core.h b/include/linux/iio/common/cros_ec_sensors_core.h
> index 7ce8a8adad58..c582e1a14232 100644
> --- a/include/linux/iio/common/cros_ec_sensors_core.h
> +++ b/include/linux/iio/common/cros_ec_sensors_core.h
> @@ -77,7 +77,7 @@ struct cros_ec_sensors_core_state {
>                 u16 scale;
>         } calib[CROS_EC_SENSOR_MAX_AXIS];
>         s8 sign[CROS_EC_SENSOR_MAX_AXIS];
> -       u8 samples[CROS_EC_SAMPLE_SIZE];
> +       u8 samples[CROS_EC_SAMPLE_SIZE] __aligned(8);
>
>         int (*read_ec_sensors_data)(struct iio_dev *indio_dev,
>                                     unsigned long scan_mask, s16 *data);
> --
> 2.31.1
>
Jonathan Cameron May 13, 2021, 6:03 p.m. UTC | #2
On Sat, 1 May 2021 16:58:21 -0700
Gwendal Grignou <gwendal@chromium.org> wrote:

> Fixes tag is correct up to kernel stable 4.18.
> Before, the include file to fix is
> drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.h:
> commit 974e6f02e27 ("iio: cros_ec_sensors_core: Add common functions
> for the ChromeOS EC Sensor Hub.") present since kernel stable 4.10.
> 
Applied with this extra info to the togreg branch of iio.git and pushed
out as testing for the autobuilders to poke at it.

This series (in it's complete form) is large enough that I'm not comfortable
rushing it in.  The bug is also rarely seen in practice so this can wait
for the next merge window.

Thanks,

Jonathan

> Reviewed-by: Gwendal Grignou <gwendal@chromium.org
> 
> On Sat, May 1, 2021 at 10:15 AM Jonathan Cameron <jic23@kernel.org> wrote:
> >
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> >
> > The samples buffer is passed to iio_push_to_buffers_with_timestamp()
> > which requires a buffer aligned to 8 bytes as it is assumed that
> > the timestamp will be naturally aligned if present.
> >
> > Fixes tag is inaccurate but prior to that likely manual backporting needed.
> >
> > Fixes: 5a0b8cb46624c ("iio: cros_ec: Move cros_ec_sensors_core.h in /include")
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > Cc: Gwendal Grignou <gwendal@chromium.org>
> > ---
> >  include/linux/iio/common/cros_ec_sensors_core.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/include/linux/iio/common/cros_ec_sensors_core.h b/include/linux/iio/common/cros_ec_sensors_core.h
> > index 7ce8a8adad58..c582e1a14232 100644
> > --- a/include/linux/iio/common/cros_ec_sensors_core.h
> > +++ b/include/linux/iio/common/cros_ec_sensors_core.h
> > @@ -77,7 +77,7 @@ struct cros_ec_sensors_core_state {
> >                 u16 scale;
> >         } calib[CROS_EC_SENSOR_MAX_AXIS];
> >         s8 sign[CROS_EC_SENSOR_MAX_AXIS];
> > -       u8 samples[CROS_EC_SAMPLE_SIZE];
> > +       u8 samples[CROS_EC_SAMPLE_SIZE] __aligned(8);
> >
> >         int (*read_ec_sensors_data)(struct iio_dev *indio_dev,
> >                                     unsigned long scan_mask, s16 *data);
> > --
> > 2.31.1
> >
diff mbox series

Patch

diff --git a/include/linux/iio/common/cros_ec_sensors_core.h b/include/linux/iio/common/cros_ec_sensors_core.h
index 7ce8a8adad58..c582e1a14232 100644
--- a/include/linux/iio/common/cros_ec_sensors_core.h
+++ b/include/linux/iio/common/cros_ec_sensors_core.h
@@ -77,7 +77,7 @@  struct cros_ec_sensors_core_state {
 		u16 scale;
 	} calib[CROS_EC_SENSOR_MAX_AXIS];
 	s8 sign[CROS_EC_SENSOR_MAX_AXIS];
-	u8 samples[CROS_EC_SAMPLE_SIZE];
+	u8 samples[CROS_EC_SAMPLE_SIZE] __aligned(8);
 
 	int (*read_ec_sensors_data)(struct iio_dev *indio_dev,
 				    unsigned long scan_mask, s16 *data);