Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp466514imm; Mon, 9 Jul 2018 05:15:49 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd4506Lxme1bKLElW2f8BkYtD/DkredR8W/VNri1oeGhAxQhUVc+eGd1wqw8x0O01W5VaSm X-Received: by 2002:a63:81c3:: with SMTP id t186-v6mr12713745pgd.413.1531138548950; Mon, 09 Jul 2018 05:15:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531138548; cv=none; d=google.com; s=arc-20160816; b=Gpy6lOQA+O0ukHxvXgcFRsjykhPEFUuy8KwW51hzUsMEWXeN00cJhphHbYlRTqYQ6E oHn3malH23sWTDKF4fz4Idai7Ybcx+C6TMpUkiVsPmhuRMbjYm335i3G6aGCtxq4OuAn geGyzf8kWthvD9ys12oSTXdf3wugv6xVUN7jZqxfZLJ+aE7sZSXwIcvKWjnQavbWti5Y b5b5NqBYgNU4I2YDIJVLo8HvpGjIuNxgXGiPOSss8ErC3xiWCxcZPl/3rxsRL4lZPfP6 KRD67PbWmJvksdTqVGn1YOep4zUedIOkackG8GY7PjEWbpFI1e37rYvCCTkDU320hLg6 /rJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:arc-authentication-results; bh=vp01Dn7IkA+rRCW9mdGDqGDjNK0TNscm9zcD3y07lFI=; b=m/NtFhu78bCtPvKWEd2PaHucgaGh1MFj4KtNRI/enu2bkhEe2VHOr0VGvtm4qp2oOI VauaChp4mgYHcaaFxeBqew3RjTFw7nEUUczl9C0T9Hl4/zDfxBgnm33DluenbUi2Eh37 u5yEl3HtRm/7tZf7CuHA1Yf02Xkd6YzNIrRUCbfPVd/P/tBp1s5RpSb2tijJHlrPc/H/ im1LROJ09wptRp+G23JaIMOPqGYEJ0OvUmNSn9ZYWdoc3VPtHXmVVeGHrYSoV3CeGO11 GUEQqJYi4imJY4J8KkH0GYxePgTGTijRc6T6IcUiqgP0Yzj338c/oqPqIzr1ywi1o53s O8hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="U/gQSb9i"; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 189-v6si15162569pfg.163.2018.07.09.05.15.10; Mon, 09 Jul 2018 05:15:48 -0700 (PDT) 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=@linaro.org header.s=google header.b="U/gQSb9i"; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932666AbeGIMNi (ORCPT + 99 others); Mon, 9 Jul 2018 08:13:38 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:36993 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932567AbeGIMNg (ORCPT ); Mon, 9 Jul 2018 08:13:36 -0400 Received: by mail-oi0-f65.google.com with SMTP id k81-v6so35414153oib.4 for ; Mon, 09 Jul 2018 05:13:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=vp01Dn7IkA+rRCW9mdGDqGDjNK0TNscm9zcD3y07lFI=; b=U/gQSb9iO1fN0fZKJnBj1vLPldpAg/7M66fgebKstnX5tOfTqVvJOP/fOFu6pt+LHV XRj2ebyk4RZWzTBLXH1KIsBUHRt6rTW7HIw7VbgosaSFnNZC72GoOEiEuQO+RSyzQeVR LA+mJ6AHAsEdm6JiFJFAM7uZ5FVqaZh4ideHA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=vp01Dn7IkA+rRCW9mdGDqGDjNK0TNscm9zcD3y07lFI=; b=oQqo6GOofHOb0BLDEeS0mUpZnCkh6EGCwDJhhPh43vXRUxYTAAa9OlrynS2ugpwNjx cbP5QbQQuca9qmdRPWlWJtM2dlce/osNdWH7cph+TTSUjGaKUukZZ4emZ9NZ+E7GfucV EN/LYPqbc7q6+4MTw1A89l7KfIqUHt+Z5ToGczzPK1qHfQIyNaDJZOO7oc6EVL0EvENq 5jxq5Q+cp8zAHsYJkLTL2SRtGKaz8zkKjZU3huIP6nfkoHz0g3/dnxH5BbfeS82YvAbr p61V3+huoBQPfngpqo3YYtsMHvmDBMJ5CkAAkl6xUTk+PBZIBqVsyvAAy5Q/1QPwfNhP LnVA== X-Gm-Message-State: APt69E3kPkxa9cfrxAwCo/ifTC3py1wU4Jefb6QrOavicvVLqwkBXRFB XdYxDiTCkZ1N+Ac6K3HAWdQs3mtAV+/azdBXukacIA== X-Received: by 2002:aca:b954:: with SMTP id j81-v6mr24731113oif.356.1531138416141; Mon, 09 Jul 2018 05:13:36 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:192d:0:0:0:0:0 with HTTP; Mon, 9 Jul 2018 05:13:35 -0700 (PDT) In-Reply-To: <20180709111753eucas1p1f32e66fb2f7ea3216097cd72a132355d~-rzycA5Rg0378203782eucas1p1C@eucas1p1.samsung.com> References: <20180709111753eucas1p1f32e66fb2f7ea3216097cd72a132355d~-rzycA5Rg0378203782eucas1p1C@eucas1p1.samsung.com> From: Benjamin Gaignard Date: Mon, 9 Jul 2018 14:13:35 +0200 Message-ID: Subject: Re: Applied "regulator: core: Link consumer with regulator driver" to the regulator tree To: Marek Szyprowski Cc: Mark Brown , pascal paillet , "gregkh@linuxfoundation.org" , "lgirdwood@gmail.com" , "linux-kernel@vger.kernel.org" , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz , rafael.j.wysocki@intel.co Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org + Rafael 2018-07-09 13:17 GMT+02:00 Marek Szyprowski : > Dear All, > > On 2018-07-05 19:55, Mark Brown wrote: >> The patch >> >> regulator: core: Link consumer with regulator driver >> >> has been applied to the regulator tree at >> >> https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.gi= t >> >> 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 >> >> >From ed1ae2dd9f242c7a36e8e39100f6a7f6bcdfdd89 Mon Sep 17 00:00:00 2001 >> From: pascal paillet >> Date: Thu, 5 Jul 2018 14:25:56 +0000 >> Subject: [PATCH] regulator: core: Link consumer with regulator driver >> >> Add a device link between the consumer and the driver so that >> the consumer is not suspended before the driver. The goal is to avoid >> implementing suspend_late ops in regulator drivers. >> >> Signed-off-by: pascal paillet >> Signed-off-by: Mark Brown > > This patch triggers the following warning on several Exynos SoC based > boards: > > ------------[ cut here ]------------ > WARNING: CPU: 1 PID: 1 at drivers/base/core.c:108 > device_is_dependent+0xa4/0xb4 > Modules linked in: > CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.18.0-rc3-next-20180706 #112 > Hardware name: SAMSUNG EXYNOS (Flattened Device Tree) > [] (unwind_backtrace) from [] (show_stack+0x10/0x14) > [] (show_stack) from [] (dump_stack+0x98/0xc4) > [] (dump_stack) from [] (__warn+0x10c/0x124) > [] (__warn) from [] (warn_slowpath_null+0x40/0x48) > [] (warn_slowpath_null) from [] > (device_is_dependent+0xa4/0xb4) > [] (device_is_dependent) from [] > (device_for_each_child+0x50/0x94) > [] (device_for_each_child) from [] > (device_is_dependent+0x20/0xb4) > [] (device_is_dependent) from [] > (device_link_add+0x70/0x2a8) > [] (device_link_add) from [] (_regulator_get+0xbc/0x2= 70) > [] (_regulator_get) from [] > (regulator_bulk_get+0x60/0xcc) > [] (regulator_bulk_get) from [] > (wm8994_i2c_probe+0x334/0x8ec) > [] (wm8994_i2c_probe) from [] > (i2c_device_probe+0x240/0x2b8) > [] (i2c_device_probe) from [] > (driver_probe_device+0x2dc/0x4ac) > [] (driver_probe_device) from [] > (__driver_attach+0x128/0x144) > [] (__driver_attach) from [] > (bus_for_each_dev+0x68/0xb4) > [] (bus_for_each_dev) from [] > (bus_add_driver+0x1a8/0x268) > [] (bus_add_driver) from [] (driver_register+0x78/0x1= 0c) > [] (driver_register) from [] > (i2c_register_driver+0x3c/0xa8) > [] (i2c_register_driver) from [] > (do_one_initcall+0x8c/0x4b0) > [] (do_one_initcall) from [] > (kernel_init_freeable+0x3e4/0x570) > [] (kernel_init_freeable) from [] > (kernel_init+0x8/0x10c) > [] (kernel_init) from [] (ret_from_fork+0x14/0x20) > Exception stack(0xee8c9fb0 to 0xee8c9ff8) > ... > ---[ end trace 4ed89cca1d70ea82 ]--- > > The above stack comes from Exynos5250 Arndale board > (arch/arm/boot/dts/exynos5250-arndale.dts), where wm8994 codec tries to g= et > regulator, which is provided by its parent mfd device. Similar issue can = be > observed on Exynos4412-based Trats2 and Exynos5433 TM2(e) boards. > > It looks that some more checks have to be done before adding a link betwe= en > regulator consumer and regulator driver, because it is not that uncommon > that > regulator consumer shares the parent device with regulator provider. > Each time device_is_dependent() will return 1 we have a warn_on. It is strange since returning 1 is well documented on function description. I don't know if we can safely remove the warn_on or if their is a good reason to keep it. Rafael what do you think about that ? >> --- >> drivers/regulator/core.c | 18 ++++++++++++++++-- >> 1 file changed, 16 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c >> index da9b0fed8330..bb1324f93143 100644 >> --- a/drivers/regulator/core.c >> +++ b/drivers/regulator/core.c >> @@ -1740,6 +1740,8 @@ struct regulator *_regulator_get(struct device *de= v, const char *id, >> rdev->use_count =3D 0; >> } >> >> + device_link_add(dev, &rdev->dev, DL_FLAG_STATELESS); >> + >> return regulator; >> } >> >> @@ -1829,9 +1831,21 @@ static void _regulator_put(struct regulator *regu= lator) >> >> debugfs_remove_recursive(regulator->debugfs); >> >> - /* remove any sysfs entries */ >> - if (regulator->dev) >> + if (regulator->dev) { >> + int count =3D 0; >> + struct regulator *r; >> + >> + list_for_each_entry(r, &rdev->consumer_list, list) >> + if (r->dev =3D=3D regulator->dev) >> + count++; >> + >> + if (count =3D=3D 1) >> + device_link_remove(regulator->dev, &rdev->dev); >> + >> + /* remove any sysfs entries */ >> sysfs_remove_link(&rdev->dev.kobj, regulator->supply_name)= ; >> + } >> + >> regulator_lock(rdev); >> list_del(®ulator->list); >> > > Best regards > -- > Marek Szyprowski, PhD > Samsung R&D Institute Poland > --=20 Benjamin Gaignard Graphic Study Group Linaro.org =E2=94=82 Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog