drm_crtc_arm_vblank_event(9)
π drm_crtc_arm_vblank_event(9) β the Kernel API Manual, bestie edition β¨
okay so you found the page for drm_crtc_arm_vblank_event in the Kernel API Manual and honestly? iconic of you. this is the "arm a vblank event after pageflip" girlie, and she has β¨opinionsβ¨. let's get into it π
β¨ NAME β¨
drm_crtc_arm_vblank_event β arm vblank event after pageflip π¦
πΈ SYNOPSIS πΈ
void drm_crtc_arm_vblank_event (struct drm_crtc *crtc , struct
drm_pending_vblank_event *e );
π ARGUMENTS π
crtcβ the source CRTC of the vblank event π like, the CRTC that's sending this whole thingeβ the event to send π the actual event that goes out
π DESCRIPTION π
so real talk: a lot of drivers need to generate vblank events for the very next vblank interrupt. why? say the page flip interrupt fires off when the page flip gets armed β not when it actually executes within the next vblank period. awkward, right? π
this helper function implements exactly the required vblank arming behaviour. no cap, that's literally its whole job π
β οΈ NOTE β οΈ
bestie. listen to me. this is the important part π¨
drivers using this to send out the drm_crtc_state.event as part of an atomic commit must ensure that the next vblank happens at exactly the same time as the atomic commit is committed to the hardware. this function itself does not protect against the next vblank interrupt racing with either this function call or the atomic commit operation. π
a possible sequence could be:
- Driver commits new hardware state into vblank-synchronized registers.
- A vblank happens, committing the hardware state. Also the corresponding vblank interrupt is fired off and fully processed by the interrupt handler.
- The atomic commit operation proceeds to call
drm_crtc_arm_vblank_event. - The event is only send out for the next vblank, which is wrong.
and an equivalent race can happen when the driver calls drm_crtc_arm_vblank_event before writing out the new hardware state. yes, both directions. she bites either way π
the only way to make this work safely is to prevent the vblank from firing (and the hardware from committing anything else) until the entire atomic commit sequence has run to completion. if the hardware does not have such a feature (e.g. using a "go" bit), then it is unsafe to use this functions. instead, drivers need to manually send out the event from their interrupt handler by calling drm_crtc_send_vblank_event and make sure that there's no possible race with the hardware committing the atomic update. π
last thing, and it's a big one: caller must hold a vblank reference for the event e acquired by a drm_crtc_vblank_get, which will be dropped when the next vblank arrives. π«Ά don't skip the ref, don't lose the ref.
π¦ SEE ALSO π¦
the whole vblank cinematic universe, fr fr:
- Kernel file
./drivers/gpu/drm/drm_vblank.cvblank handling(9) drm_crtc_accurate_vblank_count(9)drm_vblank_init(9)drm_dev_has_vblank(9)drm_crtc_vblank_waitqueue(9)drm_calc_timestamping_constants(9)drm_crtc_vblank_helper_get_vblank_timestamp_internal(9)drm_crtc_vblank_helper_get_vblank_timestamp(9)drm_crtc_get_last_vbltimestamp(9)drm_crtc_vblank_count(9)drm_vblank_count_and_time(9)drm_crtc_vblank_count_and_time(9)drm_crtc_next_vblank_start(9)drm_crtc_send_vblank_event(9)drm_crtc_vblank_get(9)drm_crtc_vblank_put(9)drm_crtc_wait_one_vblank(9)drm_crtc_vblank_off(9)drm_crtc_vblank_reset(9)drm_crtc_set_max_vblank_count(9)drm_crtc_vblank_on_config(9)drm_crtc_vblank_on(9)drm_crtc_vblank_restore(9)drm_handle_vblank(9)drm_crtc_handle_vblank(9)drm_crtc_vblank_start_timer(9)drm_crtc_vblank_cancel_timer(9)drm_crtc_vblank_get_vblank_timeout(9)
anyway that's the page π sourced from ./drivers/gpu/drm, dated October 2026, living in the Kernel API Manual β mwah, go hold your vblank ref, ily, bye π§ββοΈβ¨
π¦ 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