Skip to contentSkip to conversation

PCI: dm: Ignore 64-bit memory regions if CONFIG_SYS_PCI_64BIT not set

PATCH New Tuomas Tynkkynen 4 participants 10 messages May 14, 2018 – Sep 4, 2018 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 PCI: dm: Ignore 64-bit memory regions if CONFIG_SYS_PCI_64BIT not set

Currently, qemu_arm_defconfig and qemu_arm64_defconfig only work with the 'highmem=off' parameter passed to QEMU's virt machine. The reason is that when 'highmem' is not disabled, QEMU appends 64-bit a memory resource to the PCI controller's regions property in DT in addition to the 32-bit PCI memory window in low memory. And the current DT parsing code picks the last (thus the 64-bit one) memory resource, whose address eventually gets silently truncated to 32 bits because CONFIG_SYS_PCI_64BIT is not set, which obviously causes PCI to break.

Avoid this problem by ignoring memory regions whose addresses are above the 32-bit boundary when CONFIG_SYS_PCI_64BIT is not set.

---
 drivers/pci/pci-uclass.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/pci/pci-uclass.c +7 -0
index 49be1ebdd7..1cd1e409e3 100644
@@ -860,6 +860,13 @@ static int decode_regions(struct pci_controller *hose, ofnode parent_node,
 		} else {
 			continue;
 		}
