[v6,00/14] can: m_can: Optimizations for m_can/tcan part 2

Message ID 20230929141304.3934380-1-msp@baylibre.com
Headers
Series can: m_can: Optimizations for m_can/tcan part 2 |

Message

Markus Schneider-Pargmann Sept. 29, 2023, 2:12 p.m. UTC
  Hi Marc, Simon, Martin and everyone,

v6 is a rebase on v6.6. As there was a conflicting change merged for
v6.6 which introduced irq polling, I had to modify the patches that
touch the hrtimer.

@Simon: I removed a couple of your reviewed-by tags because of the
changes.

@Martin: as the functionality changed, I did not apply your Tested-by
tag as I may have introduced new bugs with the changes.

The series implements many small and bigger throughput improvements and
adds rx/tx coalescing at the end.

Based on v6.6-rc2. Also available at
https://gitlab.baylibre.com/msp8/linux/-/tree/topic/mcan-optimization/v6.6?ref_type=heads

Best,
Markus

Changes in v6:
- Rebased to v6.6-rc2
- Added two small changes for the newly integrated polling feature
- Reuse the polling hrtimer for coalescing as the timer used for
  coalescing has a similar purpose as the one for polling. Also polling
  and coalescing will never be active at the same time.

Changes in v5:
- Add back parenthesis in m_can_set_coalesce(). This will make
  checkpatch unhappy but gcc happy.
- Remove unused fifo_header variable in m_can_tx_handler().
- Rebased to v6.5-rc1

Changes in v4:
- Create and use struct m_can_fifo_element in m_can_tx_handler
- Fix memcpy_and_pad to copy the full buffer
- Fixed a few checkpatch warnings
- Change putidx to be unsigned
- Print hard_xmit error only once when TX FIFO is full

Changes in v3:
- Remove parenthesis in error messages
- Use memcpy_and_pad for buffer copy in 'can: m_can: Write transmit
  header and data in one transaction'.
- Replace spin_lock with spin_lock_irqsave. I got a report of a
  interrupt that was calling start_xmit just after the netqueue was
  woken up before the locked region was exited. spin_lock_irqsave should
  fix this. I attached the full stack at the end of the mail if someone
  wants to know.
- Rebased to v6.3-rc1.
- Removed tcan4x5x patches from this series.

Changes in v2:
- Rebased on v6.2-rc5
- Fixed missing/broken accounting for non peripheral m_can devices.

previous versions:
v1 - https://lore.kernel.org/lkml/20221221152537.751564-1-msp@baylibre.com
v2 - https://lore.kernel.org/lkml/20230125195059.630377-1-msp@baylibre.com
v3 - https://lore.kernel.org/lkml/20230315110546.2518305-1-msp@baylibre.com/
v4 - https://lore.kernel.org/lkml/20230621092350.3130866-1-msp@baylibre.com/
v5 - https://lore.kernel.org/lkml/20230718075708.958094-1-msp@baylibre.com

Markus Schneider-Pargmann (14):
  can: m_can: Start/Cancel polling timer together with interrupts
  can: m_can: Move hrtimer init to m_can_class_register
  can: m_can: Write transmit header and data in one transaction
  can: m_can: Implement receive coalescing
  can: m_can: Implement transmit coalescing
  can: m_can: Add rx coalescing ethtool support
  can: m_can: Add tx coalescing ethtool support
  can: m_can: Use u32 for putidx
  can: m_can: Cache tx putidx
  can: m_can: Use the workqueue as queue
  can: m_can: Introduce a tx_fifo_in_flight counter
  can: m_can: Use tx_fifo_in_flight for netif_queue control
  can: m_can: Implement BQL
  can: m_can: Implement transmit submission coalescing

 drivers/net/can/m_can/m_can.c          | 559 ++++++++++++++++++-------
 drivers/net/can/m_can/m_can.h          |  34 +-
 drivers/net/can/m_can/m_can_platform.c |   4 -
 3 files changed, 447 insertions(+), 150 deletions(-)


base-commit: ce9ecca0238b140b88f43859b211c9fdfd8e5b70
  

Comments

Simon Horman Oct. 1, 2023, 12:23 p.m. UTC | #1
On Fri, Sep 29, 2023 at 04:12:56PM +0200, Markus Schneider-Pargmann wrote:
> Add the possibility to set coalescing parameters with ethtool.
> 
> rx-frames-irq and rx-usecs-irq can only be set and unset together as the
> implemented mechanism would not work otherwise. rx-frames-irq can't be
> greater than the RX FIFO size.
> 
> Also all values can only be changed if the chip is not active.
> 
> Polling is excluded from irq coalescing support.
> 
> Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>

