omap: Fix DEBUG_LL uart to access phys addr when MMU isn't enable
Subsystems (4)
PATCH 1/1 omap: Fix DEBUG_LL uart to access phys addr when MMU isn't enable
Now we use a memory address to store the debug port info, So we need to read/write this address when we choose DEBUG_LL. When MMU isn't enable(I.E. the begining part of init stage of the linux kernel boot), we need to access physical address instead of virtual address, otherwise the kernel will crash.
--- arch/arm/mach-omap1/include/mach/debug-macro.S | 10 +++++-- arch/arm/mach-omap2/include/mach/debug-macro.S | 29 +++++++++++++++++------ 2 files changed, 28 insertions(+), 11 deletions(-)
arch/arm/mach-omap1/include/mach/debug-macro.S +7 -3
@@ -33,7 +33,7 @@ omap_uart_virt: .word 0x0 /* Use omap_uart_phys/virt if already configured */ 9: mrc p15, 0, \rx, c1, c0 tst \rx, #1 @ MMU enabled? - ldreq \rx, =omap_uart_phys @ physical base address + ldreq \rx, =__virt_to_phys(omap_uart_phys) @ physical base address ldrne \rx, =omap_uart_virt @ virtual base ldr \rx, [\rx, #0] cmp \rx, #0 @ is port configured?
@@ -68,11 +68,15 @@ omap_uart_virt: .word 0x0 /* Store both phys and virt address for the uart */ 98: add \rx, \rx, #0xff000000 @ phys base - ldr \tmp, =omap_uart_phys + mrc p15, 0, \tmp, c1, c0 + tst \tmp, #1 @ MMU enabled? + ldreq \tmp, =__virt_to_phys(omap_uart_phys) + ldrne \tmp, =omap_uart_phys str \rx, [\tmp, #0] sub \rx, \rx, #0xff000000 @ phys base add \rx, \rx, #0xfe000000 @ virt base - ldr \tmp, =omap_uart_virt + ldreq \tmp, =__virt_to_phys(omap_uart_virt) + ldrne \tmp, =omap_uart_virt str \rx, [\tmp, #0] b 9b 99:
arch/arm/mach-omap2/include/mach/debug-macro.S +21 -8
@@ -36,7 +36,7 @@ omap_uart_lsr: .word 0 /* Use omap_uart_phys/virt if already configured */ 10: mrc p15, 0, \rx, c1, c0 tst \rx, #1 @ MMU enabled? - ldreq \rx, =omap_uart_phys @ physical base address + ldreq \rx, =__virt_to_phys(omap_uart_phys) @ physical base address ldrne \rx, =omap_uart_virt @ virtual base address ldr \rx, [\rx, #0] cmp \rx, #0 @ is port configured?
@@ -89,26 +89,36 @@ omap_uart_lsr: .word 0 44: mov \rx, #UART_OFFSET(OMAP4_UART4_BASE) b 98f 95: ldr \rx, =ZOOM_UART_BASE - ldr \tmp, =omap_uart_phys + mrc p15, 0, \tmp, c1, c0 + tst \tmp, #1 @ MMU enabled? + ldreq \tmp, =__virt_to_phys(omap_uart_phys) + ldrne \tmp, =omap_uart_phys str \rx, [\tmp, #0] ldr \rx, =ZOOM_UART_VIRT - ldr \tmp, =omap_uart_virt + ldreq \tmp, =__virt_to_phys(omap_uart_virt) + ldrne \tmp, =omap_uart_virt str \rx, [\tmp, #0] mov \rx, #(UART_LSR << ZOOM_PORT_SHIFT) - ldr \tmp, =omap_uart_lsr + ldreq \tmp, =__virt_to_phys(omap_uart_lsr) + ldrne \tmp, =omap_uart_lsr str \rx, [\tmp, #0] b 10b /* Store both phys and virt address for the uart */ 98: add \rx, \rx, #0x48000000 @ phys base - ldr \tmp, =omap_uart_phys + mrc p15, 0, \tmp, c1, c0 + tst \tmp, #1 @ MMU enabled? + ldreq \tmp, =__virt_to_phys(omap_uart_phys) + ldrne \tmp, =omap_uart_phys str \rx, [\tmp, #0] sub \rx, \rx, #0x48000000 @ phys base add \rx, \rx, #0xfa000000 @ virt base - ldr \tmp, =omap_uart_virt + ldreq \tmp, =__virt_to_phys(omap_uart_virt) + ldrne \tmp, =omap_uart_virt str \rx, [\tmp, #0] mov \rx, #(UART_LSR << OMAP_PORT_SHIFT) - ldr \tmp, =omap_uart_lsr + ldreq \tmp, =__virt_to_phys(omap_uart_lsr) + ldrne \tmp, =omap_uart_lsr str \rx, [\tmp, #0] b 10b
@@ -120,7 +130,10 @@ omap_uart_lsr: .word 0 .endm .macro busyuart,rd,rx -1001: ldr \rd, =omap_uart_lsr +1001: mrc p15, 0, \rd, c1, c0 + tst \rd, #1 @ MMU enabled? + ldreq \rd, =__virt_to_phys(omap_uart_lsr) + ldrne \rd, =omap_uart_lsr ldr \rd, [\rd, #0] ldrb \rd, [\rx, \rd] and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
Signature · 1 line
1.5.6.5
PATCH 1/1 omap: Fix DEBUG_LL uart to access phys addr when MMU isn't enable
Quoted 17 lines · Jason Wang
Now we use a memory address to store the debug port info, So we need to read/write this address when we choose
DEBUG_LL. When MMU isn't enable(I.E. the begining part of init stage of the linux kernel boot), we need to access physical address instead of virtual address, otherwise the kernel will crash.Signed-off-by Jason Wang <[email protected]>---
?arch/arm/mach-omap1/include/mach/debug-macro.S | ? 10 +++++-- ?arch/arm/mach-omap2/include/mach/debug-macro.S | ? 29 +++++++++++++++++------ ?2 files changed, 28 insertions(+), 11 deletions(-)arch/arm/mach-omap1/include/mach/debug-macro.S +0
-0@@ -33,7 +33,7 @@ omap_uart_virt: ? ? ? .word ? 0x0
Quoted 5 lines
? ? ? ? ? ? ? ?/* Use omap_uart_phys/virt if already configured */
?9: ? ? ? ? ? ? mrc ? ? p15, 0, \rx, c1, c0
? ? ? ? ? ? ? ?tst ? ? \rx, #1 ? ? ? ? ? ? ? ? @ MMU enabled?
- ? ? ? ? ? ? ? ldreq ? \rx, =omap_uart_phys ? ?@ physical base address
+ ? ? ? ? ? ? ? ldreq ? \rx, =__virt_to_phys(omap_uart_phys) ? ?@ physical base address
Along with introduction of run-time phys_offset, I'm afraid this macro won't work in assembly any longer.
And having a variable version of debugging uart base, in my POV, may not be generic enough to handle the fundamental issue. Tho I'm not sure if it will feasible to have a generic debug function in 'struct machine_desc' and make that structure available as early as possible.
Quoted 98 lines
? ? ? ? ? ? ? ?ldrne ? \rx, =omap_uart_virt ? ?@ virtual base ? ? ? ? ? ? ? ?ldr ? ? \rx, [\rx, #0]
? ? ? ? ? ? ? ?cmp ? ? \rx, #0 ? ? ? ? ? ? ? ? @ is port configured?arch/arm/mach-omap1/include/mach/debug-macro.S +0
-0@@ -68,11 +68,15 @@ omap_uart_virt: ? ? .word ? 0x0? ? ? ? ? ? ? ?/* Store both phys and virt address for the uart */ ?98: ? ? ? ? ? ?add ? ? \rx, \rx, #0xff000000 ? @ phys base
- ? ? ? ? ? ? ? ldr ? ? \tmp, =omap_uart_phys
+ ? ? ? ? ? ? ? mrc ? ? p15, 0, \tmp, c1, c0
+ ? ? ? ? ? ? ? tst ? ? \tmp, #1 ? ? ? ? ? ? ? ?@ MMU enabled?
+ ? ? ? ? ? ? ? ldreq ? \tmp, =__virt_to_phys(omap_uart_phys)
+ ? ? ? ? ? ? ? ldrne ? \tmp, =omap_uart_phys
? ? ? ? ? ? ? ?str ? ? \rx, [\tmp, #0]
? ? ? ? ? ? ? ?sub ? ? \rx, \rx, #0xff000000 ? @ phys base ? ? ? ? ? ? ? ?add ? ? \rx, \rx, #0xfe000000 ? @ virt base
- ? ? ? ? ? ? ? ldr ? ? \tmp, =omap_uart_virt
+ ? ? ? ? ? ? ? ldreq ? \tmp, =__virt_to_phys(omap_uart_virt)
+ ? ? ? ? ? ? ? ldrne ? \tmp, =omap_uart_virt
? ? ? ? ? ? ? ?str ? ? \rx, [\tmp, #0]
? ? ? ? ? ? ? ?b ? ? ? 9b
?99:arch/arm/mach-omap2/include/mach/debug-macro.S +0
-0@@ -36,7 +36,7 @@ omap_uart_lsr: ? ? ? ?.word ? 0? ? ? ? ? ? ? ?/* Use omap_uart_phys/virt if already configured */
?10: ? ? ? ? ? ?mrc ? ? p15, 0, \rx, c1, c0
? ? ? ? ? ? ? ?tst ? ? \rx, #1 ? ? ? ? ? ? ? ? @ MMU enabled?
- ? ? ? ? ? ? ? ldreq ? \rx, =omap_uart_phys ? ?@ physical base address
+ ? ? ? ? ? ? ? ldreq ? \rx, =__virt_to_phys(omap_uart_phys) ? ?@ physical base address ? ? ? ? ? ? ? ?ldrne ? \rx, =omap_uart_virt ? ?@ virtual base address
? ? ? ? ? ? ? ?ldr ? ? \rx, [\rx, #0]
? ? ? ? ? ? ? ?cmp ? ? \rx, #0 ? ? ? ? ? ? ? ? @ is port configured?arch/arm/mach-omap2/include/mach/debug-macro.S +0
-0@@ -89,26 +89,36 @@ omap_uart_lsr: ? ? ?.word ? 0 ?44: ? ? ? ? ? ?mov ? ? \rx, #UART_OFFSET(OMAP4_UART4_BASE)? ? ? ? ? ? ? ?b ? ? ? 98f
?95: ? ? ? ? ? ?ldr ? ? \rx, =ZOOM_UART_BASE
- ? ? ? ? ? ? ? ldr ? ? \tmp, =omap_uart_phys
+ ? ? ? ? ? ? ? mrc ? ? p15, 0, \tmp, c1, c0
+ ? ? ? ? ? ? ? tst ? ? \tmp, #1 ? ? ? ? ? ? ? ?@ MMU enabled?
+ ? ? ? ? ? ? ? ldreq ? \tmp, =__virt_to_phys(omap_uart_phys)
+ ? ? ? ? ? ? ? ldrne ? \tmp, =omap_uart_phys
? ? ? ? ? ? ? ?str ? ? \rx, [\tmp, #0]
? ? ? ? ? ? ? ?ldr ? ? \rx, =ZOOM_UART_VIRT
- ? ? ? ? ? ? ? ldr ? ? \tmp, =omap_uart_virt
+ ? ? ? ? ? ? ? ldreq ? \tmp, =__virt_to_phys(omap_uart_virt)
+ ? ? ? ? ? ? ? ldrne ? \tmp, =omap_uart_virt
? ? ? ? ? ? ? ?str ? ? \rx, [\tmp, #0]
? ? ? ? ? ? ? ?mov ? ? \rx, #(UART_LSR <<ZOOM_PORT_SHIFT)
- ? ? ? ? ? ? ? ldr ? ? \tmp, =omap_uart_lsr
+ ? ? ? ? ? ? ? ldreq ? \tmp, =__virt_to_phys(omap_uart_lsr)
+ ? ? ? ? ? ? ? ldrne ? \tmp, =omap_uart_lsr
? ? ? ? ? ? ? ?str ? ? \rx, [\tmp, #0]
? ? ? ? ? ? ? ?b ? ? ? 10b? ? ? ? ? ? ? ?/* Store both phys and virt address for the uart */ ?98: ? ? ? ? ? ?add ? ? \rx, \rx, #0x48000000 ? @ phys base
- ? ? ? ? ? ? ? ldr ? ? \tmp, =omap_uart_phys
+ ? ? ? ? ? ? ? mrc ? ? p15, 0, \tmp, c1, c0
+ ? ? ? ? ? ? ? tst ? ? \tmp, #1 ? ? ? ? ? ? ? ?@ MMU enabled?
+ ? ? ? ? ? ? ? ldreq ? \tmp, =__virt_to_phys(omap_uart_phys)
+ ? ? ? ? ? ? ? ldrne ? \tmp, =omap_uart_phys
? ? ? ? ? ? ? ?str ? ? \rx, [\tmp, #0]
? ? ? ? ? ? ? ?sub ? ? \rx, \rx, #0x48000000 ? @ phys base ? ? ? ? ? ? ? ?add ? ? \rx, \rx, #0xfa000000 ? @ virt base
- ? ? ? ? ? ? ? ldr ? ? \tmp, =omap_uart_virt
+ ? ? ? ? ? ? ? ldreq ? \tmp, =__virt_to_phys(omap_uart_virt)
+ ? ? ? ? ? ? ? ldrne ? \tmp, =omap_uart_virt
? ? ? ? ? ? ? ?str ? ? \rx, [\tmp, #0]
? ? ? ? ? ? ? ?mov ? ? \rx, #(UART_LSR <<OMAP_PORT_SHIFT)
- ? ? ? ? ? ? ? ldr ? ? \tmp, =omap_uart_lsr
+ ? ? ? ? ? ? ? ldreq ? \tmp, =__virt_to_phys(omap_uart_lsr)
+ ? ? ? ? ? ? ? ldrne ? \tmp, =omap_uart_lsr
? ? ? ? ? ? ? ?str ? ? \rx, [\tmp, #0]? ? ? ? ? ? ? ?b ? ? ? 10b
arch/arm/mach-omap2/include/mach/debug-macro.S +0
-0@@ -120,7 +130,10 @@ omap_uart_lsr: ? ? .word ? 0? ? ? ? ? ? ? ?.endm
? ? ? ? ? ? ? ?.macro ?busyuart,rd,rx
-1001: ? ? ? ? ?ldr ? ? \rd, =omap_uart_lsr
+1001: ? ? ? ? ?mrc ? ? p15, 0, \rd, c1, c0
+ ? ? ? ? ? ? ? tst ? ? \rd, #1 ? ? ? ? @ MMU enabled?
+ ? ? ? ? ? ? ? ldreq ? \rd, =__virt_to_phys(omap_uart_lsr)
+ ? ? ? ? ? ? ? ldrne ? \rd, =omap_uart_lsr
? ? ? ? ? ? ? ?ldr ? ? \rd, [\rd, #0]
? ? ? ? ? ? ? ?ldrb ? ?\rd, [\rx, \rd]
? ? ? ? ? ? ? ?and ? ? \rd, \rd, #(UART_LSR_TEMT |UART_LSR_THRE) --
1.5.6.5_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Tony Lindgren
maintainerPATCH 1/1 omap: Fix DEBUG_LL uart to access phys addr when MMU isn't enable
Quoted 13 lines · Eric Miao
Quoted 12 lines · Jason Wang
Now we use a memory address to store the debug port info, So we need to read/write this address when we choose
DEBUG_LL. When MMU isn't enable(I.E. the begining part of init stage of the linux kernel boot), we need to access physical address instead of virtual address, otherwise the kernel will crash.Signed-off-by Jason Wang <[email protected]>---
?arch/arm/mach-omap1/include/mach/debug-macro.S | ? 10 +++++-- ?arch/arm/mach-omap2/include/mach/debug-macro.S | ? 29 +++++++++++++++++------ ?2 files changed, 28 insertions(+), 11 deletions(-)
Quoted 13 lines
Quoted 10 lines
arch/arm/mach-omap1/include/mach/debug-macro.S +0
-0@@ -33,7 +33,7 @@ omap_uart_virt: ? ? ? .word ? 0x0? ? ? ? ? ? ? ?/* Use omap_uart_phys/virt if already configured */
?9: ? ? ? ? ? ? mrc ? ? p15, 0, \rx, c1, c0
? ? ? ? ? ? ? ?tst ? ? \rx, #1 ? ? ? ? ? ? ? ? @ MMU enabled?
- ? ? ? ? ? ? ? ldreq ? \rx, =omap_uart_phys ? ?@ physical base address
+ ? ? ? ? ? ? ? ldreq ? \rx, =__virt_to_phys(omap_uart_phys) ? ?@ physical base addressAlong with introduction of run-time
phys_offset, I'm afraid this macro won't work in assembly any longer.
/me scratches head wondering how this has been working so far on the systems tested.. Looks like we've been lucky and the omap_uart_virt and phys have been initialized twice to different memory addresses, first with MMU off then on.
For the run-time phys_offset, can we use the same logic here and set it based on the PC?
Quoted 5 lines
And having a variable version of debugging uart base, in my POV, may not be generic enough to handle the fundamental issue. Tho I'm not sure if it will feasible to have a generic debug function in 'struct
machine_desc' and make that structure available as early as possible.
That might cover the most typical debug cases, but is not available right from the start.
What if we initialize the low level debug functions in some static memory location already in uncompress.h? That would help sorting out the debug-macro.S issue from compiling in multile ARM archs point of view.
Regards,
Tony
PATCH 1/1 omap: Fix DEBUG_LL uart to access phys addr when MMU isn't enable
Quoted 28 lines · Tony Lindgren
Quoted 13 lines · Eric Miao
Quoted 12 lines · Jason Wang
Now we use a memory address to store the debug port info, So we need to read/write this address when we choose
DEBUG_LL. When MMU isn't enable(I.E. the begining part of init stage of the linux kernel boot), we need to access physical address instead of virtual address, otherwise the kernel will crash.Signed-off-by Jason Wang <[email protected]>---
?arch/arm/mach-omap1/include/mach/debug-macro.S | ? 10 +++++-- ?arch/arm/mach-omap2/include/mach/debug-macro.S | ? 29 +++++++++++++++++------ ?2 files changed, 28 insertions(+), 11 deletions(-)Quoted 13 lines
Quoted 10 lines
arch/arm/mach-omap1/include/mach/debug-macro.S +0
-0@@ -33,7 +33,7 @@ omap_uart_virt: ? ? ? .word ? 0x0? ? ? ? ? ? ? ?/* Use omap_uart_phys/virt if already configured */
?9: ? ? ? ? ? ? mrc ? ? p15, 0, \rx, c1, c0
? ? ? ? ? ? ? ?tst ? ? \rx, #1 ? ? ? ? ? ? ? ? @ MMU enabled?
- ? ? ? ? ? ? ? ldreq ? \rx, =omap_uart_phys ? ?@ physical base address
+ ? ? ? ? ? ? ? ldreq ? \rx, =__virt_to_phys(omap_uart_phys) ? ?@ physical base addressAlong with introduction of run-time
phys_offset, I'm afraid this macro won't work in assembly any longer.
Quoted 5 lines
/me scratches head wondering how this has been working so far on the systems tested.. Looks like we've been lucky and the
omap_uart_virtand phys have been initialized twice to different memory addresses, first with MMU off then on.
Yeah, you lucky guys. Or possibly because it's not even used when MMU is off in the early stage?
Quoted 3 lines
For the run-time
phys_offset, can we use the same logic here and set it based on the PC?
That's exactly what the run-time phys_offset is calculated.
Quoted 6 lines
Quoted 5 lines
And having a variable version of debugging uart base, in my POV, may not be generic enough to handle the fundamental issue. Tho I'm not sure if it will feasible to have a generic debug function in 'struct
machine_desc' and make that structure available as early as possible.
Quoted 8 lines
That might cover the most typical debug cases, but is not available right from the start.
What if we initialize the low level debug functions in some static memory location already in
uncompress.h? That would help sorting out thedebug-macro.Sissue from compiling in multile ARM archs point of view.
We also need to take care of Jeremy's recent patchset to remove .io_pg_offst and .phys_io, which modifies all the addruart macros.
Considering:
1) the debug UART might not be 8250 compatible (mostly are, but some like ICEDCC)
2) and the settings are different between boards (different register space, etc)
So it is actually board specific code, which could be encoded into 'struct machine_desc', yet not sure how to be generic enough.
PATCH 1/1 omap: Fix DEBUG_LL uart to access phys addr when MMU isn't enable
Quoted 2 lines · Eric Miao
We also need to take care of Jeremy's recent patchset to remove .io_pg_offst and .phys_io, which modifies all the addruart macros.
I don't think Jeremy's patches will be going in for this merge window as we can't intentionally break OMAP's support because we don't understand OMAP. I think Jeremy's patches will have to wait for the next merge window now.
Tony Lindgren
maintainerPATCH 1/1 omap: Fix DEBUG_LL uart to access phys addr when MMU isn't enable
Quoted 8 lines · Russell King - ARM Linux
Quoted 2 lines · Eric Miao
We also need to take care of Jeremy's recent patchset to remove .io_pg_offst and .phys_io, which modifies all the addruart macros.
I don't think Jeremy's patches will be going in for this merge window as we can't intentionally break OMAP's support because we don't understand OMAP. I think Jeremy's patches will have to wait for the next merge window now.
Well now we understand there's a bug.. Here's what's needed to make Jason's fix to work on Jeremy's mdesc series.
This is still not looking at SP for the memory address, but at least this would allow us to merge some of Jeremy's patches.
Regards,
Tony
-------------- next part --------------
A non-text attachment was scrubbed...
Name: omap-debug-ll-nommu.patch
Type: text/x-diff
Size: 5777 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20100803/ba458309/attachment.bin>
PATCH 1/1 omap: Fix DEBUG_LL uart to access phys addr when MMU isn't enable
Quoted 5 lines · Tony Lindgren
Quoted 4 lines · Russell King - ARM Linux
Quoted 2 lines · Eric Miao
We also need to take care of Jeremy's recent patchset to remove .io_pg_offst and .phys_io, which modifies all the addruart macros.
Quoted 7 lines
Quoted 4 lines
I don't think Jeremy's patches will be going in for this merge window as we can't intentionally break OMAP's support because we don't understand OMAP. I think Jeremy's patches will have to wait for the next merge window now.
Well now we understand there's a bug.. Here's what's needed to make Jason's fix to work on Jeremy's mdesc series.
That's not quite the point - Jeremy's patches with working OMAP support haven't been tested in linux-next, and so hasn't had visibility to the wider community, and so it shouldn't be going into the current merge window.
Tony Lindgren
maintainerPATCH 1/1 omap: Fix DEBUG_LL uart to access phys addr when MMU isn't enable
Quoted 11 lines · Russell King - ARM Linux
Quoted 10 lines · Tony Lindgren
Quoted 8 lines · Russell King - ARM Linux
Quoted 2 lines · Eric Miao
We also need to take care of Jeremy's recent patchset to remove .io_pg_offst and .phys_io, which modifies all the addruart macros.
I don't think Jeremy's patches will be going in for this merge window as we can't intentionally break OMAP's support because we don't understand OMAP. I think Jeremy's patches will have to wait for the next merge window now.
Quoted 7 lines
Quoted 2 lines
Well now we understand there's a bug.. Here's what's needed to make Jason's fix to work on Jeremy's mdesc series.
That's not quite the point - Jeremy's patches with working OMAP support haven't been tested in linux-next, and so hasn't had visibility to the wider community, and so it shouldn't be going into the current merge window.
OK. It's best to test them properly. I'll add Jason's original fix into omap-for-linus then for this merge window.
Tony