iommu_group_for_each_dev(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… iommu_group_for_each_dev(9) β€” Kernel API Manual

okay so bestie, welcome to the Kernel API Manual page for iommu_group_for_each_dev(9). this is the one that walks every device in an IOMMU group, one at a time, very demure, very mindful. let's get into it πŸŽ€


✨ NAME ✨

iommu_group_for_each_dev β€” iterate over each device in the group

like, every single one. no skipping. no cap. πŸ¦‹


✨ SYNOPSIS ✨

int iommu_group_for_each_dev (struct iommu_group *group , void *data ,
       int (*fn)(struct device *, void *) );

that's the whole vibe right there β€” a group, some opaque data, and a callback. it's giving "I trust you to handle this." 🫢


✨ ARGUMENTS ✨

  • group β€” the group. that's it. that's the group you're iterating over πŸ’œ
  • data β€” caller opaque data, passed straight through to the callback function. it's your stuff, the kernel is literally just holding it for you. don't make it weird πŸ™ˆ
  • fn β€” the caller supplied callback function. you write it, it gets called for each device. main character energy, tbh πŸ‘‘

✨ DESCRIPTION ✨

so here's what's happening: this function is called by group users to iterate over group devices. that's the whole job. it goes through the devices in the group and hits your fn for each one πŸ”₯

before you get too comfy, two things, and these are not optional:

  • callers should hold a reference count to the group during the callback. like, do not let that group slip away mid-loop. hold it. 🫢
  • group->mutex is held across callbacks, which will block calls to iommu_group_add_device and iommu_group_remove_device.
okay but for real though β€” that mutex thing is important. while your callback is running, anybody trying to add or remove a device in that group is just gonna wait. so don't sit in your callback doing side quests forever, bestie 😭

✨ SEE ALSO ✨

Kernel file ./drivers/iommu/iommu.c β€” and honestly the whole friend group:


and that's the page!! 🌸 this lil cutie lives in ./drivers/iommu, and the manual itself is dated October 2026. mwah, go iterate responsibly πŸ’…βœ¨

πŸ“¦ where this page comes from