<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Aug 10, 2023 at 10:15 PM Dave Airlie <<a href="mailto:airlied@gmail.com">airlied@gmail.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">From: Dave Airlie <<a href="mailto:airlied@redhat.com" target="_blank">airlied@redhat.com</a>><br>
<br>
With the new uapi we don't have the comp flags on the allocation,<br>
so we shouldn't be using the first size that works, we should be<br>
iterating until we get the correct one.<br>
<br>
This reduces allocations from 2MB to 64k in lots of places.<br>
<br>
Fixes dEQP-VK.memory.allocation.basic.size_8KiB.forward.count_4000<br>
on my ampere/gsp system.<br>
<br>
Signed-off-by: Dave Airlie <<a href="mailto:airlied@redhat.com" target="_blank">airlied@redhat.com</a>><br></blockquote><div><br></div><div>Reviewed-by: Faith Ekstrand <<a href="mailto:faith.ekstrand@collabora.com">faith.ekstrand@collabora.com</a>><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
---<br>
 drivers/gpu/drm/nouveau/nouveau_bo.c | 5 +++--<br>
 1 file changed, 3 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c<br>
index 949195d5d782..a6993c7807b6 100644<br>
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c<br>
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c<br>
@@ -318,8 +318,9 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain,<br>
                            (!vmm->page[i].host || vmm->page[i].shift > PAGE_SHIFT))<br>
                                continue;<br>
<br>
-                       if (pi < 0)<br>
-                               pi = i;<br>
+                       /* pick the last one as it will be smallest. */<br>
+                       pi = i;<br>
+<br>
                        /* Stop once the buffer is larger than the current page size. */<br>
                        if (*size >= 1ULL << vmm->page[i].shift)<br>
                                break;<br>
-- <br>
2.41.0<br>
<br>
</blockquote></div></div>