drmm_add_action(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 when dev is released. your little cleanup bestie 🌈
  • data β€” an opaque pointer, passed to action. 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 πŸ”₯

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