All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Markus Schneider-Pargmann <msp@baylibre.com>
Cc: Chandrasekar Ramakrishnan <rcsekar@samsung.com>,
	Wolfgang Grandegger <wg@grandegger.com>,
	linux-can@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 04/15] can: m_can: Use transmit event FIFO watermark level interrupt
Date: Thu, 1 Dec 2022 12:00:33 +0100	[thread overview]
Message-ID: <20221201110033.r7hnvpw6fp2fquni@pengutronix.de> (raw)
In-Reply-To: <20221201101220.r63fvussavailwh5@blmsp>

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

On 01.12.2022 11:12:20, Markus Schneider-Pargmann wrote:
> > > For the upcoming receive side patch I already added a hrtimer. I may try
> > > to use the same timer for both directions as it is going to do the exact
> > > same thing in both cases (call the interrupt routine). Of course that
> > > depends on the details of the coalescing support. Any objections on
> > > that?
> > 
> > For the mcp251xfd I implemented the RX and TX coalescing independent of
> > each other and made it configurable via ethtool's IRQ coalescing
> > options.
> > 
> > The hardware doesn't support any timeouts and only FIFO not empty, FIFO
> > half full and FIFO full IRQs and the on chip RAM for mailboxes is rather
> > limited. I think the mcan core has the same limitations.
> 
> Yes and no, the mcan core provides watermark levels so it has more
> options, but there is no hardware timer as well (at least I didn't see
> anything usable).

Are there any limitations to the water mark level?

> > The configuration for the mcp251xfd looks like this:
> > 
> > - First decide for classical CAN or CAN-FD mode
> > - configure RX and TX ring size
> >   9263c2e92be9 ("can: mcp251xfd: ring: add support for runtime configurable RX/TX ring parameters")
> >   For TX only a single FIFO is used.
> >   For RX up to 3 FIFOs (up to a depth of 32 each).
> >   FIFO depth is limited to power of 2.
> >   On the mcan cores this is currently done with a DT property.
> >   Runtime configurable ring size is optional but gives more flexibility
> >   for our use-cases due to limited RAM size.
> > - configure RX and TX coalescing via ethtools
> >   Set a timeout and the max CAN frames to coalesce.
> >   The max frames are limited to half or full FIFO.
> 
> mcan can offer more options for the max frames limit fortunately.
> 
> > 
> > How does coalescing work?
> > 
> > If coalescing is activated during reading of the RX'ed frames the FIFO
> > not empty IRQ is disabled (the half or full IRQ stays enabled). After
> > handling the RX'ed frames a hrtimer is started. In the hrtimer's
> > functions the FIFO not empty IRQ is enabled again.
> 
> My rx path patches are working similarly though not 100% the same. I
> will adopt everything and add it to the next version of this series.
> 
> > 
> > I decided not to call the IRQ handler from the hrtimer to avoid
> > concurrency, but enable the FIFO not empty IRQ.
> 
> mcan uses a threaded irq and I found this nice helper function I am
> currently using for the receive path.
> 	irq_wake_thread()
> 
> It is not widely used so I hope this is fine. But this hopefully avoids
> the concurrency issue. Also I don't need to artificially create an IRQ
> as you do.

I think it's Ok to use the function. Which IRQs are enabled after you
leave the RX handler? The mcp251xfd driver enables only a high watermark
IRQ and sets up the hrtimer. Then we have 3 scenarios:
- high watermark IRQ triggers -> IRQ is handled,
- FIFO level between 0 and high water mark -> no IRQ triggered, but
  hrtimer will run, irq_wake_thread() is called, IRQ is handled
- FIFO level 0 -> no IRQ triggered, hrtimer will run. What do you do in
  the IRQ handler? Check if FIFO is empty and enable the FIFO not empty
  IRQ?

The mcp251xfd unconditionally enables the FIFO not empty IRQ in the
hrtimer. This avoids reading of the FIFO fill level.

[...]

> > If you want to implement runtime configurable ring size, I created a
> > function to help in the calculation of the ring sizes:
> > 
> > a1439a5add62 ("can: mcp251xfd: ram: add helper function for runtime ring size calculation")
> > 
> > The code is part of the mcp251xfd driver, but is prepared to become a
> > generic helper function. The HW parameters are described with struct
> > can_ram_config and use you can_ram_get_layout() to get a valid RAM
> > layout based on CAN/CAN-FD ring size and coalescing parameters.
> 
> Thank you. I think configurable ring sizes are currently out of scope
> for me as I only have limited time for this.

