Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8643116rwb; Thu, 24 Nov 2022 02:17:47 -0800 (PST) X-Google-Smtp-Source: AA0mqf5XbfeaB5OP+4A2XjmKrEOwLS61ReCKXU3lh7oKjtsROXXQ1Z2nNPLV6ntkWF2BweFlLWGc X-Received: by 2002:a17:902:aa44:b0:189:fdf:a3d9 with SMTP id c4-20020a170902aa4400b001890fdfa3d9mr23692674plr.9.1669285066761; Thu, 24 Nov 2022 02:17:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669285066; cv=none; d=google.com; s=arc-20160816; b=S1YG0KMfGesUqDwr3yPaCOdmrnKQlJAj3OK4zBVd2YLwkADCYs0wmZ4piNA3pgQmOE 4fnrukolIwKyfFPcOWEjfkokdb+W8QL/2IDSJCN9vmhBva2QQIr0GQxyelyNwPv1Du30 5zz9Eyh9MnTN9ovy7Wgp+sESyjsOVfEmKqqlHzaGoYpYmrH8J05tQxVSKeXXSxeMB6pY rRxFz5jH3GaSETpQacrKMz6GuXd7bt+AILkBzxZ2Et9NRQ6S55UhyaTNbuxvgJwElNmr EMiPz0zPnPXFrJ91P+hGrI6YQz4YtreRk+51zEH3UTkHiH2HHHc40P/ZV6VIIuQsMTD+ zsjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=3AHLY9tvsduLZ3njRuW/wWWCfiDjBIzVHOyfG6QyGr8=; b=KW5zyhxdx8a6W7e2Gdr75InsHz27Xel4Q1vztjW/FOz2WMzGAWUc4FMdlJtuFMeII/ O2D8cIEbHqRgZDirlor1MsbL7N4T/mFDVEJcccmTJE5D9J0bzLEBzBmEHXx2yxurOGqX hlRuQMtThLDtUw7d4ghNVHxMPmW6CKlBfXZh2brOnB5+kHi87TIr/IhX8wD6A5waVUMU blxPEHyqEicpUCv12ew9F9Ii3ah9X3Zx0ZkPhAMibzLhYJca7r5uwDASDAbGPa2dtnEo 7ccmtSqn6xQLfM1O8Em6xWSJAkxsRmSxmlzb+bF6JzTrMSzLcN1TcyzLHf3hzTwOA5J2 kIgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=q2QpvAlD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bc3-20020a170902930300b0018930d070bdsi654978plb.72.2022.11.24.02.17.35; Thu, 24 Nov 2022 02:17:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=q2QpvAlD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229978AbiKXJqV (ORCPT + 87 others); Thu, 24 Nov 2022 04:46:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229632AbiKXJqT (ORCPT ); Thu, 24 Nov 2022 04:46:19 -0500 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 334C4125229 for ; Thu, 24 Nov 2022 01:46:18 -0800 (PST) Received: by mail-lf1-x12a.google.com with SMTP id g7so1737024lfv.5 for ; Thu, 24 Nov 2022 01:46:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=3AHLY9tvsduLZ3njRuW/wWWCfiDjBIzVHOyfG6QyGr8=; b=q2QpvAlDEp2M1ST1ggUdvgHWTGfPFND9+jl3nUF37uw6ACZ3TYoqpNfK/lmnNy91R0 NXpJXBmvNu+CalRsPTpWt2dv+WlT8cpIaKGPAgue4Y7Bh7+nwN0ISrmv06ekD4bJ5RlA 809/yPwF/u92xz+c2V0pB9Zefvv5MD2zaxPOXOa4YfHd1HEbuvzvJ0RZWP5hqeUgpnBR 8XN2WhqktrVYryCyLbGwR9LNM+Z+00lU6fphh+wGXl5PzCcZAiPWvsZxSNJq1M1Hpex4 2YmHfruNsmzUV9yx81GmvewYUK7Kec2riP5tmZfCEQ0N1bsfovsmtOx35LtsWhSbXqJC VscA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3AHLY9tvsduLZ3njRuW/wWWCfiDjBIzVHOyfG6QyGr8=; b=HwgRmJtLHrd3yhPV0VhI0rFUDGOn0FNlx4F7hVbQt+uXTYkisYd4pEZPmtpDCKb7ti 94M/Vydj+TDsloGx+nmIZsFS4PZ1/hNZO3GfR+Xe2mwKL0VgRUJlZBQDS/Z05eFj60rk WMX6UwQDWDK7tTy12GmZT5ceN7rKcpfYmI4uKwU0lHaWqV3d6VZRdHa9MULQxsBtEaQS Kag6qu+zR8EaCPmEIY3VTPQ5kLL5cY8w0hckIfOvbQSwZdjC8bbcRP5VQ9IvRpTzBZqk j94deTyUn9Q0Gd/YzaSmlqzDfpMS6OtQU0hrCJOofvZE8fxDb4atIns1HPgTtPqHQB5G Ygag== X-Gm-Message-State: ANoB5pnvprpo7y1t1VrRvCT9+3VZer+m04Um7FWA3YrYtDEpmfKNu+3U Ryq6AG/UwTHVZgyoo3VpNK/BFw== X-Received: by 2002:a05:6512:750:b0:4b0:a1e7:9160 with SMTP id c16-20020a056512075000b004b0a1e79160mr10030565lfs.566.1669283176500; Thu, 24 Nov 2022 01:46:16 -0800 (PST) Received: from [192.168.0.20] (088156142067.dynamic-2-waw-k-3-2-0.vectranet.pl. [88.156.142.67]) by smtp.gmail.com with ESMTPSA id t18-20020a056512209200b0049a4862966fsm69509lfr.146.2022.11.24.01.46.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 24 Nov 2022 01:46:15 -0800 (PST) Message-ID: Date: Thu, 24 Nov 2022 10:46:14 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: [PATCH v2 2/7] dt-bindings: clock: renesas,r9a06g032-sysctrl: Add h2mode property Content-Language: en-US To: Miquel Raynal Cc: Geert Uytterhoeven , Herve Codina , Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Greg Kroah-Hartman , Magnus Damm , Gareth Williams , linux-renesas-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Thomas Petazzoni References: <20221114111513.1436165-1-herve.codina@bootlin.com> <20221115150417.513955a7@bootlin.com> <20221118112349.7f09eefb@bootlin.com> <20221121165921.559d6538@bootlin.com> <4e54bfb4-bb67-73b8-f58f-56797c5925d3@linaro.org> <1f12883b-1e37-7f2b-f9e9-c8bad290a133@linaro.org> <191a7f3e-0733-8058-5829-fe170a06dd5a@linaro.org> <20221122100706.739cec4d@bootlin.com> <3856e2d8-1c16-a69f-4ac5-34b8e7f18c2b@linaro.org> <02db6a5d-ae9d-68b5-f5c5-bebb471e0f70@linaro.org> <20221124103633.4fbf483f@xps-13> From: Krzysztof Kozlowski In-Reply-To: <20221124103633.4fbf483f@xps-13> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24/11/2022 10:36, Miquel Raynal wrote: > Hi Krzysztof, > > krzysztof.kozlowski@linaro.org wrote on Wed, 23 Nov 2022 10:39:41 +0100: > >> On 22/11/2022 11:47, Geert Uytterhoeven wrote: >>> Hi Krzysztof, >>> >>> On Tue, Nov 22, 2022 at 11:30 AM Krzysztof Kozlowski >>> wrote: >>>> On 22/11/2022 10:07, Herve Codina wrote: >>>>> On Tue, 22 Nov 2022 09:42:48 +0100 >>>>> Krzysztof Kozlowski wrote: >>>>> >>>>>> On 22/11/2022 09:25, Geert Uytterhoeven wrote: >>>>>>> Hi Krzysztof, >>>>>>> >>>>>>> On Tue, Nov 22, 2022 at 8:45 AM Krzysztof Kozlowski >>>>>>> wrote: >>>>>>>> On 21/11/2022 21:46, Geert Uytterhoeven wrote: >>>>>>>>>> This does not change anything. Herve wrote: >>>>>>>>>> >>>>>>>>>>> probe some devices (USB host and probably others) >>>>>>>>>> >>>>>>>>>> Why some can be probed earlier and some not, if there are no >>>>>>>>>> dependencies? If there are dependencies, it's the same case with sysctrl >>>>>>>>>> touching the register bit and the USB controller touching it (as well >>>>>>>>>> via syscon, but that's obvious, I assume). >>>>>>>>>> >>>>>>>>>> Where is the synchronization problem? >>>>>>>>> >>>>>>>>> The h2mode bit (and probably a few other controls we haven't figured out >>>>>>>>> yet) in the sysctrl must be set before any of the USB devices is active. >>>>>>>>> Hence it's safest for the sysctrl to do this before any of the USB drivers >>>>>>>>> probes. >>>>>>>> >>>>>>>> Again, this does not differ from many, many of other devices. All of >>>>>>>> them must set something in system controller block, before they start >>>>>>>> operating (or at specific time). It's exactly the same everywhere. >>>>>>> >>>>>>> The issue here is that there are two _different drivers_ (USB host >>>>>>> and device). When both are modular, and the driver that depends on the >>>>>>> sysctrl setting is loaded second, you have a problem: the sysctrl change >>>>>>> must not be done when the first driver is already using the hardware. >>>>>>> >>>>>>> Hence the sysctrl driver should take care of it itself during early >>>>>>> initialization (it's the main clock controller, so it's a dependency >>>>>>> for all other I/O device drivers). >>>>>> >>>>>> I assumed you have there bit for the first device (which can switch >>>>>> between USB host and USB device) to choose appropriate mode. The >>>>>> bindings also expressed this - "the USBs are". Never said anything about >>>>>> dependency between these USBs. >>>>>> >>>>>> Are you saying that the mode for first device cannot be changed once the >>>>>> second device (which is only host) is started? IOW, the mode setup must >>>>>> happen before any of these devices are started? >>>>>> >>>>>> Anyway with sysctrl approach you will have dependency and you cannot >>>>>> rely on clock provider-consumer relationship to order that dependency. >>>>>> What if you make all clocks on and do not take any clocks in USB device? >>>>>> Broken dependency. What if you want to use this in a different SoC, >>>>>> where the sysctrl does not provide clocks? Broken dependency. >>>>> >>>>> The issue is really related to the Renesas sysctrl itself and not related >>>>> to the USB drivers themselves. >>>>> From the drivers themselves, the issue is not seen (I mean the driver >>>>> takes no specific action related to this issue). >>>>> If we change the SOC, the issue will probably not exist anymore. >>>> >>>> Yeah, and in the next SoC you will bring 10 of such properties to >>>> sysctrl arguing that if one was approved, 10 is also fine. Somehow >>>> people on the lists like to use that argument - I saw it somewhere, so I >>>> am allowed to do here the same. >>> >>> Like pin control properties? ;-) >>> This property represents a wiring on the board... >>> I.e. a system integration issue. >>> >>>> I understand that the registers responsible for configuration are in >>>> sysctrl block, but it does not mean that it should be described as part >>>> of sysctrl Devicetree node. If there was no synchronization problem, >>>> this would be regular example of register in syscon which is handled >>>> (toggled) by the device (so USB device/host controller). Since there is >>>> synchronization problem, you argue that it is correct representation of >>>> hardware. No, it is not, because logically in DT you do not describe >>>> mode or existence of other devices in some other node and it still does >>>> not describe this ordering. >>> >>> So we have to drop the property, and let the sysctrl block look >>> for @ nodes, and check which ones are enabled? >>> >>> Running out of ideas... > > I'm stepping in, hopefully I won't just be bikeshedding on something > that has already been discussed but here is my grain of salt. > >> One solution could be making USB nodes children of the sysctrl block which: >> 1. Gives proper ordering (children cannot start before parent) >> regardless of any other shared resources, >> 2. Allows to drop this mode property and instead check what type of >> children you have and configure mode depending on them. >> >> However this also might not be correct representation of hardware >> (dunno...), so I am also running out of ideas. > > I see what you mean here, but AFAICS that is clearly a wrong > representation of the hardware. Sorting nodes by bus seems the aim of > device tree because there is a physical relationship, that's why we > have (i2c as an example): > > ahb { > foo-controller@xxx { > reg = ; > }; > }; > > But what you are describing now is conceptually closer to: > > clk-controller { > foo-controller { > reg = ? > }; > }; Which is not a problem. reg can be anything - offset from sysctrl node or absolute offset. We have it in many places already. What's the issue here? > > Not mentioning that this only works once, because foo-controller might > also need other blocks to be ready before probing and those might > be different blocks (they are the same in the rzn1 case, but > more generally, they are not). But what is the problem of needing other blocks? All devices need something and we solve it... > So in the end I am not in favor of this > solution. > > If we compare the dependency between the USB device controller and the > sysctrl block which contains the h2mode register to existing > dependencies, they are all treated with properties. These properties, > eg: > > foo-controller { > clocks = <&provider [index]>; > }; > > were initially used to just tell the consumer which resource it should > grab/enable. If the device was not yet ready, we would rely on the > probe deferral mechanism to try again later. Not optimal, but not > bad either as it made things work. Since v5.11 and the addition of > automatic device links, the probe order is explicitly ordered. > could always get probed before . So, isn't > what we need here? What about the following: > > sysctrl { > h2mode = "something"; > }; > > usb-device { > h2mode-provider = <&sysctrl>; > }; No, because next time one will add 10 of such properties: sysctrl { h2mode = "" g2mode = "" i2mode = "" .... } and keep arguing that because these registers are in sysctrl, so they should have their own property in sysctrl mode. That's not correct representation of hardware. > > We can initially just make this work with some additional logic on both > sides. The USB device controller would manually check whether sysctrl > has been probed or not (in practice, because of the clocks and power > domains being described this will always be a yes, but IIUC we want to > avoid relying on it) and otherwise, defer its probe. On the sysctrl side > it is just a matter of checking (like we already do): > > if (!sysctrl_priv) > return -EPROBE_DEFER; > > To be honest I would love to see the device link mechanism extended to > "custom" phandle properties like that, it would avoid the burden of > checking for deferrals manually, aside with boot time improvements. If > we go this way, we shall decide whether we want to: > * extend the list of properties that will lead to a dependency creation [1] > * or maybe settle on a common suffix that could always be used, > especially for specific cases like this one where there is an > explicit provider-consumer dependency that must be fulfilled: > > DEFINE_SUFFIX_PROP(provider, "-provider", "#provider-cells") > > * or perhaps extend struct of_device_id to contain the name of the > properties pointing to phandles that describe probe dependencies with: > > char *provider_prop_name; > char *provider_cells_prop_name; > > and use them from of/property.c to generate the links when relevant. > > [1] https://elixir.bootlin.com/linux/v6.0/source/drivers/of/property.c#L1298 > > > Thanks, > Miquèl Best regards, Krzysztof