From d0beb7e9a0541a3882ae95208df5b107b4703a62 Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Tue, 14 Apr 2020 14:09:01 +0800 Subject: [PATCH] acrn-config: support passthroug GVT for WaaG by default Modify launch config tool to support passthroug GVT for WaaG by default. Tracked-On: #4625 Signed-off-by: Wei Liu Acked-by: Victor Sun Acked-by: Terry Zou --- misc/acrn-config/launch_config/com.py | 26 ++++++++++++++----- misc/acrn-config/launch_config/pt.py | 14 ++++++++-- misc/acrn-config/library/launch_cfg_lib.py | 11 ++++++++ .../industry_launch_1uos_hardrt.xml | 2 +- .../industry_launch_1uos_vxworks.xml | 2 +- .../whl-ipc-i5/industry_launch_1uos_waag.xml | 2 +- .../whl-ipc-i5/industry_launch_2uos.xml | 4 +-- .../whl-ipc-i5/sdc_launch_1uos_laag.xml | 2 +- .../whl-ipc-i5/sdc_launch_1uos_zephyr.xml | 2 +- .../industry_launch_1uos_hardrt.xml | 2 +- .../industry_launch_1uos_vxworks.xml | 2 +- .../whl-ipc-i7/industry_launch_1uos_waag.xml | 2 +- .../whl-ipc-i7/industry_launch_2uos.xml | 4 +-- .../whl-ipc-i7/sdc_launch_1uos_laag.xml | 2 +- .../whl-ipc-i7/sdc_launch_1uos_zephyr.xml | 2 +- 15 files changed, 57 insertions(+), 22 deletions(-) diff --git a/misc/acrn-config/launch_config/com.py b/misc/acrn-config/launch_config/com.py index 354dbf0d3..68a7227d3 100644 --- a/misc/acrn-config/launch_config/com.py +++ b/misc/acrn-config/launch_config/com.py @@ -231,7 +231,12 @@ def gvt_arg_set(dm, vmid, uos_type, config): if uos_type not in ('CLEARLINUX', 'ANDROID', 'ALIOS', 'WINDOWS'): return gvt_args = dm['gvt_args'][vmid] - if gvt_args: + if gvt_args == "gvtd": + bus = int(launch_cfg_lib.GPU_BDF.split(':')[0], 16) + dev = int(launch_cfg_lib.GPU_BDF.split('.')[0].split(':')[1], 16) + fun = int(launch_cfg_lib.GPU_BDF.split('.')[1], 16) + print(' -s 2,passthru,{}/{}/{},gpu \\'.format(bus, dev, fun), file=config) + elif gvt_args: print(' -s 2,pci-gvt -G "$2" \\', file=config) @@ -318,17 +323,26 @@ def uos_launch(names, args, virt_io, vmid, config): print("fi", file=config) else: print("else", file=config) - print(' launch_{} 1 "{}"'.format(launch_uos, gvt_args), file=config) + if gvt_args == "gvtd": + print(' launch_{} 1'.format(launch_uos), file=config) + elif gvt_args: + print(' launch_{} 1 "{}"'.format(launch_uos, gvt_args), file=config) print("fi", file=config) else: if uos_type in ("VXWORKS", "PREEMPT-RT LINUX", "ZEPHYR"): print("launch_{} 1".format(launch_uos), file=config) if uos_type in ("CLEARLINUX", "WINDOWS"): - print('launch_{} 1 "{}"'.format(launch_uos, gvt_args), file=config) + if gvt_args == "gvtd": + print('launch_{} 1'.format(launch_uos), file=config) + else: + print('launch_{} 1 "{}"'.format(launch_uos, gvt_args), file=config) if is_mount_needed(virt_io, vmid): print("", file=config) - print('launch_{} {} "{}" "{}" $debug'.format(launch_uos, vmid, gvt_args, vmid), file=config) + if gvt_args == "gvtd": + print('launch_{} {} "{}" $debug'.format(launch_uos, vmid, vmid), file=config) + else: + print('launch_{} {} "{}" "{}" $debug'.format(launch_uos, vmid, gvt_args, vmid), file=config) print("", file=config) i = 0 @@ -603,14 +617,14 @@ def gen(names, pt_sel, virt_io, dm, vmid, config): uos_type = names['uos_types'][vmid] # passthrough bdf/vpid dictionay - pt.gen_pt_head(names, pt_sel, vmid, config) + pt.gen_pt_head(names, dm, pt_sel, vmid, config) # gen launch header launch_begin(names, virt_io, vmid, config) tap_uos_net(names, virt_io, vmid, config) # passthrough device - pt.gen_pt(names, pt_sel, vmid, config) + pt.gen_pt(names, dm, pt_sel, vmid, config) wa_usage(uos_type, config) delay_use_usb_storage(uos_type, config) mem_size_set(dm, vmid, config) diff --git a/misc/acrn-config/launch_config/pt.py b/misc/acrn-config/launch_config/pt.py index d07e78bea..3df11a94c 100644 --- a/misc/acrn-config/launch_config/pt.py +++ b/misc/acrn-config/launch_config/pt.py @@ -200,7 +200,7 @@ def media_pt(uos_type, sel, vmid, config): audio_pt(uos_type, sel, vmid, config) -def gen_pt(names, sel, vmid, config): +def gen_pt(names, dm, sel, vmid, config): pt_none = True cap_pt = launch_cfg_lib.get_pt_dev() @@ -212,6 +212,11 @@ def gen_pt(names, sel, vmid, config): return print("modprobe pci_stub", file=config) + # pass thru GPU + if dm['gvt_args'][vmid] == "gvtd": + print('echo ${passthru_vpid["gpu"]} > /sys/bus/pci/drivers/pci-stub/new_id', file=config) + print('echo ${passthru_bdf["gpu"]} > /sys/bus/pci/devices/${passthru_bdf["gpu"]}/driver/unbind', file=config) + print('echo ${passthru_bdf["gpu"]} > /sys/bus/pci/drivers/pci-stub/bind', file=config) for pt_dev in cap_pt: if pt_dev not in MEDIA_DEV: pass_through_dev(sel, pt_dev, vmid, config) @@ -219,7 +224,7 @@ def gen_pt(names, sel, vmid, config): media_pt(uos_type, sel, vmid, config) -def gen_pt_head(names, sel, vmid, config): +def gen_pt_head(names, dm, sel, vmid, config): cap_pt = launch_cfg_lib.get_pt_dev() uos_type = names['uos_types'][vmid] @@ -240,6 +245,9 @@ def gen_pt_head(names, sel, vmid, config): for pt_dev in cap_pt: if not sel.vpid[pt_dev] or not sel.vpid[pt_dev][vmid]: continue + if dm['gvt_args'][vmid] == "gvtd": + gpu_vpid = launch_cfg_lib.get_gpu_vpid() + print('["gpu"]="{}"'.format(gpu_vpid), file=config) print('["{}"]="{}"'.format(pt_dev, sel.vpid[pt_dev][vmid]), file=config) print(')', file=config) @@ -247,6 +255,8 @@ def gen_pt_head(names, sel, vmid, config): for pt_dev in cap_pt: if not sel.bdf[pt_dev] or not sel.bdf[pt_dev][vmid]: continue + if dm['gvt_args'][vmid] == "gvtd": + print('["gpu"]="0000:{}"'.format(launch_cfg_lib.GPU_BDF), file=config) print('["{}"]="0000:{}"'.format(pt_dev, sel.bdf[pt_dev][vmid]), file=config) print(')', file=config) diff --git a/misc/acrn-config/library/launch_cfg_lib.py b/misc/acrn-config/library/launch_cfg_lib.py index 66fa474bf..cfcf103e1 100644 --- a/misc/acrn-config/library/launch_cfg_lib.py +++ b/misc/acrn-config/library/launch_cfg_lib.py @@ -54,6 +54,7 @@ PM_CHANNEL_DIC = { } MOUNT_FLAG_DIC = {} +GPU_BDF = "00:02.0" def usage(file_name): @@ -548,3 +549,13 @@ def bdf_duplicate_check(bdf_dic): return else: bdf_used.append(dev_bdf) + + +def get_gpu_vpid(): + + vpid = '' + vpid_lines = board_cfg_lib.get_info(common.BOARD_INFO_FILE, "", "") + for vpid_line in vpid_lines: + if GPU_BDF in vpid_line: + vpid = vpid_line.split()[2] + return vpid diff --git a/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_1uos_hardrt.xml b/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_1uos_hardrt.xml index 867013846..c4d91f6be 100644 --- a/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_1uos_hardrt.xml +++ b/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_1uos_hardrt.xml @@ -3,7 +3,7 @@ PREEMPT-RT LINUX Hard RT 1024 - + ovmf Disable Disabled diff --git a/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_1uos_vxworks.xml b/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_1uos_vxworks.xml index 46713d880..cda8d07f8 100644 --- a/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_1uos_vxworks.xml +++ b/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_1uos_vxworks.xml @@ -3,7 +3,7 @@ VXWORKS Hard RT 2048 - + ovmf Disable Disabled diff --git a/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_1uos_waag.xml b/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_1uos_waag.xml index c28f06a4e..eec825960 100644 --- a/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_1uos_waag.xml +++ b/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_1uos_waag.xml @@ -3,7 +3,7 @@ WINDOWS no 4096 - 64 448 8 + gvtd ovmf Enable Disabled diff --git a/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_2uos.xml b/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_2uos.xml index 62bb4047f..1576591a9 100644 --- a/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_2uos.xml +++ b/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/industry_launch_2uos.xml @@ -3,7 +3,7 @@ WINDOWS no 4096 - 64 448 8 + gvtd ovmf Enable Disabled @@ -37,7 +37,7 @@ PREEMPT-RT LINUX Hard RT 1024 - + ovmf Disable Disabled diff --git a/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/sdc_launch_1uos_laag.xml b/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/sdc_launch_1uos_laag.xml index c65b5d1db..2854ee971 100644 --- a/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/sdc_launch_1uos_laag.xml +++ b/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/sdc_launch_1uos_laag.xml @@ -3,7 +3,7 @@ CLEARLINUX no 2048 - 64 448 8 + 64 448 8 ovmf Disable Disabled diff --git a/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/sdc_launch_1uos_zephyr.xml b/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/sdc_launch_1uos_zephyr.xml index 9117a7bce..938e999d4 100644 --- a/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/sdc_launch_1uos_zephyr.xml +++ b/misc/acrn-config/xmls/config-xmls/whl-ipc-i5/sdc_launch_1uos_zephyr.xml @@ -3,7 +3,7 @@ ZEPHYR no 128 - + ovmf Enable Disabled diff --git a/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_1uos_hardrt.xml b/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_1uos_hardrt.xml index c705d33c7..d60a33020 100644 --- a/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_1uos_hardrt.xml +++ b/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_1uos_hardrt.xml @@ -3,7 +3,7 @@ PREEMPT-RT LINUX Hard RT 1024 - + ovmf Disable Disabled diff --git a/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_1uos_vxworks.xml b/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_1uos_vxworks.xml index e4c808314..cc5c51660 100644 --- a/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_1uos_vxworks.xml +++ b/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_1uos_vxworks.xml @@ -3,7 +3,7 @@ VXWORKS Hard RT 2048 - + ovmf Disable Disabled diff --git a/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_1uos_waag.xml b/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_1uos_waag.xml index a0182ac50..8a184b1d9 100644 --- a/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_1uos_waag.xml +++ b/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_1uos_waag.xml @@ -3,7 +3,7 @@ WINDOWS no 4096 - 64 448 8 + gvtd ovmf Enable Disabled diff --git a/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_2uos.xml b/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_2uos.xml index 3a65c2ba3..63496032e 100644 --- a/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_2uos.xml +++ b/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/industry_launch_2uos.xml @@ -3,7 +3,7 @@ WINDOWS no 4096 - 64 448 8 + gvtd ovmf Enable Disabled @@ -37,7 +37,7 @@ PREEMPT-RT LINUX Hard RT 1024 - + ovmf Disable Disabled diff --git a/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/sdc_launch_1uos_laag.xml b/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/sdc_launch_1uos_laag.xml index 9a85de413..9e526d588 100644 --- a/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/sdc_launch_1uos_laag.xml +++ b/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/sdc_launch_1uos_laag.xml @@ -3,7 +3,7 @@ CLEARLINUX no 2048 - 64 448 8 + 64 448 8 ovmf Disable Disabled diff --git a/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/sdc_launch_1uos_zephyr.xml b/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/sdc_launch_1uos_zephyr.xml index 9a620ed22..040d27ea0 100644 --- a/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/sdc_launch_1uos_zephyr.xml +++ b/misc/acrn-config/xmls/config-xmls/whl-ipc-i7/sdc_launch_1uos_zephyr.xml @@ -3,7 +3,7 @@ ZEPHYR no 128 - + ovmf Enable Disabled