diff --git a/drivers/gpu/nvgpu/common/mm/vm.c b/drivers/gpu/nvgpu/common/mm/vm.c index 73dd37bef..ca0b0a52b 100644 --- a/drivers/gpu/nvgpu/common/mm/vm.c +++ b/drivers/gpu/nvgpu/common/mm/vm.c @@ -148,6 +148,10 @@ int vm_aspace_id(struct vm_gk20a *vm) int nvgpu_vm_bind_channel(struct vm_gk20a *vm, struct nvgpu_channel *ch) { + if (ch == NULL) { + return -EINVAL; + } + nvgpu_log_fn(ch->g, " "); nvgpu_vm_get(vm); diff --git a/userspace/units/mm/vm/vm.c b/userspace/units/mm/vm/vm.c index 6203c2ad1..eba9e17fc 100644 --- a/userspace/units/mm/vm/vm.c +++ b/userspace/units/mm/vm/vm.c @@ -821,6 +821,15 @@ int test_vm_bind(struct unit_module *m, struct gk20a *g, void *__args) vm = create_test_vm(m, g); + /* Error testing */ + g->ops.mm.vm_bind_channel(vm, NULL); + if (channel->vm == vm) { + ret = UNIT_FAIL; + unit_err(m, "nvgpu_vm_bind_channel did not fail as expected.\n"); + goto exit; + } + + /* Succesfull call */ g->ops.mm.vm_bind_channel(vm, channel); if (channel->vm != vm) { @@ -831,6 +840,7 @@ int test_vm_bind(struct unit_module *m, struct gk20a *g, void *__args) ret = UNIT_SUCCESS; exit: + g->fifo.channel = NULL; free(channel); nvgpu_vm_put(vm); return ret; diff --git a/userspace/units/mm/vm/vm.h b/userspace/units/mm/vm/vm.h index a2f04255d..de05bfb7d 100644 --- a/userspace/units/mm/vm/vm.h +++ b/userspace/units/mm/vm/vm.h @@ -286,7 +286,7 @@ int test_nvgpu_vm_alloc_va(struct unit_module *m, struct gk20a *g, * * Description: This test targets the nvgpu_vm_bind_channel API. * - * Test Type: Feature + * Test Type: Feature, Error injection * * Targets: gops_mm.vm_bind_channel, nvgpu_vm_bind_channel * @@ -299,6 +299,8 @@ int test_nvgpu_vm_alloc_va(struct unit_module *m, struct gk20a *g, * - Address space size = 128GB * - Kernel reserved space size = 4GB * - Create an empty nvgpu_channel instance. + * - Call the nvgpu_vm_bind_channel with a NULL channel pointer and ensure it + * failed. * - Call the nvgpu_vm_bind_channel API with the empty channel instance. * - Ensure that after the call, the VM pointer in the nvgpu_channel structure * points to the VM in use in the test.