<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@SimSun";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:"Courier New";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:1032145320;
        mso-list-type:hybrid;
        mso-list-template-ids:-752715874 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level2
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level3
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level4
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level5
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level6
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level7
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level8
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level9
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l1
        {mso-list-id:1223831205;
        mso-list-type:hybrid;
        mso-list-template-ids:1278141348 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l1:level1
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1:level2
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1:level3
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l1:level4
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1:level5
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1:level6
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l1:level7
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1:level8
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1:level9
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l2
        {mso-list-id:1710110723;
        mso-list-type:hybrid;
        mso-list-template-ids:-489246596 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l2:level1
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l2:level2
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l2:level3
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l2:level4
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l2:level5
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l2:level6
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l2:level7
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l2:level8
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l2:level9
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">Hi,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">We’re working on enabling a new feature called “Local Display Direct Flip” in GVT-g. And we want to use this thread to introduce this feature and discuss the userspace interface.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><b><u>What is the local display direct flip feature?<o:p></o:p></u></b></p>
<p class="MsoNormal">This feature provides vGPUs with the capabilities to control a subset of the local HW display engine resources to display output from a virtualized environment. With this feature, vGPUs can leverage HW display engine's capabilities to compose
 their framebuffers and post the final outputs to the assigned local display monitors.<o:p></o:p></p>
<p class="MsoNormal">Please see <a href="https://lists.freedesktop.org/archives/intel-gvt-dev/2018-December/004559.html">
https://lists.freedesktop.org/archives/intel-gvt-dev/2018-December/004559.html</a> for details.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><b><u>Why the proposed local display direct flip feature is considered more efficient?<o:p></o:p></u></b></p>
<p class="MsoNormal">Currently, GVT-g upstream support local display based on dma-buf. For example, with dma-buf, GTK UI can compose the guest framebuffers and post the final framebuffer to the local display monitor.  Although this dma-buf solution is flexible
 for both local display and remote display, this solution has to involve userspace when the guest framebuffer is updated. And usually, this happens every frame.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Meanwhile, local display direct flip feature doesn’t need to involve userspace for the guest plane update. Userspace just needs to do the assignment once (although the feature supports the dynamic assignment), and planes on the assigned
 pipe can be leveraged by the guest to compose its framebuffers w/o involving host userspace any more. That’s why it’s considered more efficient.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><b><u>The proposed userspace interface:<o:p></o:p></u></b></p>
<p class="MsoNormal">Each plane of the vGPU is exposed as a DRM framebuffer object in the host-side during the vGPU creation. So host userspace can assign the HW display planes to vGPU’s planes by using existing DRM/KMS APIs. After the assignment, host kernel
 can directly help guest to update the information to the display registers of the assigned display resources. However, the only problem is how we return the DRM framebuffer id to host userspace.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Currently, we have two options:<o:p></o:p></p>
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l1 level1 lfo2"><![if !supportLists]><span style="mso-list:Ignore">1.<span style="font:7.0pt "Times New Roman"">      
</span></span><![endif]>Through “/sys/bus/pci/devices/0000:00:02.0/$UUID/intel_vgpu/plane_id_index”<o:p></o:p></p>
<pre style="margin-left:.5in"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">With the proposed “plane_id_index” attribute, userspace can echo the plane number to the attribute and then use cat to dump the userspace id of the DRM framebuffer standing for that vGPU’s plane in the host-side.<o:p></o:p></span></pre>
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l1 level1 lfo2"><![if !supportLists]><span style="mso-list:Ignore">2.<span style="font:7.0pt "Times New Roman"">      
</span></span><![endif]>Through vfio ioctl:<o:p></o:p></p>
<p class="MsoListParagraph">We can extend VFIO_DEVICE_QUERY_GFX_PLANE ABI by proposing “VFIO_GFX_PLANE_TYPE_DRM_FB” type. So that vendor driver can return the framebuffer id when userspace invoking “VFIO_DEVICE_QUERY_GFX_PLANE” ioctl with flags as “VFIO_GFX_PLANE_TYPE_DRM_FB
 | VFIO_GFX_PLANE_TYPE_PROBE”<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The patches are on:<o:p></o:p></p>
<p class="MsoNormal"><a href="https://github.com/intel/igvtg-qemu/tree/topic/local_display_direct_flip">https://github.com/intel/igvtg-qemu/tree/topic/local_display_direct_flip</a><o:p></o:p></p>
<p class="MsoNormal"><a href="https://github.com/intel/gvt-linux/tree/topic/local_display_direct_flip">https://github.com/intel/gvt-linux/tree/topic/local_display_direct_flip</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><b><u>How to try it:<o:p></o:p></u></b></p>
<p class="MsoNormal">Qemu: <a href="https://github.com/intel/igvtg-qemu/tree/topic/local_display_direct_flip">
https://github.com/intel/igvtg-qemu/tree/topic/local_display_direct_flip</a><o:p></o:p></p>
<p class="MsoNormal">Kernel: <a href="https://github.com/intel/gvt-linux/tree/topic/local_display_direct_flip">
https://github.com/intel/gvt-linux/tree/topic/local_display_direct_flip</a><o:p></o:p></p>
<p class="MsoNormal">(Note: these branches include both of the two options of userspace interface and they are live branches as WIP)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The reference boot script:<o:p></o:p></p>
<p class="MsoNormal">-m 4096 -smp 2 -M pc \<o:p></o:p></p>
<p class="MsoNormal">-name kvmgt1 \<o:p></o:p></p>
<p class="MsoNormal">-hda $1 \<o:p></o:p></p>
<p class="MsoNormal">-bios /home/tinazhang/workspace/KVMGT/qemu-upstream/qemu/roms/seabios/out/bios.bin -enable-kvm \<o:p></o:p></p>
<p class="MsoNormal">-net nic,macaddr=00:A1:00:00:00:BD -net tap,script=/etc/qemu-ifup \<o:p></o:p></p>
<p class="MsoNormal">-vga none \<o:p></o:p></p>
<p class="MsoNormal"><b>-display kms \<o:p></o:p></b></p>
<p class="MsoNormal">-k en-us \<o:p></o:p></p>
<p class="MsoNormal">-serial stdio \<o:p></o:p></p>
<p class="MsoNormal">-machine kernel_irqchip=on \<o:p></o:p></p>
<p class="MsoNormal">-global PIIX4_PM.disable_s3=1 -global PIIX4_PM.disable_s4=1 \<o:p></o:p></p>
<p class="MsoNormal">-cpu host   -usb -usbdevice tablet \<o:p></o:p></p>
<p class="MsoNormal">-device vfio-pci,sysfsdev=/sys/bus/pci/devices/0000:00:02.0/$UUID,rombar=0,x-igd-opregion=on,display=on<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><b><u>To-do list:<o:p></o:p></u></b></p>
<p class="MsoNormal">We got kernel-side to-do list here: <a href="https://lists.freedesktop.org/archives/intel-gvt-dev/2018-December/004559.html">
https://lists.freedesktop.org/archives/intel-gvt-dev/2018-December/004559.html</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Besides, here is one for the proposed Qemu KMS UI and hope that one could be interesting.<o:p></o:p></p>
<p class="MsoNormal">To support Mult-VMs pipe assignment by assigning each crtc to a VM:<o:p></o:p></p>
<p class="MsoNormal">The proposed KMS UI can only support one VM pipe assignment, due to the DRM master limitation. However, kernel has supported a feature called DRM-lease (<a href="https://keithp.com/blogs/DRM-lease-2/">https://keithp.com/blogs/DRM-lease-2/</a>).
 And userspace graphics stacks have also implemented this feature. This can solve the DRM master problem by leasing the pipe and its resources to one App which is Qemu in our case.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">BR,<o:p></o:p></p>
<p class="MsoNormal">Tina<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>