From patchwork Sat Apr 24 04:56:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1469895 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=gpR5UprS; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FRzWJ3YLyz9sT6 for ; Sat, 24 Apr 2021 15:00:44 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C1C8782CEA; Sat, 24 Apr 2021 06:58:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="gpR5UprS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9A08482CAB; Sat, 24 Apr 2021 06:57:24 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D328080C58 for ; Sat, 24 Apr 2021 06:57:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-pj1-x102f.google.com with SMTP id h14-20020a17090aea8eb02901553e1cc649so149885pjz.0 for ; Fri, 23 Apr 2021 21:57:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=15WxaYqtR8o3AlpzchjYGB+vOh9PK8NP1eISMepkX9Q=; b=gpR5UprSpP3zmjQyYLKcrEQlnYpIuOrliFiRPGicQgc5bTDWsrQPtlYTP12m5cgwNJ 2yIqisIUe0AB6pvRugRm0Evq/rHsdRtKi5c8exS6K7Md26YIQa1qc+/zb9p8w6t43Brz uJChSsXqaInfgTkonJATUWOPBbGicnC9As93k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=15WxaYqtR8o3AlpzchjYGB+vOh9PK8NP1eISMepkX9Q=; b=YO93kFC3q693SCl5LWYpSvR6AwV+k/5Snqn2MbwY/rLpAL/j20U4NYcnNDsk7g53W9 EkbgS8xYYsGALWYacpJJDXfURrupHTMIiQUkzL9sV2OrCxJ7FS8u+FrWKudoicXOeczD BK+uALwzjOKaeibyY3ENYZbiRZTkB4UhtVqndVhsk8rBpUCGcrosDHcpjKMztCR1JBMY CscKCPcKSJBfc0ToR0q1bL6nk6OnOCOzl5d9RpHQZ2WnfPE7PVULl2F2lJuIkKdmkGMd WDO5uYEOQLbv8zskhAyWYxt6GbXQ8obn2ZggldfmlGfPr3rck0wKSJLy9VroYRpSRb5x rq+A== X-Gm-Message-State: AOAM531BpQB/GhOcDyPR9l4ebmkl7TJKh1vnnUR1wFOWig0l2YQKkpSa ru4BA5Ss1sb0FBEWmmEVzKmSClVgleRjrdVA X-Google-Smtp-Source: ABdhPJwLBfKDQ6V7evCz8SRWHg7nAkuawVjzlrCGjhzhDN6kKvaI/imiAARTjwf3tGx/rIPsGvbXoA== X-Received: by 2002:a17:902:d4c6:b029:ec:881b:fdfb with SMTP id o6-20020a170902d4c6b02900ec881bfdfbmr7405126plg.83.1619240239167; Fri, 23 Apr 2021 21:57:19 -0700 (PDT) Received: from sjg1.roam.corp.google.com ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l35sm5949077pgm.10.2021.04.23.21.57.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 21:57:18 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass Subject: [PATCH v2 15/16] dtoc: Check that a parent is not missing Date: Sat, 24 Apr 2021 16:56:25 +1200 Message-Id: <20210424165534.v2.15.I11cd6003245319bf9c867b3b6e0feadb1a5d09b1@changeid> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210424045627.313802-1-sjg@chromium.org> References: <20210424045627.313802-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean With of-platdata-inst we want to set up a reference to each devices' parent device, if there is one. If we find that the device has a parent (i.e. is not a root node) but it is not in the list of devices being written, then we cannot create the reference. Report an error in this case, since it indicates that the parent node is either missing a compatible string, is disabled, or perhaps does not have any properties because it was not tagged for SPL. Signed-off-by: Simon Glass --- (no changes since v1) tools/dtoc/dtb_platdata.py | 9 ++++++++ tools/dtoc/test/dtoc_test_noparent.dts | 32 ++++++++++++++++++++++++++ tools/dtoc/test_dtoc.py | 10 ++++++++ 3 files changed, 51 insertions(+) create mode 100644 tools/dtoc/test/dtoc_test_noparent.dts diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py index 1374f01c707..c303224e295 100644 --- a/tools/dtoc/dtb_platdata.py +++ b/tools/dtoc/dtb_platdata.py @@ -749,6 +749,15 @@ class DtbPlatdata(): break if node.parent and node.parent.parent: + if node.parent not in self._valid_nodes: + # This might indicate that the parent node is not in the + # SPL/TPL devicetree but the child is. For example if we are + # dealing with of-platdata in TPL, the parent has a + # u-boot,dm-spl tag but the child has u-boot,dm-pre-reloc. In + # this case the child node exists in TPL but the parent does + # not. + raise ValueError("Node '%s' requires parent node '%s' but it is not in the valid list" % + (node.path, node.parent.path)) self.buf('\t.parent\t\t= DM_DEVICE_REF(%s),\n' % node.parent.var_name) if priv_name: diff --git a/tools/dtoc/test/dtoc_test_noparent.dts b/tools/dtoc/test/dtoc_test_noparent.dts new file mode 100644 index 00000000000..5a820301e72 --- /dev/null +++ b/tools/dtoc/test/dtoc_test_noparent.dts @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Test device tree file for dtoc + * + * Copyright 2017 Google, Inc + */ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + i2c@0 { + compatible = "sandbox,i2c"; + u-boot,dm-pre-tpl; + #address-cells = <1>; + #size-cells = <0>; + spl-test { + u-boot,dm-pre-reloc; + compatible = "sandbox,spl-test"; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + pmic@9 { + compatible = "sandbox,pmic"; + u-boot,dm-pre-reloc; + reg = <9>; + low-power; + }; + }; + }; +}; diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py index a05e3d9ed65..e7397ae554b 100755 --- a/tools/dtoc/test_dtoc.py +++ b/tools/dtoc/test_dtoc.py @@ -1839,3 +1839,13 @@ U_BOOT_DRVINFO(spl_test2) = { dtb_file = get_dtb_file('dtoc_test_single_reg.dts') output = tools.GetOutputFilename('output') self.run_test(['struct'], dtb_file, output) + + def test_missing_parent(self): + """Test detection of a parent node with no properties""" + dtb_file = get_dtb_file('dtoc_test_noparent.dts', capture_stderr=True) + output = tools.GetOutputFilename('output') + with self.assertRaises(ValueError) as exc: + self.run_test(['device'], dtb_file, output, instantiate=True) + self.assertIn("Node '/i2c@0/spl-test/pmic@9' requires parent node " + "'/i2c@0/spl-test' but it is not in the valid list", + str(exc.exception))