Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp1140877rdf; Wed, 22 Nov 2023 06:43:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IFLf3v+aeReAE/t9jvzunG4v3JkNTYGXsj/XReta05zM8K8NaT2D+fot6QKbhfPVXaWPb8Q X-Received: by 2002:a05:6a21:29c8:b0:187:d4e3:c13a with SMTP id tv8-20020a056a2129c800b00187d4e3c13amr2143771pzb.22.1700664203264; Wed, 22 Nov 2023 06:43:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700664203; cv=none; d=google.com; s=arc-20160816; b=fA4KcmWW94JjjZAkKDkjqcod9kfP5aODJmG5yYPWtDe39YILk3FApzau+hUBtC/boG LQSbwlp/3F99rP91Xapc3mWvolOnLNncLZgIGXyTmSWKWsnSx0nL/UfgfKQL1BTSXSbX gWqSr+rj+dU1QM9eoHZiUWdpQyXuu6LHa47Zejn6+3wkEa7Ogvr9JbNNzplfJ+851N2b Z0IJfHtvUQnPuauMTBh+WYcuKySF9Tr7OOM8n7Gd+lvD+7SWlfQbto3NNqkopXvpK0ie w69sM9dAYW8QiTwTz4BbFlJ3p/H0R2wQTlitxTLTsYeJ1TrznNPWbdfN0b4I3FIXzZ5K DQzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id:references :in-reply-to:subject:cc:to:from:date:dkim-signature:mime-version; bh=n9l7CzXN6LlS38rZFFq0Nxp8PK7NYDm9aN5Wn+Z/Buw=; fh=m4kRjgw28tNHlz3D/Boc51ELzc6nEwDDQQUJshGaU8Y=; b=OzOfMJFOLS7tWhTkViSxlEXDnr4EnZuVyirXA9xhjP1H0lxnN4nWyQKdxKjzkGuMNW 8kPkBmkZuk5BxyZAiPv10nqAyUyKXVu4y0sORUywVek3db/zEla/s5akmh6uYc2uPUOX 5eWJHO85J1kaW8tc2cEmncKhY7GJUyzo0+5ZZyyHSbu0QBJJFZ74jVpDKHJTy6fAwSCl HOjk/xEY4IgTdz/W7LthI9kfCoAP+kZw1ziZ9qUqo1w0LRexX1Af0vrzpfTQHiy8V32x axEtcIeoHxJU0ClQJ8Krr8vRKPuWkXUOBLXzzwlHD9LfiwRAm+pHGVsS3fPEyQTflqlC j15A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@manjaro.org header.s=2021 header.b="x7SQ/I1H"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=manjaro.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id u22-20020a631416000000b005be1955657esi12740492pgl.127.2023.11.22.06.43.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 06:43:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@manjaro.org header.s=2021 header.b="x7SQ/I1H"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=manjaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id C829B809B9CE; Wed, 22 Nov 2023 06:43:12 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231766AbjKVOmz (ORCPT + 99 others); Wed, 22 Nov 2023 09:42:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231896AbjKVOmx (ORCPT ); Wed, 22 Nov 2023 09:42:53 -0500 Received: from mail.manjaro.org (mail.manjaro.org [IPv6:2a01:4f8:c0c:51f3::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 958C1C1; Wed, 22 Nov 2023 06:42:49 -0800 (PST) MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manjaro.org; s=2021; t=1700664166; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n9l7CzXN6LlS38rZFFq0Nxp8PK7NYDm9aN5Wn+Z/Buw=; b=x7SQ/I1HOiWc0cwQ6er9JxVxd2di1ktX2ld6tiwKekdklOtdP54pycvx1s1KAVhfCqW8l6 t/Y88WRMV20TDY6M4PWiDDHKuWXTh/o5K/9QKplNCSBk0NkOuo8ZkUqFO2cDjC4v3QNQuU BwShho8epg3KI/PenQJo79YnPUu+R5FsDbEhsGaGkkCZXxko8ucAKfY1trKhy7YQjxBAL4 BTtM9VWeoaMsWlb7MqndqTur+5yM39vgYLrKyvgk/hsyd6RN8H5cQz82mq6Shd+ZQfQnTj GkqNjDCurBsMM2KsjG+Z6g7/s3ejsd+j727Gtm81FLFE0bqKtMSaw+fL3L7cqg== Date: Wed, 22 Nov 2023 15:42:46 +0100 From: Dragan Simic To: Rob Herring Cc: Michal Simek , Geert Uytterhoeven , Krzysztof Kozlowski , wens@kernel.org, =?UTF-8?Q?Rafa?= =?UTF-8?Q?=C5=82_Mi=C5=82ecki?= , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Andrew Davis , Arnd Bergmann , Bjorn Andersson , Heiko Stuebner , Konrad Dybcio , Neil Armstrong , Nishanth Menon , Olof Johansson , linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-msm@vger.kernel.org Subject: Re: [PATCH v2] docs: dt-bindings: add DTS Coding Style document In-Reply-To: References: <20231120084044.23838-1-krzysztof.kozlowski@linaro.org> <6b288a2e-d147-4bd3-b1d4-daf56295d939@gmail.com> <01f9ce3b-e6e5-4b05-bf7f-0b3a5f74910a@linaro.org> <7232a48b-b9ad-44b5-ae6a-d12dad70b3c4@linaro.org> <58a9caacc1226c7c3a2bdfe73ef1791f@manjaro.org> <808270d3-2274-4fb7-a397-38538503b67c@amd.com> Message-ID: X-Sender: dsimic@manjaro.org Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Authentication-Results: ORIGINATING; auth=pass smtp.auth=dsimic@manjaro.org smtp.mailfrom=dsimic@manjaro.org X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 22 Nov 2023 06:43:13 -0800 (PST) On 2023-11-22 15:34, Rob Herring wrote: > On Wed, Nov 22, 2023 at 1:57 AM Michal Simek > wrote: >> On 11/22/23 09:53, Geert Uytterhoeven wrote: >> > On Wed, Nov 22, 2023 at 9:50 AM Michal Simek wrote: >> >> On 11/22/23 09:29, Dragan Simic wrote: >> >>> On 2023-11-22 09:21, Krzysztof Kozlowski wrote: >> >>>> On 22/11/2023 09:09, Chen-Yu Tsai wrote: >> >>>>> On Wed, Nov 22, 2023 at 4:05 PM Krzysztof Kozlowski >> >>>>> wrote: >> >>>>>> >> >>>>>> On 21/11/2023 14:50, Rafał Miłecki wrote: >> >>>>>>>> +Order of Properties in Device Node >> >>>>>>>> +---------------------------------- >> >>>>>>>> + >> >>>>>>>> +Following order of properties in device nodes is preferred: >> >>>>>>>> + >> >>>>>>>> +1. compatible >> >>>>>>>> +2. reg >> >>>>>>>> +3. ranges >> >>>>>>>> +4. Standard/common properties (defined by common bindings, e.g. without >> >>>>>>>> + vendor-prefixes) >> >>>>>>>> +5. Vendor-specific properties >> >>>>>>>> +6. status (if applicable) >> >>>>>>>> +7. Child nodes, where each node is preceded with a blank line >> >>>>>>>> + >> >>>>>>>> +The "status" property is by default "okay", thus it can be omitted. >> >>>>>>> >> >>>>>>> I think it would really help to include position of #address-cells and >> >>>>>>> #size-cells here. In some files I saw them above "compatible" that seems >> >>>>>>> unintuitive. Some prefer putting them at end which I think makes sense >> >>>>>>> as they affect children nodes. >> >>>>>>> >> >>>>>>> Whatever you choose it'd be just nice to have things consistent. >> >>>>>> >> >>>>>> This is a standard/common property, thus it goes to (4) above. >> >>>>> >> >>>>> It's probably a mix, but AFAIK a lot of the device trees in tree have >> >>>>> #*-cells after "status". In some cases they are added in the board >> >>>>> .dts files, not the chip/module .dtsi files. >> >>>> >> >>>> Existing DTS is not a good example :) >> >>>> >> >>>>> >> >>>>> +1 that it makes sense at the end as they affect child nodes. >> >>>> >> >>>> I still insist that status must be the last, because: >> >>>> 1. Many SoC nodes have address/size cells but do not have any children >> >>>> (I2C, SPI), so we put useless information at the end. >> >>>> 2. Status should be the final information to say whether the node is >> >>>> ready or is not. I read the node, check properties and then look at the end: >> >>>> a. Lack of status means it is ready. >> >>>> b. status=disabled means device still needs board resources/customization >> >>> >> >>> I agree with the "status" belonging to the very end, because it's both logical >> >>> and much more readable. Also, "status" is expected to be modified in the >> >>> dependent DT files, which makes it kind of volatile and even more deserving to >> >>> be placed last. >> >> >> >> I am just curious if having status property at the end won't affect >> >> execution/boot up time. Not sure how it is done in Linux but in U-Boot at least >> >> (we want to have DTs in sync between Linux and U-Boot) of_find_property is >> >> pretty much big loop over all properties. And status property defined at the end >> >> means going over all of them to find it out to if device is present. >> >> Not sure if Linux works in the same way but at least of_get_property is done in >> >> the same way. >> > >> > As the default is "okay", you have to loop over all properties anyway. >> >> No doubt if you don't define status property that you need to loop >> over all of >> them. We normally describe the whole SOC with pretty much all IPs >> status = >> disabled and then in board file we are changing it to okay based on >> what it is >> actually wired out. >> It means on our systems all nodes have status properties. If you have >> it at >> first you don't need to go over all. > > Order in the source and order in the OS are independent. If checking > status needs to be optimized, then we could just put it first in the > property list or make the state a field in struct device_node. But > provide some data that it matters first. That's exactly what I plan to do, i.e. to perform some benchmarks before and after, to see does it actually matter to the point where introducing the changes is worth it. > I've had this idea to randomize the order nodes are processed so > there's no reliance on the DT order. Maybe I need the same on > properties...