Skip to content

Commit a66d972

Browse files
abrodkingregkh
authored andcommitted
devres: Align data[] to ARCH_KMALLOC_MINALIGN
Initially we bumped into problem with 32-bit aligned atomic64_t on ARC, see [1]. And then during quite lengthly discussion Peter Z. mentioned ARCH_KMALLOC_MINALIGN which IMHO makes perfect sense. If allocation is done by plain kmalloc() obtained buffer will be ARCH_KMALLOC_MINALIGN aligned and then why buffer obtained via devm_kmalloc() should have any other alignment? This way we at least get the same behavior for both types of allocation. [1] http://lists.infradead.org/pipermail/linux-snps-arc/2018-July/004009.html [2] http://lists.infradead.org/pipermail/linux-snps-arc/2018-July/004036.html Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: David Laight <David.Laight@ACULAB.COM> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Vineet Gupta <vgupta@synopsys.com> Cc: Will Deacon <will.deacon@arm.com> Cc: Greg KH <greg@kroah.com> Cc: <stable@vger.kernel.org> # 4.8+ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 6510223 commit a66d972

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/base/devres.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,14 @@ struct devres_node {
2626

2727
struct devres {
2828
struct devres_node node;
29-
/* -- 3 pointers */
30-
unsigned long long data[]; /* guarantee ull alignment */
29+
/*
30+
* Some archs want to perform DMA into kmalloc caches
31+
* and need a guaranteed alignment larger than
32+
* the alignment of a 64-bit integer.
33+
* Thus we use ARCH_KMALLOC_MINALIGN here and get exactly the same
34+
* buffer alignment as if it was allocated by plain kmalloc().
35+
*/
36+
u8 __aligned(ARCH_KMALLOC_MINALIGN) data[];
3137
};
3238

3339
struct devres_group {

0 commit comments

Comments
 (0)