Reviewed-by: Simon Horman <horms@kernel.org>
  
Markus Schneider-Pargmann Oct. 17, 2023, 8:44 a.m. UTC | #2
Hi Marc,

On Fri, Sep 29, 2023 at 04:12:50PM +0200, Markus Schneider-Pargmann wrote:
> Hi Marc, Simon, Martin and everyone,
> 
> v6 is a rebase on v6.6. As there was a conflicting change merged for
> v6.6 which introduced irq polling, I had to modify the patches that
> touch the hrtimer.

Did you have some time to have a look at this series? Anything I should
change?

Thanks!

Best,
Markus

> 
> @Simon: I removed a couple of your reviewed-by tags because of the
> changes.
> 
> @Martin: as the functionality changed, I did not apply your Tested-by
> tag as I may have introduced new bugs with the changes.
> 
> The series implements many small and bigger throughput improvements and
> adds rx/tx coalescing at the end.
> 
> Based on v6.6-rc2. Also available at
> https://gitlab.baylibre.com/msp8/linux/-/tree/topic/mcan-optimization/v6.6?ref_type=heads
> 
> Best,
> Markus
> 
> Changes in v6:
> - Rebased to v6.6-rc2
> - Added two small changes for the newly integrated polling feature
> - Reuse the polling hrtimer for coalescing as the timer used for
>   coalescing has a similar purpose as the one for polling. Also polling
>   and coalescing will never be active at the same time.
> 
> Changes in v5:
> - Add back parenthesis in m_can_set_coalesce(). This will make
>   checkpatch unhappy but gcc happy.
> - Remove unused fifo_header variable in m_can_tx_handler().
> - Rebased to v6.5-rc1
> 
> Changes in v4:
> - Create and use struct m_can_fifo_element in m_can_tx_handler
> - Fix memcpy_and_pad to copy the full buffer
> - Fixed a few checkpatch warnings
> - Change putidx to be unsigned
> - Print hard_xmit error only once when TX FIFO is full
> 
> Changes in v3:
> - Remove parenthesis in error messages
> - Use memcpy_and_pad for buffer copy in 'can: m_can: Write transmit
>   header and data in one transaction'.
> - Replace spin_lock with spin_lock_irqsave. I got a report of a
>   interrupt that was calling start_xmit just after the netqueue was
>   woken up before the locked region was exited. spin_lock_irqsave should
>   fix this. I attached the full stack at the end of the mail if someone
>   wants to know.
> - Rebased to v6.3-rc1.
> - Removed tcan4x5x patches from this series.
> 
> Changes in v2:
> - Rebased on v6.2-rc5
> - Fixed missing/broken accounting for non peripheral m_can devices.
> 
> previous versions:
> v1 - https://lore.kernel.org/lkml/20221221152537.751564-1-msp@baylibre.com
> v2 - https://lore.kernel.org/lkml/20230125195059.630377-1-msp@baylibre.com
> v3 - https://lore.kernel.org/lkml/20230315110546.2518305-1-msp@baylibre.com/
> v4 - https://lore.kernel.org/lkml/20230621092350.3130866-1-msp@baylibre.com/
> v5 - https://lore.kernel.org/lkml/20230718075708.958094-1-msp@baylibre.com
> 
> Markus Schneider-Pargmann (14):
>   can: m_can: Start/Cancel polling timer together with interrupts
>   can: m_can: Move hrtimer init to m_can_class_register
>   can: m_can: Write transmit header and data in one transaction
>   can: m_can: Implement receive coalescing
>   can: m_can: Implement transmit coalescing
>   can: m_can: Add rx coalescing ethtool support
>   can: m_can: Add tx coalescing ethtool support
>   can: m_can: Use u32 for putidx
>   can: m_can: Cache tx putidx
>   can: m_can: Use the workqueue as queue
>   can: m_can: Introduce a tx_fifo_in_flight counter
>   can: m_can: Use tx_fifo_in_flight for netif_queue control
>   can: m_can: Implement BQL
>   can: m_can: Implement transmit submission coalescing
> 
>  drivers/net/can/m_can/m_can.c          | 559 ++++++++++++++++++-------
>  drivers/net/can/m_can/m_can.h          |  34 +-
>  drivers/net/can/m_can/m_can_platform.c |   4 -
>  3 files changed, 447 insertions(+), 150 deletions(-)
> 
> 
> base-commit: ce9ecca0238b140b88f43859b211c9fdfd8e5b70
> -- 
> 2.40.1
>
  
