From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::543; helo=mail-pg1-x543.google.com; envelope-from=ming.huang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) (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 93D00210C5138 for ; Thu, 9 Aug 2018 07:19:37 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id n7-v6so2828146pgq.4 for ; Thu, 09 Aug 2018 07:19:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=E8GCpw1j6cBDbxh31Uc+c7/TnE4JecJjh6PZAyZrZQE=; b=SX83prBxpCcZoW2wVhYqQ0478pOs7QqxOCRhOZ+M38+YqcZqh4V28grA71ta8P8myj PaK+tFKZfrtpWKqFd/oFs+BX4RmG7Y5gdE+kR3j5lqTMkni6mhWaL63BbsGQ4icsC1lr AV0SxqgO9tZHK+3D6wW5NcfxbnL1TrSaLr42Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=E8GCpw1j6cBDbxh31Uc+c7/TnE4JecJjh6PZAyZrZQE=; b=V3vNBytphMfJ7AdMb3xTjY7Ca3hN4SQ66ds8H2VVvEOKC09ySkKOXFK1u52PZyDREx fCyttyGX8Y7JIxfKCwIQn37ayny34tsQN0N/j2+m8SDAisHatjrQnwA481oK8q0CspSi yWzkMHe5t0vyCoMeJQzYJ/SyXXxdp42mrJqQQEAI60ZBjuATegPwXM9dtLzfx2GQ6Jvp aUj1+Kv8otcjDCnWFTBaoWrK3oYDuylPdJHN7RBOBenR+EoG26RvXspVxWWeXBot533b 6E2Lyj2JU680g/ECBvRvumNwzbm54b5U34w075Wj1jgMrxMl6LWrXqU7THQARWGvdnj/ hjwQ== X-Gm-Message-State: AOUpUlH/lcgbnuq909Wziv6KRss0muxHG30SpmG4gnfsDDpDOwFhuVds Wqn0PE+bE23AlxjMupvx8q0hxA== X-Google-Smtp-Source: AA+uWPw4ce2R27C+Md6vOs34aWdLevKX6ac4xTAOsPMnYLF/CJVPKe7uvyDd4CEUG5hBzRDZLKeDfA== X-Received: by 2002:a63:195e:: with SMTP id 30-v6mr2345511pgz.192.1533824377327; Thu, 09 Aug 2018 07:19:37 -0700 (PDT) Received: from [10.199.0.182] ([64.64.108.224]) by smtp.gmail.com with ESMTPSA id v23-v6sm8648848pfm.80.2018.08.09.07.19.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Aug 2018 07:19:36 -0700 (PDT) To: Leif Lindholm Cc: linaro-uefi@lists.linaro.org, edk2-devel@lists.01.org, graeme.gregory@linaro.org, ard.biesheuvel@linaro.org, guoheyi@huawei.com, wanghuiqiang@huawei.com, huangming23@huawei.com, zhangjinsong2@huawei.com, huangdaode@hisilicon.com, john.garry@huawei.com, xinliang.liu@linaro.org, Heyi Guo References: <20180724070922.63362-1-ming.huang@linaro.org> <20180724070922.63362-37-ming.huang@linaro.org> <20180806095959.c55sn5vszfix5pdy@bivouac.eciton.net> From: Ming Message-ID: <62dc9a6f-6b50-313d-a35e-b2d5da0491d6@linaro.org> Date: Thu, 9 Aug 2018 22:19:24 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180806095959.c55sn5vszfix5pdy@bivouac.eciton.net> Subject: Re: [PATCH edk2-platforms v1 36/38] 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: , X-List-Received-Date: Thu, 09 Aug 2018 14:19:37 -0000 Content-Type: text/plain; charset=gbk Content-Transfer-Encoding: 8bit ÔÚ 8/6/2018 5:59 PM, Leif Lindholm дµÀ: > On Tue, Jul 24, 2018 at 03:09:20PM +0800, Ming Huang wrote: >> 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 >> Signed-off-by: Heyi Guo >> --- >> Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c | 81 ++++++++++++++++++++ >> 1 file changed, 81 insertions(+) >> >> diff --git a/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c b/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c >> index 32878ca4f9..4f0998dd24 100644 >> --- a/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c >> +++ b/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c >> @@ -24,6 +24,83 @@ >> >> #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); > > Wrap long line. > >> + 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)); > > Wrap long line. Modify it in v2. Thanks. > > / > Leif > >> + >> + return Status; >> +} >> + >> STATIC >> VOID >> RemoveUnusedMemoryNode ( >> @@ -151,6 +228,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; >> -- >> 2.17.0 >>