diff mbox series

[02/92] iio: accel: adxl313: Fix alignment for DMA safety

Message ID 20220503085935.1533814-3-jic23@kernel.org (mailing list archive)
State Superseded
Headers show
Series IIO: Fix alignment of buffers for DMA | expand

Commit Message

Jonathan Cameron May 3, 2022, 8:58 a.m. UTC
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

____cacheline_aligned is insufficient guarantee for non-coherent DMA.
Switch to the update IIO_ALIGN definition.

Fixes: 636d44633039 ("iio: accel: Add driver support for ADXL313")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/accel/adxl313_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Lars-Peter Clausen May 3, 2022, 1:11 p.m. UTC | #1
On 5/3/22 10:58, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> ____cacheline_aligned is insufficient guarantee for non-coherent DMA.
> Switch to the update IIO_ALIGN definition.
>
> Fixes: 636d44633039 ("iio: accel: Add driver support for ADXL313")
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
>   drivers/iio/accel/adxl313_core.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/accel/adxl313_core.c b/drivers/iio/accel/adxl313_core.c
> index 9e4193e64765..508fccbd4347 100644
> --- a/drivers/iio/accel/adxl313_core.c
> +++ b/drivers/iio/accel/adxl313_core.c
> @@ -46,7 +46,7 @@ EXPORT_SYMBOL_NS_GPL(adxl313_writable_regs_table, IIO_ADXL313);
>   struct adxl313_data {
>   	struct regmap	*regmap;
>   	struct mutex	lock; /* lock to protect transf_buf */
> -	__le16		transf_buf ____cacheline_aligned;
> +	__le16		transf_buf __aligned(IIO_ALIGN);
How about making __aligned(IIO_ALIGN) a macro in case we ever want to 
change it.
>   };
>   
>   static const int adxl313_odr_freqs[][2] = {
Jonathan Cameron May 3, 2022, 4:27 p.m. UTC | #2
On Tue, 3 May 2022 15:11:26 +0200
Lars-Peter Clausen <lars@metafoo.de> wrote:

> On 5/3/22 10:58, Jonathan Cameron wrote:
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> >
> > ____cacheline_aligned is insufficient guarantee for non-coherent DMA.
> > Switch to the update IIO_ALIGN definition.
> >
> > Fixes: 636d44633039 ("iio: accel: Add driver support for ADXL313")
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > ---
> >   drivers/iio/accel/adxl313_core.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/iio/accel/adxl313_core.c b/drivers/iio/accel/adxl313_core.c
> > index 9e4193e64765..508fccbd4347 100644
> > --- a/drivers/iio/accel/adxl313_core.c
> > +++ b/drivers/iio/accel/adxl313_core.c
> > @@ -46,7 +46,7 @@ EXPORT_SYMBOL_NS_GPL(adxl313_writable_regs_table, IIO_ADXL313);
> >   struct adxl313_data {
> >   	struct regmap	*regmap;
> >   	struct mutex	lock; /* lock to protect transf_buf */
> > -	__le16		transf_buf ____cacheline_aligned;
> > +	__le16		transf_buf __aligned(IIO_ALIGN);  
> How about making __aligned(IIO_ALIGN) a macro in case we ever want to 
> change it.

Could do I suppose, though scripts are already getting confused enough
at __aligned() :( (Try running check patch on this series!)

That can be fixed but adds another step.

I also can't actually think of why we would want to change an
align force to something other than an align force.  The value of
IIO_ALIGN might well change of course.

Jonathan



> >   };
> >   
> >   static const int adxl313_odr_freqs[][2] = {  
> 
>
diff mbox series

Patch

diff --git a/drivers/iio/accel/adxl313_core.c b/drivers/iio/accel/adxl313_core.c
index 9e4193e64765..508fccbd4347 100644
--- a/drivers/iio/accel/adxl313_core.c
+++ b/drivers/iio/accel/adxl313_core.c
@@ -46,7 +46,7 @@  EXPORT_SYMBOL_NS_GPL(adxl313_writable_regs_table, IIO_ADXL313);
 struct adxl313_data {
 	struct regmap	*regmap;
 	struct mutex	lock; /* lock to protect transf_buf */
-	__le16		transf_buf ____cacheline_aligned;
+	__le16		transf_buf __aligned(IIO_ALIGN);
 };
 
 static const int adxl313_odr_freqs[][2] = {