+
+		if (!IS_ENABLED(CONFIG_SYS_PCI_64BIT) &&
+		    type == PCI_REGION_MEM && upper_32_bits(pci_addr)) {
+			debug(" - beyond the 32-bit boundary, ignoring\n");
+			continue;
+		}
+
 		pos = -1;
 		for (i = 0; i < hose->region_count; i++) {
 			if (hose->regions[i].flags == type)
Signature · 1 line
2.16.3
#1 lore raw

PATCH 2/3 ARM: qemu-arm: Bump RAM size in AArch64 MMU table

Now that PCI devices work with highmem-enabled QEMU emulation, bump up the RAM size in the MMU tables to gain access to the full 255 GB of RAM potential instead of the puny 3 GB.

---
 board/emulation/qemu-arm/qemu-arm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
board/emulation/qemu-arm/qemu-arm.c +1 -1
index 6ec4200170..085cbbef99 100644
@@ -28,7 +28,7 @@ static struct mm_region qemu_arm64_mem_map[] = {
 		/* RAM */
 		.virt = 0x40000000UL,
 		.phys = 0x40000000UL,
-		.size = 0xc0000000UL,
+		.size = 255UL * SZ_1G,
 		.attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
 			 PTE_BLOCK_INNER_SHARE
 	}, {
Signature · 1 line
2.16.3
#2 lore raw

PATCH 2/3 ARM: qemu-arm: Bump RAM size in AArch64 MMU table

Quoted 8 lines · Tuomas Tynkkynen

Now that PCI devices work with highmem-enabled QEMU emulation, bump up the RAM size in the MMU tables to gain access to the full 255 GB of RAM potential instead of the puny 3 GB.

---
 board/emulation/qemu-arm/qemu-arm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#3 lore raw

PATCH 2/3 ARM: qemu-arm: Bump RAM size in AArch64 MMU table

In reply to Tuomas Tynkkynen
Quoted 6 lines · Tuomas Tynkkynen

Now that PCI devices work with highmem-enabled QEMU emulation, bump up the RAM size in the MMU tables to gain access to the full 255 GB of RAM potential instead of the puny 3 GB.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180528/82c5d4c5/attachment.sig>
#4 lore raw

PATCH 3/3 doc: qemu-arm: Drop highmem=off references

In reply to Tuomas Tynkkynen

Now that U-Boot works fine with highmem enabled, there is no need to tell users to disable highmem.

---
 doc/README.qemu-arm | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
doc/README.qemu-arm +3 -4
index 6f6f07d8bb..260165638a 100644
@@ -39,13 +39,12 @@ Running U-Boot
 The minimal QEMU command line to get U-Boot up and running is:
 
 - For ARM:
-    qemu-system-arm -machine virt,highmem=off -bios u-boot.bin
+    qemu-system-arm -machine virt -bios u-boot.bin
 
 - For AArch64:
-    qemu-system-aarch64 -machine virt,highmem=off -cpu cortex-a57 -bios u-boot.bin
+    qemu-system-aarch64 -machine virt -cpu cortex-a57 -bios u-boot.bin
 
-The 'highmem=off' parameter to the 'virt' machine is required for PCI to work
-in U-Boot. Also, for some odd reason qemu-system-aarch64 needs to be explicitly
+Note that for some odd reason qemu-system-aarch64 needs to be explicitly
 told to use a 64-bit CPU or it will boot in 32-bit mode.
 
 Additional peripherals that have been tested to work in both U-Boot and Linux
Signature · 1 line
2.16.3
#6 lore raw

PATCH 3/3 doc: qemu-arm: Drop highmem=off references

In reply to Tuomas Tynkkynen
Quoted 5 lines · Tuomas Tynkkynen

Now that U-Boot works fine with highmem enabled, there is no need to tell users to disable highmem.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180528/dd557904/attachment.sig>
#7 lore raw

PATCH 3/3 doc: qemu-arm: Drop highmem=off references

In reply to Tuomas Tynkkynen
Quoted 19 lines · Tuomas Tynkkynen

Now that U-Boot works fine with highmem enabled, there is no need to tell users to disable highmem.

---
 doc/README.qemu-arm | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
doc/README.qemu-arm +1 -1
index 6f6f07d8bb..260165638a 100644
@@ -39,13 +39,12 @@ Running U-Boot
 The minimal QEMU command line to get U-Boot up and running is:
 
 - For ARM:
-    qemu-system-arm -machine virt,highmem=off -bios u-boot.bin
+    qemu-system-arm -machine virt -bios u-boot.bin
 

doc/README.qemu-arm Running U-Boot · line 50

Quoted 10 lines
doc/README.qemu-arm +2 -3
 - For AArch64:
-    qemu-system-aarch64 -machine virt,highmem=off -cpu cortex-a57 -bios u-boot.bin
+    qemu-system-aarch64 -machine virt -cpu cortex-a57 -bios u-boot.bin
 
-The 'highmem=off' parameter to the 'virt' machine is required for PCI to work
-in U-Boot. Also, for some odd reason qemu-system-aarch64 needs to be explicitly
+Note that for some odd reason qemu-system-aarch64 needs to be explicitly
 told to use a 64-bit CPU or it will boot in 32-bit mode.
 
 Additional peripherals that have been tested to work in both U-Boot and Linux

Something has changed as qemu 3.0 requires highmem=off again. qemu 2.12.0 works without highmem=off.

$ qemu-system-aarch64 --version
QEMU emulator version 3.0.0
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
$ qemu-system-aarch64 -M virt -cpu cortex-a57 -bios u-boot.bin -serial stdio

U-Boot 2018.09-rc3 (Sep 04 2018 - 13:03:12 +1000)

DRAM:  128 MiB
In:    pl011 at 9000000
Out:   pl011 at 9000000
Err:   pl011 at 9000000
Net:   No ethernet found.

"Synchronous Abort" handler, esr 0x96000005
elr: 00000000000258e0 lr : 000000000002589c (reloc)
elr: 0000000047f978e0 lr : 0000000047f9789c x0 : 000000401000000e x1 : 0000000000000000 x2 : 000000401000000e x3 : 0000000046e608c8 x4 : 0000004010000000 x5 : 0000000000000000 x6 : 0000000047f9889c x7 : 0000000000000002 x8 : 0000000000000003 x9 : 0000000000000004
x10: 0000000046e60de8 x11: 000000000000152c
x12: 0000000046e6089c x13: 0000000000001200
x14: 0000000046e6092c x15: 0000000046e60de8
x16: 0000000000000000 x17: 0000000000000000
x18: 0000000046f61de8 x19: 0000000046e60940
x20: 0000000000000000 x21: 0000000047fcc0a8
x22: 0000000046f62450 x23: 0000000047fcc680
x24: 000000000000ff00 x25: 0000000000000000
x26: 0000000047fcc000 x27: 0000000000000000
x28: 0000000000000000 x29: 0000000046e608a0

Resetting CPU ...

resetting ...

$ qemu-system-aarch64 -M virt,highmem=off -cpu cortex-a57 -bios u-boot.bin -serial stdio

U-Boot 2018.09-rc3 (Sep 04 2018 - 13:03:12 +1000)

DRAM:  128 MiB
In:    pl011 at 9000000
Out:   pl011 at 9000000
Err:   pl011 at 9000000
Net:   No ethernet found.
Hit any key to stop autoboot:  0 

scanning bus for devices...

Device 0: unknown device
=>

#8 lore raw

PATCH 1/3 PCI: dm: Ignore 64-bit memory regions if CONFIG_SYS_PCI_64BIT not set

In reply to Tuomas Tynkkynen
Quoted 9 lines · Tuomas Tynkkynen

Currently, qemu_arm_defconfig and qemu_arm64_defconfig only work with the 'highmem=off' parameter passed to QEMU's virt machine. The reason is that when 'highmem' is not disabled, QEMU appends 64-bit a memory resource to the PCI controller's regions property in DT in addition to the 32-bit PCI memory window in low memory. And the current DT parsing code picks the last (thus the 64-bit one) memory resource, whose address eventually gets silently truncated to 32 bits because CONFIG_SYS_PCI_64BIT is not set, which obviously causes PCI to break.

Quoted 8 lines

Avoid this problem by ignoring memory regions whose addresses are above the 32-bit boundary when CONFIG_SYS_PCI_64BIT is not set.

---
 drivers/pci/pci-uclass.c | 7 +++++++
 1 file changed, 7 insertions(+)
#9 lore raw

PATCH 1/3 PCI: dm: Ignore 64-bit memory regions if CONFIG_SYS_PCI_64BIT not set

In reply to Tuomas Tynkkynen
Quoted 9 lines · Tuomas Tynkkynen

Currently, qemu_arm_defconfig and qemu_arm64_defconfig only work with the 'highmem=off' parameter passed to QEMU's virt machine. The reason is that when 'highmem' is not disabled, QEMU appends 64-bit a memory resource to the PCI controller's regions property in DT in addition to the 32-bit PCI memory window in low memory. And the current DT parsing code picks the last (thus the 64-bit one) memory resource, whose address eventually gets silently truncated to 32 bits because CONFIG_SYS_PCI_64BIT is not set, which obviously causes PCI to break.

Quoted 5 lines

Avoid this problem by ignoring memory regions whose addresses are above the 32-bit boundary when CONFIG_SYS_PCI_64BIT is not set.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180528/14542215/attachment.sig>