linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] ARM: tegra: fix DEBUG_LL combined with LPAE
@ 2013-11-25 22:36 Stephen Warren
  2013-11-25 22:36 ` [PATCH 2/3] ARM: tegra: don't hard-code DEBUG_LL baud rate Stephen Warren
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Stephen Warren @ 2013-11-25 22:36 UTC (permalink / raw)
  To: linux-arm-kernel

From: Stephen Warren <swarren@nvidia.com>

The DEBUG_LL UART address is mapped as an MMU section, hence, the
virtual address must be section-aligned. Sections are 1MB without LPAE
and 2MB with LPAE. Tegra's virtual address was only aligned to 1MB, and
hence the mapping was set up incorrectly with LPAE enabled, thus causing
a hang early during boot. Fix this by picking a different virtual address
that is aligned to 2MB.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 arch/arm/include/debug/tegra.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/include/debug/tegra.S b/arch/arm/include/debug/tegra.S
index be6a720dd183..a7b7cedef1a6 100644
--- a/arch/arm/include/debug/tegra.S
+++ b/arch/arm/include/debug/tegra.S
@@ -46,10 +46,10 @@
 #define TEGRA_APB_MISC_GP_HIDREV	(TEGRA_APB_MISC_BASE + 0x804)
 
 /*
- * Must be 1MB-aligned since a 1MB mapping is used early on.
+ * Must be section-aligned since a section mapping is used early on.
  * Must not overlap with regions in mach-tegra/io.c:tegra_io_desc[].
  */
-#define UART_VIRTUAL_BASE		0xfe100000
+#define UART_VIRTUAL_BASE		0xfe800000
 
 #define checkuart(rp, rv, lhu, bit, uart) \
 		/* Load address of CLK_RST register */ \
-- 
1.8.1.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] ARM: tegra: don't hard-code DEBUG_LL baud rate
  2013-11-25 22:36 [PATCH 1/3] ARM: tegra: fix DEBUG_LL combined with LPAE Stephen Warren
@ 2013-11-25 22:36 ` Stephen Warren
  2013-11-26 11:08   ` Thierry Reding
  2013-11-25 22:36 ` [PATCH 3/3] ARM: tegra: use section-sized static mappings for LPAE too Stephen Warren
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Stephen Warren @ 2013-11-25 22:36 UTC (permalink / raw)
  To: linux-arm-kernel

From: Stephen Warren <swarren@nvidia.com>

Stop writing to the UART clock divider registers in the Tegra DEBUG_LL
code. This allows the DEBUG_LL output to use whatever baud rate was set
up by the bootloader. Some users are using higher rates than 115200.

This removes the only usage of tegra_uart_config[3], so reduce the size
allocated for that array.

Finally, fix busyuart() so that it only waits for THRE and not TEMT. For
some reason, TEMT doesn't get asserted (at least on Tegra30 Beaver) at
9600 baud, even though it does at 115200 baud. This sounds like a HW bug,
but I haven't investigated. For reference, U-Boot's serial code has
always only checked THRE, and not checked TEMT.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Tested-by: Paul Walmsley <pwalmsley@nvidia.com>
---
 arch/arm/include/debug/tegra.S | 30 +++---------------------------
 arch/arm/mach-tegra/tegra.c    |  4 +---
 2 files changed, 4 insertions(+), 30 deletions(-)

