spi_mem_calc_op_duration(9)
๐ spi_mem_calc_op_duration(9) โ from the Kernel API Manual
okay so bestie, buckle up, we're doing kernel math today ๐งฎโจ This little function lives in the spi_mem_calc_op_duration(9) page of the Kernel API Manual, and it's genuinely iconic.
โจ NAME โจ
spi_mem_calc_op_duration โ derives the theoretical length (in ns) of an operation. It literally helps you find the best variant among a list of possible choices. iykyk ๐
๐ธ SYNOPSIS ๐ธ
u64 spi_mem_calc_op_duration (struct spi_mem *mem , struct spi_mem_op
*op );
like, that's the whole vibe. two args in, a u64 out. slay.
๐ฆ ARGUMENTS ๐ฆ
memโ the SPI memory ๐opโ the operation to benchmark ๐ฅ
๐ง DESCRIPTION ๐ง
okay so here's the situation. some chips have per-op frequency limitations, PCBs usually have their own limitations as well, and controllers can support dual, quad or even octal modes โ sometimes in DTR. ๐ซถ
the way that all these combinations stack up makes it literally impossible to statically list the best combination for all situations. no cap. so if we want something accurate, all these combinations should be rated (eg. with a time estimate) and the best pick should be taken based on these calculations. that's the main character energy we're going for ๐
it returns a ns estimate for the time this op would take โ except if no frequency limit has been set. in that case we return the number of cycles nevertheless, so callers can still distinguish which operation would be the fastest at iso-frequency. ๐ (yes, the return value means two different things depending on the frequency limit โ that's not a bug, that's the design bestie.)
๐ SEE ALSO ๐
- Kernel file
./drivers/spi/spi-mem.c๐ spi_controller_dma_map_mem_op_data(9)spi_controller_dma_unmap_mem_op_data(9)spi_mem_supports_op(9)spi_mem_exec_op(9)spi_mem_get_name(9)spi_mem_set_dqs(9)spi_mem_has_dqs(9)spi_mem_adjust_op_size(9)spi_mem_adjust_op_freq(9)spi_mem_dirmap_create(9)spi_mem_dirmap_destroy(9)devm_spi_mem_dirmap_create(9)devm_spi_mem_dirmap_destroy(9)spi_mem_dirmap_read(9)spi_mem_dirmap_write(9)spi_mem_poll_status(9)spi_mem_driver_register_with_owner(9)spi_mem_driver_unregister(9)
like, read them, they're all part of the same friend group fr fr ๐
that's the whole page!! huge shoutout to ./drivers/spi for hosting, and this one's dated October 2026 โ mark your calendars ๐๏ธ๐ mwah, go calc some durations bestie โจ๐
๐ฆ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms