Two kinds of message for a context can reach the decoder after its
CONTEXT_CLOSE has removed the context's state: a command buffer its queue's
service thread took off the ring before the close and handed over after it,
and a release the kext posted behind the close. Each one made the context a
fresh state, which nothing dropped until the device's reset. A buffer of the
context whose completion the platform refused after the close marked the
closed context failed, also until the reset, and every later buffer's check of
the failed contexts then took that lock.
The decoder now keeps the contexts closed since the reset, as runs of numbers,
so the record stays about as small as the set of open contexts. A context is
marked closed under the same lock its state is removed under. Only a create
makes a state, and a create of a closed context opens it again, as for a
process given the number again; the close has emptied the context's compiles
and waited for its no-copy buffers first.
- A late command buffer finds no state, and is refused unrun. Nothing is posted
for it, as before: its queue ended at the close, so the failure it posted
never reached the guest. A buffer of a context with no state that was never
closed fails as before.
- A late release or unshare makes no state, and goes through the drain chain
behind the close's drain.
- A refused completion after the close marks nothing.
- A buffer takes its context's drain under the states' lock, so it holds the
drain the close takes, or finds no state.
The new tests check that the decoder holds no state after a close followed by
a late buffer, a late release and a late failure, and that a release behind a
close leaves no state on the device. The tests where a process is given a
closed context's number again still pass.