Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp252953imj; Fri, 15 Feb 2019 23:06:01 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibfo0jhb4q1Wg+27d4okOGAehHNfsTXkpJxOCG1CJxJXFoj8dsXy/etbH+bkgfoO90U1/+a X-Received: by 2002:a63:981:: with SMTP id 123mr9052529pgj.444.1550300761723; Fri, 15 Feb 2019 23:06:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550300761; cv=none; d=google.com; s=arc-20160816; b=aFeYfFwO80Xr4/Rj0gDxQI3O6EM2bG++3s9+57KWLTThNC1Uj9mXdfQAS93Jq3EVMP htFYitAZ5bnwbr/ajOAsPeIHvTwhOGH9uPZPOgbmgG9tO4N5n+q42jTctpJb2uitD3W1 GHJmhPW4S5NY1y0S4y1nww423LabGobLZgn8uQY13KbZzPFpvXwmOtOEYXynr525Kn6K AcxAm28LKUcnwJ7ItXvirFAj+UZGQ+fILUqwipn+OiysYlVTSm3Usq5kmI5CMdRiW6vV Nt6WKqF7ajEg2PbazIaA7qNjF9IpGzI/ZDZLEysWMN26TvDX0Jc4ShtIKffP5oCDgfXc AdEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=rmgFJ+d2qKkD0O4G7XmkrifxPmPpvsNvaP8KXPCbSD8=; b=PQz90/sAc2xZSElLPOTfGhaKyXP5mhqzNTjY33zWY8Z3VsbHEmi9EIz8IXbYRs0n00 jeAn7Us9m8eB1nPe4wopXaE0Tw8AacddD3O3q2eXH5777Ruqw6e2mmR3c+HRjuC/E/+P L5FGUM6xpj9wtO2jh5bmhPgeVxZABtWfuuVXMOdLtpLf05UtBANfShS0KD609SYvTwwe DcPphNRpzJu6XLo9r5FVnAXedV3bUw7fxhj2Ro6iAJyVfLc5Iy8jvPqmkKZvLnOyhsqM QGLmK6cwMeyVt8Zl2vKoWLb1X8cQ/f5FIaCBRXdCj60sIVB1717Z8jU5hOgUxBYADkyT 98ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZbjScxZr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w31si7808738pla.308.2019.02.15.23.05.46; Fri, 15 Feb 2019 23:06:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZbjScxZr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732092AbfBOTok (ORCPT + 99 others); Fri, 15 Feb 2019 14:44:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:55902 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729324AbfBOTok (ORCPT ); Fri, 15 Feb 2019 14:44:40 -0500 Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 47D2F222D0; Fri, 15 Feb 2019 19:44:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550259879; bh=JK29Q39fiSwoZaHcnoTGhvUEmEYahFBdbQGssW0nU5s=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ZbjScxZr0+x8BQOBxcTBHk7+ujjXGVblld/G3TANS1xPFuHGVx9vFJSFHBVgmkOPT QtCCdVoBnwkpwybqknK/Cl+mhqcuUyJFbguNAAJkvtDF6NC/e7Jk+niTBr7BhflBka MIaWcXCSaKQO1QbM5073xSlQJ93h7RTr7yrDuc1g= Received: by mail-qt1-f181.google.com with SMTP id y20so12189386qtm.13; Fri, 15 Feb 2019 11:44:39 -0800 (PST) X-Gm-Message-State: AHQUAubgCLopxbcX5RffyIN+j09iAPX9W3OGK0j1k6k/fFc0RC4cZZi5 XC+hx8sXz9R/hgovacat3lnmhyxn7XyTEy1m8A== X-Received: by 2002:ac8:2f4e:: with SMTP id k14mr8801359qta.76.1550259878502; Fri, 15 Feb 2019 11:44:38 -0800 (PST) MIME-Version: 1.0 References: <20190212185305.112847-1-brendanhiggins@google.com> <20190212185305.112847-2-brendanhiggins@google.com> <4cb7ca12-ce60-7516-b7eb-aef08f607acc@gmail.com> In-Reply-To: From: Rob Herring Date: Fri, 15 Feb 2019 13:44:26 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v1 1/1] of: unittest: unflatten device tree on UML when testing To: Brendan Higgins Cc: Frank Rowand , Luis Chamberlain , devicetree , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 15, 2019 at 3:49 AM Brendan Higgins wrote: > > On Thu, Feb 14, 2019 at 6:48 PM Frank Rowand wrote: > > > > On 2/14/19 5:26 PM, Brendan Higgins wrote: > > > On Thu, Feb 14, 2019 at 4:10 PM Frank Rowand wrote: > > >> > > >> On 2/12/19 10:53 AM, Brendan Higgins wrote: > > >>> UML supports enabling OF, and is useful for running the device tree > > >>> tests, so add support for unflattening device tree blobs so we can > > >>> actually use it. > > >>> > > >>> Signed-off-by: Brendan Higgins > > >>> --- > > >>> drivers/of/unittest.c | 3 +++ > > >>> 1 file changed, 3 insertions(+) > > >>> > > >>> diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c > > >>> index 84427384654d5..effa4e2b9d992 100644 > > >>> --- a/drivers/of/unittest.c > > >>> +++ b/drivers/of/unittest.c > > >>> @@ -2527,6 +2527,9 @@ static int __init of_unittest(void) > > >>> } > > >>> of_node_put(np); > > >>> > > >>> + if (IS_ENABLED(CONFIG_UML)) > > >>> + unflatten_device_tree(); > > >>> + > > >>> pr_info("start of unittest - you will see error messages\n"); > > >>> of_unittest_check_tree_linkage(); > > >>> of_unittest_check_phandles(); > > >>> > > >> > > >> (Insert my usual disclaimer that I am clueless about UML, I still need to learn > > >> about it...) > > >> > > >> This does not look correct to me. > > >> > > >> A few lines earlier in of_unittest(), the live devicetree needs to exist for > > >> unittest_data_data() and a few of_*() functions to succeed. So it seems > > >> that the unflatten_device_tree() for uml should be at the beginning of > > >> of_unittest(). > > > > > > It is true that other functions ahead of it depend on the presence of > > > a device tree, but an unflattened tree does get linked in somewhere > > > else. Despite that, this is needed for overlay_base_root. I got > > > similar behavior if you don't link in a flattened device tree on x86. > > > Thus, the order in which you call them doesn't actually seem to > > > matter. I found no difference from changing the order in UML myself. > > > > > > Without my patch we get the following error, > > > ### dt-test ### FAIL of_unittest_overlay_high_level():2372 > > > overlay_base_root not initialized > > > ### dt-test ### end of unittest - 219 passed, 1 failed > > > > > > With my patch we get: > > > ### dt-test ### end of unittest - 224 passed, 0 failed > > > > Thanks for reporting both the failure and the success cases, > > that helps me understand a little bit better. > > > > If instead of the above patch, if you add the following (untested, > > not even compile tested) to the beginning of of_unittest(): > > > > if (IS_ENABLED(CONFIG_UML)) > > unittest_unflatten_overlay_base(); > > > > does that also result in a good test result of: > > > > ### dt-test ### end of unittest - 224 passed, 0 failed > > Yep, I just tried it. It works as you suspected. > > > > > I think I need to find some time to build and boot a UML kernel soon. > > It's really no big deal, just copy the .config I sent and build with > `make ARCH=um` then you "boot" the kernel with `./linux` (note this > will mess up your terminal settings); that's it! (Shameless plug: you > can also try it out with the KUnit patchset with > `./tools/testing/kunit/kunit.py --timeout=30 --jobs=12 --defconfig`, > which builds the kernel with a pretty similar config, boots the > kernel, and then parses the output for you. ;-) ) > > > > > My current _guess_ is that the original problem was not a failure to > > unflatten any present devicetree in UML but instead that the UML > > kernel does not call unflatten_device_tree() and thus fails to > > indirectly call unittest_unflatten_overlay_base(), which is > > called by unflatten_device_tree(). > > I think you are right. Sorry for not noticing this before making my > change. Since it was pretty much the only architecture (the only one I > care about) that does not unflatten DT, I assumed that was the > problem. I didn't put too much thought into it after that point beyond > making sure that it did what I wanted. > > > > > unittest_unflatten_overlay_base() is an unfortunate wart that I > > added, but I don't have a better alternative yet. > > Hey, I get it. No worries. > > In any case, it seems like unittest_unflatten_overlay_base() is the > right function to call there. I will send out patch. Do you want me to > send a patch on top of this one, or do you want to revert this one and > for me to send a v2 follow up to this patch? I don't care either way, > whatever you guys prefer. I'll drop or revert the existing one, so against mainline is good. Rob