* [PATCH] iio: adc: ad7606: explicit timestamp alignment
@ 2025-04-29 2:17 David Lechner
2025-04-29 13:01 ` Nuno Sá
0 siblings, 1 reply; 5+ messages in thread
From: David Lechner @ 2025-04-29 2:17 UTC (permalink / raw)
To: Michael Hennerich, Jonathan Cameron, Nuno Sá,
Andy Shevchenko
Cc: linux-iio, linux-kernel
Use struct with aligned_s64 timestamp to make timestamp alignment
explicit. Technically, what we have works because for all known
architectures, IIO_DMA_MINALIGN is a multiple of __alignof__(s64).
But this way, we don't have to make people read the comments to know
why there are extra elements in each buffer.
---
drivers/iio/adc/ad7606.h | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/iio/adc/ad7606.h b/drivers/iio/adc/ad7606.h
index 89d49551eaf515bab9706c12bff056dfcb707b67..441e62c521bcbea69b4f70bb2d55f65334d22276 100644
--- a/drivers/iio/adc/ad7606.h
+++ b/drivers/iio/adc/ad7606.h
@@ -155,12 +155,15 @@ struct ad7606_state {
/*
* DMA (thus cache coherency maintenance) may require the
* transfer buffers to live in their own cache lines.
- * 16 * 16-bit samples + 64-bit timestamp - for AD7616
- * 8 * 32-bit samples + 64-bit timestamp - for AD7616C-18 (and similar)
+ * 16 * 16-bit samples for AD7616
+ * 8 * 32-bit samples for AD7616C-18 (and similar)
*/
- union {
- u16 buf16[20];
- u32 buf32[10];
+ struct {
+ union {
+ u16 buf16[16];
+ u32 buf32[8];
+ };
+ aligned_s64 timestamp;
} data __aligned(IIO_DMA_MINALIGN);
__be16 d16[2];
};
---
base-commit: b475195fecc79a1a6e7fb0846aaaab0a1a4cb2e6
change-id: 20250428-iio-adc-ad7606-fix-buffer-alignment-9fcde71687dc
Best regards,
--
David Lechner <dlechner@baylibre.com>
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] iio: adc: ad7606: explicit timestamp alignment
2025-04-29 2:17 [PATCH] iio: adc: ad7606: explicit timestamp alignment David Lechner
@ 2025-04-29 13:01 ` Nuno Sá
2025-05-04 14:55 ` Jonathan Cameron
0 siblings, 1 reply; 5+ messages in thread
From: Nuno Sá @ 2025-04-29 13:01 UTC (permalink / raw)
To: David Lechner, Michael Hennerich, Jonathan Cameron, Nuno Sá,
Andy Shevchenko
Cc: linux-iio, linux-kernel
On Mon, 2025-04-28 at 21:17 -0500, David Lechner wrote:
> Use struct with aligned_s64 timestamp to make timestamp alignment
> explicit. Technically, what we have works because for all known
> architectures, IIO_DMA_MINALIGN is a multiple of __alignof__(s64).
> But this way, we don't have to make people read the comments to know
> why there are extra elements in each buffer.
>
> ---
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
> drivers/iio/adc/ad7606.h | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/iio/adc/ad7606.h b/drivers/iio/adc/ad7606.h
> index
> 89d49551eaf515bab9706c12bff056dfcb707b67..441e62c521bcbea69b4f70bb2d55f65334d2
> 2276 100644
> --- a/drivers/iio/adc/ad7606.h
> +++ b/drivers/iio/adc/ad7606.h
> @@ -155,12 +155,15 @@ struct ad7606_state {
> /*
> * DMA (thus cache coherency maintenance) may require the
> * transfer buffers to live in their own cache lines.
> - * 16 * 16-bit samples + 64-bit timestamp - for AD7616
> - * 8 * 32-bit samples + 64-bit timestamp - for AD7616C-18 (and
> similar)
> + * 16 * 16-bit samples for AD7616
> + * 8 * 32-bit samples for AD7616C-18 (and similar)
> */
> - union {
> - u16 buf16[20];
> - u32 buf32[10];
> + struct {
> + union {
> + u16 buf16[16];
> + u32 buf32[8];
> + };
> + aligned_s64 timestamp;
> } data __aligned(IIO_DMA_MINALIGN);
> __be16 d16[2];
> };
>
> ---
> base-commit: b475195fecc79a1a6e7fb0846aaaab0a1a4cb2e6
> change-id: 20250428-iio-adc-ad7606-fix-buffer-alignment-9fcde71687dc
>
> Best regards,
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] iio: adc: ad7606: explicit timestamp alignment
2025-04-29 13:01 ` Nuno Sá
@ 2025-05-04 14:55 ` Jonathan Cameron
2025-05-05 13:57 ` David Lechner
0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Cameron @ 2025-05-04 14:55 UTC (permalink / raw)
To: Nuno Sá
Cc: David Lechner, Michael Hennerich, Nuno Sá, Andy Shevchenko,
linux-iio, linux-kernel
On Tue, 29 Apr 2025 14:01:54 +0100
Nuno Sá <noname.nuno@gmail.com> wrote:
> On Mon, 2025-04-28 at 21:17 -0500, David Lechner wrote:
> > Use struct with aligned_s64 timestamp to make timestamp alignment
> > explicit. Technically, what we have works because for all known
> > architectures, IIO_DMA_MINALIGN is a multiple of __alignof__(s64).
> > But this way, we don't have to make people read the comments to know
> > why there are extra elements in each buffer.
> >
> > ---
>
> Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Applied to the togreg branch of iio.git and pushed out as testing
for all the normal reasons.
Thanks,
Jonathan
>
> > drivers/iio/adc/ad7606.h | 13 ++++++++-----
> > 1 file changed, 8 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/iio/adc/ad7606.h b/drivers/iio/adc/ad7606.h
> > index
> > 89d49551eaf515bab9706c12bff056dfcb707b67..441e62c521bcbea69b4f70bb2d55f65334d2
> > 2276 100644
> > --- a/drivers/iio/adc/ad7606.h
> > +++ b/drivers/iio/adc/ad7606.h
> > @@ -155,12 +155,15 @@ struct ad7606_state {
> > /*
> > * DMA (thus cache coherency maintenance) may require the
> > * transfer buffers to live in their own cache lines.
> > - * 16 * 16-bit samples + 64-bit timestamp - for AD7616
> > - * 8 * 32-bit samples + 64-bit timestamp - for AD7616C-18 (and
> > similar)
> > + * 16 * 16-bit samples for AD7616
> > + * 8 * 32-bit samples for AD7616C-18 (and similar)
> > */
> > - union {
> > - u16 buf16[20];
> > - u32 buf32[10];
> > + struct {
> > + union {
> > + u16 buf16[16];
> > + u32 buf32[8];
> > + };
> > + aligned_s64 timestamp;
> > } data __aligned(IIO_DMA_MINALIGN);
> > __be16 d16[2];
> > };
> >
> > ---
> > base-commit: b475195fecc79a1a6e7fb0846aaaab0a1a4cb2e6
> > change-id: 20250428-iio-adc-ad7606-fix-buffer-alignment-9fcde71687dc
> >
> > Best regards,
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] iio: adc: ad7606: explicit timestamp alignment
2025-05-04 14:55 ` Jonathan Cameron
@ 2025-05-05 13:57 ` David Lechner
2025-05-05 15:14 ` Jonathan Cameron
0 siblings, 1 reply; 5+ messages in thread
From: David Lechner @ 2025-05-05 13:57 UTC (permalink / raw)
To: Jonathan Cameron, Nuno Sá
Cc: Michael Hennerich, Nuno Sá, Andy Shevchenko, linux-iio,
linux-kernel
On 5/4/25 9:55 AM, Jonathan Cameron wrote:
> On Tue, 29 Apr 2025 14:01:54 +0100
> Nuno Sá <noname.nuno@gmail.com> wrote:
>
>> On Mon, 2025-04-28 at 21:17 -0500, David Lechner wrote:
>>> Use struct with aligned_s64 timestamp to make timestamp alignment
>>> explicit. Technically, what we have works because for all known
>>> architectures, IIO_DMA_MINALIGN is a multiple of __alignof__(s64).
>>> But this way, we don't have to make people read the comments to know
>>> why there are extra elements in each buffer.
>>>
>>> ---
>>
>> Reviewed-by: Nuno Sá <nuno.sa@analog.com>
> Applied to the togreg branch of iio.git and pushed out as testing
> for all the normal reasons.
>
Not sure how we all managed to this, but this is missing:
Signed-off-by: David Lechner <dlechner@baylibre.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] iio: adc: ad7606: explicit timestamp alignment
2025-05-05 13:57 ` David Lechner
@ 2025-05-05 15:14 ` Jonathan Cameron
0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2025-05-05 15:14 UTC (permalink / raw)
To: David Lechner
Cc: Nuno Sá, Michael Hennerich, Nuno Sá, Andy Shevchenko,
linux-iio, linux-kernel
On Mon, 5 May 2025 08:57:29 -0500
David Lechner <dlechner@baylibre.com> wrote:
> On 5/4/25 9:55 AM, Jonathan Cameron wrote:
> > On Tue, 29 Apr 2025 14:01:54 +0100
> > Nuno Sá <noname.nuno@gmail.com> wrote:
> >
> >> On Mon, 2025-04-28 at 21:17 -0500, David Lechner wrote:
> >>> Use struct with aligned_s64 timestamp to make timestamp alignment
> >>> explicit. Technically, what we have works because for all known
> >>> architectures, IIO_DMA_MINALIGN is a multiple of __alignof__(s64).
> >>> But this way, we don't have to make people read the comments to know
> >>> why there are extra elements in each buffer.
> >>>
> >>> ---
> >>
> >> Reviewed-by: Nuno Sá <nuno.sa@analog.com>
> > Applied to the togreg branch of iio.git and pushed out as testing
> > for all the normal reasons.
> >
> Not sure how we all managed to this, but this is missing:
>
> Signed-off-by: David Lechner <dlechner@baylibre.com>
>
Oops.
Added.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-05-05 15:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-29 2:17 [PATCH] iio: adc: ad7606: explicit timestamp alignment David Lechner
2025-04-29 13:01 ` Nuno Sá
2025-05-04 14:55 ` Jonathan Cameron
2025-05-05 13:57 ` David Lechner
2025-05-05 15:14 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox