Skip to content

Commit

Permalink
feat: Add GPU generic initiator support
Browse files Browse the repository at this point in the history
Create SRAT nodes for the GPU domains and make sure HMAT and SLIT
reflect this as well.

Reviewed-by: Swatisri Kantamsetti <swatisrik@nvidia.com>
Reviewed-by: Ashish Singhal <ashishsingha@nvidia.com>
Tested-by: Jeff Brasen <jbrasen@nvidia.com>
Reviewed-by: Jake Garver <jake@nvidia.com>
Tested-by: Jake Garver <jake@nvidia.com>
  • Loading branch information
jbrasen authored and jgarver committed Dec 12, 2024
1 parent 61b3d09 commit c3ec321
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion Silicon/NVIDIA/Library/NumaInfoLib/NumaInfoLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand Down

0 comments on commit c3ec321

Please sign in to comment.