Skip to content

Commit 099caed

Browse files
Stela contributorclaude
andcommitted
fix(vfio): open every IOMMU group of the lent slot to QEMU
A Radeon's HDMI audio function sits in an IOMMU group of its own on some boards (B550M: 07:00.0 in 18, 07:00.1 in 19); only the card's group was given to the user, and QEMU could not open the other. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent f0cbbab commit 099caed

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

‎xtask/scripts/vfio-gpu.sh‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ restore() {
132132
local function console
133133
set +e
134134
for function in "${members[@]}"; do release "$function"; done
135-
[[ -e /dev/vfio/$group ]] && chown root:root "/dev/vfio/$group"
135+
for group in "${groups[@]}"; do
136+
[[ -e /dev/vfio/$group ]] && chown root:root "/dev/vfio/$group"
137+
done
136138
if ((nvidia)); then
137139
modprobe nvidia_drm
138140
modprobe nvidia_uvm
@@ -167,7 +169,13 @@ run() {
167169
local card
168170
card=$(gpu)
169171
mapfile -t members < <(functions "$card")
170-
group=$(basename "$(readlink "$devices/$card/iommu_group")")
172+
# The functions of a slot may sit in IOMMU groups of their own (a
173+
# Radeon's HDMI audio does on some boards): QEMU opens each.
174+
groups=()
175+
local member
176+
for member in "${members[@]}"; do
177+
groups+=("$(basename "$(readlink "$devices/$member/iommu_group")")")
178+
done
171179
stopped=0
172180
nvidia=0
173181
trap restore EXIT
@@ -187,7 +195,7 @@ run() {
187195
esac
188196
local function
189197
for function in "${members[@]}"; do bind "$function"; done
190-
chown "$owner" "/dev/vfio/$group"
198+
for group in "${groups[@]}"; do chown "$owner" "/dev/vfio/$group"; done
191199
ulimit -l unlimited
192200
local code=0
193201
# Stopping the service ends the command too: first let the card write no

0 commit comments

Comments
 (0)