[Mesa-dev] [PATCH] i965: Allocate shadow batches to explicitly be the BO size.
Lionel Landwerlin
lionel.g.landwerlin at intel.com
Fri Apr 20 02:23:01 UTC 2018
Looks good.
Do we need to add : Fixes: c7dcee58b5fe183e1653c13bff6a212f0d157b29
(i965: Avoid problems from referencing orphaned BOs after growing.)
Which is the same as commit da25ae92bebb8921003c0df30820d06a5f5e3fef.
Regardless :
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
On 18/04/18 13:57, Kenneth Graunke wrote:
> This unfortunately makes it malloc/realloc on every new batch, rather
> than once at startup. But it ensures that the shadow buffer's size will
> absolutely match the BO size. Otherwise, as we tune BATCH_SZ/STATE_SZ
> or bufmgr cache bucket sizes, we may get a BO size that's rounded up,
> and fail to allocate the shadow buffer large enough.
>
> This doesn't fix any bugs today, as BATCH_SZ/STATE_SZ are the size of
> a cache bucket, but it's better to be safe than sorry.
>
> Reported-by: James Xiong <james.xiong at intel.com>
> ---
> src/mesa/drivers/dri/i965/intel_batchbuffer.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> index a29159e41ba..9dc9590138d 100644
> --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> @@ -107,15 +107,11 @@ intel_batchbuffer_init(struct brw_context *brw)
>
> batch->use_shadow_copy = !devinfo->has_llc;
>
> - if (batch->use_shadow_copy) {
> - batch->batch.map = malloc(BATCH_SZ);
> - batch->map_next = batch->batch.map;
> - batch->state.map = malloc(STATE_SZ);
> - }
> -
> init_reloc_list(&batch->batch_relocs, 250);
> init_reloc_list(&batch->state_relocs, 250);
>
> + batch->batch.map = NULL;
> + batch->state.map = NULL;
> batch->exec_count = 0;
> batch->exec_array_size = 100;
> batch->exec_bos =
> @@ -196,7 +192,9 @@ recreate_growing_buffer(struct brw_context *brw,
> grow->partial_bo_map = NULL;
> grow->partial_bytes = 0;
>
> - if (!batch->use_shadow_copy)
> + if (batch->use_shadow_copy)
> + grow->map = realloc(grow->map, grow->bo->size);
> + else
> grow->map = brw_bo_map(brw, grow->bo, MAP_READ | MAP_WRITE);
> }
>
More information about the mesa-dev
mailing list