From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.51318.1643736171100978297 for ; Tue, 01 Feb 2022 09:22:51 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: pierre.gondois@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C5DEE11FB; Tue, 1 Feb 2022 09:22:50 -0800 (PST) Received: from e126645.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 658B53F40C; Tue, 1 Feb 2022 09:22:49 -0800 (PST) From: "PierreGondois" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Sami Mujawar , Rebecca Cran , Pierre Gondois Subject: [PATCH v5 4/9] DynamicTablesPkg: AcpiSsdtPcieLibArm: Remove link device generation Date: Tue, 1 Feb 2022 18:22:47 +0100 Message-Id: <20220201172252.799725-5-Pierre.Gondois@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220201172252.799725-1-Pierre.Gondois@arm.com> References: <20220201172252.799725-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Pierre Gondois In ACPI 6.4, s6.2.13, _PRT objects describing PCI legacy interrupts can be defined following 2 models. In the first model, _PRT entries reference link devices. Link devices then describe interrupts. This allows to dynamically modify interrupts through _SRS and _PRS objects and to choose exactly the interrupt type (level/edge triggered, active high/low). In the second model, interrupt numbder are described in the _PRT entry. The interrupt type is then assumed by the OS. The Arm BSA, sE.6 "Legacy interrupts" states that PCI legacy interrupts must be converted to SPIs, and programmed level-sensitive, active high. Thus any OS must configure interrupts as such and there is no need to specify the interrupt type. Plus it is not possible to dynamically configure PCI interrupts. Thus remove the link device generation and use the second model for _PRT. Suggested-by: Ard Biesheuvel Signed-off-by: Pierre Gondois --- Notes: v4: - New patch. [Ard] .../AcpiSsdtPcieLibArm/SsdtPcieGenerator.c | 239 +----------------- .../AcpiSsdtPcieLibArm/SsdtPcieGenerator.h | 64 +---- 2 files changed, 15 insertions(+), 288 deletions(-) diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPci= eGenerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtP= cieGenerator.c index 3e22587d4a25..a34018151f2d 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenera= tor.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenera= tor.c @@ -1,7 +1,7 @@ /** @file SSDT Pcie Table Generator. =20 - Copyright (c) 2021, Arm Limited. All rights reserved.
+ Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -12,6 +12,7 @@ - s6.1.1 "_ADR (Address)" - linux kernel code - Arm Base Boot Requirements v1.0 + - Arm Base System Architecture v1.0 **/ =20 #include @@ -279,171 +280,6 @@ GeneratePciDeviceInfo ( return Status; } =20 -/** Generate a Link device. - - The Link device is added at the beginning of the ASL Pci device defini= tion. - - Each Link device represents a Pci legacy interrupt (INTA-...-INTD). - - ASL code: - Device () { - Name (_UID, ]) - Name (_HID, EISAID ("PNP0C0F")) - Name (CRS0, ResourceTemplate () { - Interrupt (ResourceProducer, Level, ActiveHigh, Exclusive) { = ] } - }) - Method (_CRS, 0) { - Return CRS0 - }) - Method (_DIS) { } - } - - The list of objects to define is available at: - PCI Firmware Specification - Revision 3.3, - s3.5. "Device State at Firmware/Operating System Handoff" - - The _PRS and _SRS are not supported, cf Arm Base Boot Requirements v1.= 0: - "The _PRS (Possible Resource Settings) and _SRS (Set Resource Settings= ) - are not supported." - - @param [in] Irq Interrupt controller interrupt. - @param [in] IrqFlags Interrupt flags. - @param [in] LinkIndex Legacy Pci interrupt index. - Must be between 0-INTA and 3-INTD. - @param [in, out] PciNode Pci node to amend. - - @retval EFI_SUCCESS Success. - @retval EFI_INVALID_PARAMETER Invalid parameter. - @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. -**/ -STATIC -EFI_STATUS -EFIAPI -GenerateLinkDevice ( - IN UINT32 Irq, - IN UINT32 IrqFlags, - IN UINT32 LinkIndex, - IN OUT AML_OBJECT_NODE_HANDLE PciNode - ) -{ - EFI_STATUS Status; - CHAR8 AslName[AML_NAME_SEG_SIZE + 1]; - AML_OBJECT_NODE_HANDLE LinkNode; - AML_OBJECT_NODE_HANDLE CrsNode; - UINT32 EisaId; - - ASSERT (LinkIndex < 4); - ASSERT (PciNode !=3D NULL); - - CopyMem (AslName, "LNKx", AML_NAME_SEG_SIZE + 1); - AslName[AML_NAME_SEG_SIZE - 1] =3D 'A' + LinkIndex; - - // ASL: Device (LNKx) {} - Status =3D AmlCodeGenDevice (AslName, NULL, &LinkNode); - if (EFI_ERROR (Status)) { - ASSERT (0); - return Status; - } - - Status =3D AmlAttachNode (PciNode, LinkNode); - if (EFI_ERROR (Status)) { - ASSERT (0); - // Failed to add. - AmlDeleteTree ((AML_NODE_HANDLE)LinkNode); - return Status; - } - - // ASL: Name (_UID, ) - Status =3D AmlCodeGenNameInteger ("_UID", LinkIndex, LinkNode, NULL); - if (EFI_ERROR (Status)) { - ASSERT (0); - return Status; - } - - // ASL: Name (_HID, EISAID ("PNP0C0F")) - Status =3D AmlGetEisaIdFromString ("PNP0C0F", &EisaId); - if (EFI_ERROR (Status)) { - ASSERT (0); - return Status; - } - - Status =3D AmlCodeGenNameInteger ("_HID", EisaId, LinkNode, NULL); - if (EFI_ERROR (Status)) { - ASSERT (0); - return Status; - } - - // ASL: - // Name (CRS0, ResourceTemplate () { - // Interrupt (ResourceProducer, Level, ActiveHigh, Exclusive) { } - // }) - Status =3D AmlCodeGenNameResourceTemplate ("CRS0", LinkNode, &CrsNode)= ; - if (EFI_ERROR (Status)) { - ASSERT (0); - return Status; - } - - Status =3D AmlCodeGenRdInterrupt ( - FALSE, - (IrqFlags & BIT0) !=3D 0, - (IrqFlags & BIT1) !=3D 0, - FALSE, - &Irq, - 1, - CrsNode, - NULL - ); - if (EFI_ERROR (Status)) { - ASSERT (0); - return Status; - } - - // ASL: - // Method (_CRS, 0) { - // Return (CRS0) - // } - Status =3D AmlCodeGenMethodRetNameString ( - "_CRS", - "CRS0", - 0, - FALSE, - 0, - LinkNode, - NULL - ); - if (EFI_ERROR (Status)) { - ASSERT (0); - return Status; - } - - // ASL:Method (_DIS, 1) {} - // Not possible to disable interrupts. - Status =3D AmlCodeGenMethodRetNameString ( - "_DIS", - NULL, - 0, - FALSE, - 0, - LinkNode, - NULL - ); - if (EFI_ERROR (Status)) { - ASSERT (0); - return Status; - } - - // _STA: - // ACPI 6.4, s6.3.7 "_STA (Device Status)": - // If a device object describes a device that is not on an enumerable = bus - // and the device object does not have an _STA object, then OSPM assum= es - // that the device is present, enabled, shown in the UI, and functioni= ng. - - // _MAT: - // Not supported. Mainly used for processors. - - return Status; -} - /** Generate Pci slots devices. =20 PCI Firmware Specification - Revision 3.3, @@ -556,14 +392,10 @@ GeneratePrt ( { EFI_STATUS Status; INT32 Index; - UINT32 IrqTableIndex; AML_OBJECT_NODE_HANDLE PrtNode; - CHAR8 AslName[AML_NAME_SEG_SIZE + 1]; CM_ARM_OBJ_REF *RefInfo; UINT32 RefCount; CM_ARM_PCI_INTERRUPT_MAP_INFO *IrqMapInfo; - UINT32 IrqFlags; - UINT32 PrevIrqFlags; =20 ASSERT (Generator !=3D NULL); ASSERT (CfgMgrProtocol !=3D NULL); @@ -585,13 +417,6 @@ GeneratePrt ( return Status; } =20 - // Initialized IrqTable. - Status =3D MappingTableInitialize (&Generator->IrqTable, RefCount); - if (EFI_ERROR (Status)) { - ASSERT (0); - return Status; - } - // Initialized DeviceTable. Status =3D MappingTableInitialize (&Generator->DeviceTable, RefCount); if (EFI_ERROR (Status)) { @@ -606,8 +431,6 @@ GeneratePrt ( goto exit_handler; } =20 - CopyMem (AslName, "LNKx", AML_NAME_SEG_SIZE + 1); - for (Index =3D 0; Index < RefCount; Index++) { // Get CM_ARM_PCI_INTERRUPT_MAP_INFO structures one by one. Status =3D GetEArmObjPciInterruptMapInfo ( @@ -621,25 +444,15 @@ GeneratePrt ( goto exit_handler; } =20 - // Add the interrupt in the IrqTable and get the link name. - IrqTableIndex =3D MappingTableAdd ( - &Generator->IrqTable, - IrqMapInfo->IntcInterrupt.Interrupt - ); - if (IrqTableIndex >=3D MAX_PCI_LEGACY_INTERRUPT) { - ASSERT (0); - Status =3D EFI_INVALID_PARAMETER; - goto exit_handler; - } - - AslName[AML_NAME_SEG_SIZE - 1] =3D 'A' + IrqTableIndex; - - // Check that the interrupts flags are identical for all interrupts. - PrevIrqFlags =3D IrqFlags; - IrqFlags =3D IrqMapInfo->IntcInterrupt.Flags; - if ((Index > 0) && (PrevIrqFlags !=3D IrqFlags)) { - ASSERT (0); + // Check that the interrupts flags are SPIs, level high. + // Cf. Arm BSA v1.0, sE.6 "Legacy interrupts" + if ((Index > 0) && + (IrqMapInfo->IntcInterrupt.Interrupt >=3D 32) && + (IrqMapInfo->IntcInterrupt.Interrupt < 1020) && + ((IrqMapInfo->IntcInterrupt.Flags & 0x3) !=3D BIT0)) + { Status =3D EFI_INVALID_PARAMETER; + ASSERT_EFI_ERROR (Status); goto exit_handler; } =20 @@ -662,8 +475,8 @@ GeneratePrt ( Status =3D AmlAddPrtEntry ( (IrqMapInfo->PciDevice << 16) | 0xFFFF, IrqMapInfo->PciInterrupt, - AslName, - 0, + NULL, + IrqMapInfo->IntcInterrupt.Interrupt, PrtNode ); if (EFI_ERROR (Status)) { @@ -672,24 +485,10 @@ GeneratePrt ( } } // for =20 - // Generate the LNKx devices now that we know all the interrupts used. - for (Index =3D 0; Index < Generator->IrqTable.LastIndex; Index++) { - Status =3D GenerateLinkDevice ( - Generator->IrqTable.Table[Index], - IrqFlags, - Index, - PciNode - ); - if (EFI_ERROR (Status)) { - ASSERT (0); - goto exit_handler; - } - } // for - - // Attach the _PRT entry now, after the LNKx devices. + // Attach the _PRT entry. Status =3D AmlAttachNode (PciNode, PrtNode); if (EFI_ERROR (Status)) { - ASSERT (0); + ASSERT_EFI_ERROR (Status); goto exit_handler; } =20 @@ -705,7 +504,6 @@ GeneratePrt ( exit_handler: MappingTableFree (&Generator->DeviceTable); exit_handler0: - MappingTableFree (&Generator->IrqTable); if (PrtNode !=3D NULL) { AmlDeleteTree (PrtNode); } @@ -1382,15 +1180,6 @@ ACPI_PCI_GENERATOR SsdtPcieGenerator =3D { =20 // Private fields are defined from here. =20 - // IrqTable - { - // Table - NULL, - // LastIndex - 0, - // MaxIndex - 0 - }, // DeviceTable { // Table diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPci= eGenerator.h b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtP= cieGenerator.h index d1e5465e1346..59a0d601a36d 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenera= tor.h +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenera= tor.h @@ -33,12 +33,6 @@ */ #define MAX_PCI_ROOT_COMPLEXES_SUPPORTED 16 =20 -/** Maximum number of Pci legacy interrupts. - - Currently 4 for INTA-INTB-INTC-INTD. -*/ -#define MAX_PCI_LEGACY_INTERRUPT 4 - // _SB scope of the AML namespace. #define SB_SCOPE "\\_SB_" =20 @@ -73,64 +67,8 @@ typedef struct AcpiPcieGenerator { =20 // Private fields are defined from here. =20 - /** A structure used to handle the Address and Interrupt Map referenci= ng. - - A CM_ARM_PCI_CONFIG_SPACE_INFO structure references two CM_ARM_OBJ_R= EF: - - one for the address mapping, referencing - CM_ARM_PCI_ADDRESS_MAP_INFO structures. - - one for the interrupt mapping, referencing - CM_ARM_PCI_INTERRUPT_MAP_INFO structures. - - Example: - (Pci0) - CM_ARM_PCI_CONFIG_SPACE_INFO - | - +---------------------------------------- - | | - v v - CM_ARM_OBJ_REF CM_ARM_OBJ_REF - (List of references to (List of references to - address mappings) interrupt mappings) - | | - v v - CM_ARM_PCI_ADDRESS_MAP_INFO[0..N] CM_ARM_PCI_INTERRUPT_MAP_INFO= [0..M] - (A list of address mappings) (A list of interrupt mappings= ) - - The CM_ARM_PCI_INTERRUPT_MAP_INFO objects cannot be handled individu= ally. - Device's Pci legacy interrupts that are mapped to the same CPU inter= rupt - are grouped under a Link device. - For instance, the following mapping: - - [INTA of device 0] mapped on [GIC irq 168] - - [INTB of device 1] mapped on [GIC irq 168] - will be represented in an SSDT table as: - - [INTA of device 0] mapped on [Link device A] - - [INTB of device 1] mapped on [Link device A] - - [Link device A] mapped on [GIC irq 168] - - Counting the number of Cpu interrupts used and grouping them in Link - devices is done through this IRQ_TABLE. - - ASL code: - Scope (_SB) { - Device (LNKA) { - [...] - Name (_PRS, ResourceTemplate () { - Interrupt (ResourceProducer, Level, ActiveHigh, Exclusive) { 1= 68 } - }) - } - - Device (PCI0) { - Name (_PRT, Package () { - Package (0x0FFFF, 0, LNKA, 0) // INTA of device 0 <-> LNKA - Package (0x1FFFF, 1, LNKA, 0) // INTB of device 1 <-> LNKA - }) - } - } - */ - MAPPING_TABLE IrqTable; - /// Table to map: Index <-> Pci device - MAPPING_TABLE DeviceTable; + MAPPING_TABLE DeviceTable; } ACPI_PCI_GENERATOR; =20 #pragma pack() --=20 2.25.1