Martin Hundebøll Nov. 13, 2023, 1:25 p.m. UTC | #3
On Fri, 2023-09-29 at 16:12 +0200, Markus Schneider-Pargmann wrote:
> Hi Marc, Simon, Martin and everyone,
> 
> v6 is a rebase on v6.6. As there was a conflicting change merged for
> v6.6 which introduced irq polling, I had to modify the patches that
> touch the hrtimer.
> 
> @Simon: I removed a couple of your reviewed-by tags because of the
> changes.
> 
> @Martin: as the functionality changed, I did not apply your Tested-by
> tag as I may have introduced new bugs with the changes.
> 
> The series implements many small and bigger throughput improvements
> and
> adds rx/tx coalescing at the end.
> 
> Based on v6.6-rc2. Also available at
> https://gitlab.baylibre.com/msp8/linux/-/tree/topic/mcan-optimization/v6.6?ref_type=heads

For the whole series:
Tested-by: Martin Hundebøll <martin@geanix.com>

Thanks,
Martin

> Changes in v6:
> - Rebased to v6.6-rc2
> - Added two small changes for the newly integrated polling feature
> - Reuse the polling hrtimer for coalescing as the timer used for
>   coalescing has a similar purpose as the one for polling. Also
> polling
>   and coalescing will never be active at the same time.
> 
> Changes in v5:
> - Add back parenthesis in m_can_set_coalesce(). This will make
>   checkpatch unhappy but gcc happy.
> - Remove unused fifo_header variable in m_can_tx_handler().
> - Rebased to v6.5-rc1
> 
> Changes in v4:
> - Create and use struct m_can_fifo_element in m_can_tx_handler
> - Fix memcpy_and_pad to copy the full buffer
> - Fixed a few checkpatch warnings
> - Change putidx to be unsigned
> - Print hard_xmit error only once when TX FIFO is full
> 
> Changes in v3:
> - Remove parenthesis in error messages
> - Use memcpy_and_pad for buffer copy in 'can: m_can: Write transmit
>   header and data in one transaction'.
> - Replace spin_lock with spin_lock_irqsave. I got a report of a
>   interrupt that was calling start_xmit just after the netqueue was
>   woken up before the locked region was exited. spin_lock_irqsave
> should
>   fix this. I attached the full stack at the end of the mail if
> someone
>   wants to know.
> - Rebased to v6.3-rc1.
> - Removed tcan4x5x patches from this series.
> 
> Changes in v2:
> - Rebased on v6.2-rc5
> - Fixed missing/broken accounting for non peripheral m_can devices.
> 
> previous versions:
> v1 -
> https://lore.kernel.org/lkml/20221221152537.751564-1-msp@baylibre.com
> v2 -
> https://lore.kernel.org/lkml/20230125195059.630377-1-msp@baylibre.com
> v3 -
> https://lore.kernel.org/lkml/20230315110546.2518305-1-msp@baylibre.com/
> v4 -
> https://lore.kernel.org/lkml/20230621092350.3130866-1-msp@baylibre.com/
> v5 -
> https://lore.kernel.org/lkml/20230718075708.958094-1-msp@baylibre.com
> 
> Markus Schneider-Pargmann (14):
>   can: m_can: Start/Cancel polling timer together with interrupts
>   can: m_can: Move hrtimer init to m_can_class_register
>   can: m_can: Write transmit header and data in one transaction
>   can: m_can: Implement receive coalescing
>   can: m_can: Implement transmit coalescing
>   can: m_can: Add rx coalescing ethtool support
>   can: m_can: Add tx coalescing ethtool support
>   can: m_can: Use u32 for putidx
>   can: m_can: Cache tx putidx
>   can: m_can: Use the workqueue as queue
>   can: m_can: Introduce a tx_fifo_in_flight counter
>   can: m_can: Use tx_fifo_in_flight for netif_queue control
>   can: m_can: Implement BQL
>   can: m_can: Implement transmit submission coalescing
> 
>  drivers/net/can/m_can/m_can.c          | 559 ++++++++++++++++++-----
> --
>  drivers/net/can/m_can/m_can.h          |  34 +-
>  drivers/net/can/m_can/m_can_platform.c |   4 -
>  3 files changed, 447 insertions(+), 150 deletions(-)
> 
> 
> base-commit: ce9ecca0238b140b88f43859b211c9fdfd8e5b70
  
