From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c09::241; helo=mail-wm0-x241.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::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 AB95B210DA787 for ; Mon, 6 Aug 2018 03:00:03 -0700 (PDT) Received: by mail-wm0-x241.google.com with SMTP id q8-v6so13687773wmq.4 for ; Mon, 06 Aug 2018 03:00:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=kO25tYNMedye7MdfyBL2+RGVBmBSfFIjAfwUEB76pvw=; b=S5QcRAE/6p1V2mlblPihlqb5pG2MYxeo+8Rs08BSJRZH7osRJoxPtv/kLmhCj/47Su B1JB+5H57avK6M3aoOIF7g/HGQE0oqhUzdbm+ZGvHm9j5JEP22D5EoPmXwN84+phyNYb cxHVKgoCL/NGas40PaPZ/I6F1ZMt5snG0+7LM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=kO25tYNMedye7MdfyBL2+RGVBmBSfFIjAfwUEB76pvw=; b=fOYWFc9/sQei1mELtmoWBVKL8u8+njkr4Okqz8ygT9q0cT3NKGpkwUsvI6nlgyPSY/ 89knwrloh8GUjvyn4wsnuXZ9LFjzm9oCIlaOxg9aiVXR43a1y+961ETgcAE9YOKu/Ty2 JNJSCOzOXipl7984P1XLi2GedRErUg9LkIURkPvYzPDE0TUc8+rUXB5vO1ARYmDZftg1 R2AciKbg53tCdCcKAIIcXBrrDgtmRjIg3wPQYXGSzOC6LycBocKz3IfYazMQ3+WmAx+k t+arEIbzuWeKWBZubgF1mbK0DemwlGTwOljBqK7RrB1Cx8EFAUlkEmTzYY8f/FPo4zXE ayJg== X-Gm-Message-State: AOUpUlHszboWXxKfG4xkupYLXVNL3C7+P2K65hQ5lmRcKETeSEXKW/k/ jlNTGVDrz/CU3iJuOS/STh67bg== X-Google-Smtp-Source: AAOMgpfokqjwZV3TVRzJwI9YhEcqbPFljdrGp0mBJjknknWUTJQFt5U1NpugDUe24KeIgmwEeSDFdQ== X-Received: by 2002:a1c:90e:: with SMTP id 14-v6mr11474010wmj.130.1533549602160; Mon, 06 Aug 2018 03:00:02 -0700 (PDT) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id z14-v6sm15177232wrr.71.2018.08.06.03.00.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Aug 2018 03:00:00 -0700 (PDT) Date: Mon, 6 Aug 2018 10:59:59 +0100 From: Leif Lindholm To: Ming Huang 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 Message-ID: <20180806095959.c55sn5vszfix5pdy@bivouac.eciton.net> References: <20180724070922.63362-1-ming.huang@linaro.org> <20180724070922.63362-37-ming.huang@linaro.org> MIME-Version: 1.0 In-Reply-To: <20180724070922.63362-37-ming.huang@linaro.org> User-Agent: NeoMutt/20170113 (1.7.2) 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: Mon, 06 Aug 2018 10:00:04 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. / 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 >