linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Alexander Stein <alexander.stein@systec-electronic.com>
Cc: David Jander <david@protonic.nl>,
	Wolfgang Grandegger <wg@grandegger.com>,
	linux-can@vger.kernel.org
Subject: Re: [PATCH v5] can: flexcan: Re-write receive path to use MB queue instead of FIFO
Date: Wed, 08 Oct 2014 12:43:40 +0200	[thread overview]
Message-ID: <5435155C.6030709@pengutronix.de> (raw)
In-Reply-To: <1544714.FueVS1KdZh@ws-stein>

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

On 10/08/2014 12:36 PM, Alexander Stein wrote:
[...]
>>> In this piece of code, suppose that fifo->next is in the upper half and a
>>> message is being written to the MB it is pointing at, but it is still not
>>> pending. The lower half has already been enabled and filled up completely (due
>>> to latency). In that case, fifo-next will jump back to fifo->low_first and
>>> leave a lonely filled MB in the middle of the upper half, that will trigger
>>> and infinite loop between IRQ and can_rx_fifo_poll(). The interrupt will never
>>> get cleared again.
>>> I know this is an extreme case of latency being so high as to fill more than
>>> the complete lower half, but if it strikes, it results in a lock-up. Am I
>>> right, or did I screw up somewhere?
>>
>> Correct analysis :( At least it shows it makes sense to have this code
>> in a central place.....
> 
> I didn't reviewed that piece of code, I just read David's
> description. Well, I actually saw this scenario on pch_can where the
> rx mailboxes are split in lower and upper half. The current upper MB
> was empty and rx_poll left handling MBs and freed the lower MB.
> Meanwhile a frame was about beeing inserted in the current upper MB.
> Upon next interrupt reception started on lower MBs until eventually
> the remained frame in upper MB was read. But at this time the order
> is messed up. There was no lockup, because the interrupt signaling
> worked a bit different.
> 
>> If we handle the low_first mailbox, we might have to check if the "old"
>> next, or better, if any of the mailboxes >= old_next are pending *and*
>> there is a non pending mailbox < "old" next. This should be possible
>> with one or two clever bitmasks.
> 
> If we detect that (all) MBs before the old one are pending again, we
> even can't ensure proper CAN frame order. All MBs below and even

ACK, this is why I suggested the "non pending MB in front of old next"
check.

> after old_next coul have been written meanwhile. That's why I hate
> those MB interfaces and prefer a real FIFO.

If you have a FIFO, which is big enough....(for no various definitions
of big enough) of course a FIFO is preferred.

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: 181 bytes --]

  reply	other threads:[~2014-10-08 10:43 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-29 12:52 [PATCH v5] can: flexcan: Re-write receive path to use MB queue instead of FIFO David Jander
2014-09-29 13:29 ` Alexander Stein
2014-09-29 14:39   ` David Jander
2014-09-29 15:02     ` Alexander Stein
2014-09-30  7:13       ` David Jander
2014-09-30  7:43         ` Alexander Stein
2014-10-01  6:29           ` David Jander
2014-10-01  7:11             ` Alexander Stein
2014-10-01  7:15               ` Marc Kleine-Budde
2014-10-01  8:29                 ` Alexander Stein
2014-10-01  9:07                   ` David Jander
2014-10-01  9:19                     ` Alexander Stein
2014-10-01  9:34                       ` David Jander
2014-10-01  9:58                         ` Marc Kleine-Budde
2014-10-06  7:28                           ` David Jander
2014-10-06 10:00                             ` Marc Kleine-Budde
2014-10-06 11:17                               ` David Jander
2014-10-07  9:30                                 ` [RFC PATCH 1/2] can: rx-fifo: Increase MB size limit from 32 to 64 David Jander
2014-10-07  9:30                                   ` [RFC PATCH 2/2] can: rx-fifo: Add support for IRQ readout and NAPI poll David Jander
2014-10-07 13:17                                   ` [RFC PATCH 1/2] can: rx-fifo: Increase MB size limit from 32 to 64 Marc Kleine-Budde
2014-10-07 13:27                                     ` David Jander
2014-10-07 14:18                                       ` Marc Kleine-Budde
2014-10-08  9:08                               ` [PATCH v5] can: flexcan: Re-write receive path to use MB queue instead of FIFO David Jander
2014-10-08  9:56                                 ` Marc Kleine-Budde
2014-10-08 10:36                                   ` Alexander Stein
2014-10-08 10:43                                     ` Marc Kleine-Budde [this message]
2014-10-08 14:01                                   ` David Jander
2014-10-09 10:37                                     ` David Jander
2014-10-01  9:19               ` David Jander

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=5435155C.6030709@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=alexander.stein@systec-electronic.com \
    --cc=david@protonic.nl \
    --cc=linux-can@vger.kernel.org \
    --cc=wg@grandegger.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).