[Mesa-dev] [PATCH] anv/query: handle out of host memory without crashing in compute_query_result()

Pohjolainen, Topi topi.pohjolainen at gmail.com
Fri Mar 24 08:32:17 UTC 2017


On Fri, Mar 24, 2017 at 09:12:21AM +0100, Iago Toral wrote:
> Topi, could you review this one?
> 
> This was introduced recently with the implementation of Queries in the
> Vulkan driver and since the CTS OOM tests have not landed yet Jenkins
> won't catch these issues for now.

Yeah, sorry, I was meaning to but somehow forgot. Good for you to ask :)
> 
> Iago
> 
> On Wed, 2017-03-22 at 10:15 +0100, Iago Toral Quiroga wrote:
> > We don't need to make the caller (CmdCopyQueryPoolResults) aware of
> > the
> > problem since compute_query_result() only emits state. The caller is
> > also
> > expected to hit OOM in this scenario right after calling this
> > function, but
> > it is already handling it safely.
> > 
> > Fixes:
> > dEQP-VK.api.out_of_host_memory.cmd_copy_query_pool_results
> > ---
> >  src/intel/vulkan/genX_query.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/src/intel/vulkan/genX_query.c
> > b/src/intel/vulkan/genX_query.c
> > index b1ed4d3..3610665 100644
> > --- a/src/intel/vulkan/genX_query.c
> > +++ b/src/intel/vulkan/genX_query.c
> > @@ -627,6 +627,11 @@ compute_query_result(struct anv_batch *batch,
> > uint32_t dst_reg,
> >     /* FIXME: We need to clamp the result for 32 bit. */
> >  
> >     uint32_t *dw = anv_batch_emitn(batch, 5, GENX(MI_MATH));
> > +   if (!dw) {
> > +      anv_batch_set_error(batch, VK_ERROR_OUT_OF_HOST_MEMORY);
> > +      return;
> > +   }
> > +
> >     dw[1] = alu(OPCODE_LOAD, OPERAND_SRCA, OPERAND_R1);
> >     dw[2] = alu(OPCODE_LOAD, OPERAND_SRCB, OPERAND_R0);
> >     dw[3] = alu(OPCODE_SUB, 0, 0);


More information about the mesa-dev mailing list