Skip to content

Commit 4864e18

Browse files
committed
UefiCpuPkg/RiscVIoMmuDxe: Cleanup driver relative to platform protocol
Signed-off-by: Benjamin Doron <benjamin.doron@9elements.com>
1 parent 16939bb commit 4864e18

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

UefiCpuPkg/RiscVIoMmuDxe/IoMmuDetection.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ IoMmuDeviceTreeDiscovery (
237237

238238
//
239239
// Now, gather all the downstreams. Perform this separately to avoid excessive nesting.
240-
// - TODO: Look for platform devices.
241240
//
242241
DownstreamDeviceNode = FdtNextNode (Fdt, -1, NULL);
243242
while (DownstreamDeviceNode != -FDT_ERR_NOTFOUND) {
@@ -246,6 +245,11 @@ IoMmuDeviceTreeDiscovery (
246245
goto NextDownstreamDeviceNode;
247246
}
248247

248+
//
249+
// As the DevicePath on the DeviceHandle passed to IoMmuSetAttribute() isn't standardised
250+
// for platform devices, we've elected to create the EDKII_RISC_V_IO_MMU_PLATFORM_POLICY_PROTOCOL hook.
251+
// Even with information in the FDT/ACPI, this is unimplementable, because we can't construct a device_id.
252+
//
249253
if (!FdtStringListContains (PropertyPtr, TempLen, "pci-host-ecam-generic") && !FdtStringListContains (PropertyPtr, TempLen, "pci-host-cam-generic")) {
250254
goto NextDownstreamDeviceNode;
251255
}
@@ -320,7 +324,6 @@ IoMmuAcpiRimtDiscovery (
320324
EFI_ACPI_6_6_RIMT_PCIE_ROOT_COMPLEX_NODE_STRUCTURE *RimtPcieNode;
321325
UINT16 NumberOfIdMappings;
322326
EFI_ACPI_6_6_RIMT_ID_MAPPING_STRUCTURE *NodeMapping;
323-
//EFI_ACPI_6_6_RIMT_PLATFORM_DEVICE_NODE_STRUCTURE *RimtPlatformNode;
324327
UINTN MappingIndex;
325328
LIST_ENTRY *Link;
326329
RISCV_IOMMU_DOWNSTREAMS *IoMmuDownstreams;
@@ -371,20 +374,19 @@ IoMmuAcpiRimtDiscovery (
371374
goto NodeEnd;
372375
}
373376

374-
if (RimtNodeHeader->Type == RimtNodePcieRc) {
375-
RimtPcieNode = (VOID *)RimtNodeHeader;
376-
NumberOfIdMappings = RimtPcieNode->NumberOfIdMappings;
377-
NodeMapping = (VOID *)((UINT8 *)RimtPcieNode + RimtPcieNode->IdMappingArrayOffset);
378-
} else {
379-
// TODO: Look for platform devices properly.
377+
//
378+
// As the DevicePath on the DeviceHandle passed to IoMmuSetAttribute() isn't standardised
379+
// for platform devices, we've elected to create the EDKII_RISC_V_IO_MMU_PLATFORM_POLICY_PROTOCOL hook.
380+
// Even with information in the FDT/ACPI, this is unimplementable, because we can't construct a device_id.
381+
//
382+
if (RimtNodeHeader->Type != RimtNodePcieRc) {
380383
goto NodeEnd;
381-
#if 0
382-
RimtPlatformNode = (VOID *)RimtNodeHeader;
383-
NumberOfIdMappings = RimtPlatformNode->NumberOfIdMappings;
384-
NodeMapping = (VOID *)((UINT8 *)RimtPlatformNode + RimtPlatformNode->IdMappingArrayOffset);
385-
#endif
386384
}
387385

386+
RimtPcieNode = (VOID *)RimtNodeHeader;
387+
NumberOfIdMappings = RimtPcieNode->NumberOfIdMappings;
388+
NodeMapping = (VOID *)((UINT8 *)RimtPcieNode + RimtPcieNode->IdMappingArrayOffset);
389+
388390
for (MappingIndex = 0; MappingIndex < NumberOfIdMappings; MappingIndex++) {
389391
for (Link = GetFirstNode (&mRiscVIoMmuContexts)
390392
; !IsNull (&mRiscVIoMmuContexts, Link)

UefiCpuPkg/RiscVIoMmuDxe/IoMmuDeviceContext.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** @file
2-
RISC-V IOMMU driver.
2+
RISC-V IOMMU device context construction.
33
44
Copyright (c) 2025, 9elements GmbH. All rights reserved.<BR>
55
SPDX-License-Identifier: BSD-2-Clause-Patent

UefiCpuPkg/RiscVIoMmuDxe/IoMmuProtocol.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ IoMmuSetAttribute (
250250

251251
//
252252
// Discover which IOMMU this device_id is behind through its context's downstreams.
253-
// - TODO: MapMask handling.
254253
//
255254
for (Link = GetFirstNode (&mRiscVIoMmuContexts)
256255
; !IsNull (&mRiscVIoMmuContexts, Link)
@@ -263,7 +262,7 @@ IoMmuSetAttribute (
263262
) {
264263
IoMmuDownstreams = RISCV_IOMMU_DOWNSTREAMS_FROM_LINK (DownstreamLink);
265264
if ((IoMmuDeviceId.Uint32 >= IoMmuDownstreams->NodeMapping.SourceIdBase) && (IoMmuDeviceId.Uint32 < (IoMmuDownstreams->NodeMapping.SourceIdBase + IoMmuDownstreams->NodeMapping.NumberOfIDs))) {
266-
MappedIoMmuDeviceId.Uint32 = IoMmuDownstreams->NodeMapping.DestinationDeviceIdBase + (IoMmuDeviceId.Uint32 - IoMmuDownstreams->NodeMapping.SourceIdBase);
265+
MappedIoMmuDeviceId.Uint32 = (IoMmuDownstreams->NodeMapping.DestinationDeviceIdBase + (IoMmuDeviceId.Uint32 - IoMmuDownstreams->NodeMapping.SourceIdBase)) & IoMmuDownstreams->MapMask;
267266
goto Work;
268267
}
269268
}

UefiCpuPkg/RiscVIoMmuDxe/IoMmuQueues.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** @file
2-
RISC-V IOMMU driver.
2+
RISC-V IOMMU command and fault queue handling.
33
44
Copyright (c) 2025, 9elements GmbH. All rights reserved.<BR>
55
SPDX-License-Identifier: BSD-2-Clause-Patent

0 commit comments

Comments
 (0)