This is a note to let you know that I've just added the patch titled counter: fix privdata alignment to the 6.1-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: counter-fix-privdata-alignment.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 40db7c1162d3c9e98afbc6f9ff597392acbfed47 Author: Nuno Sa <nuno.sa@xxxxxxxxxx> Date: Fri Feb 9 16:50:34 2024 +0100 counter: fix privdata alignment [ Upstream commit c83ccdc9586b3e9882da9e27507c046751999d59 ] Aligning to the L1 cache does not guarantee the same alignment as kmallocing an object [1]. Furthermore, in some platforms, that alignment is not sufficient for DMA safety (in case someone wants to have a DMA safe buffer in privdata) [2]. Sometime ago, we had the same fixes in IIO. [1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/base/devres.c#n35 [2]: https://lore.kernel.org/linux-iio/20220508175712.647246-2-jic23@xxxxxxxxxx/ Fixes: c18e2760308e ("counter: Provide alternative counter registration functions") Signed-off-by: Nuno Sa <nuno.sa@xxxxxxxxxx> Link: https://lore.kernel.org/r/20240209-counter-align-fix-v2-1-5777ea0a2722@xxxxxxxxxx Signed-off-by: William Breathitt Gray <william.gray@xxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/drivers/counter/counter-core.c b/drivers/counter/counter-core.c index 09c77afb33ca8..3f24481fc04a1 100644 --- a/drivers/counter/counter-core.c +++ b/drivers/counter/counter-core.c @@ -31,10 +31,11 @@ struct counter_device_allochelper { struct counter_device counter; /* - * This is cache line aligned to ensure private data behaves like if it - * were kmalloced separately. + * This ensures private data behaves like if it were kmalloced + * separately. Also ensures the minimum alignment for safe DMA + * operations (which may or may not mean cache alignment). */ - unsigned long privdata[] ____cacheline_aligned; + unsigned long privdata[] __aligned(ARCH_DMA_MINALIGN); }; static void counter_device_release(struct device *dev)