From: Ard Biesheuvel <ard.biesheu...@linaro.org>

When using ACPI OpRegions to poke device registers, Linux will use
the UEFI memory map to decide which memory attributes to use, and
so they should not be described as cacheable memory.

Since MMIO regions that don't require an OS virtual mapping at runtime
don't really belong in the UEFI memory map to begin with, omit them
entirely.

Signed-off-by: Pete Batard <p...@akeo.ie>
---
 Platform/RaspberryPi/Include/Library/RPiMem.h                    |  7 ++++---
 Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.c | 10 
++++++++++
 Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c        |  6 +++---
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/Platform/RaspberryPi/Include/Library/RPiMem.h 
b/Platform/RaspberryPi/Include/Library/RPiMem.h
index 9d38e4b6cfb3..a033af369bb0 100644
--- a/Platform/RaspberryPi/Include/Library/RPiMem.h
+++ b/Platform/RaspberryPi/Include/Library/RPiMem.h
@@ -9,9 +9,10 @@
 #ifndef RPI_MEM_H__
 #define RPI_MEM_H__
 
-#define RPI_MEM_BASIC_REGION    0
-#define RPI_MEM_RUNTIME_REGION  1
-#define RPI_MEM_RESERVED_REGION 2
+#define RPI_MEM_UNMAPPED_REGION 0
+#define RPI_MEM_BASIC_REGION    1
+#define RPI_MEM_RUNTIME_REGION  2
+#define RPI_MEM_RESERVED_REGION 3
 
 typedef struct {
   CONST CHAR16*                 Name;
diff --git a/Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.c 
b/Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.c
index 3a0f7e19e993..7ba1cc5602d2 100644
--- a/Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.c
+++ b/Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.c
@@ -72,6 +72,15 @@ AddRuntimeServicesRegion (
   );
 }
 
+STATIC
+VOID
+AddUnmappedMemoryRegion (
+  IN ARM_MEMORY_REGION_DESCRIPTOR *Desc
+  )
+{
+  // Do nothing
+}
+
 STATIC
 VOID
 AddReservedMemoryRegion (
@@ -88,6 +97,7 @@ AddReservedMemoryRegion (
 }
 
 void (*AddRegion[]) (IN ARM_MEMORY_REGION_DESCRIPTOR *Desc) = {
+  AddUnmappedMemoryRegion,
   AddBasicMemoryRegion,
   AddRuntimeServicesRegion,
   AddReservedMemoryRegion,
diff --git a/Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c 
b/Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c
index 781cf78b83d3..f8223d1b94e8 100644
--- a/Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c
+++ b/Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c
@@ -117,7 +117,7 @@ ArmPlatformGetVirtualMemoryMap (
   VirtualMemoryTable[Index].VirtualBase     = 
VirtualMemoryTable[Index].PhysicalBase;
   VirtualMemoryTable[Index].Length          = mVideoCoreSize;
   VirtualMemoryTable[Index].Attributes      = 
ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
-  VirtualMemoryInfo[Index].Type             = RPI_MEM_RESERVED_REGION;
+  VirtualMemoryInfo[Index].Type             = RPI_MEM_UNMAPPED_REGION;
   VirtualMemoryInfo[Index++].Name           = L"GPU Reserved";
 
   // Compute the total RAM size available on this platform
@@ -139,7 +139,7 @@ ArmPlatformGetVirtualMemoryMap (
     VirtualMemoryTable[Index].VirtualBase   = 
VirtualMemoryTable[Index].PhysicalBase;
     VirtualMemoryTable[Index].Length        = BCM2711_SOC_REGISTER_LENGTH;
     VirtualMemoryTable[Index].Attributes    = 
ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
-    VirtualMemoryInfo[Index].Type           = RPI_MEM_RESERVED_REGION;
+    VirtualMemoryInfo[Index].Type           = RPI_MEM_UNMAPPED_REGION;
     VirtualMemoryInfo[Index++].Name         = L"SoC Reserved (27xx)";
   }
 
@@ -152,7 +152,7 @@ ArmPlatformGetVirtualMemoryMap (
   VirtualMemoryTable[Index].VirtualBase     = 
VirtualMemoryTable[Index].PhysicalBase;
   VirtualMemoryTable[Index].Length          = BCM2836_SOC_REGISTER_LENGTH;
   VirtualMemoryTable[Index].Attributes      = 
ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
-  VirtualMemoryInfo[Index].Type             = RPI_MEM_RESERVED_REGION;
+  VirtualMemoryInfo[Index].Type             = RPI_MEM_UNMAPPED_REGION;
   VirtualMemoryInfo[Index++].Name           = L"SoC Reserved (283x)";
 
   // If we have RAM above the 1 GB mark, declare it
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#52115): https://edk2.groups.io/g/devel/message/52115
Mute This Topic: https://groups.io/mt/68147483/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to