On 22/07/2019 13:19, Steven Price wrote:
[...]
Indeed, that case was just occurring to me too! How about:

        u64 next_seg = ALIGN(*start, PFN_4G);

        if (next_seg - *start <= PFN_16M)
                *start = next_seg + 1;

        *end = min(*end, ALIGN(*start, PFN_4G) - 1);

So always allocate at the beginning, but skip past the next 4GB boundary
if there's less than 16MB left (or equal to avoid the 4GB boundary).

Ah, there it is! I think it generalises even further by just changing the condition to "if (next_seg - *start < *end - next_seg)", although we'd need to ensure a signed comparison to cover the case where start and end are already in the same segment.

Robin.
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reply via email to