From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.132.183.28; helo=mx1.redhat.com; envelope-from=lersek@redhat.com; receiver=edk2-devel@lists.01.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id ECD972118F35F for ; Wed, 21 Nov 2018 09:12:39 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 572F230833A6; Wed, 21 Nov 2018 17:12:39 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-240.rdu2.redhat.com [10.10.120.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 58958604DA; Wed, 21 Nov 2018 17:12:34 +0000 (UTC) To: Ard Biesheuvel , edk2-devel@lists.01.org Cc: leif.lindholm@linaro.org, philmd@redhat.com, hongbo.zhang@linaro.org, nariman.poushin@linaro.org, thomas.abraham@arm.com References: <20181121115828.3026-1-ard.biesheuvel@linaro.org> <20181121115828.3026-4-ard.biesheuvel@linaro.org> From: Laszlo Ersek Message-ID: Date: Wed, 21 Nov 2018 18:12:33 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181121115828.3026-4-ard.biesheuvel@linaro.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 21 Nov 2018 17:12:39 +0000 (UTC) Subject: Re: [PATCH v2 3/5] ArmVirtPkg/FdtClientDxe: take DT node 'status' properties into account 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, 21 Nov 2018 17:12:40 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 11/21/18 12:58, Ard Biesheuvel wrote: > DT has a [pseudo-]standardized 'status' property that can be set on > any node, and which signifies that a node should be treated as > absent unless it is set to 'ok' or 'okay'. (I now really want "oktopus" to be [pseudo-]standardized too! ;) /jk) > So take this into account > when iterating over nodes. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel > --- > ArmVirtPkg/FdtClientDxe/FdtClientDxe.c | 38 +++++++++++++++++--- > 1 file changed, 33 insertions(+), 5 deletions(-) > > diff --git a/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c b/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c > index fb6e0aeb9215..5bfde381ecd0 100644 > --- a/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c > +++ b/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c > @@ -78,6 +78,33 @@ SetNodeProperty ( > return EFI_SUCCESS; > } > > +STATIC > +BOOLEAN > +IsNodeEnabled ( > + INT32 Node > + ) > +{ > + CONST CHAR8 *NodeStatus; > + INT32 Len; > + > + // > + // A missing status property implies 'ok' so ignore any errors that > + // may occur here. If the status property is present, check whether > + // it is set to 'ok' or 'okay', anything else is treated as 'disabled'. > + // > + NodeStatus = fdt_getprop (mDeviceTreeBase, Node, "status", &Len); > + if (NodeStatus == NULL) { > + return TRUE; > + } > + if (Len >= 5 && AsciiStrCmp (NodeStatus, "okay") == 0) { > + return TRUE; > + } > + if (Len >= 3 && AsciiStrCmp (NodeStatus, "ok") == 0) { > + return TRUE; > + } > + return FALSE; > +} > + > STATIC > EFI_STATUS > EFIAPI > @@ -101,6 +128,10 @@ FindNextCompatibleNode ( > break; > } > > + if (!IsNodeEnabled (Next)) { > + continue; > + } > + > Type = fdt_getprop (mDeviceTreeBase, Next, "compatible", &Len); > if (Type == NULL) { > continue; > @@ -210,7 +241,6 @@ FindNextMemoryNodeReg ( > { > INT32 Prev, Next; > CONST CHAR8 *DeviceType; > - CONST CHAR8 *NodeStatus; > INT32 Len; > EFI_STATUS Status; > > @@ -223,10 +253,8 @@ FindNextMemoryNodeReg ( > break; > } > > - NodeStatus = fdt_getprop (mDeviceTreeBase, Next, "status", &Len); > - if (NodeStatus != NULL && AsciiStrCmp (NodeStatus, "okay") != 0) { > - DEBUG ((DEBUG_WARN, "%a: ignoring memory node with status \"%a\"\n", > - __FUNCTION__, NodeStatus)); > + if (!IsNodeEnabled (Next)) { > + DEBUG ((DEBUG_WARN, "%a: ignoring disabled memory node\n", __FUNCTION__)); > continue; > } > > Reviewed-by: Laszlo Ersek Thanks! Laszlo