Skip to content

Commit fc3b4ed

Browse files
Wei Liuwenlingz
authored andcommitted
acrn-config: refine GPU vpid format for launch script
Refine GPU vpid format for launch script. Tracked-On: #4641 Signed-off-by: Wei Liu <weix.w.liu@intel.com> Acked-by: Victor Sun <victor.sun@intel.com>
1 parent d17076b commit fc3b4ed

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

misc/acrn-config/launch_config/pt.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -205,36 +205,32 @@ def gen_pt(names, dm, sel, vmid, config):
205205
pt_none = True
206206
cap_pt = launch_cfg_lib.get_pt_dev()
207207
uos_type = names['uos_types'][vmid]
208+
209+
# pass thru GPU
210+
if dm['gvt_args'][vmid] == "gvtd":
211+
print('echo ${passthru_vpid["gpu"]} > /sys/bus/pci/drivers/pci-stub/new_id', file=config)
212+
print('echo ${passthru_bdf["gpu"]} > /sys/bus/pci/devices/${passthru_bdf["gpu"]}/driver/unbind', file=config)
213+
print('echo ${passthru_bdf["gpu"]} > /sys/bus/pci/drivers/pci-stub/bind', file=config)
214+
208215
for pt_dev in cap_pt:
209216
if sel.bdf[pt_dev][vmid]:
210217
pt_none = False
211218
if pt_none:
212219
return
213220

214221
print("modprobe pci_stub", file=config)
215-
# pass thru GPU
216-
if dm['gvt_args'][vmid] == "gvtd":
217-
print('echo ${passthru_vpid["gpu"]} > /sys/bus/pci/drivers/pci-stub/new_id', file=config)
218-
print('echo ${passthru_bdf["gpu"]} > /sys/bus/pci/devices/${passthru_bdf["gpu"]}/driver/unbind', file=config)
219-
print('echo ${passthru_bdf["gpu"]} > /sys/bus/pci/drivers/pci-stub/bind', file=config)
220222
for pt_dev in cap_pt:
221223
if pt_dev not in MEDIA_DEV:
222224
pass_through_dev(sel, pt_dev, vmid, config)
223225
continue
224226

225227
media_pt(uos_type, sel, vmid, config)
226228

229+
227230
def gen_pt_head(names, dm, sel, vmid, config):
228231

229232
cap_pt = launch_cfg_lib.get_pt_dev()
230233
uos_type = names['uos_types'][vmid]
231-
pt_none = True
232-
233-
for pt_dev in cap_pt:
234-
if sel.bdf[pt_dev][vmid]:
235-
pt_none = False
236-
if pt_none:
237-
return
238234

239235
print("# pci devices for passthru", file=config)
240236
print("declare -A passthru_vpid", file=config)
@@ -245,19 +241,19 @@ def gen_pt_head(names, dm, sel, vmid, config):
245241
for pt_dev in cap_pt:
246242
if not sel.vpid[pt_dev] or not sel.vpid[pt_dev][vmid]:
247243
continue
248-
if dm['gvt_args'][vmid] == "gvtd":
249-
gpu_vpid = launch_cfg_lib.get_gpu_vpid()
250-
print('["gpu"]="{}"'.format(gpu_vpid), file=config)
251244
print('["{}"]="{}"'.format(pt_dev, sel.vpid[pt_dev][vmid]), file=config)
245+
if dm['gvt_args'][vmid] == "gvtd":
246+
gpu_vpid = launch_cfg_lib.get_gpu_vpid()
247+
print('["gpu"]="{}"'.format(gpu_vpid), file=config)
252248
print(')', file=config)
253249

254250
print("passthru_bdf=(", file=config)
255251
for pt_dev in cap_pt:
256252
if not sel.bdf[pt_dev] or not sel.bdf[pt_dev][vmid]:
257253
continue
258-
if dm['gvt_args'][vmid] == "gvtd":
259-
print('["gpu"]="0000:{}"'.format(launch_cfg_lib.GPU_BDF), file=config)
260254
print('["{}"]="0000:{}"'.format(pt_dev, sel.bdf[pt_dev][vmid]), file=config)
255+
if dm['gvt_args'][vmid] == "gvtd":
256+
print('["gpu"]="0000:{}"'.format(launch_cfg_lib.GPU_BDF), file=config)
261257
print(')', file=config)
262258

263259
print("", file=config)

misc/acrn-config/library/launch_cfg_lib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,5 +554,5 @@ def get_gpu_vpid():
554554
vpid_lines = board_cfg_lib.get_info(common.BOARD_INFO_FILE, "<PCI_VID_PID>", "</PCI_VID_PID>")
555555
for vpid_line in vpid_lines:
556556
if GPU_BDF in vpid_line:
557-
vpid = vpid_line.split()[2]
557+
vpid = " ".join(vpid_line.split()[2].split(':'))
558558
return vpid

0 commit comments

Comments
 (0)