From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by mx.groups.io with SMTP id smtpd.web11.1020.1574880274512452919 for ; Wed, 27 Nov 2019 10:44:34 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=a3Pnhbjg; spf=pass (domain: linaro.org, ip: 209.85.221.65, mailfrom: ard.biesheuvel@linaro.org) Received: by mail-wr1-f65.google.com with SMTP id j42so2075092wrj.12 for ; Wed, 27 Nov 2019 10:44:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ST44S1bB/ANW7Si/F4VshaVCxfLWL2NEnwi6hl+EH2o=; b=a3PnhbjguVyTZfeGz6MFvMECJreU56M5GSa3f7xz0pp+QwrkTvsrH7iaWFmZsrPZ7P JkV3v+u5dcZA/FcQtjZL6Hc+2vM0ENzPa5L2Se6iKAQoT5yWFApMm94eY1stSbq4HRxh RjWNdaH8msrxgcbAsZiw9tbn7nVRfrAHL2nVuCKZHSFd+MrUfYWEdD/XXmnErgxAKIby HX5dYefZ35RoBSnPROnVahc10j7TyaT9H7SF3xbdSfUgilbFrNiNxXDdPbNbxX4WZucJ juqV2NsGhKnxirh6J7jxO+W7wm6wkQmfoWUGqNpxrbEoiLjthwFOiymH9oPSucQyiF4u KMMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ST44S1bB/ANW7Si/F4VshaVCxfLWL2NEnwi6hl+EH2o=; b=icgg0Pu8slCOwAg56gHIc+YYvnN1dBkjBWzXA0rPz1l58yyRIftu60x+a4hkGnwiyK ZMGqr5pAuYVhR0HMXQhCjnynIcP43Jir+nWVXyBT60FHcEADbp3t+fFvbg5sWrhfjqOQ 6mKNqVPn2vCyvGk9yUxnr8iX3MJsqRpho9uV4ooquD4ADPiQ1bTCHKD9rWoMRku2BZh/ 4rfvfBfgjbGFixKRTItuoOd/5gnFvN7jVnpqsLFunxEYMni2NnzYv8/bgF31Z7JYs5DE NDyzk5qYcdLejDRoVq+VTAYWvhz0txUBh2fkim++myCceL7rAZSv5g0d4vP91CPRjF2o WFKQ== X-Gm-Message-State: APjAAAWeBOEBqTuFN9W2wlkSNvdDax0fKeq/i1ul20zYmLRO21sGwjnT EezqYernCY6qJq546BUkXFYbiEjhyS4= X-Google-Smtp-Source: APXvYqx1inLjIS0YP4cMMvD3KJC9L5NrVE1ebWYFnUgKBx072aEpDxZihnfUaWj5uxiypbnoTT1SRg== X-Received: by 2002:adf:c611:: with SMTP id n17mr45258641wrg.317.1574880272834; Wed, 27 Nov 2019 10:44:32 -0800 (PST) Return-Path: Received: from e123331-lin.home (amontpellier-657-1-18-247.w109-210.abo.wanadoo.fr. [109.210.65.247]) by smtp.gmail.com with ESMTPSA id f67sm7947741wme.16.2019.11.27.10.44.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 10:44:32 -0800 (PST) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: leif.lindholm@linaro.org, Ard Biesheuvel Subject: [PATCH edk2-platforms v2 4/8] Silicon/AMD/Styx: clean up stream ID mappings for SMMU Date: Wed, 27 Nov 2019 19:44:35 +0100 Message-Id: <20191127184439.16793-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191127184439.16793-1-ard.biesheuvel@linaro.org> References: <20191127184439.16793-1-ard.biesheuvel@linaro.org> Tighten the stream ID mappings for the SMMU to only cover the stream IDs that are actually being issued by the respective masters. This is mostly just a cleanup exercise, since specifying unused stream IDs does not typically create any problems. However, the CCP crypto accelerator on B1 silicon actually uses stream IDs that we assigned to the second SATA controller, so there this actually fixes a problem. Since the crypto accelerator shares its SMMU with the second AHCI controller, we can drop the logic that hides the associated IORT node when running on B0 silicon. Signed-off-by: Ard Biesheuvel Acked-by: Leif Lindholm --- Silicon/AMD/Styx/Drivers/AcpiPlatformDxe/AcpiPlatform.c | 5 - Silicon/AMD/Styx/Drivers/AcpiPlatformDxe/Iort.aslc | 117 ++++---------------- 2 files changed, 22 insertions(+), 100 deletions(-) diff --git a/Silicon/AMD/Styx/Drivers/AcpiPlatformDxe/AcpiPlatform.c b/Silicon/AMD/Styx/Drivers/AcpiPlatformDxe/AcpiPlatform.c index 743ef0f65523..7c267542db19 100644 --- a/Silicon/AMD/Styx/Drivers/AcpiPlatformDxe/AcpiPlatform.c +++ b/Silicon/AMD/Styx/Drivers/AcpiPlatformDxe/AcpiPlatform.c @@ -123,7 +123,6 @@ InstallSystemDescriptionTables ( UINTN TableSize; UINTN TableHandle; EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLE *Gtdt; - EFI_ACPI_6_0_IO_REMAPPING_TABLE *Iort; EFI_ACPI_5_1_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER *Madt; EFI_ACPI_5_1_GIC_STRUCTURE *GicC; UINT8 MacPackage[sizeof(mDefaultMacPackageA)]; @@ -177,10 +176,6 @@ InstallSystemDescriptionTables ( if (!PcdGetBool (PcdEnableSmmus)) { continue; } - if ((CpuId & STYX_SOC_VERSION_MASK) < STYX_SOC_VERSION_B1) { - Iort = (EFI_ACPI_6_0_IO_REMAPPING_TABLE *)Table; - Iort->NumNodes -= 2; - } break; case EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE: diff --git a/Silicon/AMD/Styx/Drivers/AcpiPlatformDxe/Iort.aslc b/Silicon/AMD/Styx/Drivers/AcpiPlatformDxe/Iort.aslc index d46be49f0318..7bdc34f6737e 100644 --- a/Silicon/AMD/Styx/Drivers/AcpiPlatformDxe/Iort.aslc +++ b/Silicon/AMD/Styx/Drivers/AcpiPlatformDxe/Iort.aslc @@ -46,7 +46,7 @@ typedef struct { typedef struct { EFI_ACPI_6_0_IO_REMAPPING_NAMED_COMP_NODE Node; CONST CHAR8 Name[11]; - EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE RcIdMapping[32]; + EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE RcIdMapping[16]; } STYX_NC_NODE; typedef struct { @@ -63,6 +63,7 @@ typedef struct { STYX_NC_NODE Sata0NamedNode; STYX_SMMU_NODE Sata1SmmuNode; STYX_NC_NODE Sata1NamedNode; + STYX_NC_NODE CcpNamedNode; } STYX_IO_REMAPPING_STRUCTURE; #define __STYX_SMMU_NODE(Base, Size, Irq) \ @@ -114,14 +115,18 @@ typedef struct { EFI_ACPI_IORT_ID_MAPPING_FLAGS_SINGLE \ } -#define __STYX_NAMED_COMPONENT_NODE(Name) \ +#define __STYX_NUM_NODES(Type) \ + ((sizeof(Type) - FIELD_OFFSET(Type, RcIdMapping)) / \ + sizeof(EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE)) + +#define __STYX_NAMED_COMPONENT_NODE(Name, Num) \ { \ { \ EFI_ACPI_IORT_TYPE_NAMED_COMP, \ sizeof(STYX_NC_NODE), \ 0x0, \ 0x0, \ - 0x20, \ + Num, \ FIELD_OFFSET(STYX_NC_NODE, RcIdMapping), \ }, \ 0x0, \ @@ -139,7 +144,7 @@ STATIC STYX_IO_REMAPPING_STRUCTURE AcpiIort = { AMD_ACPI_HEADER(EFI_ACPI_6_0_IO_REMAPPING_TABLE_SIGNATURE, STYX_IO_REMAPPING_STRUCTURE, EFI_ACPI_IO_REMAPPING_TABLE_REVISION), - 10, // NumNodes + 11, // NumNodes sizeof(EFI_ACPI_6_0_IO_REMAPPING_TABLE), // NodeOffset 0 // Reserved }, { @@ -175,7 +180,7 @@ STATIC STYX_IO_REMAPPING_STRUCTURE AcpiIort = { STYX_ETH0_SMMU_INTERRUPT) }, { // Eth0NamedNode - __STYX_NAMED_COMPONENT_NODE("\\_SB_.ETH0"), + __STYX_NAMED_COMPONENT_NODE("\\_SB_.ETH0", 16), { __STYX_ID_MAPPING_SINGLE(0x00, Eth0SmmuNode), __STYX_ID_MAPPING_SINGLE(0x01, Eth0SmmuNode), @@ -185,14 +190,6 @@ STATIC STYX_IO_REMAPPING_STRUCTURE AcpiIort = { __STYX_ID_MAPPING_SINGLE(0x05, Eth0SmmuNode), __STYX_ID_MAPPING_SINGLE(0x06, Eth0SmmuNode), __STYX_ID_MAPPING_SINGLE(0x07, Eth0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x08, Eth0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x09, Eth0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x0A, Eth0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x0B, Eth0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x0C, Eth0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x0D, Eth0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x0E, Eth0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x0F, Eth0SmmuNode), __STYX_ID_MAPPING_SINGLE(0x10, Eth0SmmuNode), __STYX_ID_MAPPING_SINGLE(0x11, Eth0SmmuNode), __STYX_ID_MAPPING_SINGLE(0x12, Eth0SmmuNode), @@ -201,14 +198,6 @@ STATIC STYX_IO_REMAPPING_STRUCTURE AcpiIort = { __STYX_ID_MAPPING_SINGLE(0x15, Eth0SmmuNode), __STYX_ID_MAPPING_SINGLE(0x16, Eth0SmmuNode), __STYX_ID_MAPPING_SINGLE(0x17, Eth0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x18, Eth0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x19, Eth0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x1A, Eth0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x1B, Eth0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x1C, Eth0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x1D, Eth0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x1E, Eth0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x1F, Eth0SmmuNode), } }, { // Eth1SmmuNode @@ -217,7 +206,7 @@ STATIC STYX_IO_REMAPPING_STRUCTURE AcpiIort = { STYX_ETH1_SMMU_INTERRUPT) }, { // Eth1NamedNode - __STYX_NAMED_COMPONENT_NODE("\\_SB_.ETH1"), + __STYX_NAMED_COMPONENT_NODE("\\_SB_.ETH1", 16), { __STYX_ID_MAPPING_SINGLE(0x00, Eth1SmmuNode), __STYX_ID_MAPPING_SINGLE(0x01, Eth1SmmuNode), @@ -227,14 +216,6 @@ STATIC STYX_IO_REMAPPING_STRUCTURE AcpiIort = { __STYX_ID_MAPPING_SINGLE(0x05, Eth1SmmuNode), __STYX_ID_MAPPING_SINGLE(0x06, Eth1SmmuNode), __STYX_ID_MAPPING_SINGLE(0x07, Eth1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x08, Eth1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x09, Eth1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x0A, Eth1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x0B, Eth1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x0C, Eth1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x0D, Eth1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x0E, Eth1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x0F, Eth1SmmuNode), __STYX_ID_MAPPING_SINGLE(0x10, Eth1SmmuNode), __STYX_ID_MAPPING_SINGLE(0x11, Eth1SmmuNode), __STYX_ID_MAPPING_SINGLE(0x12, Eth1SmmuNode), @@ -243,14 +224,6 @@ STATIC STYX_IO_REMAPPING_STRUCTURE AcpiIort = { __STYX_ID_MAPPING_SINGLE(0x15, Eth1SmmuNode), __STYX_ID_MAPPING_SINGLE(0x16, Eth1SmmuNode), __STYX_ID_MAPPING_SINGLE(0x17, Eth1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x18, Eth1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x19, Eth1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x1A, Eth1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x1B, Eth1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x1C, Eth1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x1D, Eth1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x1E, Eth1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x1F, Eth1SmmuNode), } }, { // Sata0SmmuNode @@ -259,40 +232,14 @@ STATIC STYX_IO_REMAPPING_STRUCTURE AcpiIort = { STYX_SATA0_SMMU_INTERRUPT) }, { // Sata0NamedNode - __STYX_NAMED_COMPONENT_NODE("\\_SB_.AHC0"), + __STYX_NAMED_COMPONENT_NODE("\\_SB_.AHC0", 6), { - __STYX_ID_MAPPING_SINGLE(0x00, Sata0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x01, Sata0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x02, Sata0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x03, Sata0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x04, Sata0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x05, Sata0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x06, Sata0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x07, Sata0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x08, Sata0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x09, Sata0SmmuNode), __STYX_ID_MAPPING_SINGLE(0x0A, Sata0SmmuNode), __STYX_ID_MAPPING_SINGLE(0x0B, Sata0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x0C, Sata0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x0D, Sata0SmmuNode), __STYX_ID_MAPPING_SINGLE(0x0E, Sata0SmmuNode), __STYX_ID_MAPPING_SINGLE(0x0F, Sata0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x10, Sata0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x11, Sata0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x12, Sata0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x13, Sata0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x14, Sata0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x15, Sata0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x16, Sata0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x17, Sata0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x18, Sata0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x19, Sata0SmmuNode), __STYX_ID_MAPPING_SINGLE(0x1A, Sata0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x1B, Sata0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x1C, Sata0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x1D, Sata0SmmuNode), __STYX_ID_MAPPING_SINGLE(0x1E, Sata0SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x1F, Sata0SmmuNode), } }, { // Sata1SmmuNode @@ -301,40 +248,20 @@ STATIC STYX_IO_REMAPPING_STRUCTURE AcpiIort = { STYX_SATA1_SMMU_INTERRUPT) }, { // Sata1NamedNode - __STYX_NAMED_COMPONENT_NODE("\\_SB_.AHC1"), + __STYX_NAMED_COMPONENT_NODE("\\_SB_.AHC1", 3), { - __STYX_ID_MAPPING_SINGLE(0x00, Sata1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x01, Sata1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x02, Sata1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x03, Sata1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x04, Sata1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x05, Sata1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x06, Sata1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x07, Sata1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x08, Sata1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x09, Sata1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x0A, Sata1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x0B, Sata1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x0C, Sata1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x0D, Sata1SmmuNode), __STYX_ID_MAPPING_SINGLE(0x0E, Sata1SmmuNode), __STYX_ID_MAPPING_SINGLE(0x0F, Sata1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x10, Sata1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x11, Sata1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x12, Sata1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x13, Sata1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x14, Sata1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x15, Sata1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x16, Sata1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x17, Sata1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x18, Sata1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x19, Sata1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x1A, Sata1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x1B, Sata1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x1C, Sata1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x1D, Sata1SmmuNode), __STYX_ID_MAPPING_SINGLE(0x1E, Sata1SmmuNode), - __STYX_ID_MAPPING_SINGLE(0x1F, Sata1SmmuNode), + } + }, { + // CcpNamedNode + __STYX_NAMED_COMPONENT_NODE("\\_SB_.CCP0", 4), + { + __STYX_ID_MAPPING_SINGLE(0x00, Sata1SmmuNode), + __STYX_ID_MAPPING_SINGLE(0x02, Sata1SmmuNode), + __STYX_ID_MAPPING_SINGLE(0x40, Sata1SmmuNode), + __STYX_ID_MAPPING_SINGLE(0x42, Sata1SmmuNode), } } }; -- 2.17.1