After getting slightly confused by the values of the ring registers in the error state dumps, I started to actually read the specs and compare what I learned with the code. I spotted one possible issue with the head and tail handling. But I don't know if my patch might fix some obscure bug, or not. gem_ringfill seems to work equally well with and without the patch.