<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">On 09/18/2017 09:24 PM, Wuzongyong
      (Euler Dept) wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:9BD73EA91F8E404F851CF3F519B14AA8016BDE4A@dggemi501-mbs.china.huawei.com">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
      <style><!--
/* Font Definitions */
@font-face
        {font-family:\5B8B\4F53;
        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:"\@\5B8B\4F53";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        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;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
        {page:WordSection1;}
--></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]-->
      <div class="WordSection1">
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">Hi,<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">In
            function virPCIDeviceIsBehindSwitchLackingACS, I noticed
            that(line 8):<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">1   
            if (virPCIDeviceGetParent(dev, &parent) < 0)<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">2       
            return -1;<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">3   
            if (!parent) {<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">4       
            /* if we have no parent, and this is the root bus, ACS
            doesn't come<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">5        
            * into play since devices on the root bus can't P2P without
            going<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">6        
            * through the root IOMMU.<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">7        
            */<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">8       
            if (dev->address.bus == 0) {<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">9           
            return 0;<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">10       
            } else {<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">11           
            virReportError(VIR_ERR_INTERNAL_ERROR,<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">12      
                                _("Failed to find parent device for
            %s"),<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">13                          
            dev->name);<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">14           
            return -1;<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">15       
            }<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">16   
            }<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">Why
            we just return 0 only if device’s bus is 0?<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">In
            my server, I can see a root bus which bus number is greater
            than 0, see the
            <o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">results(just
            a part) after I run lspci -t:<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">+-[0000:80]-+-02.0-[81-83]--+-00.0<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">|          
            |               \-00.1<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">|          
            +-05.0<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">|          
            +-05.1<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">|          
            +-05.2<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">|          
            \-05.4<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">+-[0000:7f]-+-08.0<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">|          
            +-08.2<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">|          
            +-08.3<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">|          
            + . . .<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">|          
            \-1f.2<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">\-[0000:00]-+-00.0<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">            
            +-01.0-[01]----00.0<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">            
            +-02.0-[02]--+-00.0<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">            
            |            +-00.1<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">            
            |            +-00.2<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">            
            |            \-00.3<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">            
            +-02.2-[03]--<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">            
            +-03.0-[04-0b]----00.0-[05-0b]--+-08.0-[06-08]----00.0<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">            
            |                               \-10.0-[09-0b]----00.0<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">            
            +-05.0<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">            
            +-05.1<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">            
            +-05.2<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">            
            +-05.4<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">            
            +-11.0<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">            
            +-11.4<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">            
            +-16.0<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">            
            +-16.1<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">            
            +-1a.0<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">If
            I assign the device 0000:81:00.0 to a VM, I get “Failed to
            find parent device”.<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">I
            think I should get no error with return value 0 just like
            bus number is 0, because<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">bus
            80 is the root bus as well in my case.<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">In
            the <<Intel C610 Series Chipset and Intel X99 Chipset
            Platform Controller Hub(PCH)>><o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">Datasheet,
            I found that(Chapter 9.1):<o:p></o:p></span></p>
        <p class="MsoNormal" style="text-indent:33.0pt"><span
            style="font-size:14.0pt;font-family:"Courier New"">For
            some server platforms, it may be desirable to have multiple
            PCHs in the system<o:p></o:p></span></p>
        <p class="MsoNormal" style="text-indent:33.0pt"><span
            style="font-size:14.0pt;font-family:"Courier New"">Which
            means some PCH’s may reside on a bus greater than 0.<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:14.0pt;font-family:"Courier New"">So,
            is this a bug?</span></p>
      </div>
    </blockquote>
    <br>
    My memory is that if you're using VFIO for device assignment, all
    that checking should be performed by VFIO, and libvirt shouldn't be
    checking for ACS at all. (Alex, can you confirm or refute this?)<br>
    <br>
    virPCIDeviceIsBehindSwitchLackingACS() is only called from
    virPCIDeviceIsAssignable(), and that function is only called if the
    device's stubDriver is set to something other than "vfio-pci" (see
    step 1 in virHostdevPreparePCIDevices()). Digging deeper, it looks
    like the device's stubDriver is set by
    virHostdevGetPCIHostDeviceList(), which appears to set it to
    vfio-pci if the backend is specified as vfio (i.e. <driver
    name='vfio'/> in the libvirt XML. This *should* be the default
    setting!)<br>
    <br>
    Since I assume you're not using RHEL6, meaning that you will be
    using VFIO by default, not legacy KVM assignment.<br>
    <br>
    TL;DR I think the bug here is that the ...CheckACS function is being
    called *at all*. That code path should be completely obsolete.<br>
    <br>
  </body>
</html>