ARM: mvebu: drop pointless check for coherency_base
Subsystems (3)
PATCH 1/1 ARM: mvebu: drop pointless check for coherency_base
The MMU off code path in ll_get_coherency_base() attempts to decide whether the coherency fabric is mapped by testing the value of coherency_base, which carries its virtual address if its mapped, and 0x0 otherwise.
However, what the code actually does is take the virtual address of the coherency_base symbol, and compare it with 0x0, which are never equal, and so the branch is never taken. In fact, with the MMU off, dereferencing the VA of coherency_base is not possible to begin with, nor can its value be relied upon with the MMU off since it is not cleaned to the Dcache as is done with coherency_phys_base in armada_370_coherency_init().
Instead, the value of coherency_phys_base is returned, which results in the correct behavior since it will be 0x0 as well if the coherency fabric is not mapped, and it is accessible with the MMU off. So just drop the comparison and the branch.
---
Found by accident. Build tested only.
arch/arm/mach-mvebu/coherency_ll.S | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
arch/arm/mach-mvebu/coherency_ll.S +1 -6
@@ -35,13 +35,8 @@ ENTRY(ll_get_coherency_base) /* * MMU is disabled, use the physical address of the coherency - * base address. However, if the coherency fabric isn't mapped - * (i.e its virtual address is zero), it means coherency is - * not enabled, so we return 0. + * base address, (or 0x0 if the coherency fabric is not mapped) */ - ldr r1, =coherency_base - cmp r1, #0 - beq 2f adr r1, 3f ldr r3, [r1] ldr r1, [r1, r3]
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Gregory CLEMENT
maintainerHi Ard,
Quoted 13 lines
The MMU off code path in
ll_get_coherency_base()attempts to decide whether the coherency fabric is mapped by testing the value ofcoherency_base, which carries its virtual address if its mapped, and0x0otherwise.However, what the code actually does is take the virtual address of the
coherency_basesymbol, and compare it with0x0, which are never equal, and so the branch is never taken. In fact, with the MMU off, dereferencing the VA ofcoherency_baseis not possible to begin with, nor can its value be relied upon with the MMU off since it is not cleaned to the Dcache as is done withcoherency_phys_baseinarmada_370_coherency_init().
Quoted 4 lines
Instead, the value of
coherency_phys_baseis returned, which results in the correct behavior since it will be0x0as well if the coherency fabric is not mapped, and it is accessible with the MMU off. So just drop the comparison and the branch.
Thanks for this patch. I needed to refresh my memories about this subject and I agree with your explanation. I applied it on mvebu/fixes.
Gregory
Quoted 36 lines
Fixes 30cdef97107370a7 ("ARM: mvebu: make the coherency_ll.S functions work with no coherency fabric")Cc Thomas Petazzoni <[email protected]>Cc Jason Cooper <[email protected]>Cc Andrew Lunn <[email protected]>Cc Gregory CLEMENT <[email protected]>Cc Sebastian Hesselbarth <[email protected]>Signed-off-by Ard Biesheuvel <[email protected]>---
Found by accident. Build tested only.arch/arm/mach-mvebu/coherency_ll.S | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)arch/arm/mach-mvebu/coherency_ll.S +1
-6@@ -35,13 +35,8 @@ ENTRY(ll_get_coherency_base) /* * MMU is disabled, use the physical address of the coherency - * base address. However, if the coherency fabric isn't mapped - * (i.e its virtual address is zero), it means coherency is - * not enabled, so we return 0. + * base address, (or 0x0 if the coherency fabric is not mapped) */ - ldr r1, =coherency_base - cmp r1, #0 - beq 2f adr r1, 3f ldr r3, [r1] ldr r1, [r1, r3]Signature · 1 line
2.17.1
Signature · 8 lines
Gregory Clement, Bootlin Embedded Linux and Kernel engineering http://bootlin.com _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel