<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">
      <blockquote type="cite">
        <p>Do you suggest that rip out of amdgpu_map_csa() routine
          totally,</p>
      </blockquote>
      Yes, mapping the CSA is not something specific to virtualization,
      so we shouldn't put that into amdgpu_virt.c.<br>
      <br>
      <blockquote type="cite">
        <p> and manually call "<span>amdgpu_vm_bo_map</span>" as well as
          "<span>amdgpu_vm_bo_update</span>" in sequence in "<span>amdgpu_vm_bo_update</span>"
          ?</p>
      </blockquote>
      No, during command submission it is to late to allocate the PT.
      Better put this a layer up into amdgpu_driver_open_kms() after the
      VM is initialized.<br>
      <br>
      Regards,<br>
      Christian.<br>
      <br>
      Am 10.01.2017 um 10:53 schrieb Liu, Monk:<br>
    </div>
    <blockquote
cite="mid:BY2PR1201MB1110632E66A596FA820250E584670@BY2PR1201MB1110.namprd12.prod.outlook.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <meta name="Generator" content="Microsoft Exchange Server">
      <!-- converted from text -->
      <style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
      <meta content="text/html; charset=UTF-8">
      <style type="text/css" style="">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
      <div dir="ltr">
        <div id="x_divtagdefaultwrapper" dir="ltr"
          style="font-size:12pt; color:#000000;
          font-family:Calibri,Arial,Helvetica,sans-serif">
          <p>then what about "<span>amdgpu_vm_bo_map</span>" ? we need
            call it first before call "<span>amdgpu_vm_bo_update</span>"
            in "<span>amdgpu_bo_vm_update_pte</span>" , correct ?
            otherwise we even not create PT bo for the CSA ... </p>
          <p><br>
          </p>
          <p>Do you suggest that rip out of amdgpu_map_csa() routine
            totally, and manually call "<span>amdgpu_vm_bo_map</span>"
            as well as "<span>amdgpu_vm_bo_update</span>" in sequence in
            "<span>amdgpu_vm_bo_update</span>" ?</p>
          <p><br>
          </p>
          <p>BR Monk</p>
        </div>
        <hr tabindex="-1" style="display:inline-block; width:98%">
        <div id="x_divRplyFwdMsg" dir="ltr"><font style="font-size:11pt"
            color="#000000" face="Calibri, sans-serif"><b>发件人:</b>
            Christian König <a class="moz-txt-link-rfc2396E" href="mailto:deathsimple@vodafone.de"><deathsimple@vodafone.de></a><br>
            <b>发送时间:</b> 2017年1月10日 17:44:21<br>
            <b>收件人:</b> Liu, Monk; <a class="moz-txt-link-abbreviated" href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><br>
            <b>主题:</b> Re: 答复: [PATCH 7/7] drm/amdgpu:map/unmap static
            csa accordingly</font>
          <div> </div>
        </div>
      </div>
      <font size="2"><span style="font-size:10pt;">
          <div class="PlainText">Adding the BO and it's mapping is VM
            specific code, we should initialize
            <br>
            that directly in amdgpu_vm_init() and not call any helper to
            delegate <br>
            the work.<br>
            <br>
            Especially don't call from the VM code into the virt code
            and back into <br>
            the VM code.<br>
            <br>
            If you really want to keep that in amdgpu_virt. an
            alternative would be <br>
            to put the call into amdgpu_driver_open_kms() directly after
            calling <br>
            amdgpu_vm_init().<br>
            <br>
            Regards,<br>
            Christian.<br>
            <br>
            Am 10.01.2017 um 03:40 schrieb Liu, Monk:<br>
            ><br>
            > why you want to drop that "adev->virt.map_csa()"
            calling ?  without <br>
            > that calling you don't have CSA's initialized bo_va and
            mappings as <br>
            > well, and without bo_va and mappings how you can make <br>
            > "amdgpu_vm_bo_update()" invoke work ?<br>
            ><br>
            ><br>
            > Monk<br>
            ><br>
            >
            ------------------------------------------------------------------------<br>
            > *发件人:* Christian König <a class="moz-txt-link-rfc2396E" href="mailto:deathsimple@vodafone.de"><deathsimple@vodafone.de></a><br>
            > *发送时间:* 2017年1月9日 19:04:44<br>
            > *收件人:* Liu, Monk; <a class="moz-txt-link-abbreviated" href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><br>
            > *主题:* Re: [PATCH 7/7] drm/amdgpu:map/unmap static csa
            accordingly<br>
            > Am 09.01.2017 um 09:03 schrieb Monk Liu:<br>
            > > and update CSA bo_va in each submit<br>
            > ><br>
            > > Change-Id:
            I5ed73e1b7f89743d90298bc814a42a91e166be3b<br>
            > > Signed-off-by: Monk Liu <a class="moz-txt-link-rfc2396E" href="mailto:Monk.Liu@amd.com"><Monk.Liu@amd.com></a><br>
            > > ---<br>
            > >   drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 14
            ++++++++++++++<br>
            > >   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 11
            +++++++++++<br>
            > >   2 files changed, 25 insertions(+)<br>
            > ><br>
            > > diff --git
            a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c <br>
            > b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c<br>
            > > index 6159afc..083ab73 100644<br>
            > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c<br>
            > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c<br>
            > > @@ -771,6 +771,20 @@ static int
            amdgpu_bo_vm_update_pte(struct <br>
            > amdgpu_cs_parser *p,<br>
            > >        if (r)<br>
            > >                return r;<br>
            > ><br>
            > > +     if (amdgpu_sriov_vf(adev)) {<br>
            > > +             struct fence *f;<br>
            ><br>
            > A new line is needed between deceleration and code.<br>
            ><br>
            > > +             bo_va = vm->vm_virt.csa_bo_va;<br>
            > > +             BUG_ON(!bo_va);<br>
            > > +             r = amdgpu_vm_bo_update(adev, bo_va,
            false);<br>
            > > +             if (r)<br>
            > > +                     return r;<br>
            > > +<br>
            > > +             f = bo_va->last_pt_update;<br>
            > > +             r = amdgpu_sync_fence(adev,
            &p->job->sync, f);<br>
            > > +             if (r)<br>
            > > +                     return r;<br>
            > > +     }<br>
            > > +<br>
            > >        if (p->bo_list) {<br>
            > >                for (i = 0; i <
            p->bo_list->num_entries; i++) {<br>
            > >                        struct fence *f;<br>
            > > diff --git
            a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c <br>
            > b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
            > > index d05546e..b9cd686 100644<br>
            > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
            > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
            > > @@ -1576,6 +1576,14 @@ int amdgpu_vm_init(struct
            amdgpu_device <br>
            > *adev, struct amdgpu_vm *vm)<br>
            > >        vm->last_eviction_counter =
            atomic64_read(&adev->num_evictions);<br>
            > >        amdgpu_bo_unreserve(vm->page_directory);<br>
            > ><br>
            > > +     if (amdgpu_sriov_vf(adev)) {<br>
            > > +             BUG_ON(!adev->virt.map_csa);<br>
            > > +             BUG_ON(!adev->virt.unmap_csa);<br>
            > > +             r = adev->virt.map_csa(adev, vm);<br>
            > > +             if (r)<br>
            > > +                     goto
            error_free_page_directory;<br>
            > > +     }<br>
            > > +<br>
            ><br>
            > Just completely drop that. Updating the VM on the first
            command<br>
            > submission should be sufficient.<br>
            ><br>
            > Christian.<br>
            ><br>
            > >        return 0;<br>
            > ><br>
            > >   error_free_page_directory:<br>
            > > @@ -1606,6 +1614,9 @@ void amdgpu_vm_fini(struct
            amdgpu_device <br>
            > *adev, struct amdgpu_vm *vm)<br>
            > >        struct amdgpu_bo_va_mapping *mapping, *tmp;<br>
            > >        int i;<br>
            > ><br>
            > > +     if (amdgpu_sriov_vf(adev))<br>
            > > +             adev->virt.unmap_csa(adev, vm);<br>
            > > +<br>
            > >        amd_sched_entity_fini(vm->entity.sched,
            &vm->entity);<br>
            > ><br>
            > >        if (!RB_EMPTY_ROOT(&vm->va)) {<br>
            ><br>
            ><br>
            <br>
          </div>
        </span></font>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>