Re: [edk2-devel] [PATCH v4 1/1] SbsaQemu: AcpiDxe: Create SRAT table at runtime

2024-03-28 Thread Leif Lindholm
On Thu, Mar 28, 2024 at 06:19:35 +, Xiong Yining wrote:
> Add support to create SRAT(System resource affinity table) for
> sbsa platform at runtime.
> 
> Signed-off-by: Xiong Yining 
> Reviewed-by: Marcin Juszkiewicz 
> Reviewed-by: Leif Lindholm 

You are not supposed to add Reviewed-by: or Acked-by: tags unless
whoever is commenting on your code indicates so by posting (for me)
Reviewed-by: Leif Lindholm 

It is not an indicator of work in progress, it is a flag that the
patch has been Reviewed and is ready to merge.

This also means that if Reviewed-by: is given early in the process,
but then you need to do substantial rework, you should *drop* any
previously given Reviewed-by: tags.

Marcin has never given his Reviewed-by for this patch, so I have
dropped this before pushing. Pushed as 7c26299112f3.

Thanks!

/
Leif

> ---
>  .../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.h | 27 ++
>  .../Include/Library/HardwareInfoLib.h | 10 ++
>  .../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c | 92 +++
>  .../SbsaQemuHardwareInfoLib.c | 36 
>  4 files changed, 165 insertions(+)
> 
> diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.h 
> b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.h
> index 7595df4c8a2d..83a085cd86f4 100644
> --- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.h
> +++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.h
> @@ -63,4 +63,31 @@ typedef struct {
>  
>  #define GTDT_WDTIMER_FLAGS  (GTDT_WDTIMER_ACTIVE_HIGH | 
> GTDT_WDTIMER_LEVEL_TRIGGERED)
>  
> +#define SBSAQEMU_ACPI_MEMORY_AFFINITY_STRUCTURE_INIT(
>  \
> +  ProximityDomain, Base, Length, Flags)  
>  \
> +  {  
>  \
> +1,  /* Type */   
>  \
> +sizeof (EFI_ACPI_6_4_MEMORY_AFFINITY_STRUCTURE),/* Length */ 
>  \
> +ProximityDomain,/* Proximity Domain 
> */\
> +0,  /* Reserved */   
>  \
> +(Base) & 0x,/* Base Address Low 
> */\
> +((Base) >> 32) & 0x ,   /* Base Address High 
> */   \
> +(Length) & 0x,  /* Length Low */ 
>  \
> +((Length) >> 32) & 0x,  /* Length High */
>  \
> +0,  /* Reserved */   
>  \
> +Flags,  /* Flags */  
>  \
> +0   /* Reserved */   
>  \
> +  }
> +
> +#define SBSAQEMU_ACPI_GICC_AFFINITY_STRUCTURE_INIT(  
>  \
> +  ProximityDomain, ACPIProcessorUID, Flags, ClockDomain) 
>  \
> +  {  
>  \
> +3,  /* Type */   
>  \
> +sizeof (EFI_ACPI_6_4_GICC_AFFINITY_STRUCTURE),  /* Length */ 
>  \
> +ProximityDomain,/* Proximity Domain 
> */\
> +ACPIProcessorUID,   /* ACPI Processor 
> UID */  \
> +Flags,  /* Flags */  
>  \
> +ClockDomain /* Clock Domain */   
>  \
> +  }
> +
>  #endif
> diff --git a/Silicon/Qemu/SbsaQemu/Include/Library/HardwareInfoLib.h 
> b/Silicon/Qemu/SbsaQemu/Include/Library/HardwareInfoLib.h
> index 5db0eacc9d2d..46fdad45353c 100644
> --- a/Silicon/Qemu/SbsaQemu/Include/Library/HardwareInfoLib.h
> +++ b/Silicon/Qemu/SbsaQemu/Include/Library/HardwareInfoLib.h
> @@ -73,4 +73,14 @@ GetMemInfo (
>OUT MemoryInfo  *MemInfo
>);
>  
> +/**
> +  Get the number of numa node from device tree passed by Qemu.
> +
> +  @retvalthe number of numa node.
> +**/
> +UINT64
> +GetNumaNodeCount (
> +  VOID
> +  );
> +
>  #endif /* HARDWARE_INFO_LIB */
> diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c 
> b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c
> index 4ebe2a445344..30239e7dca0d 100644
> --- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c
> +++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c
> @@ -682,6 +682,91 @@ AddGtdtTable (
>return Status;
>  }
>  
> +/*
> + * A function that adds the SRAT ACPI table.
> + */
> +EFI_STATUS
> +AddSratTable (
> +  IN EFI_ACPI_TABLE_PROTOCOL   *AcpiTable
> +  )
> +{
> +  EFI_STATUSStatus;
> +  UINT8 *New;
> +  EFI_PHYSICAL_ADDRESS  PageAddress;
> +  UINTN  

Re: [edk2-devel] [PATCH v4 1/1] SbsaQemu: AcpiDxe: Create SRAT table at runtime

2024-03-28 Thread Marcin Juszkiewicz

W dniu 28.03.2024 o 07:19, Xiong Yining pisze:

Add support to create SRAT(System resource affinity table) for
sbsa platform at runtime.

Signed-off-by: Xiong Yining



Reviewed-by: Marcin Juszkiewicz
Reviewed-by: Leif Lindholm


When you send a new version of patch, with changes done compared to 
previous one you drop "Reviewed-by" tags because it is not code anyone 
saw before.


You add/copy "Reviewed-by" only if patch is in the same version as the 
one reviewed. And only if someone really added that tag in review, not 
when they looked and commented (I never gave "Reviewed-by" tag to any 
version of this patch).



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#117211): https://edk2.groups.io/g/devel/message/117211
Mute This Topic: https://groups.io/mt/105192387/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v4 1/1] SbsaQemu: AcpiDxe: Create SRAT table at runtime

2024-03-27 Thread Xiong Yining
Add support to create SRAT(System resource affinity table) for
sbsa platform at runtime.

Signed-off-by: Xiong Yining 
Reviewed-by: Marcin Juszkiewicz 
Reviewed-by: Leif Lindholm 
---
 .../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.h | 27 ++
 .../Include/Library/HardwareInfoLib.h | 10 ++
 .../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c | 92 +++
 .../SbsaQemuHardwareInfoLib.c | 36 
 4 files changed, 165 insertions(+)

diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.h 
b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.h
index 7595df4c8a2d..83a085cd86f4 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.h
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.h
@@ -63,4 +63,31 @@ typedef struct {
 
 #define GTDT_WDTIMER_FLAGS  (GTDT_WDTIMER_ACTIVE_HIGH | 
GTDT_WDTIMER_LEVEL_TRIGGERED)
 
+#define SBSAQEMU_ACPI_MEMORY_AFFINITY_STRUCTURE_INIT(  
   \
+  ProximityDomain, Base, Length, Flags)
   \
