All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Bultel <thierry.bultel@basystemes.fr>
To: Michael Haberler <haberlerm@gmail.com>
Cc: xenomai <xenomai@xenomai.org>
Subject: Re: [Xenomai] [PATCH 1/1] rtcan_flexcan: with open firmware, use devm_clk_put instead of clk_put
Date: Fri, 25 Sep 2015 19:19:16 +0200	[thread overview]
Message-ID: <56058214.8010703@basystemes.fr> (raw)
In-Reply-To: <110BEC51-53FC-40C6-9840-EEF64E7F1342@gmail.com>



Le 25/09/2015 18:16, Michael Haberler a écrit :
> Hi Thiery,
Hi Michael,
>
> could you give a bit of context about this patch?
>
> what problem does the patch resolve?

When the rtcan_flexcan driver is loaded as a module, the module 
unloading does not perform all the mandatory cleanup.

The symptom is that when loading the module again thereafter,
the kernel complains about the clocks:

root@CF_thierry:~>insmod /boot/xeno_can_flexcan.ko
root@CF_thierry:~>dmesg -c
[ 86.611247] ------------[ cut here ]------------
[ 86.611276] WARNING: CPU: 1 PID: 2805 at include/linux/kref.h:47 
__clk_get+0x80/0x90()
[ 86.611282] Modules linked in: xeno_can_flexcan(+) [last unloaded: 
xeno_can_flexcan]
[ 86.611304] CPU: 1 PID: 2805 Comm: insmod Not tainted 3.18.12_4.1.0 #2
[ 86.611338] [<80016550>] (unwind_backtrace) from [<80012194>] 
(show_stack+0x10/0x14)
[ 86.611362] [<80012194>] (show_stack) from [<806fba78>] 
(dump_stack+0x84/0xc4)
[ 86.611377] [<806fba78>] (dump_stack) from [<80022a90>] 
(warn_slowpath_common+0x74/0x90)
[ 86.611389] [<80022a90>] (warn_slowpath_common) from [<80022b48>] 
(warn_slowpath_null+0x1c/0x24)
[ 86.611402] [<80022b48>] (warn_slowpath_null) from [<80532750>] 
(__clk_get+0x80/0x90)
[ 86.611417] [<80532750>] (__clk_get) from [<8052f7cc>] 
(of_clk_get_by_clkspec+0x2c/0x48)
[ 86.611429] [<8052f7cc>] (of_clk_get_by_clkspec) from [<8052f820>] 
(of_clk_get.part.2+0x38/0x40)
[ 86.611441] [<8052f820>] (of_clk_get.part.2) from [<8052f8cc>] 
(of_clk_get_by_name+0x90/0xcc)
[ 86.611452] [<8052f8cc>] (of_clk_get_by_name) from [<8052f92c>] 
(clk_get+0x24/0x54)
[ 86.611464] [<8052f92c>] (clk_get) from [<8052f508>] 
(devm_clk_get+0x34/0x70)
[ 86.611485] [<8052f508>] (devm_clk_get) from [<7f007a20>] 
(flexcan_probe+0xcc/0x548 [xeno_can_flexcan])
[ 86.611511] [<7f007a20>] (flexcan_probe [xeno_can_flexcan]) from 
[<803e993c>] (platform_drv_probe+0x44/0xa4)
[ 86.611526] [<803e993c>] (platform_drv_probe) from [<803e7f80>] 
(driver_probe_device+0x108/0x23c)
[ 86.611538] [<803e7f80>] (driver_probe_device) from [<803e8184>] 
(__driver_attach+0x8c/0x90)
[ 86.611549] [<803e8184>] (__driver_attach) from [<803e6534>] 
(bus_for_each_dev+0x6c/0xa0)
[ 86.611560] [<803e6534>] (bus_for_each_dev) from [<803e77a8>] 
(bus_add_driver+0x14c/0x1f4)
[ 86.611571] [<803e77a8>] (bus_add_driver) from [<803e89e0>] 
(driver_register+0x78/0xf8)
[ 86.611582] [<803e89e0>] (driver_register) from [<80008cb0>] 
(do_one_initcall+0x8c/0x1c4)
[ 86.611596] [<80008cb0>] (do_one_initcall) from [<80085c34>] 
(load_module+0x17f4/0x2034)
[ 86.611607] [<80085c34>] (load_module) from [<800865cc>] 
(SyS_finit_module+0x68/0x78)
[ 86.611619] [<800865cc>] (SyS_finit_module) from [<8000ebe0>] 
(ret_fast_syscall+0x0/0x30)
[ 86.611627] ---[ end trace bf01e794993cef27 ]---

> what is 'open firmware'
right. I should probably reword my commit,
this not dependent of CONFIG_OF but just with the kernel
version. The bug happens with version >= KERNEL_VERSION(3,11,0)
FYI

> which kernel version did you apply this?
this is a 3.18.12
> which platform?
IMX6q SOC.

Thierry
>
> - Michael
>
>> Am 25.09.2015 um 15:22 schrieb Thierry Bultel <thierry.bultel@basystemes.fr>:
>>
>> Signed-off-by: Thierry Bultel <thierry.bultel@basystemes.fr>
>> ---
>> ksrc/drivers/can/rtcan_flexcan.c | 6 ++++--
>> 1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/ksrc/drivers/can/rtcan_flexcan.c b/ksrc/drivers/can/rtcan_flexcan.c
>> index f5477db..91c5ebf 100644
>> --- a/ksrc/drivers/can/rtcan_flexcan.c
>> +++ b/ksrc/drivers/can/rtcan_flexcan.c
>> @@ -235,6 +235,7 @@ struct flexcan_priv {
>> 	struct regulator *reg_xceiver;
>> 	struct clk *clk_ipg;
>> 	struct clk *clk_per;
>> +	struct platform_device *pdev;
>> #endif
>> };
>>
>> @@ -1054,8 +1055,8 @@ static void put_clocks(struct flexcan_priv *priv)
>> #if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
>> 	clk_put(priv->clk);
>> #else
>> -	clk_put(priv->clk_per);
>> -	clk_put(priv->clk_ipg);
>> +	devm_clk_put(&priv->pdev->dev,priv->clk_per);
>> +	devm_clk_put(&priv->pdev->dev,priv->clk_ipg);
>> #endif
>> }
>>
>> @@ -1132,6 +1133,7 @@ static int flexcan_probe(struct platform_device *pdev)
>> 		}
>> 		clock_freq = clk_get_rate(priv->clk_per);
>> 	}
>> +	priv->pdev = pdev;
>> #endif
>>
>> 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> --
>> 1.9.1
>>
>>
>> _______________________________________________
>> Xenomai mailing list
>> Xenomai@xenomai.org
>> http://xenomai.org/mailman/listinfo/xenomai
>


  reply	other threads:[~2015-09-25 17:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-25 13:22 [Xenomai] [PATCH 1/1] rtcan_flexcan: with open firmware, use devm_clk_put instead of clk_put Thierry Bultel
2015-09-25 16:16 ` Michael Haberler
2015-09-25 17:19   ` Thierry Bultel [this message]
2015-10-02 17:34 ` Gilles Chanteperdrix
2015-10-03 12:24   ` Thierry Bultel
2015-10-04 11:47     ` Gilles Chanteperdrix

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=56058214.8010703@basystemes.fr \
    --to=thierry.bultel@basystemes.fr \
    --cc=haberlerm@gmail.com \
    --cc=xenomai@xenomai.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.