Ok.

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:[~2022-12-01 11:01 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-16 20:52 [PATCH 00/15] can: m_can: Optimizations for tcan and peripheral chips Markus Schneider-Pargmann
2022-11-16 20:52 ` [PATCH 01/15] can: m_can: Eliminate double read of TXFQS in tx_handler Markus Schneider-Pargmann
2022-11-16 20:52 ` [PATCH 02/15] can: m_can: Wakeup net queue once tx was issued Markus Schneider-Pargmann
2022-11-30 17:21   ` Marc Kleine-Budde
2022-12-01  8:43     ` Markus Schneider-Pargmann
2022-12-01  9:16       ` Marc Kleine-Budde
2022-12-01 16:49         ` Markus Schneider-Pargmann
2022-12-02  9:16           ` Marc Kleine-Budde
2022-12-14  9:14     ` Markus Schneider-Pargmann
2022-12-14  9:18       ` Marc Kleine-Budde
2022-12-14  9:22         ` Marc Kleine-Budde
2022-12-14 10:15           ` Vincent MAILHOL
2022-12-14 10:35             ` Markus Schneider-Pargmann
2022-12-15  9:31               ` Markus Schneider-Pargmann
2022-12-16  4:40                 ` Vincent MAILHOL
2022-12-14 10:18           ` Markus Schneider-Pargmann
2022-12-02 13:53   ` Marc Kleine-Budde
2022-11-16 20:52 ` [PATCH 03/15] can: m_can: Cache tx putidx and transmits in flight Markus Schneider-Pargmann
2022-12-01 11:14   ` Marc Kleine-Budde
2022-12-02  8:37     ` Markus Schneider-Pargmann
2022-12-02 14:46       ` Marc Kleine-Budde
2022-12-13 17:13         ` Markus Schneider-Pargmann
2022-12-13 19:17           ` Marc Kleine-Budde
2022-12-14  8:32             ` Markus Schneider-Pargmann
2022-11-16 20:52 ` [PATCH 04/15] can: m_can: Use transmit event FIFO watermark level interrupt Markus Schneider-Pargmann
2022-11-30 17:17   ` Marc Kleine-Budde
2022-12-01  8:25     ` Markus Schneider-Pargmann
2022-12-01  9:05       ` Marc Kleine-Budde
2022-12-01 10:12         ` Markus Schneider-Pargmann
2022-12-01 11:00           ` Marc Kleine-Budde [this message]
2022-12-01 16:59             ` Markus Schneider-Pargmann
2022-12-02  9:23               ` Marc Kleine-Budde
2022-12-02  9:43                 ` Markus Schneider-Pargmann
2022-12-02 14:03                   ` Marc Kleine-Budde
2022-12-13 17:19               ` Markus Schneider-Pargmann
2022-12-13 19:18                 ` Marc Kleine-Budde
2022-11-16 20:52 ` [PATCH 05/15] can: m_can: Disable unused interrupts Markus Schneider-Pargmann
2022-11-16 20:52 ` [PATCH 06/15] can: m_can: Avoid reading irqstatus twice Markus Schneider-Pargmann
2022-11-16 20:53 ` [PATCH 07/15] can: m_can: Read register PSR only on error Markus Schneider-Pargmann
2022-11-16 20:53 ` [PATCH 08/15] can: m_can: Count TXE FIFO getidx in the driver Markus Schneider-Pargmann
2022-11-16 20:53 ` [PATCH 09/15] can: m_can: Count read getindex " Markus Schneider-Pargmann
2022-11-16 20:53 ` [PATCH 10/15] can: m_can: Batch acknowledge rx fifo Markus Schneider-Pargmann
2022-11-16 20:53 ` [PATCH 11/15] can: m_can: Batch acknowledge transmit events Markus Schneider-Pargmann
2022-11-16 20:53 ` [PATCH 12/15] can: tcan4x5x: Remove invalid write in clear_interrupts Markus Schneider-Pargmann
2022-12-02 14:17   ` Marc Kleine-Budde
2022-11-16 20:53 ` [PATCH 13/15] can: tcan4x5x: Fix use of register error status mask Markus Schneider-Pargmann
2022-12-02 14:19   ` Marc Kleine-Budde
2022-11-16 20:53 ` [PATCH 14/15] can: tcan4x5x: Fix register range of first block Markus Schneider-Pargmann
2022-12-02 14:28   ` Marc Kleine-Budde
2022-12-05  9:30     ` Markus Schneider-Pargmann
2022-12-05  9:44       ` Marc Kleine-Budde
2022-12-05  9:55         ` Markus Schneider-Pargmann
2022-11-16 20:53 ` [PATCH 15/15] can: tcan4x5x: Specify separate read/write ranges Markus Schneider-Pargmann
2022-12-02 14:03 ` [PATCH 00/15] can: m_can: Optimizations for tcan and peripheral chips Marc Kleine-Budde
2022-12-05  9:09   ` Markus Schneider-Pargmann

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=20221201110033.r7hnvpw6fp2fquni@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=msp@baylibre.com \
    --cc=netdev@vger.kernel.org \
    --cc=rcsekar@samsung.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.