radeonsi: stop using the VM_ALWAYS_VALID flag when memory usage is high
Allocation all the bo as ALWAYS_VALID means they must all fit in memory (vram + gtt) at each command submission. This causes some trouble when the total allocated memory is greater than the available memory.
This commit limits the usage of the VM_ALWAYS_VALID optimization to smaller buffers and when the total allocated memory is less than 90% of the total memory.
This is a workaround, not a complete fix but it should cover most situations, is simple and doesn't require kernel side modifications.
Related issues:
It also helps with some piglit tests (-t maxsize -t "max[_-].*size" -t maxuniformblocksize): instead of crashing the machine, the tests fail cleanly.
Edited by Pierre-Eric Pelloux-Prayer