From c2fbc999672ff41d376e4f572295e2215fb3cd4c Mon Sep 17 00:00:00 2001 From: Petlozu Pravareshwar Date: Thu, 13 Feb 2020 04:46:32 -0800 Subject: [PATCH] gpu: nvgpu: Address Vectorcast gap for posix queue Update unit test for posix queue unit to cover Vectorcast gap. Jira NVGPU-4478 Change-Id: I0d79861f173d511d25cf45051c399e3193eabdbe Signed-off-by: Petlozu Pravareshwar Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2294146 Tested-by: mobile promotions Reviewed-by: mobile promotions --- drivers/gpu/nvgpu/libnvgpu-drv_safe.export | 1 + userspace/units/posix/queue/posix-queue.c | 16 ++++++++++++++++ userspace/units/posix/queue/posix-queue.h | 4 ++++ 3 files changed, 21 insertions(+) diff --git a/drivers/gpu/nvgpu/libnvgpu-drv_safe.export b/drivers/gpu/nvgpu/libnvgpu-drv_safe.export index 2e704d41e..3d594b319 100644 --- a/drivers/gpu/nvgpu/libnvgpu-drv_safe.export +++ b/drivers/gpu/nvgpu/libnvgpu-drv_safe.export @@ -661,6 +661,7 @@ nvgpu_queue_in nvgpu_queue_in_locked nvgpu_queue_out nvgpu_queue_out_locked +nvgpu_queue_out_get_fault_injection nvgpu_preempt_channel nvgpu_preempt_get_timeout nvgpu_preempt_poll_tsg_on_pbdma diff --git a/userspace/units/posix/queue/posix-queue.c b/userspace/units/posix/queue/posix-queue.c index effcdccfa..ddf72ecf4 100644 --- a/userspace/units/posix/queue/posix-queue.c +++ b/userspace/units/posix/queue/posix-queue.c @@ -185,6 +185,8 @@ int test_nvgpu_queue_out(struct unit_module *m, struct gk20a *g, void *args) struct nvgpu_queue q = {0}; struct nvgpu_mutex lock; char buf[BUF_LEN]; + struct nvgpu_posix_fault_inj *queue_out_fi = + nvgpu_queue_out_get_fault_injection(); nvgpu_mutex_init(&lock); @@ -250,6 +252,20 @@ int test_nvgpu_queue_out(struct unit_module *m, struct gk20a *g, void *args) goto fail; } + /* + * Fault injection so that immediate call to nvgpu_queue_out_locked() + * API would return error. + */ + nvgpu_posix_enable_fault_injection(queue_out_fi, true, 0); + ret = nvgpu_queue_out_locked(&q, buf, BUF_LEN, &lock); + if (ret != -1) { + err = UNIT_FAIL; + nvgpu_posix_enable_fault_injection(queue_out_fi, false, 0); + unit_err(m, "%d. queue_out failed err=%d\n", __LINE__, ret); + goto fail; + } + nvgpu_posix_enable_fault_injection(queue_out_fi, false, 0); + fail: if (q.data != NULL) free(q.data); diff --git a/userspace/units/posix/queue/posix-queue.h b/userspace/units/posix/queue/posix-queue.h index 6c0d7de96..109f4ae83 100644 --- a/userspace/units/posix/queue/posix-queue.h +++ b/userspace/units/posix/queue/posix-queue.h @@ -137,6 +137,10 @@ int test_nvgpu_queue_in(struct unit_module *m, struct gk20a *g, void *args); * - Update "in" and "out" indexes and dequeue message of length BUF_LEN such * that we wrap around the Queue while dequeuing the message using * nvgpu_queue_out() API. Check that the API returns "BUF_LEN". + * - Do fault injection so that immediate call to nvgpu_queue_out_locked() API + * would return error. + * - Invoke nvgpu_queue_out_locked() API and check that API returns -1 error. + * - Remove the injected fault. * - Uninitialize the allocated resources. * * Output: Returns PASS if the steps above were executed successfully. FAIL