Re: [edk2-devel] [PATCH edk2-platforms v5 1/1] Platform/SbsaQemu: add GIC ITS support

2023-08-22 Thread Leif Lindholm
On Tue, Aug 22, 2023 at 18:53:43 +0200, Marcin Juszkiewicz wrote:
> From: Shashi Mallela 
> 
> SBSA Reference Platform has GIC ITS support. Let make use of it to have
> complex PCI Express setups.
> 
> Base address is read from TF-A via SMC call.
> 
> If firmware is used with QEMU 8.0 or older then there will be no GIC ITS
> support. In such case we would not add information about it into MCFG
> and there will be no IORT table.
> 
> Co-authored-by: Marcin Juszkiewicz 
> Signed-off-by: Shashi Mallela 
> Signed-off-by: Marcin Juszkiewicz 

Reviewed-by: Leif Lindholm 
Pushed as e509ac5a729e.
Thanks!

> ---
>  Silicon/Qemu/SbsaQemu/SbsaQemu.dec|   4 +
>  Platform/Qemu/SbsaQemu/SbsaQemu.dsc   |   4 +
>  .../Qemu/SbsaQemu/AcpiTables/AcpiTables.inf   |   1 +
>  .../SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf   |   2 +
>  .../SbsaQemuPlatformDxe.inf   |   1 +
>  .../Include/IndustryStandard/SbsaQemuAcpi.h   |  11 +
>  .../Include/IndustryStandard/SbsaQemuSmc.h|   1 +
>  .../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c | 206 ++
>  .../SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c |  10 +
>  9 files changed, 240 insertions(+)
> 
> diff --git a/Silicon/Qemu/SbsaQemu/SbsaQemu.dec 
> b/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
> index 5182978cf56d..aab2894e6455 100644
> --- a/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
> +++ b/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
> @@ -70,3 +70,7 @@ [PcdsDynamic.common]
>  
>
> gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor|0x0|UINT32|0x011E
>
> gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor|0x0|UINT32|0x011F
> +
> +  # ARM Generic Interrupt Controller ITS
> +  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdGicItsBase|0|UINT64|0x0120
> +  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdSmmuBase|0|UINT64|0x0121
> diff --git a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc 
> b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
> index b88729ad8ad6..be406144c242 100644
> --- a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
> +++ b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
> @@ -523,6 +523,10 @@ [PcdsDynamicDefault.common]
>gArmTokenSpaceGuid.PcdGicDistributorBase|0x4006
>gArmTokenSpaceGuid.PcdGicRedistributorsBase|0x4008
>  
> +  # GIC ITS
> +  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdGicItsBase|0
> +  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdSmmuBase|0x6005
> +
>#
># Set video resolution for boot options
># PlatformDxe can set the former at runtime.
> diff --git a/Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf 
> b/Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf
> index 0501c670d565..97021f7971c7 100644
> --- a/Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf
> +++ b/Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf
> @@ -75,3 +75,4 @@ [FixedPcd]
>  [Pcd]
>gArmTokenSpaceGuid.PcdGicDistributorBase
>gArmTokenSpaceGuid.PcdGicRedistributorsBase
> +  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdGicItsBase
> diff --git 
> a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf 
> b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf
> index c1c33788567d..14d760b36400 100644
> --- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf
> +++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf
> @@ -48,6 +48,8 @@ [Pcd]
>  
>gArmTokenSpaceGuid.PcdGicDistributorBase
>gArmTokenSpaceGuid.PcdGicRedistributorsBase
> +  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdGicItsBase
> +  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdSmmuBase
>  
>  [Depex]
>gEfiAcpiTableProtocolGuid   ## CONSUMES
> diff --git 
> a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf 
> b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
> index 545794a8c7ff..0e3b11d60426 100644
> --- 
> a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
> +++ 
> b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
> @@ -43,6 +43,7 @@ [Pcd]
>  
>gArmTokenSpaceGuid.PcdGicDistributorBase
>gArmTokenSpaceGuid.PcdGicRedistributorsBase
> +  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdGicItsBase
>  
>  
>  [Depex]
> diff --git a/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuAcpi.h 
> b/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuAcpi.h
> index 853b81b34df5..983d17f6fa50 100644
> --- a/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuAcpi.h
> +++ b/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuAcpi.h
> @@ -27,6 +27,7 @@
>  #define SBSAQEMU_MADT_GIC_HBASE  0x2c01
>  #define SBSAQEMU_MADT_GIC_PMU_IRQ23
>  #define SBSAQEMU_MADT_GICR_SIZE  0x400
> +#define SBSAQEMU_MADT_GITS_SIZE  0x2
>  
>  // Macro for MADT GIC Redistributor Structure
>  #define SBSAQEMU_MADT_GICR_INIT() {  
>   \
> @@ -37,6 +38,16 @@
> SBSAQEMU_MADT_GICR_SIZE   /* DiscoveryRangeLength */  
>   \
> }
> 

