mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: "Geert Uytterhoeven" <geert@linux-m68k.org>,
	"Francesco Lavra" <flavra@baylibre.com>,
	"Lorenzo Bianconi" <lorenzo@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 3/7] iio: imu: st_lsm6dsx: Fix check for invalid samples from FIFO
Date: Sat, 28 Feb 2026 16:38:13 +0000	[thread overview]
Message-ID: <20260228163813.1b693ee1@jic23-huawei> (raw)
In-Reply-To: <aaAYsblcnf4SEe_X@smile.fi.intel.com>

On Thu, 26 Feb 2026 11:56:01 +0200
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> On Thu, Feb 26, 2026 at 10:43:34AM +0100, Geert Uytterhoeven wrote:
> > On Wed, 25 Feb 2026 at 12:42, Andy Shevchenko
> > <andriy.shevchenko@intel.com> wrote:  
> > > On Wed, Feb 25, 2026 at 11:17:11AM +0100, Francesco Lavra wrote:  
> 
> ...
> 
> > > > -     u8 iio_buff[ST_LSM6DSX_IIO_BUFF_SIZE] __aligned(8);
> > > > +     struct {
> > > > +             union {
> > > > +                     __le16 data[3];
> > > > +                     __le32 fifo_ts;
> > > > +             };
> > > > +             aligned_s64 timestamp;
> > > > +     } iio_buff = { };  
> > >
> > > Hmm... Have you considered m68k case? IIRC there the alignment is 2 (even for
> > > 64-bit members), so theoretically the beginning of the structure can be aligned
> > > to address 2. and hence the __le16 data[3] will have no gap to the following
> > > timestamp. In current code it's 64-bit and not 48-bit item.  
> > 
> > Fortunately, the layout of a structure does not change because the
> > first member could be stored at a less-aligned address, as that would
> > make it incompatible with a different instance that is stored at a
> > differently-aligned address ;-)
> > 
> > The alignment of a structure is the maximum of the alignments of its
> > members.  So that will be 8 bytes, as the aligned_s64 definition has
> > an internal "__attribute__((aligned(8)))".  
> 
> Thanks for the elaboration on this case, my knowledge about m68k is too shallow!
> 
> > It would be wise to add explicit padding ("u16 pad") just before
> > timestamp though, for documentation purpose.  
> 
> __le16 :-) Something like this:
> 
>      struct {
>              union {
> 	             __le16 data[3];
>                      __le32 fifo_ts;
>              };
> 	     __le16 reserved; // ...compatibility with the previous impl...

We typically haven't done this.  I'm not sure why this driver justifies it
as IIO timestamp placement always relies on the set of rules Geert has
laid out.

Also if we did do it, applying an endianness to reserve data is a an odd 
thing to do.

So as far a I'm concerned the approach in this patch seems fine.

Thanks,

Jonathan

>              aligned_s64 timestamp;
>      } iio_buff = { };
> 
> ?
> 


  reply	other threads:[~2026-02-28 16:38 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-25 10:04 [PATCH v6 0/7] imu: st_lsm6dsx: Add support for rotation sensor Francesco Lavra
2026-02-25 10:06 ` [PATCH v6 1/7] iio: imu: st_lsm6dsx: Set FIFO ODR for accelerometer and gyroscope only Francesco Lavra
2026-02-25 10:06   ` [PATCH v6 2/7] iio: imu: st_lsm6dsx: Set buffer sampling frequency for accelerometer only Francesco Lavra
2026-02-25 10:06   ` [PATCH v6 3/7] iio: imu: st_lsm6dsx: Fix check for invalid samples from FIFO Francesco Lavra
2026-02-25 10:06   ` [PATCH v6 4/7] iio: Rename 'sign' field to `format` in struct iio_scan_type Francesco Lavra
2026-02-25 10:06   ` [PATCH v6 5/7] iio: ABI: Add support for floating-point numbers in buffer scan elements Francesco Lavra
2026-02-25 10:06   ` [PATCH v6 6/7] iio: ABI: Add custom data type Francesco Lavra
2026-02-25 10:06   ` [PATCH v6 7/7] iio: imu: st_lsm6dsx: Add support for rotation sensor Francesco Lavra
2026-02-25 10:11 ` [PATCH v6 1/7] iio: imu: st_lsm6dsx: Set FIFO ODR for accelerometer and gyroscope only Francesco Lavra
2026-02-25 10:16 ` [PATCH v6 2/7] iio: imu: st_lsm6dsx: Set buffer sampling frequency for accelerometer only Francesco Lavra
2026-02-28 17:56   ` Jonathan Cameron
2026-02-25 10:17 ` [PATCH v6 3/7] iio: imu: st_lsm6dsx: Fix check for invalid samples from FIFO Francesco Lavra
2026-02-25 11:39   ` Andy Shevchenko
2026-02-26  9:43     ` Geert Uytterhoeven
2026-02-26  9:56       ` Andy Shevchenko
2026-02-28 16:38         ` Jonathan Cameron [this message]
2026-02-25 10:17 ` [PATCH v6 4/7] iio: Rename 'sign' field to `format` in struct iio_scan_type Francesco Lavra
2026-02-25 21:27   ` David Lechner
2026-02-28 17:59     ` Jonathan Cameron
2026-02-25 10:17 ` [PATCH v6 5/7] iio: ABI: Add support for floating-point numbers in buffer scan elements Francesco Lavra
2026-02-25 11:29   ` Andy Shevchenko
2026-02-25 21:27   ` David Lechner
2026-02-25 10:18 ` [PATCH v6 6/7] iio: ABI: Add custom data type Francesco Lavra
2026-02-25 11:43   ` Andy Shevchenko
2026-02-25 21:27     ` David Lechner
2026-02-26  9:21       ` Andy Shevchenko
2026-02-26 15:30         ` Francesco Lavra
2026-02-26 15:57           ` Andy Shevchenko
2026-02-28 17:52             ` Jonathan Cameron
2026-02-25 10:18 ` [PATCH v6 7/7] iio: imu: st_lsm6dsx: Add support for rotation sensor Francesco Lavra
2026-02-25 11:50   ` Andy Shevchenko
2026-02-25 21:41   ` David Lechner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260228163813.1b693ee1@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=flavra@baylibre.com \
    --cc=geert@linux-m68k.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=nuno.sa@analog.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®