<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    I was thinking about that as well, yes.<br>
    <br>
    Might be a good idea to just change the alignment check in
    amdgpu_bo_create():<br>
    <br>
                    /* Memory should be aligned at least to a page size.
    */<br>
                    page_align = ALIGN(bp->byte_align, PAGE_SIZE)
    >> PAGE_SHIFT;<br>
    <br>
    <br>
    Something like ALIGN(bp->byte_align ?: 1, PAGE_SIZE) should
    already do it.<br>
    <br>
    Christian.<br>
    <br>
    <div class="moz-cite-prefix">Am 23.09.22 um 08:23 schrieb Marek
      Olšák:<br>
    </div>
    <blockquote type="cite" cite="mid:CAAxE2A7jgTq_TiqK+V7aYPMd7rW2xATJSyVRcyRXpXreo3o4eQ@mail.gmail.com">
      
      <div dir="ltr">
        <div>The kernel could report the true alignment from the ioctl
          instead of 0.</div>
        <div><br>
        </div>
        <div>Marek<br>
        </div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Fri, Sep 23, 2022 at 1:31
          AM Christian König <<a href="mailto:christian.koenig@amd.com" moz-do-not-send="true" class="moz-txt-link-freetext">christian.koenig@amd.com</a>>
          wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px
          0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Am
          23.09.22 um 07:28 schrieb lepton:<br>
          > On Thu, Sep 22, 2022 at 10:14 PM Christian König<br>
          > <<a href="mailto:christian.koenig@amd.com" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">christian.koenig@amd.com</a>>
          wrote:<br>
          >> Am 23.09.22 um 01:04 schrieb Lepton Wu:<br>
          >>> Since size has been aligned to PAGE_SIZE already,
          just align it<br>
          >>> to PAGE_SIZE so later the buffer can be used as a
          texture in mesa<br>
          >>> after <a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcgit.freedesktop.org%2Fmesa%2Fmesa%2Fcommit%2F%3Fid%3Df7a4051b8&data=05%7C01%7Cchristian.koenig%40amd.com%7C69c0881fd97d4de3380408da9d2c336b%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637995111117539790%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=KMiCYD7blJCjO9zcfsqmy9%2FfYbtAmMHbrwpzHP7F5O0%3D&reserved=0" originalsrc="https://cgit.freedesktop.org/mesa/mesa/commit/?id=f7a4051b8" shash="tWZ/wSFytcJujLRNLlQuVPu0GEQzU3dY7OQK9ATquLkHfpsKql65oFr7ZGju71IstnGuM4ElKmeZ3EJnWu9AcnyWuun7wPM82YmJQvlP7bLR1BMSuqfrVdMJvaX/nPuaeYB+JLBbEiT/9FdBdITIL3/4S2dOWwWNf4VUUkHwGqE=" rel="noreferrer" target="_blank" moz-do-not-send="true">https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcgit.freedesktop.org%2Fmesa%2Fmesa%2Fcommit%2F%3Fid%3Df7a4051b8&amp;data=05%7C01%7Cchristian.koenig%40amd.com%7C645f6878a7bd487588b708da9d246c4c%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637995077041120091%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=NMEAl8TByDLQFWW1d%2FaJfiGrXc4mpwL5dxNH0M0QH84%3D&amp;reserved=0</a><br>
          >>> Otherwise, si_texture_create_object will fail at
          line<br>
          >>> "buf->alignment <
          tex->surface.alignment"<br>
          >> I don't think that those Mesa checks are a good idea
          in the first place.<br>
          >><br>
          >> The alignment value is often specified as zero when
          it doesn't matter<br>
          >> because the minimum alignment can never be less than
          the page size.<br>
          > Are you suggesting to change those mesa checks?<br>
          <br>
          Yes, the minimum alignment of allocations is always 4096
          because that's <br>
          the page size of the GPU.<br>
          <br>
          > While that can be<br>
          > done, I still think a kernel side "fix" is still<br>
          > useful since it doesn't hurt while can fix issues for
          some versions of mesa.<br>
          <br>
          No, we have tons of places where we don't specify and
          alignment for <br>
          buffers because it never mattered. I certainly don't want to
          fix all of <br>
          those.<br>
          <br>
          Regards,<br>
          Christian.<br>
          <br>
          >> Christian.<br>
          >><br>
          >>> Signed-off-by: Lepton Wu <<a href="mailto:ytht.net@gmail.com" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">ytht.net@gmail.com</a>><br>
          >>> ---<br>
          >>>    drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 2 +-<br>
          >>>    1 file changed, 1 insertion(+), 1 deletion(-)<br>
          >>><br>
          >>> diff --git
          a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
          b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c<br>
          >>> index 8ef31d687ef3b..8dca0c920d3ce 100644<br>
          >>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c<br>
          >>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c<br>
          >>> @@ -928,7 +928,7 @@ int
          amdgpu_mode_dumb_create(struct drm_file *file_priv,<br>
          >>>        args->size = ALIGN(args->size,
          PAGE_SIZE);<br>
          >>>        domain =
          amdgpu_bo_get_preferred_domain(adev,<br>
          >>>                               
          amdgpu_display_supported_domains(adev, flags));<br>
          >>> -     r = amdgpu_gem_object_create(adev,
          args->size, 0, domain, flags,<br>
          >>> +     r = amdgpu_gem_object_create(adev,
          args->size, PAGE_SIZE, domain, flags,<br>
          >>>                                   
           ttm_bo_type_device, NULL, &gobj);<br>
          >>>        if (r)<br>
          >>>                return -ENOMEM;<br>
          <br>
        </blockquote>
      </div>
    </blockquote>
    <br>
  </body>
</html>