From patchwork Mon Nov 5 15:25:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 10668487 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BF3B115A6 for ; Mon, 5 Nov 2018 15:27:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC203285A9 for ; Mon, 5 Nov 2018 15:27:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A03AC28660; Mon, 5 Nov 2018 15:27:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC6B0285A9 for ; Mon, 5 Nov 2018 15:27:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729447AbeKFAr0 (ORCPT ); Mon, 5 Nov 2018 19:47:26 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:44309 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387498AbeKFArZ (ORCPT ); Mon, 5 Nov 2018 19:47:25 -0500 Received: by mail-pl1-f196.google.com with SMTP id s5-v6so4606327plq.11; Mon, 05 Nov 2018 07:27:12 -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=3ciaLJltZs4ZzlMFeB4pL74pMQM1ojz2TgXqUVWSiYE=; b=fIe9HWzqJ7sznFNMMjgGTLEvWRIcFLQokzhRzPspDp5U9CFZ90jNxARJxoCj+C9Zsk Ui9qJmjQR7f1bB8J2ALVPuHkVxJ7mrEPlQDPdCcIfBznN2wpzdqqqMenCjD2yjS41Rrk 7thNduH69a9VF0Qp9g3/CF7/Zu6Oe2plf9kIolbdx6/UN27BfE60OzwqqaUz6/o/mztJ gF8v8d0IJiaOA4BJEQ8pERBVM75mepZQiSbH/rDNzEa8HpLNk+h2vwqoptNfsz1o7w+y z4kCV283E35983OAbovuqCM5ppGLgqN//WLh3kxwkcNvpQ5HmaogFhq9shDimVQi8ubk LUcw== 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=3ciaLJltZs4ZzlMFeB4pL74pMQM1ojz2TgXqUVWSiYE=; b=SIuswI+cR5v3Na+TpfMMoJXZF2AuCH8yN0xZVZVOlmAE7gBQQ7k/KbLFdygk39FCxr SvskFpSiK07pCEwarEHjvVzNWKoV+ZUKenfyhs+h3CIj8u0D02oGpWZ5nTGEzd9nqFYh MgDEs70Qgm0268VTzSLx6qhy7Eph2qagNm1nSvNfbYwYWHFh2MxQv9ItXlhWcBUkM/HR FNP9/JKCHSyufTAJwKmxJP4MM2ange3lKkr/xn36XLhQXNCcePbX2tut3FR/+I8PF7Mw 2KHhGuaDc8U9eTOKvTGObbe7t18PdNhQPXI+26oyLNE/trxjUaiXZ/k8vWoirG4ad7mE gT9Q== X-Gm-Message-State: AGRZ1gLJLLkYT8IeC3DPPe6kcQB14/Dy2IySZu6KSPdMuyw56T4Vd8dh 5K6+4rMWa5U0g2q7CsLlUEE= X-Google-Smtp-Source: AJdET5dw/d9CJc2ChzHH5Dj3SCmHD0O7TQ/jl1cPDWbmf+uBWKEs2967O2zCHhZytUMPiXEp6lWMXA== X-Received: by 2002:a17:902:e089:: with SMTP id cb9-v6mr21871887plb.196.1541431632312; Mon, 05 Nov 2018 07:27:12 -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 u76-v6sm37260578pfa.176.2018.11.05.07.27.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Nov 2018 07:27:11 -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 v6 15/18] of: overlay: set node fields from properties when add new overlay node Date: Mon, 5 Nov 2018 07:25:12 -0800 Message-Id: <1541431515-25197-16-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1541431515-25197-1-git-send-email-frowand.list@gmail.com> References: <1541431515-25197-1-git-send-email-frowand.list@gmail.com> Sender: linux-fpga-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 beea792debb6..43e1ccb9c387 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);