diff options
author | Alex Waterman <alexw@nvidia.com> | 2018-03-05 22:03:32 -0500 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2018-03-08 07:27:39 -0500 |
commit | da9b549cd15b2f193a1c8b30f96d4106b28ddd30 (patch) | |
tree | 7d2a5f4c84b13cdd8d1b18bb69c2f7d103a5e32c /drivers/gpu/nvgpu/common/mm/vidmem.c | |
parent | 4320877eb49ef16a5620536427f77de44bee12b7 (diff) |
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 <alexw@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1669099
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common/mm/vidmem.c')
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/vidmem.c | 12 |
1 files changed, 7 insertions, 5 deletions
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) | |||
503 | 503 | ||
504 | err = nvgpu_vidmem_clear_all(g); | 504 | err = nvgpu_vidmem_clear_all(g); |
505 | if (err) | 505 | if (err) |
506 | return NULL; | 506 | return ERR_PTR(-ENOMEM); |
507 | 507 | ||
508 | buf = nvgpu_kzalloc(g, sizeof(*buf)); | 508 | buf = nvgpu_kzalloc(g, sizeof(*buf)); |
509 | if (!buf) | 509 | if (!buf) |
510 | return NULL; | 510 | return ERR_PTR(-ENOMEM); |
511 | 511 | ||
512 | buf->g = g; | 512 | buf->g = g; |
513 | buf->mem = nvgpu_kzalloc(g, sizeof(*buf->mem)); | 513 | buf->mem = nvgpu_kzalloc(g, sizeof(*buf->mem)); |
514 | if (!buf->mem) | 514 | if (!buf->mem) { |
515 | err = -ENOMEM; | ||
515 | goto fail; | 516 | goto fail; |
517 | } | ||
516 | 518 | ||
517 | err = nvgpu_dma_alloc_vid(g, bytes, buf->mem); | 519 | err = nvgpu_dma_alloc_vid(g, bytes, buf->mem); |
518 | if (err) | 520 | if (err) |
@@ -530,7 +532,7 @@ fail: | |||
530 | /* buf will never be NULL here. */ | 532 | /* buf will never be NULL here. */ |
531 | nvgpu_kfree(g, buf->mem); | 533 | nvgpu_kfree(g, buf->mem); |
532 | nvgpu_kfree(g, buf); | 534 | nvgpu_kfree(g, buf); |
533 | return NULL; | 535 | return ERR_PTR(err); |
534 | } | 536 | } |
535 | 537 | ||
536 | void nvgpu_vidmem_buf_free(struct gk20a *g, struct nvgpu_vidmem_buf *buf) | 538 | 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) | |||
538 | /* | 540 | /* |
539 | * In some error paths it's convenient to be able to "free" a NULL buf. | 541 | * In some error paths it's convenient to be able to "free" a NULL buf. |
540 | */ | 542 | */ |
541 | if (!buf) | 543 | if (IS_ERR_OR_NULL(buf)) |
542 | return; | 544 | return; |
543 | 545 | ||
544 | nvgpu_dma_free(g, buf->mem); | 546 | nvgpu_dma_free(g, buf->mem); |