From patchwork Thu Aug 16 12:12:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Huang X-Patchwork-Id: 144383 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2001954ljj; Thu, 16 Aug 2018 05:15:37 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzfozVIfiY+fk8wYku717yDuC0GNB7D8MNgSboy1NTvF3SjHwMbCUy/ecjvvhpXgMHn9agE X-Received: by 2002:a17:902:163:: with SMTP id 90-v6mr28512948plb.322.1534421737407; Thu, 16 Aug 2018 05:15:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534421737; cv=none; d=google.com; s=arc-20160816; b=l4zlWl81RkP0AdZDkXPts8kDW5xvtEgnygSjjkEH3EXc8yhi5KoIHkkqc8g9tQ/H+i LEjCUKdoFPw3666T04asgJhhiiSiybZOlslJkFa2ve7WcSwcjb5EHrUA4DHLk92GbUTj 7+BMCMq+/6SdjFJd8fLnmf/LUgbx+0Men6YuMG9cxaWwclkNFiRQEgWetYLRKqFEdADn 9giVMjN/gGS2fbYcv8VmPJfrHYyQY4dPy5AdFsa+abgSPeXFHFIOWQ1v85kE9FNS+eI3 guT0GDHvZQtjdNDd8jxL81s5fbBj1RMX38zW/JMjEHTasC9xMUelntPbGQegR+CZ/Id+ u+Jg== 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=T4kKJUUvQcwOUGXyM3vP33IkFQWM0kMuBLKJM+FPkhg=; b=ZtYIUb+iBx+TqfzjBiH8tpCbQz9ePdm/oJ9Yc7wNDs90bXk777IEvQl0rBKUdgImKk L5oK5NNNcxq61GYvGx9j6yURsVZzoWARUqJczAWyV2UsA58mAqjYbktJO9jpH4gCnWQE 64Wr9i+AYLEfR4m0rSLeQ4GsnZIUBgc9rnGAFuY8ZgBvxePpyQG34DtdgpXy0r5fQsQZ 6eEd7fRIOXe8aX52fv7Wgt5BId3/sG87oL5eAjPzQJh9Q044hGAtHO5XVD8tERkD7Cxe kSKFb/MITp/TLo5VbO9jehYfmJJmaauSLOuhFRqtXXXUgFE3YgjOcuVBbU/gUA2j2BL8 ARUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=FDhVx0Q6; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 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. [198.145.21.10]) by mx.google.com with ESMTPS id s21-v6si26829094pfk.213.2018.08.16.05.15.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Aug 2018 05:15:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=FDhVx0Q6; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 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 4419F210F41C9; Thu, 16 Aug 2018 05:14:58 -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:400e:c01::243; helo=mail-pl0-x243.google.com; envelope-from=ming.huang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pl0-x243.google.com (mail-pl0-x243.google.com [IPv6:2607:f8b0:400e:c01::243]) (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 45EFD210F41C4 for ; Thu, 16 Aug 2018 05:14:57 -0700 (PDT) Received: by mail-pl0-x243.google.com with SMTP id f6-v6so2026539plo.1 for ; Thu, 16 Aug 2018 05:14:57 -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=dPwuA9svVO/960rahvTTDA8WB6UGBMspAj+4E3t/334=; b=FDhVx0Q6RHf5vP6wwXuyuEt46We398me2pNHJ3oEm9259TsL/NCZljoKhT+uCwEUsa 1OrFqVLESX74zfsUhcEoyiRAhoYVf3KgSgjzPicWBV0NDfsjH4pL5iIzAhFVwTxgCt/K PibRDYcWEktWEYDOO+kdFbGQ3zn/X+3Tq4sQw= 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=dPwuA9svVO/960rahvTTDA8WB6UGBMspAj+4E3t/334=; b=TJWO8TMZKy3yZ5MMtu6CpOHwlvJuJKQIFhdJXx4L54iH308p5wTHjxG6JV31Pmejat VQlEWIPsGi48iKssSGg20aZwlhinZh31vVe4+/nOhbKe45VTKwbMXjknP274mQ0F+jIG +P2lQRYAnQGG+niss7QvkMa30/q6tHKsgMostE+PgeM9CGmiQKIlSYU9WxcOupQit+vh BQEJgxDMq9RQTi+d1FvElMhypIDO8cGEOrRKtsCdRcWSHlrjOc3GyW02n0wVEDksuC2p 4ptB3LMk+W/rXEfVRy+sRjApVHhMpKc3sCTdCKXrzK9b7wk3AnPyrvQKNRjO4rD9YnOw qXKA== X-Gm-Message-State: AOUpUlFW+pUVxO/lBiaNVV0VJS9HUoBFuxksZ1T56m3OOviEtFi42WjC GArx/7yhWDMI0rwgtyq5HSbh1g== X-Received: by 2002:a17:902:6909:: with SMTP id j9-v6mr28486291plk.196.1534421697035; Thu, 16 Aug 2018 05:14:57 -0700 (PDT) Received: from localhost.localdomain ([120.31.149.194]) by smtp.gmail.com with ESMTPSA id j27-v6sm46736311pfj.91.2018.08.16.05.14.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Aug 2018 05:14:56 -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: Thu, 16 Aug 2018 20:12:36 +0800 Message-Id: <20180816121239.44129-34-ming.huang@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180816121239.44129-1-ming.huang@linaro.org> References: <20180816121239.44129-1-ming.huang@linaro.org> Subject: [edk2] [PATCH edk2-platforms v3 33/36] Silicon/Hisilicon/setup: Support SMMU switch X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 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, 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 --- Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c | 88 ++++++++++++++++++++ 1 file changed, 88 insertions(+) -- 2.17.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/UpdateAcpiTable.c b/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c index 32878ca4f9..e0c29e0f57 100644 --- a/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c +++ b/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c @@ -24,6 +24,90 @@ #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 ( @@ -151,6 +235,10 @@ 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; case EFI_ACPI_6_2_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE: Status = IsNeedSpcr (TableHeader); break;