Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: accel: adxl367: Fix alignment for DMA safety

____cacheline_aligned is insufficient guarantee for non-coherent DMA.
Switch to the updated IIO_DMA_MINALIGN definition.

Update comment to reflect that DMA safety may require separate
cachelines.

Fixes: cbab791c5e2a5 ("iio: accel: add ADXL367 driver")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Cosmin Tanislav <demonsingur@gmail.com>
Acked-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20220508175712.647246-5-jic23@kernel.org

+6 -4
+1 -1
drivers/iio/accel/adxl367.c
··· 179 179 unsigned int fifo_set_size; 180 180 unsigned int fifo_watermark; 181 181 182 - __be16 fifo_buf[ADXL367_FIFO_SIZE] ____cacheline_aligned; 182 + __be16 fifo_buf[ADXL367_FIFO_SIZE] __aligned(IIO_DMA_MINALIGN); 183 183 __be16 sample_buf; 184 184 u8 act_threshold_buf[2]; 185 185 u8 inact_time_buf[2];
+5 -3
drivers/iio/accel/adxl367_spi.c
··· 9 9 #include <linux/regmap.h> 10 10 #include <linux/spi/spi.h> 11 11 12 + #include <linux/iio/iio.h> 13 + 12 14 #include "adxl367.h" 13 15 14 16 #define ADXL367_SPI_WRITE_COMMAND 0x0A ··· 30 28 struct spi_transfer fifo_xfer[2]; 31 29 32 30 /* 33 - * DMA (thus cache coherency maintenance) requires the 34 - * transfer buffers to live in their own cache lines. 31 + * DMA (thus cache coherency maintenance) may require the 32 + * transfer buffers live in their own cache lines. 35 33 */ 36 - u8 reg_write_tx_buf[1] ____cacheline_aligned; 34 + u8 reg_write_tx_buf[1] __aligned(IIO_DMA_MINALIGN); 37 35 u8 reg_read_tx_buf[2]; 38 36 u8 fifo_tx_buf[1]; 39 37 };