From patchwork Sat Oct 4 20:30:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Likely X-Patchwork-Id: 38355 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0DEC220DE0 for ; Sat, 4 Oct 2014 20:30:59 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id cc10sf507298wib.7 for ; Sat, 04 Oct 2014 13:30:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=NaLXTBqAkODlg+wJ/68LYjhy0BGYY3uzGRSTnVmXRls=; b=kWo7TPkJ3xvJtmW4dcnbsZBny8QH0GUurWCgHfPCtRaeb/h4z+Eo/1vrRirARzJ9xa TP7R90bXhUGNbJ2NyDjwmdJ/Xa+MFiFOAQXV3u9JKCYBH46eKSMHgNrmVPDGXjv64EB6 3DXn1DcQoGOul3oPesR8C8Qq/Qqp7Uf+WDjrCrimH0E6ROLriZNIQPI5+PveNUeFI1zO e5NNSivtOHnqzmh5R6r7MHdFunkQBQILMIXO6T1Y9dteDOljPurrueL2Ddzpq/jk6MEb daWg+r2iYSmWKkfgWOYwYZU9TCotlfWP7gRxh5J8+Jtu4/wORjVS8+j8/uam/2TkRGar /pDw== X-Gm-Message-State: ALoCoQkHb+sz+IngOtBPEHEEikDeH2dlpL6ZIUPlQjXRdMrJpOuTK/tZjcGX0FDOB56me2bKb7jJ X-Received: by 10.194.179.196 with SMTP id di4mr2240076wjc.0.1412454659274; Sat, 04 Oct 2014 13:30:59 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.42.171 with SMTP id p11ls400447lal.68.gmail; Sat, 04 Oct 2014 13:30:59 -0700 (PDT) X-Received: by 10.112.171.202 with SMTP id aw10mr13655155lbc.52.1412454659028; Sat, 04 Oct 2014 13:30:59 -0700 (PDT) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com [209.85.217.180]) by mx.google.com with ESMTPS id zk2si17113225lbb.51.2014.10.04.13.30.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 04 Oct 2014 13:30:58 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by mail-lb0-f180.google.com with SMTP id f15so2519927lbj.25 for ; Sat, 04 Oct 2014 13:30:58 -0700 (PDT) X-Received: by 10.152.7.145 with SMTP id j17mr4550330laa.67.1412454658909; Sat, 04 Oct 2014 13:30:58 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.130.169 with SMTP id of9csp76230lbb; Sat, 4 Oct 2014 13:30:58 -0700 (PDT) X-Received: by 10.68.94.34 with SMTP id cz2mr14795302pbb.7.1412454655626; Sat, 04 Oct 2014 13:30:55 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id pl6si7343357pdb.111.2014.10.04.13.30.55 for ; Sat, 04 Oct 2014 13:30:55 -0700 (PDT) Received-SPF: none (google.com: devicetree-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751011AbaJDUay (ORCPT + 5 others); Sat, 4 Oct 2014 16:30:54 -0400 Received: from mail-wg0-f50.google.com ([74.125.82.50]:35318 "EHLO mail-wg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751117AbaJDUax (ORCPT ); Sat, 4 Oct 2014 16:30:53 -0400 Received: by mail-wg0-f50.google.com with SMTP id a1so3791809wgh.21 for ; Sat, 04 Oct 2014 13:30:52 -0700 (PDT) X-Received: by 10.180.104.201 with SMTP id gg9mr7938531wib.15.1412454652451; Sat, 04 Oct 2014 13:30:52 -0700 (PDT) Received: from trevor.secretlab.ca (host86-166-87-213.range86-166.btcentralplus.com. [86.166.87.213]) by mx.google.com with ESMTPSA id cs2sm2174835wib.2.2014.10.04.13.30.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 04 Oct 2014 13:30:51 -0700 (PDT) Received: by trevor.secretlab.ca (Postfix, from userid 1000) id 3245CC41C4A; Sat, 4 Oct 2014 13:30:15 -0700 (PDT) From: Grant Likely To: devicetree@vger.kernel.org Cc: Grant Likely , Pantelis Antoniou , Gaurav Minocha Subject: [PATCH v2 6/6] of/selftest: Use the resolver to fixup phandles Date: Sat, 4 Oct 2014 21:30:02 +0100 Message-Id: <1412454602-28518-6-git-send-email-grant.likely@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1412454602-28518-1-git-send-email-grant.likely@linaro.org> References: <1412454602-28518-1-git-send-email-grant.likely@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: grant.likely@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The selftest data ends up causing duplicate phandles in the live tree for the time that the testcase data is inserted into the live tree. This is obviously a bad situation because anything attempting to read the tree while the selftests are running make resolve phandles to one of the testcase data nodes. Fix the problem by using the of_resolve_phandles() function to eliminate duplicates. Signed-off-by: Grant Likely Cc: Pantelis Antoniou Cc: Gaurav Minocha --- drivers/of/Kconfig | 1 + drivers/of/selftest.c | 9 ++++++++- drivers/of/testcase-data/testcases.dts | 35 ++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index 6b81a36f6420..1a13f5b722c5 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig @@ -11,6 +11,7 @@ config OF_SELFTEST bool "Device Tree Runtime self tests" depends on OF_IRQ && OF_EARLY_FLATTREE select OF_DYNAMIC + select OF_RESOLVE help This option builds in test cases for the device tree infrastructure that are executed once at boot time, and the results dumped to the diff --git a/drivers/of/selftest.c b/drivers/of/selftest.c index 4f83e97f8788..4fed34bff5cf 100644 --- a/drivers/of/selftest.c +++ b/drivers/of/selftest.c @@ -25,7 +25,7 @@ static struct selftest_results { int failed; } selftest_results; -#define NO_OF_NODES 2 +#define NO_OF_NODES 3 static struct device_node *nodes[NO_OF_NODES]; static int last_node_index; static bool selftest_live_tree; @@ -765,6 +765,7 @@ static int __init selftest_data_add(void) extern uint8_t __dtb_testcases_begin[]; extern uint8_t __dtb_testcases_end[]; const int size = __dtb_testcases_end - __dtb_testcases_begin; + int rc; if (!size) { pr_warn("%s: No testcase data to attach; not running tests\n", @@ -785,6 +786,12 @@ static int __init selftest_data_add(void) pr_warn("%s: No tree to attach; not running tests\n", __func__); return -ENODATA; } + of_node_set_flag(selftest_data_node, OF_DETACHED); + rc = of_resolve_phandles(selftest_data_node); + if (rc) { + pr_err("%s: Failed to resolve phandles (rc=%i)\n", __func__, rc); + return -EINVAL; + } if (!of_allnodes) { /* enabling flag for removing nodes */ diff --git a/drivers/of/testcase-data/testcases.dts b/drivers/of/testcase-data/testcases.dts index 219ef9324e9c..6994e15c24bf 100644 --- a/drivers/of/testcase-data/testcases.dts +++ b/drivers/of/testcase-data/testcases.dts @@ -13,3 +13,38 @@ #include "tests-interrupts.dtsi" #include "tests-match.dtsi" #include "tests-platform.dtsi" + +/* + * phandle fixup data - generated by dtc patches that aren't upstream. + * This data must be regenerated whenever phandle references are modified in + * the testdata tree. + * + * The format of this data may be subject to change. For the time being consider + * this a kernel-internal data format. + */ +/ { __local_fixups__ { + fixup = "/testcase-data/testcase-device2:interrupt-parent:0", + "/testcase-data/testcase-device1:interrupt-parent:0", + "/testcase-data/interrupts/interrupts-extended0:interrupts-extended:60", + "/testcase-data/interrupts/interrupts-extended0:interrupts-extended:52", + "/testcase-data/interrupts/interrupts-extended0:interrupts-extended:44", + "/testcase-data/interrupts/interrupts-extended0:interrupts-extended:36", + "/testcase-data/interrupts/interrupts-extended0:interrupts-extended:24", + "/testcase-data/interrupts/interrupts-extended0:interrupts-extended:8", + "/testcase-data/interrupts/interrupts-extended0:interrupts-extended:0", + "/testcase-data/interrupts/interrupts1:interrupt-parent:0", + "/testcase-data/interrupts/interrupts0:interrupt-parent:0", + "/testcase-data/interrupts/intmap1:interrupt-map:12", + "/testcase-data/interrupts/intmap0:interrupt-map:52", + "/testcase-data/interrupts/intmap0:interrupt-map:36", + "/testcase-data/interrupts/intmap0:interrupt-map:16", + "/testcase-data/interrupts/intmap0:interrupt-map:4", + "/testcase-data/phandle-tests/consumer-a:phandle-list-bad-args:12", + "/testcase-data/phandle-tests/consumer-a:phandle-list-bad-args:0", + "/testcase-data/phandle-tests/consumer-a:phandle-list:56", + "/testcase-data/phandle-tests/consumer-a:phandle-list:52", + "/testcase-data/phandle-tests/consumer-a:phandle-list:40", + "/testcase-data/phandle-tests/consumer-a:phandle-list:24", + "/testcase-data/phandle-tests/consumer-a:phandle-list:8", + "/testcase-data/phandle-tests/consumer-a:phandle-list:0"; +}; };