Skip to contentSkip to conversation

staging: iio: DMA alignment fixes.

PATCH Superseded Jonathan Cameron 3 participants 9 messages Aug 7, 2022 – Aug 13, 2022

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jonathan Cameron

author maintainer
#0 lore raw

cover staging: iio: DMA alignment fixes.

From: Jonathan Cameron <[email protected]>

When I introduced IIO_DMA_MINALIGN and applied it to all the drivers in drivers/iio I said I'd swing by the few remaining staging drivers at a later date. This set fixes those staging/iio drivers.

Note that no one has been very active on these drivers for some time. They do however support parts that are still available (and I have at least one of them) so I think it's worth keeping them around for now. Perhaps the necessary cleanup work can be done against emulation or road test or we can get parts for anyone interested in doing the necessary work.

Anyhow, upshot is that it's unlikely anyone will feel ownership of these drivers enough to review this series so if anyone has time a quick glance over it would be much appreciated!

Thanks,

Jonathan

Jonathan Cameron (4):
staging: iio: frequency: ad9832: Fix alignment for DMA safety
staging: iio: frequency: ad9834: Fix alignment for DMA safety
staging: iio: meter: ade7854: Fix alignment for DMA safety
staging: iio: resolver: ad2s1210: Fix alignment for DMA safety

 drivers/staging/iio/frequency/ad9832.c  | 2 +-
 drivers/staging/iio/frequency/ad9834.c  | 2 +-
 drivers/staging/iio/meter/ade7854.h     | 2 +-
 drivers/staging/iio/resolver/ad2s1210.c | 4 ++--
 4 files changed, 5 insertions(+), 5 deletions(-)
Signature · 1 line
2.37.1
author maintainer
#1 lore raw

PATCH 1/4 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.

---
 drivers/staging/iio/frequency/ad9832.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/frequency/ad9832.c +1 -1
index f43464db618a..ce9fcba6bc5c 100644
@@ -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;
 	};
Signature · 1 line
2.37.1
#2 lore raw

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

Quoted 6 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.

...

drivers/staging/iio/frequency/ad9832.c struct ad9832_state { · line 118

Quoted 6 lines
        union {
drivers/staging/iio/frequency/ad9832.c +1 -1
-               __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?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw

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

Quoted 10 lines · On Mon, 8 Aug 2022 11:18:34 +0200 Andy Shevchenko <[email protected]>…
Quoted 6 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.

...

Quoted 9 lines

drivers/staging/iio/frequency/ad9832.c struct ad9832_state { · line 118

Quoted 6 lines
        union {
drivers/staging/iio/frequency/ad9832.c +1 -1
-               __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.

author maintainer
#4 lore raw

PATCH 2/4 staging: iio: frequency: ad9834: Fix alignment for DMA safety

In reply to 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.

---
 drivers/staging/iio/frequency/ad9834.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/frequency/ad9834.c +1 -1
index 94b131ef8a22..2b4267a87e65 100644
@@ -83,7 +83,7 @@ struct ad9834_state {
 	 * DMA (thus cache coherency maintenance) requires the
 	 * transfer buffers to live in their own cache lines.
 	 */
-	__be16				data ____cacheline_aligned;
+	__be16				data __aligned(IIO_DMA_MINALIGN);
 	__be16				freq_data[2];
 };
 
Signature · 1 line
2.37.1
author maintainer
#5 lore raw

PATCH 3/4 staging: iio: meter: ade7854: Fix alignment for DMA safety

In reply to 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.

---
 drivers/staging/iio/meter/ade7854.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/meter/ade7854.h +1 -1
index a51e6e3183d3..7a49f8f1016f 100644
@@ -162,7 +162,7 @@ struct ade7854_state {
 			 int bits);
 	int irq;
 	struct mutex buf_lock;
-	u8 tx[ADE7854_MAX_TX] ____cacheline_aligned;
+	u8 tx[ADE7854_MAX_TX] __aligned(IIO_DMA_MINALIGN);
 	u8 rx[ADE7854_MAX_RX];
 
 };
Signature · 1 line
2.37.1
author maintainer
#6 lore raw

PATCH 4/4 staging: iio: resolver: ad2s1210: Fix alignment for DMA safety

In reply to 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. As the tx[] an rx[] buffers are only used in the same SPI exchanges, we should be safe with them on the same cacheline. Hence only mark the first one __aligned(IIO_DMA_MINALIGN).

---
 drivers/staging/iio/resolver/ad2s1210.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/iio/resolver/ad2s1210.c +2 -2
index c0b2716d0511..e4cf42438487 100644
@@ -94,8 +94,8 @@ struct ad2s1210_state {
 	bool hysteresis;
 	u8 resolution;
 	enum ad2s1210_mode mode;
-	u8 rx[2] ____cacheline_aligned;
-	u8 tx[2] ____cacheline_aligned;
+	u8 rx[2] __aligned(IIO_DMA_MINALIGN);
+	u8 tx[2];
 };
 
 static const int ad2s1210_mode_vals[4][2] = {
Signature · 1 line
2.37.1
Reviewed-by on the v1 series
#7 lore raw
In reply to Jonathan Cameron
Quoted 14 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

When I introduced IIO_DMA_MINALIGN and applied it to all the drivers in drivers/iio I said I'd swing by the few remaining staging drivers at a later date. This set fixes those staging/iio drivers.

Note that no one has been very active on these drivers for some time. They do however support parts that are still available (and I have at least one of them) so I think it's worth keeping them around for now. Perhaps the necessary cleanup work can be done against emulation or road test or we can get parts for anyone interested in doing the necessary work.

Quoted 3 lines

Anyhow, upshot is that it's unlikely anyone will feel ownership of these drivers enough to review this series so if anyone has time a quick glance over it would be much appreciated!

for non-commented patches.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#8 lore raw
Quoted 15 lines · On Mon, 8 Aug 2022 11:20:32 +0200 Andy Shevchenko <[email protected]>…
Quoted 14 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

When I introduced IIO_DMA_MINALIGN and applied it to all the drivers in drivers/iio I said I'd swing by the few remaining staging drivers at a later date. This set fixes those staging/iio drivers.

Note that no one has been very active on these drivers for some time. They do however support parts that are still available (and I have at least one of them) so I think it's worth keeping them around for now. Perhaps the necessary cleanup work can be done against emulation or road test or we can get parts for anyone interested in doing the necessary work.

Quoted 8 lines
Quoted 3 lines

Anyhow, upshot is that it's unlikely anyone will feel ownership of these drivers enough to review this series so if anyone has time a quick glance over it would be much appreciated!

for non-commented patches.

Thanks, patches 2-4 applied. v2 of patch one to be posted shortly.

Jonathan