Message ID | 20230323083312.199189-1-m.szyprowski@samsung.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp2789278wrt; Thu, 23 Mar 2023 01:37:20 -0700 (PDT) X-Google-Smtp-Source: AK7set/iHdaXxmwarmYVjt47VN+kPDU2dJur73LjDk4uaUtdhG+DPHGu7tGHrk37eJLeo3RDPcB5 X-Received: by 2002:a17:902:d4cb:b0:19b:dbf7:f9ca with SMTP id o11-20020a170902d4cb00b0019bdbf7f9camr7729158plg.0.1679560639711; Thu, 23 Mar 2023 01:37:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679560639; cv=none; d=google.com; s=arc-20160816; b=WkMdIwbiRTL4E23Jo/llpq1IT2eFB8q2iiAV+cjbPWPCNW1JcCMEK5ZmI+lqMXevlw WgBw5XqzR52U1MHLETg7r5ejvoUoHgWxJtMQ05aeH07giZvTA+KRVu3SEnm4DikP+Qww LDHzMrNhRa23lVGS5vs3Xrm9KvAjKfrQAwO5D+/Dt3JcbV54mnBBrctC8n3/fCbEkRJg sfXwCh6qsb55TeislaMZyH1k5eZ+sxtPgPn9RGoMmg8ggXQugKfrVrpHIuxfXaIuvI6i ITmrXSdVGboGEPqLlLNxORdR8T5FCFDo8QJ3ShZ/hVVI1FmrNLJ1yYofdJx6fJtHhhW4 I6lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dkim-filter; bh=YudGPA60bFxRDbJj3Qc3E+Wrq3F9hpMuQjBdPXmpKAo=; b=iy0FrBbW5NFdiCEtR3O1zc9bWjgeqMiQ7hWqX/e+xof8dcmtctLYf7VDE0P+CV/aKC dUd7HNpEYmSjVexw1YSMOkulVP8zlPaRGifBRlwpWyIhDS/Zcc/oJuINujIAxC+QVxI+ lgDrfb7afd+r9VlZ4MDJTCWh3AhFYmh+SzulNlvQw22cPsGxpVFI4YZC+fEAn72tjjDJ BArjrMGJ3ceJYXpLKZniBHXkyw54Pd9KiXoprGPKbkcOqFUpRyUlAU170fRtrPh5GPU4 bv2xj90rfJYWyOemhxukzGrLLufPl4ZJn1oabDLmHRQimwkIqsDEhGgOnSMtyhS/P8j8 ZFSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=PRhlmaiy; 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=samsung.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h11-20020a65480b000000b0050bcc130779si17531551pgs.28.2023.03.23.01.37.07; Thu, 23 Mar 2023 01:37:19 -0700 (PDT) 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=@samsung.com header.s=mail20170921 header.b=PRhlmaiy; 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=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231460AbjCWIeA (ORCPT <rfc822;ezelljr.billy@gmail.com> + 99 others); Thu, 23 Mar 2023 04:34:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231463AbjCWIdk (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 23 Mar 2023 04:33:40 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56851769A for <linux-kernel@vger.kernel.org>; Thu, 23 Mar 2023 01:33:33 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230323083330euoutp01ada7a16a0f4c7caac6b21f03a485fd86~O-0uD_PNR1426814268euoutp01t for <linux-kernel@vger.kernel.org>; Thu, 23 Mar 2023 08:33:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230323083330euoutp01ada7a16a0f4c7caac6b21f03a485fd86~O-0uD_PNR1426814268euoutp01t DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1679560410; bh=YudGPA60bFxRDbJj3Qc3E+Wrq3F9hpMuQjBdPXmpKAo=; h=From:To:Cc:Subject:Date:References:From; b=PRhlmaiynunD/Lf64BFyTvlQ2rjTylZ2cuCD9xdli1z9wny5OOeVCn3sTS4CGk5ZU rAmn1sJyHuBzQ4FQoZy0zfSb4+8jkCb7bEWItJhY7BiW2cMeI5UWvsiJ21LWBZNQGQ DwAq0tekHwGFLHVqn8ep61VTLrVeDnzcOW7AqSt8= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230323083330eucas1p19a97dfc0ce93df9ef18fa48df58faa23~O-0t2oqWn0376103761eucas1p1P; Thu, 23 Mar 2023 08:33:30 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id BF.96.10014.ADE0C146; Thu, 23 Mar 2023 08:33:30 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230323083330eucas1p1f7e3f9beb5ba168c6b13374d74c158f0~O-0taGy_-0377303773eucas1p1M; Thu, 23 Mar 2023 08:33:30 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230323083330eusmtrp1fd0d0ddebb0ed10535121ce630db59bf~O-0tZfgZI1498714987eusmtrp1Y; Thu, 23 Mar 2023 08:33:30 +0000 (GMT) X-AuditID: cbfec7f5-b8bff7000000271e-1c-641c0eda28c8 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 08.8B.08862.ADE0C146; Thu, 23 Mar 2023 08:33:30 +0000 (GMT) Received: from AMDC2765.eu.corp.samsungelectronics.net (unknown [106.120.51.73]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230323083329eusmtip190f52998ff08829aa6a9ccae7d7e7f53~O-0s8uj8e1892518925eusmtip1O; Thu, 23 Mar 2023 08:33:29 +0000 (GMT) From: Marek Szyprowski <m.szyprowski@samsung.com> To: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski <m.szyprowski@samsung.com>, Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>, Douglas Anderson <dianders@chromium.org>, patches@opensource.cirrus.com Subject: [PATCH] regulator: wm8994: Use PROBE_FORCE_SYNCHRONOUS Date: Thu, 23 Mar 2023 09:33:12 +0100 Message-Id: <20230323083312.199189-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprOKsWRmVeSWpSXmKPExsWy7djPc7q3+GRSDPa+lLOY+vAJm8XZZQfZ LL5d6WCyuLxrDpvFjPP7mCzWHrnLbvH5/X5WB3aP2Q0XWTx2zrrL7rFpVSebx/Q5/xk9+ras YvT4vEkugC2KyyYlNSezLLVI3y6BK+PxhI0sBd/YKk5tbGBpYPzI2sXIySEhYCJxr+klI4gt JLCCUWLdNI0uRi4g+wujxJurH9ghnM+MEue2zoHr6LpyAyqxnFFiybLXTBBOK5PEhI8/WECq 2AQMJbredrGB2CICzhK3P3xjASliFjjEKLFtx012kISwgL3E3f42sAYWAVWJvg8/wQ7hFbCT +DHvHzPEOnmJ/QfPMkPEBSVOznwCVs8MFG/eOpsZZKiEwFIOiffnvgBt4wByXCROfBOE6BWW eHV8CzuELSNxenIPC0R9O6PEgt/3mSCcCYwSDc9vMUJUWUvcOfcLbBCzgKbE+l36EGFHicNd i5gh5vNJ3HgrCHEDn8SkbdOhwrwSHW1CENVqErOOr4Nbe/DCJahXPCSePZzKAgnrWInHu9vZ JjAqzELy2Swkn81CuGEBI/MqRvHU0uLc9NRi47zUcr3ixNzi0rx0veT83E2MwLRz+t/xrzsY V7z6qHeIkYmDERjIHMxKIrxuzBIpQrwpiZVVqUX58UWlOanFhxilOViUxHm1bU8mCwmkJ5ak ZqemFqQWwWSZODilGpiW+MzSO/RYSiVpwqPpB9de9Hno/PSh1cK3QR+v8m23Dlf4EvBHNOoh 9+Lj2z/e5LoeOzOkK1Gs+a/vXT1Gycxfpy9ph+mEv9JjKlZeesjqAe/GWQ5qHOt7xZe5iP4I 8or8tlJ6u4jrstkW26z0azdraOk93+b2/vrz/5NUwrcFmydnfwxbqrHTfqrT5NpdcYcvRxuV fVDU8lfON70ceLCIi+NoYrt02Otzuyf+y67kCbh8QdfeJSIiZQVfeU9JfbCAWnGE08VS1vaO iGansg1isxjZDgRNUjbPdwlas0LG1y3n1zddE/tkLZ39sTcWpd7K3BOffaUqtd197Q3HxXyx wR8/c70/+3jKnm3OvEosxRmJhlrMRcWJANuPX5WqAwAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrHLMWRmVeSWpSXmKPExsVy+t/xu7q3+GRSDPoeMVtMffiEzeLssoNs Ft+udDBZXN41h81ixvl9TBZrj9xlt/j8fj+rA7vH7IaLLB47Z91l99i0qpPNY/qc/4wefVtW MXp83iQXwBalZ1OUX1qSqpCRX1xiqxRtaGGkZ2hpoWdkYqlnaGwea2VkqqRvZ5OSmpNZllqk b5egl/F4wkaWgm9sFac2NrA0MH5k7WLk5JAQMJHounKDvYuRi0NIYCmjxM7OG0wQCRmJk9Ma oIqEJf5c62KDKGpmknhy8BMjSIJNwFCi6y1IgpNDRMBVovXLDxaQImaBY4wSt5e9AOsWFrCX uNvfxgJiswioSvR9+AnWzCtgJ/Fj3j9miA3yEvsPnmWGiAtKnJz5BKyeGSjevHU28wRGvllI UrOQpBYwMq1iFEktLc5Nzy021CtOzC0uzUvXS87P3cQIDPhtx35u3sE479VHvUOMTByMhxgl OJiVRHjdmCVShHhTEiurUovy44tKc1KLDzGaAt03kVlKNDkfGHN5JfGGZgamhiZmlgamlmbG SuK8ngUdiUIC6YklqdmpqQWpRTB9TBycUg1M8vv4s1ZXCd9nYTPbb28Uu+fwDKXc3EWhy0J2 G0Y9W9j9hu/1e6sooZm96YIz+OZuubJf4/D9QqOS6acFs52enPRX6fr2Ref4qq4Z85hCzRmt Uidus99jFPW5XKO3STCUeZ1Jws0pswNkawJVb4nXvZhi8+zjHp51F9s2aswIT9Ge9NK98op3 V2Rx342c0gWP29k3fn5w1kI/w3bat/R3V1O2NpjcPrxAc82bzRxzmT8nZPA3zU6791fuU8jM 6XuWPFUy317RVlf16Z7YbeMd1ta1p3KyGTYkum35d/m1Q93lcobP0y9sV9ZamZsaeeram07J ij9v/theeeAwfdODl+mMKROW77zGrjpVlakqQYmlOCPRUIu5qDgRAICrdyIBAwAA X-CMS-MailID: 20230323083330eucas1p1f7e3f9beb5ba168c6b13374d74c158f0 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20230323083330eucas1p1f7e3f9beb5ba168c6b13374d74c158f0 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230323083330eucas1p1f7e3f9beb5ba168c6b13374d74c158f0 References: <CGME20230323083330eucas1p1f7e3f9beb5ba168c6b13374d74c158f0@eucas1p1.samsung.com> X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761146977359585752?= X-GMAIL-MSGID: =?utf-8?q?1761146977359585752?= |
Series |
regulator: wm8994: Use PROBE_FORCE_SYNCHRONOUS
|
|
Commit Message
Marek Szyprowski
March 23, 2023, 8:33 a.m. UTC
Restore synchronous probing for wm8994 regulators because otherwise the
sound device is never initialized on Exynos5250-based Arndale board.
Fixes: 259b93b21a9f ("regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers that existed in 4.14")
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
drivers/regulator/wm8994-regulator.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Thu, Mar 23, 2023 at 09:33:12AM +0100, Marek Szyprowski wrote: > Restore synchronous probing for wm8994 regulators because otherwise the > sound device is never initialized on Exynos5250-based Arndale board. > > Fixes: 259b93b21a9f ("regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers that existed in 4.14") > Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> > --- > drivers/regulator/wm8994-regulator.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/regulator/wm8994-regulator.c b/drivers/regulator/wm8994-regulator.c > index 8921051a00e9..2946db448aec 100644 > --- a/drivers/regulator/wm8994-regulator.c > +++ b/drivers/regulator/wm8994-regulator.c > @@ -227,7 +227,7 @@ static struct platform_driver wm8994_ldo_driver = { > .probe = wm8994_ldo_probe, > .driver = { > .name = "wm8994-ldo", > - .probe_type = PROBE_PREFER_ASYNCHRONOUS, > + .probe_type = PROBE_FORCE_SYNCHRONOUS, > }, > }; Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com> Yes, these seems to be a wider problem with these complex CODECs that have an internal LDO. Changing to async probe, means the internal LDO driver doesn't probe before the code in the main MFD carries on, which means the regulator framework finds no driver and swaps in the dummy. Which means the CODEC never powers up. I think these basically have to be forced sync, I will do a patch to update the other devices working like this. Thanks, Charles
On Thu, 23 Mar 2023 09:33:12 +0100, Marek Szyprowski wrote: > Restore synchronous probing for wm8994 regulators because otherwise the > sound device is never initialized on Exynos5250-based Arndale board. > > Applied to https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next Thanks! [1/1] regulator: wm8994: Use PROBE_FORCE_SYNCHRONOUS commit: eef644d3802e7d5b899514dc9c3663a692817162 All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark
Hi, On Thu, Mar 23, 2023 at 4:40 AM Charles Keepax <ckeepax@opensource.cirrus.com> wrote: > > On Thu, Mar 23, 2023 at 09:33:12AM +0100, Marek Szyprowski wrote: > > Restore synchronous probing for wm8994 regulators because otherwise the > > sound device is never initialized on Exynos5250-based Arndale board. > > > > Fixes: 259b93b21a9f ("regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers that existed in 4.14") > > Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> > > --- > > drivers/regulator/wm8994-regulator.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/regulator/wm8994-regulator.c b/drivers/regulator/wm8994-regulator.c > > index 8921051a00e9..2946db448aec 100644 > > --- a/drivers/regulator/wm8994-regulator.c > > +++ b/drivers/regulator/wm8994-regulator.c > > @@ -227,7 +227,7 @@ static struct platform_driver wm8994_ldo_driver = { > > .probe = wm8994_ldo_probe, > > .driver = { > > .name = "wm8994-ldo", > > - .probe_type = PROBE_PREFER_ASYNCHRONOUS, > > + .probe_type = PROBE_FORCE_SYNCHRONOUS, > > }, > > }; > > Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com> > > Yes, these seems to be a wider problem with these complex CODECs > that have an internal LDO. Changing to async probe, means the > internal LDO driver doesn't probe before the code in the main MFD > carries on, which means the regulator framework finds no driver > and swaps in the dummy. Which means the CODEC never powers up. > > I think these basically have to be forced sync, I will do a patch > to update the other devices working like this. Sorry for the breakage and thank you for the fix. No question that a quick switch back to PROBE_FORCE_SYNCHRONOUS is the right first step here, but I'm wondering if there are any further steps we want to take. If my analysis is correct, there's still potential to run into similar problems even with PROBE_FORCE_SYNCHRONOUS. I don't think that mfd_add_devices() is _guaranteed_ to finish probing all the sub-devices by the time it returns. Specifically, imagine that wm8994_ldo_probe() tries to get a GPIO that that system hasn't made available yet. Potentially the system could return -EPROBE_DEFER there and that would put the LDO on the deferred probe list. Doing so won't cause mfd_add_devices() to fail. Now we'll end up with a dummy regulator again. Admittedly most cases GPIO providers probe really early and so this argument is a bit of a stretch, but I guess the point is that there's no official guarantee that mfd_add_devices() will finish probing all sub-devices so it's not ideal to rely on. Also, other drivers with a similar pattern might have other reasons to -EPROBE_DEFER. These types of issues are the same ones I faced with DP AUX bus and the solutions were never super amazing... One solution we ended up with for the DP AUX bus was to add a "done_probing" callback argument to devm_of_dp_aux_populate_bus(). This allowed the parent to be called back when all the children were done probing. This implementation is easier for DP AUX bus than it would be in the generic MFD case, but conceivably it would be possible there too? Another possible solution is to somehow break the driver up into more sub-drivers. Essentially, you have a top-level "wm8994" that's not much more than a container. Then you create a new-sub-device and relegate anything that needs the regulators to the new sub-device. The new sub-device can just -EPROBE_DEFER until it detects that the regulators have finished probing. I ended up doing stuff like this for "ti-sn65dsi86.c" using the Linux aux bus (not to be confused with the DP Aux bus) and it was a bit odd but worked OK. -Doug
On Thu, Mar 23, 2023 at 09:53:18AM -0700, Doug Anderson wrote: > Sorry for the breakage and thank you for the fix. Mostly my fault, it was me asked you to do all the drivers. > No question that a quick switch back to PROBE_FORCE_SYNCHRONOUS is the > right first step here, but I'm wondering if there are any further > steps we want to take. > If my analysis is correct, there's still potential to run into similar > problems even with PROBE_FORCE_SYNCHRONOUS. I don't think that > mfd_add_devices() is _guaranteed_ to finish probing all the > sub-devices by the time it returns. Specifically, imagine that > wm8994_ldo_probe() tries to get a GPIO that that system hasn't made > available yet. Potentially the system could return -EPROBE_DEFER there Yes, the code isn't 100% robust. The driver was written on the basis that we know the target systems for practical deployments are very unlikely to have such issues and we'd deal with the potential issues if they ever actually cropped up.
On Thu, Mar 23, 2023 at 09:53:18AM -0700, Doug Anderson wrote: > On Thu, Mar 23, 2023 at 4:40 AM Charles Keepax > If my analysis is correct, there's still potential to run into similar > problems even with PROBE_FORCE_SYNCHRONOUS. I don't think that > mfd_add_devices() is _guaranteed_ to finish probing all the > sub-devices by the time it returns. Specifically, imagine that > wm8994_ldo_probe() tries to get a GPIO that that system hasn't made > available yet. Potentially the system could return -EPROBE_DEFER there > and that would put the LDO on the deferred probe list. Doing so won't > cause mfd_add_devices() to fail. Now we'll end up with a dummy > regulator again. Admittedly most cases GPIO providers probe really > early and so this argument is a bit of a stretch, but I guess the > point is that there's no official guarantee that mfd_add_devices() > will finish probing all sub-devices so it's not ideal to rely on. > Also, other drivers with a similar pattern might have other reasons to > -EPROBE_DEFER. > > These types of issues are the same ones I faced with DP AUX bus and > the solutions were never super amazing... > > One solution we ended up with for the DP AUX bus was to add a > "done_probing" callback argument to devm_of_dp_aux_populate_bus(). > This allowed the parent to be called back when all the children were > done probing. This implementation is easier for DP AUX bus than it > would be in the generic MFD case, but conceivably it would be possible > there too? > > Another possible solution is to somehow break the driver up into more > sub-drivers. Essentially, you have a top-level "wm8994" that's not > much more than a container. Then you create a new-sub-device and > relegate anything that needs the regulators to the new sub-device. The > new sub-device can just -EPROBE_DEFER until it detects that the > regulators have finished probing. I ended up doing stuff like this for > "ti-sn65dsi86.c" using the Linux aux bus (not to be confused with the > DP Aux bus) and it was a bit odd but worked OK. Yes I believe you are correct, there is still an issue here, indeed a quick test suggests I can still cause this by forcing a probe defer in the regulator driver. I think really the best place to look at this would be at the regulator level. It is fine if mfd_add_devices passes, the problem really is that the regulator core doesn't realise the regulator is going to be arriving, and thus returns a dummy regulator, rather than returning EPROBE_DEFER. If it did the MFD driver would probe defer at the point of requesting the regulator, which would all make sense. I will see if I can find some time to think about that further but very unlikely to happen this week. Thanks, Charles
On Thu, Mar 23, 2023 at 05:45:31PM +0000, Charles Keepax wrote: > I think really the best place to look at this would be at the > regulator level. It is fine if mfd_add_devices passes, the problem > really is that the regulator core doesn't realise the regulator is > going to be arriving, and thus returns a dummy regulator, rather > than returning EPROBE_DEFER. If it did the MFD driver would probe > defer at the point of requesting the regulator, which would all > make sense. You need the MFD to tell the regulator subsystem that there's a regulator bound there, or to force all the users to explicitly do the mapping of the regulator in their firmwares (which isn't really a viable approach).
Hi, On Thu, Mar 23, 2023 at 10:45 AM Charles Keepax <ckeepax@opensource.cirrus.com> wrote: > > I think really the best place to look at this would be at the > regulator level. It is fine if mfd_add_devices passes, the problem > really is that the regulator core doesn't realise the regulator is > going to be arriving, and thus returns a dummy regulator, rather > than returning EPROBE_DEFER. If it did the MFD driver would probe > defer at the point of requesting the regulator, which would all > make sense. I think something like your suggestion could be made to work for the "microphone" supply in the arizona MFD, but not for the others looked at here. The problem is that if the MFD driver gets -EPROBE_DEFER then it will go through its error handling path and call mfd_remove_devices(). That'll remove the sub-device providing the regulator. If you try again, you'll just do the same. :-) Specifically in wm8994 after we've populated the regulator sub-devices then we turn them on and start talking to the device. I think the two options I have could both work for wm8994's case: either add some type of "my children have done probing" to MFD and move the turning on of regulators / talking to devices there, or add another stub-device and add it there. ;-) -Doug
On Thu, Mar 23, 2023 at 05:49:28PM +0000, Mark Brown wrote: > On Thu, Mar 23, 2023 at 05:45:31PM +0000, Charles Keepax wrote: > > > I think really the best place to look at this would be at the > > regulator level. It is fine if mfd_add_devices passes, the problem > > really is that the regulator core doesn't realise the regulator is > > going to be arriving, and thus returns a dummy regulator, rather > > than returning EPROBE_DEFER. If it did the MFD driver would probe > > defer at the point of requesting the regulator, which would all > > make sense. > > You need the MFD to tell the regulator subsystem that there's a > regulator bound there, or to force all the users to explicitly do the > mapping of the regulator in their firmwares (which isn't really a > viable approach). Yeah changing the firmware situation is definitely not a goer. I need to just clarify in my head exactly what is missing, with respect to the know the regulator exists. Thanks, Charles
On Thu, Mar 23, 2023 at 11:00:32AM -0700, Doug Anderson wrote: > Hi, > > On Thu, Mar 23, 2023 at 10:45 AM Charles Keepax > <ckeepax@opensource.cirrus.com> wrote: > > > > I think really the best place to look at this would be at the > > regulator level. It is fine if mfd_add_devices passes, the problem > > really is that the regulator core doesn't realise the regulator is > > going to be arriving, and thus returns a dummy regulator, rather > > than returning EPROBE_DEFER. If it did the MFD driver would probe > > defer at the point of requesting the regulator, which would all > > make sense. > > I think something like your suggestion could be made to work for the > "microphone" supply in the arizona MFD, but not for the others looked > at here. > > The problem is that if the MFD driver gets -EPROBE_DEFER then it will > go through its error handling path and call mfd_remove_devices(). > That'll remove the sub-device providing the regulator. If you try > again, you'll just do the same. :-) > > Specifically in wm8994 after we've populated the regulator sub-devices > then we turn them on and start talking to the device. > > I think the two options I have could both work for wm8994's case: > either add some type of "my children have done probing" to MFD and > move the turning on of regulators / talking to devices there, or add > another stub-device and add it there. ;-) Is this true if we keep the regulator as sync though? Yes it will remove the children but when it re-adds them the reason that the regulator probe deferred in the first place will hopefully be removed. So it will now fully probe in path. Thanks, Charles
Hi, On Fri, Mar 24, 2023 at 2:23 AM Charles Keepax <ckeepax@opensource.cirrus.com> wrote: > > On Thu, Mar 23, 2023 at 11:00:32AM -0700, Doug Anderson wrote: > > Hi, > > > > On Thu, Mar 23, 2023 at 10:45 AM Charles Keepax > > <ckeepax@opensource.cirrus.com> wrote: > > > > > > I think really the best place to look at this would be at the > > > regulator level. It is fine if mfd_add_devices passes, the problem > > > really is that the regulator core doesn't realise the regulator is > > > going to be arriving, and thus returns a dummy regulator, rather > > > than returning EPROBE_DEFER. If it did the MFD driver would probe > > > defer at the point of requesting the regulator, which would all > > > make sense. > > > > I think something like your suggestion could be made to work for the > > "microphone" supply in the arizona MFD, but not for the others looked > > at here. > > > > The problem is that if the MFD driver gets -EPROBE_DEFER then it will > > go through its error handling path and call mfd_remove_devices(). > > That'll remove the sub-device providing the regulator. If you try > > again, you'll just do the same. :-) > > > > Specifically in wm8994 after we've populated the regulator sub-devices > > then we turn them on and start talking to the device. > > > > I think the two options I have could both work for wm8994's case: > > either add some type of "my children have done probing" to MFD and > > move the turning on of regulators / talking to devices there, or add > > another stub-device and add it there. ;-) > > Is this true if we keep the regulator as sync though? Yes it will > remove the children but when it re-adds them the reason that the > regulator probe deferred in the first place will hopefully be > removed. So it will now fully probe in path. Ah, I see. So you keep it as synchronous _and_ make it so that it won't get a dummy. Yeah, I was trying to brainstorm ways we could fix it if we kept the regulator async. If we keep it as sync and fix the dummy problem then, indeed, it should work as you say. I've spent a whole lot of time dealing with similar issues, though, and I think there is actually another related concern with that design (where the regulator is synchronous). ;-) If the child device ends up depending on a resource that _never_ shows up then you can get into an infinite probe deferral loop at bootup. If it works the way it did last time I analyzed similar code: 1. Your MFD starts to probe and kicks off probing of its children (including the regulator). 2. Your regulator tries to probe and tries to get a resource that will never exist, maybe because of a bug in dts or maybe because it won't show up until userspace loads a module. It returns -EPROBE_DEFER. 3. The MFD realizes that the regulator didn't come up and it also returns -EPROBE_DEFER after removing all its children. 4. That fact that we added/removed devices in the above means that the kernel thinks it should retry probes of previously deferred devices because, maybe, the device showed up that everyone was waiting for. Thus, we go back to step #1. ...the system can actually loop forever in steps #1 - #4 and we ended up in that situation several times during development with similar architected systems. -Doug
On Fri, Mar 24, 2023 at 08:06:15AM -0700, Doug Anderson wrote: > On Fri, Mar 24, 2023 at 2:23 AM Charles Keepax > > On Thu, Mar 23, 2023 at 11:00:32AM -0700, Doug Anderson wrote: > > > On Thu, Mar 23, 2023 at 10:45 AM Charles Keepax > I've spent a whole lot of time dealing with similar issues, though, > and I think there is actually another related concern with that design > (where the regulator is synchronous). ;-) If the child device ends up > depending on a resource that _never_ shows up then you can get into an > infinite probe deferral loop at bootup. If it works the way it did > last time I analyzed similar code: > > 1. Your MFD starts to probe and kicks off probing of its children > (including the regulator). > > 2. Your regulator tries to probe and tries to get a resource that will > never exist, maybe because of a bug in dts or maybe because it won't > show up until userspace loads a module. It returns -EPROBE_DEFER. > > 3. The MFD realizes that the regulator didn't come up and it also > returns -EPROBE_DEFER after removing all its children. > > 4. That fact that we added/removed devices in the above means that the > kernel thinks it should retry probes of previously deferred devices > because, maybe, the device showed up that everyone was waiting for. > Thus, we go back to step #1. > > ...the system can actually loop forever in steps #1 - #4 and we ended > up in that situation several times during development with similar > architected systems. Hmm... shoot yes you are correct that would indeed happen. Thanks, Charles
diff --git a/drivers/regulator/wm8994-regulator.c b/drivers/regulator/wm8994-regulator.c index 8921051a00e9..2946db448aec 100644 --- a/drivers/regulator/wm8994-regulator.c +++ b/drivers/regulator/wm8994-regulator.c @@ -227,7 +227,7 @@ static struct platform_driver wm8994_ldo_driver = { .probe = wm8994_ldo_probe, .driver = { .name = "wm8994-ldo", - .probe_type = PROBE_PREFER_ASYNCHRONOUS, + .probe_type = PROBE_FORCE_SYNCHRONOUS, }, };