From patchwork Fri Aug 31 13:27:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Huang X-Patchwork-Id: 145640 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp785344ljw; Fri, 31 Aug 2018 06:29:28 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZzwfJjgeGSzfR65Hp47sqO5EVzFUXWS9h7o2XFzDBkSYE7mV7bj/x3TYsocPOi5m8yK0xy X-Received: by 2002:a62:e412:: with SMTP id r18-v6mr15974123pfh.25.1535722168629; Fri, 31 Aug 2018 06:29:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535722168; cv=none; d=google.com; s=arc-20160816; b=EUnfT9XQY1Y+RngZyGfmDpTOQWnCUKLJGwPn/VhJTF/JPhYXXjwJNpS7wVrExMA5Ak VakY5GWFfc2mlcrXbhhf0a4X0F0N3JJIspnso0zQFy/lKvnsegMB343zF+mF/L/X8Mpg Z1SDdfVN8mRmLZBR4GiWNz1/Ldk066oMUOh/LEyN9chypHeQuDNqGOQQsBJYiNiMyXA+ xSgoitw1/VynMXLB/b2bGQYdsbyn71EoJ5vryR7vOwy9tuO+d1CFgj1GVJyiwLprdSrp jY1jXPfvXMziJImi3p/9HUOzWFjImKoH+OcREq3vzkxmwM9rD0dH5XSiSs+pohUDztEs ddHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=tMocrc19ZtFoqv9i2EtpYYdTWmdEBP7+qOpm280CKaY=; b=NIa3BHIbegqMi92gzjllMO4H8iRo8fUKpZfhHsNm5XZUCWqes8H/mLjtJFdL2t6bUu CQ8Dd4vCwhBhcHUt+WdeHDD5Xy4vrp0TDdI9Fxyv50PhmW7mP/wcRVXzILRJkTj0qL9l nBS+Cs1JoehlbzAyQyvdy4XAzBHL88vsl1S87gQEBfGuHp5iz03hFo4rjG/JeDz7GJVM OM5P/vCRQ9clcjyp6106OvhNFIKXI95sKcg9eve2BF137lz6DdqqkKLp7NNlKjlXEuD0 M7OmqK/cQ2spAHibTatWuwo3lyFtnyK83oRHhYND8/GFOVV9HakM+uD7GcJtk0zNbNvI wMHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=KAAgwkC3; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id q126-v6si10996907pfb.277.2018.08.31.06.29.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Aug 2018 06:29:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=KAAgwkC3; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id AC26C2110BFAA; Fri, 31 Aug 2018 06:29:02 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::542; helo=mail-pg1-x542.google.com; envelope-from=ming.huang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A6E722110BD68 for ; Fri, 31 Aug 2018 06:29:01 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id d1-v6so5461845pgo.3 for ; Fri, 31 Aug 2018 06:29:01 -0700 (PDT) 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=GMpUfLxvKhOd84WiRa2bCIih1sfS7mtATtcg/AwtE6w=; b=KAAgwkC3/w+UZfM+F0a4Qid826zfaAwawFMZl4X/DP2CFJsJErkMu0CGkActMdC7QG gCkEVV4zO6vVmOacr0YWAY3i22TFdeyCl9GG41waSPyiDTshmSXXgDOvSbDujwSfWCeG 4qHevyMSJTOHdKMQKPbsabDtNyWrnukIGr438= 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=GMpUfLxvKhOd84WiRa2bCIih1sfS7mtATtcg/AwtE6w=; b=mFCDdGJ+9SOdEVwfkd0cago1yJhDVDIbyWH/0FeH18icQDLI6YuR81xlMEBngab2HG JW5XrTceTqsM+OWX0LORotb1uDL9RlIw1uc8GXNeoJPpJfUhD0BOmhUs+cH/f+7cMuLu NNfs03Ks8/U5WYQPEPqYl3QtrKY3z+/WCdniqjcIS/wBz2TT9V5nLH3K/YSCnf0DAv0x 9G64z2HBkVAQorwIIai5OPU5StHsTJ+JYLAFwVEOrEErnTGADrmdfDnoV9Lz2R1AAgJ1 gDKjP4U8Dvh+C0+ztRvWQsldaAYq3zHDdaU7pz+Ri18GGcwAkesnPX5xkUcoXehWjkYF fiwA== X-Gm-Message-State: APzg51BNCMOW6GZRGA582CIIETEfeQu6Dik4O2qiLhbmauc3SycHuW3O hHvUqISyrGfgd3hKI03w63cjN4WSq8U= X-Received: by 2002:a63:1823:: with SMTP id y35-v6mr14472677pgl.438.1535722141377; Fri, 31 Aug 2018 06:29:01 -0700 (PDT) Received: from localhost.localdomain ([120.31.149.194]) by smtp.gmail.com with ESMTPSA id l185-v6sm19081936pga.5.2018.08.31.06.28.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 31 Aug 2018 06:29:00 -0700 (PDT) From: Ming Huang To: leif.lindholm@linaro.org, linaro-uefi@lists.linaro.org, edk2-devel@lists.01.org, graeme.gregory@linaro.org Date: Fri, 31 Aug 2018 21:27:09 +0800 Message-Id: <20180831132710.23055-28-ming.huang@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180831132710.23055-1-ming.huang@linaro.org> References: <20180831132710.23055-1-ming.huang@linaro.org> Subject: [edk2] [PATCH edk2-platforms v5 27/28] Silicon/Hisilicon/setup: Enable/disable SMMU X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: huangming23@huawei.com, xinliang.liu@linaro.org, john.garry@huawei.com, zhangjinsong2@huawei.com, guoheyi@huawei.com, huangdaode@hisilicon.com, zhangfeng56@huawei.com, michael.d.kinney@intel.com, lersek@redhat.com, wanghuiqiang@huawei.com MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Select without SMMU iort while SMMU item is disable, Select with SMMU iort while SMMU item is enable. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ming Huang Reviewed-by: Leif Lindholm --- Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/AcpiPlatformDxe.inf | 1 + Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c | 89 ++++++++++++++++++++ 2 files changed, 90 insertions(+) -- 2.18.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/AcpiPlatformDxe.inf b/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/AcpiPlatformDxe.inf index 281a4f2ebd..3d133aff85 100644 --- a/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/AcpiPlatformDxe.inf +++ b/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/AcpiPlatformDxe.inf @@ -51,6 +51,7 @@ [Guids] gHisiEfiMemoryMapGuid + gOemConfigGuid [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiTableStorageFile ## CONSUMES diff --git a/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c b/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c index 54f49977c3..c2c8f687b0 100644 --- a/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c +++ b/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c @@ -16,12 +16,98 @@ #include #include #include +#include #include #include +#include #include #define CORECOUNT(X) ((X) * CORE_NUM_PER_SOCKET) +#define FIELD_IORT_NODE_OFFSET 40 + +typedef enum { + NodeTypeIts = 0, + NodeTypeNameComponent, + NodeTypePciRC, + NodeTypeSmmuV1, + NodeTypeSmmuV3, + NodeTypePMCG +} IORT_NODE_TYPE; + +#pragma pack(1) +typedef struct { + UINT8 Type; + UINT16 Length; + UINT8 Revision; + UINT32 Reserved; + UINT32 IdMapNumber; + UINT32 IdArrayOffset; +} IORT_NODE_HEAD; +#pragma pack() + +BOOLEAN +IsIortWithSmmu ( + IN EFI_ACPI_DESCRIPTION_HEADER *TableHeader + ) +{ + UINT32 *NodeOffset; + UINT32 NextOffset; + IORT_NODE_HEAD *Node; + + NodeOffset = (UINT32 *)((UINT8 *)TableHeader + FIELD_IORT_NODE_OFFSET); + NextOffset = *NodeOffset; + + while (NextOffset < TableHeader->Length) { + Node = (IORT_NODE_HEAD *)((UINT8 *)TableHeader + NextOffset); + NextOffset += Node->Length; + + if ((Node->Type == NodeTypeSmmuV1) || (Node->Type == NodeTypeSmmuV3)) { + return TRUE; + } + } + + return FALSE; +} + +EFI_STATUS +SelectIort ( + IN EFI_ACPI_DESCRIPTION_HEADER *TableHeader + ) +{ + EFI_STATUS Status; + UINTN Size; + OEM_CONFIG_DATA Configuration; + + Configuration.EnableSmmu = 0; + Size = sizeof (OEM_CONFIG_DATA); + Status = gRT->GetVariable ( + OEM_CONFIG_NAME, + &gOemConfigGuid, + NULL, + &Size, + &Configuration + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Get OemConfig variable (%r).\n", Status)); + } + + Status = EFI_SUCCESS; + if (IsIortWithSmmu (TableHeader)) { + if (!Configuration.EnableSmmu) { + Status = EFI_ABORTED; + } + } else { + if (Configuration.EnableSmmu) { + Status = EFI_ABORTED; + } + } + DEBUG ((DEBUG_INFO, "SmmuEnable=%x, return %r for Iort table.\n", + Configuration.EnableSmmu, Status)); + + return Status; +} + STATIC VOID RemoveUnusedMemoryNode ( @@ -130,6 +216,9 @@ UpdateAcpiTable ( case EFI_ACPI_6_0_SYSTEM_LOCALITY_INFORMATION_TABLE_SIGNATURE: Status = UpdateSlit (TableHeader); break; + case EFI_ACPI_6_2_IO_REMAPPING_TABLE_SIGNATURE: + Status = SelectIort (TableHeader); + break; } return Status; }