From: "Sami Mujawar" <sami.mujawar@arm.com>
To: <devel@edk2.groups.io>
Cc: Sami Mujawar <sami.mujawar@arm.com>, <Alexei.Fedorov@arm.com>,
<Matteo.Carlini@arm.com>, <Ben.Adderson@arm.com>, <nd@arm.com>
Subject: [PATCH v1 6/8] DynamicTablesPkg: IORT set reference to interrupt array if present
Date: Tue, 15 Jun 2021 17:36:16 +0100 [thread overview]
Message-ID: <20210615163618.85200-7-sami.mujawar@arm.com> (raw)
In-Reply-To: <20210615163618.85200-1-sami.mujawar@arm.com>
The IORT generator is populating the reference field for Context and
PMU interrupts even if their count is zero.
Update the IORT generator to set the references only if the interrupt
count is not 0. Also add checks to ensure a valid reference token has
been provided.
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
---
DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c | 82 +++++++++++++-------
1 file changed, 55 insertions(+), 27 deletions(-)
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c
index bdf839eab25e2b84b40c50da38f2bf961cdc5f42..9ccf72594db378878d4e3abbafe98e749d9963da 100644
--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c
@@ -1136,6 +1136,7 @@ AddSmmuV1V2Nodes (
EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT * ContextInterruptArray;
EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT * PmuInterruptArray;
UINT64 NodeLength;
+ UINT32 Offset;
ASSERT (Iort != NULL);
@@ -1178,47 +1179,74 @@ AddSmmuV1V2Nodes (
SmmuNode->GlobalInterruptArrayRef =
OFFSET_OF (EFI_ACPI_6_0_IO_REMAPPING_SMMU_NODE, SMMU_NSgIrpt);
+ Offset = sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_NODE);
// Context Interrupt
SmmuNode->NumContextInterrupts = NodeList->ContextInterruptCount;
- SmmuNode->ContextInterruptArrayRef =
- sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_NODE);
- ContextInterruptArray =
- (EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT*)((UINT8*)SmmuNode +
- sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_NODE));
+ if (NodeList->ContextInterruptCount != 0) {
+ SmmuNode->ContextInterruptArrayRef = Offset;
+ ContextInterruptArray =
+ (EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT*)((UINT8*)SmmuNode + Offset);
+ Offset += (NodeList->ContextInterruptCount *
+ sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT));
+ }
// PMU Interrupt
SmmuNode->NumPmuInterrupts = NodeList->PmuInterruptCount;
- SmmuNode->PmuInterruptArrayRef = SmmuNode->ContextInterruptArrayRef +
- (NodeList->ContextInterruptCount *
- sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT));
- PmuInterruptArray =
- (EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT*)((UINT8*)SmmuNode +
- SmmuNode->PmuInterruptArrayRef);
+ if (NodeList->PmuInterruptCount != 0) {
+ SmmuNode->PmuInterruptArrayRef = Offset;
+ PmuInterruptArray =
+ (EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT*)((UINT8*)SmmuNode + Offset);
+ }
SmmuNode->SMMU_NSgIrpt = NodeList->SMMU_NSgIrpt;
SmmuNode->SMMU_NSgIrptFlags = NodeList->SMMU_NSgIrptFlags;
SmmuNode->SMMU_NSgCfgIrpt = NodeList->SMMU_NSgCfgIrpt;
SmmuNode->SMMU_NSgCfgIrptFlags = NodeList->SMMU_NSgCfgIrptFlags;
- // Add Context Interrupt Array
- Status = AddSmmuInterruptArray (
- CfgMgrProtocol,
- ContextInterruptArray,
- SmmuNode->NumContextInterrupts,
- NodeList->ContextInterruptToken
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: IORT: Failed to Context Interrupt Array. Status = %r\n",
- Status
- ));
- return Status;
+ if (NodeList->ContextInterruptCount != 0) {
+ if (NodeList->ContextInterruptToken == CM_NULL_TOKEN) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((
+ DEBUG_ERROR,
+ "ERROR: IORT: Invalid Context Interrupt token,"
+ " Token = 0x%x, Status =%r\n",
+ NodeList->ContextInterruptToken,
+ Status
+ ));
+ return Status;
+ }
+
+ // Add Context Interrupt Array
+ Status = AddSmmuInterruptArray (
+ CfgMgrProtocol,
+ ContextInterruptArray,
+ SmmuNode->NumContextInterrupts,
+ NodeList->ContextInterruptToken
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "ERROR: IORT: Failed to Context Interrupt Array. Status = %r\n",
+ Status
+ ));
+ return Status;
+ }
}
// Add PMU Interrupt Array
- if ((SmmuNode->NumPmuInterrupts > 0) &&
- (NodeList->PmuInterruptToken != CM_NULL_TOKEN)) {
+ if (SmmuNode->NumPmuInterrupts != 0) {
+ if (NodeList->PmuInterruptToken == CM_NULL_TOKEN) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((
+ DEBUG_ERROR,
+ "ERROR: IORT: Invalid PMU Interrupt token,"
+ " Token = 0x%x, Status =%r\n",
+ NodeList->PmuInterruptToken,
+ Status
+ ));
+ return Status;
+ }
+
Status = AddSmmuInterruptArray (
CfgMgrProtocol,
PmuInterruptArray,
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
next prev parent reply other threads:[~2021-06-15 16:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-15 16:36 [PATCH v1 0/8] IORT Rev E.b specification updates Sami Mujawar
2021-06-15 16:36 ` [PATCH v1 1/8] MdePkg: Fix IORT header file include guard Sami Mujawar
2021-06-15 16:36 ` [PATCH v1 2/8] MdePkg: IORT header update for IORT Rev E.b spec Sami Mujawar
2021-06-15 16:36 ` [PATCH v1 3/8] ShellPkg: Acpiview: Abbreviate field names to preserve alignment Sami Mujawar
2021-06-15 16:36 ` [PATCH v1 4/8] ShellPkg: Acpiview: IORT parser update for IORT Rev E.b spec Sami Mujawar
2021-06-15 16:36 ` [PATCH v1 5/8] DynamicTablesPkg: IORT set reference to Id array only if present Sami Mujawar
2021-06-15 16:36 ` Sami Mujawar [this message]
2021-06-15 16:36 ` [PATCH v1 7/8] DynamicTablesPkg: Update ArmNameSpaceObjects for IORT Rev E.b Sami Mujawar
2021-06-15 16:36 ` [PATCH v1 8/8] DynamicTablesPkg: IORT generator updates for Rev E.b spec Sami Mujawar
[not found] ` <1688CEC74013EBBF.1864@groups.io>
2021-06-16 18:56 ` [edk2-devel] [PATCH v1 2/8] MdePkg: IORT header update for IORT " Sami Mujawar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210615163618.85200-7-sami.mujawar@arm.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox