<div dir="auto">int p = -1.<div dir="auto">unsigned u = p;</div><div dir="auto">int p2 = u;</div><div dir="auto"><br></div><div dir="auto">p2 is -1.</div><div dir="auto"><br></div><div dir="auto">Marek</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jan 9, 2024, 03:26 Christian König <<a href="mailto:christian.koenig@amd.com">christian.koenig@amd.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u>

  
  <div>
    Am 09.01.24 um 09:09 schrieb 李真能:<br>
    <blockquote type="cite">
      
      <p>Thanks!</p>
      <p>What about the second patch?</p>
      <p>The second patch:   amdgpu: change proirity value to be
        consistent with kernel.</p>
      <p>As I want to pass AMDGPU_CTX_PRIORITY_LOW to kernel module
        drm-scheduler, if these two patches are not applyed, </p>
      <p>It can not pass LOW priority to drm-scheduler.</p>
      <p>Do you have any other suggestion?</p>
    </blockquote>
    <br>
    Well what exactly is the problem? Just use AMD_PRIORITY=-512.<br>
    <br>
    As far as I can see that is how it is supposed to be used.<br>
    <br>
    Regards,<br>
    Christian.<br>
    <br>
    <br>
    <blockquote type="cite">
      <p><br>
        <br>
        <br>
        <br>
        <br>
        <br>
        ----</p>
      <p> </p>
      <div id="m_-4761085421037625214re" style="margin-left:0.5em;padding-left:0.5em;border-left:1px solid green"><br>
        <br>
        <br>
        <div style="background-color:#f5f7fa"><strong>主 题:</strong><span id="m_-4761085421037625214subject">Re: 回复: Re: [PATCH libdrm 1/2] amdgpu: fix
            parameter of amdgpu_cs_ctx_create2</span> <br>
          <strong>日 期:</strong><span id="m_-4761085421037625214date">2024-01-09 15:15</span> <br>
          <strong>发件人:</strong><span id="m_-4761085421037625214from">Christian König</span> <br>
          <strong>收件人:</strong><span id="m_-4761085421037625214to" style="word-break:break-all">李真能;Marek Olsak;Pierre-Eric
            Pelloux-Prayer;dri-devel;amd-gfx;</span></div>
        <br>
        <div id="m_-4761085421037625214content">
          <div>
            <div>Am 09.01.24 um 02:50 schrieb 李真能:<br>
              <p>When the priority value is passed to the kernel, the
                kernel compares it with the following values:</p>
              <p>#define AMDGPU_CTX_PRIORITY_VERY_LOW    -1023<br>
                #define AMDGPU_CTX_PRIORITY_LOW         -512<br>
                #define AMDGPU_CTX_PRIORITY_NORMAL      0<br>
                #define AMDGPU_CTX_PRIORITY_HIGH        512<br>
                #define AMDGPU_CTX_PRIORITY_VERY_HIGH   1023</p>
              <p>If priority is uint32_t, we can't set LOW and VERY_LOW
                value to kernel context priority,</p>
              <br>
              Well that's nonsense.<br>
              <br>
              How the kernel handles the values and how userspace
              handles them are two separate things. You just need to
              make sure that it's always 32 bits.<br>
              <br>
              In other words if you have signed or unsigned data type in
              userspace is irrelevant for the kernel.<br>
              <br>
              <p>You can refer to the kernel function
                amdgpu_ctx_priority_permit, if priority is greater</p>
              <p>than 0, and this process has not  CAP_SYS_NICE
                capibility or DRM_MASTER permission,</p>
              <p>this process will be exited.</p>
              <br>
              Correct, that's intentional.<br>
              <br>
              Regards,<br>
              Christian.<br>
              <br>
              <p><br>
                <br>
                <br>
                <br>
                <br>
                ----</p>
              <p> </p>
              <div id="m_-4761085421037625214re" style="margin-left:0.5em;padding-left:0.5em;border-left:1px solid green"><br>
                <br>
                <br>
                <div style="background-color:#f5f7fa"><strong>主 题:</strong><span id="m_-4761085421037625214subject">Re: [PATCH libdrm 1/2] amdgpu: fix
                    parameter of amdgpu_cs_ctx_create2</span> <br>
                  <strong>日 期:</strong><span id="m_-4761085421037625214date">2024-01-09 00:28</span>
                  <br>
                  <strong>发件人:</strong><span id="m_-4761085421037625214from">Christian König</span>
                  <br>
                  <strong>收件人:</strong><span id="m_-4761085421037625214to" style="word-break:break-all">李真能;Marek
                    Olsak;Pierre-Eric Pelloux-Prayer;dri-devel;amd-gfx;</span></div>
                <br>
                <div id="m_-4761085421037625214content">
                  <div>
                    <div>Am 08.01.24 um 10:40 schrieb Zhenneng Li:<br>
                      > In order to pass the correct priority
                      parameter to the kernel,<br>
                      > we must change priority type from uint32_t to
                      int32_t.<br>
                      <br>
                      Hui what? Why should it matter if the parameter is
                      signed or not?<br>
                      <br>
                      That doesn't seem to make sense.<br>
                      <br>
                      Regards,<br>
                      Christian.<br>
                      <br>
                      ><br>
                      > Signed-off-by: Zhenneng Li <br>
                      > ---<br>
                      > amdgpu/amdgpu.h | 2 +-<br>
                      > amdgpu/amdgpu_cs.c | 2 +-<br>
                      > 2 files changed, 2 insertions(+), 2
                      deletions(-)<br>
                      ><br>
                      > diff --git a/amdgpu/amdgpu.h
                      b/amdgpu/amdgpu.h<br>
                      > index 9bdbf366..f46753f3 100644<br>
                      > --- a/amdgpu/amdgpu.h<br>
                      > +++ b/amdgpu/amdgpu.h<br>
                      > @@ -896,7 +896,7 @@ int
                      amdgpu_bo_list_update(amdgpu_bo_list_handle
                      handle,<br>
                      > *<br>
                      > */<br>
                      > int
                      amdgpu_cs_ctx_create2(amdgpu_device_handle dev,<br>
                      > - uint32_t priority,<br>
                      > + int32_t priority,<br>
                      > amdgpu_context_handle *context);<br>
                      > /**<br>
                      > * Create GPU execution Context<br>
                      > diff --git a/amdgpu/amdgpu_cs.c
                      b/amdgpu/amdgpu_cs.c<br>
                      > index 49fc16c3..eb72c638 100644<br>
                      > --- a/amdgpu/amdgpu_cs.c<br>
                      > +++ b/amdgpu/amdgpu_cs.c<br>
                      > @@ -49,7 +49,7 @@ static int
                      amdgpu_cs_reset_sem(amdgpu_semaphore_handle sem);<br>
                      > * \return 0 on success otherwise POSIX Error
                      code<br>
                      > */<br>
                      > drm_public int
                      amdgpu_cs_ctx_create2(amdgpu_device_handle dev,<br>
                      > - uint32_t priority,<br>
                      > + int32_t priority,<br>
                      > amdgpu_context_handle *context)<br>
                      > {<br>
                      > struct amdgpu_context *gpu_context;<br>
                      <br>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
  </div>

</blockquote></div>