Skip to content

can: c_can: Another pile of fixes and improvements

Thomas Gleixner linux-can 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest21 patches 4 repliesIn review
  2. v110 patches 14 repliesSuperseded

Changes in v2 from the cover letter

- Slightly modified version of the interrupt reduction patch
- Included the fix for PCH / C_CAN
- Lockless XMIT path
- Further reduction of register access
- Add the missing can.type setup in c_can_pci.c
- A pile of code cleanups.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/21can: c_can_pci: Set the type of the IP coredrivers/net/can/c_can/c_can_pci.c+2 -00 replies
2/21can: c_can: Fix startup logicdrivers/net/can/c_can/c_can.c+17 -180 replies
3/21can: c_can: Make bus off interrupt disable logic workdrivers/net/can/c_can/c_can.c+4 -70 replies
4/21can: c_can: Do not access skb after net_receive_skb()drivers/net/can/c_can/c_can.c+4 -50 replies
5/21can: c_can: Handle state change correctlydrivers/net/can/c_can/c_can.c+20 -50 replies
6/21can: c_can: Fix berr reportingdrivers/net/can/c_can/c_can.c+6 -100 replies
7/21can: c_can: Always update error statsdrivers/net/can/c_can/c_can.c+7 -60 replies
8/21can: c_can: Simplify buffer reenablingdrivers/net/can/c_can/c_can.c+6 -100 replies
9/21can: c_can: Avoid status register update for D_CANdrivers/net/can/c_can/c_can.c+6 -30 replies
10/21can: c_can: Get rid of pointless interruptsdrivers/net/can/c_can/c_can.c drivers/net/can/c_can/c_can.h+48 -770 replies
11/21can: c_can : Disable rx split as workarounddrivers/net/can/c_can/Kconfig drivers/net/can/c_can/c_can.c+55 -140 replies
12/21can: c_can": Work around C_CAN RX wreckagedrivers/net/can/c_can/c_can.c drivers/net/can/c_can/c_can.h+11 -33 replies
13/21can: c_can: Cleanup irq enable/disabledrivers/net/can/c_can/c_can.c+12 -250 replies
14/21can: c_can: Cleanup c_can_read_msg_object()drivers/net/can/c_can/c_can.c+15 -170 replies
15/21can: c_can Cleanup setup of receive buffersdrivers/net/can/c_can/c_can.c+18 -220 replies
16/21can: c_can: Cleanup c_can_inval_msg_object()drivers/net/can/c_can/c_can.c+5 -50 replies
17/21can: c_can: Cleanup c_can_msg_obj_put/get()drivers/net/can/c_can/c_can.c+16 -440 replies
18/21can: c_can: Cleanup c_can_write_msg_object()drivers/net/can/c_can/c_can.c drivers/net/can/c_can/c_can.h+25 -340 replies
19/21can: c_can: Use proper u32 variables in c_can_write_msg_object()drivers/net/can/c_can/c_can.c+9 -90 replies
20/21can: c_can: Remove tx lockingdrivers/net/can/c_can/c_can.c drivers/net/can/c_can/c_can.h+43 -920 replies
21/21can: c_can: Speed up tx buffer invalidationdrivers/net/can/c_can/c_can.c drivers/net/can/c_can/c_can.h+40 -150 replies

Reviews trailers per patch

None of the 21 patches has a Reviewed-by or Acked-by.

PatchAlexander Stein
SeriesT-b
1/21
2/21
3/21
4/21
5/21
6/21
7/21
8/21
9/21
10/21
11/21
12/21Reported-and-tested-by
13/21
14/21
15/21
16/21
17/21
18/21
19/21
20/21
21/21

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [patch V2 00/21] can: c_can: Another pile of fixes and improvements

Changes since V1:

- Slightly modified version of the interrupt reduction patch
- Included the fix for PCH / C_CAN
- Lockless XMIT path
- Further reduction of register access
- Add the missing can.type setup in c_can_pci.c
- A pile of code cleanups.

It would be nice to reduce the register access some more by relying completely on the status interrupt, but it turned out that the TX/RXOK is not reliable enough. So we need to invalidate the message objects in the tx softirq handling.

But the overall change of this series is that the I/O load gets reduced by about 45% according to perf top. Though that PCH thing sucks. The beaglebone manages to almost saturate the bus with short packets at 1Mbit while PCH fails miserably and thats solely related to the miserable I/O performance.

time cangen can0 -g0 -p10 -I5A5 -L0 -x -n 1000000

arm: real 0m51.510s I/O read: ~6% I/O write: 1.5% ~3.5s
x86: real 1m48.533s I/O read: ~29% I/O write: 0.8% ~32 s!!

That's both with HW loopback on, as my PCH does not have a tranceiver. Granted the C_CAN in the PCH needs the double IF transfer to prevent the message loss versus the D_CAN in the ARM chip, but even that taken into account makes a whopping 16s per 1M messages vs. 3.5s on ARM.

w/o loopback the arm I/O read load drops to ~3.5% on the sender side and ~5.5% on the receiver side. The time drops to 50.5s on the transmit side if we do not have to get all the RX packets from HW loopback. On TX we have a ~10us large gap every 16 packets which is caused by the queue stall as we have to wait for the last packet in the "FIFO" to be transferred.

It seems there is a reason why the ATOM perf events do not expose the stalled cpu cycles. But it's easy to figure out. You can compare the CAN load case with some other scenario which has 100% CPU utilization by running

# perf stat -a sleep 60

The interesting part is: insns per cycle

CAN: 0.23 insns per cycle
Other: 0.53 insns per cycle

I don't have comparison numbers for ARM due to not supported perf events, but the perf top numbers and the transfer performance tell a clear story.

There might be room for a few improvements, but I'm running out of cycles and I really want to get the IF3 DMA feature functional on the TI chips, but that seems to be an equally tedious reverse engineering problem as the rest of this.

Thanks,

tglx

---------

 Kconfig     |    7 
 c_can.c     |  662 +++++++++++++++++++++++++++---------------------------------
 c_can.h     |   21 -
 c_can_pci.c |    2 
 4 files changed, 320 insertions(+), 372 deletions(-)