From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::442; helo=mail-wr1-x442.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) (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 C548B210FC368 for ; Wed, 22 Aug 2018 11:42:16 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id n2-v6so2420943wrw.7 for ; Wed, 22 Aug 2018 11:42:15 -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=weAXary7pKPNaXxNH+ufx2OR7H8ehiM7c9QFRSw6o6w=; b=RhlBbvdu8Fk0VvifzBUdQxV9JJ768IcWqtz1pcQ48jpjmwFAA78XbUD6EqNOccNh4L zK1WcXsajHbafbZpqi+krUzXhLRcsKjr+6u35HPzyDKyjCEK8j4gUCTY+d9QmXy0Ddm6 YpYc8jVZUuhxaU7sAg5gpYSA00Ph86x8goVsI= 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=weAXary7pKPNaXxNH+ufx2OR7H8ehiM7c9QFRSw6o6w=; b=FAPVZSm9xOXkvPQzjvmTVt4DQlfFHNkfK5MrxS+wkWiGXonyH8F+gWJL1TNw0J6xhB 5TFDlZA3gPIuUo3IRtGwwz92BOvHMahZ+Pl/x9MIYRBlnsjU0JA/9LPyZE3qGE1yjLI1 MNVZ0TCRTXia0iXGcSmC7+z0wwZ9QnZgKqzG/1qYeijrpkWC+xzD3Pe69dqGaLfSEQ5k /cn+9IlUpG7+ft8kQ5jWCL9d/f8MzIq9FOnXQd/eDbTSgasQwsYXYyY0u1LL93J2sbhf 1C7IemeO25nUdeh6rLzWIMpAHaLagq6/a/MLACi41ULpEm1kTENED858ddZYXUpWS0cY 0Hdw== X-Gm-Message-State: AOUpUlHIDB9oeXLKFWOCI09JCZaqgHoCjKsTfdJfJFisIX5sDFwNk6Ep nTXWYslXuKAP1W1Eo076ihC7rQ== X-Google-Smtp-Source: AA+uWPxEH6hswKjvvFxGvTRSZC3RmJa0547sz36oJRbQaUtmve9GKTAYEisEcfst3ZK4XgTutUe2iw== X-Received: by 2002:adf:ff82:: with SMTP id j2-v6mr16877519wrr.165.1534963334276; Wed, 22 Aug 2018 11:42:14 -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 v2-v6sm2721944wme.36.2018.08.22.11.42.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 22 Aug 2018 11:42:13 -0700 (PDT) Date: Wed, 22 Aug 2018 19:42:11 +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, michael.d.kinney@intel.com, lersek@redhat.com, guoheyi@huawei.com, wanghuiqiang@huawei.com, huangming23@huawei.com, zhangjinsong2@huawei.com, huangdaode@hisilicon.com, john.garry@huawei.com, xinliang.liu@linaro.org Message-ID: <20180822184211.67u6b5gkyp6ihr5d@bivouac.eciton.net> References: <20180814080903.50466-1-ming.huang@linaro.org> <20180814080903.50466-41-ming.huang@linaro.org> MIME-Version: 1.0 In-Reply-To: <20180814080903.50466-41-ming.huang@linaro.org> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [PATCH edk2-platforms v2 40/43] Silicon/Hisilicon/setup: Support SMMU switch 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: , X-List-Received-Date: Wed, 22 Aug 2018 18:42:17 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Please correct the subject as per my prevoious comments on this. On the whole, I think the enable/disable SMMU is a likely enough scenario that we should probably have some core functionality for it like for SPCR. For now I'm OK with this. On Tue, Aug 14, 2018 at 04:09:00PM +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 > --- > Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c | 88 ++++++++++++++++++++ > 1 file changed, 88 insertions(+) > > 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; > + Drop this blank line. / Leif > + 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 >