forked from Minki/linux
iio: core: Fix IIO_ALIGN and rename as it was not sufficiently large
Discussion of the series: https://lore.kernel.org/all/20220405135758.774016-1-catalin.marinas@arm.com/ mm, arm64: Reduce ARCH_KMALLOC_MINALIGN brought to my attention that our current IIO usage of L1CACHE_ALIGN is insufficient as their are Arm platforms out their with non coherent DMA and larger cache lines at at higher levels of their cache hierarchy. Rename the define to make it's purpose more explicit. It will be used much more widely going forwards (to replace incorrect ____cacheline_aligned markings. Note this patch will greatly reduce the padding on some architectures that have smaller requirements for DMA safe buffers. The history of changing values of ARCH_KMALLOC_MINALIGN via ARCH_DMA_MINALIGN on arm64 is rather complex. I'm not tagging this as fixing a particular patch from that route as it's not clear what to tag. Most recently a change to bring them back inline was reverted because of some Qualcomm Kryo cores with an L2 cache with 128-byte lines sitting above the point of coherency.c1132702c7
Revert "arm64: cache: Lower ARCH_DMA_MINALIGN to 64 (L1_CACHE_BYTES)" That reverts:65688d2a05
arm64: cache: Lower ARCH_DMA_MINALIGN to 64 (L1_CACHE_BYTES) which refers to the change originally being motivated by Thunder x1 performance rather than correctness. Fixes:6f7c8ee585
("staging:iio: Add ability to allocate private data space to iio_allocate_device") Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Acked-by: Nuno Sá <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20220508175712.647246-2-jic23@kernel.org
This commit is contained in:
parent
68d07a7bc3
commit
12c4efe350
@ -93,7 +93,7 @@ struct bma400_data {
|
|||||||
__le16 buff[3];
|
__le16 buff[3];
|
||||||
u8 temperature;
|
u8 temperature;
|
||||||
s64 ts __aligned(8);
|
s64 ts __aligned(8);
|
||||||
} buffer __aligned(IIO_ALIGN);
|
} buffer __aligned(IIO_DMA_MINALIGN);
|
||||||
__le16 status;
|
__le16 status;
|
||||||
__be16 duration;
|
__be16 duration;
|
||||||
};
|
};
|
||||||
|
@ -84,7 +84,8 @@ void *adi_axi_adc_conv_priv(struct adi_axi_adc_conv *conv)
|
|||||||
{
|
{
|
||||||
struct adi_axi_adc_client *cl = conv_to_client(conv);
|
struct adi_axi_adc_client *cl = conv_to_client(conv);
|
||||||
|
|
||||||
return (char *)cl + ALIGN(sizeof(struct adi_axi_adc_client), IIO_ALIGN);
|
return (char *)cl + ALIGN(sizeof(struct adi_axi_adc_client),
|
||||||
|
IIO_DMA_MINALIGN);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_NS_GPL(adi_axi_adc_conv_priv, IIO_ADI_AXI);
|
EXPORT_SYMBOL_NS_GPL(adi_axi_adc_conv_priv, IIO_ADI_AXI);
|
||||||
|
|
||||||
@ -169,9 +170,9 @@ static struct adi_axi_adc_conv *adi_axi_adc_conv_register(struct device *dev,
|
|||||||
struct adi_axi_adc_client *cl;
|
struct adi_axi_adc_client *cl;
|
||||||
size_t alloc_size;
|
size_t alloc_size;
|
||||||
|
|
||||||
alloc_size = ALIGN(sizeof(struct adi_axi_adc_client), IIO_ALIGN);
|
alloc_size = ALIGN(sizeof(struct adi_axi_adc_client), IIO_DMA_MINALIGN);
|
||||||
if (sizeof_priv)
|
if (sizeof_priv)
|
||||||
alloc_size += ALIGN(sizeof_priv, IIO_ALIGN);
|
alloc_size += ALIGN(sizeof_priv, IIO_DMA_MINALIGN);
|
||||||
|
|
||||||
cl = kzalloc(alloc_size, GFP_KERNEL);
|
cl = kzalloc(alloc_size, GFP_KERNEL);
|
||||||
if (!cl)
|
if (!cl)
|
||||||
|
@ -1630,7 +1630,7 @@ struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv)
|
|||||||
|
|
||||||
alloc_size = sizeof(struct iio_dev_opaque);
|
alloc_size = sizeof(struct iio_dev_opaque);
|
||||||
if (sizeof_priv) {
|
if (sizeof_priv) {
|
||||||
alloc_size = ALIGN(alloc_size, IIO_ALIGN);
|
alloc_size = ALIGN(alloc_size, IIO_DMA_MINALIGN);
|
||||||
alloc_size += sizeof_priv;
|
alloc_size += sizeof_priv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1640,7 +1640,7 @@ struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv)
|
|||||||
|
|
||||||
indio_dev = &iio_dev_opaque->indio_dev;
|
indio_dev = &iio_dev_opaque->indio_dev;
|
||||||
indio_dev->priv = (char *)iio_dev_opaque +
|
indio_dev->priv = (char *)iio_dev_opaque +
|
||||||
ALIGN(sizeof(struct iio_dev_opaque), IIO_ALIGN);
|
ALIGN(sizeof(struct iio_dev_opaque), IIO_DMA_MINALIGN);
|
||||||
|
|
||||||
indio_dev->dev.parent = parent;
|
indio_dev->dev.parent = parent;
|
||||||
indio_dev->dev.type = &iio_device_type;
|
indio_dev->dev.type = &iio_device_type;
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include <linux/device.h>
|
#include <linux/device.h>
|
||||||
#include <linux/cdev.h>
|
#include <linux/cdev.h>
|
||||||
|
#include <linux/slab.h>
|
||||||
#include <linux/iio/types.h>
|
#include <linux/iio/types.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
/* IIO TODO LIST */
|
/* IIO TODO LIST */
|
||||||
@ -708,8 +709,13 @@ static inline void *iio_device_get_drvdata(const struct iio_dev *indio_dev)
|
|||||||
return dev_get_drvdata(&indio_dev->dev);
|
return dev_get_drvdata(&indio_dev->dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Can we make this smaller? */
|
/*
|
||||||
#define IIO_ALIGN L1_CACHE_BYTES
|
* Used to ensure the iio_priv() structure is aligned to allow that structure
|
||||||
|
* to in turn include IIO_DMA_MINALIGN'd elements such as buffers which
|
||||||
|
* must not share cachelines with the rest of the structure, thus making
|
||||||
|
* them safe for use with non-coherent DMA.
|
||||||
|
*/
|
||||||
|
#define IIO_DMA_MINALIGN ARCH_KMALLOC_MINALIGN
|
||||||
struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv);
|
struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv);
|
||||||
|
|
||||||
/* The information at the returned address is guaranteed to be cacheline aligned */
|
/* The information at the returned address is guaranteed to be cacheline aligned */
|
||||||
|
Loading…
Reference in New Issue
Block a user