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: 827369 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=devicetree-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="aRWEt1uJ"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yGs8g2ySsz9t3m for ; Wed, 18 Oct 2017 10:38:59 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756916AbdJQXio (ORCPT ); Tue, 17 Oct 2017 19:38:44 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:44470 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1764751AbdJQXgv (ORCPT ); Tue, 17 Oct 2017 19:36:51 -0400 Received: by mail-pf0-f194.google.com with SMTP id x7so2520875pfa.1; 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=a5KcOBcJ4M2woJ9J/KOgbrty9UvdQ0d6mSHsSL5M5We6bGVEX5fsKHwjXBSnUPSd1G P1RWBxf+DN4HPrAxJZh5dlxk3O7vvr6OkvJRNhPYRDXLf8NiHS4sjGsWMEmk8ER+Z68Q sn5w2iHM3W2LZMhPjTPir4D76uE/w3DjsIE+otZX6hdzwZoMkvoC1EFlzknDAsiEYpNr oVzWHmkokMItGR+ettyZK/Xq69YK0CMzucrBlkK5ZFadvgNObgZApURL+LQh4ch481vA lZ+ZQhbW/K7kPAyGe81uQc3sTK8t4un1m20p1j8gS44bjJwacBlJy/pm1GDHNUhIBexo GKcw== X-Gm-Message-State: AMCzsaWtqYDhKqeLtz7JoZ2cLbzwG3iEI78pwPmVNeXNgNobFMfcjCHu QmaxY0eBwqXYHtV9igb9UkY= 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 Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Rutland , Tomi Valkeinen , dri-devel@lists.freedesktop.org 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> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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; }