<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Am 21.07.2016 um 13:15 schrieb Wang,
      Qingqing:<br>
    </div>
    <blockquote
cite="mid:SN1PR12MB051120166EEFC6A65C7BB795EC090@SN1PR12MB0511.namprd12.prod.outlook.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
      <div id="divtagdefaultwrapper"
style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
        <div id="divtagdefaultwrapper"
style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
          <p><span style="color: rgb(33, 33, 33); font-size: 15px;">Actually
              that discussion was held long ago internally but we never
              got a conclusion on this IIRC. So we should probably
              continue the discussion on this thread now.</span><br>
          </p>
          <p><font color="#212121"><span style="font-size: 15px;">-there
                is a thread for this topic yesterday, some people are
                not in amd-gfx mail list, we'd better discuss in
                the internal thread.</span></font></p>
        </div>
      </div>
    </blockquote>
    No, exactly for this reason we have the public mailing list. I for
    example wasn't part of the internal thread either.<br>
    <br>
    Christian.<br>
    <br>
    <blockquote
cite="mid:SN1PR12MB051120166EEFC6A65C7BB795EC090@SN1PR12MB0511.namprd12.prod.outlook.com"
      type="cite">
      <div id="divtagdefaultwrapper"
style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
        <div id="divtagdefaultwrapper"
style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;"></div>
        <hr style="display:inline-block;width:98%" tabindex="-1">
        <div id="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> 2016年7月21日 17:48:41<br>
            <b>收件人:</b> Wang, Qingqing; <a class="moz-txt-link-abbreviated" href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><br>
            <b>主题:</b> Re: 答复: [PATCH] drm/amdgpu: adjust gtt memory
            size</font>
          <div> </div>
        </div>
        <div>
          <div class="moz-cite-prefix">Am 21.07.2016 um 11:16 schrieb
            Wang, Qingqing:<br>
          </div>
          <blockquote
cite="mid:SN1PR12MB0511612A271156A2EFC7B449EC090@SN1PR12MB0511.namprd12.prod.outlook.com"
            type="cite">
            <meta name="Generator" content="Microsoft Exchange Server">
            <!-- converted from text -->
            <meta content="text/html; charset=UTF-8">
            <div dir="ltr">
              <div id="x_divtagdefaultwrapper" style="font-size:12pt;
                color:#000000; background-color:#FFFFFF;
                font-family:Calibri,Arial,Helvetica,sans-serif">
                <p><font size="2"><span style="font-size:10pt">This
                      doesn't work on 32bit systems since totalram is a
                      long (IIRC) and
                      <br>
                      so this will certainly overflow.</span></font></p>
                <p>-- can you be more specific, how could the overflow
                  happen?</p>
              </div>
            </div>
          </blockquote>
          <br>
          Both values are 32bit on a 32bit system, so as soon as you
          have more than 4GB installed this will overflow.<br>
          <br>
          You need to cast the long to a 64bit value to avoid that.<br>
          <br>
          <blockquote
cite="mid:SN1PR12MB0511612A271156A2EFC7B449EC090@SN1PR12MB0511.namprd12.prod.outlook.com"
            type="cite">
            <div dir="ltr">
              <div id="x_divtagdefaultwrapper" style="font-size:12pt;
                color:#000000; background-color:#FFFFFF;
                font-family:Calibri,Arial,Helvetica,sans-serif">
                <p><br>
                </p>
                <p><font size="2"><span style="font-size:10pt">Additional
                      if I remember correctly we didn't ended the
                      discussion on
                      <br>
                      what to do here with a conclusion.</span></font></p>
                <p>-- ok, since it happens in anther mail list, we
                  should stop talking about it here, you can send out
                  your ideas there.<br>
                </p>
              </div>
            </div>
          </blockquote>
          <br>
          Actually that discussion was held long ago internally but we
          never got a conclusion on this IIRC. So we should probably
          continue the discussion on this thread now.<br>
          <br>
          Regards,<br>
          Christian.<br>
          <br>
          <blockquote
