Skip to contentSkip to conversation

nouveau: find the smallest page allocation to cover a buffer alloc.

PATCH In review Dave Airlie 2 participants 2 messages Aug 11, 2023 – Aug 12, 2023

Subsystems (3)
lore
Share & tools
lore

Dave Airlie

author maintainer
#0 lore raw

PATCH 1/1 nouveau: find the smallest page allocation to cover a buffer alloc.

From: Dave Airlie <[email protected]>

With the new uapi we don't have the comp flags on the allocation, so we shouldn't be using the first size that works, we should be iterating until we get the correct one.

This reduces allocations from 2MB to 64k in lots of places.

Fixes dEQP-VK.memory.allocation.basic.size_8KiB.forward.count_4000 on my ampere/gsp system.

---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +3 -2
index 949195d5d782..a6993c7807b6 100644
@@ -318,8 +318,9 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain,
 			    (!vmm->page[i].host || vmm->page[i].shift > PAGE_SHIFT))
 				continue;
 
-			if (pi < 0)
-				pi = i;
+			/* pick the last one as it will be smallest. */
+			pi = i;
+
 			/* Stop once the buffer is larger than the current page size. */
 			if (*size >= 1ULL << vmm->page[i].shift)
 				break;
Signature · 1 line
2.41.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Dave Airlie

From: Dave Airlie <[email protected]>

With the new uapi we don't have the comp flags on the allocation, so we shouldn't be using the first size that works, we should be iterating until we get the correct one.

Quoted 7 lines

This reduces allocations from 2MB to 64k in lots of places.

Fixes dEQP-VK.memory.allocation.basic.size_8KiB.forward.count_4000 on my ampere/gsp system.

Quoted 28 lines
---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +3 -2
index 949195d5d782..a6993c7807b6 100644
@@ -318,8 +318,9 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size,
 int *align, u32 domain,
                            (!vmm->page[i].host || vmm->page[i].shift >
 PAGE_SHIFT))
                                continue;
 
-                       if (pi < 0)
-                               pi = i;
+                       /* pick the last one as it will be smallest. */
+                       pi = i;
+
                        /* Stop once the buffer is larger than the current

page size. */

                        if (*size >= 1ULL << vmm->page[i].shift)
                                break;

--
2.41.0