[Mesa-dev] [PATCH 3/4] i965: Prevent infinite finish_batch recursion

Ben Widawsky ben at bwidawsk.net
Fri Feb 27 10:51:13 PST 2015


On Fri, Feb 27, 2015 at 10:22:10AM -0800, Ben Widawsky wrote:
> From the comments in the code:
> 
>    Called from intel_batchbuffer_flush before emitting MI_BATCHBUFFER_END and
>    sending it off.
> 
> This fixes a possible, unlikely infinite recursion in our batch flush path. More
> importantly it allows me to add some code here.
> 
> The relevant part of the call chain for flush
> intel_batchbuffer_flush()->brw_finish_batch(). The problem arises if anything in
> the time from intel_batchbuffer_flush, until brw_finish_batch ends up calling
> itself. This can happen as a result of a call to
> intel_batchbuffer_begin()->intel_batchbuffer_require_space()->intel_batchbuffer_flush().
> 
> There are two possible cases today which can spawn this recursion.
> 1. There is a ring switch occurring (impossible, see below)
> 2. The ring is out of space (fairly unlikely)

Just discussed this with krh. #2 cannot occur because of the BATCH_RESERVE. So
only case #1 is possible, and only after the next patch.

Also, there is probably a cleaner way to do this (I'm thinking modify the ring
variable in a different place), but this is cleaner, and I'd like to see if it
fixes anything first



More information about the mesa-dev mailing list