From patchwork Thu Oct 2 15:27:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Likely X-Patchwork-Id: 38299 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B7A6020BF9 for ; Thu, 2 Oct 2014 15:27:47 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id b6sf1351628lbj.11 for ; Thu, 02 Oct 2014 08:27:46 -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=qic20fzU41vpJwcchzBoq3n7JKnIJJuxhQ01yf4jQQk=; b=ecL7YSzgno3XzPzCldSfmaaVd4a2I24UaiH3QBZBDODeCb2SgFWMnRdLw/DjXJ4jvx LkjWuHwqpLHlqujs1nirhLt4RG/LnbEurz2MUmnr+z7xx8VDdrj+vpcIPd/yMRgPOUsx 1kQAR7UXFSsj75mGGShg34TQZ6mmE7jfBYEsrm6P2GQu71vhL3Bj2+KbZzvIJWQKHcmY oIIihahe7AvXkIfXfE6zFETsHwEfVZFD8C6M7lqKN2J8IkVZDkdVcqh9vrPC4cSZwBQ+ hS0zETbcGyosXhazSGUxo4q+sWIix+4w6HDlAb7jWErOUNgkd3dHPZNJ6OoUVBqW66Z4 stDQ== X-Gm-Message-State: ALoCoQlScRx8g1KKg6sSPssrP3JAeKBbs+rYgRBkCmUdGpxFO8FlgfejKeb1hOmiNYLfODOmS9Fq X-Received: by 10.152.6.195 with SMTP id d3mr2631laa.10.1412263666631; Thu, 02 Oct 2014 08:27:46 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.74 with SMTP id r10ls294910lag.109.gmail; Thu, 02 Oct 2014 08:27:46 -0700 (PDT) X-Received: by 10.152.36.4 with SMTP id m4mr64249121laj.17.1412263666425; Thu, 02 Oct 2014 08:27:46 -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 e7si7058525lag.100.2014.10.02.08.27.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 02 Oct 2014 08:27:46 -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 f15so2485501lbj.11 for ; Thu, 02 Oct 2014 08:27:46 -0700 (PDT) X-Received: by 10.152.22.137 with SMTP id d9mr64747220laf.29.1412263666329; Thu, 02 Oct 2014 08:27:46 -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 of9csp74620lbb; Thu, 2 Oct 2014 08:27:45 -0700 (PDT) X-Received: by 10.66.124.202 with SMTP id mk10mr25520537pab.1.1412263664556; Thu, 02 Oct 2014 08:27:44 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ia9si4385912pbc.55.2014.10.02.08.27.43 for ; Thu, 02 Oct 2014 08:27:44 -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 S1754042AbaJBP1k (ORCPT + 5 others); Thu, 2 Oct 2014 11:27:40 -0400 Received: from mail-wg0-f48.google.com ([74.125.82.48]:49153 "EHLO mail-wg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753926AbaJBP1i (ORCPT ); Thu, 2 Oct 2014 11:27:38 -0400 Received: by mail-wg0-f48.google.com with SMTP id n12so3396726wgh.19 for ; Thu, 02 Oct 2014 08:27:37 -0700 (PDT) X-Received: by 10.194.78.136 with SMTP id b8mr32429304wjx.106.1412263656925; Thu, 02 Oct 2014 08:27:36 -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 bi7sm1583283wib.17.2014.10.02.08.27.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Oct 2014 08:27:34 -0700 (PDT) Received: by trevor.secretlab.ca (Postfix, from userid 1000) id 5568AC41FF5; Thu, 2 Oct 2014 08:27:07 -0700 (PDT) From: Grant Likely To: devicetree@vger.kernel.org Cc: Grant Likely , Pantelis Antoniou , Gaurav Minocha Subject: [PATCH 2/2] of/selftest: Use the resolver to fixup phandles Date: Thu, 2 Oct 2014 16:27:04 +0100 Message-Id: <1412263624-21838-3-git-send-email-grant.likely@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1412263624-21838-1-git-send-email-grant.likely@linaro.org> References: <1412263624-21838-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 634eb79bfe47..c80cd6258b1e 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"; +}; };