spi_take_timestamp_pre(9)
π spi_take_timestamp_pre(9) β from the Kernel API Manual, bestie
okay so picture this: you're a driver dev, you need to know exactly when your TX started going out the door, and the kernel hands you this little helper π that's literally what it does. here's the whole thing, no cap.
πΈ SYNOPSIS πΈ
void spi_take_timestamp_pre (struct spi_controller *ctlr , struct
spi_transfer *xfer , size_t progress , bool irqs_off );
β¨ ARGUMENTS β¨
ctlrβ pointer to thespi_controllerstructure of the driver. that's your controller, your main character πxferβ pointer to the transfer being timestamped. the vibes we're measuring πprogressβ how many words (not bytes!! say it with me, words π«Ά) have been transferred so farirqs_offβ iftrue, this disables IRQs and preemption for the duration of the transfer, all so the time measurement has less jitter β¨. only compatible with PIO drivers, iykyk. if it'strue, you must follow up withspi_take_timestamp_postβ otherwise the system will crash π. WARNING: for fully predictable results, the CPU frequency must also be under control (governor).
ngl that irqs_off = true path is a whole commitment. no follow-up call means crash city. you've been warned π
π DESCRIPTION π
so this is a helper for drivers to collect the beginning of the TX timestamp for the requested byte from the SPI transfer. π¦
how often do you have to call it? literally whatever, bestie β the frequency is arbitrary. once per word, once for the whole transfer, once per batch of words, etc. all fine, as long as the tx buffer offset is greater than or equal to the requested byte at the time of the call. the timestamp is only taken once, at the first such call. and it's assumed that the driver advances its tx buffer pointer monotonically β that's the deal, periodt. π
π₯ SEE ALSO π₯
kernel file ./drivers/spi/spi.c, plus all of these:
__spi_register_driver(9), spi_alloc_device(9), spi_add_device(9), spi_new_device(9), spi_unregister_device(9), spi_register_board_info(9), spi_res_alloc(9), spi_res_free(9), spi_res_add(9), spi_res_release(9), spi_finalize_current_transfer(9), __spi_pump_messages(9), spi_pump_messages(9), spi_take_timestamp_post(9), spi_set_thread_rt(9), spi_get_next_queued_message(9), spi_finalize_current_message(9), spi_queued_transfer(9), spi_flush_queue(9), of_register_spi_devices(9), spi_new_ancillary_device(9), devm_spi_new_ancillary_device(9), acpi_spi_count_resources(9), acpi_spi_device_alloc(9), spi_target_abort(9), __spi_alloc_controller(9), __devm_spi_alloc_controller(9), spi_get_gpio_descs(9), spi_register_controller(9), devm_spi_register_controller(9), spi_unregister_controller(9), spi_replace_transfers(9), spi_split_transfers_maxsize(9), spi_split_transfers_maxwords(9), spi_set_cs_timing(9), spi_setup(9), spi_optimize_message(9), spi_unoptimize_message(9), devm_spi_optimize_message(9), spi_async(9), spi_sync(9), spi_sync_locked(9), spi_bus_lock(9), spi_bus_unlock(9), spi_write_then_read(9)
that's the whole page, bestie β go timestamp something iconic β
source/version: ./drivers/spi π dated October 2026 π mwah, hope this ate π
π¦ 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