Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1100932imu; Tue, 20 Nov 2018 11:42:13 -0800 (PST) X-Google-Smtp-Source: AJdET5d88lDlAaaY5G7aNrvIIPtYgUBe2DcSsM9h55E2pd/LXsx8FfZat6hbvLCUWSjCmOkoheM5 X-Received: by 2002:a62:9712:: with SMTP id n18-v6mr3517855pfe.69.1542742933388; Tue, 20 Nov 2018 11:42:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542742933; cv=none; d=google.com; s=arc-20160816; b=oSS9Zc46UeEbCrPSi0/AvC1iUvUaO8dszmoTcokPvorOf0c+9YWku0rUrLmifNiqbV Pb+r2rmhMz4o0Lb4bFMZ/e+FvZbZIqxmhdXLBneVorzAr0exzfWoE1Ag5ZT9ckM+JrTY M5B2aw8/AaSnyfMoOu9cBdolAlsZm3Bh3xyl1+MU7HyrsJSPMxreeZIyEBunjVwwRvEl eRW80gCt4CpzLntmMteEUFMWwaOt9Rdl37xBh7eseslWsnmlnYS6AHQUSkhmNk/ZJ//R ihOPe3ckutr9PIXjzxvXhgPdYOx3NRy6nPPWkbW96D5UhlidzBa1zApd7ouD2kK7xJqO aRXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:cc:to:subject:dkim-signature:dkim-filter; bh=OK3+KtbLau+jKjMd/mxEwuw63ufehGU+XV+pENUVG1s=; b=uiqgjftTsyr3pY/7hPeV4HrLDFBGSrXCo9uPinU4ZBImaGK2m2OWnhFAHbM32JCfSD Q6oWyuAfYNkf+yG09ISWG0jRUJwEjxhatDU+kFizf+RmY7nq/yogh930InftJxAHcYOo BPLrxIvUX/zrOMB8sZj0UvSWJzlUuffrO+ZaDp0Oz5FhX8MDDCfUc7xvgH9i7s9JNMiD cFMevE2GPwdWEMmruwc8V2tyEWB9Ob/3RJKY4hHsIBiQkPRQFyF1VT9uTBromb0PGqca cDoLO5e4345xgG4KNYteFrmondHkxpt6Kzkme2cLBmRJZ3eUEAfTiN1bLRDjhiLMVQ33 SeaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="oHsJqEL/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si47408172plh.96.2018.11.20.11.41.58; Tue, 20 Nov 2018 11:42:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="oHsJqEL/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1728473AbeKUDz7 (ORCPT + 99 others); Tue, 20 Nov 2018 22:55:59 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:57455 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726314AbeKUDz7 (ORCPT ); Tue, 20 Nov 2018 22:55:59 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20181120172542euoutp0128d496b8b59deff437141afdc758fdec~o5RMWznPC1727417274euoutp01M for ; Tue, 20 Nov 2018 17:25:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20181120172542euoutp0128d496b8b59deff437141afdc758fdec~o5RMWznPC1727417274euoutp01M DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1542734742; bh=OK3+KtbLau+jKjMd/mxEwuw63ufehGU+XV+pENUVG1s=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=oHsJqEL/wDopymtYrRcqjbcFv1Ek2J8hEoB7pB/UIm+0oUaCwN2YtNReLEddn9rru kozfyP8M86twRYM2mS+sbC0nsfrPRno0vnJ01TovJCchD7d5jWCXSGoLW+jNQzt+wy VcgHckMtNWiIUP/KBVNs7J0wdu8fo59+oZtmhMCU= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181120172541eucas1p2153bd44cb4735ced8bb3b7f289dbb152~o5RLKX_1B1183511835eucas1p2p; Tue, 20 Nov 2018 17:25:41 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 95.08.04806.49344FB5; Tue, 20 Nov 2018 17:25:40 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20181120172540eucas1p29bb48c51d2f0d10cd0ad3a1b889534cf~o5RKBQYR40512305123eucas1p2l; Tue, 20 Nov 2018 17:25:40 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20181120172539eusmtrp2c3d88cd2513b588535636b5241023ac5~o5RJyLOol3179831798eusmtrp2e; Tue, 20 Nov 2018 17:25:39 +0000 (GMT) X-AuditID: cbfec7f5-367ff700000012c6-dd-5bf44394c916 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id C9.D7.04128.39344FB5; Tue, 20 Nov 2018 17:25:39 +0000 (GMT) Received: from [106.116.147.30] (unknown [106.116.147.30]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20181120172539eusmtip20e2d1731b8d8c03492bba6717eefa9ce~o5RJbtD5F0300703007eusmtip2X; Tue, 20 Nov 2018 17:25:39 +0000 (GMT) Subject: Re: [PATCH] regulator: wm8994: Don't use devres for enable GPIOs To: Charles Keepax , broonie@kernel.org Cc: linus.walleij@linaro.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, patches@opensource.cirrus.com From: Marek Szyprowski Message-ID: Date: Tue, 20 Nov 2018 18:25:38 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 In-Reply-To: <20181120170152.24652-1-ckeepax@opensource.cirrus.com> Content-Transfer-Encoding: 8bit Content-Language: en-US X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrCKsWRmVeSWpSXmKPExsWy7djPc7pTnL9EG0ybZWYx9eETNosrrZsY Lb5d6WCymPJnOZPF5V1z2Cw+v9/P6sDmsXPWXXaPTas62TzuXNvD5jF9zn9Gj8+b5AJYo7hs UlJzMstSi/TtErgyTvR8ZCn4YVCx/O9E1gbGO5pdjBwcEgImEmvnxHYxcnIICaxglFi5M7mL kQvI/sIosfrRE3YI5zOjxLIPP9lAqkAajjx9BpVYzihx5v8TZgjnPaPE0yXXGUGqhAU8JW5s Owhmiwi4Sby+v4YZxGYWKJD41vsEzGYTMJToetvFBnIGr4CdxMRGMZAwi4CqxMa/u5hAbFGB GIljK2+AjeEVEJQ4OfMJC4jNKeAssf3kVaiR8hLNW2dD2eISt57MZwK5R0JgFbvE4t+b2SGu dpHo7fvBBGELS7w6vgUqLiPxfydMQzOjRPuMWewQTg+jxNY5O6B+tpY4fPwiK8ilzAKaEut3 6UOEHSVuzdvCCAlHPokbbwUhjuCTmLRtOjNEmFeio00IolpNYtbxdXBrD164xDyBUWkWktdm IXlnFpJ3ZiHsXcDIsopRPLW0ODc9tdg4L7Vcrzgxt7g0L10vO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+f 7DJP26xW0ZUbxb3Y/3l3q0Wl0YJ1H/jLP2/kL7Px+33vz/I5yypyp/tM3JEUf23fWX0Z48hn SxukPcMe7F9xIrDh7uSpZvtPLNxXd7Rom8ihV7+Or05clTpDPv31KXfPZAMlluKMREMt5qLi RADegF7pywIAAA== X-CMS-MailID: 20181120172540eucas1p29bb48c51d2f0d10cd0ad3a1b889534cf X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20181120170248epcas1p2a93ec9ff7f74ad4908166590ed548386 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181120170248epcas1p2a93ec9ff7f74ad4908166590ed548386 References: <20181120170152.24652-1-ckeepax@opensource.cirrus.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Charles, On 2018-11-20 18:01, Charles Keepax wrote: > We need to manage the life time of the enable GPIO against the regulator > device but the OF node lives on the parent MFD device. As such we can't > use the devm functions which assume the same device will be used for > both. > > Reported-by: Marek Szyprowski > Signed-off-by: Charles Keepax > --- > > This patch is only build tested so it would be good to get a > tested by from Marek before applying. Sadly it looks that it is not enough. The issue is still there: wm8994 4-001a: Failed to get supply 'DBVDD1': -517 wm8994 4-001a: Failed to get supplies: -517 ------------[ cut here ]------------ WARNING: CPU: 0 PID: 1 at drivers/gpio/gpiolib.c:2421 regulator_ena_gpio_free+0x70/0xa0 Modules linked in: CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.20.0-rc3-next-20181120-00001-g330f37c7fb0c #5090 Hardware name: SAMSUNG EXYNOS (Flattened Device Tree) [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [] (show_stack) from [] (dump_stack+0x90/0xc8) [] (dump_stack) from [] (__warn+0xf8/0x124) [] (__warn) from [] (warn_slowpath_null+0x40/0x48) [] (warn_slowpath_null) from [] (regulator_ena_gpio_free+0x70/0xa0) [] (regulator_ena_gpio_free) from [] (regulator_unregister+0x134/0x17c) [] (regulator_unregister) from [] (release_nodes+0x164/0x1dc) [] (release_nodes) from [] (device_release_driver_internal+0x18c/0x21c) [] (device_release_driver_internal) from [] (bus_remove_device+0xdc/0x12c) [] (bus_remove_device) from [] (device_del+0x108/0x2e0) [] (device_del) from [] (platform_device_del+0x20/0x8c) [] (platform_device_del) from [] (platform_device_unregister+0xc/0x18) [] (platform_device_unregister) from [] (mfd_remove_devices_fn+0x58/0x64) [] (mfd_remove_devices_fn) from [] (device_for_each_child_reverse+0x34/0x74) [] (device_for_each_child_reverse) from [] (mfd_remove_devices+0x20/0x30) [] (mfd_remove_devices) from [] (wm8994_i2c_probe+0x2dc/0x8d0) [] (wm8994_i2c_probe) from [] (i2c_device_probe+0x234/0x2b0) [] (i2c_device_probe) from [] (really_probe+0x224/0x3f4) [] (really_probe) from [] (driver_probe_device+0x70/0x1c4) [] (driver_probe_device) from [] (__driver_attach+0x120/0x144) [] (__driver_attach) from [] (bus_for_each_dev+0x58/0x7c) [] (bus_for_each_dev) from [] (bus_add_driver+0x174/0x250) [] (bus_add_driver) from [] (driver_register+0x7c/0x110) [] (driver_register) from [] (i2c_register_driver+0x38/0xa8) [] (i2c_register_driver) from [] (do_one_initcall+0x80/0x408) [] (do_one_initcall) from [] (kernel_init_freeable+0x3a0/0x4fc) [] (kernel_init_freeable) from [] (kernel_init+0x8/0x118) [] (kernel_init) from [] (ret_from_fork+0x14/0x20) Exception stack(0xef0e3fb0 to 0xef0e3ff8) 3fa0:                                     00000000 00000000 00000000 00000000 3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 3fe0: 00000000 00000000 00000000 00000000 00000013 00000000 irq event stamp: 176913 hardirqs last  enabled at (176921): [] console_unlock+0x460/0x6ec hardirqs last disabled at (176940): [] console_unlock+0xb8/0x6ec softirqs last  enabled at (176956): [] __do_softirq+0x3a4/0x66c softirqs last disabled at (176967): [] irq_exit+0x140/0x168 I will check more tomorrow. > Thanks, > Charles > > drivers/regulator/wm8994-regulator.c | 28 +++++++++++++++++++++++----- > 1 file changed, 23 insertions(+), 5 deletions(-) > > diff --git a/drivers/regulator/wm8994-regulator.c b/drivers/regulator/wm8994-regulator.c > index d7fec533c403..f2592c30d0ca 100644 > --- a/drivers/regulator/wm8994-regulator.c > +++ b/drivers/regulator/wm8994-regulator.c > @@ -31,6 +31,7 @@ struct wm8994_ldo { > struct wm8994 *wm8994; > struct regulator_consumer_supply supply; > struct regulator_init_data init_data; > + struct gpio_desc *ena_gpiod; > }; > > #define WM8994_LDO1_MAX_SELECTOR 0x7 > @@ -147,14 +148,19 @@ static int wm8994_ldo_probe(struct platform_device *pdev) > config.regmap = wm8994->regmap; > config.init_data = &ldo->init_data; > > - /* Look up LDO enable GPIO from the parent device node */ > - gpiod = devm_gpiod_get_optional(pdev->dev.parent, > - id ? "wlf,ldo2ena" : "wlf,ldo1ena", > - GPIOD_OUT_LOW | > - GPIOD_FLAGS_BIT_NONEXCLUSIVE); > + /* > + * Look up LDO enable GPIO from the parent device node, we can't > + * use devm because it assumes the device we want to allocate > + * against is the same one that holds the OF node > + */ > + gpiod = gpiod_get_optional(pdev->dev.parent, > + id ? "wlf,ldo2ena" : "wlf,ldo1ena", > + GPIOD_OUT_LOW | > + GPIOD_FLAGS_BIT_NONEXCLUSIVE); > if (IS_ERR(gpiod)) > return PTR_ERR(gpiod); > config.ena_gpiod = gpiod; > + ldo->ena_gpiod = gpiod; > > /* Use default constraints if none set up */ > if (!pdata || !pdata->ldo[id].init_data || wm8994->dev->of_node) { > @@ -184,11 +190,23 @@ static int wm8994_ldo_probe(struct platform_device *pdev) > return 0; > > err: > + gpiod_put(gpiod); > return ret; > } > > +static int wm8994_ldo_remove(struct platform_device *pdev) > +{ > + struct wm8994_ldo *ldo = platform_get_drvdata(pdev); > + > + if (ldo->ena_gpiod) > + gpiod_put(ldo->ena_gpiod); > + > + return 0; > +} > + > static struct platform_driver wm8994_ldo_driver = { > .probe = wm8994_ldo_probe, > + .remove = wm8994_ldo_remove, > .driver = { > .name = "wm8994-ldo", > }, Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland