linux-amlogic.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Jon Hunter <jonathanh@nvidia.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Michael Turquette" <mturquette@baylibre.com>,
	"Stephen Boyd" <sboyd@kernel.org>,
	"Russell King" <linux@armlinux.org.uk>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Jean Delvare" <jdelvare@suse.com>,
	"Guenter Roeck" <linux@roeck-us.net>,
	"Lars Povlsen" <lars.povlsen@microchip.com>,
	"Steen Hegelund" <Steen.Hegelund@microchip.com>,
	UNGLinuxDriver@microchip.com, linux-hwmon@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	"Lars-Peter Clausen" <lars@metafoo.de>,
	"Michael Hennerich" <Michael.Hennerich@analog.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"Matt Mackall" <mpm@selenic.com>,
	"Herbert Xu" <herbert@gondor.apana.org.au>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Linus Walleij" <linus.walleij@linaro.org>,
	"Bartosz Golaszewski" <brgl@bgdev.pl>,
	"Neil Armstrong" <narmstrong@baylibre.com>,
	"David Airlie" <airlied@linux.ie>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	"Kevin Hilman" <khilman@baylibre.com>,
	"Jerome Brunet" <jbrunet@baylibre.com>,
	"Martin Blumenstingl" <martin.blumenstingl@googlemail.com>,
	"Paul Cercueil" <paul@crapouillou.net>,
	"Alessandro Zummo" <a.zummo@towertech.it>,
	"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	"Wim Van Sebroeck" <wim@linux-watchdog.org>,
	"Claudiu Beznea" <claudiu.beznea@microchip.com>,
	"Thierry Reding" <thierry.reding@gmail.com>,
	"Lee Jones" <lee.jones@linaro.org>,
	"Nicolas Ferre" <nicolas.ferre@microchip.com>,
	"Oleksij Rempel" <linux@rempel-privat.de>,
	"Shawn Guo" <shawnguo@kernel.org>,
	"Fabio Estevam" <festevam@gmail.com>,
	"NXP Linux Team" <linux-imx@nxp.com>,
	"Mark Brown" <broonie@kernel.org>,
	"Vinod Koul" <vkoul@kernel.org>
Cc: linux-clk@vger.kernel.org, kernel@pengutronix.de,
	"Vladimir Zapolskiy" <vz@mleia.com>,
	"Heiko Stuebner" <heiko@sntech.de>,
	"Tomislav Denis" <tomislav.denis@avl.com>,
	"Anand Ashok Dumbre" <anand.ashok.dumbre@xilinx.com>,
	"Michal Simek" <michal.simek@xilinx.com>,
	"André Gustavo Nakagomi Lopez" <andregnl@usp.br>,
	"Cai Huoqing" <caihuoqing@baidu.com>,
	linux-iio@vger.kernel.org, linux-crypto@vger.kernel.org,
	linux-amlogic@lists.infradead.org, linux-gpio@vger.kernel.org,
	dri-devel@lists.freedesktop.org, linux-mips@vger.kernel.org,
	linux-rtc@vger.kernel.org,
	"Keguang Zhang" <keguang.zhang@gmail.com>,
	"Andy Gross" <agross@kernel.org>,
	"Bjorn Andersson" <bjorn.andersson@linaro.org>,
	"Patrice Chotard" <patrice.chotard@foss.st.com>,
	"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
	"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
	"Nobuhiro Iwamatsu" <nobuhiro1.iwamatsu@toshiba.co.jp>,
	linux-watchdog@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-pwm@vger.kernel.org, linux-i2c@vger.kernel.org,
	linux-spi@vger.kernel.org,
	"Amireddy Mallikarjuna reddy"
	<mallikarjunax.reddy@linux.intel.com>,
	dmaengine@vger.kernel.org,
	"Jonathan Cameron" <Jonathan.Cameron@huawei.com>,
	"Alexandru Ardelean" <aardelean@deviqon.com>,
	"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>
Subject: Re: [PATCH v8 01/16] clk: generalize devm_clk_get() a bit
Date: Tue, 21 Jun 2022 20:57:00 +0100	[thread overview]
Message-ID: <d6b890c8-bfb5-cfa5-c6d8-ee245701c077@nvidia.com> (raw)
In-Reply-To: <20220314141643.22184-2-u.kleine-koenig@pengutronix.de>

Hi Uwe,

On 14/03/2022 14:16, Uwe Kleine-König wrote:
> Allow to add an exit hook to devm managed clocks. Also use
> clk_get_optional() in devm_clk_get_optional instead of open coding it.
> The generalisation will be used in the next commit to add some more
> devm_clk helpers.
> 
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Reviewed-by: Alexandru Ardelean <aardelean@deviqon.com>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>   drivers/clk/clk-devres.c | 67 ++++++++++++++++++++++++++++++----------
>   1 file changed, 50 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c
> index f9d5b7334341..fb7761888b30 100644
> --- a/drivers/clk/clk-devres.c
> +++ b/drivers/clk/clk-devres.c
> @@ -4,39 +4,72 @@
>   #include <linux/export.h>
>   #include <linux/gfp.h>
>   
> +struct devm_clk_state {
> +	struct clk *clk;
> +	void (*exit)(struct clk *clk);
> +};
> +
>   static void devm_clk_release(struct device *dev, void *res)
>   {
> -	clk_put(*(struct clk **)res);
> +	struct devm_clk_state *state = *(struct devm_clk_state **)res;
> +
> +	if (state->exit)
> +		state->exit(state->clk);
> +
> +	clk_put(state->clk);
>   }
>   
> -struct clk *devm_clk_get(struct device *dev, const char *id)
> +static struct clk *__devm_clk_get(struct device *dev, const char *id,
> +				  struct clk *(*get)(struct device *dev, const char *id),
> +				  int (*init)(struct clk *clk),
> +				  void (*exit)(struct clk *clk))
>   {
> -	struct clk **ptr, *clk;
> +	struct devm_clk_state *state;
> +	struct clk *clk;
> +	int ret;
>   
> -	ptr = devres_alloc(devm_clk_release, sizeof(*ptr), GFP_KERNEL);
> -	if (!ptr)
> +	state = devres_alloc(devm_clk_release, sizeof(*state), GFP_KERNEL);
> +	if (!state)
>   		return ERR_PTR(-ENOMEM);
>   
> -	clk = clk_get(dev, id);
> -	if (!IS_ERR(clk)) {
> -		*ptr = clk;
> -		devres_add(dev, ptr);
> -	} else {
> -		devres_free(ptr);
> +	clk = get(dev, id);
> +	if (IS_ERR(clk)) {
> +		ret = PTR_ERR(clk);
> +		goto err_clk_get;
>   	}
>   
> +	if (init) {
> +		ret = init(clk);
> +		if (ret)
> +			goto err_clk_init;
> +	}
> +
> +	state->clk = clk;
> +	state->exit = exit;
> +
> +	devres_add(dev, state);
> +
>   	return clk;
> +
> +err_clk_init:
> +
> +	clk_put(clk);
> +err_clk_get:
> +
> +	devres_free(state);
> +	return ERR_PTR(ret);
>   }
> -EXPORT_SYMBOL(devm_clk_get);
>   
> -struct clk *devm_clk_get_optional(struct device *dev, const char *id)
> +struct clk *devm_clk_get(struct device *dev, const char *id)
>   {
> -	struct clk *clk = devm_clk_get(dev, id);
> +	return __devm_clk_get(dev, id, clk_get, NULL, NULL);
>   
> -	if (clk == ERR_PTR(-ENOENT))
> -		return NULL;
> +}
> +EXPORT_SYMBOL(devm_clk_get);
>   
> -	return clk;
> +struct clk *devm_clk_get_optional(struct device *dev, const char *id)
> +{
> +	return __devm_clk_get(dev, id, clk_get_optional, NULL, NULL);
>   }
>   EXPORT_SYMBOL(devm_clk_get_optional);
>   


Some of our Tegra boards are not booting with the current -next and
bisect is pointing to this commit. Looking at the boot log I am
seeing the following panic ...

[    2.097048] 8<--- cut here ---
[    2.097053] Unable to handle kernel paging request at virtual address c216c810
[    2.097060] [c216c810] *pgd=0201141e(bad)
[    2.097079] Internal error: Oops: 8000000d [#1] SMP ARM
[    2.097088] Modules linked in:
[    2.097097] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.19.0-rc3-next-20220621-g34d1d36073ea #1
[    2.097107] Hardware name: NVIDIA Tegra SoC (Flattened Device Tree)
[    2.097113] PC is at 0xc216c810
[    2.097123] LR is at devm_clk_release+0x18/0x24
[    2.097150] pc : [<c216c810>]    lr : [<c088cb04>]    psr: a0000013
[    2.097155] sp : f080dde8  ip : 000006cf  fp : c18d4854
[    2.097161] r10: c1501850  r9 : c1a04d10  r8 : c1c4efa0
[    2.097166] r7 : c216c810  r6 : f080de1c  r5 : c2737680  r4 : c26a9680
[    2.097172] r3 : c216c810  r2 : 00000000  r1 : c2737840  r0 : c2082840
[    2.097179] Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
[    2.097187] Control: 10c5387d  Table: 0020404a  DAC: 00000051
[    2.097191] Register r0 information: slab kmalloc-192 start c2082840 pointer offset 0 size 192
[    2.097216] Register r1 information: slab kmalloc-128 start c2737800 pointer offset 64 size 128
[    2.097236] Register r2 information: NULL pointer
[    2.097244] Register r3 information: slab kmalloc-1k start c216c800 pointer offset 16 size 1024
[    2.097263] Register r4 information: slab kmalloc-64 start c26a9680 pointer offset 0 size 64
[    2.097282] Register r5 information: slab kmalloc-128 start c2737680 pointer offset 0 size 128
[    2.097301] Register r6 information: 2-page vmalloc region starting at 0xf080c000 allocated at kernel_clone+0xb4/0x3e8
[    2.097321] Register r7 information: slab kmalloc-1k start c216c800 pointer offset 16 size 1024
[    2.097341] Register r8 information: non-slab/vmalloc memory
[    2.097348] Register r9 information: non-slab/vmalloc memory
[    2.097355] Register r10 information: non-slab/vmalloc memory
[    2.097362] Register r11 information: non-slab/vmalloc memory
[    2.097369] Register r12 information: non-paged memory
[    2.097375] Process swapper/0 (pid: 1, stack limit = 0x(ptrval))
[    2.097384] Stack: (0xf080dde8 to 0xf080e000)
[    2.097394] dde0:                   c2737800 c0a72d38 c18d4854 c0530490 c216c810 f080de1c
[    2.097404] de00: c2120000 00000005 c216c9c0 80000013 0000017e c0a73d68 00000008 c2629e00
[    2.097413] de20: c2737880 5640e141 c216c810 c216c810 00000205 c1c09dd4 00000000 c27375b8
[    2.097422] de40: c2091700 c0a6e9a0 c216c810 c0a6f288 c216c810 c1c09dd4 c216c810 00000000
[    2.097430] de60: c27375b8 c0a6f3c0 c1caa8e0 c216c810 c216c810 c0a6f450 00000000 c216c810
[    2.097439] de80: c1c09dd4 c2120000 c27375b8 c0a6f850 00000000 c1c09dd4 c0a6f7c4 c0a6d4c0
[    2.097447] dea0: 00000000 c2091458 c2286434 5640e141 c1be7f08 c1c09dd4 c2737580 c1be7f08
[    2.097455] dec0: 00000000 c0a6e484 c1615714 c1be7c50 c1c09dd4 c2120000 c189a99c 00000000
[    2.097464] dee0: c2120000 c0a701a0 c1c494e0 c2120000 c189a99c c0302144 0000017d c0364438
[    2.097472] df00: c16da8bc c1626700 00000000 00000006 00000006 c16554c8 00000000 c2120000
[    2.097480] df20: c15105bc c14f9778 c2091700 c20917d9 00000000 5640e141 c1a88930 c16da8bc
[    2.097488] df40: c1c59000 5640e141 c16da8bc c1c59000 c1953b4c c18d4834 00000007 c1801340
[    2.097497] df60: 00000006 00000006 00000000 c18004dc c2120000 c18004dc f080df74 c1a04cc0
[    2.097505] df80: c106bbf0 00000000 00000000 00000000 00000000 00000000 00000000 c106bc08
[    2.097513] dfa0: 00000000 c106bbf0 00000000 c03001a8 00000000 00000000 00000000 00000000
[    2.097520] dfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    2.097528] dfe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000
[    2.097542]  devm_clk_release from release_nodes+0x58/0xc0
[    2.097575]  release_nodes from devres_release_all+0x7c/0xc0
[    2.097596]  devres_release_all from device_unbind_cleanup+0xc/0x60
[    2.097626]  device_unbind_cleanup from really_probe+0x1f4/0x2a8
[    2.097650]  really_probe from __driver_probe_device+0x84/0xe4
[    2.097673]  __driver_probe_device from driver_probe_device+0x30/0xd0
[    2.097696]  driver_probe_device from __driver_attach+0x8c/0xf0
[    2.097713]  __driver_attach from bus_for_each_dev+0x70/0xb0
[    2.097729]  bus_for_each_dev from bus_add_driver+0x168/0x1f4
[    2.097749]  bus_add_driver from driver_register+0x7c/0x118
[    2.097766]  driver_register from do_one_initcall+0x44/0x1ec
[    2.097784]  do_one_initcall from kernel_init_freeable+0x1d4/0x224
[    2.097803]  kernel_init_freeable from kernel_init+0x18/0x12c
[    2.097820]  kernel_init from ret_from_fork+0x14/0x2c
[    2.097831] Exception stack(0xf080dfb0 to 0xf080dff8)
[    2.097839] dfa0:                                     00000000 00000000 00000000 00000000
[    2.097847] dfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    2.097854] dfe0: 00000000 00000000 00000000 00000000 00000013 00000000
[    2.097862] Code: c2288680 ffffffff 00000000 00000000 (c2288680)
[    2.097872] ---[ end trace 0000000000000000 ]---


Let me know if you have any thoughts.

Cheers
Jon

-- 
nvpublic

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

  reply	other threads:[~2022-06-21 19:57 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-14 14:16 [PATCH v8 00/16] clk: provide new devm helpers for prepared and enabled clocks Uwe Kleine-König
2022-03-14 14:16 ` [PATCH v8 01/16] clk: generalize devm_clk_get() a bit Uwe Kleine-König
2022-06-21 19:57   ` Jon Hunter [this message]
2022-06-21 20:49     ` Uwe Kleine-König
2022-06-22 10:36       ` Andy Shevchenko
2022-06-22 11:14         ` Neil Armstrong
2022-06-22 15:28       ` Jon Hunter
2022-03-14 14:16 ` [PATCH v8 02/16] clk: Provide new devm_clk helpers for prepared and enabled clocks Uwe Kleine-König
2022-03-19 18:29   ` Jonathan Cameron
2022-03-21  7:22     ` Uwe Kleine-König
2022-03-14 14:16 ` [PATCH v8 03/16] hwmon: Make use of devm_clk_get_enabled() Uwe Kleine-König
2022-03-15 23:26   ` Guenter Roeck
2022-03-14 14:16 ` [PATCH v8 05/16] hwrng: meson - Don't open-code devm_clk_get_optional_enabled() Uwe Kleine-König
2022-03-16  8:32   ` Neil Armstrong
2022-03-14 14:16 ` [PATCH v8 08/16] drm/meson: dw-hdmi: Don't open code devm_clk_get_enabled() Uwe Kleine-König
2022-03-16  8:33   ` Neil Armstrong
2022-03-14 14:16 ` [PATCH v8 10/16] clk: meson: axg-audio: Don't duplicate devm_clk_get_enabled() Uwe Kleine-König
2022-03-14 14:16 ` [PATCH v8 11/16] watchdog: Make use of devm_clk_get_enabled() Uwe Kleine-König
2022-03-16  1:29   ` Guenter Roeck
2022-03-15 18:03 ` [PATCH v8 00/16] clk: provide new devm helpers for prepared and enabled clocks Andy Shevchenko

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=d6b890c8-bfb5-cfa5-c6d8-ee245701c077@nvidia.com \
    --to=jonathanh@nvidia.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=Steen.Hegelund@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=a.zummo@towertech.it \
    --cc=aardelean@deviqon.com \
    --cc=agross@kernel.org \
    --cc=airlied@linux.ie \
    --cc=alexandre.belloni@bootlin.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=anand.ashok.dumbre@xilinx.com \
    --cc=andregnl@usp.br \
    --cc=bjorn.andersson@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=broonie@kernel.org \
    --cc=caihuoqing@baidu.com \
    --cc=claudiu.beznea@microchip.com \
    --cc=daniel@ffwll.ch \
    --cc=dmaengine@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=festevam@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heiko@sntech.de \
    --cc=herbert@gondor.apana.org.au \
    --cc=jbrunet@baylibre.com \
    --cc=jdelvare@suse.com \
    --cc=jic23@kernel.org \
    --cc=keguang.zhang@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=khilman@baylibre.com \
    --cc=lars.povlsen@microchip.com \
    --cc=lars@metafoo.de \
    --cc=lee.jones@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=linux-tegra@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=linux@rempel-privat.de \
    --cc=linux@roeck-us.net \
    --cc=mallikarjunax.reddy@linux.intel.com \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=michal.simek@xilinx.com \
    --cc=mpm@selenic.com \
    --cc=mturquette@baylibre.com \
    --cc=narmstrong@baylibre.com \
    --cc=nicolas.ferre@microchip.com \
    --cc=nobuhiro1.iwamatsu@toshiba.co.jp \
    --cc=nuno.sa@analog.com \
    --cc=patrice.chotard@foss.st.com \
    --cc=paul@crapouillou.net \
    --cc=sboyd@kernel.org \
    --cc=shawnguo@kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=tomislav.denis@avl.com \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=vkoul@kernel.org \
    --cc=vz@mleia.com \
    --cc=wim@linux-watchdog.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;
as well as URLs for NNTP newsgroup(s).