+  {
   \
+1,  /* Type */ 
   \
+sizeof (EFI_ACPI_6_4_MEMORY_AFFINITY_STRUCTURE),/* Length */   
   \
+ProximityDomain,/* Proximity Domain */ 
   \
+0,  /* Reserved */ 
   \
+(Base) & 0x,/* Base Address Low */ 
   \
+((Base) >> 32) & 0x ,   /* Base Address High 
*/   \
+(Length) & 0x,  /* Length Low */   
   \
+((Length) >> 32) & 0x,  /* Length High */  
   \
+0,  /* Reserved */ 
   \
+Flags,  /* Flags */
   \
+0   /* Reserved */ 
   \
+  }
+
+#define SBSAQEMU_ACPI_GICC_AFFINITY_STRUCTURE_INIT(
   \
+  ProximityDomain, ACPIProcessorUID, Flags, ClockDomain)   
   \
+  {
   \
+3,  /* Type */ 
   \
+sizeof (EFI_ACPI_6_4_GICC_AFFINITY_STRUCTURE),  /* Length */   
   \
+ProximityDomain,/* Proximity Domain */ 
   \
+ACPIProcessorUID,   /* ACPI Processor UID 
*/  \
+Flags,  /* Flags */
   \
+ClockDomain /* Clock Domain */ 
   \
+  }
+
 #endif
diff --git a/Silicon/Qemu/SbsaQemu/Include/Library/HardwareInfoLib.h 
b/Silicon/Qemu/SbsaQemu/Include/Library/HardwareInfoLib.h
index 5db0eacc9d2d..46fdad45353c 100644
--- a/Silicon/Qemu/SbsaQemu/Include/Library/HardwareInfoLib.h
+++ b/Silicon/Qemu/SbsaQemu/Include/Library/HardwareInfoLib.h
@@ -73,4 +73,14 @@ GetMemInfo (
   OUT MemoryInfo  *MemInfo
   );
 
+/**
+  Get the number of numa node from device tree passed by Qemu.
+
+  @retvalthe number of numa node.
+**/
+UINT64
+GetNumaNodeCount (
+  VOID
+  );
+
 #endif /* HARDWARE_INFO_LIB */
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c 
b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c
index 4ebe2a445344..30239e7dca0d 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c
@@ -682,6 +682,91 @@ AddGtdtTable (
   return Status;
 }
 
+/*
+ * A function that adds the SRAT ACPI table.
+ */
+EFI_STATUS
+AddSratTable (
+  IN EFI_ACPI_TABLE_PROTOCOL   *AcpiTable
+  )
+{
+  EFI_STATUSStatus;
+  UINT8 *New;
+  EFI_PHYSICAL_ADDRESS  PageAddress;
+  UINTN TableHandle;
+  UINT32TableSize;
+  UINT32Index;
+  UINT32NodeId;
+  UINT32NumMemNodes;
+  MemoryInfoMemInfo;
+  UINT32NumCores = GetCpuCount ();
+
+  // Initialize SRAT ACPI Header
+  EFI_ACPI_6_4_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER Header = {
+ SBSAQEMU_ACPI_HEADER 
(EFI_ACPI_6_4_SYSTEM_RESOURCE_AFFINITY_TABLE_SIGNATURE,
+   EFI_ACPI_6_4_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER,
+   
EFI_ACPI_6_4_SYSTEM_RESOURCE_AFFINITY_TABLE_REVISION),
+  1, 0 };
+
+  NumMemNodes  = GetMemNodeCount();
+
+  // Calculate the new table size based on the number of cores
+  TableSize = sizeof (EFI_ACPI_6_4_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER) +
+   (sizeof (EFI_ACPI_6_4_MEMORY_AFFINITY_STRUCTURE) * NumMemNodes