Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752025AbdFKXFh (ORCPT ); Sun, 11 Jun 2017 19:05:37 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:36833 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751912AbdFKXFf (ORCPT ); Sun, 11 Jun 2017 19:05:35 -0400 Subject: Re: [PATCH] external references for device tree overlays To: Stefani Seibold , Pantelis Antoniou References: <1496667567-13266-1-git-send-email-stefani.seibold.ext@huawei.com> <1496688186.12947.10.camel@hp800z> <1496776664.3821.3.camel@seibold.net> <1496823091.28265.3.camel@hp800z> <1496904510.7999.1.camel@seibold.net> Cc: Stefani Seibold , Rob Herring , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Holm Rauchfuss From: Frank Rowand Message-ID: <593DCC8F.8010601@gmail.com> Date: Sun, 11 Jun 2017 16:04:47 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <1496904510.7999.1.camel@seibold.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3728 Lines: 133 On 06/07/17 23:48, Stefani Seibold wrote: > Hi Pantelis, > > On Wed, 2017-06-07 at 11:11 +0300, Pantelis Antoniou wrote: >> Hi Stefani, >> >> On Tue, 2017-06-06 at 21:17 +0200, Stefani Seibold wrote: >>> Hi Pantelis, >>> >>> thanks for the suggestion. This feature is not very well >>> documented. I >>> tried this on my rasp1 running 4.12.0-rc3 and it doesn't work. My >>> source is: >>> >>> // rapsi example >>> /dts-v1/; >>> /plugin/; >>> >>> / { >>> compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709"; >>> >>> fragment@0 { >>> target-path = "/soc/i2s@7e203000"; >>> __overlay__ { >>> #address-cells = <0x00000001>; >>> #size-cells = <0x00000001>; >>> test = "test"; >>> timer = <&{/soc/timer@7e0030000}>; >>> }; >>> }; >>> }; >>> >>> >>> The resulting overlay is (decompiled with fdtdump): >>> >>> /dts-v1/; >>> // magic: 0xd00dfeed >>> // totalsize: 0x19a (410) >>> // off_dt_struct: 0x38 >>> // off_dt_strings: 0x148 >>> // off_mem_rsvmap: 0x28 >>> // version: 17 >>> // last_comp_version: 16 >>> // boot_cpuid_phys: 0x0 >>> // size_dt_strings: 0x52 >>> // size_dt_struct: 0x110 >>> >>> / { >>> compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709"; >>> fragment@0 { >>> target-path = "/soc/i2s@7e203000"; >>> __overlay__ { >>> #address-cells = <0x00000001>; >>> #size-cells = <0x00000001>; >>> test = "test"; >>> timer = <0xdeadbeef>; >>> }; >>> }; >>> __fixups__ { >>> /soc/timer@7e0030000 = "/fragment@0/__overlay__:timer:0"; >>> }; >>> }; >>> >>> But this will not apply: >>> >>> OF: resolver: overlay phandle fixup failed: -22 >>> create_overlay: Failed to resolve tree >>> >>> >> >> Yes, it will not work as it is; my point is that you don't need the >> magic __*__ node. >> > > The magic __fixups__ node was inserted by the device tree compiler. I > use the dtc from https://github.com/pantoniou/dtc at commit > d990b8013889b816ec054c7e07a77db59c56c400. > >> You will need to modify the overlay application code to live insert a >> phandle (if it doesn't exist) when it encounters a /path fixup. >> > > That is part of my patch! > >>> Anyway, the reason for my patch is that i can reference to nodes >>> which >>> lacks a phandle. The phandle will be created on the fly and also >>> destroyed when the overlay is unloaded. >>> >>> I have a real use case for this patch: >>> >>> I have a BIOS on some ARM64 servers which provides broken device >>> tree. >>> It also lacks some devices in this tree which needs references to >>> other >>> devices which lacks a phandle. >>> >>> Since the BIOSes are closed source i need a way to work arround >>> this >>> problem without patching all the drivers involved to this devices. >>> >>> Hope this helps to understand the reason for this patch. >>> >> >> FWIW your problem seems like something that would happen on the >> field. >> We can berate the vendor of not providing the correct device tree, >> but >> in the end workarounds for broken vendor things are common in the >> kernel. >> > > Yes, that is the way how linux do the things. Linux has a long history > to bypassing bugs of BIOSes, ACPI or broken devices. ARM device tree in Linux is not like BIOSes or ACPI. ARM device tree in Linux is GPL v2 licensed (yes, it may also be dual licensed for other uses) and thus "free software". One of the key points of "free software" is that you have access to the source and the ability to modify it. Instead of bypassing device tree bugs, you have the ability to fix device tree bugs. This is a fundamental difference. -Frank > > Greetings, > Stefani > >