Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp374923imu; Thu, 8 Nov 2018 22:09:09 -0800 (PST) X-Google-Smtp-Source: AJdET5c1wgtvaZTUXvKhaB7c82B6XgjcVlPgHJGQ69Pcas8NI2usI3cS4L2nc/dRvjR3c8CGvZW+ X-Received: by 2002:a63:8549:: with SMTP id u70mr6355860pgd.401.1541743749809; Thu, 08 Nov 2018 22:09:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541743749; cv=none; d=google.com; s=arc-20160816; b=p3JGn43rpOjj7mCdF9V9XaNqswKLD+LndavDgACugzaCInPcZ+sj0pyoScvojCw2qg FMRK/pgcKGXT6ULJScNKPEqhnBvBVmB6ZPrqpMYv4WBD5ufc6SBvdRqwvrFvUPn3nY1N IWFyB1Q10/kU27vdaTQepTOb/amHVKLAl/agvOU4x7yEfn/Em1c38zfeIQSoJoPEDvU4 nBHKvNfl8hNViNJnBwbZEcBoUzACAt0uWCfO61zw3GCF00mmAjKwvETcSRwDe2sFM+EO OACNcwR1KMLDgtzne+9693PJ5Vcxm9lQRKZtOwX3yF7NABf/e5Su61hfWeIo1NckNI3D /Myw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=SEAqeXPr99Q2vo/zszVi0jNkz0OnJqyskwx/aIyN+c0=; b=w97T1bsKBgn9dhHdKqpN3uomcaIFgO5wjvMWMZfbiAnrIZ2+nreizMyMp3cL37Wdl0 ngBu+8PK25ZLPmUPPXFyhD8Ds0PjTXXEMSYm2gcZpMvrgEhmoUqFYwPgnNTkMwLslow/ iO2MV5hgJfwSPbcCJ9biUSWnyuc1Iyv9qJtg3R7u1C0EJxceu8huPLPE0wrD/sdLSiBK 1jB9Gfka9UwjgVFi/nO3gTdODtBRu36YK65wqUEgO0p7B5fXBdF8OHpeVieBniF2JtSg 4cuV5uTxEDtp8ryFxByOV8nXA7W1LzeWgtlSDsG0A+qtRMlsneJGvLyjioOokXSOfRGs j67Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sUuZQP+1; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e33-v6si6878452pld.314.2018.11.08.22.08.54; Thu, 08 Nov 2018 22:09:09 -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=@gmail.com header.s=20161025 header.b=sUuZQP+1; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728173AbeKIPrD (ORCPT + 99 others); Fri, 9 Nov 2018 10:47:03 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:41697 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727603AbeKIPrC (ORCPT ); Fri, 9 Nov 2018 10:47:02 -0500 Received: by mail-pl1-f194.google.com with SMTP id p16-v6so445766plr.8; Thu, 08 Nov 2018 22:08:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SEAqeXPr99Q2vo/zszVi0jNkz0OnJqyskwx/aIyN+c0=; b=sUuZQP+10rT8qlPm2G+qfWMYj4ZkNH/cfarDkYfOZHWJPXn8l038Dp2+G0Y1j3foCV nM9u2fo9QoAEoVXDfBNU4OxDtecin8e5nqfy2/l30/+U/08mOTUiE5ZmpHfgEED0BNi4 M9bX4eag8EpJfLUvZ2TsZAMrLEDkGwfQhYVbVkzJ1S2oArjFwA3j+SsguOKo5krsk8qO wfPofyDeEIMECCuLKjRq0fvkusTeHOLLEFVt1rCzhIxAPHH54i2YS8qKjywUO+5ji+Dg n7nJ90GNrGYU/tGlPP8xj0QSr8FODQOj59OiuaB1YTcniJ+lHv2Z2++xc6Vozdmq1FZS aTPw== 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; bh=SEAqeXPr99Q2vo/zszVi0jNkz0OnJqyskwx/aIyN+c0=; b=q6KGb4uJ/nmF5Czw/3RYWhphOJZFYQbcQg5iyxVH+trnBtYskvsb4Eo+1w1MX9ww61 gVufo50XSS8il0/8hzWHPNi3Q0pYpZFaLGu8/VtIQp7XaIaTMgHzxjl4gX2Txo6FatX3 vnytyH4+oU8EZWMbm44x6K7PxUo+zOFwHfGuAkv/WDu4++de+pfEs9bcghzrAe6qiLaA hQMWJkd796p0KiLtKpinFr3o0tpSLY3UATXHrQXaWHoSKWC7+DtUd/ZgOYqDtDQ5bn01 to6Rk6ylJJn7g4biFJ/R1WMW/ktW311b/ziVI+toy5wRvaH737Ehi5uJl5JKfgt7Rg9p xlPg== X-Gm-Message-State: AGRZ1gIhKnbcbYWLVgIz8n2DxbeaB9x8A7/qWj4d7daEfe48xb7R2xNy 1Mj6hWN97tt4Y+bBC9829b4= X-Received: by 2002:a17:902:5a43:: with SMTP id f3-v6mr7670203plm.57.1541743681300; Thu, 08 Nov 2018 22:08:01 -0800 (PST) Received: from localhost.localdomain (c-24-6-192-50.hsd1.ca.comcast.net. [24.6.192.50]) by smtp.gmail.com with ESMTPSA id c70-v6sm6620722pfg.97.2018.11.08.22.08.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Nov 2018 22:08:00 -0800 (PST) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alan Tull , Moritz Fischer Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, devicetree@vger.kernel.org, linux-fpga@vger.kernel.org Subject: [PATCH v7 14/17] of: overlay: set node fields from properties when add new overlay node Date: Thu, 8 Nov 2018 22:06:02 -0800 Message-Id: <1541743565-23163-15-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1541743565-23163-1-git-send-email-frowand.list@gmail.com> References: <1541743565-23163-1-git-send-email-frowand.list@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Frank Rowand Overlay nodes added by add_changeset_node() do not have the node fields name, phandle, and type set. The node passed to __of_attach_node() when the add node changeset entry is processed does not contain any properties. The node's properties are located in add property changeset entries that will be processed after the add node changeset is applied. Set the node's fields in the node contained in the add node changeset entry and do not set them to incorrect values in add_changeset_node(). A visible symptom that is fixed by this patch is the names of nodes added by overlays that have an entry in /sys/bus/platform/drivers/*/ will contain the unit-address but the node-name will be , for example, "fc4ab000.". After applying the patch the name, in this example, for node restart@fc4ab000 is "fc4ab000.restart". Tested-by: Alan Tull Signed-off-by: Frank Rowand --- drivers/of/dynamic.c | 27 ++++++++++++++++++--------- drivers/of/overlay.c | 29 ++++++++++++++++++++++++----- 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c index 146681540487..b4e5b90cb314 100644 --- a/drivers/of/dynamic.c +++ b/drivers/of/dynamic.c @@ -205,15 +205,24 @@ static void __of_attach_node(struct device_node *np) const __be32 *phandle; int sz; - np->name = __of_get_property(np, "name", NULL) ? : ""; - np->type = __of_get_property(np, "device_type", NULL) ? : ""; - - phandle = __of_get_property(np, "phandle", &sz); - if (!phandle) - phandle = __of_get_property(np, "linux,phandle", &sz); - if (IS_ENABLED(CONFIG_PPC_PSERIES) && !phandle) - phandle = __of_get_property(np, "ibm,phandle", &sz); - np->phandle = (phandle && (sz >= 4)) ? be32_to_cpup(phandle) : 0; + if (!of_node_check_flag(np, OF_OVERLAY)) { + np->name = __of_get_property(np, "name", NULL); + np->type = __of_get_property(np, "device_type", NULL); + if (!np->name) + np->name = ""; + if (!np->type) + np->type = ""; + + phandle = __of_get_property(np, "phandle", &sz); + if (!phandle) + phandle = __of_get_property(np, "linux,phandle", &sz); + if (IS_ENABLED(CONFIG_PPC_PSERIES) && !phandle) + phandle = __of_get_property(np, "ibm,phandle", &sz); + if (phandle && (sz >= 4)) + np->phandle = be32_to_cpup(phandle); + else + np->phandle = 0; + } np->child = NULL; np->sibling = np->parent->child; diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index 184cc2c4a931..2b5ac43a5690 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -307,10 +307,11 @@ static int add_changeset_property(struct overlay_changeset *ovcs, int ret = 0; bool check_for_non_overlay_node = false; - if (!of_prop_cmp(overlay_prop->name, "name") || - !of_prop_cmp(overlay_prop->name, "phandle") || - !of_prop_cmp(overlay_prop->name, "linux,phandle")) - return 0; + if (target->in_livetree) + if (!of_prop_cmp(overlay_prop->name, "name") || + !of_prop_cmp(overlay_prop->name, "phandle") || + !of_prop_cmp(overlay_prop->name, "linux,phandle")) + return 0; if (target->in_livetree) prop = of_find_property(target->np, overlay_prop->name, NULL); @@ -330,6 +331,10 @@ static int add_changeset_property(struct overlay_changeset *ovcs, if (!prop) { check_for_non_overlay_node = true; + if (!target->in_livetree) { + new_prop->next = target->np->deadprops; + target->np->deadprops = new_prop; + } ret = of_changeset_add_property(&ovcs->cset, target->np, new_prop); } else if (!of_prop_cmp(prop->name, "#address-cells")) { @@ -400,9 +405,10 @@ static int add_changeset_node(struct overlay_changeset *ovcs, struct target *target, struct device_node *node) { const char *node_kbasename; + const __be32 *phandle; struct device_node *tchild; struct target target_child; - int ret = 0; + int ret = 0, size; node_kbasename = kbasename(node->full_name); @@ -416,6 +422,19 @@ static int add_changeset_node(struct overlay_changeset *ovcs, return -ENOMEM; tchild->parent = target->np; + tchild->name = __of_get_property(node, "name", NULL); + tchild->type = __of_get_property(node, "device_type", NULL); + + if (!tchild->name) + tchild->name = ""; + if (!tchild->type) + tchild->type = ""; + + /* ignore obsolete "linux,phandle" */ + phandle = __of_get_property(node, "phandle", &size); + if (phandle && (size == 4)) + tchild->phandle = be32_to_cpup(phandle); + of_node_set_flag(tchild, OF_OVERLAY); ret = of_changeset_attach_node(&ovcs->cset, tchild); -- Frank Rowand