Marc Kleine-Budde Nov. 13, 2023, 1:30 p.m. UTC | #4
On 13.11.2023 14:25:37, Martin Hundebøll wrote:
> On Fri, 2023-09-29 at 16:12 +0200, Markus Schneider-Pargmann wrote:
> > Hi Marc, Simon, Martin and everyone,
> > 
> > v6 is a rebase on v6.6. As there was a conflicting change merged for
> > v6.6 which introduced irq polling, I had to modify the patches that
> > touch the hrtimer.
> > 
> > @Simon: I removed a couple of your reviewed-by tags because of the
> > changes.
> > 
> > @Martin: as the functionality changed, I did not apply your Tested-by
> > tag as I may have introduced new bugs with the changes.
> > 
> > The series implements many small and bigger throughput improvements
> > and
> > adds rx/tx coalescing at the end.
> > 
> > Based on v6.6-rc2. Also available at
> > https://gitlab.baylibre.com/msp8/linux/-/tree/topic/mcan-optimization/v6.6?ref_type=heads
> 
> For the whole series:
> Tested-by: Martin Hundebøll <martin@geanix.com>

On which hardware? On an mmio mapped m_can or the tcan4x5x?

Marc
  
Martin Hundebøll Nov. 13, 2023, 1:31 p.m. UTC | #5
On Mon, 2023-11-13 at 14:30 +0100, Marc Kleine-Budde wrote:
> On 13.11.2023 14:25:37, Martin Hundebøll wrote:
> > On Fri, 2023-09-29 at 16:12 +0200, Markus Schneider-Pargmann wrote:
> > > Hi Marc, Simon, Martin and everyone,
> > > 
> > > v6 is a rebase on v6.6. As there was a conflicting change merged
> > > for
> > > v6.6 which introduced irq polling, I had to modify the patches
> > > that
> > > touch the hrtimer.
> > > 
> > > @Simon: I removed a couple of your reviewed-by tags because of
> > > the
> > > changes.
> > > 
> > > @Martin: as the functionality changed, I did not apply your
> > > Tested-by
> > > tag as I may have introduced new bugs with the changes.
> > > 
> > > The series implements many small and bigger throughput
> > > improvements
> > > and
> > > adds rx/tx coalescing at the end.
> > > 
> > > Based on v6.6-rc2. Also available at
> > > https://gitlab.baylibre.com/msp8/linux/-/tree/topic/mcan-optimization/v6.6?ref_type=heads
> > 
> > For the whole series:
> > Tested-by: Martin Hundebøll <martin@geanix.com>
> 
> On which hardware? On an mmio mapped m_can or the tcan4x5x?

tcan4x5x on a custom iMX6UL.

Sorry for mentioning it.

// Martin
  
Markus Schneider-Pargmann Nov. 13, 2023, 8:51 p.m. UTC | #6
On Mon, Nov 13, 2023 at 02:31:20PM +0100, Martin Hundebøll wrote:
> On Mon, 2023-11-13 at 14:30 +0100, Marc Kleine-Budde wrote:
> > On 13.11.2023 14:25:37, Martin Hundebøll wrote:
> > > On Fri, 2023-09-29 at 16:12 +0200, Markus Schneider-Pargmann wrote:
> > > > Hi Marc, Simon, Martin and everyone,
> > > > 
> > > > v6 is a rebase on v6.6. As there was a conflicting change merged
> > > > for
> > > > v6.6 which introduced irq polling, I had to modify the patches
> > > > that
> > > > touch the hrtimer.
> > > > 
> > > > @Simon: I removed a couple of your reviewed-by tags because of
> > > > the
> > > > changes.
> > > > 
> > > > @Martin: as the functionality changed, I did not apply your
> > > > Tested-by
> > > > tag as I may have introduced new bugs with the changes.
> > > > 
> > > > The series implements many small and bigger throughput
> > > > improvements
> > > > and
> > > > adds rx/tx coalescing at the end.
> > > > 
> > > > Based on v6.6-rc2. Also available at
> > > > https://gitlab.baylibre.com/msp8/linux/-/tree/topic/mcan-optimization/v6.6?ref_type=heads
> > > 
> > > For the whole series:
> > > Tested-by: Martin Hundebøll <martin@geanix.com>
> > 
> > On which hardware? On an mmio mapped m_can or the tcan4x5x?
> 
> tcan4x5x on a custom iMX6UL.
> 
> Sorry for mentioning it.

Thanks for testing!

Also I was able to get my hands on an am62 board and could test the
series on a mmio mapped m_can (in loopback mode). I didn't notice any
issues.

Best,
Markus