diff --git a/arch/arm/include/debug/tegra.S b/arch/arm/include/debug/tegra.S
index a7b7cedef1a6..f98763f0bc17 100644
--- a/arch/arm/include/debug/tegra.S
+++ b/arch/arm/include/debug/tegra.S
@@ -156,28 +156,6 @@
 92:		and	\rv, \rp, #0xffffff	@ offset within 1MB section
 		add	\rv, \rv, #UART_VIRTUAL_BASE
 		str	\rv, [\tmp, #8]		@ Store in tegra_uart_virt
-		movw	\rv, #TEGRA_APB_MISC_GP_HIDREV & 0xffff
-		movt	\rv, #TEGRA_APB_MISC_GP_HIDREV >> 16
-		ldr	\rv, [\rv, #0]		@ Load HIDREV
-		ubfx	\rv, \rv, #8, #8	@ 15:8 are SoC version
-		cmp	\rv, #0x20		@ Tegra20?
-		moveq	\rv, #0x75		@ Tegra20 divisor
-		movne	\rv, #0xdd		@ Tegra30 divisor
-		str	\rv, [\tmp, #12]	@ Save divisor to scratch
-		/* uart[UART_LCR] = UART_LCR_WLEN8 | UART_LCR_DLAB; */
-		mov	\rv, #UART_LCR_WLEN8 | UART_LCR_DLAB
-		str	\rv, [\rp, #UART_LCR << UART_SHIFT]
-		/* uart[UART_DLL] = div & 0xff; */
-		ldr	\rv, [\tmp, #12]
-		and	\rv, \rv, #0xff
-		str	\rv, [\rp, #UART_DLL << UART_SHIFT]
-		/* uart[UART_DLM] = div >> 8; */
-		ldr	\rv, [\tmp, #12]
-		lsr	\rv, \rv, #8
-		str	\rv, [\rp, #UART_DLM << UART_SHIFT]
-		/* uart[UART_LCR] = UART_LCR_WLEN8; */
-		mov	\rv, #UART_LCR_WLEN8
-		str	\rv, [\rp, #UART_LCR << UART_SHIFT]
 		b	100f
 
 		.align
@@ -205,8 +183,8 @@
 		cmp	\rx, #0
 		beq	1002f
 1001:		ldrb	\rd, [\rx, #UART_LSR << UART_SHIFT]
-		and	\rd, \rd, #UART_LSR_TEMT | UART_LSR_THRE
-		teq	\rd, #UART_LSR_TEMT | UART_LSR_THRE
+		and	\rd, \rd, #UART_LSR_THRE
+		teq	\rd, #UART_LSR_THRE
 		bne	1001b
 1002:
 		.endm
@@ -225,7 +203,7 @@
 /*
  * Storage for the state maintained by the macros above.
  *
- * In the kernel proper, this data is located in arch/arm/mach-tegra/common.c.
+ * In the kernel proper, this data is located in arch/arm/mach-tegra/tegra.c.
  * That's because this header is included from multiple files, and we only
  * want a single copy of the data. In particular, the UART probing code above
  * assumes it's running using physical addresses. This is true when this file
@@ -247,6 +225,4 @@ tegra_uart_config:
 	.word 0
 	/* Debug UART virtual address */
 	.word 0
-	/* Scratch space for debug macro */
-	.word 0
 #endif
diff --git a/arch/arm/mach-tegra/tegra.c b/arch/arm/mach-tegra/tegra.c
index 73368176c6e8..ea14d380fc0c 100644
--- a/arch/arm/mach-tegra/tegra.c
+++ b/arch/arm/mach-tegra/tegra.c
@@ -60,15 +60,13 @@
  * kernel is loaded. The data is declared here rather than debug-macro.S so
  * that multiple inclusions of debug-macro.S point@the same data.
  */
-u32 tegra_uart_config[4] = {
+u32 tegra_uart_config[3] = {
 	/* Debug UART initialization required */
 	1,
 	/* Debug UART physical address */
 	0,
 	/* Debug UART virtual address */
 	0,
-	/* Scratch space for debug macro */
-	0,
 };
 
 static void __init tegra_init_cache(void)
-- 
1.8.1.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] ARM: tegra: use section-sized static mappings for LPAE too
  2013-11-25 22:36 [PATCH 1/3] ARM: tegra: fix DEBUG_LL combined with LPAE Stephen Warren
  2013-11-25 22:36 ` [PATCH 2/3] ARM: tegra: don't hard-code DEBUG_LL baud rate Stephen Warren
@ 2013-11-25 22:36 ` Stephen Warren
  2013-11-26 11:13   ` Thierry Reding
  2013-11-26 10:21 ` [PATCH 1/3] ARM: tegra: fix DEBUG_LL combined with LPAE Thierry Reding
  2013-12-04 19:37 ` Stephen Warren
  3 siblings, 1 reply; 7+ messages in thread
From: Stephen Warren @ 2013-11-25 22:36 UTC (permalink / raw)
  To: linux-arm-kernel

From: Stephen Warren <swarren@nvidia.com>

The static mappings for Tegra's PPSB and APB regions were sized at 1MB
in order to allow mapping via sections in order to avoid burning RAM for
PTEs. On LPAE, sections are 2MB, so the static mappings need to be
larger in order to gain the same benefit. Set IO_{PPSB,APB}_SIZE to
SECTION_SIZE so this adjusts automatically.

While we're fiddling with iomap.h, compress IO_{IRAM,CPU}_VIRT together
to save virtual address space in the vmalloc region; these two regions
are mapped using PTEs.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 arch/arm/mach-tegra/iomap.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-tegra/iomap.h b/arch/arm/mach-tegra/iomap.h
index 26b1c2ad0ceb..ee79808e93a3 100644
--- a/arch/arm/mach-tegra/iomap.h
+++ b/arch/arm/mach-tegra/iomap.h
@@ -19,6 +19,7 @@
 #ifndef __MACH_TEGRA_IOMAP_H
 #define __MACH_TEGRA_IOMAP_H
 
+#include <asm/pgtable.h>
 #include <asm/sizes.h>
 
 #define TEGRA_IRAM_BASE			0x40000000
@@ -115,27 +116,26 @@
  * two 256MB io windows (that actually only use about 64KB
  * at the start of each).
  *
- * We will just map the first 1MB of each window (to minimize
+ * We will just map the first MMU section of each window (to minimize
  * pt entries needed) and provide a macro to transform physical
  * io addresses to an appropriate void __iomem *.
- *
  */
 
 #define IO_IRAM_PHYS	0x40000000
 #define IO_IRAM_VIRT	IOMEM(0xFE400000)
 #define IO_IRAM_SIZE	SZ_256K
 
-#define IO_CPU_PHYS     0x50040000
-#define IO_CPU_VIRT     IOMEM(0xFE000000)
+#define IO_CPU_PHYS	0x50040000
+#define IO_CPU_VIRT	IOMEM(0xFE440000)
 #define IO_CPU_SIZE	SZ_16K
 
 #define IO_PPSB_PHYS	0x60000000
 #define IO_PPSB_VIRT	IOMEM(0xFE200000)
-#define IO_PPSB_SIZE	SZ_1M
+#define IO_PPSB_SIZE	SECTION_SIZE
 
 #define IO_APB_PHYS	0x70000000
-#define IO_APB_VIRT	IOMEM(0xFE300000)
-#define IO_APB_SIZE	SZ_1M
+#define IO_APB_VIRT	IOMEM(0xFE000000)
+#define IO_APB_SIZE	SECTION_SIZE
 
 #define IO_TO_VIRT_BETWEEN(p, st, sz)	((p) >= (st) && (p) < ((st) + (sz)))
 #define IO_TO_VIRT_XLATE(p, pst, vst)	(((p) - (pst) + (vst)))
-- 
1.8.1.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 1/3] ARM: tegra: fix DEBUG_LL combined with LPAE
  2013-11-25 22:36 [PATCH 1/3] ARM: tegra: fix DEBUG_LL combined with LPAE Stephen Warren
  2013-11-25 22:36 ` [PATCH 2/3] ARM: tegra: don't hard-code DEBUG_LL baud rate Stephen Warren
  2013-11-25 22:36 ` [PATCH 3/3] ARM: tegra: use section-sized static mappings for LPAE too Stephen Warren
@ 2013-11-26 10:21 ` Thierry Reding
  2013-12-04 19:37 ` Stephen Warren
  3 siblings, 0 replies; 7+ messages in thread
From: Thierry Reding @ 2013-11-26 10:21 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Nov 25, 2013 at 03:36:41PM -0700, Stephen Warren wrote:
> From: Stephen Warren <swarren@nvidia.com>
> 
> The DEBUG_LL UART address is mapped as an MMU section, hence, the
> virtual address must be section-aligned. Sections are 1MB without LPAE
> and 2MB with LPAE. Tegra's virtual address was only aligned to 1MB, and
> hence the mapping was set up incorrectly with LPAE enabled, thus causing
> a hang early during boot. Fix this by picking a different virtual address
> that is aligned to 2MB.
> 
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> ---
>  arch/arm/include/debug/tegra.S | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Thierry Reding <treding@nvidia.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131126/fb608f99/attachment-0001.sig>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/3] ARM: tegra: don't hard-code DEBUG_LL baud rate
  2013-11-25 22:36 ` [PATCH 2/3] ARM: tegra: don't hard-code DEBUG_LL baud rate Stephen Warren
@ 2013-11-26 11:08   ` Thierry Reding
  0 siblings, 0 replies; 7+ messages in thread
From: Thierry Reding @ 2013-11-26 11:08 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Nov 25, 2013 at 03:36:42PM -0700, Stephen Warren wrote:
> From: Stephen Warren <swarren@nvidia.com>
> 
> Stop writing to the UART clock divider registers in the Tegra DEBUG_LL
> code. This allows the DEBUG_LL output to use whatever baud rate was set
> up by the bootloader. Some users are using higher rates than 115200.
> 
> This removes the only usage of tegra_uart_config[3], so reduce the size
> allocated for that array.
> 
> Finally, fix busyuart() so that it only waits for THRE and not TEMT. For
> some reason, TEMT doesn't get asserted (at least on Tegra30 Beaver) at
> 9600 baud, even though it does at 115200 baud. This sounds like a HW bug,
> but I haven't investigated. For reference, U-Boot's serial code has
> always only checked THRE, and not checked TEMT.
> 
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> Tested-by: Paul Walmsley <pwalmsley@nvidia.com>
> ---
>  arch/arm/include/debug/tegra.S | 30 +++---------------------------
>  arch/arm/mach-tegra/tegra.c    |  4 +---
>  2 files changed, 4 insertions(+), 30 deletions(-)

Reviewed-by: Thierry Reding <treding@nvidia.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131126/1b7ac321/attachment.sig>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 3/3] ARM: tegra: use section-sized static mappings for LPAE too
  2013-11-25 22:36 ` [PATCH 3/3] ARM: tegra: use section-sized static mappings for LPAE too Stephen Warren
@ 2013-11-26 11:13   ` Thierry Reding
  0 siblings, 0 replies; 7+ messages in thread
From: Thierry Reding @ 2013-11-26 11:13 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Nov 25, 2013 at 03:36:43PM -0700, Stephen Warren wrote:
> From: Stephen Warren <swarren@nvidia.com>
> 
> The static mappings for Tegra's PPSB and APB regions were sized at 1MB
> in order to allow mapping via sections in order to avoid burning RAM for
> PTEs. On LPAE, sections are 2MB, so the static mappings need to be
> larger in order to gain the same benefit. Set IO_{PPSB,APB}_SIZE to
> SECTION_SIZE so this adjusts automatically.
> 
> While we're fiddling with iomap.h, compress IO_{IRAM,CPU}_VIRT together
> to save virtual address space in the vmalloc region; these two regions
> are mapped using PTEs.
> 
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> ---
>  arch/arm/mach-tegra/iomap.h | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)

Reviewed-by: Thierry Reding <treding@nvidia.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131126/85bf1e67/attachment-0001.sig>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] ARM: tegra: fix DEBUG_LL combined with LPAE
  2013-11-25 22:36 [PATCH 1/3] ARM: tegra: fix DEBUG_LL combined with LPAE Stephen Warren
                   ` (2 preceding siblings ...)
  2013-11-26 10:21 ` [PATCH 1/3] ARM: tegra: fix DEBUG_LL combined with LPAE Thierry Reding
@ 2013-12-04 19:37 ` Stephen Warren
  3 siblings, 0 replies; 7+ messages in thread
From: Stephen Warren @ 2013-12-04 19:37 UTC (permalink / raw)
  To: linux-arm-kernel

On 11/25/2013 03:36 PM, Stephen Warren wrote:
> The DEBUG_LL UART address is mapped as an MMU section, hence, the
> virtual address must be section-aligned. Sections are 1MB without LPAE
> and 2MB with LPAE. Tegra's virtual address was only aligned to 1MB, and
> hence the mapping was set up incorrectly with LPAE enabled, thus causing
> a hang early during boot. Fix this by picking a different virtual address
> that is aligned to 2MB.

I've applied this series to Tegra's for-3.14/soc branch.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-12-04 19:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-25 22:36 [PATCH 1/3] ARM: tegra: fix DEBUG_LL combined with LPAE Stephen Warren
2013-11-25 22:36 ` [PATCH 2/3] ARM: tegra: don't hard-code DEBUG_LL baud rate Stephen Warren
2013-11-26 11:08   ` Thierry Reding
2013-11-25 22:36 ` [PATCH 3/3] ARM: tegra: use section-sized static mappings for LPAE too Stephen Warren
2013-11-26 11:13   ` Thierry Reding
2013-11-26 10:21 ` [PATCH 1/3] ARM: tegra: fix DEBUG_LL combined with LPAE Thierry Reding
2013-12-04 19:37 ` Stephen Warren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).