Skip to content

Commit

Permalink
tegradrm: purge cache on allocation failure
Browse files Browse the repository at this point in the history
Purge cache and retry on BO allocation failure.
  • Loading branch information
digetx committed Dec 11, 2020
1 parent 754fb7f commit 7ddba53
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/tegradrm/tegra.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7ddba53

Please sign in to comment.