@@ -723,10 +723,14 @@ retry:
* of the list, as it will likely be hot in the GPU
* cache and in the aperture for us.
*/
- bo_gem = DRMLISTENTRY(drm_intel_bo_gem,
- bucket->head.prev, head);
- DRMLISTDEL(&bo_gem->head);
- bo_gem->bo.align = alignment;
+ DRMLISTFOREACHENTRYREVERSE(temp_bo_gem, &bucket->head, head) {
+ if (temp_bo_gem->bo.size >= size) {
+ bo_gem = temp_bo_gem;
+ DRMLISTDEL(&bo_gem->head);
+ bo_gem->bo.align = alignment;
+ break;
+ }
+ }
} else {
assert(alignment == 0);
/* For non-render-target BOs (where we're probably
@@ -736,12 +740,13 @@ retry:
* allocating a new buffer is probably faster than
* waiting for the GPU to finish.
*/
- bo_gem = DRMLISTENTRY(drm_intel_bo_gem,
- bucket->head.next, head);
- if (!drm_intel_gem_bo_busy(&bo_gem->bo)) {
- DRMLISTDEL(&bo_gem->head);
- } else {
- bo_gem = NULL;
+ DRMLISTFOREACHENTRY(temp_bo_gem, &bucket->head, head) {
+ if (temp_bo_gem->bo.size >= size &&
+ !drm_intel_gem_bo_busy(&temp_bo_gem->bo)) {
+ bo_gem = temp_bo_gem;
+ DRMLISTDEL(&bo_gem->head);
+ break;
+ }
}
}