<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    Yeah, that's a good point.<br>
    <br>
    If build_bug_on() doesn't works for some reason then we at least
    need to lower this to a WARN_ON.<br>
    <br>
    A BUG_ON() is only justified if we prevent strong data corruption
    with it or note a NULL pointer earlier on or similar.<br>
    <br>
    Regards,<br>
    Christian.<br>
    <br>
    <div class="moz-cite-prefix">Am 10.09.21 um 06:36 schrieb Pan,
      Xinhui:<br>
    </div>
    <blockquote type="cite" cite="mid:DM4PR12MB5165EC993C7CF4413D52925E87D69@DM4PR12MB5165.namprd12.prod.outlook.com">
      
      <p style="font-family:Arial;font-size:10pt;color:#0000FF;margin:5pt;" align="Left">
        [AMD Official Use Only]<br>
      </p>
      <br>
      <div>
        <div dir="auto" style="direction: ltr; margin: 0; padding: 0;
          font-family: sans-serif; font-size: 11pt; color: black; ">
          looks good to me.<br>
        </div>
        <div dir="auto" style="direction: ltr; margin: 0; padding: 0;
          font-family: sans-serif; font-size: 11pt; color: black; ">
        </div>
        <div dir="auto" style="direction: ltr; margin: 0px; padding:
          0px; font-family: sans-serif; font-size: 11pt; color: black;
          text-align: left;">
          But maybe build_bug_on works too and more reasonable to detect
          such wrong usage.</div>
        <hr style="display:inline-block;width:98%" tabindex="-1">
        <div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b>
            Chen, Guchun <a class="moz-txt-link-rfc2396E" href="mailto:Guchun.Chen@amd.com"><Guchun.Chen@amd.com></a><br>
            <b>Sent:</b> Friday, September 10, 2021 12:30:14 PM<br>
            <b>To:</b> <a class="moz-txt-link-abbreviated" href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a>
            <a class="moz-txt-link-rfc2396E" href="mailto:amd-gfx@lists.freedesktop.org"><amd-gfx@lists.freedesktop.org></a>;
            <a class="moz-txt-link-abbreviated" href="mailto:dri-devel@lists.freedesktop.org">dri-devel@lists.freedesktop.org</a>
            <a class="moz-txt-link-rfc2396E" href="mailto:dri-devel@lists.freedesktop.org"><dri-devel@lists.freedesktop.org></a>; Koenig, Christian
            <a class="moz-txt-link-rfc2396E" href="mailto:Christian.Koenig@amd.com"><Christian.Koenig@amd.com></a>; Pan, Xinhui
            <a class="moz-txt-link-rfc2396E" href="mailto:Xinhui.Pan@amd.com"><Xinhui.Pan@amd.com></a>; Deucher, Alexander
            <a class="moz-txt-link-rfc2396E" href="mailto:Alexander.Deucher@amd.com"><Alexander.Deucher@amd.com></a><br>
            <b>Cc:</b> Chen, Guchun <a class="moz-txt-link-rfc2396E" href="mailto:Guchun.Chen@amd.com"><Guchun.Chen@amd.com></a>; Shi,
            Leslie <a class="moz-txt-link-rfc2396E" href="mailto:Yuliang.Shi@amd.com"><Yuliang.Shi@amd.com></a><br>
            <b>Subject:</b> [PATCH] drm/ttm: add a BUG_ON in
            ttm_set_driver_manager when array bounds</font>
          <div> </div>
        </div>
        <div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
              <div class="PlainText">Vendor will define their own memory
                types on top of TTM_PL_PRIV,<br>
                but call ttm_set_driver_manager directly without
                checking mem_type<br>
                value when setting up memory manager. So add such check
                to aware<br>
                the case when array bounds.<br>
                <br>
                Signed-off-by: Leslie Shi <a class="moz-txt-link-rfc2396E" href="mailto:Yuliang.Shi@amd.com"><Yuliang.Shi@amd.com></a><br>
                Signed-off-by: Guchun Chen <a class="moz-txt-link-rfc2396E" href="mailto:guchun.chen@amd.com"><guchun.chen@amd.com></a><br>
                ---<br>
                 include/drm/ttm/ttm_device.h | 1 +<br>
                 1 file changed, 1 insertion(+)<br>
                <br>
                diff --git a/include/drm/ttm/ttm_device.h
                b/include/drm/ttm/ttm_device.h<br>
                index 7a0f561c57ee..24ad76ca8022 100644<br>
                --- a/include/drm/ttm/ttm_device.h<br>
                +++ b/include/drm/ttm/ttm_device.h<br>
                @@ -308,6 +308,7 @@ ttm_manager_type(struct ttm_device
                *bdev, int mem_type)<br>
                 static inline void ttm_set_driver_manager(struct
                ttm_device *bdev, int type,<br>
                                                           struct
                ttm_resource_manager *manager)<br>
                 {<br>
                +       BUG_ON(type >= TTM_NUM_MEM_TYPES);<br>
                         bdev->man_drv[type] = manager;<br>
                 }<br>
                 <br>
                -- <br>
                2.17.1<br>
                <br>
              </div>
            </span></font></div>
      </div>
    </blockquote>
    <br>
  </body>
</html>