Message ID | 20171211144937.4537-2-marc.zyngier@arm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Mon, Dec 11, 2017 at 02:49:19PM +0000, Marc Zyngier wrote: > asm-offsets.h contains a few DMA related definitions that have > the exact same name than the enum members they are derived from. > > While this is not a problem so far, it will become an issue if > both asm-offsets.h and include/linux/dma-direction.h: are pulled > by the same file. Umm. asm-offsets.h is only supposed to be included by assembly files. Assembly files would not be able to include linux/dma-direction.h So this shouldn't be a problem. The same could be true of things like CLOCK_REALTIME etc. Just don't do it. Keep asm-offsets.h as something that gets included by assembly and only assembly. If you need to know the offset of some member, use offsetof(), don't re-use asm-offsets.h.
On 11/12/17 15:03, Russell King - ARM Linux wrote: > On Mon, Dec 11, 2017 at 02:49:19PM +0000, Marc Zyngier wrote: >> asm-offsets.h contains a few DMA related definitions that have >> the exact same name than the enum members they are derived from. >> >> While this is not a problem so far, it will become an issue if >> both asm-offsets.h and include/linux/dma-direction.h: are pulled >> by the same file. > > Umm. asm-offsets.h is only supposed to be included by assembly files. > Assembly files would not be able to include linux/dma-direction.h > So this shouldn't be a problem. > > The same could be true of things like CLOCK_REALTIME etc. > > Just don't do it. Keep asm-offsets.h as something that gets included > by assembly and only assembly. That'd be true if C code never used anything that is exposed by asm-offsets.h. Unfortunately, things like our alternative patching relies on generating assembly (or rather, using assembly generated data structures). For more details, please see patch 4 in the same series. Thanks, M.
diff --git a/arch/arm64/kernel/asm-offsets.c b/arch/arm64/kernel/asm-offsets.c index 71bf088f1e4b..7e8be0c22ce0 100644 --- a/arch/arm64/kernel/asm-offsets.c +++ b/arch/arm64/kernel/asm-offsets.c @@ -87,9 +87,9 @@ int main(void) BLANK(); DEFINE(PAGE_SZ, PAGE_SIZE); BLANK(); - DEFINE(DMA_BIDIRECTIONAL, DMA_BIDIRECTIONAL); - DEFINE(DMA_TO_DEVICE, DMA_TO_DEVICE); - DEFINE(DMA_FROM_DEVICE, DMA_FROM_DEVICE); + DEFINE(__DMA_BIDIRECTIONAL, DMA_BIDIRECTIONAL); + DEFINE(__DMA_TO_DEVICE, DMA_TO_DEVICE); + DEFINE(__DMA_FROM_DEVICE, DMA_FROM_DEVICE); BLANK(); DEFINE(CLOCK_REALTIME, CLOCK_REALTIME); DEFINE(CLOCK_MONOTONIC, CLOCK_MONOTONIC); diff --git a/arch/arm64/mm/cache.S b/arch/arm64/mm/cache.S index 7f1dbe962cf5..c1336be085eb 100644 --- a/arch/arm64/mm/cache.S +++ b/arch/arm64/mm/cache.S @@ -205,7 +205,7 @@ ENDPIPROC(__dma_flush_area) * - dir - DMA direction */ ENTRY(__dma_map_area) - cmp w2, #DMA_FROM_DEVICE + cmp w2, #__DMA_FROM_DEVICE b.eq __dma_inv_area b __dma_clean_area ENDPIPROC(__dma_map_area) @@ -217,7 +217,7 @@ ENDPIPROC(__dma_map_area) * - dir - DMA direction */ ENTRY(__dma_unmap_area) - cmp w2, #DMA_TO_DEVICE + cmp w2, #__DMA_TO_DEVICE b.ne __dma_inv_area ret ENDPIPROC(__dma_unmap_area)
asm-offsets.h contains a few DMA related definitions that have the exact same name than the enum members they are derived from. While this is not a problem so far, it will become an issue if both asm-offsets.h and include/linux/dma-direction.h: are pulled by the same file. Let's sidestep the issue by renaming the asm-offsets.h constants. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> --- arch/arm64/kernel/asm-offsets.c | 6 +++--- arch/arm64/mm/cache.S | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-)