From: Marek Szyprowski <m.szyprowski@samsung.com>
To: Linus Walleij <linus.walleij@linaro.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>
Cc: linux-kernel@vger.kernel.org,
Charles Keepax <ckeepax@opensource.cirrus.com>,
Bartosz Golaszewski <bgolaszewski@baylibre.com>
Subject: Re: [PATCH 00/13 v2] Regulator ena_gpiod fixups
Date: Mon, 3 Dec 2018 15:35:37 +0100 [thread overview]
Message-ID: <d6b5f384-51aa-0e99-7e88-a1debcf5eca3@samsung.com> (raw)
In-Reply-To: <20181201154151.14890-1-linus.walleij@linaro.org>
Hi Linus,
On 2018-12-01 16:41, Linus Walleij wrote:
> Here is a second iteration of these fixups after thinking
> over Charles Keepax excellent comments on the first series
> of fixes.
>
> To make sure GPIO descriptors are never left dangling
> (as far as I can tell!) I use this stepwise approach:
>
> 1. Fix the regulator_register() in the core to guarantee
> that after calling this with a valid GPIO descriptor
> in ena_gpiod it will be gpiod_put() if there is any
> problem.
>
> 2. Fix up simple descriptor consumers to just gpiod_get()
> and let the core take over the descriptor. Only handle
> the errorpath up to this point.
>
> 3. Export gpiod_get_from_of_node() and let max77686
> obtain a GPIO descriptor from the device tree without
> any devres make-up in the DT parsing callback.
>
> 4. Invent devm_gpiod_unhinge() that will remove the devres
> monitoring of a devm_* allocated GPIO descriptor
> right before handling it over to the regulator core,
> and use this in the otherwise hairy da9211,
> s5m8767, tps65090 and s2mps11 drivers.
The idea is good imho, but it looks that there are some missing cases in
the code. Here are some logs from the boards I have access to:
Artik5 evaluation board (arch/arm/boot/dts/exynos3250-artik5-eval.dtb):
s2mps11-pmic s2mps14-regulator: Failed to get control GPIO for 11/LDO12
------------[ cut here ]------------
WARNING: CPU: 1 PID: 1 at drivers/gpio/gpiolib-devres.c:336
s2mps11_pmic_probe+0x1c4/0x49c
Modules linked in:
CPU: 1 PID: 1 Comm: swapper/0 Not tainted
4.20.0-rc5-next-20181203-00020-gf6d64d46ca8c #1156
Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
[<c01125fc>] (unwind_backtrace) from [<c010e140>] (show_stack+0x10/0x14)
[<c010e140>] (show_stack) from [<c0a510bc>] (dump_stack+0x98/0xc4)
[<c0a510bc>] (dump_stack) from [<c0127078>] (__warn+0x10c/0x124)
[<c0127078>] (__warn) from [<c01271a4>] (warn_slowpath_null+0x40/0x48)
[<c01271a4>] (warn_slowpath_null) from [<c04e5c94>]
(s2mps11_pmic_probe+0x1c4/0x49c)
[<c04e5c94>] (s2mps11_pmic_probe) from [<c0583e60>]
(platform_drv_probe+0x48/0x9c)
[<c0583e60>] (platform_drv_probe) from [<c0581858>]
(really_probe+0x274/0x400)
[<c0581858>] (really_probe) from [<c0581ba0>]
(driver_probe_device+0x78/0x1b8)
[<c0581ba0>] (driver_probe_device) from [<c0581e08>]
(__driver_attach+0x128/0x144)
[<c0581e08>] (__driver_attach) from [<c057f71c>]
(bus_for_each_dev+0x68/0xb4)
[<c057f71c>] (bus_for_each_dev) from [<c0580a1c>]
(bus_add_driver+0x1a8/0x268)
[<c0580a1c>] (bus_add_driver) from [<c0582e44>] (driver_register+0x78/0x10c)
[<c0582e44>] (driver_register) from [<c0103154>]
(do_one_initcall+0x8c/0x410)
[<c0103154>] (do_one_initcall) from [<c0f0124c>]
(kernel_init_freeable+0x3c8/0x4d0)
[<c0f0124c>] (kernel_init_freeable) from [<c0a6afd4>]
(kernel_init+0x8/0x10c)
random: fast init done
[<c0a6afd4>] (kernel_init) from [<c01010b4>] (ret_from_fork+0x14/0x20)
Exception stack(0xd8cc1fb0 to 0xd8cc1ff8)
1fa0: 00000000 00000000 00000000
00000000
1fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000
1fe0: 00000000 00000000 00000000 00000000 00000013 00000000
irq event stamp: 98209
hardirqs last enabled at (98217): [<c0192e14>] console_unlock+0x4ac/0x698
hardirqs last disabled at (98256): [<c0192a34>] console_unlock+0xcc/0x698
softirqs last enabled at (98276): [<c0102618>] __do_softirq+0x4f0/0x5e0
softirqs last disabled at (98289): [<c012f2f4>] irq_exit+0x160/0x16c
---[ end trace fed5502b2c7cd57b ]---
Unable to handle kernel paging request at virtual address fffffff0
pgd = (ptrval)
[fffffff0] *pgd=597ce841, *pte=00000000, *ppte=00000000
Internal error: Oops: 27 [#1] PREEMPT SMP ARM
Modules linked in:
CPU: 1 PID: 1 Comm: swapper/0 Tainted: G W
4.20.0-rc5-next-20181203-00020-gf6d64d46ca8c #1156
Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
PC is at devm_gpiod_match+0x4/0x18
LR is at devres_remove+0x68/0xb8
...
Flags: NzCv IRQs off FIQs on Mode SVC_32 ISA ARM Segment none
Control: 10c5387d Table: 4000406a DAC: 00000051
Process swapper/0 (pid: 1, stack limit = 0x(ptrval))
Stack: (0xd8cc1d58 to 0xd8cc2000)
...
[<c04a6f1c>] (devm_gpiod_match) from [<c05854b8>] (devres_remove+0x68/0xb8)
[<c05854b8>] (devres_remove) from [<c0585cdc>] (devres_destroy+0x8/0x24)
[<c0585cdc>] (devres_destroy) from [<c04a74a4>]
(devm_gpiod_unhinge+0x1c/0x38)
[<c04a74a4>] (devm_gpiod_unhinge) from [<c04e5c94>]
(s2mps11_pmic_probe+0x1c4/0x49c)
[<c04e5c94>] (s2mps11_pmic_probe) from [<c0583e60>]
(platform_drv_probe+0x48/0x9c)
[<c0583e60>] (platform_drv_probe) from [<c0581858>]
(really_probe+0x274/0x400)
[<c0581858>] (really_probe) from [<c0581ba0>]
(driver_probe_device+0x78/0x1b8)
[<c0581ba0>] (driver_probe_device) from [<c0581e08>]
(__driver_attach+0x128/0x144)
[<c0581e08>] (__driver_attach) from [<c057f71c>]
(bus_for_each_dev+0x68/0xb4)
[<c057f71c>] (bus_for_each_dev) from [<c0580a1c>]
(bus_add_driver+0x1a8/0x268)
[<c0580a1c>] (bus_add_driver) from [<c0582e44>] (driver_register+0x78/0x10c)
[<c0582e44>] (driver_register) from [<c0103154>]
(do_one_initcall+0x8c/0x410)
[<c0103154>] (do_one_initcall) from [<c0f0124c>]
(kernel_init_freeable+0x3c8/0x4d0)
[<c0f0124c>] (kernel_init_freeable) from [<c0a6afd4>]
(kernel_init+0x8/0x10c)
[<c0a6afd4>] (kernel_init) from [<c01010b4>] (ret_from_fork+0x14/0x20)
Exception stack(0xd8cc1fb0 to 0xd8cc1ff8)
...
---[ end trace fed5502b2c7cd57c ]---
Rinato (arch/arm/boot/dts/exynos3250-rinato.dtb):
s2mps11-pmic s2mps14-regulator: Failed to get control GPIO for 11/LDO12
random: fast init done
------------[ cut here ]------------
WARNING: CPU: 0 PID: 1 at drivers/gpio/gpiolib-devres.c:336
s2mps11_pmic_probe+0x1c4/0x49c
Modules linked in:
CPU: 0 PID: 1 Comm: swapper/0 Not tainted
4.20.0-rc5-next-20181203-00020-gf6d64d46ca8c #1156
Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
[<c01125fc>] (unwind_backtrace) from [<c010e140>] (show_stack+0x10/0x14)
[<c010e140>] (show_stack) from [<c0a510bc>] (dump_stack+0x98/0xc4)
[<c0a510bc>] (dump_stack) from [<c0127078>] (__warn+0x10c/0x124)
[<c0127078>] (__warn) from [<c01271a4>] (warn_slowpath_null+0x40/0x48)
[<c01271a4>] (warn_slowpath_null) from [<c04e5c94>]
(s2mps11_pmic_probe+0x1c4/0x49c)
[<c04e5c94>] (s2mps11_pmic_probe) from [<c0583e60>]
(platform_drv_probe+0x48/0x9c)
[<c0583e60>] (platform_drv_probe) from [<c0581858>]
(really_probe+0x274/0x400)
[<c0581858>] (really_probe) from [<c0581ba0>]
(driver_probe_device+0x78/0x1b8)
[<c0581ba0>] (driver_probe_device) from [<c0581e08>]
(__driver_attach+0x128/0x144)
[<c0581e08>] (__driver_attach) from [<c057f71c>]
(bus_for_each_dev+0x68/0xb4)
[<c057f71c>] (bus_for_each_dev) from [<c0580a1c>]
(bus_add_driver+0x1a8/0x268)
[<c0580a1c>] (bus_add_driver) from [<c0582e44>] (driver_register+0x78/0x10c)
[<c0582e44>] (driver_register) from [<c0103154>]
(do_one_initcall+0x8c/0x410)
[<c0103154>] (do_one_initcall) from [<c0f0124c>]
(kernel_init_freeable+0x3c8/0x4d0)
[<c0f0124c>] (kernel_init_freeable) from [<c0a6afd4>]
(kernel_init+0x8/0x10c)
[<c0a6afd4>] (kernel_init) from [<c01010b4>] (ret_from_fork+0x14/0x20)
Exception stack(0xd94c1fb0 to 0xd94c1ff8)
...
irq event stamp: 114729
hardirqs last enabled at (114747): [<c0192e14>] console_unlock+0x4ac/0x698
hardirqs last disabled at (114764): [<c0192a34>] console_unlock+0xcc/0x698
softirqs last enabled at (114762): [<c0102618>] __do_softirq+0x4f0/0x5e0
softirqs last disabled at (114781): [<c012f2f4>] irq_exit+0x160/0x16c
---[ end trace 5961f9fa5249019f ]---
Unable to handle kernel paging request at virtual address fffffff0
pgd = (ptrval)
[fffffff0] *pgd=5fece841, *pte=00000000, *ppte=00000000
Internal error: Oops: 27 [#1] PREEMPT SMP ARM
Modules linked in:
CPU: 0 PID: 1 Comm: swapper/0 Tainted: G W
4.20.0-rc5-next-20181203-00020-gf6d64d46ca8c #1156
Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
PC is at devm_gpiod_match+0x4/0x18
LR is at devres_remove+0x68/0xb8
...
Flags: NzCv IRQs off FIQs on Mode SVC_32 ISA ARM Segment none
Control: 10c5387d Table: 4000406a DAC: 00000051
Process swapper/0 (pid: 1, stack limit = 0x(ptrval))
Stack: (0xd94c1d58 to 0xd94c2000)
...
[<c04a6f1c>] (devm_gpiod_match) from [<c05854b8>] (devres_remove+0x68/0xb8)
[<c05854b8>] (devres_remove) from [<c0585cdc>] (devres_destroy+0x8/0x24)
[<c0585cdc>] (devres_destroy) from [<c04a74a4>]
(devm_gpiod_unhinge+0x1c/0x38)
[<c04a74a4>] (devm_gpiod_unhinge) from [<c04e5c94>]
(s2mps11_pmic_probe+0x1c4/0x49c)
[<c04e5c94>] (s2mps11_pmic_probe) from [<c0583e60>]
(platform_drv_probe+0x48/0x9c)
[<c0583e60>] (platform_drv_probe) from [<c0581858>]
(really_probe+0x274/0x400)
[<c0581858>] (really_probe) from [<c0581ba0>]
(driver_probe_device+0x78/0x1b8)
[<c0581ba0>] (driver_probe_device) from [<c0581e08>]
(__driver_attach+0x128/0x144)
[<c0581e08>] (__driver_attach) from [<c057f71c>]
(bus_for_each_dev+0x68/0xb4)
[<c057f71c>] (bus_for_each_dev) from [<c0580a1c>]
(bus_add_driver+0x1a8/0x268)
[<c0580a1c>] (bus_add_driver) from [<c0582e44>] (driver_register+0x78/0x10c)
[<c0582e44>] (driver_register) from [<c0103154>]
(do_one_initcall+0x8c/0x410)
[<c0103154>] (do_one_initcall) from [<c0f0124c>]
(kernel_init_freeable+0x3c8/0x4d0)
[<c0f0124c>] (kernel_init_freeable) from [<c0a6afd4>]
(kernel_init+0x8/0x10c)
[<c0a6afd4>] (kernel_init) from [<c01010b4>] (ret_from_fork+0x14/0x20)
Exception stack(0xd94c1fb0 to 0xd94c1ff8)
...
---[ end trace 5961f9fa524901a0 ]---
Other boards with other variants of s2mps11 or other PMICs works fine.
>
> Linus Walleij (13):
> regulator: core: Track dangling GPIO descriptors
> regulator: fixed: Let core handle GPIO descriptor
> regulator: lm363x: Let core handle GPIO descriptor
> regulator: lp8788-ldo: Let core handle GPIO descriptor
> regulator: max8952: Let core handle GPIO descriptor
> regulator: max8973: Let core handle GPIO descriptor
> gpio: Export gpiod_get_from_of_node()
> regulator: max77686: Let core handle GPIO descriptor
> gpio: Add devm_gpiod_unhinge()
> regulator: da9211: Hand over GPIO to regulator core
> regulator: s5m8767: Hand over GPIO to regulator core
> regulator: tps65090: Hand over GPIO to regulator core
> regulator: s2mps11: Hand over GPIO to regulator core
>
> Documentation/driver-model/devres.txt | 1 +
> drivers/gpio/gpiolib-devres.c | 17 ++++++++
> drivers/gpio/gpiolib.h | 6 ---
> drivers/regulator/core.c | 55 +++++++++++++++++++++-----
> drivers/regulator/da9211-regulator.c | 6 +++
> drivers/regulator/fixed.c | 6 ++-
> drivers/regulator/lm363x-regulator.c | 8 +++-
> drivers/regulator/lp8788-ldo.c | 8 +++-
> drivers/regulator/max77686-regulator.c | 14 ++++---
> drivers/regulator/max8952.c | 10 +++--
> drivers/regulator/max8973-regulator.c | 23 +++++++----
> drivers/regulator/s2mps11.c | 7 +++-
> drivers/regulator/s5m8767.c | 9 ++++-
> drivers/regulator/tps65090-regulator.c | 6 +++
> include/linux/gpio/consumer.h | 23 +++++++++++
> 15 files changed, 161 insertions(+), 38 deletions(-)
>
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
next prev parent reply other threads:[~2018-12-03 14:35 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20181201154428epcas4p3a1a5c9c576027b1c56f8dd1510b32187@epcas4p3.samsung.com>
2018-12-01 15:41 ` Linus Walleij
2018-12-01 15:41 ` [PATCH 01/13 v2] regulator: core: Track dangling GPIO descriptors Linus Walleij
2018-12-01 15:41 ` [PATCH 02/13 v2] regulator: fixed: Let core handle GPIO descriptor Linus Walleij
2018-12-01 15:41 ` [PATCH 03/13 v2] regulator: lm363x: " Linus Walleij
2018-12-01 15:41 ` [PATCH 04/13 v2] regulator: lp8788-ldo: " Linus Walleij
2018-12-01 15:41 ` [PATCH 05/13 v2] regulator: max8952: " Linus Walleij
2018-12-01 15:41 ` [PATCH 06/13 v2] regulator: max8973: " Linus Walleij
2018-12-05 13:08 ` Charles Keepax
2018-12-01 15:41 ` [PATCH 07/13 v2] gpio: Export gpiod_get_from_of_node() Linus Walleij
2018-12-01 15:41 ` [PATCH 08/13 v2] regulator: max77686: Let core handle GPIO descriptor Linus Walleij
2018-12-01 15:41 ` [PATCH 09/13 v2] gpio: Add devm_gpiod_unhinge() Linus Walleij
2018-12-02 17:02 ` Bartosz Golaszewski
2018-12-01 15:41 ` [PATCH 10/13 v2] regulator: da9211: Hand over GPIO to regulator core Linus Walleij
2018-12-01 15:41 ` [PATCH 11/13 v2] regulator: s5m8767: " Linus Walleij
2018-12-01 15:41 ` [PATCH 12/13 v2] regulator: tps65090: " Linus Walleij
2018-12-01 15:41 ` [PATCH 13/13 v2] regulator: s2mps11: " Linus Walleij
2018-12-03 14:35 ` Marek Szyprowski [this message]
2018-12-04 9:31 ` [PATCH 00/13 v2] Regulator ena_gpiod fixups Linus Walleij
2018-12-04 10:33 ` Marek Szyprowski
2018-12-04 12:44 ` Linus Walleij
2018-12-05 14:30 ` Marek Szyprowski
2018-12-05 14:32 ` Linus Walleij
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d6b5f384-51aa-0e99-7e88-a1debcf5eca3@samsung.com \
--to=m.szyprowski@samsung.com \
--cc=bgolaszewski@baylibre.com \
--cc=broonie@kernel.org \
--cc=ckeepax@opensource.cirrus.com \
--cc=lgirdwood@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®