All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Ashutosh Singh <ashuleapyear@gmail.com>
Cc: "linux-can@vger.kernel.org" <linux-can@vger.kernel.org>
Subject: Re: facing some problem with flexcan driver
Date: Wed, 15 May 2013 11:30:42 +0200	[thread overview]
Message-ID: <519355C2.2050502@pengutronix.de> (raw)
In-Reply-To: <CALUo3F9Zmx-rOCOmBone6b-nu3G_0bfOjL1Npp=ku=2fBHpTJw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4251 bytes --]

Hello Ashu,

please use the linux-can mailing list (Cc'ed).

On 05/10/2013 04:31 PM, Ashutosh Singh wrote:
> I trying to use this driver for freescale vybrid processor VF600.
> 
> I just modify the below structure
> 
> static struct platform_device_id flexcan_devtype[] = {
>         {
>                 .name = "imx25-flexcan",
>                 .driver_data = FLEXCAN_VER_3_0_0,
>         }, {
>                 .name = "imx28-flexcan",
>                 .driver_data = FLEXCAN_VER_3_0_4,
>         }, {
>                 .name = "imx35-flexcan",
>                 .driver_data = FLEXCAN_VER_3_0_0,
>         }, {
>                 .name = "imx53-flexcan",
>                 .driver_data = FLEXCAN_VER_3_0_0,
>         }, {
>                 .name = "imx6q-flexcan",
>                 .driver_data = FLEXCAN_VER_10_0_12,
>         }, {
>                 .name = "mvf-flexcan",
>                 .driver_data = FLEXCAN_VER_10_0_12,
>         },
> 
> };

Tip: use "git diff" to illustrate your changes.

[...]

> # canconfig can0 bitrate 50000 ctrlmode triple-sampling on
> 
> Unhandled fault: external abort on non-linefetch (0x1008) at 0x9087801c
> Internal error: : 1008 [#1]
> Modules linked in:
> CPU: 0    Not tainted  (3.0.15-ts-armv7l-gf141ea3-dirty #18)
> PC is at flexcan_get_berr_counter+0xc/0x38
> LR is at can_fill_info+0xf0/0x150
> pc : [<8025c6f4>]    lr : [<80258454>]    psr: a0000013
> sp : 8f961b80  ip : 00000018  fp : 00000000
> r10: 8f9995b4  r9 : 805f48f0  r8 : 8f99958c
> r7 : 805ca7b0  r6 : 8f961ba0  r5 : 8f86e180  r4 : 8f961ba4
> r3 : 90878000  r2 : 00000000  r1 : 8f961ba4  r0 : 8fe22800
> Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
> Control: 10c53c7d  Table: 8f97c059  DAC: 00000015
> Process canconfig (pid: 806, stack limit = 0x8f9602e8)
> Stack: (0x8f961b80 to 0x8f962000)

[...]

> [<8025c6f4>] (flexcan_get_berr_counter+0xc/0x38) from [<80258454>]
> (can_fill_info+0xf0/0x150)
> [<80258454>] (can_fill_info+0xf0/0x150) from [<802e8710>]
> (rtnl_fill_ifinfo+0x5b0/0x76c)

This means the driver is in the flexcan_get_berr_counter() [1] function
when the oops happens. The driver accesses the hardware to read the ecr
register (offset 0x1c) [2].

Please check if the flexcan in the vybrid still has the ecr register at
offset 0x1c. The next thing might be, that in this flexcan design the
clock gating has improved and access to the ecr register is only valid
if the clock(s) is/are switched on. Please check if this patch (totally
untested) helps:

-------->8-------->8-------->8-------->8-------->8-------->8-------->8--------
commit 28c17d5a382912ee66ed5476616b3d64d425a3e0
Author: Marc Kleine-Budde <mkl@pengutronix.de>
Date:   Wed May 15 11:28:38 2013 +0200

    net: can: flexcan: switch on clocks before accessing ecr register

    Reported-by: Ashutosh Singh <ashuleapyear@gmail.com>
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 4a40a18..71983c8 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -302,7 +302,13 @@ static int flexcan_get_berr_counter(const struct
net_device *dev,
 {
        const struct flexcan_priv *priv = netdev_priv(dev);
        struct flexcan_regs __iomem *regs = priv->base;
-       u32 reg = flexcan_read(&regs->ecr);
+       u32 reg;
+
+       clk_prepare_enable(priv->clk_ipg);
+       clk_prepare_enable(priv->clk_per);
+       reg = flexcan_read(&regs->ecr);
+       clk_disable_unprepare(priv->clk_per);
+       clk_disable_unprepare(priv->clk_ipg);

        bec->txerr = (reg >> 0) & 0xff;
        bec->rxerr = (reg >> 8) & 0xff;

-------->8-------->8-------->8-------->8-------->8-------->8-------->8--------

[1] http://lxr.free-electrons.com/source/drivers/net/can/flexcan.c#L300
[2] http://lxr.free-electrons.com/source/drivers/net/can/flexcan.c#L305

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]

       reply	other threads:[~2013-05-15  9:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CALUo3F9Zmx-rOCOmBone6b-nu3G_0bfOjL1Npp=ku=2fBHpTJw@mail.gmail.com>
2013-05-15  9:30 ` Marc Kleine-Budde [this message]
2013-05-21  6:56   ` facing some problem with flexcan driver Marc Kleine-Budde

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=519355C2.2050502@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=ashuleapyear@gmail.com \
    --cc=linux-can@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 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.