linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: David Jander <david@protonic.nl>
Cc: linux-can@vger.kernel.org
Subject: Re: [PATCH v4 4/5] can: flexcan: put TX mailbox into TX_INACTIVE mode after tx-complete
Date: Tue, 16 Sep 2014 17:28:46 +0200	[thread overview]
Message-ID: <5418572E.2090304@pengutronix.de> (raw)
In-Reply-To: <20140916171848.7aca14ed@archvile>

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

On 09/16/2014 05:18 PM, David Jander wrote:
> On Tue, 16 Sep 2014 16:20:33 +0200
> Marc Kleine-Budde <mkl@pengutronix.de> wrote:
> 
>> After sending a RTR frame the TX mailbox becomes a RX_EMPTY mailbox. To avoid
>> side effects when the RX-FIFO is full, this patch puts the TX mailbox into
>> TX_INACTIVE mode after the transmission has been completed.
>>
>> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
>> ---
>>
>> Changes since v3:
>> - new
>>
>>  drivers/net/can/flexcan.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
>> index 54061c4..c17ae9e 100644
>> --- a/drivers/net/can/flexcan.c
>> +++ b/drivers/net/can/flexcan.c
>> @@ -765,6 +765,9 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id)
>>  		stats->tx_bytes += can_get_echo_skb(dev, 0);
>>  		stats->tx_packets++;
>>  		can_led_event(dev, CAN_LED_EVENT_TX);
>> +		/* after sending a RTR frame mailbox is in RX mode */
>> +		flexcan_write(FLEXCAN_MB_CODE_TX_INACTIVE,
>> +			      &regs->cantxfg[FLEXCAN_TX_BUF_ID].can_ctrl);
>>  		flexcan_write((1 << FLEXCAN_TX_BUF_ID), &regs->iflag1);
>>  		netif_wake_queue(dev);
>>  	}
> 
> Good one. I hadn't notice that case yet.

Just stumbled over it, the reference manual is a bit vague, it this
mailbox will receive any CAN frame or just a CAN frame with the same ID.

> Since you do this in the IRQ, I assume the expected race-condition window is
> minimal, but AFAICS there is stil a (very) small chance of a race if an

Yes, there's a race window.

> overflow message arrives before this code in the IRQ handler is reached.
> Both chance of occurring and impact is so small that it will not likely be a
> problem ever... besides the fact that it cannot be avoided. Should this be
> mentioned?

Good point, I'll add a comment to the code.

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-09-16 15:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-16 14:20 [PATCH v4 1/5] can: flexcan: mark TX mailbox as TX_INACTIVE Marc Kleine-Budde
2014-09-16 14:20 ` [PATCH v4 2/5] can: flexcan: correctly initialize mailboxes Marc Kleine-Budde
2014-09-16 14:20 ` [PATCH v4 3/5] can: flexcan: implement workaround for errata ERR005829 Marc Kleine-Budde
2014-09-16 14:20 ` [PATCH v4 4/5] can: flexcan: put TX mailbox into TX_INACTIVE mode after tx-complete Marc Kleine-Budde
2014-09-16 15:18   ` David Jander
2014-09-16 15:28     ` Marc Kleine-Budde [this message]
2014-09-16 14:20 ` [PATCH v4 5/5] can: flexcan: increase FLEXCAN_MCR_MAXMB() macro to 7 bits 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=5418572E.2090304@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=david@protonic.nl \
    --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 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).