From 7ddba530657d05c1a2dd823701655c2c3c7639a0 Mon Sep 17 00:00:00 2001 From: Dmitry Osipenko Date: Fri, 11 Dec 2020 16:14:24 +0300 Subject: [PATCH] tegradrm: purge cache on allocation failure Purge cache and retry on BO allocation failure. --- src/tegradrm/tegra.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/tegradrm/tegra.c b/src/tegradrm/tegra.c index b3eac28..15383ce 100644 --- a/src/tegradrm/tegra.c +++ b/src/tegradrm/tegra.c @@ -358,6 +358,7 @@ int drm_tegra_bo_new(struct drm_tegra_bo **bop, struct drm_tegra *drm, { struct drm_tegra_gem_create args; struct drm_tegra_bo *bo; + bool retried = false; int err; if (!drm || size == 0 || !bop) @@ -397,9 +398,16 @@ int drm_tegra_bo_new(struct drm_tegra_bo **bop, struct drm_tegra *drm, if (drm->debug_bo_back_guard) args.size += 4096; #endif +retry: err = drmCommandWriteRead(drm->fd, DRM_TEGRA_GEM_CREATE, &args, sizeof(args)); if (err < 0) { + if (!retried) { + drm_tegra_bo_cache_cleanup(drm, 0); + retried = true; + goto retry; + } + VDBG_DRM(drm, "failed size %u bytes flags 0x%08X err %d (%s)\n", size, flags, err, strerror(-err)); free(bo);