@@ -205,36 +205,32 @@ def gen_pt(names, dm, sel, vmid, config):
205
205
pt_none = True
206
206
cap_pt = launch_cfg_lib .get_pt_dev ()
207
207
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
+
208
215
for pt_dev in cap_pt :
209
216
if sel .bdf [pt_dev ][vmid ]:
210
217
pt_none = False
211
218
if pt_none :
212
219
return
213
220
214
221
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 )
220
222
for pt_dev in cap_pt :
221
223
if pt_dev not in MEDIA_DEV :
222
224
pass_through_dev (sel , pt_dev , vmid , config )
223
225
continue
224
226
225
227
media_pt (uos_type , sel , vmid , config )
226
228
229
+
227
230
def gen_pt_head (names , dm , sel , vmid , config ):
228
231
229
232
cap_pt = launch_cfg_lib .get_pt_dev ()
230
233
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
238
234
239
235
print ("# pci devices for passthru" , file = config )
240
236
print ("declare -A passthru_vpid" , file = config )
@@ -245,19 +241,19 @@ def gen_pt_head(names, dm, sel, vmid, config):
245
241
for pt_dev in cap_pt :
246
242
if not sel .vpid [pt_dev ] or not sel .vpid [pt_dev ][vmid ]:
247
243
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 )
251
244
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 )
252
248
print (')' , file = config )
253
249
254
250
print ("passthru_bdf=(" , file = config )
255
251
for pt_dev in cap_pt :
256
252
if not sel .bdf [pt_dev ] or not sel .bdf [pt_dev ][vmid ]:
257
253
continue
258
- if dm ['gvt_args' ][vmid ] == "gvtd" :
259
- print ('["gpu"]="0000:{}"' .format (launch_cfg_lib .GPU_BDF ), file = config )
260
254
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 )
261
257
print (')' , file = config )
262
258
263
259
print ("" , file = config )
0 commit comments