If memory allocation fails, we look for a suitable sized BO in the BO cache and wait until we can use its memory. That usually works, but there's a case when it can fail despite sufficient memory in the system: BOs in the BO cache contributing to memory pressure but none of them being of sufficient size. This case is not just theoretical: it's seen in the OpenCL test_non_uniform_work_group, which puts the system under considerable memory pressure with an unusual allocation pattern.
To handle this case, try evicting everything from the BO cache and stalling in order to allocate, if the above attempts failed. Fixes the following error:
DRM_IOCTL_PANFROST_CREATE_BO failed: No space left on device
on the aforementioned OpenCL test.
Signed-off-by: Alyssa Rosenzweig email@example.com