public inbox for linux-can@vger.kernel.org
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Torin Cooper-Bennun <torin@maxiluxsystems.com>
Cc: linux-rpi-kernel@lists.infradead.org, linux-can@vger.kernel.org
Subject: Re: can, tcan4x5x: look to merge rpi support into rpi kernel tree
Date: Mon, 15 Feb 2021 18:44:08 +0100	[thread overview]
Message-ID: <20210215174408.eea3okssfzjsqrly@hardanger.blackshift.org> (raw)
In-Reply-To: <CAALJrqgrmzGHZX+iiMYwMkVMpxtf_3fWYkVA-iMdPOxpGzrCRQ@mail.gmail.com>

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

I've added the linux-can mailing list on Cc.

On 15.02.2021 15:41:57, Torin Cooper-Bennun wrote:
> On Mon, 15 Feb 2021 at 14:45, Marc Kleine-Budde <mkl@pengutronix.de> wrote:
> > Sadly, the driver is still not in good shape...I think it will explode
> > as soon as you receive a CAN frame on the rpi, as the frames are passed
> > into the networking stack from the wrong context...
> >
> > Maybe I'll find some time to get receive properly working.
> 
> I'm afraid I've just found that myself -- in fact, I'm having problems
> getting TX to behave as well. I think the chip configuration is
> incorrect (at the very least, the chip is never put into standby mode,
> which the datasheet says is paramount!)

Do you have the wake-gpio in your DT? This one works for me:

|         tcan4x5x: tcan4x5x@1 {
|                 reg = <1>;
|                 compatible = "ti,tcan4x5x";
|                 vsup-supply = <&reg_tcan4x5x_vsup>;
|                 pinctrl-names = "default";
|                 pinctrl-0 = <&pinctrl_tcan4x5x>;
|                 spi-max-frequency = <10000000>;
|                 bosch,mram-cfg = <0x0 0 0 16 0 0 1 1>;
|                 interrupt-parent = <&gpio4>;
|                 interrupts = <31 IRQ_TYPE_LEVEL_LOW>;
|                 clock-names = "cclk";
|                 clocks = <&tcan4x5x_osc>;
|                 device-wake-gpios = <&gpio5 5 GPIO_ACTIVE_HIGH>;
|         };

> The current config procedure
> ends up with bizarre activity on the CAN lines. I also observed
> intermittent refcount warnings during driver use.

You mean something like these...

| [  543.116807] WARNING: CPU: 0 PID: 11 at lib/refcount.c:25 refcount_warn_saturate+0x108/0x174
| [  543.116820] refcount_t: addition on 0; use-after-free.

with can_put_echo_skb() in the call stack?

| [  543.117745] [<bf186edc>] (can_put_echo_skb [can_dev]) from [<bf1d67ec>] (mcp251xfd_start_xmit+0x2b0/0x3bc [mcp251xfd])

We tried to fix the problem, but the patch made the problem more
visible. Working on this.

> I've cherry-picked the relevant changes onto RPi kernel 5.10 :
> https://github.com/tcbennun/linux/commit/c32a0d422b551390f6960243f29e1afacfe30d48
> and I'll be next trying the bleeding-edge driver with 5.11.
> 
> > BTW: what kind of hardware are you using?
> 
> This is a Raspberry Pi 3 Model B v1.2, hosting a TCAN4550 on spi0. The
> external oscillator for the TCAN4550 is 20 MHz.

Is that a custom tcan pi hat, or is it officially sold somewhere?

> Since you've confirmed it needs work, I'll probably be able to put
> some time into it myself.

First thing I'd do is to rewrite the RX function and IRQ handler for the
"peripheral", that's the code path used for the SPI attached m-can
core. TX doesn't look efficient, but it should work at least.

regards,
Marc

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

       reply	other threads:[~2021-02-15 17:45 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <602651f9.1c69fb81.302a5.647d@mx.google.com>
     [not found] ` <20210215144509.rhds7oybzat6u27w@hardanger.blackshift.org>
     [not found]   ` <CAALJrqgrmzGHZX+iiMYwMkVMpxtf_3fWYkVA-iMdPOxpGzrCRQ@mail.gmail.com>
2021-02-15 17:44     ` Marc Kleine-Budde [this message]
2021-02-16  9:06       ` can, tcan4x5x: look to merge rpi support into rpi kernel tree Torin Cooper-Bennun
2021-02-16  9:13         ` Marc Kleine-Budde
2021-02-16  9:44           ` Torin Cooper-Bennun
2021-02-16 10:28             ` Marc Kleine-Budde
     [not found]               ` <CAALJrqiVdmLQr7q2ijbWq70RD6PTD8PtVX_zmLW9=uNdc57WqA@mail.gmail.com>
2021-02-16 11:19                 ` Marc Kleine-Budde
2021-02-16 11:38                   ` Torin Cooper-Bennun
2021-02-16 12:32                     ` Marc Kleine-Budde
2021-02-26 12:27                       ` Torin Cooper-Bennun
2021-02-26 12:28                         ` Marc Kleine-Budde
2021-02-26 12:18   ` Torin Cooper-Bennun
2021-02-26 12:22     ` Marc Kleine-Budde
2021-02-26 12:31       ` Torin Cooper-Bennun
2021-02-26 12:40         ` Marc Kleine-Budde
2021-02-26 13:26           ` Torin Cooper-Bennun
2021-02-26 13:39             ` Marc Kleine-Budde
2021-02-26 13:45               ` Torin Cooper-Bennun
2021-02-26 14:00                 ` Marc Kleine-Budde
2021-02-26 15:26                   ` Torin Cooper-Bennun
2021-02-26 16:01                     ` Marc Kleine-Budde
2021-02-26 16:14                       ` Torin Cooper-Bennun

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=20210215174408.eea3okssfzjsqrly@hardanger.blackshift.org \
    --to=mkl@pengutronix.de \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=torin@maxiluxsystems.com \
    /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