diff mbox series

[1/4] staging: iio: frequency: ad9832: Fix alignment for DMA safety

Message ID 20220807151218.656881-2-jic23@kernel.org (mailing list archive)
State Superseded
Headers show
Series staging: iio: DMA alignment fixes. | expand

Commit Message

Jonathan Cameron Aug. 7, 2022, 3:12 p.m. UTC
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

____cacheline_aligned is an insufficient guarantee for non-coherent DMA
on platforms with 128 byte cachelines above L1.  Switch to the updated
IIO_DMA_MINALIGN definition.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/staging/iio/frequency/ad9832.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andy Shevchenko Aug. 8, 2022, 9:18 a.m. UTC | #1
On Sun, Aug 7, 2022 at 5:26 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> ____cacheline_aligned is an insufficient guarantee for non-coherent DMA
> on platforms with 128 byte cachelines above L1.  Switch to the updated
> IIO_DMA_MINALIGN definition.

...

>         union {
> -               __be16                  freq_data[4]____cacheline_aligned;
> +               __be16                  freq_data[4] __aligned(IIO_DMA_MINALIGN);
>                 __be16                  phase_data[2];
>                 __be16                  data;
>         };

Hmm... Can we rather mark the entire union with it?
Jonathan Cameron Aug. 8, 2022, 2:14 p.m. UTC | #2
On Mon, 8 Aug 2022 11:18:34 +0200
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Sun, Aug 7, 2022 at 5:26 PM Jonathan Cameron <jic23@kernel.org> wrote:
> >
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> >
> > ____cacheline_aligned is an insufficient guarantee for non-coherent DMA
> > on platforms with 128 byte cachelines above L1.  Switch to the updated
> > IIO_DMA_MINALIGN definition.  
> 
> ...
> 
> >         union {
> > -               __be16                  freq_data[4]____cacheline_aligned;
> > +               __be16                  freq_data[4] __aligned(IIO_DMA_MINALIGN);
> >                 __be16                  phase_data[2];
> >                 __be16                  data;
> >         };  
> 
> Hmm... Can we rather mark the entire union with it?
> 

ah. I'd not even registered it was a union ;)  Anyhow, yes, that would make
sense.
diff mbox series

Patch

diff --git a/drivers/staging/iio/frequency/ad9832.c b/drivers/staging/iio/frequency/ad9832.c
index f43464db618a..ce9fcba6bc5c 100644
--- a/drivers/staging/iio/frequency/ad9832.c
+++ b/drivers/staging/iio/frequency/ad9832.c
@@ -112,7 +112,7 @@  struct ad9832_state {
 	 * transfer buffers to live in their own cache lines.
 	 */
 	union {
-		__be16			freq_data[4]____cacheline_aligned;
+		__be16			freq_data[4] __aligned(IIO_DMA_MINALIGN);
 		__be16			phase_data[2];
 		__be16			data;
 	};