Skip to content

Understanding SPI latency in recent Kernel versions #3

@matt-foundry

Description

@matt-foundry

Hello @msperl,

Thanks for all your work on improving SPI latency in Linux. As you note, the situation in recent Kernel versions is quite different from when you created this patch, and I notice you have made several recent contributions to https://github.com/torvalds/linux too. I have read through these patches as best as I can, but I am struggling to understand what kind of latency I can expect to achieve today?

For example I am using a Raspberry Pi Model 3A+ with an MCP2515, queuing bursts of 6 back-to-back 8-byte EFF frames from the Pi at 1 Mbps, using SocketCAN, and a recent build of https://github.com/raspberrypi/linux. I was hoping to see transmissions at "close" to the best-case 128 us period, but instead observe frames sent every 260-300 us.

I have tried tweaking several parameters, such as fixing the CPU and GPU frequency, assigning SCHED_FIFO priorities to user and kernel threads such as "spi0", and building a custom kernel setting cs_change_delay to 0 ns in mcp251x.c, and ->rt = 1 in mcp251x.c and spi-bcm2835.c, but nothing has made any substantial improvement.

Is this the best latency I can hope to achieve today, or am I missing some setting or patch which I could apply?

All the best,
Matt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions