spi_take_timestamp_pre(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 the spi_controller structure 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 far
  • irqs_off β€” if true, 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's true, you must follow up with spi_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