Skip to contentSkip to conversation

arm: plat-orion: fix address decoding when > 4GB is used

PATCH New Thomas Petazzoni 4 participants 4 messages Feb 27, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: plat-orion: fix address decoding when > 4GB is used

During the system initialization, the orion_setup_cpu_mbus_target() function reads the SDRAM address decoding registers to find out how many chip-selects of SDRAM have been enabled, and builds a small array with one entry per chip-select. This array is then used by device drivers (XOR, Ethernet, etc.) to configure their own address decoding windows to the SDRAM.

However, devices can only access the first 32 bits of the physical memory. Even though LPAE is not supported for now, some Marvell boards are not showing up with 8 GB of RAM, configured using two SDRAM address decoding windows: the first covering the first 4 GB, the second covering the last 4 GB. The array built by orion_setup_cpu_mbus_target() has therefore two entries, and device drivers try to set up two address decoding windows to the SDRAM. However, in the device registers for the address decoding, the base address is only 32 bits, so those two windows overlap each other, and the devices do not work at all.

This patch makes sure that the array built by orion_setup_cpu_mbus_target() only contains the SDRAM decoding windows that correspond to the first 4 GB of the memory. To do that, it ignores the SDRAM decoding windows for which the 3 low-order bits are not zero (the 3 low-order bits of the base register are used to store bits 32:35 of the base address, so they actually indicate whether the base address is above 4 GB).

This patch allows the newly introduced armada-xp-gp board to properly operate when it is mounted with more than 4 GB of RAM. Without that, all devices doing DMA (for example XOR and Ethernet) do not work at all.

---
This patch should definitely be applied for 3.9. It may also be considered for 3.8, since other boards than the armada-xp-gp can be mounted with more than 4 GB of RAM.

---
 arch/arm/plat-orion/addr-map.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
