Skip to content

Instantly share code, notes, and snippets.

@pgaskin
Created May 26, 2026 19:01
Show Gist options
  • Select an option

  • Save pgaskin/400966d2990bcffee0c7d070240ef06e to your computer and use it in GitHub Desktop.

Select an option

Save pgaskin/400966d2990bcffee0c7d070240ef06e to your computer and use it in GitHub Desktop.
#!/bin/bash
for ctrl in /sys/bus/pci/devices/*/; do
class=$(cat "$ctrl/class" 2>/dev/null)
case "$class" in 0x0c03*)
bdf=$(basename "$ctrl")
iommu=$(basename $(readlink "$ctrl/iommu_group" 2>/dev/null) 2>/dev/null || echo "none")
driver=$(basename $(readlink "$ctrl/driver" 2>/dev/null) 2>/dev/null || echo "none")
desc=$(lspci -s "$bdf" 2>/dev/null | sed 's/^[^ ]* //')
echo "[$bdf] $desc"
echo " IOMMU group: $iommu | driver: $driver"
for usbbus in "$ctrl"usb*/; do
[ -d "$usbbus" ] || continue
busnum=$(cat "$usbbus/busnum" 2>/dev/null)
[ -n "$busnum" ] || continue
echo " USB bus $busnum:"
lsusb -s "${busnum}:" 2>/dev/null | sed 's/^/ /'
done
echo
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment