From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.85.221.68; helo=mail-wr1-f68.google.com; envelope-from=philmd@redhat.com; receiver=edk2-devel@lists.01.org Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) (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 6327C21B02822 for ; Thu, 22 Nov 2018 07:38:54 -0800 (PST) Received: by mail-wr1-f68.google.com with SMTP id c14so4051110wrr.0 for ; Thu, 22 Nov 2018 07:38:54 -0800 (PST) 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:openpgp:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=JtySdEstPEXWdAL+wF7f+LNlkjWHbC10pqX37cH4z5g=; b=JG02MovW2X3IY3TdDCpdzZJqLPPFWLJFMAi2ZEhgoMeHaLBUaYYKwV1yjMma7F5l68 ymc7z1TJQgNETDD41vFoxaPNbAnMgbtcsQWGCmz2fEmoVxgOvm6cC65eTO3v9BE+K2TY 71MsNqE/gkktS28JIDN2Ev2WnRNxj7/mQ7iOUlfsd80O/hZ+hUJfr8lGEToSeEyZFHVo GdSltVly38W82a4okFsaYPwbk9sX2qqc7QUoBdPCwB61Dh9CB0uV6sN20zzGbt547nw8 to6Mc9P1ZQ7eqoAqv9Cg0YIFnzPwW3CGcj4cYQRSa6jzFCcP5qSWDfrDLUuAJDD8BW0G 4VFg== X-Gm-Message-State: AA+aEWZzCZTm2JytOI9t0AP1+QJ+ZA/Eg2k2mzfyCRL2IdeXdeW4bo/d O+rXFOCoFxOc1pjjV7Or0FxrxA== X-Google-Smtp-Source: AFSGD/Xo9nv0QicRhENGAgMZYTlFnGRfNH6N0nbYzhwXxFj2No1EYTiBJZJTF2BspYwuOl+WNOii7g== X-Received: by 2002:a5d:4b42:: with SMTP id w2mr10208579wrs.156.1542901132969; Thu, 22 Nov 2018 07:38:52 -0800 (PST) Received: from [192.168.1.33] (75.red-83-57-172.dynamicip.rima-tde.net. [83.57.172.75]) by smtp.gmail.com with ESMTPSA id i9sm21107663wrs.34.2018.11.22.07.38.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Nov 2018 07:38:52 -0800 (PST) To: Ard Biesheuvel , edk2-devel@lists.01.org Cc: leif.lindholm@linaro.org, lersek@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: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= Openpgp: url=http://pgp.mit.edu/pks/lookup?op=get&search=0xA2A3FD6EDEADC0DE Message-ID: Date: Thu, 22 Nov 2018 16:38:51 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: <20181121115828.3026-4-ard.biesheuvel@linaro.org> 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 15:38:54 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit On 21/11/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'. So take this into account > when iterating over nodes. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel Reviewed-by: Philippe Mathieu-Daudé > --- > 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; > } > >