arch/arm/plat-orion/addr-map.c +5 -2
index febe386..41a8363 100644
@@ -157,9 +157,12 @@ void __init orion_setup_cpu_mbus_target(const struct orion_addr_map_cfg *cfg,
 		u32 size = readl(ddr_window_cpu_base + DDR_SIZE_CS_OFF(i));
 
 		/*
-		 * Chip select enabled?
+		 * We only take care of entries for which the chip
+		 * select is enabled, and that don't have high base
+		 * address bits set (devices can only access the first
+		 * 32 bits of the memory).
 		 */
-		if (size & 1) {
+		if ((size & 1) && !(base & 0x7)) {
 			struct mbus_dram_window *w;
 
 			w = &orion_mbus_dram_info.cs[cs++];
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 arm: plat-orion: fix address decoding when > 4GB is used

Quoted 26 lines · Thomas Petazzoni

During the system initialization, the orion_setup_cpu_mbus_target() function reads the SDRAM address decoding registers to find out how many chip-selects of SDRAM have been enabled, and builds a small array with one entry per chip-select. This array is then used by device drivers (XOR, Ethernet, etc.) to configure their own address decoding windows to the SDRAM.

However, devices can only access the first 32 bits of the physical memory. Even though LPAE is not supported for now, some Marvell boards are not showing up with 8 GB of RAM, configured using two SDRAM address decoding windows: the first covering the first 4 GB, the second covering the last 4 GB. The array built by orion_setup_cpu_mbus_target() has therefore two entries, and device drivers try to set up two address decoding windows to the SDRAM. However, in the device registers for the address decoding, the base address is only 32 bits, so those two windows overlap each other, and the devices do not work at all.

This patch makes sure that the array built by orion_setup_cpu_mbus_target() only contains the SDRAM decoding windows that correspond to the first 4 GB of the memory. To do that, it ignores the SDRAM decoding windows for which the 3 low-order bits are not zero (the 3 low-order bits of the base register are used to store bits 32:35 of the base address, so they actually indicate whether the base address is above 4 GB).

Quoted 4 lines

This patch allows the newly introduced armada-xp-gp board to properly operate when it is mounted with more than 4 GB of RAM. Without that, all devices doing DMA (for example XOR and Ethernet) do not work at all.

It fixes the issue I had with Ethernet since severals weeks, you can definitely add my:

Quoted 30 lines

---
This patch should definitely be applied for 3.9. It may also be considered for 3.8, since other boards than the armada-xp-gp can be mounted with more than 4 GB of RAM.

---
 arch/arm/plat-orion/addr-map.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
arch/arm/plat-orion/addr-map.c +5 -2
index febe386..41a8363 100644
@@ -157,9 +157,12 @@ void __init orion_setup_cpu_mbus_target(const struct orion_addr_map_cfg *cfg,
 		u32 size = readl(ddr_window_cpu_base + DDR_SIZE_CS_OFF(i));
 
 		/*
-		 * Chip select enabled?
+		 * We only take care of entries for which the chip
+		 * select is enabled, and that don't have high base
+		 * address bits set (devices can only access the first
+		 * 32 bits of the memory).
 		 */
-		if (size & 1) {
+		if ((size & 1) && !(base & 0x7)) {
 			struct mbus_dram_window *w;
 
 			w = &orion_mbus_dram_info.cs[cs++];
Signature · 4 lines
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#2 lore raw

PATCH 1/1 arm: plat-orion: fix address decoding when > 4GB is used

Quoted 43 lines

-----Original Message-----
From: Gregory CLEMENT [mailto:gregory.clement at free-electrons.com]
Sent: Wednesday, February 27, 2013 11:57 AM
To: Thomas Petazzoni
Cc: Jason Cooper; Andrew Lunn; Lior Amsalem; Maen Suleiman; linux-arm- kernel at lists.infradead.org
Subject: Re: [PATCH] arm: plat-orion: fix address decoding when > 4GB is used

Quoted 18 lines · Thomas Petazzoni

During the system initialization, the orion_setup_cpu_mbus_target() function reads the SDRAM address decoding registers to find out how many chip-selects of SDRAM have been enabled, and builds a small array with one entry per chip-select. This array is then used by device drivers (XOR, Ethernet, etc.) to configure their own address decoding windows to the SDRAM.

However, devices can only access the first 32 bits of the physical memory. Even though LPAE is not supported for now, some Marvell boards are not showing up with 8 GB of RAM, configured using two SDRAM address decoding windows: the first covering the first 4 GB, the second covering the last 4 GB. The array built by orion_setup_cpu_mbus_target() has therefore two entries, and device drivers try to set up two address decoding windows to the SDRAM. However, in the device registers for the address decoding, the base address is only 32 bits, so those two windows overlap each other, and the devices do not work at all.

Quoted 2 lines

This patch makes sure that the array built by orion_setup_cpu_mbus_target() only contains the SDRAM decoding

windows

Quoted 10 lines

that correspond to the first 4 GB of the memory. To do that, it ignores the SDRAM decoding windows for which the 3 low-order bits are not zero (the 3 low-order bits of the base register are used to store bits 32:35 of the base address, so they actually indicate whether the base address is above 4 GB).

This patch allows the newly introduced armada-xp-gp board to properly operate when it is mounted with more than 4 GB of RAM. Without that, all devices doing DMA (for example XOR and Ethernet) do not work at all.

Quoted 5 lines

It fixes the issue I had with Ethernet since severals weeks, you can definitely add my:

Tested and review here as well:

Quoted 32 lines
Quoted 3 lines

electrons.com>

arch/arm/plat-orion/addr-map.c void __init orion_setup_cpu_mbus_target(const

Quoted 13 lines

---
This patch should definitely be applied for 3.9. It may also be considered for 3.8, since other boards than the armada-xp-gp can be mounted with more than 4 GB of RAM.

---
 arch/arm/plat-orion/addr-map.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/arch/arm/plat-orion/addr-map.c index febe386..41a8363 100644

arch/arm/plat-orion/addr-map.c +0 -0
@@ -157,9 +157,12 @@ void __init orion_setup_cpu_mbus_target(const

struct orion_addr_map_cfg *cfg,

arch/arm/plat-orion/addr-map.c void __init orion_setup_cpu_mbus_target(const · line 157

Quoted 1 line
arch/arm/plat-orion/addr-map.c +0 -0
 		u32 size = readl(ddr_window_cpu_base +

DDR_SIZE_CS_OFF(i));

Quoted 12 lines
arch/arm/plat-orion/addr-map.c +5 -2
 		/*
-		 * Chip select enabled?
+		 * We only take care of entries for which the chip
+		 * select is enabled, and that don't have high base
+		 * address bits set (devices can only access the first
+		 * 32 bits of the memory).
 		 */
-		if (size & 1) {
+		if ((size & 1) && !(base & 0x7)) {
 			struct mbus_dram_window *w;
 
Quoted 9 lines

arch/arm/plat-orion/addr-map.c void __init orion_setup_cpu_mbus_target(const · line 168

Quoted 2 lines
arch/arm/plat-orion/addr-map.c +0 -0
 			w = &orion_mbus_dram_info.cs[cs++];
 

--
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux development, consulting, training and support.
http://free-electrons.com

Regatds,
Lior Amsalem

#3 lore raw

PATCH 1/1 arm: plat-orion: fix address decoding when > 4GB is used

In reply to Thomas Petazzoni
Quoted 10 lines · Thomas Petazzoni

During the system initialization, the orion_setup_cpu_mbus_target() function reads the SDRAM address decoding registers to find out how many chip-selects of SDRAM have been enabled, and builds a small array with one entry per chip-select. This array is then used by device drivers (XOR, Ethernet, etc.) to configure their own address decoding windows to the SDRAM.

However, devices can only access the first 32 bits of the physical memory. Even though LPAE is not supported for now, some Marvell boards are not showing up with 8 GB of RAM, configured using two SDRAM

Tiny nitpick:

s/not/now

Quoted 16 lines

address decoding windows: the first covering the first 4 GB, the second covering the last 4 GB. The array built by orion_setup_cpu_mbus_target() has therefore two entries, and device drivers try to set up two address decoding windows to the SDRAM. However, in the device registers for the address decoding, the base address is only 32 bits, so those two windows overlap each other, and the devices do not work at all.

This patch makes sure that the array built by orion_setup_cpu_mbus_target() only contains the SDRAM decoding windows that correspond to the first 4 GB of the memory. To do that, it ignores the SDRAM decoding windows for which the 3 low-order bits are not zero (the 3 low-order bits of the base register are used to store bits 32:35 of the base address, so they actually indicate whether the base address is above 4 GB).

Quoted 6 lines

This patch allows the newly introduced armada-xp-gp board to properly operate when it is mounted with more than 4 GB of RAM. Without that, all devices doing DMA (for example XOR and Ethernet) do not work at all.

On the Armada XP GP board, ethernet doesn't work at all without this patch.

Thanks,

Signature · 3 lines
Ezequiel Garc?a, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com