broadcom/vc4: Fix infinite retry in vc4_bo_alloc()

cleared_and_retried is always reset to false when jumping to the retry
label, thus leading to an infinite retry loop.

Fix that by moving the cleared_and_retried variable definitions at the
beginning of the function.  While we're at it, move the create variable
with the other local variables and explicitly reset its content in the
retry path.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Fixes: 78087676c9 "vc4: Restructure the simulator mode."
(cherry picked from commit ef578906d8)
This commit is contained in:
Boris Brezillon 2017-09-26 09:48:37 +02:00 committed by Juan A. Suarez Romero
parent e22ab89f9f
commit d9aba007c0

View file

@ -123,6 +123,8 @@ vc4_bo_from_cache(struct vc4_screen *screen, uint32_t size, const char *name)
struct vc4_bo *
vc4_bo_alloc(struct vc4_screen *screen, uint32_t size, const char *name)
{
bool cleared_and_retried = false;
struct drm_vc4_create_bo create;
struct vc4_bo *bo;
int ret;
@ -149,12 +151,8 @@ vc4_bo_alloc(struct vc4_screen *screen, uint32_t size, const char *name)
bo->private = true;
retry:
;
bool cleared_and_retried = false;
struct drm_vc4_create_bo create = {
.size = size
};
memset(&create, 0, sizeof(create));
create.size = size;
ret = vc4_ioctl(screen->fd, DRM_IOCTL_VC4_CREATE_BO, &create);
bo->handle = create.handle;