[edk2-devel] [PATCH edk2-platforms v5 1/1] Platform/SbsaQemu: add GIC ITS support

2023-08-22 Thread Marcin Juszkiewicz
From: Shashi Mallela 

SBSA Reference Platform has GIC ITS support. Let make use of it to have
complex PCI Express setups.

Base address is read from TF-A via SMC call.

If firmware is used with QEMU 8.0 or older then there will be no GIC ITS
support. In such case we would not add information about it into MCFG
and there will be no IORT table.

Co-authored-by: Marcin Juszkiewicz 
Signed-off-by: Shashi Mallela 
Signed-off-by: Marcin Juszkiewicz 
---
 Silicon/Qemu/SbsaQemu/SbsaQemu.dec|   4 +
 Platform/Qemu/SbsaQemu/SbsaQemu.dsc   |   4 +
 .../Qemu/SbsaQemu/AcpiTables/AcpiTables.inf   |   1 +
 .../SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf   |   2 +
 .../SbsaQemuPlatformDxe.inf   |   1 +
 .../Include/IndustryStandard/SbsaQemuAcpi.h   |  11 +
 .../Include/IndustryStandard/SbsaQemuSmc.h|   1 +
 .../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c | 206 ++
 .../SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c |  10 +
 9 files changed, 240 insertions(+)

diff --git a/Silicon/Qemu/SbsaQemu/SbsaQemu.dec 
b/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
index 5182978cf56d..aab2894e6455 100644
--- a/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
+++ b/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
@@ -70,3 +70,7 @@ [PcdsDynamic.common]
 
   
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor|0x0|UINT32|0x011E
   
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor|0x0|UINT32|0x011F
+
+  # ARM Generic Interrupt Controller ITS
+  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdGicItsBase|0|UINT64|0x0120
+  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdSmmuBase|0|UINT64|0x0121
diff --git a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc 
b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
index b88729ad8ad6..be406144c242 100644
--- a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
+++ b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
@@ -523,6 +523,10 @@ [PcdsDynamicDefault.common]
   gArmTokenSpaceGuid.PcdGicDistributorBase|0x4006
   gArmTokenSpaceGuid.PcdGicRedistributorsBase|0x4008
 
+  # GIC ITS
+  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdGicItsBase|0
+  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdSmmuBase|0x6005
+
   #
   # Set video resolution for boot options
   # PlatformDxe can set the former at runtime.
diff --git a/Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf 
b/Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf
index 0501c670d565..97021f7971c7 100644
--- a/Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf
+++ b/Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf
@@ -75,3 +75,4 @@ [FixedPcd]
 [Pcd]
   gArmTokenSpaceGuid.PcdGicDistributorBase
   gArmTokenSpaceGuid.PcdGicRedistributorsBase
+  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdGicItsBase
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf 
b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf
index c1c33788567d..14d760b36400 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf
@@ -48,6 +48,8 @@ [Pcd]
 
   gArmTokenSpaceGuid.PcdGicDistributorBase
   gArmTokenSpaceGuid.PcdGicRedistributorsBase
+  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdGicItsBase
+  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdSmmuBase
 
 [Depex]
   gEfiAcpiTableProtocolGuid   ## CONSUMES
diff --git 
a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf 
b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
index 545794a8c7ff..0e3b11d60426 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
@@ -43,6 +43,7 @@ [Pcd]
 
   gArmTokenSpaceGuid.PcdGicDistributorBase
   gArmTokenSpaceGuid.PcdGicRedistributorsBase
+  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdGicItsBase
 
 
 [Depex]
diff --git a/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuAcpi.h 
b/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuAcpi.h
index 853b81b34df5..983d17f6fa50 100644
--- a/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuAcpi.h
+++ b/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuAcpi.h
@@ -27,6 +27,7 @@
 #define SBSAQEMU_MADT_GIC_HBASE  0x2c01
 #define SBSAQEMU_MADT_GIC_PMU_IRQ23
 #define SBSAQEMU_MADT_GICR_SIZE  0x400
+#define SBSAQEMU_MADT_GITS_SIZE  0x2
 
 // Macro for MADT GIC Redistributor Structure
 #define SBSAQEMU_MADT_GICR_INIT() {
\
@@ -37,6 +38,16 @@
SBSAQEMU_MADT_GICR_SIZE   /* DiscoveryRangeLength */
\
}
 
+// Macro for MADT GIC ITS Structure
+#define SBSAQEMU_MADT_GIC_ITS_INIT(GicItsId) { 
\
+   EFI_ACPI_6_5_GIC_ITS, /* Type */
\
+   sizeof (EFI_ACPI_6_5_GIC_ITS_STRUCTURE),  /* Length */  
\
+   EFI_ACPI_RESERVED_WORD,   /* Reserved */