Skip to content

Commit

Permalink
update script
Browse files Browse the repository at this point in the history
  • Loading branch information
joelsmithTT committed Dec 13, 2024
1 parent ff2547d commit 5c34e26
Showing 1 changed file with 33 additions and 32 deletions.
65 changes: 33 additions & 32 deletions scripts/iommu_detect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ GS_PID="faca"
WH_PID="401e"
BH_PID="b140"

# Find all Tenstorrent PCI devices with full domain info
tt_devices=$(lspci -D -d ${TT_VID}: | cut -d' ' -f1)

if [ -z "$tt_devices" ]; then
Expand All @@ -17,43 +16,45 @@ fi
found_gs_wh=false
found_bh=false

# First identify devices
for dev in $tt_devices; do
device_id=$(lspci -D -n -s "$dev" | cut -d' ' -f3 | cut -d: -f2)
echo "Checking device $dev (ID: $device_id):"

case $device_id in
$GS_PID|$WH_PID)
found_gs_wh=true
if [ -f "/sys/bus/pci/devices/${dev}/iommu_group/type" ]; then
iommu_type=$(cat "/sys/bus/pci/devices/${dev}/iommu_group/type")
if [[ "$iommu_type" == *"DMA"* ]]; then
echo " WARNING: Grayskull/Wormhole device with IOMMU enabled (type: $iommu_type) - this configuration is not supported"
else
echo " Grayskull/Wormhole device detected - hugepages required"
fi
else
echo " Grayskull/Wormhole device detected - hugepages required"
fi
;;
$BH_PID)
found_bh=true
if [ -f "/sys/bus/pci/devices/${dev}/iommu_group/type" ]; then
iommu_type=$(cat "/sys/bus/pci/devices/${dev}/iommu_group/type")
if [[ "$iommu_type" == *"DMA"* ]]; then
echo " Blackhole device with IOMMU enabled (type: $iommu_type) - hugepages optional"
else
echo " Blackhole device with IOMMU in passthrough mode (type: $iommu_type) - hugepages required"
fi
else
echo " Blackhole device with no IOMMU configuration - hugepages required"
fi
;;
*)
echo " Unknown device ID: $device_id"
;;
$GS_PID|$WH_PID) found_gs_wh=true ;;
$BH_PID) found_bh=true ;;
esac
done

# Check and output for each device
for dev in $tt_devices; do
device_id=$(lspci -D -n -s "$dev" | cut -d' ' -f3 | cut -d: -f2)
echo "Checking device $dev (ID: $device_id):"

# Check IOMMU status for this device
iommu_enabled=false
iommu_type="none"
if [ -f "/sys/bus/pci/devices/${dev}/iommu_group/type" ]; then
iommu_type=$(cat "/sys/bus/pci/devices/${dev}/iommu_group/type")
[[ "$iommu_type" == *"DMA"* ]] && iommu_enabled=true
fi

if [[ "$device_id" == "$GS_PID" || "$device_id" == "$WH_PID" ]]; then
if [ "$iommu_enabled" = true ]; then
echo " WARNING: Grayskull/Wormhole device with IOMMU enabled (type: $iommu_type) - this configuration is not supported"
else
echo " Grayskull/Wormhole device detected - hugepages required"
fi
elif [[ "$device_id" == "$BH_PID" ]]; then
if [ "$iommu_enabled" = true ]; then
echo " Blackhole device with IOMMU enabled (type: $iommu_type) - hugepages optional"
else
echo " Blackhole device with no IOMMU/passthrough (type: $iommu_type) - hugepages required"
fi
else
echo " Unknown device ID: $device_id"
fi
done

echo -e "\nSummary:"
if [ "$found_gs_wh" = true ]; then
echo "- System has Grayskull/Wormhole devices - hugepages required"
Expand Down

0 comments on commit 5c34e26

Please sign in to comment.