Skip to contentSkip to conversation

staging: iio: frequency: ad9832: Fix alignment for DMA safety

PATCH In review Jonathan Cameron 2 participants 2 messages Aug 13, 2022 – Aug 14, 2022

Subsystems (4)
lore
Share & tools
lore

Jonathan Cameron

author maintainer
#0 lore raw

PATCH v2 1/1 staging: iio: frequency: ad9832: Fix alignment for DMA safety

From: Jonathan Cameron <[email protected]>

____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. Whilst here, move the marking to cover the whole union. That has not functional affect, but makes it slightly easier to see what is going on.

---
v2: Move the alignment marking to the union rather than an element in the
union. (Andy Shevchenko)

 drivers/staging/iio/frequency/ad9832.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/iio/frequency/ad9832.c +2 -2
index f43464db618a..6f9eebd6c7ee 100644
@@ -112,10 +112,10 @@ struct ad9832_state {
 	 * transfer buffers to live in their own cache lines.
 	 */
 	union {
-		__be16			freq_data[4]____cacheline_aligned;
+		__be16			freq_data[4];
 		__be16			phase_data[2];
 		__be16			data;
-	};
+	} __aligned(IIO_DMA_MINALIGN);
 };
 
 static unsigned long ad9832_calc_freqreg(unsigned long mclk, unsigned long fout)
Signature · 1 line
2.37.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

____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. Whilst here, move the marking to cover the whole union. That has not functional affect, but makes it slightly

not --> no ?

Quoted 1 line

easier to see what is going on.

Quoted 28 lines

---
v2: Move the alignment marking to the union rather than an element in the
union. (Andy Shevchenko)

 drivers/staging/iio/frequency/ad9832.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/iio/frequency/ad9832.c +2 -3
index f43464db618a..6f9eebd6c7ee 100644
@@ -112,10 +112,10 @@ struct ad9832_state {
         * transfer buffers to live in their own cache lines.
         */
        union {
-               __be16                  freq_data[4]____cacheline_aligned;
+               __be16                  freq_data[4];
                __be16                  phase_data[2];
                __be16                  data;
-       };
+       } __aligned(IIO_DMA_MINALIGN);
 };
 
 static unsigned long ad9832_calc_freqreg(unsigned long mclk, unsigned long fout)
--

2.37.1

Signature · 2 lines
With Best Regards,
Andy Shevchenko