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::144; helo=mail-it1-x144.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-it1-x144.google.com (mail-it1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) (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 9035F211944D2 for ; Thu, 22 Nov 2018 05:12:24 -0800 (PST) Received: by mail-it1-x144.google.com with SMTP id p11-v6so15428912itf.0 for ; Thu, 22 Nov 2018 05:12:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6ZkIzV+4z3ubJnVaciCLTDFTrkBKNWA2yovK/5g+Xrc=; b=PsPBcNVdrdpIdTpt3sNXkRvF93Lczzr+r67xpiqUC7xHoKE3JbZIkM2H//aQkaHRa8 OWsuCxqHAflt8MzHrTlgcoZfeWwnMHrP32yJBej5gUsfyMnBuu/7p9rLBLKSb9cHS2c0 pd9B2oO6JHePcLDpuGLdmH6lsEjkZWfAMuz7s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6ZkIzV+4z3ubJnVaciCLTDFTrkBKNWA2yovK/5g+Xrc=; b=LCDOgYmijU9VRMZ/JFcMVz3+S1xL+DLQr1dDhM94mUJOidAGoMIqRb6RpTL77PtMHH uhZyr7Hy8G95xueUvZ3K7+qKrO/3C2wvszRH89ACQ9zRNNvk6FhIwtV+MEQCVfrv0d3e IGqvnpYcFBlbZXSgTVeNPWCis1az1fiQlGer3nvW0QRS7+0CMFlvgaJWZgN6ScOlmTMn 7BLhZs3HQ7v/n2f5fAq/83ARP1sH2Xtsuynr4U95X1qv1tQIxtAyZbRAbwaPP1JhlYOa t9lmrhjX9jbjGn8h192gGSZ3nL4XxIHtmIfpfuPTuZ+JZqCwbaK8EmW15vbmcU4YdhvB Uvsg== X-Gm-Message-State: AA+aEWYhYuy8J6hsYrO2FqDHZq4kfQXDrcvG4SloE+UFwhdxkVg8PpT/ /MsyGH/W6UlyXzk3rUQYz64VMXbU+OjJMpzQCH5dVg== X-Google-Smtp-Source: AFSGD/XSN5Xs8dfGaJGqvgBo2CAZt5So8shDELsL4zUl9b9LfZYj/6V5PpkdzwZN0JnhFp37pdQjndR26huz4QS8Kts= X-Received: by 2002:a02:734b:: with SMTP id a11mr8407661jae.62.1542892343883; Thu, 22 Nov 2018 05:12:23 -0800 (PST) MIME-Version: 1.0 References: <20181121115828.3026-1-ard.biesheuvel@linaro.org> <20181121115828.3026-4-ard.biesheuvel@linaro.org> In-Reply-To: From: Ard Biesheuvel Date: Thu, 22 Nov 2018 14:12:12 +0100 Message-ID: To: Laszlo Ersek Cc: "edk2-devel@lists.01.org" , Leif Lindholm , =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= , Hongbo Zhang , Nariman Poushin , Thomas Panakamattam Abraham 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: Thu, 22 Nov 2018 13:12:24 -0000 Content-Type: text/plain; charset="UTF-8" On Wed, 21 Nov 2018 at 18:12, Laszlo Ersek wrote: > > 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) > Be careful what you wish for :-) > > 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.