Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6398626ybv; Wed, 12 Feb 2020 11:25:58 -0800 (PST) X-Google-Smtp-Source: APXvYqySKItBGk5AldNI6stI72CiQQDH90lpGQTJ4C4bcd0Nh65SDNLVzQswaIJ9jQDRWN7Rdzfu X-Received: by 2002:a9d:6283:: with SMTP id x3mr10173915otk.367.1581535558297; Wed, 12 Feb 2020 11:25:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581535558; cv=none; d=google.com; s=arc-20160816; b=RrH3p50/hdvpz5dZuyariGZuhvRJH6EoHHY525L0lVKWzvnExI/Cs0TPTLASeDoXz+ 7NV7F0r+y/EQrWESRSSGhIGv1bbRrX+MPWNOtg6c0aJjdTwSpDEhmQi+CUm8eft1Rc2g Q+EsUNzy0NqMyzG0tAXA7I4jqKJjFWdKmQtVce7a7qk43AZzyho6acjfmRSZcdoztvGx rssconLhe73d+mjG/lFZLP1dkVPoihe9k7YE+f8DgYQRS1fJlX9ZdEQ0PLDmc/8CwKN+ 7Yfm5N5UyNBgriFM0RiNmnPXf7gc4uL8JY22ZEiML0sJ99zAW1wbCxtssXNYaxMumJ3y fiSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=e8exSTDAg5sZLZmlGK8nUZyqln3uI9i458uB0Q1NwKc=; b=0MRSpTgAA/RTRq77er/Q+H/7SUzU559JUg++SuzsIfVLj5HC/3nZxJuQM+5VVy+CWc V0Q0VCg63I9zsZRH3Jzid8M5B21mbuy9Nft28YOFf4afQnfh9uwsPuqNYemMzh7WJTIR GL/I99GjfhP/gpPeDZH80wkTu4IH+idQH5TxF7W3I7wx8EOAgwm9g8W6UxFu8qOE2Hzd FujenngXIjwjD3I2QUYGhJK7f2YeFm1lxIuFzCGI7b1NFE0vhSOLbHbYVb2vuharAN5/ DRdLfSAFkZ11ZOmXpSvJPUDSQaXG2S/SQerk6TtSoXCDeB+B9Dw6t+ERHOlMfyO9rqGl jOJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="KxM9mFd/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i15si658577otk.120.2020.02.12.11.25.45; Wed, 12 Feb 2020 11:25:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="KxM9mFd/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728958AbgBLTZh (ORCPT + 99 others); Wed, 12 Feb 2020 14:25:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:48818 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728775AbgBLTZh (ORCPT ); Wed, 12 Feb 2020 14:25:37 -0500 Received: from mail-qk1-f174.google.com (mail-qk1-f174.google.com [209.85.222.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ED8F2217F4; Wed, 12 Feb 2020 19:25:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581535536; bh=xjAs5P+3VFbhq1+HKipj0rlkvXEzY5u1PSc9zD/yAMA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=KxM9mFd/fproB88bxg02lKfgUh3Du7/kDwLfqln8PlYhzIDJrDG8vgHppaX4Da0a4 NmE8uLTTY1pvtZIaSERemdT/5VbSCee1YWHPOtdkXkc7FC3LUZxhHBoGm6O+kmUpiB iHzpFAHJ/mb1PYz/BlDWpE90vQWXIV4rlGLJe7m8= Received: by mail-qk1-f174.google.com with SMTP id c20so3243932qkm.1; Wed, 12 Feb 2020 11:25:35 -0800 (PST) X-Gm-Message-State: APjAAAWmV+BGA3+7r9vWU4K9S7DCYvO7azuxHEbZrp+r46nuYXM07aYa Bg2lcHuuqw449sYzVf1Pw34gthjZ874kHjfzGg== X-Received: by 2002:ae9:f205:: with SMTP id m5mr12569288qkg.152.1581535535057; Wed, 12 Feb 2020 11:25:35 -0800 (PST) MIME-Version: 1.0 References: <20200204125844.19955-1-m.szyprowski@samsung.com> <20200205054508.GG60221@umbus.fritz.box> <20200210234406.GH22584@umbus.fritz.box> <1cc6258c-5bf3-3d48-2d6d-1a7176af1459@samsung.com> In-Reply-To: <1cc6258c-5bf3-3d48-2d6d-1a7176af1459@samsung.com> From: Rob Herring Date: Wed, 12 Feb 2020 13:25:23 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] libfdt: place new nodes & properties after the parent's ones To: Marek Szyprowski Cc: David Gibson , Devicetree Compiler , "linux-kernel@vger.kernel.org" , Bartlomiej Zolnierkiewicz Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 12, 2020 at 12:57 AM Marek Szyprowski wrote: > > Hi Rob, > > On 11.02.2020 21:29, Rob Herring wrote: > > On Mon, Feb 10, 2020 at 5:44 PM David Gibson > > wrote: > >> On Mon, Feb 10, 2020 at 12:40:19PM +0100, Marek Szyprowski wrote: > >>> Hi David, > >>> > >>> On 05.02.2020 06:45, David Gibson wrote: > >>>> On Tue, Feb 04, 2020 at 01:58:44PM +0100, Marek Szyprowski wrote: > >>>>> While applying dt-overlays using libfdt code, the order of the applied > >>>>> properties and sub-nodes is reversed. This should not be a problem in > >>>>> ideal world (mainline), but this matters for some vendor specific/custom > >>>>> dtb files. This can be easily fixed by the little change to libfdt code: > >>>>> any new properties and sub-nodes should be added after the parent's node > >>>>> properties and subnodes. > >>>>> > >>>>> Signed-off-by: Marek Szyprowski > >>>> I'm not convinced this is a good idea. > >>>> > >>>> First, anything that relies on the order of properties or subnodes in > >>>> a dtb is deeply, fundamentally broken. That can't even really be a > >>>> problem with a dtb file itself, only with the code processing it. > >>> I agree about the properties, but generally the order of nodes usually > >>> implies the order of creation of some devices or objects. > >> Huh? From the device tree client's point of view the devices just > >> exist - the order of creation should not be visible to it. > > I'm not sure if downstream is different, but upstream this stems from > > Linux initcalls being processed in link order within a given level. > > It's much better than it used to be, but short of randomizing the > > ordering, I'm not sure we'll ever find and fix all these hidden > > dependencies. > > Downstream is probably much worse, because I've seen a lots of custom > code iterating over the nodes and doing its initialization. > > >>> This sometimes > >>> has some side-effects. > >> If those side effects matter, your code is broken. If you need to > >> apply an order to nodes, you should be looking at 'reg' or other > >> properties. > > The general preference is to sort by 'reg'. And we try to catch and > > reject any node re-ordering patches. > > If one applies an dt-overlay with current libfdt, the order of the all > nodes from that overlay is reversed. Sure, but my caring about the ordering ends at the source level. Rob