diff --git a/Silicon/NVIDIA/Drivers/ConfigurationManagerData/SratParser/SratParser.c b/Silicon/NVIDIA/Drivers/ConfigurationManagerData/SratParser/SratParser.c index 6d18f58d37..fd1a06aa0b 100644 --- a/Silicon/NVIDIA/Drivers/ConfigurationManagerData/SratParser/SratParser.c +++ b/Silicon/NVIDIA/Drivers/ConfigurationManagerData/SratParser/SratParser.c @@ -28,19 +28,24 @@ SratParser ( IN INT32 FdtBranch ) { - EFI_STATUS Status; - CM_STD_OBJ_ACPI_TABLE_INFO AcpiTableHeader; - CM_ARCH_COMMON_MEMORY_AFFINITY_INFO *MemoryAffinityInfo; - UINTN MemoryAffinityInfoCount; - UINTN MemoryAffinityInfoIndex; - VOID *Hob; - TEGRA_PLATFORM_RESOURCE_INFO *PlatformResourceInfo; - CM_OBJ_DESCRIPTOR Desc; - UINT32 Index; - UINT32 MaxProximityDomain; - UINT32 NumberOfInitiatorDomains; - UINT32 NumberOfTargetDomains; - NUMA_INFO_DOMAIN_INFO DomainInfo; + EFI_STATUS Status; + CM_STD_OBJ_ACPI_TABLE_INFO AcpiTableHeader; + CM_ARCH_COMMON_MEMORY_AFFINITY_INFO *MemoryAffinityInfo; + UINTN MemoryAffinityInfoCount; + UINTN MemoryAffinityInfoIndex; + CM_ARCH_COMMON_GENERIC_INITIATOR_AFFINITY_INFO *GenericInitiatorAffinityInfo; + UINTN GenericInitiatorAffinityInfoCount; + UINTN GenericInitiatorAffinityInfoIndex; + CM_ARCH_COMMON_DEVICE_HANDLE_PCI *DeviceHandlePciInfo; + CM_OBJECT_TOKEN *DeviceHandleTokenMap; + VOID *Hob; + TEGRA_PLATFORM_RESOURCE_INFO *PlatformResourceInfo; + CM_OBJ_DESCRIPTOR Desc; + UINT32 Index; + UINT32 MaxProximityDomain; + UINT32 NumberOfInitiatorDomains; + UINT32 NumberOfTargetDomains; + NUMA_INFO_DOMAIN_INFO DomainInfo; // Get platform resource info Hob = GetFirstGuidHob (&gNVIDIAPlatformResourceDataGuid); @@ -126,6 +131,79 @@ SratParser ( } } + // Build generic initiators + GenericInitiatorAffinityInfoCount = NumberOfInitiatorDomains; // Will remove CPU nodes later + GenericInitiatorAffinityInfo = (CM_ARCH_COMMON_GENERIC_INITIATOR_AFFINITY_INFO *)AllocateZeroPool (sizeof (CM_ARCH_COMMON_GENERIC_INITIATOR_AFFINITY_INFO) * GenericInitiatorAffinityInfoCount); + if (GenericInitiatorAffinityInfo == NULL) { + DEBUG ((DEBUG_ERROR, "%a: Failed to allocate generic initiator affinity info\r\n", __FUNCTION__)); + Status = EFI_DEVICE_ERROR; + goto CleanupAndReturn; + } + + DeviceHandlePciInfo = (CM_ARCH_COMMON_DEVICE_HANDLE_PCI *)AllocateZeroPool (sizeof (CM_ARCH_COMMON_DEVICE_HANDLE_PCI) * GenericInitiatorAffinityInfoCount); + if (DeviceHandlePciInfo == NULL) { + DEBUG ((DEBUG_ERROR, "%a: Failed to allocate device handle PCI info\r\n", __FUNCTION__)); + Status = EFI_DEVICE_ERROR; + goto CleanupAndReturn; + } + + GenericInitiatorAffinityInfoIndex = 0; + for (Index = 0; Index <= MaxProximityDomain; Index++) { + Status = NumaInfoGetDomainDetails (Index, &DomainInfo); + if (EFI_ERROR (Status)) { + continue; + } + + if (DomainInfo.InitiatorDomain) { + if (DomainInfo.DeviceType == NUMA_INFO_TYPE_CPU) { + // CPU initiators do not generate generic initiator entries, there are GIC entries for them + GenericInitiatorAffinityInfoCount--; + continue; + } + + // Only support PCI device handle type for now + if (DomainInfo.DeviceHandleType != EFI_ACPI_6_4_PCI_DEVICE_HANDLE) { + GenericInitiatorAffinityInfoCount--; + continue; + } + + GenericInitiatorAffinityInfo[GenericInitiatorAffinityInfoIndex].ProximityDomain = Index; + GenericInitiatorAffinityInfo[GenericInitiatorAffinityInfoIndex].Flags = EFI_ACPI_6_4_GENERIC_INITIATOR_AFFINITY_STRUCTURE_ENABLED|EFI_ACPI_6_4_GENERIC_INITIATOR_AFFINITY_STRUCTURE_ARCHITECTURAL_TRANSACTIONS; + GenericInitiatorAffinityInfo[GenericInitiatorAffinityInfoIndex].DeviceHandleType = DomainInfo.DeviceHandleType; + DeviceHandlePciInfo[GenericInitiatorAffinityInfoIndex].SegmentNumber = DomainInfo.DeviceHandle.Pci.PciSegment; + DeviceHandlePciInfo[GenericInitiatorAffinityInfoIndex].BusNumber = DomainInfo.DeviceHandle.Pci.PciBdfNumber & 0xFF; + DeviceHandlePciInfo[GenericInitiatorAffinityInfoIndex].DeviceNumber = (DomainInfo.DeviceHandle.Pci.PciBdfNumber >> 11) & 0x1F; + DeviceHandlePciInfo[GenericInitiatorAffinityInfoIndex].FunctionNumber = (DomainInfo.DeviceHandle.Pci.PciBdfNumber >> 8) & 0x7; + GenericInitiatorAffinityInfoIndex++; + } + } + + ASSERT (GenericInitiatorAffinityInfoIndex == GenericInitiatorAffinityInfoCount); + + if (GenericInitiatorAffinityInfoCount != 0) { + Desc.ObjectId = CREATE_CM_ARCH_COMMON_OBJECT_ID (EArchCommonObjDeviceHandlePci); + Desc.Size = sizeof (CM_ARCH_COMMON_DEVICE_HANDLE_PCI) * GenericInitiatorAffinityInfoCount; + Desc.Count = GenericInitiatorAffinityInfoCount; + Desc.Data = DeviceHandlePciInfo; + Status = NvAddMultipleCmObjGetTokens (ParserHandle, &Desc, &DeviceHandleTokenMap, NULL); + if (EFI_ERROR (Status)) { + goto CleanupAndReturn; + } + + for (Index = 0; Index < GenericInitiatorAffinityInfoCount; Index++) { + GenericInitiatorAffinityInfo[Index].DeviceHandleToken = DeviceHandleTokenMap[Index]; + } + + Desc.ObjectId = CREATE_CM_ARCH_COMMON_OBJECT_ID (EArchCommonObjGenericInitiatorAffinityInfo); + Desc.Size = sizeof (CM_ARCH_COMMON_GENERIC_INITIATOR_AFFINITY_INFO) * GenericInitiatorAffinityInfoCount; + Desc.Count = GenericInitiatorAffinityInfoCount; + Desc.Data = GenericInitiatorAffinityInfo; + Status = NvAddMultipleCmObjGetTokens (ParserHandle, &Desc, NULL, NULL); + if (EFI_ERROR (Status)) { + goto CleanupAndReturn; + } + } + CleanupAndReturn: return Status; } diff --git a/Silicon/NVIDIA/Library/NumaInfoLib/NumaInfoLib.c b/Silicon/NVIDIA/Library/NumaInfoLib/NumaInfoLib.c index 8b9285fe2e..6f6c879353 100644 --- a/Silicon/NVIDIA/Library/NumaInfoLib/NumaInfoLib.c +++ b/Silicon/NVIDIA/Library/NumaInfoLib/NumaInfoLib.c @@ -460,7 +460,7 @@ NumaInfoLibConstructor ( mNumaInfo[NumaIndex].DeviceHandleType = EFI_ACPI_6_5_PCI_DEVICE_HANDLE; mNumaInfo[NumaIndex].DeviceHandle.Pci.PciBdfNumber = SwapBytes16 (BusNumber << 8 | DeviceNumber << 3 | FunctionNumber); mNumaInfo[NumaIndex].DeviceHandle.Pci.PciSegment = SegmentNumber; - mNumaInfo[NumaIndex].InitiatorDomain = FALSE; + mNumaInfo[NumaIndex].InitiatorDomain = TRUE; mNumaInfo[NumaIndex].TargetDomain = TRUE; NumaIndex++; }