lima,panfrost: Do not ralloc contexts against the screen

ralloc is not thread-safe. While a given context can only be accessed from a
single thread at once, multiple contexts can be created against the same screen
at once. The ralloc allocations against the shared screens will race. Depending
on the result of the race, the same block of memory can be returned as the two
new contexts in two different threads, causing a use-after-free when the context
is freed later.

We free the context explicitly when it's destroyed anyway. If screens are
getting destroyed without the contexts getting destroyed first, that's a state
tracker bug, not a Panfrost one.

This matches what Iris does.

Fixes crash in test_integer_ops.int_math on Panfrost.

Fixes: 0fcf73bc ("panfrost: Move to use ralloc for some allocations")
Signed-off-by: Alyssa Rosenzweig <>
Reviewed-by: Jesse Natalie <>
Reviewed-by: Vasily Khoruzhick <>
Reviewed-by: Jason Ekstrand <>
Part-of: <!17234>
55 jobs for !17234 with panfrost/ralloc-context in 13 minutes and 11 seconds (queued for 7 seconds)
latest merge request