linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeroen Hofstee <jhofstee@victronenergy.com>
To: Marc Kleine-Budde <mkl@pengutronix.de>,
	"linux-can@vger.kernel.org" <linux-can@vger.kernel.org>
Cc: Anant Gole <anantgole@ti.com>, AnilKumar Ch <anilkumar@ti.com>,
	Wolfgang Grandegger <wg@grandegger.com>,
	"David S. Miller" <davem@davemloft.net>,
	"open list:NETWORKING DRIVERS" <netdev@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] can: ti_hecc: use timestamp based rx-offloading
Date: Fri, 26 Jul 2019 20:10:47 +0000	[thread overview]
Message-ID: <c52cda86-8889-63a7-ce10-e1d10444f6d2@victronenergy.com> (raw)
In-Reply-To: <04bdda38-79fa-c266-2a3c-1229a1fd8229@pengutronix.de>

Hello Marc,

On 7/26/19 1:48 PM, Marc Kleine-Budde wrote:
> On 4/29/19 2:03 PM, Jeroen Hofstee wrote:
>
>> @@ -744,8 +652,8 @@ static irqreturn_t ti_hecc_interrupt(int irq, void *dev_id)
>>   	struct net_device *ndev = (struct net_device *)dev_id;
>>   	struct ti_hecc_priv *priv = netdev_priv(ndev);
>>   	struct net_device_stats *stats = &ndev->stats;
>> -	u32 mbxno, mbx_mask, int_status, err_status;
>> -	unsigned long ack, flags;
>> +	u32 mbxno, mbx_mask, int_status, err_status, stamp;
>> +	unsigned long flags, rx_pending;
>>   
>>   	int_status = hecc_read(priv,
>>   		(priv->use_hecc1int) ? HECC_CANGIF1 : HECC_CANGIF0);
>> @@ -769,11 +677,11 @@ static irqreturn_t ti_hecc_interrupt(int irq, void *dev_id)
>>   			spin_lock_irqsave(&priv->mbx_lock, flags);
>>   			hecc_clear_bit(priv, HECC_CANME, mbx_mask);
>>   			spin_unlock_irqrestore(&priv->mbx_lock, flags);
>> -			stats->tx_bytes += hecc_read_mbx(priv, mbxno,
>> -						HECC_CANMCF) & 0xF;
>> +			stamp = hecc_read_stamp(priv, mbxno);
>> +			stats->tx_bytes += can_rx_offload_get_echo_skb(&priv->offload,
>> +									mbxno, stamp);
>>   			stats->tx_packets++;
>>   			can_led_event(ndev, CAN_LED_EVENT_TX);
>> -			can_get_echo_skb(ndev, mbxno);
>>   			--priv->tx_tail;
>>   		}
>>   
>> @@ -784,12 +692,11 @@ static irqreturn_t ti_hecc_interrupt(int irq, void *dev_id)
>>   		((priv->tx_head & HECC_TX_MASK) == HECC_TX_MASK)))
>>   			netif_wake_queue(ndev);
>>   
>> -		/* Disable RX mailbox interrupts and let NAPI reenable them */
>> -		if (hecc_read(priv, HECC_CANRMP)) {
>> -			ack = hecc_read(priv, HECC_CANMIM);
>> -			ack &= BIT(HECC_MAX_TX_MBOX) - 1;
>> -			hecc_write(priv, HECC_CANMIM, ack);
>> -			napi_schedule(&priv->napi);
>> +		/* offload RX mailboxes and let NAPI deliver them */
>> +		while ((rx_pending = hecc_read(priv, HECC_CANRMP))) {
>> +			can_rx_offload_irq_offload_timestamp(&priv->offload,
>> +							     rx_pending);
>> +			hecc_write(priv, HECC_CANRMP, rx_pending);
> Can prepare a patch to move the RMP writing into the mailbox_read()
> function. This makes the mailbox available a bit earlier and works
> better for memory pressure situations, where no skb can be allocated.


For my understanding, is there any other reason for alloc_can_skb,
to fail, besides being out of memory. I couldn't easily find an other
limit enforced on it.

If it is actually _moved_, as you suggested, it does loose the ability to
handle the newly received messages while the messages are read
in the same interrupt, so it needs to interrupt again. That will work,
but seems a bit a silly thing to do.

Perhaps we can do both? Mark the mailbox as available in
mailbox_read, so it is available as soon as possible and clear
them all in the irq (under the assumption that alloc_can_skb
failure means real big trouble, why would we want to keep the
old messages around and eventually ignore the new messages?).

Another question, not related to this patch, but this driver..
Most of the times the irq handles 1 or sometimes 2 messages.
Do you happen to know if it is possible to optionally delay the irq
a bit in the millisecond range, so more work can be done in a single
interrupt? Since there are now 28 rx hardware mailboxes available,
it shouldn't run out easily.

And as last, I guess you want a patch which applies to
linux-can-next/testing, right?

With kind regards,

Jeroen



      reply	other threads:[~2019-07-26 20:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-29 12:03 [PATCH] can: ti_hecc: use timestamp based rx-offloading Jeroen Hofstee
2019-07-24  8:26 ` Marc Kleine-Budde
2019-07-24  9:13   ` Jeroen Hofstee
2019-07-24 19:56 ` Saeed Mahameed
2019-07-26 11:48 ` Marc Kleine-Budde
2019-07-26 20:10   ` Jeroen Hofstee [this message]

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=c52cda86-8889-63a7-ce10-e1d10444f6d2@victronenergy.com \
    --to=jhofstee@victronenergy.com \
    --cc=anantgole@ti.com \
    --cc=anilkumar@ti.com \
    --cc=davem@davemloft.net \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=netdev@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).