Skip to content

Instantly share code, notes, and snippets.

@r15ch13
Last active October 29, 2025 18:27
Show Gist options
  • Save r15ch13/ba2d738985fce8990a4e9f32d07c6ada to your computer and use it in GitHub Desktop.
Save r15ch13/ba2d738985fce8990a4e9f32d07c6ada to your computer and use it in GitHub Desktop.

Revisions

  1. r15ch13 revised this gist Jul 25, 2021. No changes.
  2. r15ch13 revised this gist Jul 25, 2021. No changes.
  3. r15ch13 revised this gist Jul 25, 2021. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions iommu.sh
    Original file line number Diff line number Diff line change
    @@ -4,12 +4,12 @@ shopt -s nullglob
    lastgroup=""
    for g in `find /sys/kernel/iommu_groups/* -maxdepth 0 -type d | sort -V`; do
    for d in $g/devices/*; do
    if [ "${g##*/}" != "$lastgroup" ]; then
    echo -en "Group ${g##*/}:\t"
    else
    echo -en "\t\t"
    fi
    lastgroup=${g##*/}
    if [ "${g##*/}" != "$lastgroup" ]; then
    echo -en "Group ${g##*/}:\t"
    else
    echo -en "\t\t"
    fi
    lastgroup=${g##*/}
    lspci -nms ${d##*/} | awk -F'"' '{printf "[%s:%s]", $4, $6}'
    if [[ -e "$d"/reset ]]; then echo -en " [R] "; else echo -en " "; fi

  4. r15ch13 revised this gist Jul 24, 2021. 1 changed file with 14 additions and 4 deletions.
    18 changes: 14 additions & 4 deletions iommu.sh
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,24 @@
    #!/usr/bin/env bash

    shopt -s nullglob
    lastgroup=""
    for g in `find /sys/kernel/iommu_groups/* -maxdepth 0 -type d | sort -V`; do
    for d in $g/devices/*; do
    if [ "${g##*/}" != "$lastgroup" ]; then
    echo -en "Group ${g##*/}:\t"
    if [[ -e "$d"/reset ]]; then echo -en "[RESET]"; fi
    echo -e "\t$(lspci -nns ${d##*/})"
    else
    echo -en "\t\t"
    fi
    lastgroup=${g##*/}
    lspci -nms ${d##*/} | awk -F'"' '{printf "[%s:%s]", $4, $6}'
    if [[ -e "$d"/reset ]]; then echo -en " [R] "; else echo -en " "; fi

    lspci -mms ${d##*/} | awk -F'"' '{printf "%s %-40s %s\n", $1, $2, $6}'
    for u in ${d}/usb*/; do
    lsusb -s $(cat "${u}/busnum"): | awk '{printf "\t\t\t\t%s\n", $0}'
    echo
    bus=$(cat "${u}/busnum")
    lsusb -s $bus: | \
    awk '{gsub(/:/,"",$4); printf "%s|%s %s %s %s|", $6, $1, $2, $3, $4; for(i=7;i<=NF;i++){printf "%s ", $i}; printf "\n"}' | \
    awk -F'|' '{printf "USB:\t\t[%s]\t\t %-40s %s\n", $1, $2, $3}'
    done
    done
    done
  5. r15ch13 revised this gist Jul 24, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion iommu.sh
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ for g in `find /sys/kernel/iommu_groups/* -maxdepth 0 -type d | sort -V`; do
    if [[ -e "$d"/reset ]]; then echo -en "[RESET]"; fi
    echo -e "\t$(lspci -nns ${d##*/})"
    for u in ${d}/usb*/; do
    lsusb -s $(cat "${u}/busnum"): | awk '{printf "\t\t\t%s\n", $0}'
    lsusb -s $(cat "${u}/busnum"): | awk '{printf "\t\t\t\t%s\n", $0}'
    echo
    done
    done
  6. r15ch13 revised this gist Jul 24, 2021. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion iommu.sh
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,9 @@
    shopt -s nullglob
    for g in `find /sys/kernel/iommu_groups/* -maxdepth 0 -type d | sort -V`; do
    for d in $g/devices/*; do
    echo -e "Group ${g##*/}:\t$(lspci -nns ${d##*/})"
    echo -en "Group ${g##*/}:\t"
    if [[ -e "$d"/reset ]]; then echo -en "[RESET]"; fi
    echo -e "\t$(lspci -nns ${d##*/})"
    for u in ${d}/usb*/; do
    lsusb -s $(cat "${u}/busnum"): | awk '{printf "\t\t\t%s\n", $0}'
    echo
  7. r15ch13 created this gist Jul 24, 2021.
    12 changes: 12 additions & 0 deletions iommu.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    #!/usr/bin/env bash

    shopt -s nullglob
    for g in `find /sys/kernel/iommu_groups/* -maxdepth 0 -type d | sort -V`; do
    for d in $g/devices/*; do
    echo -e "Group ${g##*/}:\t$(lspci -nns ${d##*/})"
    for u in ${d}/usb*/; do
    lsusb -s $(cat "${u}/busnum"): | awk '{printf "\t\t\t%s\n", $0}'
    echo
    done
    done
    done