From patchwork Tue Aug 14 08:09:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Huang X-Patchwork-Id: 144148 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4050986ljj; Tue, 14 Aug 2018 01:12:53 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwjBUxVCqqnJNyTKqhhd0AtlBS9Q3f2km2VN9XCw/iE8NcetImQ8qYVevmvcOrNAGK8jch+ X-Received: by 2002:a63:be4a:: with SMTP id g10-v6mr17299859pgo.378.1534234373289; Tue, 14 Aug 2018 01:12:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534234373; cv=none; d=google.com; s=arc-20160816; b=vQq/kIfaLbT+Uom3xFp+IYmWCwy5PvRlXiEK89bdhI63jnSg9U3+oFtGI8OisJd0aC g3RtTed6nunUtEgt6X5vqA2DpWkimXIwIvbRXWvRz7xJaVDnpGK+Y42YURvYl7PFT20a qjd87GiT9sQzWeZC8AlSaHfxxPQbBPLMSy2+lbJINN0zluMPrRu8quLdJ5o9UaeDbE2o 86xUb59ucTreDnT66EswmCcLvl0XhebSbJbf5YVfHxX4kigWGnDJPNze6YvtefORRlkS UwOfKrpAet7rv08KbWAlXqytZline6R8IxjmSU0jlPTyS5B2lqfasVPsFZDFJ8ObvEju X0FQ== 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=ZsGcraAGQGHvRuf5dEWMsPGBJ5DlgE8frd8ZeY2cLcE5MpIuvmOrkSakK5Ac2lKr35 LdXufMcY1/Tw5xWkU2VNEjE2+mCDh2hCM7yVrKzX+vPCNUuspwKQMuyIIc1aaKxxxVay VJnOiVHLcL/NnRrrL55dHVAbskl9bMeHFkBuTI13I31jrrhsvWSNWeinRhBhUkyroGXV 8dWGqpz/5m01PEgGbprBPtsYJvEQrW7Z0crZhT9L8iJCzZdPWqVNS8AE1plbGYgf/elc szjVLlAjF5IPgmUlb4Na8nGM3xWcSFJJEhFsBEa7ohJo0HJ4JLuC+mcfnb2te2tCRfCM owRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=XjxhdvgU; 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 s10-v6si19330602pgm.501.2018.08.14.01.12.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Aug 2018 01:12:53 -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=XjxhdvgU; 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 5361C210F2552; Tue, 14 Aug 2018 01:11:44 -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::241; helo=mail-pl0-x241.google.com; envelope-from=ming.huang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pl0-x241.google.com (mail-pl0-x241.google.com [IPv6:2607:f8b0:400e:c01::241]) (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 94517210F2544 for ; Tue, 14 Aug 2018 01:11:43 -0700 (PDT) Received: by mail-pl0-x241.google.com with SMTP id b90-v6so8044252plb.0 for ; Tue, 14 Aug 2018 01:11:43 -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=XjxhdvgU4nxtm71HjHiFapsLh3ZwkjOFQ4H7WxFif3uGQxVLVYzr1OuoSOzwDRR0mz FPoHjz7PuAR9hRxMmAoT3LgHcxEWRS9/WS8FrI/mfUlAnSclyzTKI555cMAeGuxT8CS9 8o996edeoIpKFusqJuGzWGLqkktcnH8JFbQfE= 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=hrvhvQWsjn/XWdnOO+xCwG4Lopsun0E0M8Akon0idERgjBDdhnkhKDnipNCyFKd6Gf UwrsDECoPXUfA32+C3bNSXdsf5haLGkUxNOIM0r/389U/l++nIch/dEXaLOPYgIsbYky 9jeAkoKr/1WwjywFneQ0ItQpiWyvy59/hE1W/RvDgS2BPFlNhYQwfdOevMG/jsC6yLlW kyZWRnHAOLU6ccpXt1BvxLy1TKI2d4u6YS1cIFMqII3+3qMLcOIcc31gTQUZVpwmcXgZ Bzpo7g8F8gZku1WgBjC+9YDgTAmZHPQBGoqOCeBjYH/8/Cm9faFEQdZ3OxyujA2wYwrL 9r7Q== X-Gm-Message-State: AOUpUlGgc1vTno2td1OcLL8rOzmr1ltaRm4mBrvm1qzapiJeZOw/Jrpz Qe0GcOB/flXKSaioLHsxbxP3iQ4c3LY= X-Received: by 2002:a17:902:22:: with SMTP id 31-v6mr19557805pla.190.1534234303340; Tue, 14 Aug 2018 01:11:43 -0700 (PDT) Received: from localhost.localdomain ([120.31.149.194]) by smtp.gmail.com with ESMTPSA id h130-v6sm72905670pgc.88.2018.08.14.01.11.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 Aug 2018 01:11:42 -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: Tue, 14 Aug 2018 16:09:00 +0800 Message-Id: <20180814080903.50466-41-ming.huang@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180814080903.50466-1-ming.huang@linaro.org> References: <20180814080903.50466-1-ming.huang@linaro.org> Subject: [edk2] [PATCH edk2-platforms v2 40/43] 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;