From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Dario Binacchi <dariobin@libero.it>
Cc: linux-kernel@vger.kernel.org,
Federico Vaga <federico.vaga@gmail.com>,
Oliver Hartkopp <socketcan@hartkopp.net>,
Vincent Mailhol <mailhol.vincent@wanadoo.fr>,
YueHaibing <yuehaibing@huawei.com>,
Zhang Qilong <zhangqilong3@huawei.com>,
linux-can@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH v2 3/6] can: c_can: fix control interface used by c_can_do_tx
Date: Mon, 1 Mar 2021 12:36:12 +0100 [thread overview]
Message-ID: <20210301113612.rvbjnqacqstseokm@pengutronix.de> (raw)
In-Reply-To: <942251933.544595.1614508531322@mail1.libero.it>
[-- Attachment #1: Type: text/plain, Size: 1549 bytes --]
On 28.02.2021 11:35:31, Dario Binacchi wrote:
> > On 25.02.2021 22:51:52, Dario Binacchi wrote:
> > > According to commit 640916db2bf7 ("can: c_can: Make it SMP safe") let RX use
> > > IF1 (i.e. IF_RX) and TX use IF2 (i.e. IF_TX).
> >
> > Is this a fix?
> >
>
> I think that If I consider what is described in the 640916db2bf7
> commit, using the IF_RX interface in a tx routine is wrong.
Yes, IF_RX is used in c_can_do_tx(), but that's called from
c_can_poll(), which runs ins NAPI.
As far as I understand 640916db2bf7 ("can: c_can: Make it SMP safe")
fixes the race condition that c_can_poll() and c_can_start_xmit() both
access the same IF. See again the patch description:
| The hardware has two message control interfaces, but the code only uses the
| first one. So on SMP the following can be observed:
|
| CPU0 CPU1
| rx_poll()
| write IF1 xmit()
| write IF1
| write IF1
It's not 100% accurate, as the race condition is not just
c_can_do_rx_poll() against the c_can_start_xmit(), but the whole
c_can_poll() against c_can_start_xmit().
If you think my analysis is correct, please update the patch and add a
comment to clarify why IF_RX is used instead of changing it to IF_TX.
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 --]
next prev parent reply other threads:[~2021-03-01 11:37 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-25 21:51 [PATCH v2 0/6] can: c_can: add support to 64 message objects Dario Binacchi
2021-02-25 21:51 ` [PATCH v2 1/6] can: c_can: remove unused code Dario Binacchi
2021-02-25 21:51 ` [PATCH v2 2/6] can: c_can: fix indentation Dario Binacchi
2021-02-25 21:51 ` [PATCH v2 3/6] can: c_can: fix control interface used by c_can_do_tx Dario Binacchi
2021-02-26 8:44 ` Marc Kleine-Budde
2021-02-28 10:35 ` Dario Binacchi
2021-03-01 11:36 ` Marc Kleine-Budde [this message]
2021-03-01 17:38 ` Dario Binacchi
2021-02-25 21:51 ` [PATCH v2 4/6] can: c_can: use 32-bit write to set arbitration register Dario Binacchi
2021-02-25 21:51 ` [PATCH v2 5/6] can: c_can: prepare to up the message objects number Dario Binacchi
2021-02-26 8:33 ` Marc Kleine-Budde
2021-02-28 10:18 ` Dario Binacchi
2021-03-01 11:51 ` Marc Kleine-Budde
2021-02-26 9:21 ` Marc Kleine-Budde
2021-02-25 21:51 ` [PATCH v2 6/6] can: c_can: add support to 64 message objects Dario Binacchi
2021-02-26 8:43 ` 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=20210301113612.rvbjnqacqstseokm@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=dariobin@libero.it \
--cc=federico.vaga@gmail.com \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mailhol.vincent@wanadoo.fr \
--cc=netdev@vger.kernel.org \
--cc=socketcan@hartkopp.net \
--cc=yuehaibing@huawei.com \
--cc=zhangqilong3@huawei.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;
as well as URLs for NNTP newsgroup(s).