From patchwork Tue Oct 17 23:36:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Rowand X-Patchwork-Id: 10014027 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0AC6360215 for ; Wed, 18 Oct 2017 08:17:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EED5B28AF1 for ; Wed, 18 Oct 2017 08:17:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E36AC28AF9; Wed, 18 Oct 2017 08:17:18 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A13F028AF1 for ; Wed, 18 Oct 2017 08:17:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EFE066E7FC; Wed, 18 Oct 2017 08:17:10 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf0-x244.google.com (mail-pf0-x244.google.com [IPv6:2607:f8b0:400e:c00::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 98E196E7B0 for ; Tue, 17 Oct 2017 23:36:51 +0000 (UTC) Received: by mail-pf0-x244.google.com with SMTP id b6so2511520pfh.7 for ; Tue, 17 Oct 2017 16:36:51 -0700 (PDT) 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=v0WYzee5xi3hWaYUc2art3mNxn5digk3oKY3t/70r6g=; b=aRWEt1uJYUVOvAQlxA7Waz6JEBYm3jq8bOy15LlLtobGNNEHnrGvqxy1ZSkU/FiNHA 9t+A/EEjG1nF1dyAzAyMS0Ke2HQAWwBaZnYf2TFd5d6W3gQsQmkdOpXVUmaSDlCkhrhX v3f1vrAAQq5wyHufZD3g9puEw0jv74UxDeOfDfi31FZ881w7Guhr4SyS2i18OWFJs3ap VS+Q5vlrYZ64AF9QV64QC22y1r1psZ47YPkJ8GFNrcL2HB4k9bzCy0TEhlhaR2ADGwqY lsEXnCLUubPu0YV/uSv4nj929QYsV/rWQLWj7UE4c3v01Ya5laOgaR4tgFMdAFLH6bj+ hdeA== 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=v0WYzee5xi3hWaYUc2art3mNxn5digk3oKY3t/70r6g=; b=Amypy8Ou9z316X/T50dEvw0RBY2O3/2BYUtynSQxRy+TyTYUWAjLQmEHDNdA+cHhWh +xPXlUjrYmre67o033dzAXyP26idP3CFrJLjPLIIKOZ9oq2WTELqcdkp/cyAa+OgrlFk ffQTb2J02k6U1NK+Zcr9+yoTJZ12wU8tst8LrNAA1lTLMqE4xM8lez8DC5VdXBTo0Y6z ZAMmMmLbZxH0D6yPICB/SZKmAB3zRyFE8fspHXTJ1g42wCQLh8ryi/WE/eDFMswetA2i Sq4ucC5L8zOvPgaZgXCQqwBds53kuKQqCoJqvBYD8KKSi4Cn92Krle9gd7l6IQZAG8kE Aghw== X-Gm-Message-State: AMCzsaXjrusBxzGu2UBCFaBeyw9egVPiZoU3hwUXJ+Up4bx4TqXC0ui0 /nlznzIaYkJl7d1layHfYQU= X-Google-Smtp-Source: AOwi7QBNAXzfaId/sCK0aRaRXZsWsdjiS3v6tj+7zz0Z3s6+DbS1IzwldvGHlvu/BeLUavkbyCs1nA== X-Received: by 10.98.157.156 with SMTP id a28mr13358399pfk.74.1508283411325; Tue, 17 Oct 2017 16:36:51 -0700 (PDT) Received: from localhost.localdomain (c-73-93-215-6.hsd1.ca.comcast.net. [73.93.215.6]) by smtp.gmail.com with ESMTPSA id 76sm21185562pfq.4.2017.10.17.16.36.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Oct 2017 16:36:50 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , David Airlie , Jyri Sarha Subject: [PATCH v3 07/12] of: overlay: expand check of whether overlay changeset can be removed Date: Tue, 17 Oct 2017 16:36:27 -0700 Message-Id: <1508283392-18252-8-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1508283392-18252-1-git-send-email-frowand.list@gmail.com> References: <1508283392-18252-1-git-send-email-frowand.list@gmail.com> X-Mailman-Approved-At: Wed, 18 Oct 2017 08:17:10 +0000 Cc: Mark Rutland , devicetree@vger.kernel.org, Tomi Valkeinen , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Frank Rowand The test of whether it is safe to remove an overlay changeset looked at whether any node in the overlay changeset was in a subtree rooted at any more recently applied overlay changeset node. The test failed to determine whether any node in the overlay changeset was the root of a subtree that contained a more recently applied overlay changeset node. Add this additional check to the test. The test is still lacking any check for any phandle dependencies. Signed-off-by: Frank Rowand --- drivers/of/overlay.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index 78c50fd57750..4cdee169a5ab 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -707,13 +707,13 @@ static int find_node(struct device_node *tree, struct device_node *np) } /* - * Is @remove_ce_np a child of or the same as any + * Is @remove_ce_node a child of, a parent of, or the same as any * node in an overlay changeset more topmost than @remove_ovcs? * * Returns 1 if found, else 0 */ -static int node_in_later_cs(struct overlay_changeset *remove_ovcs, - struct device_node *remove_ce_np) +static int node_overlaps_later_cs(struct overlay_changeset *remove_ovcs, + struct device_node *remove_ce_node) { struct overlay_changeset *ovcs; struct of_changeset_entry *ce; @@ -723,10 +723,16 @@ static int node_in_later_cs(struct overlay_changeset *remove_ovcs, break; list_for_each_entry(ce, &ovcs->cset.entries, node) { - if (find_node(ce->np, remove_ce_np)) { - pr_err("%s: #%d clashes #%d @%pOF\n", + if (find_node(ce->np, remove_ce_node)) { + pr_err("%s: #%d overlaps with #%d @%pOF\n", __func__, remove_ovcs->id, ovcs->id, - remove_ce_np); + remove_ce_node); + return 1; + } + if (find_node(remove_ce_node, ce->np)) { + pr_err("%s: #%d overlaps with #%d @%pOF\n", + __func__, remove_ovcs->id, ovcs->id, + remove_ce_node); return 1; } } @@ -750,7 +756,7 @@ static int overlay_removal_is_ok(struct overlay_changeset *remove_ovcs) struct of_changeset_entry *remove_ce; list_for_each_entry(remove_ce, &remove_ovcs->cset.entries, node) { - if (node_in_later_cs(remove_ovcs, remove_ce->np)) { + if (node_overlaps_later_cs(remove_ovcs, remove_ce->np)) { pr_err("overlay #%d is not topmost\n", remove_ovcs->id); return 0; }