From da9b549cd15b2f193a1c8b30f96d4106b28ddd30 Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Mon, 5 Mar 2018 19:03:32 -0800 Subject: gpu: nvgpu: Correctly plumb -EAGAIN from vidmem allocations Userspace can and should retry vidmem allocations if there are pending clears still to be executed by the GPU. But this requires the -EAGAIN to properly propagate back to userspace. Bug 200378648 Change-Id: Ib930711270439843e043d65c2e87b60612a76239 Signed-off-by: Alex Waterman Reviewed-on: https://git-master.nvidia.com/r/1669099 Reviewed-by: svc-mobile-coverity GVS: Gerrit_Virtual_Submit Reviewed-by: Konsta Holtta Reviewed-by: Vijayakumar Subbu Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/mm/vidmem.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'drivers/gpu/nvgpu/common/mm/vidmem.c') diff --git a/drivers/gpu/nvgpu/common/mm/vidmem.c b/drivers/gpu/nvgpu/common/mm/vidmem.c index 4239bd06..e4137090 100644 --- a/drivers/gpu/nvgpu/common/mm/vidmem.c +++ b/drivers/gpu/nvgpu/common/mm/vidmem.c @@ -503,16 +503,18 @@ struct nvgpu_vidmem_buf *nvgpu_vidmem_user_alloc(struct gk20a *g, size_t bytes) err = nvgpu_vidmem_clear_all(g); if (err) - return NULL; + return ERR_PTR(-ENOMEM); buf = nvgpu_kzalloc(g, sizeof(*buf)); if (!buf) - return NULL; + return ERR_PTR(-ENOMEM); buf->g = g; buf->mem = nvgpu_kzalloc(g, sizeof(*buf->mem)); - if (!buf->mem) + if (!buf->mem) { + err = -ENOMEM; goto fail; + } err = nvgpu_dma_alloc_vid(g, bytes, buf->mem); if (err) @@ -530,7 +532,7 @@ fail: /* buf will never be NULL here. */ nvgpu_kfree(g, buf->mem); nvgpu_kfree(g, buf); - return NULL; + return ERR_PTR(err); } void nvgpu_vidmem_buf_free(struct gk20a *g, struct nvgpu_vidmem_buf *buf) @@ -538,7 +540,7 @@ void nvgpu_vidmem_buf_free(struct gk20a *g, struct nvgpu_vidmem_buf *buf) /* * In some error paths it's convenient to be able to "free" a NULL buf. */ - if (!buf) + if (IS_ERR_OR_NULL(buf)) return; nvgpu_dma_free(g, buf->mem); -- cgit v1.2.2