Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5406153rdb; Sat, 16 Sep 2023 16:10:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE7WtYyCrCK6EgtcXC+s27aj7iM+GHaczB6lhE6os92TV8/qmhPxbzaKkb3/mLg8GhVk4hT X-Received: by 2002:a05:6a20:4285:b0:14d:d9f8:83f8 with SMTP id o5-20020a056a20428500b0014dd9f883f8mr7973834pzj.1.1694905824338; Sat, 16 Sep 2023 16:10:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694905824; cv=none; d=google.com; s=arc-20160816; b=n9O2cMM49GnahbhWhz2knNT31i9O6hWZbA0hSB3jPmHinvNp7BhOFvKY04CK/CzWEq K0MRqck46mYF+fwqe9vgRI/oMfl09hATUnIVMJN9WqcoNkwSydBybaLKMWTSU8zo+VOu fcPGpAh1zsSZOFV5Vlu47Sm5R4VqZcP5vdizXigBS2eCjVXQGuiwIzxPSlPnHmWONY// wihNlyN+R94AXpVRGJpN0fF1MSDJljo3C/mhyuPdH5ZK9K/OuHCM5CzEIM/aq0WTuqwO rIjLbDr3GbDSdsCna+2/pGTM+byYGDE/PI5gckFbu8KPPnukRc1vtjYU+1QtM9aYvt6y jAcQ== 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:feedback-id:dkim-signature:dkim-signature; bh=AiiRLsWmSd5omTSsVWE7/nPP8xSFayX8bsXWXu59V40=; fh=uhpS5mrTnvbeM+ZBrhPIbN7kVXAQsNACy/dHvo9fG8Y=; b=jCwQUjNcs0faaI/JWIqXDVFz+CLP1Ps0TVJZMXMWzjMouReygGFOKCWHVd+eGycuGV lKdwC7IvW83JqjJ6oHQlX1RO6I6Nbm3SqN/3LgZQZvLwPS7AsWgahB6MJPPuoZ4CRCeT WsNxRrDYIW72t41HjF00mT4s4WOjaiDwfG3MKmMouLP6kOqvTsdxkuGJ8w2Rt+Rx9SD9 1X+kQcGaGTUAWquABc1Wsrzp8e/XI2MwioPHUfaE0Q4KC05fE4V90qcFQNVg0QzrbQpO C8hUWUvNXYPySWoI74Gpk5u0DXSBcC1wecMCBiiQMV2XdXWxFcnegji3ab9+adzbQzgy YfkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sholland.org header.s=fm3 header.b="Kqw/d/2w"; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=oQNWFgit; 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=NONE sp=NONE dis=NONE) header.from=sholland.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id ca20-20020a056a02069400b00565eccbc52fsi5954608pgb.303.2023.09.16.16.10.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 16:10:24 -0700 (PDT) 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=@sholland.org header.s=fm3 header.b="Kqw/d/2w"; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=oQNWFgit; 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=NONE sp=NONE dis=NONE) header.from=sholland.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id E71B48047872; Fri, 15 Sep 2023 22:03:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238470AbjIPFAM (ORCPT + 99 others); Sat, 16 Sep 2023 01:00:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238431AbjIPFAK (ORCPT ); Sat, 16 Sep 2023 01:00:10 -0400 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B1041BE3; Fri, 15 Sep 2023 22:00:05 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id D3C5B5C01EC; Sat, 16 Sep 2023 01:00:01 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Sat, 16 Sep 2023 01:00:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm3; t= 1694840401; x=1694926801; bh=AiiRLsWmSd5omTSsVWE7/nPP8xSFayX8bsX WXu59V40=; b=Kqw/d/2w3S28QiXRFwkxvePDrM8dFhz74RMTQQJakHkL8DctgJ8 MbJivKPiMXpIntW2cRIZmdLHwIHzrwyU7pBbxsUOzZmNZCp3gMUOS/SlvXHVgq1d po6bsMlGMANNr6c5OOTivp2hQCOJK1NZlVHyUyXzkpgonPH87kvxHeCkEDpOK2Cp qWaDbCUojHmtbQQeexcMlMHmA/YhrbWhyvGc+o00OpEzzH5hTrRMeG8HrAqebiXT 3xXxvB1lp9/1x/xxInYe/DfRdsxVmCpHkY/xAaGhPSTmT2M45lor8uEx92QzAZb9 kMnC3bo/CkNvKeHUJ/E1rkplLGHx6IS5Miw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1694840401; x=1694926801; bh=AiiRLsWmSd5omTSsVWE7/nPP8xSFayX8bsX WXu59V40=; b=oQNWFgitw5weXS+KA0QECq8DgO+ECRW0F//RIDseWzy3uqP/PEv gLmIyQ/T/0y371VAET/dY3LjoJmRaFiAK8lJhzYyeCIKCdTGpJmBOf0Xf0HGZTFx fYM0h/lzhi9ZbH3E1yrVDm/ZxxpAGAcKdWxewpmr3G7bz759oWhj1BdmeRvWfdCV iy/zwKMpfc8XwIw1AlPv7tZyUcKoqCHtuTcKlJfvooiJiPzML5Dy6ae5sos6igDd MzxwViTTBew0hv18+PxHTJkGxkuZLT3pXDLqKOlSke881D3dbewfrkNw2iHlGvVJ NDpNAwaTDz8Az0X0ZONzwSpfiH/jz+pjCeA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudejfedgkeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtfeejnecuhfhrohhmpefurghm uhgvlhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenuc ggtffrrghtthgvrhhnpefgtdfgleffkeevledvueetteefgfellefhjeetieeuhfehteeu feefgfehfeevfeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 16 Sep 2023 01:00:00 -0400 (EDT) Message-ID: <367a8ee4-2047-879d-22ae-a0082a04f92f@sholland.org> Date: Fri, 15 Sep 2023 23:59:59 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux ppc64le; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: [PATCH 1/3] pinctrl: rockchip: add support for io-domain dependency Content-Language: en-US To: Saravana Kannan , Sascha Hauer Cc: Chen-Yu Tsai , Linus Walleij , linux-rockchip@lists.infradead.org, Heiko Stuebner , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, kernel@pengutronix.de, Quentin Schulz , Michael Riesch , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robin Murphy References: <20230904115816.1237684-1-s.hauer@pengutronix.de> <20230904115816.1237684-2-s.hauer@pengutronix.de> <20230913065843.GF637806@pengutronix.de> From: Samuel Holland In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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]); Fri, 15 Sep 2023 22:03:58 -0700 (PDT) On 9/13/23 15:48, Saravana Kannan wrote: > On Tue, Sep 12, 2023 at 11:58 PM Sascha Hauer wrote: >> On Wed, Sep 13, 2023 at 12:37:54PM +0800, Chen-Yu Tsai wrote: >>> On Tue, Sep 12, 2023 at 4:07 PM Linus Walleij wrote: >>>> >>>> Top posting to bring Saravana Kannan into this discussion. >>>> >>>> This looks like a big hack to me, Saravana has been working >>>> tirelessly to make the device tree probe order "sort itself out" >>>> and I am pretty sure this issue needs to be fixed at the DT >>>> core level and not in a driver. >>> >>> We could merge all the IO domain stuff into the pinctrl node/driver, >>> like is done for Allwinner? Maybe that would simplify things a bit? >> >> I thought about this as well. On Rockchip the pinctrl driver and the IO >> domain driver even work on the same register space, so putting these >> into a single node/driver would even feel more natural than what we have >> now. > > Then we should try to do this and fix any issues blocking us. > >> However, with that the pinctrl node would get the supplies that the IO >> domain node now has and we would never get into the probe of the pinctrl >> driver due to the circular dependencies. > > From a fw_devlink perspective, the circular dependency shouldn't be a > problem. It's smart enough to recognize all cycle possibilities (since > 6.3) and not enforce ordering between nodes in a cycle. > > So, this is really only a matter of pinctrl not trying to do > regulator_get() in its probe function. You need to do the > regulator_get() when the pins that depend on the io-domain are > requested. And if the regulator isn't ready yet, return -EPROBE_DEFER? > > Is there something that prevents us from doing that? Calling regulator_get() from the pin request function does not solve the problem on its own. We already do that in the Allwinner driver (in sunxi_pmx_request()), and we still have the circular dependency: __driver_probe_device(I2C/RSB controller) pinctrl_bind_pins(I2C/RSB controller) pinctrl_select_state(I2C/RSB controller default pins) pinmux_enable_setting() pin_request() sunxi_pmx_request() regulator_get(vcc-pl) [depends on the PMIC/regulator driver] [depends on the I2C/RSB controller driver] To break the cycle, you need to defer the regulator_get() call during this specific call to the pin request function, then come back later and call regulator_get() once the regulator is actually registered. If we have a DT property somewhere that provides an initial voltage for the I/O domain, then regulator_get() returning -EPROBE_DEFER would not be an error. Instead, we would configure the I/O domain based on the DT property, and add the pair (IO domain, regulator OF node) to a list. Then register a notifier for new regulator class devices. Check each new device's OF node against the list; if it is found, hook up the voltage notifier and remove the list entry. When the list is empty, remove the regulator class notifier. I thought about (ab)using the pinctrl "init" state so pin_request() gets called a second time inside pinctrl_init_done() after the PMIC's bus controller gets probed, but that would rely on the regulator getting registered synchronously by some recursive call inside the bus controller probe function. So it would break if probing the PMIC/regulator driver got deferred for any reason. So the suggestion from my perspective ends up being the same as what Robin just suggested elsewhere in the thread. :) Regards, Samuel