drmm_add_action(9)
π drmm_add_action (9) β from the Kernel API Manual, bestie β¨
okay so you're in the drm_managed part of the kernel, the part that cleans up after you so you literally never have to remember to free stuff yourself. and this function? this is the moment you hand the kernel a little note that says "hey, when this device dips, run this for me π«Ά". iconic behaviour, no cap.
πΈ NAME πΈ
drmm_add_action β add a managed release action to a &drm_device π
like, you give the device a chore to do on its way out. that's the whole vibe.
β¨ SYNOPSIS β¨
drmm_add_action (dev , action , data );
yes the spacing is exactly like that, don't come for me, it's verbatim π
π¦ ARGUMENTS π¦
devβ the DRM device. the main character of this whole situation πactionβ the function that should be called whendevis released. your little cleanup bestie πdataβ an opaque pointer, passed toaction. it's giving "mystery bag, contents: yours to know, kernel's to not care about" π
π DESCRIPTION π
okay so here's the tea: this function adds the release action β with its optional parameter data β to the list of cleanup actions for dev.
and then, and this is the part that ate: those cleanup actions get run in reverse order in the final drm_dev_put call for dev. reverse order. so the last thing you registered is the first thing to go. lowkey poetic π₯Ή
it's giving stack energy, it's giving "unwind me backwards", and it means every single thing you registered gets torn down in the correct order without you lifting a finger. slay π
π₯ SEE ALSO π₯
- Kernel file
./include/drm/drm_managed.h drmm_add_action_or_reset(9)drmm_kzalloc(9)drmm_kmalloc_array(9)drmm_kcalloc(9)drmm_mutex_init(9)drmm_alloc_ordered_workqueue(9)
the whole managed-allocator friend group fr fr π«Ά go read them all, they're all valid and they all ate.
β friendly reminder: drmm_add_action_or_reset(9) is right there in SEE ALSO if you want the version that also handles the reset case β but that's a different page, this one's just the plain add. stay in your lane, drink water, read the source π
and that's the page!! brought to you by the fine folks at ./include/drm, dated October 2026, living in the Kernel API Manual section 9 β mwah, go forth and manage your device's cleanup era π§ββοΈβ¨ππ
π¦ 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