cite="mid:SN1PR12MB0511612A271156A2EFC7B449EC090@SN1PR12MB0511.namprd12.prod.outlook.com"
            type="cite">
            <div dir="ltr">
              <div id="x_divtagdefaultwrapper" style="font-size:12pt;
                color:#000000; background-color:#FFFFFF;
                font-family:Calibri,Arial,Helvetica,sans-serif">
              </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> amd-gfx
                  <a moz-do-not-send="true"
                    class="moz-txt-link-rfc2396E"
                    href="mailto:amd-gfx-bounces@lists.freedesktop.org">
                    <amd-gfx-bounces@lists.freedesktop.org></a> 代表
                  Christian König <a moz-do-not-send="true"
                    class="moz-txt-link-rfc2396E"
                    href="mailto:deathsimple@vodafone.de">
                    <deathsimple@vodafone.de></a><br>
                  <b>发送时间:</b> 2016年7月21日 16:53:05<br>
                  <b>收件人:</b> Wang, Qingqing; <a moz-do-not-send="true"
                    class="moz-txt-link-abbreviated"
                    href="mailto:amd-gfx@lists.freedesktop.org">
                    amd-gfx@lists.freedesktop.org</a><br>
                  <b>主题:</b> Re: [PATCH] drm/amdgpu: adjust gtt memory
                  size</font>
                <div> </div>
              </div>
            </div>
            <font size="2"><span style="font-size:10pt;">
                <div class="PlainText">Am 21.07.2016 um 09:46 schrieb
                  Ken Wang:<br>
                  > Change-Id:
                  If00d5b97ba9e30f9b7f68fdfc134a0f8b3ad2add<br>
                  > Signed-off-by: Ken Wang <a
                    moz-do-not-send="true" class="moz-txt-link-rfc2396E"
                    href="mailto:Qingqing.Wang@amd.com">
                    <Qingqing.Wang@amd.com></a><br>
                  > ---<br>
                  >   drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 7
                  ++++++-<br>
                  >   drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 7
                  ++++++-<br>
                  >   2 files changed, 12 insertions(+), 2
                  deletions(-)<br>
                  ><br>
                  > diff --git
                  a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
                  b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c<br>
                  > index a3b6048..0b095d5 100644<br>
                  > --- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c<br>
                  > +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c<br>
                  > @@ -336,6 +336,11 @@ static int
                  gmc_v7_0_mc_init(struct amdgpu_device *adev)<br>
                  >   {<br>
                  >        u32 tmp;<br>
                  >        int chansize, numchan;<br>
                  > +     u64 sysmem_size;<br>
                  > +     struct sysinfo si;<br>
                  > +<br>
                  > +     si_meminfo(&si);<br>
                  > +     sysmem_size = si.totalram * si.mem_unit;<br>
                  <br>
                  This doesn't work on 32bit systems since totalram is a
                  long (IIRC) and <br>
                  so this will certainly overflow.<br>
                  <br>
                  Additional if I remember correctly we didn't ended the
                  discussion on <br>
                  what to do here with a conclusion.<br>
                  <br>
                  Regards,<br>
                  Christian.<br>
                  <br>
                  >   <br>
                  >        /* Get VRAM informations */<br>
                  >        tmp = RREG32(mmMC_ARB_RAMCFG);<br>
                  > @@ -392,7 +397,7 @@ static int
                  gmc_v7_0_mc_init(struct amdgpu_device *adev)<br>
                  >         * size equal to the 1024 or vram,
                  whichever is larger.<br>
                  >         */<br>
                  >        if (amdgpu_gart_size == -1)<br>
                  > -             adev->mc.gtt_size = max((1024ULL
                  << 20), adev->mc.mc_vram_size);<br>
                  > +             adev->mc.gtt_size = max((1024ULL
                  << 20), min(adev->mc.mc_vram_size,
                  sysmem_size/2));<br>
                  >        else<br>
                  >                adev->mc.gtt_size =
                  (uint64_t)amdgpu_gart_size << 20;<br>
                  >   <br>
                  > diff --git
                  a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
                  b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c<br>
                  > index 02b6872..790bf7a 100644<br>
                  > --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c<br>
                  > +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c<br>
                  > @@ -413,6 +413,11 @@ static int
                  gmc_v8_0_mc_init(struct amdgpu_device *adev)<br>
                  >   {<br>
                  >        u32 tmp;<br>
                  >        int chansize, numchan;<br>
                  > +     u64 sysmem_size;<br>
                  > +     struct sysinfo si;<br>
                  > +<br>
                  > +     si_meminfo(&si);<br>
                  > +     sysmem_size = si.totalram * si.mem_unit;<br>
                  >   <br>
                  >        /* Get VRAM informations */<br>
                  >        tmp = RREG32(mmMC_ARB_RAMCFG);<br>
                  > @@ -469,7 +474,7 @@ static int
                  gmc_v8_0_mc_init(struct amdgpu_device *adev)<br>
                  >         * size equal to the 1024 or vram,
                  whichever is larger.<br>
                  >         */<br>
                  >        if (amdgpu_gart_size == -1)<br>
                  > -             adev->mc.gtt_size = max((1024ULL
                  << 20), adev->mc.mc_vram_size);<br>
                  > +             adev->mc.gtt_size = max((1024ULL
                  << 20), min(adev->mc.mc_vram_size,
                  sysmem_size/2));<br>
                  >        else<br>
                  >                adev->mc.gtt_size =
                  (uint64_t)amdgpu_gart_size << 20;<br>
                  >   <br>
                  <br>
                  <br>
                  _______________________________________________<br>
                  amd-gfx mailing list<br>
                  <a moz-do-not-send="true"
                    class="moz-txt-link-abbreviated"
                    href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><br>
                  <a moz-do-not-send="true"
                    href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br>
                </div>
              </span></font></blockquote>
          <p><br>
          </p>
        </div>
      </div>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>