Received: by 10.223.185.116 with SMTP id b49csp8048210wrg; Thu, 1 Mar 2018 16:13:57 -0800 (PST) X-Google-Smtp-Source: AG47ELszQK2duvrGhHcY3Y3qnyh/u9I5ZPeAO4ebjBMUAkqCgQdGRhTK5NQ9oOd7OoL3DJRsgiLq X-Received: by 2002:a17:902:bc41:: with SMTP id t1-v6mr3542559plz.436.1519949637232; Thu, 01 Mar 2018 16:13:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519949637; cv=none; d=google.com; s=arc-20160816; b=jw3XJ3S5sfP50VdZmF5P3US/mH0vtzKTgpdRewpEJQdN8R6opFIrhaUnJBTAizvcD7 kgZwKe8vhB81hyaJiTsvQMYbnoxe6MHK+QnbY5r0bo6/UqHi/0R7weWl98EKFZnefthQ CsQWPePWR8PHC/BIDPb+YRfRaYEkZ+AaBNfyDOJB85ZUzYln0gB8dYxe5Vr6gVr+s+Yn 537bg90ARxCphbbsVkTF9T2Aq0aflZCfw7ZfKXfSxWCgMjCaG/mGx2f6SDzlORLM9cu4 cBB0bzL7maLo6Eko7N/ihq8lXLXp96yD4klgu+jnS2xEXihkP3733M85/AdbXEHgmUKv llyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:dkim-signature :arc-authentication-results; bh=RjpUdlUaxl+8i1UuA9RRyXGjPu7A4iPVWM74B1QA+mU=; b=0CRjE/1ZN6mRzHXZe/NwY7p7fHzHXF6mXp2wGGxSE5mjfXyV/WrYs1/30wLMnfpfjH 7TdQz67F2SYuKiagxHYOBpxxElj6NwQmfsLVrsOaf4aHc19pRLKHfdPHk2Gv9MeroiXj 2LU4TrixEACN+pmZl95Ogg63kaPtf0S+ys4Vv7opur1P5uB80sljEocdwfN4ybUrVYeQ uyLLcybLqGhYjJi9JOSM0AkLCp90DGLPDwNmK9VOekMM/rqwT99S9gQtG2x2uec41nWP 5jQZ8iojFIQrY6rFXfC/zIoxcsi/4Pa0lE7qHkx34rZp5SqITeVSz6o32unkPYcof9Hx PU6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Kig0l2dz; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q4si3142370pgc.269.2018.03.01.16.13.42; Thu, 01 Mar 2018 16:13:57 -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=@gmail.com header.s=20161025 header.b=Kig0l2dz; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1163516AbeCAXi0 (ORCPT + 99 others); Thu, 1 Mar 2018 18:38:26 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:47015 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1163159AbeCAXiV (ORCPT ); Thu, 1 Mar 2018 18:38:21 -0500 Received: by mail-pf0-f196.google.com with SMTP id z10so3156083pfh.13; Thu, 01 Mar 2018 15:38:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=RjpUdlUaxl+8i1UuA9RRyXGjPu7A4iPVWM74B1QA+mU=; b=Kig0l2dzW60P8NgtPLKR7tagDUXE/fYAGzKiUh7abrks9Lmkwp+mUFYoN/Gwy9OdU+ ymDg3XB+Hnnh8nPpG4H/LGsIW6EpY47nZOEk6NJbQmGEmvT24Ggdfjy0hgAaenddPZiH 6VN9vUNITjbY5T9WNoWvES+ZL/dp1DSXFW17dsGE4CBthB/kaYZL1ieNl5WC6D70H4oF TF+TMALvkEV9hBydYQcdtdXCeqFgomdhh2I7v3Kz7BnooFkQR+Iv5IHqpvcXS+UYaU5C IYGvXipxKQ6F6FMBCeTu+J6aR2hL9wm7x3icwR8j9C4k/q0EhNdoNs8JyRb8/aEW9+Ij /72w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=RjpUdlUaxl+8i1UuA9RRyXGjPu7A4iPVWM74B1QA+mU=; b=FGmzx6fGPem4qWu54wWurRNiR0E9vFItO94x4itdIJ9AA0jTtgbEkZeqv8IjxuD1QD TQUVA+SzdmRKz11cdmOy78LFEz5COGiglUuREMtTRW6fTJyjjaM8Uw6m/+nS4Bo+UWOI S35RjLv0hTE3w1e9HAsCdJK1bWMsQVjWAB4QmCrEDN9++mqVDIASHn/g1spB+DBMheYE D3Vk++qlyf4+pYZ4bCRzelpGdyLNAh52zP4cxcspinN5O6CWXXKmnFJDfW3BLxuKrIKz OSIUp2foqgBUIx3ZsqrimZ/TY24QI/jBjws2+9slqYUmhDLCCtLSur5PQB5neC07GC+V gdDA== X-Gm-Message-State: APf1xPAab/WwgEpFhZhFU6chtfOXujs2qHPhAoYJwfmZ2KbNekdG0BrQ tXOVcQj+vf/EOt070j2VRzM= X-Received: by 10.99.176.68 with SMTP id z4mr2878063pgo.74.1519947500905; Thu, 01 Mar 2018 15:38:20 -0800 (PST) Received: from [192.168.1.70] (c-73-93-215-6.hsd1.ca.comcast.net. [73.93.215.6]) by smtp.gmail.com with ESMTPSA id s9sm8695364pfm.39.2018.03.01.15.38.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Mar 2018 15:38:20 -0800 (PST) Subject: Re: [PATCH v4 1/4] of: change overlay apply input data from unflattened to FDT From: Frank Rowand To: Rob Herring Cc: Pantelis Antoniou , Pantelis Antoniou , devicetree@vger.kernel.org, "linux-kernel@vger.kernel.org" , Geert Uytterhoeven , Laurent Pinchart References: <1519927256-4868-1-git-send-email-frowand.list@gmail.com> <1519927256-4868-2-git-send-email-frowand.list@gmail.com> <53b47afa-f7df-777a-6a96-d0b986a389fb@gmail.com> Message-ID: Date: Thu, 1 Mar 2018 15:38:18 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <53b47afa-f7df-777a-6a96-d0b986a389fb@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/01/18 14:36, Frank Rowand wrote: > On 03/01/18 13:02, Rob Herring wrote: >> On Thu, Mar 1, 2018 at 12:00 PM, wrote: >>> From: Frank Rowand >>> >>> Move duplicating and unflattening of an overlay flattened devicetree >>> (FDT) into the overlay application code. To accomplish this, >>> of_overlay_apply() is replaced by of_overlay_fdt_apply(). >>> >>> The copy of the FDT (aka "duplicate FDT") now belongs to devicetree >>> code, which is thus responsible for freeing the duplicate FDT. The >>> caller of of_overlay_fdt_apply() remains responsible for freeing the >>> original FDT. >>> >>> The unflattened devicetree now belongs to devicetree code, which is >>> thus responsible for freeing the unflattened devicetree. >>> >>> These ownership changes prevent early freeing of the duplicated FDT >>> or the unflattened devicetree, which could result in use after free >>> errors. >>> >>> of_overlay_fdt_apply() is a private function for the anticipated >>> overlay loader. >>> >>> Update unittest.c to use of_overlay_fdt_apply() instead of >>> of_overlay_apply(). >>> >>> Move overlay fragments from artificial locations in >>> drivers/of/unittest-data/tests-overlay.dtsi into one devicetree >>> source file per overlay. This led to changes in >>> drivers/of/unitest-data/Makefile and drivers/of/unitest.c. >>> >>> - Add overlay directives to the overlay devicetree source files so >>> that dtc will compile them as true overlays into one FDT data >>> chunk per overlay. >>> >>> - Set CFLAGS for drivers/of/unittest-data/testcases.dts so that >>> symbols will be generated for overlay resolution of overlays >>> that are no longer artificially contained in testcases.dts >>> >>> - Unflatten and apply each unittest overlay FDT using >>> of_overlay_fdt_apply(). >>> >>> - Enable the of_resolve_phandles() check for whether the unflattened >>> overlay is detached. This check was previously disabled because the >>> overlays from tests-overlay.dtsi were not unflattened into detached >>> trees. >>> >>> - Other changes to unittest.c infrastructure to manage multiple test >>> FDTs built into the kernel image (access by name instead of >>> arbitrary number). >>> >>> - of_unittest_overlay_high_level(): previously unused code to add >>> properties from the overlay_base devicetree to the live tree >>> was triggered by the restructuring of tests-overlay.dtsi and thus >>> testcases.dts. This exposed two bugs: (1) the need to dup a >>> property before adding it, and (2) property 'name' is >>> auto-generated in the unflatten code and thus will be a duplicate >>> in the __symbols__ node - do not treat this duplicate as an error. >>> >>> Signed-off-by: Frank Rowand >>> --- < snip > >>> diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c >>> index 7a9abaae874d..2d706039ac96 100644 >>> --- a/drivers/of/unittest.c >>> +++ b/drivers/of/unittest.c < snip > >>> @@ -1263,25 +1264,19 @@ static void of_unittest_destroy_tracked_overlays(void) >>> } while (defers > 0); >>> } >>> >>> -static int of_unittest_apply_overlay(int overlay_nr, int unittest_nr, >>> +static int __init of_unittest_apply_overlay(int overlay_nr, int unittest_nr, >>> int *overlay_id) >> >> Why __init? Really, we want to move towards building the unittests as >> a module and we don't want __init for that. Though maybe __init is a >> nop for modules, I don't remember offhand. > > It has to be a nop for modules. > > __init makes sense when the unittests are an initcall. > > >> In any case, seems like a separate change. > > Correct. It was a gratuitous clean up when I was making other changes > to the function. I'll remove it from this series. Now I remember, after trying to remove the __init. I get a modpost warning when I build the kernel. Before the patches, the old overlay tests did not apply the overlays from overlay FDTs. Instead the overlay fragment nodes were hand coded into the testcases dts, and the overlay apply code just grabbed the fragment nodes from the live testcases tree and called the overlay code to apply the fragment nodes. With the new FDT based overlay API, I was able to make the test overlays actual overlay dts files and dtbs. This change involved changing of_unittest_apply_overlay() to no longer call of_overlay_apply() (which passed in a pointer to a node from the live testcases tree), but instead call overlay_data_apply() (which handles finding the requested fdt and applies it). overlay_data_apply() is already an __init() function. There are a few more functions that I would expect modpost to warn about, but it does not. > There is a mix of some functions being marked __init and some not, > so that will be worth another patch someday. > > >> >> Rob >> > >